4910 lines
824 KiB
JavaScript
4910 lines
824 KiB
JavaScript
(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;color:#bf1d1d;box-sizing:border-box;overflow:hidden}.bim-engine-opt-btn-container{position:absolute;bottom:20px;left:50%;transform:translate(-50%);z-index:100}.bim-construct-tree-btn{position:absolute;top:20px;left:20px!important;z-index:100}.bim-btn-group-root{display:flex;gap:8px;z-index:1000;position:absolute;pointer-events:auto}.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;color:var(--bim-btn-text-color, #ccc);background-color:var(--bim-btn-bg, transparent);padding:6px;align-items:center;position:relative;justify-content:center}.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.active .opt-btn-icon{color:var(--bim-icon-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;box-sizing:border-box}.opt-btn-dropdown-item:hover{background-color:var(--bim-btn-hover-bg, #444);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}:root{--bim-dialog-bg: rgba(17, 17, 17, .95);--bim-dialog-header-bg: #2a2a2a;--bim-dialog-title-color: #fff;--bim-dialog-text-color: #ccc;--bim-dialog-border-color: #444}.bim-dialog{position:absolute;background-color:var(--bim-dialog-bg);border:1px solid var(--bim-dialog-border-color);border-radius:6px;box-shadow:0 4px 12px #0000004d;display:flex;flex-direction:column;z-index:10001;color:var(--bim-dialog-title-color);overflow:hidden;min-width:200px;min-height:100px;pointer-events:auto}.bim-dialog-header{height:32px;background-color:var(--bim-dialog-header-bg);display:flex;align-items:center;justify-content:space-between;padding:0 10px;cursor:default;-webkit-user-select:none;user-select:none;border-bottom:1px solid var(--bim-dialog-border-color);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:#999;line-height:1;margin-left:8px}.bim-dialog-close:hover{color:#fff}.bim-dialog-content{flex:1;overflow:auto;font-size:14px;color:var(--bim-dialog-text-color)}.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 #666;border-bottom:2px solid #666}.bim-dialog-resize-handle:hover:after{border-color:#fff}.bim-info-dialog-content{padding:16px;font-family:sans-serif;color:#333}.bim-info-dialog-content h3{margin-top:0;margin-bottom:12px;border-bottom:1px solid #eee;padding-bottom:8px;color:#0078d4}.bim-info-dialog-content ul{list-style:none;padding:0;margin:0}.bim-info-dialog-content li{margin-bottom:8px;font-size:14px;display:flex}.bim-info-dialog-content li strong{width:80px;color:#555}.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-ui_bg_color, #2b2d30);border-radius:4px;padding:4px 0;margin:0;list-style:none;min-width:160px;box-shadow:0 4px 12px #0003;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;-webkit-user-select:none;user-select:none;color:var(--bim-ui_text_primary, #ffffff)}.bim-menu-group{display:flex;flex-direction:column}.bim-menu-divider{height:1px;background-color:var(--bim-ui_border_color, #3e4145);margin:4px 0}.bim-menu-item{display:flex;align-items:center;padding:6px 12px;cursor:pointer;transition:background-color .2s;font-size:13px;position:relative;color:var(--bim-ui_text_primary, #ffffff)}.bim-menu-item:hover{background-color:var(--bim-ui_bg_hover, #3e4145)}.bim-menu-item.disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.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-ui_text_primary, #333);-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-ui_text_secondary, #999);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-ui_border_color, #d9d9d9);border-radius:4px;outline:none;font-size:13px;color:inherit;background-color:var(--bim-ui_bg_color, #fff);transition:all .2s;box-sizing:border-box}.bim-tree-search-input:focus{border-color:var(--bim-primary_color, #1890ff);box-shadow:0 0 0 2px #1890ff33}.bim-tree-search-results{position:absolute;top:100%;left:8px;right:8px;background-color:var(--bim-ui_bg_color, #fff);border:1px solid var(--bim-ui_border_color, #eee);box-shadow:0 4px 12px #00000026;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-ui_bg_hover, #f5f5f5)}.bim-tree-search-item-title{font-weight:500;display:block}.bim-tree-search-item-path{font-size:12px;color:var(--bim-ui_text_secondary, #999);margin-top:2px;display:block}.bim-tree-content{flex:1;overflow-y:auto;padding:2px 0;min-height:0}.bim-tree-node{display:flex;flex-direction:column}.bim-tree-node-content{display:flex;align-items:center;height:32px;cursor:pointer;transition:background-color .2s;border-radius:4px;padding-right:8px}.bim-tree-node-content:hover{background-color:var(--bim-ui_bg_hover, rgba(0, 0, 0, .05))}.bim-tree-switcher{width:24px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--bim-ui_text_secondary, #999);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-ui_border_color, #d9d9d9);border-radius:2px;margin-right:8px;background-color:var(--bim-ui_bg_color, #fff);position:relative;cursor:pointer;flex-shrink:0;transition:all .2s}.bim-tree-checkbox:hover{border-color:var(--bim-primary_color, #1890ff)}.bim-tree-checkbox.is-checked{background-color:var(--bim-primary_color, #1890ff);border-color:var(--bim-primary_color, #1890ff)}.bim-tree-checkbox.is-checked:after{content:"";position:absolute;top:1px;left:4px;width:5px;height:9px;border:2px solid #fff;border-top:0;border-left:0;transform:rotate(45deg)}.bim-tree-checkbox.is-indeterminate{background-color:var(--bim-ui_bg_color, #fff);border-color:var(--bim-primary_color, #1890ff)}.bim-tree-checkbox.is-indeterminate:after{content:"";position:absolute;top:6px;left:3px;width:8px;height:2px;background-color:var(--bim-primary_color, #1890ff)}.bim-tree-node.is-disabled .bim-tree-checkbox{background-color:#f5f5f5;border-color:#d9d9d9;cursor:not-allowed}.bim-tree-node.is-disabled .bim-tree-checkbox.is-checked{background-color:#d9d9d9}.bim-tree-node.is-disabled .bim-tree-node-content{color:var(--bim-ui_text_disabled, #ccc);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-ui_bg_selected, rgba(24, 144, 255, .2));color:var(--bim-primary_color, #1890ff)}.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:auto;padding:2px 0;min-height:0}.bim-tree-node{display:flex;flex-direction:column;width:fit-content;min-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:fit-content;min-width:100%;box-sizing:border-box}.bim-tab{display:flex;flex-direction:column;width:100%;height:100%;background:transparent;color:var(--bim-tab-text, #e6e6e6)}.bim-tab__nav{display:flex;align-items:center;justify-content:center;background:transparent}.bim-tab__item{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:4px 0;border:none;border-radius:0;background:transparent;color:var(--bim-tab-text, #e6e6e6);cursor:pointer;transition:all .2s ease;font-size:14px;border-bottom:4px solid transparent}.bim-tab__item:hover{color:var(--bim-tab-text, #e6e6e6);background-color:var(--bim-tab-hover-bg, rgba(255, 255, 255, .05));border-bottom-color:var(--bim-tab-hover-bg, rgba(255, 255, 255, .15))}.bim-tab__item.is-active{color:var(--bim-tab-text-active, #4da3ff);border-bottom-color:var(--bim-tab-text-active, #4da3ff)}.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-collapse{background-color:var(--bim-bg-color, #ffffff);border:1px solid var(--bim-border-color, #d9d9d9);border-radius:4px;font-size:14px;color:var(--bim-text-color, rgba(0, 0, 0, .88))}.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:transparent;padding-left:0;padding-right:0}.bim-collapse.is-ghost .bim-collapse-content{background-color:transparent;border-top:none}.bim-collapse-item{border-bottom:1px solid var(--bim-border-color, #d9d9d9)}.bim-collapse-item:last-child{border-bottom:none}.bim-collapse-item.is-disabled .bim-collapse-header{color:var(--bim-disabled-color, rgba(0, 0, 0, .25));cursor:not-allowed}.bim-collapse-header{display:flex;align-items:center;padding:12px 16px;background-color:var(--bim-header-bg-color, rgba(0, 0, 0, .02));cursor:pointer;transition:all .3s;position:relative}.bim-collapse-header:hover{background-color:var(--bim-header-hover-bg-color, rgba(0, 0, 0, .05))}.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-content-bg-color, #ffffff);border-top:1px solid var(--bim-border-color, #d9d9d9);transition:height .2s ease-in-out,opacity .2s ease-in-out}.bim-collapse-content.is-hidden{display:none}.bim-description{display:flex;flex-direction:column;width:100%;font-size:var(--bim-desc-font-size, 14px);color:var(--bim-text-color, #333);padding:0}.bim-description-item{display:flex;align-items:stretch;padding:0;line-height:1.5}.bim-description.is-bordered{border-bottom:none}.bim-description.is-bordered .bim-description-item{border-bottom:1px solid var(--bim-border-color, #eee)}.bim-description-label{color:var(--bim-desc-label-color, var(--bim-label-color, #666));flex-shrink:0;padding:var(--bim-desc-label-padding, 4px 4px);display:flex;align-items:center}.bim-description.is-bordered .bim-description-label{border-right:1px solid var(--bim-border-color, #eee)}.bim-description-value{color:var(--bim-desc-value-color, var(--bim-value-color, #333));flex:1;word-break:break-all;padding:var(--bim-desc-value-padding, 4px 4px);display:flex;align-items:center}.bim-measure-panel{width:100%;display:flex;flex-direction:column;box-sizing:border-box;color:var(--bim-dialog-text-color, #ccc)}.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-measure-border, rgba(255, 255, 255, .12));background:var(--bim-measure-btn-bg, rgba(255, 255, 255, .06));cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .15s ease,border-color .15s ease;padding:0;box-sizing:border-box}.bim-measure-tool-btn:hover{background:var(--bim-measure-btn-hover-bg, rgba(255, 255, 255, .1))}.bim-measure-tool-btn.is-active{border-color:var(--bim-measure-active-border, rgba(255, 255, 255, .3));background:var(--bim-measure-btn-active-bg, rgba(255, 255, 255, .14))}.bim-measure-tool-icon{width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;color:var(--bim-measure-icon-color, #ddd)}.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-measure-border, rgba(255, 255, 255, .12));background:var(--bim-measure-btn-bg, rgba(255, 255, 255, .06));cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:background-color .15s ease;padding:0 6px;gap:4px;font-size:12px;line-height:1}.bim-measure-toggle-btn:hover{background:var(--bim-measure-btn-hover-bg, rgba(255, 255, 255, .1))}.bim-measure-toggle-text{color:var(--bim-measure-label-color, rgba(255, 255, 255, .7))}.bim-measure-toggle-icon svg{width:14px;height:14px;fill:currentColor;color:var(--bim-measure-icon-color, #ddd);transition:transform .15s ease}.bim-measure-toggle-btn.is-expanded .bim-measure-toggle-icon svg{transform:rotate(180deg)}.bim-measure-result{margin-top:12px;padding-top:12px;border-top:1px solid var(--bim-measure-divider, rgba(255, 255, 255, .1));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-measure-label-color, rgba(255, 255, 255, .7));min-width:84px}.bim-measure-row .value{color:var(--bim-measure-value-color, rgba(255, 255, 255, .9));flex:1;word-break:break-word}.bim-measure-xyz{display:flex;flex-direction:column;gap:6px}.bim-measure-xyz .value{font-variant-numeric:tabular-nums}.bim-measure-footer{margin-top:12px;padding-top:10px;border-top:1px solid var(--bim-measure-divider, rgba(255, 255, 255, .1));display:flex;align-items:center;justify-content:flex-start;gap:10px}.bim-measure-clear-btn{background:transparent;border:none;color:var(--bim-measure-danger, white);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-measure-icon-color, #ddd)}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
||
(function(yr,ls){typeof exports=="object"&&typeof module<"u"?ls(exports):typeof define=="function"&&define.amd?define(["exports"],ls):(yr=typeof globalThis<"u"?globalThis:yr||self,ls(yr.LyzBimEngineSDK={}))})(this,(function(yr){"use strict";const ls={common:{title:"BimEngine",description:"这是一个使用 BIM-ENGINE。",openTestDialog:"打开测试弹窗",openInfoDialog:"打开信息弹窗 (封装版)"},toolbar:{home:"首页",measure:"测量",info:"信息",location:"定位",setting:"设置",walk:"漫游",walkMenu:"漫游菜单",walkPerson:"第一人称",walkBird:"第三人称",tree:"模型树"},dialog:{testTitle:"测试弹窗",testContent:'<div style="padding: 10px;">这是一个 <b>可拖拽</b> 且 <b>可缩放</b> 的弹窗。<br><br>你可以尝试拖动标题栏,或者拖动右下角改变大小。</div>'},menu:{info:"信息",home:"首页"},tree:{searchPlaceholder:"请输入要搜索的内容"},constructTree:{title:"目录树"},tab:{component:"构件",system:"系统",space:"空间"},panel:{property:{title:"构件详情",base:"基本属性",material:"材质信息",advanced:"高级设置",tab:{props:"属性",material:"材质"}}},measure:{btnName:"测量",dialogTitle:"测量",modes:{distance:"距离",minDistance:"最小距离",angle:"角度",elevation:"标高",volume:"体积",laserDistance:"激光测距",slope:"坡度",spaceVolume:"空间体积"},actions:{expand:"展开",collapse:"收起",clearAll:"删除全部",settings:"设置"},labels:{currentMode:"当前测量方式:",x:"X:",y:"Y:",z:"Z:",value:{distance:"距离:",minDistance:"最小距离:",angle:"角度:",elevation:"标高:",volume:"体积:",laserDistance:"激光测距:",slope:"坡度:",spaceVolume:"空间体积:"}},units:{mm:"mm",deg:"°",m3:"m³",percent:"%"}}},Gh={common:{title:"BimEngine",description:"This is a BIM-ENGINE demo.",openTestDialog:"Open Test Dialog",openInfoDialog:"Open Info Dialog (Wrapped)"},toolbar:{home:"Home",measure:"Measure",info:"Info",location:"Location",setting:"Settings",walk:"Walk",walkPerson:"Person",walkBird:"Bird Eye",walkMenu:"Menu",tree:"Tree"},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"},tree:{searchPlaceholder:"Please enter content to search"},constructTree:{title:"Construct Tree"},tab:{component:"Component",system:"System",space:"Space"},panel:{property:{title:"Component Details",base:"Basic Info",material:"Material",advanced:"Advanced",tab:{props:"Properties",material:"Material"}}},measure:{btnName:"Measure",dialogTitle:"Measure",modes:{distance:"Distance",minDistance:"Min Distance",angle:"Angle",elevation:"Elevation",volume:"Volume",laserDistance:"Laser Distance",slope:"Slope",spaceVolume:"Space Volume"},actions:{expand:"Expand",collapse:"Collapse",clearAll:"Clear All",settings:"Settings"},labels:{currentMode:"Mode:",x:"X:",y:"Y:",z:"Z:",value:{distance:"Distance:",minDistance:"Min Distance:",angle:"Angle:",elevation:"Elevation:",volume:"Volume:",laserDistance:"Laser Distance:",slope:"Slope:",spaceVolume:"Space Volume:"}},units:{mm:"mm",deg:"°",m3:"m³",percent:"%"}}};class Wh{currentLocale="zh-CN";messages={"zh-CN":ls,"en-US":Gh};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 i=this.messages[this.currentLocale];for(const r of t)if(i&&typeof i=="object"&&r in i)i=i[r];else return e;return i}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}notifyListeners(){this.listeners.forEach(e=>e(this.currentLocale))}}const ri=new Wh,gt=s=>ri.t(s),sl={name:"dark",primary:"#0078d4",primaryHover:"#0063b1",background:"#f5f5f5",panelBackground:"rgba(30, 30, 30, 0.9)",textPrimary:"#ffffff",textSecondary:"#cccccc",border:"#444444",icon:"#cccccc",iconActive:"#ffffff",componentBackground:"transparent",componentHover:"#4e4d4dff",componentActive:"rgba(255, 255, 255, 0.1)"},jh={name:"light",primary:"#0078d4",primaryHover:"#106ebe",background:"#f5f5f5",panelBackground:"#ffffff",textPrimary:"#333333",textSecondary:"#666666",border:"#e0e0e0",icon:"#555555",iconActive:"#0078d4",componentBackground:"transparent",componentHover:"#f0f0f0",componentActive:"#e0e0e0"};class Xh{currentTheme=sl;listeners=[];constructor(){}getTheme(){return this.currentTheme}setTheme(e){e==="light"?this.applyTheme(jh):this.applyTheme(sl)}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 vt=new Xh;class Fn{container;options;groups=[];activeBtnIds=new Set;btnRefs=new Map;dropdownElement=null;hoverTimeout=null;customColors=new Set;unsubscribeLocale=null;unsubscribeTheme=null;engine=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(r=>{e[r]&&this.customColors.add(r)}),this.initContainer(),this.applyStyles()}setEngine(e){this.engine=e}emit(e,t){this.engine?this.engine.emit(e,t):console.warn("[BimButtonGroup] Engine not set, cannot emit event:",e)}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.updatePosition(),this.setupEventInterception(this.container)}setupEventInterception(e){const t=r=>{r.stopPropagation()};["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(r=>{e.addEventListener(r,t,{passive:!1})})}updatePosition(){const e=this.options.position,t=this.container.style;if(t.top="",t.bottom="",t.left="",t.right="",t.transform="",e==="static"){this.container.classList.add("static");return}if(this.container.classList.remove("static"),this.container.style.position="absolute",typeof e=="object"&&"x"in e)t.left=`${e.x}px`,t.top=`${e.y}px`;else{const i="20px";switch(e){case"top-left":t.top=i,t.left=i;break;case"top-center":t.top=i,t.left="50%",t.transform="translateX(-50%)";break;case"top-right":t.top=i,t.right=i;break;case"bottom-left":t.bottom=i,t.left=i;break;case"bottom-center":t.bottom=i,t.left="50%",t.transform="translateX(-50%)";break;case"bottom-right":t.bottom=i,t.right=i;break;case"left-center":t.left=i,t.top="50%",t.transform="translateY(-50%)";break;case"right-center":t.right=i,t.top="50%",t.transform="translateY(-50%)";break;case"center":t.top="50%",t.left="50%",t.transform="translate(-50%, -50%)";break}}}applyStyles(){const e=this.container.style;this.options.backgroundColor&&e.setProperty("--bim-btn-group-section-bg",this.options.backgroundColor),this.options.btnBackgroundColor&&e.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&e.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&e.setProperty("--bim-btn-active-bg",this.options.btnActiveColor),this.options.iconColor&&e.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&e.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&e.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&e.setProperty("--bim-btn-text-active-color",this.options.textActiveColor)}setTheme(e){const t={backgroundColor:e.panelBackground,btnBackgroundColor:e.componentBackground,btnHoverColor:e.componentHover,btnActiveColor:e.componentActive,iconColor:e.icon,iconActiveColor:e.iconActive,textColor:e.textSecondary,textActiveColor:e.textPrimary};Object.entries(t).forEach(([i,r])=>{const n=i;this.customColors.has(n)||(this.options[n]=r)}),this.applyStyles()}setColors(e){this.options={...this.options,...e},Object.keys(e).forEach(t=>{this.customColors.add(t)}),this.applyStyles()}async init(){this.render(),this.unsubscribeLocale=ri.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=vt.subscribe(e=>{this.setTheme(e)})}setLocales(){this.render()}addGroup(e,t){if(this.groups.some(r=>r.id===e))return;const i={id:e,buttons:[]};if(t){const r=this.groups.findIndex(n=>n.id===t);r!==-1?this.groups.splice(r,0,i):this.groups.push(i)}else this.groups.push(i)}addButton(e){const{groupId:t,parentId:i}=e,r=this.groups.find(a=>a.id===t);if(!r)return;const n={...e,children:e.children||[]};if(i){const a=this.findButton(r.buttons,i);a&&(a.children||(a.children=[]),a.children.push(n))}else r.buttons.push(n)}findButton(e,t){for(const i of e){if(i.id===t)return i;if(i.children){const r=this.findButton(i.children,t);if(r)return r}}}render(){this.container.innerHTML="",this.btnRefs.clear(),this.groups.forEach((e,t)=>{const i=this.renderGroup(e,t,this.groups.length);this.container.appendChild(i)})}renderGroup(e,t,i){const r=document.createElement("div");return r.className="bim-btn-group-section",t<i-1&&r.classList.add("has-divider"),e.buttons.forEach(n=>{if(this.isVisible(n.id)){const a=this.renderButton(n);r.appendChild(a)}}),r}renderButton(e){const t=document.createElement("div");t.className="opt-btn-wrapper";const i=document.createElement("div");i.className="opt-btn",e.isActive&&this.activeBtnIds.add(e.id),(e.align||this.options.align||"vertical")==="horizontal"?i.classList.add("align-horizontal"):i.classList.add("align-vertical"),this.activeBtnIds.has(e.id)&&i.classList.add("active"),e.disabled&&i.classList.add("disabled"),this.options.showLabel&&e.label||i.classList.add("no-label");const a=e.iconSize||32,o=e.minWidth||50;i.style.minWidth=`${o}px`;const l=document.createElement("div");l.className="opt-btn-icon",l.style.width=`${a}px`,l.style.height=`${a}px`,l.innerHTML=this.getIcon(e.icon),i.appendChild(l);const c=document.createElement("div");if(c.className="opt-btn-text-wrapper",this.options.showLabel&&e.label){const h=document.createElement("span");h.className="opt-btn-label",h.textContent=gt(e.label),c.appendChild(h)}if(e.children&&e.children.length>0){const h=document.createElement("span");h.className="opt-btn-arrow",h.textContent="▼",c.appendChild(h)}return c.hasChildNodes()&&i.appendChild(c),i.addEventListener("click",()=>this.handleClick(e)),i.addEventListener("mouseenter",()=>this.handleMouseEnter(e,i)),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.btnRefs.set(e.id,i),t.appendChild(i),t}setBtnActive(e,t){const i=this.findButtonById(e);if(!i)return;const r=t!==void 0?t:!this.activeBtnIds.has(e);r?this.activeBtnIds.add(e):this.activeBtnIds.delete(e),i.isActive=r,this.updateButtonState(e)}handleClick(e){e.disabled||(!e.children||e.children.length===0)&&(e.keepActive&&this.setBtnActive(e.id),this.closeDropdown(),e.onClick&&e.onClick(e))}handleMouseEnter(e,t){this.hoverTimeout&&clearTimeout(this.hoverTimeout),e.children&&e.children.length>0?this.showDropdown(e,t):this.closeDropdown()}handleMouseLeave(){this.hoverTimeout=window.setTimeout(()=>this.closeDropdown(),200)}showDropdown(e,t){if(this.closeDropdown(),!e.children)return;const i=document.createElement("div");i.className="opt-btn-dropdown",this.options.backgroundColor&&i.style.setProperty("--bim-toolbar-bg",this.options.backgroundColor);const r=t.getBoundingClientRect(),n=this.options.expand||"down";this.options.direction==="row"?i.style.flexDirection="column":i.style.flexDirection="row",document.body.appendChild(i),this.setupEventInterception(i),e.children.forEach(o=>{if(this.isVisible(o.id)){const l=this.renderDropdownItem(o);i.appendChild(l)}});const a=i.getBoundingClientRect();n==="up"?(i.style.bottom=window.innerHeight-r.top+8+"px",i.style.left=r.left+(r.width-a.width)/2+"px"):n==="down"?(i.style.top=r.bottom+8+"px",i.style.left=r.left+(r.width-a.width)/2+"px"):n==="right"?(i.style.top=r.top+(r.height-a.height)/2+"px",i.style.left=r.right+8+"px"):n==="left"&&(i.style.top=r.top+(r.height-a.height)/2+"px",i.style.right=window.innerWidth-r.left+8+"px"),i.addEventListener("mouseenter",()=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout)}),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.dropdownElement=i}renderDropdownItem(e){const t=document.createElement("div");t.className="opt-btn-dropdown-item",(e.align||"horizontal")==="horizontal"?t.classList.add("align-horizontal"):t.classList.add("align-vertical");const r=e.iconSize||32,n=e.minWidth;n&&(t.style.minWidth=`${n}px`);const a=document.createElement("div");if(a.className="opt-btn-icon",a.style.width=`${r}px`,a.style.height=`${r}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=gt(e.label),t.appendChild(o)}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}updateButtonVisibility(e,t){this.options.visibility||(this.options.visibility={}),this.options.visibility[e]=t,this.render()}setShowLabel(e){this.options.showLabel=e,this.updateLabelsVisibility()}updateLabelsVisibility(){this.btnRefs.forEach((e,t)=>{const i=this.findButtonById(t);if(!i)return;this.options.showLabel&&i.label?e.classList.remove("no-label"):e.classList.add("no-label")})}findButtonById(e){for(const t of this.groups){const i=this.findButton(t.buttons,e);if(i)return i}}setBackgroundColor(e){this.setColors({backgroundColor:e})}isVisible(e){return this.options.visibility?.[e]!==!1}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeDropdown(),this.container.innerHTML="",this.btnRefs.clear()}}class qh extends Fn{async init(){await super.init();const{createHomeButton:e}=await Promise.resolve().then(()=>n1),{locationButton:t}=await Promise.resolve().then(()=>a1),{walkMenuButton:i}=await Promise.resolve().then(()=>o1),{walkPersonButton:r}=await Promise.resolve().then(()=>l1),{walkBirdButton:n}=await Promise.resolve().then(()=>c1),{settingButton:a}=await Promise.resolve().then(()=>h1),{infoButton:o}=await Promise.resolve().then(()=>u1),{createMeasureButton:l}=await Promise.resolve().then(()=>d1);this.addGroup("group-1"),this.engine?(this.addButton(e(this.engine)),this.addButton(l(this.engine))):console.warn("[Toolbar] Engine not available when creating buttons."),this.addButton(i),this.addButton(r),this.addButton(n),this.addButton(t),this.addGroup("group-2"),this.addButton(a),this.addButton(o),this.render()}}class ji{engine;constructor(e){this.engine=e}emit(e,t){this.engine.emit(e,t)}on(e,t){return this.engine.on(e,t)}}class Yh extends ji{toolbar=null;toolbarContainer=null;container;constructor(e,t){super(e),this.container=t,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 qh({container:this.toolbarContainer,showLabel:!0,direction:"row",position:"bottom-center",align:"vertical",expand:"up"}),this.toolbar.setEngine(this.engine),this.toolbar.init()}updateTheme(e){this.toolbar?.setTheme(e)}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null}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)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}}class Kh extends ji{groups=new Map;container;constructor(e,t){super(e),this.container=t}create(e,t){const i=new Fn({container:this.container,...t});return i.setEngine(this.engine),i.init(),this.groups.set(e,i),i}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()}}class nl{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.panelBackground),this.options.headerBackgroundColor||t.setProperty("--bim-dialog-header-bg",e.componentHover),this.options.titleColor||t.setProperty("--bim-dialog-title-color",e.textPrimary),this.options.textColor||t.setProperty("--bim-dialog-text-color",e.textPrimary),this.options.borderColor||t.setProperty("--bim-dialog-border-color",e.border)}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=vt.subscribe(e=>{this.setTheme(e)}),this.unsubscribeLocale=ri.subscribe(()=>{this.setLocales()}))}setLocales(){if(this.options.title){const e=this.header.querySelector(".bim-dialog-title");e&&(e.textContent=gt(this.options.title))}}createDom(){const e=document.createElement("div");e.className="bim-dialog",this.options.id&&(e.id=this.options.id);const t=e.style;this.options.backgroundColor&&t.setProperty("--bim-dialog-bg",this.options.backgroundColor),this.options.headerBackgroundColor&&t.setProperty("--bim-dialog-header-bg",this.options.headerBackgroundColor),this.options.titleColor&&t.setProperty("--bim-dialog-title-color",this.options.titleColor),this.options.textColor&&t.setProperty("--bim-dialog-text-color",this.options.textColor),this.options.borderColor&&t.setProperty("--bim-dialog-border-color",this.options.borderColor),this.setSize(e,this.options.width,this.options.height),this.options.minWidth&&(e.style.minWidth=`${this.options.minWidth}px`);const i=document.createElement("div");i.className="bim-dialog-header",this.options.draggable&&i.classList.add("draggable");const r=document.createElement("span");r.className="bim-dialog-title",r.textContent=this.options.title?gt(this.options.title):"";const n=document.createElement("span");n.className="bim-dialog-close",n.innerHTML="×",n.onclick=()=>{this.close()},i.appendChild(r),i.appendChild(n);const a=document.createElement("div");if(a.className="bim-dialog-content",typeof this.options.content=="string"?a.innerHTML=this.options.content:this.options.content instanceof HTMLElement&&a.appendChild(this.options.content),e.appendChild(i),e.appendChild(a),this.options.resizable){const c=document.createElement("div");c.className="bim-dialog-resize-handle",e.appendChild(c)}const o=c=>{c.stopPropagation()};return["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(c=>{e.addEventListener(c,o,{passive:!1})}),e}setSize(e,t,i){t!==void 0&&(t==="auto"||t==="fit-content"?e.style.width=t:e.style.width=typeof t=="number"?`${t}px`:t),i!==void 0&&(i==="auto"||i==="fit-content"?e.style.height=i:e.style.height=typeof i=="number"?`${i}px`:i)}fitWidth(e=!1){this.element.style.width="fit-content",e&&this.initPosition()}fitHeight(e=!1){this.element.style.height="auto";const t=this.element.getBoundingClientRect().height,i=this.options.minHeight??100,r=this.container.clientHeight||0;let n=Math.max(i,t);r>0&&(n=Math.min(n,r)),this.element.style.height=`${n}px`,e?this.initPosition():this.clampToContainer()}clampToContainer(){const e=this.container.clientWidth,t=this.container.clientHeight,i=this.element.offsetWidth,r=this.element.offsetHeight,n=this.element.offsetLeft,a=this.element.offsetTop,o=Math.max(0,e-i),l=Math.max(0,t-r),c=Math.max(0,Math.min(n,o)),h=Math.max(0,Math.min(a,l));this.element.style.left=`${c}px`,this.element.style.top=`${h}px`}initPosition(){const e=this.options.position,t=this.element.getBoundingClientRect();let i=0,r=0;const n=this.container.clientWidth,a=this.container.clientHeight,o=t.width,l=t.height;if(typeof e=="object"&&"x"in e)i=e.x,r=e.y;else switch(e){case"center":i=(n-o)/2,r=(a-l)/2;break;case"top-left":i=0,r=0;break;case"top-center":i=(n-o)/2,r=0;break;case"top-right":i=n-o,r=0;break;case"left-center":i=0,r=(a-l)/2;break;case"right-center":i=n-o,r=(a-l)/2;break;case"bottom-left":i=0,r=a-l;break;case"bottom-center":i=(n-o)/2,r=a-l;break;case"bottom-right":i=n-o,r=a-l;break;default:i=(n-o)/2,r=(a-l)/2}i=Math.max(0,Math.min(i,n-o)),r=Math.max(0,Math.min(r,a-l)),this.element.style.left=`${i}px`,this.element.style.top=`${r}px`}initDrag(){let e=0,t=0,i=0,r=0,n=0,a=0,o=0,l=0;const c=d=>{d.preventDefault(),d.stopPropagation(),e=d.clientX,t=d.clientY,i=this.element.offsetLeft,r=this.element.offsetTop,n=this.container.clientWidth,a=this.container.clientHeight,o=this.element.offsetWidth,l=this.element.offsetHeight,document.addEventListener("mousemove",h,{capture:!0}),document.addEventListener("mouseup",u,{capture:!0})},h=d=>{d.preventDefault(),d.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const m=d.clientX-e,g=d.clientY-t;let v=i+m,f=r+g;const p=n-o,y=a-l;v=Math.max(0,Math.min(v,p)),f=Math.max(0,Math.min(f,y)),this.element.style.left=`${v}px`,this.element.style.top=`${f}px`,this.rafId=null}))},u=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",h,{capture:!0}),document.removeEventListener("mouseup",u,{capture:!0})};this.header.addEventListener("mousedown",c)}initResize(){const e=this.element.querySelector(".bim-dialog-resize-handle");if(!e)return;let t=0,i=0,r=0,n=0;const a=c=>{c.preventDefault(),c.stopPropagation(),t=c.clientX,i=c.clientY,r=this.element.offsetWidth,n=this.element.offsetHeight,document.addEventListener("mousemove",o,{capture:!0}),document.addEventListener("mouseup",l,{capture:!0})},o=c=>{c.preventDefault(),c.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const h=c.clientX-t,u=c.clientY-i,d=Math.max(this.options.minWidth||100,r+h),m=Math.max(this.options.minHeight||50,n+u);this.element.style.width=`${d}px`,this.element.style.height=`${m}px`,this.rafId=null}))},l=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",o,{capture:!0}),document.removeEventListener("mouseup",l,{capture:!0})};e.addEventListener("mousedown",a)}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 Zh extends nl{constructor(e){const t=document.createElement("div");t.className="bim-info-dialog-content";const i=document.createElement("h3");i.textContent="Model Information";const r=document.createElement("ul");r.innerHTML=`
|
||
<li><strong>Name:</strong> Sample Project</li>
|
||
<li><strong>Version:</strong> 1.0.0</li>
|
||
<li><strong>Date:</strong> ${new Date().toLocaleDateString()}</li>
|
||
<li><strong>Status:</strong> <span style="color: green;">Active</span></li>
|
||
`;const n=document.createElement("button");n.textContent="Update Status",n.style.marginTop="10px",n.onclick=()=>{alert("Status updated!")},t.appendChild(i),t.appendChild(r),t.appendChild(n),super({container:e,title:"dialog.testTitle",content:t,width:320,height:"auto",position:"center",resizable:!0,draggable:!0,onClose:()=>{console.log("Info dialog closed")},onOpen:()=>{console.log("Info dialog opened")}})}}class $h extends ji{container;activeDialogs=[];constructor(e,t){super(e),this.container=t,this.on("ui:open-dialog",i=>{console.log("[DialogManager] Received open-dialog event:",i),i.id==="info"&&this.showInfoDialog()})}create(e){const t=new nl({container:this.container,...e,onClose:()=>{this.activeDialogs=this.activeDialogs.filter(i=>i!==t),e.onClose&&e.onClose()}});return t.setTheme(vt.getTheme()),this.activeDialogs.push(t),t}showInfoDialog(){new Zh(this.container)}updateTheme(e){this.activeDialogs.forEach(t=>{t.setTheme&&t.setTheme(e)})}destroy(){this.activeDialogs.forEach(e=>e.destroy()),this.activeDialogs=[]}}const br={ROTATE:0,DOLLY:1,PAN:2},Mr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Jh=0,al=1,Qh=2,ol=1,ll=2,Di=3,bi=0,Ft=1,Gt=2,xt=0,Tr=1,Bs=2,cl=3,hl=4,ul=5,si=100,eu=101,tu=102,iu=103,ru=104,cs=200,su=201,nu=202,au=203,kn=204,zn=205,Hn=206,ou=207,Vn=208,lu=209,cu=210,hu=211,uu=212,du=213,pu=214,Gn=0,Wn=1,jn=2,Sr=3,Xn=4,qn=5,Yn=6,Kn=7,Zn=0,mu=1,fu=2,Xi=0,dl=1,pl=2,ml=3,$n=4,fl=5,gl=6,vl=7,_l="attached",gu="detached",xl=300,Er=301,wr=302,Fs=303,Jn=304,ks=306,Mi=1e3,$t=1001,zs=1002,Dt=1003,yl=1004,hs=1005,yt=1006,Hs=1007,Ti=1008,ni=1009,bl=1010,Ml=1011,us=1012,Qn=1013,ar=1014,Wt=1015,pt=1016,ea=1017,ta=1018,Cr=1020,Tl=35902,Sl=35899,El=1021,wl=1022,qt=1023,ds=1026,Rr=1027,ia=1028,ra=1029,sa=1030,na=1031,aa=1033,Vs=33776,Gs=33777,Ws=33778,js=33779,oa=35840,la=35841,ca=35842,ha=35843,ua=36196,da=37492,pa=37496,ma=37808,fa=37809,ga=37810,va=37811,_a=37812,xa=37813,ya=37814,ba=37815,Ma=37816,Ta=37817,Sa=37818,Ea=37819,wa=37820,Ca=37821,Ra=36492,Aa=36494,Pa=36495,La=36283,Da=36284,Ia=36285,Ua=36286,ps=2300,ms=2301,Na=2302,Cl=2400,Rl=2401,Al=2402,vu=2500,_u=0,Pl=1,Oa=2,xu=3200,Ll=3201,Xs=0,yu=1,qi="",Ct="srgb",Nt="srgb-linear",qs="linear",et="srgb",Ar=7680,Ba=34055,Fa=34056,bu=517,ka=519,Mu=512,Tu=513,Su=514,Dl=515,Eu=516,wu=517,Cu=518,Ru=519,za=35044,Il="300 es",Si=2e3,Ys=2001;function Ul(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function fs(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Au(){const s=fs("canvas");return s.style.display="block",s}const Nl={};function Ks(...s){const e="THREE."+s.shift();console.log(e,...s)}function be(...s){const e="THREE."+s.shift();console.warn(e,...s)}function He(...s){const e="THREE."+s.shift();console.error(e,...s)}function gs(...s){const e=s.join(" ");e in Nl||(Nl[e]=!0,be(...s))}function Pu(s,e,t){return new Promise(function(i,r){function n(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:r();break;case s.TIMEOUT_EXPIRED:setTimeout(n,t);break;default:i()}}setTimeout(n,t)})}class or{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const n=r.indexOf(t);n!==-1&&r.splice(n,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let n=0,a=r.length;n<a;n++)r[n].call(this,e);e.target=null}}}const Ot=["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 Ol=1234567;const vs=Math.PI/180,Pr=180/Math.PI;function ai(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Ot[s&255]+Ot[s>>8&255]+Ot[s>>16&255]+Ot[s>>24&255]+"-"+Ot[e&255]+Ot[e>>8&255]+"-"+Ot[e>>16&15|64]+Ot[e>>24&255]+"-"+Ot[t&63|128]+Ot[t>>8&255]+"-"+Ot[t>>16&255]+Ot[t>>24&255]+Ot[i&255]+Ot[i>>8&255]+Ot[i>>16&255]+Ot[i>>24&255]).toLowerCase()}function Fe(s,e,t){return Math.max(e,Math.min(t,s))}function Ha(s,e){return(s%e+e)%e}function Lu(s,e,t,i,r){return i+(s-e)*(r-i)/(t-e)}function Du(s,e,t){return s!==e?(t-s)/(e-s):0}function _s(s,e,t){return(1-t)*s+t*e}function Iu(s,e,t,i){return _s(s,e,1-Math.exp(-t*i))}function Uu(s,e=1){return e-Math.abs(Ha(s,e*2)-e)}function Nu(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Ou(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Bu(s,e){return s+Math.floor(Math.random()*(e-s+1))}function Fu(s,e){return s+Math.random()*(e-s)}function ku(s){return s*(.5-Math.random())}function zu(s){s!==void 0&&(Ol=s);let e=Ol+=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 Hu(s){return s*vs}function Vu(s){return s*Pr}function Gu(s){return(s&s-1)===0&&s!==0}function Wu(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function ju(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Xu(s,e,t,i,r){const n=Math.cos,a=Math.sin,o=n(t/2),l=a(t/2),c=n((e+i)/2),h=a((e+i)/2),u=n((e-i)/2),d=a((e-i)/2),m=n((i-e)/2),g=a((i-e)/2);switch(r){case"XYX":s.set(o*h,l*u,l*d,o*c);break;case"YZY":s.set(l*d,o*h,l*u,o*c);break;case"ZXZ":s.set(l*u,l*d,o*h,o*c);break;case"XZX":s.set(o*h,l*g,l*m,o*c);break;case"YXY":s.set(l*m,o*h,l*g,o*c);break;case"ZYZ":s.set(l*g,l*m,o*h,o*c);break;default:be("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function oi(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 tt(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 Va={DEG2RAD:vs,RAD2DEG:Pr,generateUUID:ai,clamp:Fe,euclideanModulo:Ha,mapLinear:Lu,inverseLerp:Du,lerp:_s,damp:Iu,pingpong:Uu,smoothstep:Nu,smootherstep:Ou,randInt:Bu,randFloat:Fu,randFloatSpread:ku,seededRandom:zu,degToRad:Hu,radToDeg:Vu,isPowerOfTwo:Gu,ceilPowerOfTwo:Wu,floorPowerOfTwo:ju,setQuaternionFromProperEuler:Xu,normalize:tt,denormalize:oi};class oe{constructor(e=0,t=0){oe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Fe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*r+e.x,this.y=n*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class li{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,n,a,o){let l=i[r+0],c=i[r+1],h=i[r+2],u=i[r+3],d=n[a+0],m=n[a+1],g=n[a+2],v=n[a+3];if(o<=0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(o>=1){e[t+0]=d,e[t+1]=m,e[t+2]=g,e[t+3]=v;return}if(u!==v||l!==d||c!==m||h!==g){let f=l*d+c*m+h*g+u*v;f<0&&(d=-d,m=-m,g=-g,v=-v,f=-f);let p=1-o;if(f<.9995){const y=Math.acos(f),_=Math.sin(y);p=Math.sin(p*y)/_,o=Math.sin(o*y)/_,l=l*p+d*o,c=c*p+m*o,h=h*p+g*o,u=u*p+v*o}else{l=l*p+d*o,c=c*p+m*o,h=h*p+g*o,u=u*p+v*o;const y=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=y,c*=y,h*=y,u*=y}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,r,n,a){const o=i[r],l=i[r+1],c=i[r+2],h=i[r+3],u=n[a],d=n[a+1],m=n[a+2],g=n[a+3];return e[t]=o*g+h*u+l*m-c*d,e[t+1]=l*g+h*d+c*u-o*m,e[t+2]=c*g+h*m+o*d-l*u,e[t+3]=h*g-o*u-l*d-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,n=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(r/2),u=o(n/2),d=l(i/2),m=l(r/2),g=l(n/2);switch(a){case"XYZ":this._x=d*h*u+c*m*g,this._y=c*m*u-d*h*g,this._z=c*h*g+d*m*u,this._w=c*h*u-d*m*g;break;case"YXZ":this._x=d*h*u+c*m*g,this._y=c*m*u-d*h*g,this._z=c*h*g-d*m*u,this._w=c*h*u+d*m*g;break;case"ZXY":this._x=d*h*u-c*m*g,this._y=c*m*u+d*h*g,this._z=c*h*g+d*m*u,this._w=c*h*u-d*m*g;break;case"ZYX":this._x=d*h*u-c*m*g,this._y=c*m*u+d*h*g,this._z=c*h*g-d*m*u,this._w=c*h*u+d*m*g;break;case"YZX":this._x=d*h*u+c*m*g,this._y=c*m*u+d*h*g,this._z=c*h*g-d*m*u,this._w=c*h*u-d*m*g;break;case"XZY":this._x=d*h*u-c*m*g,this._y=c*m*u-d*h*g,this._z=c*h*g+d*m*u,this._w=c*h*u+d*m*g;break;default:be("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],n=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=i+o+u;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(h-l)*m,this._y=(n-c)*m,this._z=(a-r)*m}else if(i>o&&i>u){const m=2*Math.sqrt(1+i-o-u);this._w=(h-l)/m,this._x=.25*m,this._y=(r+a)/m,this._z=(n+c)/m}else if(o>u){const m=2*Math.sqrt(1+o-i-u);this._w=(n-c)/m,this._x=(r+a)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+u-i-o);this._w=(a-r)/m,this._x=(n+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Fe(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,n=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+r*c-n*l,this._y=r*h+a*l+n*o-i*c,this._z=n*h+a*c+i*l-r*o,this._w=a*h-i*o-r*l-n*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,r=e._y,n=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,n=-n,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+n*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+n*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),n*Math.sin(t),n*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class w{constructor(e=0,t=0,i=0){w.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Bl.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Bl.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=e.elements,a=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),h=2*(o*t-n*r),u=2*(n*i-a*t);return this.x=t+l*c+a*u-o*h,this.y=i+l*h+o*c-n*u,this.z=r+l*u+n*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this.z=Fe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this.z=Fe(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,n=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-n*o,this.y=n*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Ga.copy(this).projectOnVector(e),this.sub(Ga)}reflect(e){return this.sub(Ga.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Fe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ga=new w,Bl=new li;class Be{constructor(e,t,i,r,n,a,o,l,c){Be.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,c)}set(e,t,i,r,n,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=n,h[5]=l,h[6]=i,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],u=i[7],d=i[2],m=i[5],g=i[8],v=r[0],f=r[3],p=r[6],y=r[1],_=r[4],E=r[7],R=r[2],T=r[5],A=r[8];return n[0]=a*v+o*y+l*R,n[3]=a*f+o*_+l*T,n[6]=a*p+o*E+l*A,n[1]=c*v+h*y+u*R,n[4]=c*f+h*_+u*T,n[7]=c*p+h*E+u*A,n[2]=d*v+m*y+g*R,n[5]=d*f+m*_+g*T,n[8]=d*p+m*E+g*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*n*h+i*o*l+r*n*c-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*n,m=c*n-a*l,g=t*u+i*d+r*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return e[0]=u*v,e[1]=(r*c-h*i)*v,e[2]=(o*i-r*a)*v,e[3]=d*v,e[4]=(h*t-r*l)*v,e[5]=(r*n-o*t)*v,e[6]=m*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*n)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,n,a,o){const l=Math.cos(n),c=Math.sin(n);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Wa.makeScale(e,t)),this}rotate(e){return this.premultiply(Wa.makeRotation(-e)),this}translate(e,t){return this.premultiply(Wa.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Wa=new Be,Fl=new Be().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),kl=new Be().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function qu(){const s={enabled:!0,workingColorSpace:Nt,spaces:{},convert:function(r,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===et&&(r.r=Ii(r.r),r.g=Ii(r.g),r.b=Ii(r.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[n].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===et&&(r.r=Lr(r.r),r.g=Lr(r.g),r.b=Lr(r.b))),r},workingToColorSpace:function(r,n){return this.convert(r,this.workingColorSpace,n)},colorSpaceToWorking:function(r,n){return this.convert(r,n,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===qi?qs:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,n=this.workingColorSpace){return r.fromArray(this.spaces[n].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,n,a){return r.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,n){return gs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(r,n)},toWorkingColorSpace:function(r,n){return gs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(r,n)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[Nt]:{primaries:e,whitePoint:i,transfer:qs,toXYZ:Fl,fromXYZ:kl,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ct},outputColorSpaceConfig:{drawingBufferColorSpace:Ct}},[Ct]:{primaries:e,whitePoint:i,transfer:et,toXYZ:Fl,fromXYZ:kl,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ct}}}),s}const je=qu();function Ii(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Lr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Dr;class Yu{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Dr===void 0&&(Dr=fs("canvas")),Dr.width=e.width,Dr.height=e.height;const r=Dr.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Dr}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=fs("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),n=r.data;for(let a=0;a<n.length;a++)n[a]=Ii(n[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Ii(t[i]/255)*255):t[i]=Ii(t[i]);return{data:t,width:e.width,height:e.height}}else return be("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Ku=0;class ja{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ku++}),this.uuid=ai(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let n;if(Array.isArray(r)){n=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?n.push(Xa(r[a].image)):n.push(Xa(r[a]))}else n=Xa(r);i.url=n}return t||(e.images[this.uuid]=i),i}}function Xa(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?Yu.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(be("Texture: Unable to serialize Texture."),{})}let Zu=0;const qa=new w;class Rt extends or{constructor(e=Rt.DEFAULT_IMAGE,t=Rt.DEFAULT_MAPPING,i=$t,r=$t,n=yt,a=Ti,o=qt,l=ni,c=Rt.DEFAULT_ANISOTROPY,h=qi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Zu++}),this.uuid=ai(),this.name="",this.source=new ja(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=n,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new oe(0,0),this.repeat=new oe(1,1),this.center=new oe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Be,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(qa).x}get height(){return this.source.getSize(qa).y}get depth(){return this.source.getSize(qa).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){be(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){be(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==xl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Mi:e.x=e.x-Math.floor(e.x);break;case $t:e.x=e.x<0?0:1;break;case zs: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 Mi:e.y=e.y-Math.floor(e.y);break;case $t:e.y=e.y<0?0:1;break;case zs: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++}}Rt.DEFAULT_IMAGE=null,Rt.DEFAULT_MAPPING=xl,Rt.DEFAULT_ANISOTROPY=1;class Ke{constructor(e=0,t=0,i=0,r=1){Ke.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*n,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*n,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*n,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,n;const a=e.elements,o=a[0],l=a[4],c=a[8],h=a[1],u=a[5],d=a[9],m=a[2],g=a[6],v=a[10];if(Math.abs(l-h)<.01&&Math.abs(c-m)<.01&&Math.abs(d-g)<.01){if(Math.abs(l+h)<.1&&Math.abs(c+m)<.1&&Math.abs(d+g)<.1&&Math.abs(o+u+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const p=(o+1)/2,y=(u+1)/2,_=(v+1)/2,E=(l+h)/4,R=(c+m)/4,T=(d+g)/4;return p>y&&p>_?p<.01?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(p),r=E/i,n=R/i):y>_?y<.01?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(y),i=E/r,n=T/r):_<.01?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(_),i=R/n,r=T/n),this.set(i,r,n,t),this}let f=Math.sqrt((g-d)*(g-d)+(c-m)*(c-m)+(h-l)*(h-l));return Math.abs(f)<.001&&(f=1),this.x=(g-d)/f,this.y=(c-m)/f,this.z=(h-l)/f,this.w=Math.acos((o+u+v-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this.z=Fe(this.z,e.z,t.z),this.w=Fe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this.z=Fe(this.z,e,t),this.w=Fe(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class $u extends or{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Ke(0,0,e,t),this.scissorTest=!1,this.viewport=new Ke(0,0,e,t);const r={width:e,height:t,depth:i.depth},n=new Rt(r);this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=n.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:yt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,n=this.textures.length;r<n;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new ja(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class bt extends $u{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class zl extends Rt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Dt,this.minFilter=Dt,this.wrapR=$t,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ju extends Rt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Dt,this.minFilter=Dt,this.wrapR=$t,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class At{constructor(e=new w(1/0,1/0,1/0),t=new w(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(ci.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(ci.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=ci.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const n=i.getAttribute("position");if(t===!0&&n!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=n.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,ci):ci.fromBufferAttribute(n,a),ci.applyMatrix4(e.matrixWorld),this.expandByPoint(ci);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Zs.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Zs.copy(i.boundingBox)),Zs.applyMatrix4(e.matrixWorld),this.union(Zs)}const r=e.children;for(let n=0,a=r.length;n<a;n++)this.expandByObject(r[n],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,ci),ci.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(xs),$s.subVectors(this.max,xs),Ir.subVectors(e.a,xs),Ur.subVectors(e.b,xs),Nr.subVectors(e.c,xs),Yi.subVectors(Ur,Ir),Ki.subVectors(Nr,Ur),lr.subVectors(Ir,Nr);let t=[0,-Yi.z,Yi.y,0,-Ki.z,Ki.y,0,-lr.z,lr.y,Yi.z,0,-Yi.x,Ki.z,0,-Ki.x,lr.z,0,-lr.x,-Yi.y,Yi.x,0,-Ki.y,Ki.x,0,-lr.y,lr.x,0];return!Ya(t,Ir,Ur,Nr,$s)||(t=[1,0,0,0,1,0,0,0,1],!Ya(t,Ir,Ur,Nr,$s))?!1:(Js.crossVectors(Yi,Ki),t=[Js.x,Js.y,Js.z],Ya(t,Ir,Ur,Nr,$s))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ci).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ci).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:(Ui[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ui[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ui[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ui[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ui[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ui[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ui[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ui[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ui),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 Ui=[new w,new w,new w,new w,new w,new w,new w,new w],ci=new w,Zs=new At,Ir=new w,Ur=new w,Nr=new w,Yi=new w,Ki=new w,lr=new w,xs=new w,$s=new w,Js=new w,cr=new w;function Ya(s,e,t,i,r){for(let n=0,a=s.length-3;n<=a;n+=3){cr.fromArray(s,n);const o=r.x*Math.abs(cr.x)+r.y*Math.abs(cr.y)+r.z*Math.abs(cr.z),l=e.dot(cr),c=t.dot(cr),h=i.dot(cr);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Qu=new At,ys=new w,Ka=new w;class Ei{constructor(e=new w,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):Qu.setFromPoints(e).getCenter(i);let r=0;for(let n=0,a=e.length;n<a;n++)r=Math.max(r,i.distanceToSquared(e[n]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ys.subVectors(e,this.center);const t=ys.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(ys,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ka.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ys.copy(e.center).add(Ka)),this.expandByPoint(ys.copy(e.center).sub(Ka))),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 Ni=new w,Za=new w,Qs=new w,Zi=new w,$a=new w,en=new w,Ja=new w;class Or{constructor(e=new w,t=new w(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ni)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ni.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ni.copy(this.origin).addScaledVector(this.direction,t),Ni.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Za.copy(e).add(t).multiplyScalar(.5),Qs.copy(t).sub(e).normalize(),Zi.copy(this.origin).sub(Za);const n=e.distanceTo(t)*.5,a=-this.direction.dot(Qs),o=Zi.dot(this.direction),l=-Zi.dot(Qs),c=Zi.lengthSq(),h=Math.abs(1-a*a);let u,d,m,g;if(h>0)if(u=a*l-o,d=a*o-l,g=n*h,u>=0)if(d>=-g)if(d<=g){const v=1/h;u*=v,d*=v,m=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=n,u=Math.max(0,-(a*d+o)),m=-u*u+d*(d+2*l)+c;else d=-n,u=Math.max(0,-(a*d+o)),m=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*n+o)),d=u>0?-n:Math.min(Math.max(-n,-l),n),m=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-n,-l),n),m=d*(d+2*l)+c):(u=Math.max(0,-(a*n+o)),d=u>0?n:Math.min(Math.max(-n,-l),n),m=-u*u+d*(d+2*l)+c);else d=a>0?-n:n,u=Math.max(0,-(a*d+o)),m=-u*u+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(Za).addScaledVector(Qs,d),m}intersectSphere(e,t){Ni.subVectors(e.center,this.origin);const i=Ni.dot(this.direction),r=Ni.dot(Ni)-i*i,n=e.radius*e.radius;if(r>n)return null;const a=Math.sqrt(n-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,n,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),h>=0?(n=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(n=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||n>r||((n>i||isNaN(i))&&(i=n),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Ni)!==null}intersectTriangle(e,t,i,r,n){$a.subVectors(t,e),en.subVectors(i,e),Ja.crossVectors($a,en);let a=this.direction.dot(Ja),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Zi.subVectors(this.origin,e);const l=o*this.direction.dot(en.crossVectors(Zi,en));if(l<0)return null;const c=o*this.direction.dot($a.cross(Zi));if(c<0||l+c>a)return null;const h=-o*Zi.dot(Ja);return h<0?null:this.at(h/a,n)}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 Le{constructor(e,t,i,r,n,a,o,l,c,h,u,d,m,g,v,f){Le.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,n,a,o,l,c,h,u,d,m,g,v,f)}set(e,t,i,r,n,a,o,l,c,h,u,d,m,g,v,f){const p=this.elements;return p[0]=e,p[4]=t,p[8]=i,p[12]=r,p[1]=n,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=m,p[7]=g,p[11]=v,p[15]=f,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 Le().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/Br.setFromMatrixColumn(e,0).length(),n=1/Br.setFromMatrixColumn(e,1).length(),a=1/Br.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),h=Math.cos(n),u=Math.sin(n);if(e.order==="XYZ"){const d=a*h,m=a*u,g=o*h,v=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=m+g*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=g+m*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,m=l*u,g=c*h,v=c*u;t[0]=d+v*o,t[4]=g*o-m,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=m*o-g,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,m=l*u,g=c*h,v=c*u;t[0]=d-v*o,t[4]=-a*u,t[8]=g+m*o,t[1]=m+g*o,t[5]=a*h,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,m=a*u,g=o*h,v=o*u;t[0]=l*h,t[4]=g*c-m,t[8]=d*c+v,t[1]=l*u,t[5]=v*c+d,t[9]=m*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,m=a*c,g=o*l,v=o*c;t[0]=l*h,t[4]=v-d*u,t[8]=g*u+m,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=m*u+g,t[10]=d-v*u}else if(e.order==="XZY"){const d=a*l,m=a*c,g=o*l,v=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+v,t[5]=a*h,t[9]=m*u-g,t[2]=g*u-m,t[6]=o*h,t[10]=v*u+d}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(ed,e,td)}lookAt(e,t,i){const r=this.elements;return Yt.subVectors(e,t),Yt.lengthSq()===0&&(Yt.z=1),Yt.normalize(),$i.crossVectors(i,Yt),$i.lengthSq()===0&&(Math.abs(i.z)===1?Yt.x+=1e-4:Yt.z+=1e-4,Yt.normalize(),$i.crossVectors(i,Yt)),$i.normalize(),tn.crossVectors(Yt,$i),r[0]=$i.x,r[4]=tn.x,r[8]=Yt.x,r[1]=$i.y,r[5]=tn.y,r[9]=Yt.y,r[2]=$i.z,r[6]=tn.z,r[10]=Yt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],u=i[5],d=i[9],m=i[13],g=i[2],v=i[6],f=i[10],p=i[14],y=i[3],_=i[7],E=i[11],R=i[15],T=r[0],A=r[4],I=r[8],S=r[12],M=r[1],L=r[5],N=r[9],z=r[13],H=r[2],j=r[6],q=r[10],te=r[14],G=r[3],Z=r[7],se=r[11],Pe=r[15];return n[0]=a*T+o*M+l*H+c*G,n[4]=a*A+o*L+l*j+c*Z,n[8]=a*I+o*N+l*q+c*se,n[12]=a*S+o*z+l*te+c*Pe,n[1]=h*T+u*M+d*H+m*G,n[5]=h*A+u*L+d*j+m*Z,n[9]=h*I+u*N+d*q+m*se,n[13]=h*S+u*z+d*te+m*Pe,n[2]=g*T+v*M+f*H+p*G,n[6]=g*A+v*L+f*j+p*Z,n[10]=g*I+v*N+f*q+p*se,n[14]=g*S+v*z+f*te+p*Pe,n[3]=y*T+_*M+E*H+R*G,n[7]=y*A+_*L+E*j+R*Z,n[11]=y*I+_*N+E*q+R*se,n[15]=y*S+_*z+E*te+R*Pe,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],m=e[14],g=e[3],v=e[7],f=e[11],p=e[15];return g*(+n*l*u-r*c*u-n*o*d+i*c*d+r*o*m-i*l*m)+v*(+t*l*m-t*c*d+n*a*d-r*a*m+r*c*h-n*l*h)+f*(+t*c*u-t*o*m-n*a*u+i*a*m+n*o*h-i*c*h)+p*(-r*o*h-t*l*u+t*o*d+r*a*u-i*a*d+i*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],m=e[11],g=e[12],v=e[13],f=e[14],p=e[15],y=u*f*c-v*d*c+v*l*m-o*f*m-u*l*p+o*d*p,_=g*d*c-h*f*c-g*l*m+a*f*m+h*l*p-a*d*p,E=h*v*c-g*u*c+g*o*m-a*v*m-h*o*p+a*u*p,R=g*u*l-h*v*l-g*o*d+a*v*d+h*o*f-a*u*f,T=t*y+i*_+r*E+n*R;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/T;return e[0]=y*A,e[1]=(v*d*n-u*f*n-v*r*m+i*f*m+u*r*p-i*d*p)*A,e[2]=(o*f*n-v*l*n+v*r*c-i*f*c-o*r*p+i*l*p)*A,e[3]=(u*l*n-o*d*n-u*r*c+i*d*c+o*r*m-i*l*m)*A,e[4]=_*A,e[5]=(h*f*n-g*d*n+g*r*m-t*f*m-h*r*p+t*d*p)*A,e[6]=(g*l*n-a*f*n-g*r*c+t*f*c+a*r*p-t*l*p)*A,e[7]=(a*d*n-h*l*n+h*r*c-t*d*c-a*r*m+t*l*m)*A,e[8]=E*A,e[9]=(g*u*n-h*v*n-g*i*m+t*v*m+h*i*p-t*u*p)*A,e[10]=(a*v*n-g*o*n+g*i*c-t*v*c-a*i*p+t*o*p)*A,e[11]=(h*o*n-a*u*n-h*i*c+t*u*c+a*i*m-t*o*m)*A,e[12]=R*A,e[13]=(h*v*r-g*u*r+g*i*d-t*v*d-h*i*f+t*u*f)*A,e[14]=(g*o*r-a*v*r-g*i*l+t*v*l+a*i*f-t*o*f)*A,e[15]=(a*u*r-h*o*r+h*i*l-t*u*l-a*i*d+t*o*d)*A,this}scale(e){const t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),n=1-i,a=e.x,o=e.y,l=e.z,c=n*a,h=n*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+i,h*l-r*a,0,c*l-r*o,h*l+r*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,n,a){return this.set(1,i,n,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,n=t._x,a=t._y,o=t._z,l=t._w,c=n+n,h=a+a,u=o+o,d=n*c,m=n*h,g=n*u,v=a*h,f=a*u,p=o*u,y=l*c,_=l*h,E=l*u,R=i.x,T=i.y,A=i.z;return r[0]=(1-(v+p))*R,r[1]=(m+E)*R,r[2]=(g-_)*R,r[3]=0,r[4]=(m-E)*T,r[5]=(1-(d+p))*T,r[6]=(f+y)*T,r[7]=0,r[8]=(g+_)*A,r[9]=(f-y)*A,r[10]=(1-(d+v))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let n=Br.set(r[0],r[1],r[2]).length();const a=Br.set(r[4],r[5],r[6]).length(),o=Br.set(r[8],r[9],r[10]).length();this.determinant()<0&&(n=-n),e.x=r[12],e.y=r[13],e.z=r[14],hi.copy(this);const l=1/n,c=1/a,h=1/o;return hi.elements[0]*=l,hi.elements[1]*=l,hi.elements[2]*=l,hi.elements[4]*=c,hi.elements[5]*=c,hi.elements[6]*=c,hi.elements[8]*=h,hi.elements[9]*=h,hi.elements[10]*=h,t.setFromRotationMatrix(hi),i.x=n,i.y=a,i.z=o,this}makePerspective(e,t,i,r,n,a,o=Si,l=!1){const c=this.elements,h=2*n/(t-e),u=2*n/(i-r),d=(t+e)/(t-e),m=(i+r)/(i-r);let g,v;if(l)g=n/(a-n),v=a*n/(a-n);else if(o===Si)g=-(a+n)/(a-n),v=-2*a*n/(a-n);else if(o===Ys)g=-a/(a-n),v=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,n,a,o=Si,l=!1){const c=this.elements,h=2/(t-e),u=2/(i-r),d=-(t+e)/(t-e),m=-(i+r)/(i-r);let g,v;if(l)g=1/(a-n),v=a/(a-n);else if(o===Si)g=-2/(a-n),v=-(a+n)/(a-n);else if(o===Ys)g=-1/(a-n),v=-n/(a-n);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Br=new w,hi=new Le,ed=new w(0,0,0),td=new w(1,1,1),$i=new w,tn=new w,Yt=new w,Hl=new Le,Vl=new li;class ui{constructor(e=0,t=0,i=0,r=ui.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,n=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],u=r[2],d=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(Fe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Fe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(Fe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-Fe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Fe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Fe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-h,m),this._y=0);break;default:be("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Hl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Hl,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Vl.setFromEuler(this),this.setFromQuaternion(Vl,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}}ui.DEFAULT_ORDER="XYZ";class Qa{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 id=0;const Gl=new w,Fr=new li,Oi=new Le,rn=new w,bs=new w,rd=new w,sd=new li,Wl=new w(1,0,0),jl=new w(0,1,0),Xl=new w(0,0,1),ql={type:"added"},nd={type:"removed"},kr={type:"childadded",child:null},eo={type:"childremoved",child:null};class ht extends or{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:id++}),this.uuid=ai(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ht.DEFAULT_UP.clone();const e=new w,t=new ui,i=new li,r=new w(1,1,1);function n(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(n),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Le},normalMatrix:{value:new Be}}),this.matrix=new Le,this.matrixWorld=new Le,this.matrixAutoUpdate=ht.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Qa,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 Fr.setFromAxisAngle(e,t),this.quaternion.multiply(Fr),this}rotateOnWorldAxis(e,t){return Fr.setFromAxisAngle(e,t),this.quaternion.premultiply(Fr),this}rotateX(e){return this.rotateOnAxis(Wl,e)}rotateY(e){return this.rotateOnAxis(jl,e)}rotateZ(e){return this.rotateOnAxis(Xl,e)}translateOnAxis(e,t){return Gl.copy(e).applyQuaternion(this.quaternion),this.position.add(Gl.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Wl,e)}translateY(e){return this.translateOnAxis(jl,e)}translateZ(e){return this.translateOnAxis(Xl,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Oi.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?rn.copy(e):rn.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),bs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Oi.lookAt(bs,rn,this.up):Oi.lookAt(rn,bs,this.up),this.quaternion.setFromRotationMatrix(Oi),r&&(Oi.extractRotation(r.matrixWorld),Fr.setFromRotationMatrix(Oi),this.quaternion.premultiply(Fr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(He("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(ql),kr.child=e,this.dispatchEvent(kr),kr.child=null):He("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(nd),eo.child=e,this.dispatchEvent(eo),eo.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),Oi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Oi.multiply(e.parent.matrixWorld)),e.applyMatrix4(Oi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ql),kr.child=e,this.dispatchEvent(kr),kr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const n=this.children[i].getObjectByProperty(e,t);if(n!==void 0)return n}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bs,e,rd),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bs,sd,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let n=0,a=r.length;n<a;n++)r[n].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=n(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 u=l[c];n(e.shapes,u)}else n(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(e.skeletons,this.skeleton),r.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(n(e.materials,this.material[l]));r.material=o}else r.material=n(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(n(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),m=a(e.animations),g=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),m.length>0&&(i.animations=m),g.length>0&&(i.nodes=g)}return i.object=r,i;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}ht.DEFAULT_UP=new w(0,1,0),ht.DEFAULT_MATRIX_AUTO_UPDATE=!0,ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const di=new w,Bi=new w,to=new w,Fi=new w,zr=new w,Hr=new w,Yl=new w,io=new w,ro=new w,so=new w,no=new Ke,ao=new Ke,oo=new Ke;class pi{constructor(e=new w,t=new w,i=new w){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),di.subVectors(e,t),r.cross(di);const n=r.lengthSq();return n>0?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)}static getBarycoord(e,t,i,r,n){di.subVectors(r,t),Bi.subVectors(i,t),to.subVectors(e,t);const a=di.dot(di),o=di.dot(Bi),l=di.dot(to),c=Bi.dot(Bi),h=Bi.dot(to),u=a*c-o*o;if(u===0)return n.set(0,0,0),null;const d=1/u,m=(c*l-o*h)*d,g=(a*h-o*l)*d;return n.set(1-m-g,g,m)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Fi)===null?!1:Fi.x>=0&&Fi.y>=0&&Fi.x+Fi.y<=1}static getInterpolation(e,t,i,r,n,a,o,l){return this.getBarycoord(e,t,i,r,Fi)===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(n,Fi.x),l.addScaledVector(a,Fi.y),l.addScaledVector(o,Fi.z),l)}static getInterpolatedAttribute(e,t,i,r,n,a){return no.setScalar(0),ao.setScalar(0),oo.setScalar(0),no.fromBufferAttribute(e,t),ao.fromBufferAttribute(e,i),oo.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(no,n.x),a.addScaledVector(ao,n.y),a.addScaledVector(oo,n.z),a}static isFrontFacing(e,t,i,r){return di.subVectors(i,t),Bi.subVectors(e,t),di.cross(Bi).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return di.subVectors(this.c,this.b),Bi.subVectors(this.a,this.b),di.cross(Bi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return pi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return pi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,n){return pi.getInterpolation(e,this.a,this.b,this.c,t,i,r,n)}containsPoint(e){return pi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return pi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,n=this.c;let a,o;zr.subVectors(r,i),Hr.subVectors(n,i),io.subVectors(e,i);const l=zr.dot(io),c=Hr.dot(io);if(l<=0&&c<=0)return t.copy(i);ro.subVectors(e,r);const h=zr.dot(ro),u=Hr.dot(ro);if(h>=0&&u<=h)return t.copy(r);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(zr,a);so.subVectors(e,n);const m=zr.dot(so),g=Hr.dot(so);if(g>=0&&m<=g)return t.copy(n);const v=m*c-l*g;if(v<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(i).addScaledVector(Hr,o);const f=h*g-m*u;if(f<=0&&u-h>=0&&m-g>=0)return Yl.subVectors(n,r),o=(u-h)/(u-h+(m-g)),t.copy(r).addScaledVector(Yl,o);const p=1/(f+v+d);return a=v*p,o=d*p,t.copy(i).addScaledVector(zr,a).addScaledVector(Hr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Kl={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},Ji={h:0,s:0,l:0},sn={h:0,s:0,l:0};function lo(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 _e{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ct){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=je.workingColorSpace){return this.r=e,this.g=t,this.b=i,je.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=je.workingColorSpace){if(e=Ha(e,1),t=Fe(t,0,1),i=Fe(i,0,1),t===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,a=2*i-n;this.r=lo(a,n,e+1/3),this.g=lo(a,n,e),this.b=lo(a,n,e-1/3)}return je.colorSpaceToWorking(this,r),this}setStyle(e,t=Ct){function i(n){n!==void 0&&parseFloat(n)<1&&be("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let n;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,t);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,t);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,t);break;default:be("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=r[1],a=n.length;if(a===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(n,16),t);be("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ct){const i=Kl[e.toLowerCase()];return i!==void 0?this.setHex(i,t):be("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=Ii(e.r),this.g=Ii(e.g),this.b=Ii(e.b),this}copyLinearToSRGB(e){return this.r=Lr(e.r),this.g=Lr(e.g),this.b=Lr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ct){return je.workingToColorSpace(Bt.copy(this),e),Math.round(Fe(Bt.r*255,0,255))*65536+Math.round(Fe(Bt.g*255,0,255))*256+Math.round(Fe(Bt.b*255,0,255))}getHexString(e=Ct){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(Bt.copy(this),t);const i=Bt.r,r=Bt.g,n=Bt.b,a=Math.max(i,r,n),o=Math.min(i,r,n);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case i:l=(r-n)/u+(r<n?6:0);break;case r:l=(n-i)/u+2;break;case n:l=(i-r)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=je.workingColorSpace){return je.workingToColorSpace(Bt.copy(this),t),e.r=Bt.r,e.g=Bt.g,e.b=Bt.b,e}getStyle(e=Ct){je.workingToColorSpace(Bt.copy(this),e);const t=Bt.r,i=Bt.g,r=Bt.b;return e!==Ct?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(Ji),this.setHSL(Ji.h+e,Ji.s+t,Ji.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Ji),e.getHSL(sn);const i=_s(Ji.h,sn.h,t),r=_s(Ji.s,sn.s,t),n=_s(Ji.l,sn.l,t);return this.setHSL(i,r,n),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,n=e.elements;return this.r=n[0]*t+n[3]*i+n[6]*r,this.g=n[1]*t+n[4]*i+n[7]*r,this.b=n[2]*t+n[5]*i+n[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Bt=new _e;_e.NAMES=Kl;let ad=0;class Jt extends or{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ad++}),this.uuid=ai(),this.name="",this.type="Material",this.blending=Tr,this.side=bi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=kn,this.blendDst=zn,this.blendEquation=si,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new _e(0,0,0),this.blendAlpha=0,this.depthFunc=Sr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ka,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ar,this.stencilZFail=Ar,this.stencilZPass=Ar,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){be(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){be(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Tr&&(i.blending=this.blending),this.side!==bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==kn&&(i.blendSrc=this.blendSrc),this.blendDst!==zn&&(i.blendDst=this.blendDst),this.blendEquation!==si&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Sr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ka&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ar&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ar&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ar&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(n){const a=[];for(const o in n){const l=n[o];delete l.metadata,a.push(l)}return a}if(t){const n=r(e.textures),a=r(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class kt extends Jt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new _e(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 ui,this.combine=Zn,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 ki=od();function od(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const n=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,n[l]=c|h}for(let l=1024;l<2048;++l)n[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:n,exponentTable:a,offsetTable:o}}function ld(s){Math.abs(s)>65504&&be("DataUtils.toHalfFloat(): Value out of range."),s=Fe(s,-65504,65504),ki.floatView[0]=s;const e=ki.uint32View[0],t=e>>23&511;return ki.baseTable[t]+((e&8388607)>>ki.shiftTable[t])}function cd(s){const e=s>>10;return ki.uint32View[0]=ki.mantissaTable[ki.offsetTable[e]+(s&1023)]+ki.exponentTable[e],ki.floatView[0]}class nn{static toHalfFloat(e){return ld(e)}static fromHalfFloat(e){return cd(e)}}const Mt=new w,an=new oe;let hd=0;class zt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:hd++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=za,this.updateRanges=[],this.gpuType=Wt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,n=this.itemSize;r<n;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)an.fromBufferAttribute(this,t),an.applyMatrix3(e),this.setXY(t,an.x,an.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Mt.fromBufferAttribute(this,t),Mt.applyMatrix3(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Mt.fromBufferAttribute(this,t),Mt.applyMatrix4(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Mt.fromBufferAttribute(this,t),Mt.applyNormalMatrix(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Mt.fromBufferAttribute(this,t),Mt.transformDirection(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=oi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=tt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=oi(t,this.array)),t}setX(e,t){return this.normalized&&(t=tt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=oi(t,this.array)),t}setY(e,t){return this.normalized&&(t=tt(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=oi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=tt(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=oi(t,this.array)),t}setW(e,t){return this.normalized&&(t=tt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array),r=tt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e*=this.itemSize,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array),r=tt(r,this.array),n=tt(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=n,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!==za&&(e.usage=this.usage),e}}class Zl extends zt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class $l extends zt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class mi extends zt{constructor(e,t,i){super(new Float32Array(e),t,i)}}let ud=0;const Qt=new Le,co=new ht,Vr=new w,Kt=new At,Ms=new At,Pt=new w;class ei extends or{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ud++}),this.uuid=ai(),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(Ul(e)?$l:Zl)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new Be().getNormalMatrix(e);i.applyNormalMatrix(n),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Qt.makeRotationFromQuaternion(e),this.applyMatrix4(Qt),this}rotateX(e){return Qt.makeRotationX(e),this.applyMatrix4(Qt),this}rotateY(e){return Qt.makeRotationY(e),this.applyMatrix4(Qt),this}rotateZ(e){return Qt.makeRotationZ(e),this.applyMatrix4(Qt),this}translate(e,t,i){return Qt.makeTranslation(e,t,i),this.applyMatrix4(Qt),this}scale(e,t,i){return Qt.makeScale(e,t,i),this.applyMatrix4(Qt),this}lookAt(e){return co.lookAt(e),co.updateMatrix(),this.applyMatrix4(co.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Vr).negate(),this.translate(Vr.x,Vr.y,Vr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,n=e.length;r<n;r++){const a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new mi(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&be("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 At);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){He("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new w(-1/0,-1/0,-1/0),new w(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const n=t[i];Kt.setFromBufferAttribute(n),this.morphTargetsRelative?(Pt.addVectors(this.boundingBox.min,Kt.min),this.boundingBox.expandByPoint(Pt),Pt.addVectors(this.boundingBox.max,Kt.max),this.boundingBox.expandByPoint(Pt)):(this.boundingBox.expandByPoint(Kt.min),this.boundingBox.expandByPoint(Kt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&He('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 Ei);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){He("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new w,1/0);return}if(e){const i=this.boundingSphere.center;if(Kt.setFromBufferAttribute(e),t)for(let n=0,a=t.length;n<a;n++){const o=t[n];Ms.setFromBufferAttribute(o),this.morphTargetsRelative?(Pt.addVectors(Kt.min,Ms.min),Kt.expandByPoint(Pt),Pt.addVectors(Kt.max,Ms.max),Kt.expandByPoint(Pt)):(Kt.expandByPoint(Ms.min),Kt.expandByPoint(Ms.max))}Kt.getCenter(i);let r=0;for(let n=0,a=e.count;n<a;n++)Pt.fromBufferAttribute(e,n),r=Math.max(r,i.distanceToSquared(Pt));if(t)for(let n=0,a=t.length;n<a;n++){const o=t[n],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Pt.fromBufferAttribute(o,c),l&&(Vr.fromBufferAttribute(e,c),Pt.add(Vr)),r=Math.max(r,i.distanceToSquared(Pt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&He('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){He("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,n=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new zt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let I=0;I<i.count;I++)o[I]=new w,l[I]=new w;const c=new w,h=new w,u=new w,d=new oe,m=new oe,g=new oe,v=new w,f=new w;function p(I,S,M){c.fromBufferAttribute(i,I),h.fromBufferAttribute(i,S),u.fromBufferAttribute(i,M),d.fromBufferAttribute(n,I),m.fromBufferAttribute(n,S),g.fromBufferAttribute(n,M),h.sub(c),u.sub(c),m.sub(d),g.sub(d);const L=1/(m.x*g.y-g.x*m.y);isFinite(L)&&(v.copy(h).multiplyScalar(g.y).addScaledVector(u,-m.y).multiplyScalar(L),f.copy(u).multiplyScalar(m.x).addScaledVector(h,-g.x).multiplyScalar(L),o[I].add(v),o[S].add(v),o[M].add(v),l[I].add(f),l[S].add(f),l[M].add(f))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let I=0,S=y.length;I<S;++I){const M=y[I],L=M.start,N=M.count;for(let z=L,H=L+N;z<H;z+=3)p(e.getX(z+0),e.getX(z+1),e.getX(z+2))}const _=new w,E=new w,R=new w,T=new w;function A(I){R.fromBufferAttribute(r,I),T.copy(R);const S=o[I];_.copy(S),_.sub(R.multiplyScalar(R.dot(S))).normalize(),E.crossVectors(T,S);const M=E.dot(l[I])<0?-1:1;a.setXYZW(I,_.x,_.y,_.z,M)}for(let I=0,S=y.length;I<S;++I){const M=y[I],L=M.start,N=M.count;for(let z=L,H=L+N;z<H;z+=3)A(e.getX(z+0)),A(e.getX(z+1)),A(e.getX(z+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new zt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,m=i.count;d<m;d++)i.setXYZ(d,0,0,0);const r=new w,n=new w,a=new w,o=new w,l=new w,c=new w,h=new w,u=new w;if(e)for(let d=0,m=e.count;d<m;d+=3){const g=e.getX(d+0),v=e.getX(d+1),f=e.getX(d+2);r.fromBufferAttribute(t,g),n.fromBufferAttribute(t,v),a.fromBufferAttribute(t,f),h.subVectors(a,n),u.subVectors(r,n),h.cross(u),o.fromBufferAttribute(i,g),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,f),o.add(h),l.add(h),c.add(h),i.setXYZ(g,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(f,c.x,c.y,c.z)}else for(let d=0,m=t.count;d<m;d+=3)r.fromBufferAttribute(t,d+0),n.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,n),u.subVectors(r,n),h.cross(u),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Pt.fromBufferAttribute(e,t),Pt.normalize(),e.setXYZ(t,Pt.x,Pt.y,Pt.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let m=0,g=0;for(let v=0,f=l.length;v<f;v++){o.isInterleavedBufferAttribute?m=l[v]*o.data.stride+o.offset:m=l[v]*h;for(let p=0;p<h;p++)d[g++]=c[m++]}return new zt(d,h,u)}if(this.index===null)return be("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ei,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);t.setAttribute(o,c)}const n=this.morphAttributes;for(const o in n){const l=[],c=n[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],m=e(d,i);l.push(m)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let n=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const m=c[u];h.push(m.toJSON(e.data))}h.length>0&&(r[l]=h,n=!0)}n&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const n=e.morphAttributes;for(const c in n){const h=[],u=n[c];for(let d=0,m=u.length;d<m;d++)h.push(u[d].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 u=a[c];this.addGroup(u.start,u.count,u.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 Jl=new Le,hr=new Or,on=new Ei,Ql=new w,ln=new w,cn=new w,hn=new w,ho=new w,un=new w,ec=new w,dn=new w;class rt extends ht{constructor(e=new ei,t=new kt){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,n=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(n&&o){un.set(0,0,0);for(let l=0,c=n.length;l<c;l++){const h=o[l],u=n[l];h!==0&&(ho.fromBufferAttribute(u,e),a?un.addScaledVector(ho,h):un.addScaledVector(ho.sub(t),h))}t.add(un)}return t}raycast(e,t){const i=this.geometry,r=this.material,n=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),on.copy(i.boundingSphere),on.applyMatrix4(n),hr.copy(e.ray).recast(e.near),!(on.containsPoint(hr.origin)===!1&&(hr.intersectSphere(on,Ql)===null||hr.origin.distanceToSquared(Ql)>(e.far-e.near)**2))&&(Jl.copy(n).invert(),hr.copy(e.ray).applyMatrix4(Jl),!(i.boundingBox!==null&&hr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,hr)))}_computeIntersections(e,t,i){let r;const n=this.geometry,a=this.material,o=n.index,l=n.attributes.position,c=n.attributes.uv,h=n.attributes.uv1,u=n.attributes.normal,d=n.groups,m=n.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const f=d[g],p=a[f.materialIndex],y=Math.max(f.start,m.start),_=Math.min(o.count,Math.min(f.start+f.count,m.start+m.count));for(let E=y,R=_;E<R;E+=3){const T=o.getX(E),A=o.getX(E+1),I=o.getX(E+2);r=pn(this,p,e,i,c,h,u,T,A,I),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const g=Math.max(0,m.start),v=Math.min(o.count,m.start+m.count);for(let f=g,p=v;f<p;f+=3){const y=o.getX(f),_=o.getX(f+1),E=o.getX(f+2);r=pn(this,a,e,i,c,h,u,y,_,E),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const f=d[g],p=a[f.materialIndex],y=Math.max(f.start,m.start),_=Math.min(l.count,Math.min(f.start+f.count,m.start+m.count));for(let E=y,R=_;E<R;E+=3){const T=E,A=E+1,I=E+2;r=pn(this,p,e,i,c,h,u,T,A,I),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const g=Math.max(0,m.start),v=Math.min(l.count,m.start+m.count);for(let f=g,p=v;f<p;f+=3){const y=f,_=f+1,E=f+2;r=pn(this,a,e,i,c,h,u,y,_,E),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}}function dd(s,e,t,i,r,n,a,o){let l;if(e.side===Ft?l=i.intersectTriangle(a,n,r,!0,o):l=i.intersectTriangle(r,n,a,e.side===bi,o),l===null)return null;dn.copy(o),dn.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(dn);return c<t.near||c>t.far?null:{distance:c,point:dn.clone(),object:s}}function pn(s,e,t,i,r,n,a,o,l,c){s.getVertexPosition(o,ln),s.getVertexPosition(l,cn),s.getVertexPosition(c,hn);const h=dd(s,e,t,i,ln,cn,hn,ec);if(h){const u=new w;pi.getBarycoord(ec,ln,cn,hn,u),r&&(h.uv=pi.getInterpolatedAttribute(r,o,l,c,u,new oe)),n&&(h.uv1=pi.getInterpolatedAttribute(n,o,l,c,u,new oe)),a&&(h.normal=pi.getInterpolatedAttribute(a,o,l,c,u,new w),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new w,materialIndex:0};pi.getNormal(ln,cn,hn,d.normal),h.face=d,h.barycoord=u}return h}class ur extends ei{constructor(e=1,t=1,i=1,r=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:n,depthSegments:a};const o=this;r=Math.floor(r),n=Math.floor(n),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,m=0;g("z","y","x",-1,-1,i,t,e,a,n,0),g("z","y","x",1,-1,i,t,-e,a,n,1),g("x","z","y",1,1,e,i,t,r,a,2),g("x","z","y",1,-1,e,i,-t,r,a,3),g("x","y","z",1,-1,e,t,i,r,n,4),g("x","y","z",-1,-1,e,t,-i,r,n,5),this.setIndex(l),this.setAttribute("position",new mi(c,3)),this.setAttribute("normal",new mi(h,3)),this.setAttribute("uv",new mi(u,2));function g(v,f,p,y,_,E,R,T,A,I,S){const M=E/A,L=R/I,N=E/2,z=R/2,H=T/2,j=A+1,q=I+1;let te=0,G=0;const Z=new w;for(let se=0;se<q;se++){const Pe=se*L-z;for(let ze=0;ze<j;ze++){const qe=ze*M-N;Z[v]=qe*y,Z[f]=Pe*_,Z[p]=H,c.push(Z.x,Z.y,Z.z),Z[v]=0,Z[f]=0,Z[p]=T>0?1:-1,h.push(Z.x,Z.y,Z.z),u.push(ze/A),u.push(1-se/I),te+=1}}for(let se=0;se<I;se++)for(let Pe=0;Pe<A;Pe++){const ze=d+Pe+j*se,qe=d+Pe+j*(se+1),Ze=d+(Pe+1)+j*(se+1),$e=d+(Pe+1)+j*se;l.push(ze,qe,$e),l.push(qe,Ze,$e),G+=6}o.addGroup(m,G,S),m+=G,d+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ur(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Gr(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const r=s[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(be("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Ht(s){const e={};for(let t=0;t<s.length;t++){const i=Gr(s[t]);for(const r in i)e[r]=i[r]}return e}function pd(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function tc(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:je.workingColorSpace}const fi={clone:Gr,merge:Ht};var md=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fd=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`;class ot extends Jt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=md,this.fragmentShader=fd,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=Gr(e.uniforms),this.uniformsGroups=pd(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const n=this.uniforms[r].value;n&&n.isTexture?t.uniforms[r]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[r]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[r]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[r]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[r]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[r]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[r]={type:"m4",value:n.toArray()}:t.uniforms[r]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class ic extends ht{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Le,this.projectionMatrix=new Le,this.projectionMatrixInverse=new Le,this.coordinateSystem=Si,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 Qi=new w,rc=new oe,sc=new oe;class Tt extends ic{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Pr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(vs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Pr*2*Math.atan(Math.tan(vs*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Qi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Qi.x,Qi.y).multiplyScalar(-e/Qi.z),Qi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Qi.x,Qi.y).multiplyScalar(-e/Qi.z)}getViewSize(e,t){return this.getViewBounds(e,rc,sc),t.subVectors(sc,rc)}setViewOffset(e,t,i,r,n,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,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(vs*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,n=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;n+=a.offsetX*r/l,t-=a.offsetY*i/c,r*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(n+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Wr=-90,jr=1;class gd extends ht{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Tt(Wr,jr,e,t);r.layers=this.layers,this.add(r);const n=new Tt(Wr,jr,e,t);n.layers=this.layers,this.add(n);const a=new Tt(Wr,jr,e,t);a.layers=this.layers,this.add(a);const o=new Tt(Wr,jr,e,t);o.layers=this.layers,this.add(o);const l=new Tt(Wr,jr,e,t);l.layers=this.layers,this.add(l);const c=new Tt(Wr,jr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,n,a,o,l]=t;for(const c of t)this.remove(c);if(e===Si)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),n.up.set(0,0,-1),n.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===Ys)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),n.up.set(0,0,1),n.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[n,a,o,l,c,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,n),e.setRenderTarget(i,1,r),e.render(t,a),e.setRenderTarget(i,2,r),e.render(t,o),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,r),e.render(t,h),e.setRenderTarget(u,d,m),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class uo extends Rt{constructor(e=[],t=Er,i,r,n,a,o,l,c,h){super(e,t,i,r,n,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class vd extends bt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new uo(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
|
||
|
||
varying vec3 vWorldDirection;
|
||
|
||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
|
||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
|
||
}
|
||
`,fragmentShader:`
|
||
|
||
uniform sampler2D tEquirect;
|
||
|
||
varying vec3 vWorldDirection;
|
||
|
||
#include <common>
|
||
|
||
void main() {
|
||
|
||
vec3 direction = normalize( vWorldDirection );
|
||
|
||
vec2 sampleUV = equirectUv( direction );
|
||
|
||
gl_FragColor = texture2D( tEquirect, sampleUV );
|
||
|
||
}
|
||
`},r=new ur(5,5,5),n=new ot({name:"CubemapFromEquirect",uniforms:Gr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ft,blending:xt});n.uniforms.tEquirect.value=t;const a=new rt(r,n),o=t.minFilter;return t.minFilter===Ti&&(t.minFilter=yt),new gd(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const n=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(n)}}let zi=class extends ht{constructor(){super(),this.isGroup=!0,this.type="Group"}};const _d={type:"move"};class po{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new zi,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 zi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new w,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new w),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new zi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new w,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new w),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,n=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const f=t.getJointPose(v,i),p=this._getHandJoint(c,v);f!==null&&(p.matrix.fromArray(f.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=f.radius),p.visible=f!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),m=.02,g=.005;c.inputState.pinching&&d>m+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=m-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(n=t.getPose(e.gripSpace,i),n!==null&&(l.matrix.fromArray(n.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,n.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(n.linearVelocity)):l.hasLinearVelocity=!1,n.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(n.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&n!==null&&(r=n),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(_d)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=n!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new zi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class mo extends ht{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 ui,this.environmentIntensity=1,this.environmentRotation=new ui,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 xd{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=za,this.updateRanges=[],this.version=0,this.uuid=ai()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,n=this.stride;r<n;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ai()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ai()),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 Vt=new w;class fo{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;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,i=this.count;t<i;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,i=this.count;t<i;t++)Vt.fromBufferAttribute(this,t),Vt.transformDirection(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=oi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=tt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=tt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=tt(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=oi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=oi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=oi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=oi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array),r=tt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array),r=tt(r,this.array),n=tt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}clone(e){if(e===void 0){Ks("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}return new zt(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 fo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ks("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)t.push(this.data.array[r+n])}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}}}const nc=new w,ac=new Ke,oc=new Ke,yd=new w,lc=new Le,mn=new w,go=new Ei,cc=new Le,vo=new Or;class bd extends rt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=_l,this.bindMatrix=new Le,this.bindMatrixInverse=new Le,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new At),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,mn),this.boundingBox.expandByPoint(mn)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ei),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,mn),this.boundingSphere.expandByPoint(mn)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),go.copy(this.boundingSphere),go.applyMatrix4(r),e.ray.intersectsSphere(go)!==!1&&(cc.copy(r).invert(),vo.copy(e.ray).applyMatrix4(cc),!(this.boundingBox!==null&&vo.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,vo)))}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 Ke,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===_l?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===gu?this.bindMatrixInverse.copy(this.bindMatrix).invert():be("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;ac.fromBufferAttribute(r.attributes.skinIndex,e),oc.fromBufferAttribute(r.attributes.skinWeight,e),nc.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let n=0;n<4;n++){const a=oc.getComponent(n);if(a!==0){const o=ac.getComponent(n);lc.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(yd.copy(nc).applyMatrix4(lc),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class hc extends ht{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Xr extends Rt{constructor(e=null,t=1,i=1,r,n,a,o,l,c=Dt,h=Dt,u,d){super(null,a,o,l,c,h,r,n,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const uc=new Le,Md=new Le;class _o{constructor(e=[],t=[]){this.uuid=ai(),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){be("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Le)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Le;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let n=0,a=e.length;n<a;n++){const o=e[n]?e[n].matrixWorld:Md;uc.multiplyMatrices(o,t[n]),uc.toArray(i,n*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new _o(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Xr(t,e,e,qt,Wt);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const n=e.bones[i];let a=t[n];a===void 0&&(be("Skeleton: No bone found with UUID:",n),a=new hc),this.bones.push(a),this.boneInverses.push(new Le().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,n=t.length;r<n;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}class xo extends zt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const qr=new Le,dc=new Le,fn=[],pc=new At,Td=new Le,Ts=new rt,Ss=new Ei;class Sd extends rt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new xo(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,Td)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new At),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,qr),pc.copy(e.boundingBox).applyMatrix4(qr),this.boundingBox.union(pc)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ei),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,qr),Ss.copy(e.boundingSphere).applyMatrix4(qr),this.boundingSphere.union(Ss)}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 i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,n=i.length+1,a=e*n+1;for(let o=0;o<i.length;o++)i[o]=r[a+o]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(Ts.geometry=this.geometry,Ts.material=this.material,Ts.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ss.copy(this.boundingSphere),Ss.applyMatrix4(i),e.ray.intersectsSphere(Ss)!==!1))for(let n=0;n<r;n++){this.getMatrixAt(n,qr),dc.multiplyMatrices(i,qr),Ts.matrixWorld=dc,Ts.raycast(e,fn);for(let a=0,o=fn.length;a<o;a++){const l=fn[a];l.instanceId=n,l.object=this,t.push(l)}fn.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new xo(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Xr(new Float32Array(r*this.count),r,this.count,ia,Wt));const n=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;n[l]=o,n.set(i,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const yo=new w,Ed=new w,wd=new Be;class wi{constructor(e=new w(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=yo.subVectors(i,t).cross(Ed.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(yo),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const n=-(e.start.dot(this.normal)+this.constant)/r;return n<0||n>1?null:t.copy(e.start).addScaledVector(i,n)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||wd.getNormalMatrix(e),r=this.coplanarPoint(yo).applyMatrix4(e),n=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(n),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 dr=new Ei,Cd=new oe(.5,.5),gn=new w;class bo{constructor(e=new wi,t=new wi,i=new wi,r=new wi,n=new wi,a=new wi){this.planes=[e,t,i,r,n,a]}set(e,t,i,r,n,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(n),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Si,i=!1){const r=this.planes,n=e.elements,a=n[0],o=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],m=n[7],g=n[8],v=n[9],f=n[10],p=n[11],y=n[12],_=n[13],E=n[14],R=n[15];if(r[0].setComponents(c-a,m-h,p-g,R-y).normalize(),r[1].setComponents(c+a,m+h,p+g,R+y).normalize(),r[2].setComponents(c+o,m+u,p+v,R+_).normalize(),r[3].setComponents(c-o,m-u,p-v,R-_).normalize(),i)r[4].setComponents(l,d,f,E).normalize(),r[5].setComponents(c-l,m-d,p-f,R-E).normalize();else if(r[4].setComponents(c-l,m-d,p-f,R-E).normalize(),t===Si)r[5].setComponents(c+l,m+d,p+f,R+E).normalize();else if(t===Ys)r[5].setComponents(l,d,f,E).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(),dr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),dr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(dr)}intersectsSprite(e){dr.center.set(0,0,0);const t=Cd.distanceTo(e.center);return dr.radius=.7071067811865476+t,dr.applyMatrix4(e.matrixWorld),this.intersectsSphere(dr)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let n=0;n<6;n++)if(t[n].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(gn.x=r.normal.x>0?e.max.x:e.min.x,gn.y=r.normal.y>0?e.max.y:e.min.y,gn.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(gn)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class mc extends Jt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _e(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 vn=new w,_n=new w,fc=new Le,Es=new Or,xn=new Ei,Mo=new w,gc=new w;class To extends ht{constructor(e=new ei,t=new mc){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,n=t.count;r<n;r++)vn.fromBufferAttribute(t,r-1),_n.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=vn.distanceTo(_n);e.setAttribute("lineDistance",new mi(i,1))}else be("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,n=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),xn.copy(i.boundingSphere),xn.applyMatrix4(r),xn.radius+=n,e.ray.intersectsSphere(xn)===!1)return;fc.copy(r).invert(),Es.copy(e.ray).applyMatrix4(fc);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=i.index,u=i.attributes.position;if(h!==null){const d=Math.max(0,a.start),m=Math.min(h.count,a.start+a.count);for(let g=d,v=m-1;g<v;g+=c){const f=h.getX(g),p=h.getX(g+1),y=yn(this,e,Es,l,f,p,g);y&&t.push(y)}if(this.isLineLoop){const g=h.getX(m-1),v=h.getX(d),f=yn(this,e,Es,l,g,v,m-1);f&&t.push(f)}}else{const d=Math.max(0,a.start),m=Math.min(u.count,a.start+a.count);for(let g=d,v=m-1;g<v;g+=c){const f=yn(this,e,Es,l,g,g+1,g);f&&t.push(f)}if(this.isLineLoop){const g=yn(this,e,Es,l,m-1,d,m-1);g&&t.push(g)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function yn(s,e,t,i,r,n,a){const o=s.geometry.attributes.position;if(vn.fromBufferAttribute(o,r),_n.fromBufferAttribute(o,n),t.distanceSqToSegment(vn,_n,Mo,gc)>i)return;Mo.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(Mo);if(!(l<e.near||l>e.far))return{distance:l,point:gc.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const vc=new w,_c=new w;class Rd extends To{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,n=t.count;r<n;r+=2)vc.fromBufferAttribute(t,r),_c.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+vc.distanceTo(_c);e.setAttribute("lineDistance",new mi(i,1))}else be("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Ad extends To{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class xc extends Jt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new _e(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 yc=new Le,So=new Or,bn=new Ei,Mn=new w;class Pd extends ht{constructor(e=new ei,t=new xc){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,n=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),bn.copy(i.boundingSphere),bn.applyMatrix4(r),bn.radius+=n,e.ray.intersectsSphere(bn)===!1)return;yc.copy(r).invert(),So.copy(e.ray).applyMatrix4(yc);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,h=i.attributes.position;if(c!==null){const u=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let m=u,g=d;m<g;m++){const v=c.getX(m);Mn.fromBufferAttribute(h,v),bc(Mn,v,l,r,e,t,this)}}else{const u=Math.max(0,a.start),d=Math.min(h.count,a.start+a.count);for(let m=u,g=d;m<g;m++)Mn.fromBufferAttribute(h,m),bc(Mn,m,l,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,n=i.length;r<n;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function bc(s,e,t,i,r,n,a){const o=So.distanceSqToPoint(s);if(o<t){const l=new w;So.closestPointToPoint(s,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;n.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Eo extends Rt{constructor(e,t,i=ar,r,n,a,o=Dt,l=Dt,c,h=ds,u=1){if(h!==ds&&h!==Rr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,r,n,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ja(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 Mc extends Rt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class ws extends ei{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const n=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),c=o+1,h=l+1,u=e/o,d=t/l,m=[],g=[],v=[],f=[];for(let p=0;p<h;p++){const y=p*d-a;for(let _=0;_<c;_++){const E=_*u-n;g.push(E,-y,0),v.push(0,0,1),f.push(_/o),f.push(1-p/l)}}for(let p=0;p<l;p++)for(let y=0;y<o;y++){const _=y+c*p,E=y+c*(p+1),R=y+1+c*(p+1),T=y+1+c*p;m.push(_,E,T),m.push(E,R,T)}this.setIndex(m),this.setAttribute("position",new mi(g,3)),this.setAttribute("normal",new mi(v,3)),this.setAttribute("uv",new mi(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ws(e.width,e.height,e.widthSegments,e.heightSegments)}}class Ld extends ot{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class wo extends Jt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new _e(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 _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new oe(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 ui,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 Ci extends wo{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 oe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Fe(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 _e(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 _e(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new _e(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 Dd extends Jt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new oe(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 Id extends Jt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new _e(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.combine=Zn,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 Tc extends Jt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=xu,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 Ud extends Jt{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 Tn(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function Nd(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Od(s){function e(r,n){return s[r]-s[n]}const t=s.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Sc(s,e,t){const i=s.length,r=new s.constructor(i);for(let n=0,a=0;a!==i;++n){const o=t[n]*e;for(let l=0;l!==e;++l)r[a++]=s[o+l]}return r}function Ec(s,e,t,i){let r=1,n=s[0];for(;n!==void 0&&n[i]===void 0;)n=s[r++];if(n===void 0)return;let a=n[i];if(a!==void 0)if(Array.isArray(a))do a=n[i],a!==void 0&&(e.push(n.time),t.push(...a)),n=s[r++];while(n!==void 0);else if(a.toArray!==void 0)do a=n[i],a!==void 0&&(e.push(n.time),a.toArray(t,t.length)),n=s[r++];while(n!==void 0);else do a=n[i],a!==void 0&&(e.push(n.time),t.push(a)),n=s[r++];while(n!==void 0)}class Cs{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],n=t[i-1];i:{e:{let a;t:{r:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<n)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(n=r,r=t[++i],e<r)break e}a=t.length;break t}if(!(e>=n)){const o=t[1];e<o&&(i=2,n=o);for(let l=i-2;;){if(n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=n,n=t[--i-1],e>=n)break e}a=i,i=0;break t}break i}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],n=t[i-1],n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=e*r;for(let a=0;a!==r;++a)t[a]=i[n+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Bd extends Cs{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Cl,endingEnd:Cl}}intervalChanged_(e,t,i){const r=this.parameterPositions;let n=e-2,a=e+1,o=r[n],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case Rl:n=e,o=2*t-i;break;case Al:n=r.length-2,o=t+r[n]-r[n+1];break;default:n=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Rl:a=e,l=2*i-t;break;case Al:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const c=(i-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=n*h,this._offsetNext=a*h}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,m=this._weightNext,g=(i-t)/(r-t),v=g*g,f=v*g,p=-d*f+2*d*v-d*g,y=(1+d)*f+(-1.5-2*d)*v+(-.5+d)*g+1,_=(-1-m)*f+(1.5+m)*v+.5*g,E=m*f-m*v;for(let R=0;R!==o;++R)n[R]=p*a[h+R]+y*a[c+R]+_*a[l+R]+E*a[u+R];return n}}class Fd extends Cs{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(i-t)/(r-t),u=1-h;for(let d=0;d!==o;++d)n[d]=a[c+d]*u+a[l+d]*h;return n}}class kd extends Cs{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class gi{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Tn(t,this.TimeBufferType),this.values=Tn(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Tn(e.times,Array),values:Tn(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new kd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Fd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Bd(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ps:t=this.InterpolantFactoryMethodDiscrete;break;case ms:t=this.InterpolantFactoryMethodLinear;break;case Na:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return be("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ps;case this.InterpolantFactoryMethodLinear:return ms;case this.InterpolantFactoryMethodSmooth:return Na}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let n=0,a=r-1;for(;n!==r&&i[n]<e;)++n;for(;a!==-1&&i[a]>t;)--a;if(++a,n!==0||a!==r){n>=a&&(a=Math.max(a,1),n=a-1);const o=this.getValueSize();this.times=i.slice(n,a),this.values=this.values.slice(n*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(He("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,n=i.length;n===0&&(He("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==n;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){He("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){He("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Nd(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){He("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Na,n=e.length-1;let a=1;for(let o=1;o<n;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(r)l=!0;else{const u=o*i,d=u-i,m=u+i;for(let g=0;g!==i;++g){const v=t[u+g];if(v!==t[d+g]||v!==t[m+g]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const u=o*i,d=a*i;for(let m=0;m!==i;++m)t[d+m]=t[u+m]}++a}}if(n>0){e[a]=e[n];for(let o=n*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}gi.prototype.ValueTypeName="",gi.prototype.TimeBufferType=Float32Array,gi.prototype.ValueBufferType=Float32Array,gi.prototype.DefaultInterpolation=ms;class Yr extends gi{constructor(e,t,i){super(e,t,i)}}Yr.prototype.ValueTypeName="bool",Yr.prototype.ValueBufferType=Array,Yr.prototype.DefaultInterpolation=ps,Yr.prototype.InterpolantFactoryMethodLinear=void 0,Yr.prototype.InterpolantFactoryMethodSmooth=void 0;class wc extends gi{constructor(e,t,i,r){super(e,t,i,r)}}wc.prototype.ValueTypeName="color";class Kr extends gi{constructor(e,t,i,r){super(e,t,i,r)}}Kr.prototype.ValueTypeName="number";class zd extends Cs{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let c=e*o;for(let h=c+o;c!==h;c+=4)li.slerpFlat(n,0,a,c-o,a,c,l);return n}}class Zr extends gi{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new zd(this.times,this.values,this.getValueSize(),e)}}Zr.prototype.ValueTypeName="quaternion",Zr.prototype.InterpolantFactoryMethodSmooth=void 0;class $r extends gi{constructor(e,t,i){super(e,t,i)}}$r.prototype.ValueTypeName="string",$r.prototype.ValueBufferType=Array,$r.prototype.DefaultInterpolation=ps,$r.prototype.InterpolantFactoryMethodLinear=void 0,$r.prototype.InterpolantFactoryMethodSmooth=void 0;class Jr extends gi{constructor(e,t,i,r){super(e,t,i,r)}}Jr.prototype.ValueTypeName="vector";class Hd{constructor(e="",t=-1,i=[],r=vu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=ai(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(Gd(i[a]).scale(r));const n=new this(e.name,e.duration,t,e.blendMode);return n.uuid=e.uuid,n.userData=JSON.parse(e.userData||"{}"),n}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let n=0,a=i.length;n!==a;++n)t.push(gi.toJSON(i[n]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const n=t.length,a=[];for(let o=0;o<n;o++){let l=[],c=[];l.push((o+n-1)%n,o,(o+1)%n),c.push(0,1,0);const h=Od(l);l=Sc(l,1,h),c=Sc(c,1,h),!r&&l[0]===0&&(l.push(n),c.push(c[0])),a.push(new Kr(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},n=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(n);if(h&&h.length>1){const u=h[1];let d=r[u];d||(r[u]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(be("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return He("AnimationClip: No animation in JSONLoader data."),null;const i=function(h,u,d,m,g){if(d.length!==0){const v=[],f=[];Ec(d,v,f,m),v.length!==0&&g.push(new h(u,v,f))}},r=[],n=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const u=c[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){const d={};let m;for(m=0;m<u.length;m++)if(u[m].morphTargets)for(let g=0;g<u[m].morphTargets.length;g++)d[u[m].morphTargets[g]]=-1;for(const g in d){const v=[],f=[];for(let p=0;p!==u[m].morphTargets.length;++p){const y=u[m];v.push(y.time),f.push(y.morphTarget===g?1:0)}r.push(new Kr(".morphTargetInfluence["+g+"]",v,f))}l=d.length*a}else{const d=".bones["+t[h].name+"]";i(Jr,d+".position",u,"pos",r),i(Zr,d+".quaternion",u,"rot",r),i(Jr,d+".scale",u,"scl",r)}}return r.length===0?null:new this(n,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const n=this.tracks[i];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function Vd(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Kr;case"vector":case"vector2":case"vector3":case"vector4":return Jr;case"color":return wc;case"quaternion":return Zr;case"bool":case"boolean":return Yr;case"string":return $r}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Gd(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Vd(s.type);if(s.times===void 0){const t=[],i=[];Ec(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Hi={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 Wd{constructor(e,t,i){const r=this;let n=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(h){o++,n===!1&&r.onStart!==void 0&&r.onStart(h,a,o),n=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,o),a===o&&(n=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){const m=c[u],g=c[u+1];if(m.global&&(m.lastIndex=0),m.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 jd=new Wd;class er{constructor(e){this.manager=e!==void 0?e:jd,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,n){i.load(e,r,t,n)})}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}}er.DEFAULT_MATERIAL_NAME="__DEFAULT";const Vi={};class Xd extends Error{constructor(e,t){super(e),this.response=t}}class Co extends er{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=Hi.get(`file:${e}`);if(n!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(n),this.manager.itemEnd(e)},0),n;if(Vi[e]!==void 0){Vi[e].push({onLoad:t,onProgress:i,onError:r});return}Vi[e]=[],Vi[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&be("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Vi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),m=d?parseInt(d):0,g=m!==0;let v=0;const f=new ReadableStream({start(p){y();function y(){u.read().then(({done:_,value:E})=>{if(_)p.close();else{v+=E.byteLength;const R=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:m});for(let T=0,A=h.length;T<A;T++){const I=h[T];I.onProgress&&I.onProgress(R)}p.enqueue(E),y()}},_=>{p.error(_)})}}});return new Response(f)}else throw new Xd(`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 h=/charset="?([^;"\s]*)"?/i.exec(o),u=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(u);return c.arrayBuffer().then(m=>d.decode(m))}}}).then(c=>{Hi.add(`file:${e}`,c);const h=Vi[e];delete Vi[e];for(let u=0,d=h.length;u<d;u++){const m=h[u];m.onLoad&&m.onLoad(c)}}).catch(c=>{const h=Vi[e];if(h===void 0)throw this.manager.itemError(e),c;delete Vi[e];for(let u=0,d=h.length;u<d;u++){const m=h[u];m.onError&&m.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 Qr=new WeakMap;class Cc extends er{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=Hi.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)n.manager.itemStart(e),setTimeout(function(){t&&t(a),n.manager.itemEnd(e)},0);else{let u=Qr.get(a);u===void 0&&(u=[],Qr.set(a,u)),u.push({onLoad:t,onError:r})}return a}const o=fs("img");function l(){h(),t&&t(this);const u=Qr.get(this)||[];for(let d=0;d<u.length;d++){const m=u[d];m.onLoad&&m.onLoad(this)}Qr.delete(this),n.manager.itemEnd(e)}function c(u){h(),r&&r(u),Hi.remove(`image:${e}`);const d=Qr.get(this)||[];for(let m=0;m<d.length;m++){const g=d[m];g.onError&&g.onError(u)}Qr.delete(this),n.manager.itemError(e),n.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),Hi.add(`image:${e}`,o),n.manager.itemStart(e),o.src=e,o}}class Rc extends er{constructor(e){super(e)}load(e,t,i,r){const n=new uo;n.colorSpace=Ct;const a=new Cc(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(h){n.images[c]=h,o++,o===6&&(n.needsUpdate=!0,t&&t(n))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return n}}class qd extends er{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new Xr,o=new Co(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(n.withCredentials),o.load(e,function(l){let c;try{c=n.parse(l)}catch(h){if(r!==void 0)r(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:$t,a.wrapT=c.wrapT!==void 0?c.wrapT:$t,a.magFilter=c.magFilter!==void 0?c.magFilter:yt,a.minFilter=c.minFilter!==void 0?c.minFilter:yt,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=Ti),c.mipmapCount===1&&(a.minFilter=yt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,r),a}}class Ac extends er{constructor(e){super(e)}load(e,t,i,r){const n=new Rt,a=new Cc(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){n.image=o,n.needsUpdate=!0,t!==void 0&&t(n)},i,r),n}}class Rs extends ht{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new _e(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 Ro=new Le,Pc=new w,Lc=new w;class Ao{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new oe(512,512),this.mapType=ni,this.map=null,this.mapPass=null,this.matrix=new Le,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new bo,this._frameExtents=new oe(1,1),this._viewportCount=1,this._viewports=[new Ke(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Pc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Pc),Lc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Lc),t.updateMatrixWorld(),Ro.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ro,t.coordinateSystem,t.reversedDepth),t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ro)}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 Yd extends Ao{constructor(){super(new Tt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Pr*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,n=e.distance||t.far;(i!==t.fov||r!==t.aspect||n!==t.far)&&(t.fov=i,t.aspect=r,t.far=n,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Kd extends Rs{constructor(e,t,i=0,r=Math.PI/3,n=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.distance=i,this.angle=r,this.penumbra=n,this.decay=a,this.map=null,this.shadow=new Yd}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 Dc=new Le,As=new w,Po=new w;class Zd extends Ao{constructor(){super(new Tt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new oe(4,2),this._viewportCount=6,this._viewports=[new Ke(2,1,1,1),new Ke(0,1,1,1),new Ke(3,1,1,1),new Ke(1,1,1,1),new Ke(3,0,1,1),new Ke(1,0,1,1)],this._cubeDirections=[new w(1,0,0),new w(-1,0,0),new w(0,0,1),new w(0,0,-1),new w(0,1,0),new w(0,-1,0)],this._cubeUps=[new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,0,1),new w(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,n=e.distance||i.far;n!==i.far&&(i.far=n,i.updateProjectionMatrix()),As.setFromMatrixPosition(e.matrixWorld),i.position.copy(As),Po.copy(i.position),Po.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Po),i.updateMatrixWorld(),r.makeTranslation(-As.x,-As.y,-As.z),Dc.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Dc,i.coordinateSystem,i.reversedDepth)}}class $d extends Rs{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new Zd}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 pr extends ic{constructor(e=-1,t=1,i=1,r=-1,n=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=n,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,n,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let n=i-e,a=i+e,o=r+t,l=r-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;n+=c*this.view.offsetX,a=n+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(n,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 Jd extends Ao{constructor(){super(new pr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ic extends Rs{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.shadow=new Jd}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Uc extends Rs{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ps{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 Lo=new WeakMap;class Qd extends er{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&be("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&be("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=Hi.get(`image-bitmap:${e}`);if(a!==void 0){if(n.manager.itemStart(e),a.then){a.then(c=>{if(Lo.has(a)===!0)r&&r(Lo.get(a)),n.manager.itemError(e),n.manager.itemEnd(e);else return t&&t(c),n.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),n.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(n.options,{colorSpaceConversion:"none"}))}).then(function(c){return Hi.add(`image-bitmap:${e}`,c),t&&t(c),n.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Lo.set(l,c),Hi.remove(`image-bitmap:${e}`),n.manager.itemError(e),n.manager.itemEnd(e)});Hi.add(`image-bitmap:${e}`,l),n.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class ep extends Tt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class tp{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 Do="\\[\\]\\.:\\/",ip=new RegExp("["+Do+"]","g"),Io="[^"+Do+"]",rp="[^"+Do.replace("\\.","")+"]",sp=/((?:WC+[\/:])*)/.source.replace("WC",Io),np=/(WCOD+)?/.source.replace("WCOD",rp),ap=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Io),op=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Io),lp=new RegExp("^"+sp+np+ap+op+"$"),cp=["material","materials","bones","map"];class hp{constructor(e,t,i){const r=i||it.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class it{constructor(e,t,i){this.path=t,this.parsedPath=i||it.parseTrackName(t),this.node=it.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new it.Composite(e,t,i):new it(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ip,"")}static parseTrackName(e){const t=lp.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const n=i.nodeName.substring(r+1);cp.indexOf(n)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=n)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(n){for(let a=0;a<n.length;a++){const o=n[a];if(o.name===t||o.uuid===t)return o;const l=i(o.children);if(l)return l}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let n=t.propertyIndex;if(e||(e=it.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){be("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){He("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){He("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){He("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){He("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){He("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){He("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){He("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;He("PropertyBinding: Trying to update property for track: "+c+"."+r+" 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(n!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){He("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){He("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[n]!==void 0&&(n=e.morphTargetDictionary[n])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=n}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=r;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}}it.Composite=hp,it.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},it.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},it.prototype.GetterByBindingType=[it.prototype._getValue_direct,it.prototype._getValue_array,it.prototype._getValue_arrayElement,it.prototype._getValue_toArray],it.prototype.SetterByBindingTypeAndVersioning=[[it.prototype._setValue_direct,it.prototype._setValue_direct_setNeedsUpdate,it.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[it.prototype._setValue_array,it.prototype._setValue_array_setNeedsUpdate,it.prototype._setValue_array_setMatrixWorldNeedsUpdate],[it.prototype._setValue_arrayElement,it.prototype._setValue_arrayElement_setNeedsUpdate,it.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[it.prototype._setValue_fromArray,it.prototype._setValue_fromArray_setNeedsUpdate,it.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const Nc=new Le;class Oc{constructor(e,t,i=0,r=1/0){this.ray=new Or(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Qa,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):He("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Nc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Nc),this}intersectObject(e,t=!0,i=[]){return Uo(e,this,i,t),i.sort(Bc),i}intersectObjects(e,t=!0,i=[]){for(let r=0,n=e.length;r<n;r++)Uo(e[r],this,i,t);return i.sort(Bc),i}}function Bc(s,e){return s.distance-e.distance}function Uo(s,e,t,i){let r=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const n=s.children;for(let a=0,o=n.length;a<o;a++)Uo(n[a],e,t,!0)}}class Fc{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Fe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Fe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class up extends or{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){be("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function kc(s,e,t,i){const r=dp(i);switch(t){case El:return s*e;case ia:return s*e/r.components*r.byteLength;case ra:return s*e/r.components*r.byteLength;case sa:return s*e*2/r.components*r.byteLength;case na:return s*e*2/r.components*r.byteLength;case wl:return s*e*3/r.components*r.byteLength;case qt:return s*e*4/r.components*r.byteLength;case aa:return s*e*4/r.components*r.byteLength;case Vs:case Gs:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Ws:case js:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case la:case ha:return Math.max(s,16)*Math.max(e,8)/4;case oa:case ca:return Math.max(s,8)*Math.max(e,8)/2;case ua:case da:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case pa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case ma:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case fa:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case ga:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case va:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case _a:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case xa:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case ya:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case ba:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Ma:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case Ta:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case Sa:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Ea:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case wa:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case Ca:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case Ra:case Aa:case Pa:return Math.ceil(s/4)*Math.ceil(e/4)*16;case La:case Da:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Ia:case Ua:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function dp(s){switch(s){case ni:case bl:return{byteLength:1,components:1};case us:case Ml:case pt:return{byteLength:2,components:1};case ea:case ta:return{byteLength:2,components:4};case ar:case Qn:case Wt:return{byteLength:4,components:1};case Tl:case Sl:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"181"}})),typeof window<"u"&&(window.__THREE__?be("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="181");function zc(){let s=null,e=!1,t=null,i=null;function r(n,a){t(n,a),i=s.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=s.requestAnimationFrame(r),e=!0)},stop:function(){s.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(n){t=n},setContext:function(n){s=n}}}function pp(s){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,h),o.onUploadCallback();let m;if(c instanceof Float32Array)m=s.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)m=s.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=s.HALF_FLOAT:m=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=s.SHORT;else if(c instanceof Uint32Array)m=s.UNSIGNED_INT;else if(c instanceof Int32Array)m=s.INT;else if(c instanceof Int8Array)m=s.BYTE;else if(c instanceof Uint8Array)m=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function i(o,l,c){const h=l.array,u=l.updateRanges;if(s.bindBuffer(c,o),u.length===0)s.bufferSubData(c,0,h);else{u.sort((m,g)=>m.start-g.start);let d=0;for(let m=1;m<u.length;m++){const g=u[d],v=u[m];v.start<=g.start+g.count+1?g.count=Math.max(g.count,v.start+v.count-g.start):(++d,u[d]=v)}u.length=d+1;for(let m=0,g=u.length;m<g;m++){const v=u[m];s.bufferSubData(c,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function n(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,o,l),c.version=o.version}}return{get:r,remove:n,update:a}}var mp=`#ifdef USE_ALPHAHASH
|
||
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
#endif`,fp=`#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`,gp=`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
#endif`,vp=`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,_p=`#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`,xp=`#ifdef USE_ALPHATEST
|
||
uniform float alphaTest;
|
||
#endif`,yp=`#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`,bp=`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,Mp=`#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`,Tp=`#ifdef USE_BATCHING
|
||
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,Sp=`vec3 transformed = vec3( position );
|
||
#ifdef USE_ALPHAHASH
|
||
vPosition = vec3( position );
|
||
#endif`,Ep=`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,wp=`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`,Cp=`#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`,Rp=`#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`,Ap=`#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`,Pp=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,Lp=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,Dp=`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,Ip=`#if defined( USE_COLOR_ALPHA )
|
||
diffuseColor *= vColor;
|
||
#elif defined( USE_COLOR )
|
||
diffuseColor.rgb *= vColor;
|
||
#endif`,Up=`#if defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#elif defined( USE_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,Np=`#if defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,Op=`#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`,Bp=`#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`,Fp=`#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`,kp=`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`,zp=`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,Hp=`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
#endif`,Vp=`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
#endif
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,Gp=`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,Wp="gl_FragColor = linearToOutputTexel( gl_FragColor );",jp=`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 );
|
||
}`,Xp=`#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`,qp=`#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`,Yp=`#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`,Kp=`#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`,Zp=`#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`,$p=`#ifdef USE_FOG
|
||
vFogDepth = - mvPosition.z;
|
||
#endif`,Jp=`#ifdef USE_FOG
|
||
varying float vFogDepth;
|
||
#endif`,Qp=`#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`,em=`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float vFogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,tm=`#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
|
||
}`,im=`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,rm=`LambertMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularStrength = specularStrength;`,sm=`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`,nm=`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`,am=`#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`,om=`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,lm=`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`,cm=`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,hm=`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`,um=`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`,dm=`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 );
|
||
}`,pm=`
|
||
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`,mm=`#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`,fm=`#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`,gm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,vm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,_m=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,xm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#endif`,ym=`#ifdef USE_MAP
|
||
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
#endif
|
||
diffuseColor *= sampledDiffuseColor;
|
||
#endif`,bm=`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,Mm=`#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`,Tm=`#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`,Sm=`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,Em=`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,wm=`#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`,Cm=`#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`,Rm=`#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`,Am=`#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`,Pm=`#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`,Lm=`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;`,Dm=`#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`,Im=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,Um=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,Nm=`#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif`,Om=`#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`,Bm=`#ifdef USE_CLEARCOAT
|
||
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
#endif`,Fm=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
#endif`,km=`#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`,zm=`#ifdef USE_IRIDESCENCEMAP
|
||
uniform sampler2D iridescenceMap;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform sampler2D iridescenceThicknessMap;
|
||
#endif`,Hm=`#ifdef OPAQUE
|
||
diffuseColor.a = 1.0;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
diffuseColor.a *= material.transmissionAlpha;
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Vm=`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 );
|
||
}`,Gm=`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,Wm=`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;`,jm=`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,Xm=`#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`,qm=`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,Ym=`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,Km=`#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`,Zm=`#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`,$m=`#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`,Jm=`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;
|
||
}`,Qm=`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,ef=`#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`,tf=`#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`,rf=`#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`,sf=`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,nf=`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,af=`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,of=`#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; }`,lf=`#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`,cf=`#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`,hf=`#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`,uf=`#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`,df=`#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`,pf=`#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 mf=`varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
void main() {
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
}`,ff=`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>
|
||
}`,gf=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,vf=`#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>
|
||
}`,_f=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,xf=`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>
|
||
}`,yf=`#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;
|
||
}`,bf=`#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
|
||
}`,Mf=`#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;
|
||
}`,Tf=`#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 );
|
||
}`,Sf=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
}`,Ef=`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>
|
||
}`,wf=`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>
|
||
}`,Cf=`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>
|
||
}`,Rf=`#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>
|
||
}`,Af=`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>
|
||
}`,Pf=`#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>
|
||
}`,Lf=`#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>
|
||
}`,Df=`#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;
|
||
}`,If=`#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>
|
||
}`,Uf=`#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
|
||
}`,Nf=`#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
|
||
}`,Of=`#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>
|
||
}`,Bf=`#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>
|
||
}`,Ff=`#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
|
||
}`,kf=`#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>
|
||
}`,zf=`#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>
|
||
}`,Hf=`#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>
|
||
}`,Vf=`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>
|
||
}`,Gf=`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>
|
||
}`,Wf=`#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>
|
||
}`,jf=`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>
|
||
}`,Xf=`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>
|
||
}`,qf=`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>
|
||
}`,ke={alphahash_fragment:mp,alphahash_pars_fragment:fp,alphamap_fragment:gp,alphamap_pars_fragment:vp,alphatest_fragment:_p,alphatest_pars_fragment:xp,aomap_fragment:yp,aomap_pars_fragment:bp,batching_pars_vertex:Mp,batching_vertex:Tp,begin_vertex:Sp,beginnormal_vertex:Ep,bsdfs:wp,iridescence_fragment:Cp,bumpmap_pars_fragment:Rp,clipping_planes_fragment:Ap,clipping_planes_pars_fragment:Pp,clipping_planes_pars_vertex:Lp,clipping_planes_vertex:Dp,color_fragment:Ip,color_pars_fragment:Up,color_pars_vertex:Np,color_vertex:Op,common:Bp,cube_uv_reflection_fragment:Fp,defaultnormal_vertex:kp,displacementmap_pars_vertex:zp,displacementmap_vertex:Hp,emissivemap_fragment:Vp,emissivemap_pars_fragment:Gp,colorspace_fragment:Wp,colorspace_pars_fragment:jp,envmap_fragment:Xp,envmap_common_pars_fragment:qp,envmap_pars_fragment:Yp,envmap_pars_vertex:Kp,envmap_physical_pars_fragment:am,envmap_vertex:Zp,fog_vertex:$p,fog_pars_vertex:Jp,fog_fragment:Qp,fog_pars_fragment:em,gradientmap_pars_fragment:tm,lightmap_pars_fragment:im,lights_lambert_fragment:rm,lights_lambert_pars_fragment:sm,lights_pars_begin:nm,lights_toon_fragment:om,lights_toon_pars_fragment:lm,lights_phong_fragment:cm,lights_phong_pars_fragment:hm,lights_physical_fragment:um,lights_physical_pars_fragment:dm,lights_fragment_begin:pm,lights_fragment_maps:mm,lights_fragment_end:fm,logdepthbuf_fragment:gm,logdepthbuf_pars_fragment:vm,logdepthbuf_pars_vertex:_m,logdepthbuf_vertex:xm,map_fragment:ym,map_pars_fragment:bm,map_particle_fragment:Mm,map_particle_pars_fragment:Tm,metalnessmap_fragment:Sm,metalnessmap_pars_fragment:Em,morphinstance_vertex:wm,morphcolor_vertex:Cm,morphnormal_vertex:Rm,morphtarget_pars_vertex:Am,morphtarget_vertex:Pm,normal_fragment_begin:Lm,normal_fragment_maps:Dm,normal_pars_fragment:Im,normal_pars_vertex:Um,normal_vertex:Nm,normalmap_pars_fragment:Om,clearcoat_normal_fragment_begin:Bm,clearcoat_normal_fragment_maps:Fm,clearcoat_pars_fragment:km,iridescence_pars_fragment:zm,opaque_fragment:Hm,packing:Vm,premultiplied_alpha_fragment:Gm,project_vertex:Wm,dithering_fragment:jm,dithering_pars_fragment:Xm,roughnessmap_fragment:qm,roughnessmap_pars_fragment:Ym,shadowmap_pars_fragment:Km,shadowmap_pars_vertex:Zm,shadowmap_vertex:$m,shadowmask_pars_fragment:Jm,skinbase_vertex:Qm,skinning_pars_vertex:ef,skinning_vertex:tf,skinnormal_vertex:rf,specularmap_fragment:sf,specularmap_pars_fragment:nf,tonemapping_fragment:af,tonemapping_pars_fragment:of,transmission_fragment:lf,transmission_pars_fragment:cf,uv_pars_fragment:hf,uv_pars_vertex:uf,uv_vertex:df,worldpos_vertex:pf,background_vert:mf,background_frag:ff,backgroundCube_vert:gf,backgroundCube_frag:vf,cube_vert:_f,cube_frag:xf,depth_vert:yf,depth_frag:bf,distanceRGBA_vert:Mf,distanceRGBA_frag:Tf,equirect_vert:Sf,equirect_frag:Ef,linedashed_vert:wf,linedashed_frag:Cf,meshbasic_vert:Rf,meshbasic_frag:Af,meshlambert_vert:Pf,meshlambert_frag:Lf,meshmatcap_vert:Df,meshmatcap_frag:If,meshnormal_vert:Uf,meshnormal_frag:Nf,meshphong_vert:Of,meshphong_frag:Bf,meshphysical_vert:Ff,meshphysical_frag:kf,meshtoon_vert:zf,meshtoon_frag:Hf,points_vert:Vf,points_frag:Gf,shadow_vert:Wf,shadow_frag:jf,sprite_vert:Xf,sprite_frag:qf},le={common:{diffuse:{value:new _e(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Be}},envmap:{envMap:{value:null},envMapRotation:{value:new Be},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 Be}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Be}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Be},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Be},normalScale:{value:new oe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Be},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Be}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Be}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Be}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _e(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 _e(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0},uvTransform:{value:new Be}},sprite:{diffuse:{value:new _e(16777215)},opacity:{value:1},center:{value:new oe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}}},Ri={basic:{uniforms:Ht([le.common,le.specularmap,le.envmap,le.aomap,le.lightmap,le.fog]),vertexShader:ke.meshbasic_vert,fragmentShader:ke.meshbasic_frag},lambert:{uniforms:Ht([le.common,le.specularmap,le.envmap,le.aomap,le.lightmap,le.emissivemap,le.bumpmap,le.normalmap,le.displacementmap,le.fog,le.lights,{emissive:{value:new _e(0)}}]),vertexShader:ke.meshlambert_vert,fragmentShader:ke.meshlambert_frag},phong:{uniforms:Ht([le.common,le.specularmap,le.envmap,le.aomap,le.lightmap,le.emissivemap,le.bumpmap,le.normalmap,le.displacementmap,le.fog,le.lights,{emissive:{value:new _e(0)},specular:{value:new _e(1118481)},shininess:{value:30}}]),vertexShader:ke.meshphong_vert,fragmentShader:ke.meshphong_frag},standard:{uniforms:Ht([le.common,le.envmap,le.aomap,le.lightmap,le.emissivemap,le.bumpmap,le.normalmap,le.displacementmap,le.roughnessmap,le.metalnessmap,le.fog,le.lights,{emissive:{value:new _e(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ke.meshphysical_vert,fragmentShader:ke.meshphysical_frag},toon:{uniforms:Ht([le.common,le.aomap,le.lightmap,le.emissivemap,le.bumpmap,le.normalmap,le.displacementmap,le.gradientmap,le.fog,le.lights,{emissive:{value:new _e(0)}}]),vertexShader:ke.meshtoon_vert,fragmentShader:ke.meshtoon_frag},matcap:{uniforms:Ht([le.common,le.bumpmap,le.normalmap,le.displacementmap,le.fog,{matcap:{value:null}}]),vertexShader:ke.meshmatcap_vert,fragmentShader:ke.meshmatcap_frag},points:{uniforms:Ht([le.points,le.fog]),vertexShader:ke.points_vert,fragmentShader:ke.points_frag},dashed:{uniforms:Ht([le.common,le.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ke.linedashed_vert,fragmentShader:ke.linedashed_frag},depth:{uniforms:Ht([le.common,le.displacementmap]),vertexShader:ke.depth_vert,fragmentShader:ke.depth_frag},normal:{uniforms:Ht([le.common,le.bumpmap,le.normalmap,le.displacementmap,{opacity:{value:1}}]),vertexShader:ke.meshnormal_vert,fragmentShader:ke.meshnormal_frag},sprite:{uniforms:Ht([le.sprite,le.fog]),vertexShader:ke.sprite_vert,fragmentShader:ke.sprite_frag},background:{uniforms:{uvTransform:{value:new Be},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ke.background_vert,fragmentShader:ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Be}},vertexShader:ke.backgroundCube_vert,fragmentShader:ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ke.cube_vert,fragmentShader:ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ke.equirect_vert,fragmentShader:ke.equirect_frag},distanceRGBA:{uniforms:Ht([le.common,le.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ke.distanceRGBA_vert,fragmentShader:ke.distanceRGBA_frag},shadow:{uniforms:Ht([le.lights,le.fog,{color:{value:new _e(0)},opacity:{value:1}}]),vertexShader:ke.shadow_vert,fragmentShader:ke.shadow_frag}};Ri.physical={uniforms:Ht([Ri.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Be},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Be},clearcoatNormalScale:{value:new oe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Be},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Be},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Be},sheen:{value:0},sheenColor:{value:new _e(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Be},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Be},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Be},transmissionSamplerSize:{value:new oe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Be},attenuationDistance:{value:0},attenuationColor:{value:new _e(0)},specularColor:{value:new _e(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Be},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Be},anisotropyVector:{value:new oe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Be}}]),vertexShader:ke.meshphysical_vert,fragmentShader:ke.meshphysical_frag};const Sn={r:0,b:0,g:0},mr=new ui,Yf=new Le;function Kf(s,e,t,i,r,n,a){const o=new _e(0);let l=n===!0?0:1,c,h,u=null,d=0,m=null;function g(_){let E=_.isScene===!0?_.background:null;return E&&E.isTexture&&(E=(_.backgroundBlurriness>0?t:e).get(E)),E}function v(_){let E=!1;const R=g(_);R===null?p(o,l):R&&R.isColor&&(p(R,1),E=!0);const T=s.xr.getEnvironmentBlendMode();T==="additive"?i.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(s.autoClear||E)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function f(_,E){const R=g(E);R&&(R.isCubeTexture||R.mapping===ks)?(h===void 0&&(h=new rt(new ur(1,1,1),new ot({name:"BackgroundCubeMaterial",uniforms:Gr(Ri.backgroundCube.uniforms),vertexShader:Ri.backgroundCube.vertexShader,fragmentShader:Ri.backgroundCube.fragmentShader,side:Ft,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,A,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),mr.copy(E.backgroundRotation),mr.x*=-1,mr.y*=-1,mr.z*=-1,R.isCubeTexture&&R.isRenderTargetTexture===!1&&(mr.y*=-1,mr.z*=-1),h.material.uniforms.envMap.value=R,h.material.uniforms.flipEnvMap.value=R.isCubeTexture&&R.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Yf.makeRotationFromEuler(mr)),h.material.toneMapped=je.getTransfer(R.colorSpace)!==et,(u!==R||d!==R.version||m!==s.toneMapping)&&(h.material.needsUpdate=!0,u=R,d=R.version,m=s.toneMapping),h.layers.enableAll(),_.unshift(h,h.geometry,h.material,0,0,null)):R&&R.isTexture&&(c===void 0&&(c=new rt(new ws(2,2),new ot({name:"BackgroundMaterial",uniforms:Gr(Ri.background.uniforms),vertexShader:Ri.background.vertexShader,fragmentShader:Ri.background.fragmentShader,side:bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=R,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=je.getTransfer(R.colorSpace)!==et,R.matrixAutoUpdate===!0&&R.updateMatrix(),c.material.uniforms.uvTransform.value.copy(R.matrix),(u!==R||d!==R.version||m!==s.toneMapping)&&(c.material.needsUpdate=!0,u=R,d=R.version,m=s.toneMapping),c.layers.enableAll(),_.unshift(c,c.geometry,c.material,0,0,null))}function p(_,E){_.getRGB(Sn,tc(s)),i.buffers.color.setClear(Sn.r,Sn.g,Sn.b,E,a)}function y(){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(_,E=1){o.set(_),l=E,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(_){l=_,p(o,l)},render:v,addToRenderList:f,dispose:y}}function Zf(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},r=d(null);let n=r,a=!1;function o(M,L,N,z,H){let j=!1;const q=u(z,N,L);n!==q&&(n=q,c(n.object)),j=m(M,z,N,H),j&&g(M,z,N,H),H!==null&&e.update(H,s.ELEMENT_ARRAY_BUFFER),(j||a)&&(a=!1,E(M,L,N,z),H!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return s.createVertexArray()}function c(M){return s.bindVertexArray(M)}function h(M){return s.deleteVertexArray(M)}function u(M,L,N){const z=N.wireframe===!0;let H=i[M.id];H===void 0&&(H={},i[M.id]=H);let j=H[L.id];j===void 0&&(j={},H[L.id]=j);let q=j[z];return q===void 0&&(q=d(l()),j[z]=q),q}function d(M){const L=[],N=[],z=[];for(let H=0;H<t;H++)L[H]=0,N[H]=0,z[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:N,attributeDivisors:z,object:M,attributes:{},index:null}}function m(M,L,N,z){const H=n.attributes,j=L.attributes;let q=0;const te=N.getAttributes();for(const G in te)if(te[G].location>=0){const Z=H[G];let se=j[G];if(se===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(se=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(se=M.instanceColor)),Z===void 0||Z.attribute!==se||se&&Z.data!==se.data)return!0;q++}return n.attributesNum!==q||n.index!==z}function g(M,L,N,z){const H={},j=L.attributes;let q=0;const te=N.getAttributes();for(const G in te)if(te[G].location>=0){let Z=j[G];Z===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(Z=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(Z=M.instanceColor));const se={};se.attribute=Z,Z&&Z.data&&(se.data=Z.data),H[G]=se,q++}n.attributes=H,n.attributesNum=q,n.index=z}function v(){const M=n.newAttributes;for(let L=0,N=M.length;L<N;L++)M[L]=0}function f(M){p(M,0)}function p(M,L){const N=n.newAttributes,z=n.enabledAttributes,H=n.attributeDivisors;N[M]=1,z[M]===0&&(s.enableVertexAttribArray(M),z[M]=1),H[M]!==L&&(s.vertexAttribDivisor(M,L),H[M]=L)}function y(){const M=n.newAttributes,L=n.enabledAttributes;for(let N=0,z=L.length;N<z;N++)L[N]!==M[N]&&(s.disableVertexAttribArray(N),L[N]=0)}function _(M,L,N,z,H,j,q){q===!0?s.vertexAttribIPointer(M,L,N,H,j):s.vertexAttribPointer(M,L,N,z,H,j)}function E(M,L,N,z){v();const H=z.attributes,j=N.getAttributes(),q=L.defaultAttributeValues;for(const te in j){const G=j[te];if(G.location>=0){let Z=H[te];if(Z===void 0&&(te==="instanceMatrix"&&M.instanceMatrix&&(Z=M.instanceMatrix),te==="instanceColor"&&M.instanceColor&&(Z=M.instanceColor)),Z!==void 0){const se=Z.normalized,Pe=Z.itemSize,ze=e.get(Z);if(ze===void 0)continue;const qe=ze.buffer,Ze=ze.type,$e=ze.bytesPerElement,W=Ze===s.INT||Ze===s.UNSIGNED_INT||Z.gpuType===Qn;if(Z.isInterleavedBufferAttribute){const Y=Z.data,ue=Y.stride,Ce=Z.offset;if(Y.isInstancedInterleavedBuffer){for(let Te=0;Te<G.locationSize;Te++)p(G.location+Te,Y.meshPerAttribute);M.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let Te=0;Te<G.locationSize;Te++)f(G.location+Te);s.bindBuffer(s.ARRAY_BUFFER,qe);for(let Te=0;Te<G.locationSize;Te++)_(G.location+Te,Pe/G.locationSize,Ze,se,ue*$e,(Ce+Pe/G.locationSize*Te)*$e,W)}else{if(Z.isInstancedBufferAttribute){for(let Y=0;Y<G.locationSize;Y++)p(G.location+Y,Z.meshPerAttribute);M.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let Y=0;Y<G.locationSize;Y++)f(G.location+Y);s.bindBuffer(s.ARRAY_BUFFER,qe);for(let Y=0;Y<G.locationSize;Y++)_(G.location+Y,Pe/G.locationSize,Ze,se,Pe*$e,Pe/G.locationSize*Y*$e,W)}}else if(q!==void 0){const se=q[te];if(se!==void 0)switch(se.length){case 2:s.vertexAttrib2fv(G.location,se);break;case 3:s.vertexAttrib3fv(G.location,se);break;case 4:s.vertexAttrib4fv(G.location,se);break;default:s.vertexAttrib1fv(G.location,se)}}}}y()}function R(){I();for(const M in i){const L=i[M];for(const N in L){const z=L[N];for(const H in z)h(z[H].object),delete z[H];delete L[N]}delete i[M]}}function T(M){if(i[M.id]===void 0)return;const L=i[M.id];for(const N in L){const z=L[N];for(const H in z)h(z[H].object),delete z[H];delete L[N]}delete i[M.id]}function A(M){for(const L in i){const N=i[L];if(N[M.id]===void 0)continue;const z=N[M.id];for(const H in z)h(z[H].object),delete z[H];delete N[M.id]}}function I(){S(),a=!0,n!==r&&(n=r,c(n.object))}function S(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:I,resetDefaultState:S,dispose:R,releaseStatesOfGeometry:T,releaseStatesOfProgram:A,initAttributes:v,enableAttribute:f,disableUnusedAttributes:y}}function $f(s,e,t){let i;function r(c){i=c}function n(c,h){s.drawArrays(i,c,h),t.update(h,i,1)}function a(c,h,u){u!==0&&(s.drawArraysInstanced(i,c,h,u),t.update(h,i,u))}function o(c,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,h,0,u);let d=0;for(let m=0;m<u;m++)d+=h[m];t.update(d,i,1)}function l(c,h,u,d){if(u===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<c.length;g++)a(c[g],h[g],d[g]);else{m.multiDrawArraysInstancedWEBGL(i,c,0,h,0,d,0,u);let g=0;for(let v=0;v<u;v++)g+=h[v]*d[v];t.update(g,i,1)}}this.setMode=r,this.render=n,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Jf(s,e,t,i){let r;function n(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");r=s.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){return!(A!==qt&&i.convert(A)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const I=A===pt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==ni&&i.convert(A)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==Wt&&!I)}function l(A){if(A==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="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&&(be("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),f=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),p=s.getParameter(s.MAX_VERTEX_ATTRIBS),y=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),_=s.getParameter(s.MAX_VARYING_VECTORS),E=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),R=g>0,T=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:n,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:m,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:y,maxVaryings:_,maxFragmentUniforms:E,vertexTextures:R,maxSamples:T}}function Qf(s){const e=this;let t=null,i=0,r=!1,n=!1;const a=new wi,o=new Be,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const m=u.length!==0||d||i!==0||r;return r=d,i=u.length,m},this.beginShadows=function(){n=!0,h(null)},this.endShadows=function(){n=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,m){const g=u.clippingPlanes,v=u.clipIntersection,f=u.clipShadows,p=s.get(u);if(!r||g===null||g.length===0||n&&!f)n?h(null):c();else{const y=n?0:i,_=y*4;let E=p.clippingState||null;l.value=E,E=h(g,d,_,m);for(let R=0;R!==_;++R)E[R]=t[R];p.clippingState=E,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(u,d,m,g){const v=u!==null?u.length:0;let f=null;if(v!==0){if(f=l.value,g!==!0||f===null){const p=m+v*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(f===null||f.length<p)&&(f=new Float32Array(p));for(let _=0,E=m;_!==v;++_,E+=4)a.copy(u[_]).applyMatrix4(y,o),a.normal.toArray(f,E),f[E+3]=a.constant}l.value=f,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,f}}function eg(s){let e=new WeakMap;function t(a,o){return o===Fs?a.mapping=Er:o===Jn&&(a.mapping=wr),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===Fs||o===Jn)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 vd(l.height);return c.fromEquirectangularTexture(s,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function n(){e=new WeakMap}return{get:i,dispose:n}}const tr=4,Hc=[.125,.215,.35,.446,.526,.582],fr=20,tg=256,Ls=new pr,Vc=new _e;let No=null,Oo=0,Bo=0,Fo=!1;const ig=new w;class Gc{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,n={}){const{size:a=256,position:o=ig}=n;No=this._renderer.getRenderTarget(),Oo=this._renderer.getActiveCubeFace(),Bo=this._renderer.getActiveMipmapLevel(),Fo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,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=Xc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jc(),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(No,Oo,Bo),this._renderer.xr.enabled=Fo,e.scissorTest=!1,es(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Er||e.mapping===wr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),No=this._renderer.getRenderTarget(),Oo=this._renderer.getActiveCubeFace(),Bo=this._renderer.getActiveMipmapLevel(),Fo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:yt,minFilter:yt,generateMipmaps:!1,type:pt,format:qt,colorSpace:Nt,depthBuffer:!1},r=Wc(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Wc(e,t,i);const{_lodMax:n}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=rg(n)),this._blurMaterial=ng(n,e,t),this._ggxMaterial=sg(n,e,t)}return r}_compileMaterial(e){const t=new rt(new ei,e);this._renderer.compile(t,Ls)}_sceneToCubeUV(e,t,i,r,n){const a=new Tt(90,1,t,i),o=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],c=this._renderer,h=c.autoClear,u=c.toneMapping;c.getClearColor(Vc),c.toneMapping=Xi,c.autoClear=!1,c.state.buffers.depth.getReversed()&&(c.setRenderTarget(r),c.clearDepth(),c.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new rt(new ur,new kt({name:"PMREM.Background",side:Ft,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,m=d.material;let g=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,g=!0):(m.color.copy(Vc),g=!0);for(let f=0;f<6;f++){const p=f%3;p===0?(a.up.set(0,o[f],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x+l[f],n.y,n.z)):p===1?(a.up.set(0,0,o[f]),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y+l[f],n.z)):(a.up.set(0,o[f],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y,n.z+l[f]));const y=this._cubeSize;es(r,p*y,f>2?y:0,y,y),c.setRenderTarget(r),g&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=h,e.background=v}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Er||e.mapping===wr;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Xc()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jc());const n=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=n;const o=n.uniforms;o.envMap.value=e;const l=this._cubeSize;es(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Ls)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let n=1;n<r;n++)this._applyGGXFilter(e,n-1,n);t.autoClear=i}_applyGGXFilter(e,t,i){const r=this._renderer,n=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-h*h),d=.05+c*.95,m=u*d,{_lodMax:g}=this,v=this._sizeLods[i],f=3*v*(i>g-tr?i-g+tr:0),p=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=g-t,es(n,f,p,3*v,2*v),r.setRenderTarget(n),r.render(o,Ls),l.envMap.value=n.texture,l.roughness.value=0,l.mipInt.value=g-i,es(e,f,p,3*v,2*v),r.setRenderTarget(e),r.render(o,Ls)}_blur(e,t,i,r,n){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",n),this._halfBlur(a,e,i,i,r,"longitudinal",n)}_halfBlur(e,t,i,r,n,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&He("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[r];u.material=c;const d=c.uniforms,m=this._sizeLods[i]-1,g=isFinite(n)?Math.PI/(2*m):2*Math.PI/(2*fr-1),v=n/g,f=isFinite(n)?1+Math.floor(h*v):fr;f>fr&&be(`sigmaRadians, ${n}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${fr}`);const p=[];let y=0;for(let A=0;A<fr;++A){const I=A/v,S=Math.exp(-I*I/2);p.push(S),A===0?y+=S:A<f&&(y+=2*S)}for(let A=0;A<p.length;A++)p[A]=p[A]/y;d.envMap.value=e.texture,d.samples.value=f,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:_}=this;d.dTheta.value=g,d.mipInt.value=_-i;const E=this._sizeLods[r],R=3*E*(r>_-tr?r-_+tr:0),T=4*(this._cubeSize-E);es(t,R,T,3*E,2*E),l.setRenderTarget(t),l.render(u,Ls)}}function rg(s){const e=[],t=[],i=[];let r=s;const n=s-tr+1+Hc.length;for(let a=0;a<n;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>s-tr?l=Hc[a-s+tr-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],m=6,g=6,v=3,f=2,p=1,y=new Float32Array(v*g*m),_=new Float32Array(f*g*m),E=new Float32Array(p*g*m);for(let T=0;T<m;T++){const A=T%3*2/3-1,I=T>2?0:-1,S=[A,I,0,A+2/3,I,0,A+2/3,I+1,0,A,I,0,A+2/3,I+1,0,A,I+1,0];y.set(S,v*g*T),_.set(d,f*g*T);const M=[T,T,T,T,T,T];E.set(M,p*g*T)}const R=new ei;R.setAttribute("position",new zt(y,v)),R.setAttribute("uv",new zt(_,f)),R.setAttribute("faceIndex",new zt(E,p)),i.push(new rt(R,null)),r>tr&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Wc(s,e,t){const i=new bt(s,e,t);return i.texture.mapping=ks,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function es(s,e,t,i,r){s.viewport.set(e,t,i,r),s.scissor.set(e,t,i,r)}function sg(s,e,t){return new ot({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:tg,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:En(),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:xt,depthTest:!1,depthWrite:!1})}function ng(s,e,t){const i=new Float32Array(fr),r=new w(0,1,0);return new ot({name:"SphericalGaussianBlur",defines:{n:fr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:En(),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:xt,depthTest:!1,depthWrite:!1})}function jc(){return new ot({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:En(),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:xt,depthTest:!1,depthWrite:!1})}function Xc(){return new ot({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:En(),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:xt,depthTest:!1,depthWrite:!1})}function En(){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 ag(s){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===Fs||l===Jn,h=l===Er||l===wr;if(c||h){let u=e.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Gc(s)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),u.texture;if(u!==void 0)return u.texture;{const m=o.image;return c&&m&&m.height>0||h&&m&&r(m)?(t===null&&(t=new Gc(s)),u=c?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",n),u.texture):null}}}return o}function r(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function n(o){const l=o.target;l.removeEventListener("dispose",n);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function og(s){const e={};function t(i){if(e[i]!==void 0)return e[i];const r=s.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&gs("WebGLRenderer: "+i+" extension not supported."),r}}}function lg(s,e,t,i){const r={},n=new WeakMap;function a(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete r[d.id];const m=n.get(d);m&&(e.remove(m),n.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(u){const d=u.attributes;for(const m in d)e.update(d[m],s.ARRAY_BUFFER)}function c(u){const d=[],m=u.index,g=u.attributes.position;let v=0;if(m!==null){const y=m.array;v=m.version;for(let _=0,E=y.length;_<E;_+=3){const R=y[_+0],T=y[_+1],A=y[_+2];d.push(R,T,T,A,A,R)}}else if(g!==void 0){const y=g.array;v=g.version;for(let _=0,E=y.length/3-1;_<E;_+=3){const R=_+0,T=_+1,A=_+2;d.push(R,T,T,A,A,R)}}else return;const f=new(Ul(d)?$l:Zl)(d,1);f.version=v;const p=n.get(u);p&&e.remove(p),n.set(u,f)}function h(u){const d=n.get(u);if(d){const m=u.index;m!==null&&d.version<m.version&&c(u)}else c(u);return n.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function cg(s,e,t){let i;function r(d){i=d}let n,a;function o(d){n=d.type,a=d.bytesPerElement}function l(d,m){s.drawElements(i,m,n,d*a),t.update(m,i,1)}function c(d,m,g){g!==0&&(s.drawElementsInstanced(i,m,n,d*a,g),t.update(m,i,g))}function h(d,m,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,m,0,n,d,0,g);let v=0;for(let f=0;f<g;f++)v+=m[f];t.update(v,i,1)}function u(d,m,g,v){if(g===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<d.length;p++)c(d[p]/a,m[p],v[p]);else{f.multiDrawElementsInstancedWEBGL(i,m,0,n,d,0,v,0,g);let p=0;for(let y=0;y<g;y++)p+=m[y]*v[y];t.update(p,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function hg(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(n,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(n/3);break;case s.LINES:t.lines+=o*(n/2);break;case s.LINE_STRIP:t.lines+=o*(n-1);break;case s.LINE_LOOP:t.lines+=o*n;break;case s.POINTS:t.points+=o*n;break;default:He("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function ug(s,e,t){const i=new WeakMap,r=new Ke;function n(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=i.get(o);if(d===void 0||d.count!==u){let m=function(){I.dispose(),i.delete(o),o.removeEventListener("dispose",m)};d!==void 0&&d.texture.dispose();const g=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,f=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],y=o.morphAttributes.normal||[],_=o.morphAttributes.color||[];let E=0;g===!0&&(E=1),v===!0&&(E=2),f===!0&&(E=3);let R=o.attributes.position.count*E,T=1;R>e.maxTextureSize&&(T=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const A=new Float32Array(R*T*4*u),I=new zl(A,R,T,u);I.type=Wt,I.needsUpdate=!0;const S=E*4;for(let M=0;M<u;M++){const L=p[M],N=y[M],z=_[M],H=R*T*4*M;for(let j=0;j<L.count;j++){const q=j*S;g===!0&&(r.fromBufferAttribute(L,j),A[H+q+0]=r.x,A[H+q+1]=r.y,A[H+q+2]=r.z,A[H+q+3]=0),v===!0&&(r.fromBufferAttribute(N,j),A[H+q+4]=r.x,A[H+q+5]=r.y,A[H+q+6]=r.z,A[H+q+7]=0),f===!0&&(r.fromBufferAttribute(z,j),A[H+q+8]=r.x,A[H+q+9]=r.y,A[H+q+10]=r.z,A[H+q+11]=z.itemSize===4?r.w:1)}}d={count:u,texture:I,size:new oe(R,T)},i.set(o,d),o.addEventListener("dispose",m)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let m=0;for(let v=0;v<c.length;v++)m+=c[v];const g=o.morphTargetsRelative?1:1-m;l.getUniforms().setValue(s,"morphTargetBaseInfluence",g),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:n}}function dg(s,e,t,i){let r=new WeakMap;function n(l){const c=i.render.frame,h=l.geometry,u=e.get(l,h);if(r.get(u)!==c&&(e.update(u),r.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return u}function a(){r=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:n,dispose:a}}const qc=new Rt,Yc=new Eo(1,1),Kc=new zl,Zc=new Ju,$c=new uo,Jc=[],Qc=[],eh=new Float32Array(16),th=new Float32Array(9),ih=new Float32Array(4);function ts(s,e,t){const i=s[0];if(i<=0||i>0)return s;const r=e*t;let n=Jc[r];if(n===void 0&&(n=new Float32Array(r),Jc[r]=n),e!==0){i.toArray(n,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(n,o)}return n}function St(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t<i;t++)if(s[t]!==e[t])return!1;return!0}function Et(s,e){for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}function wn(s,e){let t=Qc[e];t===void 0&&(t=new Int32Array(e),Qc[e]=t);for(let i=0;i!==e;++i)t[i]=s.allocateTextureUnit();return t}function pg(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function mg(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(St(t,e))return;s.uniform2fv(this.addr,e),Et(t,e)}}function fg(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(St(t,e))return;s.uniform3fv(this.addr,e),Et(t,e)}}function gg(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(St(t,e))return;s.uniform4fv(this.addr,e),Et(t,e)}}function vg(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(St(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),Et(t,e)}else{if(St(t,i))return;ih.set(i),s.uniformMatrix2fv(this.addr,!1,ih),Et(t,i)}}function _g(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(St(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),Et(t,e)}else{if(St(t,i))return;th.set(i),s.uniformMatrix3fv(this.addr,!1,th),Et(t,i)}}function xg(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(St(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),Et(t,e)}else{if(St(t,i))return;eh.set(i),s.uniformMatrix4fv(this.addr,!1,eh),Et(t,i)}}function yg(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function bg(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(St(t,e))return;s.uniform2iv(this.addr,e),Et(t,e)}}function Mg(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(St(t,e))return;s.uniform3iv(this.addr,e),Et(t,e)}}function Tg(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(St(t,e))return;s.uniform4iv(this.addr,e),Et(t,e)}}function Sg(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function Eg(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(St(t,e))return;s.uniform2uiv(this.addr,e),Et(t,e)}}function wg(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(St(t,e))return;s.uniform3uiv(this.addr,e),Et(t,e)}}function Cg(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(St(t,e))return;s.uniform4uiv(this.addr,e),Et(t,e)}}function Rg(s,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(s.uniform1i(this.addr,r),i[0]=r);let n;this.type===s.SAMPLER_2D_SHADOW?(Yc.compareFunction=Dl,n=Yc):n=qc,t.setTexture2D(e||n,r)}function Ag(s,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(s.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Zc,r)}function Pg(s,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(s.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||$c,r)}function Lg(s,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(s.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Kc,r)}function Dg(s){switch(s){case 5126:return pg;case 35664:return mg;case 35665:return fg;case 35666:return gg;case 35674:return vg;case 35675:return _g;case 35676:return xg;case 5124:case 35670:return yg;case 35667:case 35671:return bg;case 35668:case 35672:return Mg;case 35669:case 35673:return Tg;case 5125:return Sg;case 36294:return Eg;case 36295:return wg;case 36296:return Cg;case 35678:case 36198:case 36298:case 36306:case 35682:return Rg;case 35679:case 36299:case 36307:return Ag;case 35680:case 36300:case 36308:case 36293:return Pg;case 36289:case 36303:case 36311:case 36292:return Lg}}function Ig(s,e){s.uniform1fv(this.addr,e)}function Ug(s,e){const t=ts(e,this.size,2);s.uniform2fv(this.addr,t)}function Ng(s,e){const t=ts(e,this.size,3);s.uniform3fv(this.addr,t)}function Og(s,e){const t=ts(e,this.size,4);s.uniform4fv(this.addr,t)}function Bg(s,e){const t=ts(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function Fg(s,e){const t=ts(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function kg(s,e){const t=ts(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function zg(s,e){s.uniform1iv(this.addr,e)}function Hg(s,e){s.uniform2iv(this.addr,e)}function Vg(s,e){s.uniform3iv(this.addr,e)}function Gg(s,e){s.uniform4iv(this.addr,e)}function Wg(s,e){s.uniform1uiv(this.addr,e)}function jg(s,e){s.uniform2uiv(this.addr,e)}function Xg(s,e){s.uniform3uiv(this.addr,e)}function qg(s,e){s.uniform4uiv(this.addr,e)}function Yg(s,e,t){const i=this.cache,r=e.length,n=wn(t,r);St(i,n)||(s.uniform1iv(this.addr,n),Et(i,n));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||qc,n[a])}function Kg(s,e,t){const i=this.cache,r=e.length,n=wn(t,r);St(i,n)||(s.uniform1iv(this.addr,n),Et(i,n));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Zc,n[a])}function Zg(s,e,t){const i=this.cache,r=e.length,n=wn(t,r);St(i,n)||(s.uniform1iv(this.addr,n),Et(i,n));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||$c,n[a])}function $g(s,e,t){const i=this.cache,r=e.length,n=wn(t,r);St(i,n)||(s.uniform1iv(this.addr,n),Et(i,n));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Kc,n[a])}function Jg(s){switch(s){case 5126:return Ig;case 35664:return Ug;case 35665:return Ng;case 35666:return Og;case 35674:return Bg;case 35675:return Fg;case 35676:return kg;case 5124:case 35670:return zg;case 35667:case 35671:return Hg;case 35668:case 35672:return Vg;case 35669:case 35673:return Gg;case 5125:return Wg;case 36294:return jg;case 36295:return Xg;case 36296:return qg;case 35678:case 36198:case 36298:case 36306:case 35682:return Yg;case 35679:case 36299:case 36307:return Kg;case 35680:case 36300:case 36308:case 36293:return Zg;case 36289:case 36303:case 36311:case 36292:return $g}}class Qg{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=Dg(t.type)}}class ev{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Jg(t.type)}}class tv{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let n=0,a=r.length;n!==a;++n){const o=r[n];o.setValue(e,t[o.id],i)}}}const ko=/(\w+)(\])?(\[|\.)?/g;function rh(s,e){s.seq.push(e),s.map[e.id]=e}function iv(s,e,t){const i=s.name,r=i.length;for(ko.lastIndex=0;;){const n=ko.exec(i),a=ko.lastIndex;let o=n[1];const l=n[2]==="]",c=n[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){rh(t,c===void 0?new Qg(o,s,e):new ev(o,s,e));break}else{let h=t.map[o];h===void 0&&(h=new tv(o),rh(t,h)),t=h}}}class Cn{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const n=e.getActiveUniform(t,r),a=e.getUniformLocation(t,n.name);iv(n,a,this)}}setValue(e,t,i,r){const n=this.map[t];n!==void 0&&n.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let n=0,a=t.length;n!==a;++n){const o=t[n],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,n=e.length;r!==n;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function sh(s,e,t){const i=s.createShader(e);return s.shaderSource(i,t),s.compileShader(i),i}const rv=37297;let sv=0;function nv(s,e){const t=s.split(`
|
||
`),i=[],r=Math.max(e-6,0),n=Math.min(e+6,t.length);for(let a=r;a<n;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
||
`)}const nh=new Be;function av(s){je._getMatrix(nh,je.workingColorSpace,s);const e=`mat3( ${nh.elements.map(t=>t.toFixed(4))} )`;switch(je.getTransfer(s)){case qs:return[e,"LinearTransferOETF"];case et:return[e,"sRGBTransferOETF"];default:return be("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function ah(s,e,t){const i=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const n=/ERROR: 0:(\d+)/.exec(r);if(n){const a=parseInt(n[1]);return t.toUpperCase()+`
|
||
|
||
`+r+`
|
||
|
||
`+nv(s.getShaderSource(e),a)}else return r}function ov(s,e){const t=av(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
||
`)}function lv(s,e){let t;switch(e){case dl:t="Linear";break;case pl:t="Reinhard";break;case ml:t="Cineon";break;case $n:t="ACESFilmic";break;case gl:t="AgX";break;case vl:t="Neutral";break;case fl:t="Custom";break;default:be("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Rn=new w;function cv(){je.getLuminanceCoefficients(Rn);const s=Rn.x.toFixed(4),e=Rn.y.toFixed(4),t=Rn.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
||
`)}function hv(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ds).join(`
|
||
`)}function uv(s){const e=[];for(const t in s){const i=s[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
||
`)}function dv(s,e){const t={},i=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const n=s.getActiveAttrib(e,r),a=n.name;let o=1;n.type===s.FLOAT_MAT2&&(o=2),n.type===s.FLOAT_MAT3&&(o=3),n.type===s.FLOAT_MAT4&&(o=4),t[a]={type:n.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function Ds(s){return s!==""}function oh(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 lh(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const pv=/^[ \t]*#include +<([\w\d./]+)>/gm;function zo(s){return s.replace(pv,fv)}const mv=new Map;function fv(s,e){let t=ke[e];if(t===void 0){const i=mv.get(e);if(i!==void 0)t=ke[i],be('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return zo(t)}const gv=/#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 ch(s){return s.replace(gv,vv)}function vv(s,e,t,i){let r="";for(let n=parseInt(e);n<parseInt(t);n++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+n+" ]").replace(/UNROLLED_LOOP_INDEX/g,n);return r}function hh(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 _v(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===ol?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===ll?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===Di&&(e="SHADOWMAP_TYPE_VSM"),e}function xv(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case Er:case wr:e="ENVMAP_TYPE_CUBE";break;case ks:e="ENVMAP_TYPE_CUBE_UV";break}return e}function yv(s){let e="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case wr:e="ENVMAP_MODE_REFRACTION";break}return e}function bv(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case Zn:e="ENVMAP_BLENDING_MULTIPLY";break;case mu:e="ENVMAP_BLENDING_MIX";break;case fu:e="ENVMAP_BLENDING_ADD";break}return e}function Mv(s){const e=s.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function Tv(s,e,t,i){const r=s.getContext(),n=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=_v(t),c=xv(t),h=yv(t),u=bv(t),d=Mv(t),m=hv(t),g=uv(n),v=r.createProgram();let f,p,y=t.glslVersion?"#version "+t.glslVersion+`
|
||
`:"";t.isRawShaderMaterial?(f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ds).join(`
|
||
`),f.length>0&&(f+=`
|
||
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ds).join(`
|
||
`),p.length>0&&(p+=`
|
||
`)):(f=[hh(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(Ds).join(`
|
||
`),p=[hh(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 "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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!==Xi?"#define TONE_MAPPING":"",t.toneMapping!==Xi?ke.tonemapping_pars_fragment:"",t.toneMapping!==Xi?lv("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ke.colorspace_pars_fragment,ov("linearToOutputTexel",t.outputColorSpace),cv(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
||
`].filter(Ds).join(`
|
||
`)),a=zo(a),a=oh(a,t),a=lh(a,t),o=zo(o),o=oh(o,t),o=lh(o,t),a=ch(a),o=ch(o),t.isRawShaderMaterial!==!0&&(y=`#version 300 es
|
||
`,f=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
`)+`
|
||
`+f,p=["#define varying in",t.glslVersion===Il?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Il?"":"#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(`
|
||
`)+`
|
||
`+p);const _=y+f+a,E=y+p+o,R=sh(r,r.VERTEX_SHADER,_),T=sh(r,r.FRAGMENT_SHADER,E);r.attachShader(v,R),r.attachShader(v,T),t.index0AttributeName!==void 0?r.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function A(L){if(s.debug.checkShaderErrors){const N=r.getProgramInfoLog(v)||"",z=r.getShaderInfoLog(R)||"",H=r.getShaderInfoLog(T)||"",j=N.trim(),q=z.trim(),te=H.trim();let G=!0,Z=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(G=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(r,v,R,T);else{const se=ah(r,R,"vertex"),Pe=ah(r,T,"fragment");He("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
|
||
|
||
Material Name: `+L.name+`
|
||
Material Type: `+L.type+`
|
||
|
||
Program Info Log: `+j+`
|
||
`+se+`
|
||
`+Pe)}else j!==""?be("WebGLProgram: Program Info Log:",j):(q===""||te==="")&&(Z=!1);Z&&(L.diagnostics={runnable:G,programLog:j,vertexShader:{log:q,prefix:f},fragmentShader:{log:te,prefix:p}})}r.deleteShader(R),r.deleteShader(T),I=new Cn(r,v),S=dv(r,v)}let I;this.getUniforms=function(){return I===void 0&&A(this),I};let S;this.getAttributes=function(){return S===void 0&&A(this),S};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,rv)),M},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=sv++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=R,this.fragmentShader=T,this}let Sv=0;class Ev{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),n=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(n)===!1&&(a.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new wv(e),t.set(e,i)),i}}class wv{constructor(e){this.id=Sv++,this.code=e,this.usedTimes=0}}function Cv(s,e,t,i,r,n,a){const o=new Qa,l=new Ev,c=new Set,h=[],u=r.logarithmicDepthBuffer,d=r.vertexTextures;let m=r.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 v(S){return c.add(S),S===0?"uv":`uv${S}`}function f(S,M,L,N,z){const H=N.fog,j=z.geometry,q=S.isMeshStandardMaterial?N.environment:null,te=(S.isMeshStandardMaterial?t:e).get(S.envMap||q),G=te&&te.mapping===ks?te.image.height:null,Z=g[S.type];S.precision!==null&&(m=r.getMaxPrecision(S.precision),m!==S.precision&&be("WebGLProgram.getParameters:",S.precision,"not supported, using",m,"instead."));const se=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,Pe=se!==void 0?se.length:0;let ze=0;j.morphAttributes.position!==void 0&&(ze=1),j.morphAttributes.normal!==void 0&&(ze=2),j.morphAttributes.color!==void 0&&(ze=3);let qe,Ze,$e,W;if(Z){const nt=Ri[Z];qe=nt.vertexShader,Ze=nt.fragmentShader}else qe=S.vertexShader,Ze=S.fragmentShader,l.update(S),$e=l.getVertexShaderID(S),W=l.getFragmentShaderID(S);const Y=s.getRenderTarget(),ue=s.state.buffers.depth.getReversed(),Ce=z.isInstancedMesh===!0,Te=z.isBatchedMesh===!0,Ee=!!S.map,Je=!!S.matcap,Xe=!!te,Ge=!!S.aoMap,D=!!S.lightMap,_t=!!S.bumpMap,We=!!S.normalMap,Qe=!!S.displacementMap,me=!!S.emissiveMap,at=!!S.metalnessMap,Me=!!S.roughnessMap,De=S.anisotropy>0,C=S.clearcoat>0,x=S.dispersion>0,B=S.iridescence>0,X=S.sheen>0,K=S.transmission>0,V=De&&!!S.anisotropyMap,xe=C&&!!S.clearcoatMap,ne=C&&!!S.clearcoatNormalMap,Se=C&&!!S.clearcoatRoughnessMap,de=B&&!!S.iridescenceMap,J=B&&!!S.iridescenceThicknessMap,re=X&&!!S.sheenColorMap,Oe=X&&!!S.sheenRoughnessMap,we=!!S.specularMap,he=!!S.specularColorMap,Re=!!S.specularIntensityMap,P=K&&!!S.transmissionMap,ae=K&&!!S.thicknessMap,ie=!!S.gradientMap,ce=!!S.alphaMap,Q=S.alphaTest>0,$=!!S.alphaHash,ve=!!S.extensions;let Ae=Xi;S.toneMapped&&(Y===null||Y.isXRRenderTarget===!0)&&(Ae=s.toneMapping);const Lt={shaderID:Z,shaderType:S.type,shaderName:S.name,vertexShader:qe,fragmentShader:Ze,defines:S.defines,customVertexShaderID:$e,customFragmentShaderID:W,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:m,batching:Te,batchingColor:Te&&z._colorsTexture!==null,instancing:Ce,instancingColor:Ce&&z.instanceColor!==null,instancingMorph:Ce&&z.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:Y===null?s.outputColorSpace:Y.isXRRenderTarget===!0?Y.texture.colorSpace:Nt,alphaToCoverage:!!S.alphaToCoverage,map:Ee,matcap:Je,envMap:Xe,envMapMode:Xe&&te.mapping,envMapCubeUVHeight:G,aoMap:Ge,lightMap:D,bumpMap:_t,normalMap:We,displacementMap:d&&Qe,emissiveMap:me,normalMapObjectSpace:We&&S.normalMapType===yu,normalMapTangentSpace:We&&S.normalMapType===Xs,metalnessMap:at,roughnessMap:Me,anisotropy:De,anisotropyMap:V,clearcoat:C,clearcoatMap:xe,clearcoatNormalMap:ne,clearcoatRoughnessMap:Se,dispersion:x,iridescence:B,iridescenceMap:de,iridescenceThicknessMap:J,sheen:X,sheenColorMap:re,sheenRoughnessMap:Oe,specularMap:we,specularColorMap:he,specularIntensityMap:Re,transmission:K,transmissionMap:P,thicknessMap:ae,gradientMap:ie,opaque:S.transparent===!1&&S.blending===Tr&&S.alphaToCoverage===!1,alphaMap:ce,alphaTest:Q,alphaHash:$,combine:S.combine,mapUv:Ee&&v(S.map.channel),aoMapUv:Ge&&v(S.aoMap.channel),lightMapUv:D&&v(S.lightMap.channel),bumpMapUv:_t&&v(S.bumpMap.channel),normalMapUv:We&&v(S.normalMap.channel),displacementMapUv:Qe&&v(S.displacementMap.channel),emissiveMapUv:me&&v(S.emissiveMap.channel),metalnessMapUv:at&&v(S.metalnessMap.channel),roughnessMapUv:Me&&v(S.roughnessMap.channel),anisotropyMapUv:V&&v(S.anisotropyMap.channel),clearcoatMapUv:xe&&v(S.clearcoatMap.channel),clearcoatNormalMapUv:ne&&v(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Se&&v(S.clearcoatRoughnessMap.channel),iridescenceMapUv:de&&v(S.iridescenceMap.channel),iridescenceThicknessMapUv:J&&v(S.iridescenceThicknessMap.channel),sheenColorMapUv:re&&v(S.sheenColorMap.channel),sheenRoughnessMapUv:Oe&&v(S.sheenRoughnessMap.channel),specularMapUv:we&&v(S.specularMap.channel),specularColorMapUv:he&&v(S.specularColorMap.channel),specularIntensityMapUv:Re&&v(S.specularIntensityMap.channel),transmissionMapUv:P&&v(S.transmissionMap.channel),thicknessMapUv:ae&&v(S.thicknessMap.channel),alphaMapUv:ce&&v(S.alphaMap.channel),vertexTangents:!!j.attributes.tangent&&(We||De),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!j.attributes.uv&&(Ee||ce),fog:!!H,useFog:S.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:S.flatShading===!0&&S.wireframe===!1,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:ue,skinning:z.isSkinnedMesh===!0,morphTargets:j.morphAttributes.position!==void 0,morphNormals:j.morphAttributes.normal!==void 0,morphColors:j.morphAttributes.color!==void 0,morphTargetsCount:Pe,morphTextureStride:ze,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:s.shadowMap.enabled&&L.length>0,shadowMapType:s.shadowMap.type,toneMapping:Ae,decodeVideoTexture:Ee&&S.map.isVideoTexture===!0&&je.getTransfer(S.map.colorSpace)===et,decodeVideoTextureEmissive:me&&S.emissiveMap.isVideoTexture===!0&&je.getTransfer(S.emissiveMap.colorSpace)===et,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Gt,flipSided:S.side===Ft,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:ve&&S.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&S.extensions.multiDraw===!0||Te)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return Lt.vertexUv1s=c.has(1),Lt.vertexUv2s=c.has(2),Lt.vertexUv3s=c.has(3),c.clear(),Lt}function p(S){const M=[];if(S.shaderID?M.push(S.shaderID):(M.push(S.customVertexShaderID),M.push(S.customFragmentShaderID)),S.defines!==void 0)for(const L in S.defines)M.push(L),M.push(S.defines[L]);return S.isRawShaderMaterial===!1&&(y(M,S),_(M,S),M.push(s.outputColorSpace)),M.push(S.customProgramCacheKey),M.join()}function y(S,M){S.push(M.precision),S.push(M.outputColorSpace),S.push(M.envMapMode),S.push(M.envMapCubeUVHeight),S.push(M.mapUv),S.push(M.alphaMapUv),S.push(M.lightMapUv),S.push(M.aoMapUv),S.push(M.bumpMapUv),S.push(M.normalMapUv),S.push(M.displacementMapUv),S.push(M.emissiveMapUv),S.push(M.metalnessMapUv),S.push(M.roughnessMapUv),S.push(M.anisotropyMapUv),S.push(M.clearcoatMapUv),S.push(M.clearcoatNormalMapUv),S.push(M.clearcoatRoughnessMapUv),S.push(M.iridescenceMapUv),S.push(M.iridescenceThicknessMapUv),S.push(M.sheenColorMapUv),S.push(M.sheenRoughnessMapUv),S.push(M.specularMapUv),S.push(M.specularColorMapUv),S.push(M.specularIntensityMapUv),S.push(M.transmissionMapUv),S.push(M.thicknessMapUv),S.push(M.combine),S.push(M.fogExp2),S.push(M.sizeAttenuation),S.push(M.morphTargetsCount),S.push(M.morphAttributeCount),S.push(M.numDirLights),S.push(M.numPointLights),S.push(M.numSpotLights),S.push(M.numSpotLightMaps),S.push(M.numHemiLights),S.push(M.numRectAreaLights),S.push(M.numDirLightShadows),S.push(M.numPointLightShadows),S.push(M.numSpotLightShadows),S.push(M.numSpotLightShadowsWithMaps),S.push(M.numLightProbes),S.push(M.shadowMapType),S.push(M.toneMapping),S.push(M.numClippingPlanes),S.push(M.numClipIntersection),S.push(M.depthPacking)}function _(S,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),M.gradientMap&&o.enable(22),S.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reversedDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),S.push(o.mask)}function E(S){const M=g[S.type];let L;if(M){const N=Ri[M];L=fi.clone(N.uniforms)}else L=S.uniforms;return L}function R(S,M){let L;for(let N=0,z=h.length;N<z;N++){const H=h[N];if(H.cacheKey===M){L=H,++L.usedTimes;break}}return L===void 0&&(L=new Tv(s,M,S,n),h.push(L)),L}function T(S){if(--S.usedTimes===0){const M=h.indexOf(S);h[M]=h[h.length-1],h.pop(),S.destroy()}}function A(S){l.remove(S)}function I(){l.dispose()}return{getParameters:f,getProgramCacheKey:p,getUniforms:E,acquireProgram:R,releaseProgram:T,releaseShaderCache:A,programs:h,dispose:I}}function Rv(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function i(a){s.delete(a)}function r(a,o,l){s.get(a)[o]=l}function n(){s=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:n}}function Av(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 uh(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 dh(){const s=[];let e=0;const t=[],i=[],r=[];function n(){e=0,t.length=0,i.length=0,r.length=0}function a(u,d,m,g,v,f){let p=s[e];return p===void 0?(p={id:u.id,object:u,geometry:d,material:m,groupOrder:g,renderOrder:u.renderOrder,z:v,group:f},s[e]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=m,p.groupOrder=g,p.renderOrder=u.renderOrder,p.z=v,p.group=f),e++,p}function o(u,d,m,g,v,f){const p=a(u,d,m,g,v,f);m.transmission>0?i.push(p):m.transparent===!0?r.push(p):t.push(p)}function l(u,d,m,g,v,f){const p=a(u,d,m,g,v,f);m.transmission>0?i.unshift(p):m.transparent===!0?r.unshift(p):t.unshift(p)}function c(u,d){t.length>1&&t.sort(u||Av),i.length>1&&i.sort(d||uh),r.length>1&&r.sort(d||uh)}function h(){for(let u=e,d=s.length;u<d;u++){const m=s[u];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:r,init:n,push:o,unshift:l,finish:h,sort:c}}function Pv(){let s=new WeakMap;function e(i,r){const n=s.get(i);let a;return n===void 0?(a=new dh,s.set(i,[a])):r>=n.length?(a=new dh,n.push(a)):a=n[r],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function Lv(){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 w,color:new _e};break;case"SpotLight":t={position:new w,direction:new w,color:new _e,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new w,color:new _e,distance:0,decay:0};break;case"HemisphereLight":t={direction:new w,skyColor:new _e,groundColor:new _e};break;case"RectAreaLight":t={color:new _e,position:new w,halfWidth:new w,halfHeight:new w};break}return s[e.id]=t,t}}}function Dv(){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 oe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let Iv=0;function Uv(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function Nv(s){const e=new Lv,t=Dv(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new w);const r=new w,n=new Le,a=new Le;function o(c){let h=0,u=0,d=0;for(let S=0;S<9;S++)i.probe[S].set(0,0,0);let m=0,g=0,v=0,f=0,p=0,y=0,_=0,E=0,R=0,T=0,A=0;c.sort(Uv);for(let S=0,M=c.length;S<M;S++){const L=c[S],N=L.color,z=L.intensity,H=L.distance,j=L.shadow&&L.shadow.map?L.shadow.map.texture:null;if(L.isAmbientLight)h+=N.r*z,u+=N.g*z,d+=N.b*z;else if(L.isLightProbe){for(let q=0;q<9;q++)i.probe[q].addScaledVector(L.sh.coefficients[q],z);A++}else if(L.isDirectionalLight){const q=e.get(L);if(q.color.copy(L.color).multiplyScalar(L.intensity),L.castShadow){const te=L.shadow,G=t.get(L);G.shadowIntensity=te.intensity,G.shadowBias=te.bias,G.shadowNormalBias=te.normalBias,G.shadowRadius=te.radius,G.shadowMapSize=te.mapSize,i.directionalShadow[m]=G,i.directionalShadowMap[m]=j,i.directionalShadowMatrix[m]=L.shadow.matrix,y++}i.directional[m]=q,m++}else if(L.isSpotLight){const q=e.get(L);q.position.setFromMatrixPosition(L.matrixWorld),q.color.copy(N).multiplyScalar(z),q.distance=H,q.coneCos=Math.cos(L.angle),q.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),q.decay=L.decay,i.spot[v]=q;const te=L.shadow;if(L.map&&(i.spotLightMap[R]=L.map,R++,te.updateMatrices(L),L.castShadow&&T++),i.spotLightMatrix[v]=te.matrix,L.castShadow){const G=t.get(L);G.shadowIntensity=te.intensity,G.shadowBias=te.bias,G.shadowNormalBias=te.normalBias,G.shadowRadius=te.radius,G.shadowMapSize=te.mapSize,i.spotShadow[v]=G,i.spotShadowMap[v]=j,E++}v++}else if(L.isRectAreaLight){const q=e.get(L);q.color.copy(N).multiplyScalar(z),q.halfWidth.set(L.width*.5,0,0),q.halfHeight.set(0,L.height*.5,0),i.rectArea[f]=q,f++}else if(L.isPointLight){const q=e.get(L);if(q.color.copy(L.color).multiplyScalar(L.intensity),q.distance=L.distance,q.decay=L.decay,L.castShadow){const te=L.shadow,G=t.get(L);G.shadowIntensity=te.intensity,G.shadowBias=te.bias,G.shadowNormalBias=te.normalBias,G.shadowRadius=te.radius,G.shadowMapSize=te.mapSize,G.shadowCameraNear=te.camera.near,G.shadowCameraFar=te.camera.far,i.pointShadow[g]=G,i.pointShadowMap[g]=j,i.pointShadowMatrix[g]=L.shadow.matrix,_++}i.point[g]=q,g++}else if(L.isHemisphereLight){const q=e.get(L);q.skyColor.copy(L.color).multiplyScalar(z),q.groundColor.copy(L.groundColor).multiplyScalar(z),i.hemi[p]=q,p++}}f>0&&(s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=le.LTC_FLOAT_1,i.rectAreaLTC2=le.LTC_FLOAT_2):(i.rectAreaLTC1=le.LTC_HALF_1,i.rectAreaLTC2=le.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const I=i.hash;(I.directionalLength!==m||I.pointLength!==g||I.spotLength!==v||I.rectAreaLength!==f||I.hemiLength!==p||I.numDirectionalShadows!==y||I.numPointShadows!==_||I.numSpotShadows!==E||I.numSpotMaps!==R||I.numLightProbes!==A)&&(i.directional.length=m,i.spot.length=v,i.rectArea.length=f,i.point.length=g,i.hemi.length=p,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=_,i.pointShadowMap.length=_,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=_,i.spotLightMatrix.length=E+R-T,i.spotLightMap.length=R,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=A,I.directionalLength=m,I.pointLength=g,I.spotLength=v,I.rectAreaLength=f,I.hemiLength=p,I.numDirectionalShadows=y,I.numPointShadows=_,I.numSpotShadows=E,I.numSpotMaps=R,I.numLightProbes=A,i.version=Iv++)}function l(c,h){let u=0,d=0,m=0,g=0,v=0;const f=h.matrixWorldInverse;for(let p=0,y=c.length;p<y;p++){const _=c[p];if(_.isDirectionalLight){const E=i.directional[u];E.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(f),u++}else if(_.isSpotLight){const E=i.spot[m];E.position.setFromMatrixPosition(_.matrixWorld),E.position.applyMatrix4(f),E.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(f),m++}else if(_.isRectAreaLight){const E=i.rectArea[g];E.position.setFromMatrixPosition(_.matrixWorld),E.position.applyMatrix4(f),a.identity(),n.copy(_.matrixWorld),n.premultiply(f),a.extractRotation(n),E.halfWidth.set(_.width*.5,0,0),E.halfHeight.set(0,_.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),g++}else if(_.isPointLight){const E=i.point[d];E.position.setFromMatrixPosition(_.matrixWorld),E.position.applyMatrix4(f),d++}else if(_.isHemisphereLight){const E=i.hemi[v];E.direction.setFromMatrixPosition(_.matrixWorld),E.direction.transformDirection(f),v++}}}return{setup:o,setupView:l,state:i}}function ph(s){const e=new Nv(s),t=[],i=[];function r(h){c.camera=h,t.length=0,i.length=0}function n(h){t.push(h)}function a(h){i.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:n,pushShadow:a}}function Ov(s){let e=new WeakMap;function t(r,n=0){const a=e.get(r);let o;return a===void 0?(o=new ph(s),e.set(r,[o])):n>=a.length?(o=new ph(s),a.push(o)):o=a[n],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Bv=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,Fv=`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 kv(s,e,t){let i=new bo;const r=new oe,n=new oe,a=new Ke,o=new Tc({depthPacking:Ll}),l=new Ud,c={},h=t.maxTextureSize,u={[bi]:Ft,[Ft]:bi,[Gt]:Gt},d=new ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new oe},radius:{value:4}},vertexShader:Bv,fragmentShader:Fv}),m=d.clone();m.defines.HORIZONTAL_PASS=1;const g=new ei;g.setAttribute("position",new zt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new rt(g,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ol;let p=this.type;this.render=function(T,A,I){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||T.length===0)return;const S=s.getRenderTarget(),M=s.getActiveCubeFace(),L=s.getActiveMipmapLevel(),N=s.state;N.setBlending(xt),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);const z=p!==Di&&this.type===Di,H=p===Di&&this.type!==Di;for(let j=0,q=T.length;j<q;j++){const te=T[j],G=te.shadow;if(G===void 0){be("WebGLShadowMap:",te,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;r.copy(G.mapSize);const Z=G.getFrameExtents();if(r.multiply(Z),n.copy(G.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(n.x=Math.floor(h/Z.x),r.x=n.x*Z.x,G.mapSize.x=n.x),r.y>h&&(n.y=Math.floor(h/Z.y),r.y=n.y*Z.y,G.mapSize.y=n.y)),G.map===null||z===!0||H===!0){const Pe=this.type!==Di?{minFilter:Dt,magFilter:Dt}:{};G.map!==null&&G.map.dispose(),G.map=new bt(r.x,r.y,Pe),G.map.texture.name=te.name+".shadowMap",G.camera.updateProjectionMatrix()}s.setRenderTarget(G.map),s.clear();const se=G.getViewportCount();for(let Pe=0;Pe<se;Pe++){const ze=G.getViewport(Pe);a.set(n.x*ze.x,n.y*ze.y,n.x*ze.z,n.y*ze.w),N.viewport(a),G.updateMatrices(te,Pe),i=G.getFrustum(),E(A,I,G.camera,te,this.type)}G.isPointLightShadow!==!0&&this.type===Di&&y(G,I),G.needsUpdate=!1}p=this.type,f.needsUpdate=!1,s.setRenderTarget(S,M,L)};function y(T,A){const I=e.update(v);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new bt(r.x,r.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,s.setRenderTarget(T.mapPass),s.clear(),s.renderBufferDirect(A,null,I,d,v,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,s.setRenderTarget(T.map),s.clear(),s.renderBufferDirect(A,null,I,m,v,null)}function _(T,A,I,S){let M=null;const L=I.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(L!==void 0)M=L;else if(M=I.isPointLight===!0?l:o,s.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const N=M.uuid,z=A.uuid;let H=c[N];H===void 0&&(H={},c[N]=H);let j=H[z];j===void 0&&(j=M.clone(),H[z]=j,A.addEventListener("dispose",R)),M=j}if(M.visible=A.visible,M.wireframe=A.wireframe,S===Di?M.side=A.shadowSide!==null?A.shadowSide:A.side:M.side=A.shadowSide!==null?A.shadowSide:u[A.side],M.alphaMap=A.alphaMap,M.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,M.map=A.map,M.clipShadows=A.clipShadows,M.clippingPlanes=A.clippingPlanes,M.clipIntersection=A.clipIntersection,M.displacementMap=A.displacementMap,M.displacementScale=A.displacementScale,M.displacementBias=A.displacementBias,M.wireframeLinewidth=A.wireframeLinewidth,M.linewidth=A.linewidth,I.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const N=s.properties.get(M);N.light=I}return M}function E(T,A,I,S,M){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===Di)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,T.matrixWorld);const N=e.update(T),z=T.material;if(Array.isArray(z)){const H=N.groups;for(let j=0,q=H.length;j<q;j++){const te=H[j],G=z[te.materialIndex];if(G&&G.visible){const Z=_(T,G,S,M);T.onBeforeShadow(s,T,A,I,N,Z,te),s.renderBufferDirect(I,null,N,Z,T,te),T.onAfterShadow(s,T,A,I,N,Z,te)}}}else if(z.visible){const H=_(T,z,S,M);T.onBeforeShadow(s,T,A,I,N,H,null),s.renderBufferDirect(I,null,N,H,T,null),T.onAfterShadow(s,T,A,I,N,H,null)}}const L=T.children;for(let N=0,z=L.length;N<z;N++)E(L[N],A,I,S,M)}function R(T){T.target.removeEventListener("dispose",R);for(const A in c){const I=c[A],S=T.target.uuid;S in I&&(I[S].dispose(),delete I[S])}}}const zv={[Gn]:Wn,[jn]:Yn,[Xn]:Kn,[Sr]:qn,[Wn]:Gn,[Yn]:jn,[Kn]:Xn,[qn]:Sr};function Hv(s,e){function t(){let P=!1;const ae=new Ke;let ie=null;const ce=new Ke(0,0,0,0);return{setMask:function(Q){ie!==Q&&!P&&(s.colorMask(Q,Q,Q,Q),ie=Q)},setLocked:function(Q){P=Q},setClear:function(Q,$,ve,Ae,Lt){Lt===!0&&(Q*=Ae,$*=Ae,ve*=Ae),ae.set(Q,$,ve,Ae),ce.equals(ae)===!1&&(s.clearColor(Q,$,ve,Ae),ce.copy(ae))},reset:function(){P=!1,ie=null,ce.set(-1,0,0,0)}}}function i(){let P=!1,ae=!1,ie=null,ce=null,Q=null;return{setReversed:function($){if(ae!==$){const ve=e.get("EXT_clip_control");$?ve.clipControlEXT(ve.LOWER_LEFT_EXT,ve.ZERO_TO_ONE_EXT):ve.clipControlEXT(ve.LOWER_LEFT_EXT,ve.NEGATIVE_ONE_TO_ONE_EXT),ae=$;const Ae=Q;Q=null,this.setClear(Ae)}},getReversed:function(){return ae},setTest:function($){$?Y(s.DEPTH_TEST):ue(s.DEPTH_TEST)},setMask:function($){ie!==$&&!P&&(s.depthMask($),ie=$)},setFunc:function($){if(ae&&($=zv[$]),ce!==$){switch($){case Gn:s.depthFunc(s.NEVER);break;case Wn:s.depthFunc(s.ALWAYS);break;case jn:s.depthFunc(s.LESS);break;case Sr:s.depthFunc(s.LEQUAL);break;case Xn:s.depthFunc(s.EQUAL);break;case qn:s.depthFunc(s.GEQUAL);break;case Yn:s.depthFunc(s.GREATER);break;case Kn:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}ce=$}},setLocked:function($){P=$},setClear:function($){Q!==$&&(ae&&($=1-$),s.clearDepth($),Q=$)},reset:function(){P=!1,ie=null,ce=null,Q=null,ae=!1}}}function r(){let P=!1,ae=null,ie=null,ce=null,Q=null,$=null,ve=null,Ae=null,Lt=null;return{setTest:function(nt){P||(nt?Y(s.STENCIL_TEST):ue(s.STENCIL_TEST))},setMask:function(nt){ae!==nt&&!P&&(s.stencilMask(nt),ae=nt)},setFunc:function(nt,Li,_i){(ie!==nt||ce!==Li||Q!==_i)&&(s.stencilFunc(nt,Li,_i),ie=nt,ce=Li,Q=_i)},setOp:function(nt,Li,_i){($!==nt||ve!==Li||Ae!==_i)&&(s.stencilOp(nt,Li,_i),$=nt,ve=Li,Ae=_i)},setLocked:function(nt){P=nt},setClear:function(nt){Lt!==nt&&(s.clearStencil(nt),Lt=nt)},reset:function(){P=!1,ae=null,ie=null,ce=null,Q=null,$=null,ve=null,Ae=null,Lt=null}}}const n=new t,a=new i,o=new r,l=new WeakMap,c=new WeakMap;let h={},u={},d=new WeakMap,m=[],g=null,v=!1,f=null,p=null,y=null,_=null,E=null,R=null,T=null,A=new _e(0,0,0),I=0,S=!1,M=null,L=null,N=null,z=null,H=null;const j=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,te=0;const G=s.getParameter(s.VERSION);G.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(G)[1]),q=te>=1):G.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),q=te>=2);let Z=null,se={};const Pe=s.getParameter(s.SCISSOR_BOX),ze=s.getParameter(s.VIEWPORT),qe=new Ke().fromArray(Pe),Ze=new Ke().fromArray(ze);function $e(P,ae,ie,ce){const Q=new Uint8Array(4),$=s.createTexture();s.bindTexture(P,$),s.texParameteri(P,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(P,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ve=0;ve<ie;ve++)P===s.TEXTURE_3D||P===s.TEXTURE_2D_ARRAY?s.texImage3D(ae,0,s.RGBA,1,1,ce,0,s.RGBA,s.UNSIGNED_BYTE,Q):s.texImage2D(ae+ve,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,Q);return $}const W={};W[s.TEXTURE_2D]=$e(s.TEXTURE_2D,s.TEXTURE_2D,1),W[s.TEXTURE_CUBE_MAP]=$e(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),W[s.TEXTURE_2D_ARRAY]=$e(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),W[s.TEXTURE_3D]=$e(s.TEXTURE_3D,s.TEXTURE_3D,1,1),n.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Y(s.DEPTH_TEST),a.setFunc(Sr),_t(!1),We(al),Y(s.CULL_FACE),Ge(xt);function Y(P){h[P]!==!0&&(s.enable(P),h[P]=!0)}function ue(P){h[P]!==!1&&(s.disable(P),h[P]=!1)}function Ce(P,ae){return u[P]!==ae?(s.bindFramebuffer(P,ae),u[P]=ae,P===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=ae),P===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=ae),!0):!1}function Te(P,ae){let ie=m,ce=!1;if(P){ie=d.get(ae),ie===void 0&&(ie=[],d.set(ae,ie));const Q=P.textures;if(ie.length!==Q.length||ie[0]!==s.COLOR_ATTACHMENT0){for(let $=0,ve=Q.length;$<ve;$++)ie[$]=s.COLOR_ATTACHMENT0+$;ie.length=Q.length,ce=!0}}else ie[0]!==s.BACK&&(ie[0]=s.BACK,ce=!0);ce&&s.drawBuffers(ie)}function Ee(P){return g!==P?(s.useProgram(P),g=P,!0):!1}const Je={[si]:s.FUNC_ADD,[eu]:s.FUNC_SUBTRACT,[tu]:s.FUNC_REVERSE_SUBTRACT};Je[iu]=s.MIN,Je[ru]=s.MAX;const Xe={[cs]:s.ZERO,[su]:s.ONE,[nu]:s.SRC_COLOR,[kn]:s.SRC_ALPHA,[cu]:s.SRC_ALPHA_SATURATE,[Vn]:s.DST_COLOR,[Hn]:s.DST_ALPHA,[au]:s.ONE_MINUS_SRC_COLOR,[zn]:s.ONE_MINUS_SRC_ALPHA,[lu]:s.ONE_MINUS_DST_COLOR,[ou]:s.ONE_MINUS_DST_ALPHA,[hu]:s.CONSTANT_COLOR,[uu]:s.ONE_MINUS_CONSTANT_COLOR,[du]:s.CONSTANT_ALPHA,[pu]:s.ONE_MINUS_CONSTANT_ALPHA};function Ge(P,ae,ie,ce,Q,$,ve,Ae,Lt,nt){if(P===xt){v===!0&&(ue(s.BLEND),v=!1);return}if(v===!1&&(Y(s.BLEND),v=!0),P!==ul){if(P!==f||nt!==S){if((p!==si||E!==si)&&(s.blendEquation(s.FUNC_ADD),p=si,E=si),nt)switch(P){case Tr:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Bs:s.blendFunc(s.ONE,s.ONE);break;case cl:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case hl:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:He("WebGLState: Invalid blending: ",P);break}else switch(P){case Tr:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Bs:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case cl:He("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case hl:He("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:He("WebGLState: Invalid blending: ",P);break}y=null,_=null,R=null,T=null,A.set(0,0,0),I=0,f=P,S=nt}return}Q=Q||ae,$=$||ie,ve=ve||ce,(ae!==p||Q!==E)&&(s.blendEquationSeparate(Je[ae],Je[Q]),p=ae,E=Q),(ie!==y||ce!==_||$!==R||ve!==T)&&(s.blendFuncSeparate(Xe[ie],Xe[ce],Xe[$],Xe[ve]),y=ie,_=ce,R=$,T=ve),(Ae.equals(A)===!1||Lt!==I)&&(s.blendColor(Ae.r,Ae.g,Ae.b,Lt),A.copy(Ae),I=Lt),f=P,S=!1}function D(P,ae){P.side===Gt?ue(s.CULL_FACE):Y(s.CULL_FACE);let ie=P.side===Ft;ae&&(ie=!ie),_t(ie),P.blending===Tr&&P.transparent===!1?Ge(xt):Ge(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),a.setFunc(P.depthFunc),a.setTest(P.depthTest),a.setMask(P.depthWrite),n.setMask(P.colorWrite);const ce=P.stencilWrite;o.setTest(ce),ce&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),me(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?Y(s.SAMPLE_ALPHA_TO_COVERAGE):ue(s.SAMPLE_ALPHA_TO_COVERAGE)}function _t(P){M!==P&&(P?s.frontFace(s.CW):s.frontFace(s.CCW),M=P)}function We(P){P!==Jh?(Y(s.CULL_FACE),P!==L&&(P===al?s.cullFace(s.BACK):P===Qh?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):ue(s.CULL_FACE),L=P}function Qe(P){P!==N&&(q&&s.lineWidth(P),N=P)}function me(P,ae,ie){P?(Y(s.POLYGON_OFFSET_FILL),(z!==ae||H!==ie)&&(s.polygonOffset(ae,ie),z=ae,H=ie)):ue(s.POLYGON_OFFSET_FILL)}function at(P){P?Y(s.SCISSOR_TEST):ue(s.SCISSOR_TEST)}function Me(P){P===void 0&&(P=s.TEXTURE0+j-1),Z!==P&&(s.activeTexture(P),Z=P)}function De(P,ae,ie){ie===void 0&&(Z===null?ie=s.TEXTURE0+j-1:ie=Z);let ce=se[ie];ce===void 0&&(ce={type:void 0,texture:void 0},se[ie]=ce),(ce.type!==P||ce.texture!==ae)&&(Z!==ie&&(s.activeTexture(ie),Z=ie),s.bindTexture(P,ae||W[P]),ce.type=P,ce.texture=ae)}function C(){const P=se[Z];P!==void 0&&P.type!==void 0&&(s.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function x(){try{s.compressedTexImage2D(...arguments)}catch(P){P("WebGLState:",P)}}function B(){try{s.compressedTexImage3D(...arguments)}catch(P){P("WebGLState:",P)}}function X(){try{s.texSubImage2D(...arguments)}catch(P){P("WebGLState:",P)}}function K(){try{s.texSubImage3D(...arguments)}catch(P){P("WebGLState:",P)}}function V(){try{s.compressedTexSubImage2D(...arguments)}catch(P){P("WebGLState:",P)}}function xe(){try{s.compressedTexSubImage3D(...arguments)}catch(P){P("WebGLState:",P)}}function ne(){try{s.texStorage2D(...arguments)}catch(P){P("WebGLState:",P)}}function Se(){try{s.texStorage3D(...arguments)}catch(P){P("WebGLState:",P)}}function de(){try{s.texImage2D(...arguments)}catch(P){P("WebGLState:",P)}}function J(){try{s.texImage3D(...arguments)}catch(P){P("WebGLState:",P)}}function re(P){qe.equals(P)===!1&&(s.scissor(P.x,P.y,P.z,P.w),qe.copy(P))}function Oe(P){Ze.equals(P)===!1&&(s.viewport(P.x,P.y,P.z,P.w),Ze.copy(P))}function we(P,ae){let ie=c.get(ae);ie===void 0&&(ie=new WeakMap,c.set(ae,ie));let ce=ie.get(P);ce===void 0&&(ce=s.getUniformBlockIndex(ae,P.name),ie.set(P,ce))}function he(P,ae){const ie=c.get(ae).get(P);l.get(ae)!==ie&&(s.uniformBlockBinding(ae,ie,P.__bindingPointIndex),l.set(ae,ie))}function Re(){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={},Z=null,se={},u={},d=new WeakMap,m=[],g=null,v=!1,f=null,p=null,y=null,_=null,E=null,R=null,T=null,A=new _e(0,0,0),I=0,S=!1,M=null,L=null,N=null,z=null,H=null,qe.set(0,0,s.canvas.width,s.canvas.height),Ze.set(0,0,s.canvas.width,s.canvas.height),n.reset(),a.reset(),o.reset()}return{buffers:{color:n,depth:a,stencil:o},enable:Y,disable:ue,bindFramebuffer:Ce,drawBuffers:Te,useProgram:Ee,setBlending:Ge,setMaterial:D,setFlipSided:_t,setCullFace:We,setLineWidth:Qe,setPolygonOffset:me,setScissorTest:at,activeTexture:Me,bindTexture:De,unbindTexture:C,compressedTexImage2D:x,compressedTexImage3D:B,texImage2D:de,texImage3D:J,updateUBOMapping:we,uniformBlockBinding:he,texStorage2D:ne,texStorage3D:Se,texSubImage2D:X,texSubImage3D:K,compressedTexSubImage2D:V,compressedTexSubImage3D:xe,scissor:re,viewport:Oe,reset:Re}}function Vv(s,e,t,i,r,n,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 oe,h=new WeakMap;let u;const d=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(C,x){return m?new OffscreenCanvas(C,x):fs("canvas")}function v(C,x,B){let X=1;const K=De(C);if((K.width>B||K.height>B)&&(X=B/Math.max(K.width,K.height)),X<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const V=Math.floor(X*K.width),xe=Math.floor(X*K.height);u===void 0&&(u=g(V,xe));const ne=x?g(V,xe):u;return ne.width=V,ne.height=xe,ne.getContext("2d").drawImage(C,0,0,V,xe),be("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+V+"x"+xe+")."),ne}else return"data"in C&&be("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),C;return C}function f(C){return C.generateMipmaps}function p(C){s.generateMipmap(C)}function y(C){return C.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?s.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function _(C,x,B,X,K=!1){if(C!==null){if(s[C]!==void 0)return s[C];be("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let V=x;if(x===s.RED&&(B===s.FLOAT&&(V=s.R32F),B===s.HALF_FLOAT&&(V=s.R16F),B===s.UNSIGNED_BYTE&&(V=s.R8)),x===s.RED_INTEGER&&(B===s.UNSIGNED_BYTE&&(V=s.R8UI),B===s.UNSIGNED_SHORT&&(V=s.R16UI),B===s.UNSIGNED_INT&&(V=s.R32UI),B===s.BYTE&&(V=s.R8I),B===s.SHORT&&(V=s.R16I),B===s.INT&&(V=s.R32I)),x===s.RG&&(B===s.FLOAT&&(V=s.RG32F),B===s.HALF_FLOAT&&(V=s.RG16F),B===s.UNSIGNED_BYTE&&(V=s.RG8)),x===s.RG_INTEGER&&(B===s.UNSIGNED_BYTE&&(V=s.RG8UI),B===s.UNSIGNED_SHORT&&(V=s.RG16UI),B===s.UNSIGNED_INT&&(V=s.RG32UI),B===s.BYTE&&(V=s.RG8I),B===s.SHORT&&(V=s.RG16I),B===s.INT&&(V=s.RG32I)),x===s.RGB_INTEGER&&(B===s.UNSIGNED_BYTE&&(V=s.RGB8UI),B===s.UNSIGNED_SHORT&&(V=s.RGB16UI),B===s.UNSIGNED_INT&&(V=s.RGB32UI),B===s.BYTE&&(V=s.RGB8I),B===s.SHORT&&(V=s.RGB16I),B===s.INT&&(V=s.RGB32I)),x===s.RGBA_INTEGER&&(B===s.UNSIGNED_BYTE&&(V=s.RGBA8UI),B===s.UNSIGNED_SHORT&&(V=s.RGBA16UI),B===s.UNSIGNED_INT&&(V=s.RGBA32UI),B===s.BYTE&&(V=s.RGBA8I),B===s.SHORT&&(V=s.RGBA16I),B===s.INT&&(V=s.RGBA32I)),x===s.RGB&&(B===s.UNSIGNED_INT_5_9_9_9_REV&&(V=s.RGB9_E5),B===s.UNSIGNED_INT_10F_11F_11F_REV&&(V=s.R11F_G11F_B10F)),x===s.RGBA){const xe=K?qs:je.getTransfer(X);B===s.FLOAT&&(V=s.RGBA32F),B===s.HALF_FLOAT&&(V=s.RGBA16F),B===s.UNSIGNED_BYTE&&(V=xe===et?s.SRGB8_ALPHA8:s.RGBA8),B===s.UNSIGNED_SHORT_4_4_4_4&&(V=s.RGBA4),B===s.UNSIGNED_SHORT_5_5_5_1&&(V=s.RGB5_A1)}return(V===s.R16F||V===s.R32F||V===s.RG16F||V===s.RG32F||V===s.RGBA16F||V===s.RGBA32F)&&e.get("EXT_color_buffer_float"),V}function E(C,x){let B;return C?x===null||x===ar||x===Cr?B=s.DEPTH24_STENCIL8:x===Wt?B=s.DEPTH32F_STENCIL8:x===us&&(B=s.DEPTH24_STENCIL8,be("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ar||x===Cr?B=s.DEPTH_COMPONENT24:x===Wt?B=s.DEPTH_COMPONENT32F:x===us&&(B=s.DEPTH_COMPONENT16),B}function R(C,x){return f(C)===!0||C.isFramebufferTexture&&C.minFilter!==Dt&&C.minFilter!==yt?Math.log2(Math.max(x.width,x.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?x.mipmaps.length:1}function T(C){const x=C.target;x.removeEventListener("dispose",T),I(x),x.isVideoTexture&&h.delete(x)}function A(C){const x=C.target;x.removeEventListener("dispose",A),M(x)}function I(C){const x=i.get(C);if(x.__webglInit===void 0)return;const B=C.source,X=d.get(B);if(X){const K=X[x.__cacheKey];K.usedTimes--,K.usedTimes===0&&S(C),Object.keys(X).length===0&&d.delete(B)}i.remove(C)}function S(C){const x=i.get(C);s.deleteTexture(x.__webglTexture);const B=C.source,X=d.get(B);delete X[x.__cacheKey],a.memory.textures--}function M(C){const x=i.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),i.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let K=0;K<x.__webglFramebuffer[X].length;K++)s.deleteFramebuffer(x.__webglFramebuffer[X][K]);else s.deleteFramebuffer(x.__webglFramebuffer[X]);x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer[X])}else{if(Array.isArray(x.__webglFramebuffer))for(let X=0;X<x.__webglFramebuffer.length;X++)s.deleteFramebuffer(x.__webglFramebuffer[X]);else s.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&s.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let X=0;X<x.__webglColorRenderbuffer.length;X++)x.__webglColorRenderbuffer[X]&&s.deleteRenderbuffer(x.__webglColorRenderbuffer[X]);x.__webglDepthRenderbuffer&&s.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const B=C.textures;for(let X=0,K=B.length;X<K;X++){const V=i.get(B[X]);V.__webglTexture&&(s.deleteTexture(V.__webglTexture),a.memory.textures--),i.remove(B[X])}i.remove(C)}let L=0;function N(){L=0}function z(){const C=L;return C>=r.maxTextures&&be("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+r.maxTextures),L+=1,C}function H(C){const x=[];return x.push(C.wrapS),x.push(C.wrapT),x.push(C.wrapR||0),x.push(C.magFilter),x.push(C.minFilter),x.push(C.anisotropy),x.push(C.internalFormat),x.push(C.format),x.push(C.type),x.push(C.generateMipmaps),x.push(C.premultiplyAlpha),x.push(C.flipY),x.push(C.unpackAlignment),x.push(C.colorSpace),x.join()}function j(C,x){const B=i.get(C);if(C.isVideoTexture&&at(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&B.__version!==C.version){const X=C.image;if(X===null)be("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)be("WebGLRenderer: Texture marked for update but image is incomplete");else{W(B,C,x);return}}else C.isExternalTexture&&(B.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,B.__webglTexture,s.TEXTURE0+x)}function q(C,x){const B=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&B.__version!==C.version){W(B,C,x);return}else C.isExternalTexture&&(B.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,B.__webglTexture,s.TEXTURE0+x)}function te(C,x){const B=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&B.__version!==C.version){W(B,C,x);return}t.bindTexture(s.TEXTURE_3D,B.__webglTexture,s.TEXTURE0+x)}function G(C,x){const B=i.get(C);if(C.version>0&&B.__version!==C.version){Y(B,C,x);return}t.bindTexture(s.TEXTURE_CUBE_MAP,B.__webglTexture,s.TEXTURE0+x)}const Z={[Mi]:s.REPEAT,[$t]:s.CLAMP_TO_EDGE,[zs]:s.MIRRORED_REPEAT},se={[Dt]:s.NEAREST,[yl]:s.NEAREST_MIPMAP_NEAREST,[hs]:s.NEAREST_MIPMAP_LINEAR,[yt]:s.LINEAR,[Hs]:s.LINEAR_MIPMAP_NEAREST,[Ti]:s.LINEAR_MIPMAP_LINEAR},Pe={[Mu]:s.NEVER,[Ru]:s.ALWAYS,[Tu]:s.LESS,[Dl]:s.LEQUAL,[Su]:s.EQUAL,[Cu]:s.GEQUAL,[Eu]:s.GREATER,[wu]:s.NOTEQUAL};function ze(C,x){if(x.type===Wt&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===yt||x.magFilter===Hs||x.magFilter===hs||x.magFilter===Ti||x.minFilter===yt||x.minFilter===Hs||x.minFilter===hs||x.minFilter===Ti)&&be("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(C,s.TEXTURE_WRAP_S,Z[x.wrapS]),s.texParameteri(C,s.TEXTURE_WRAP_T,Z[x.wrapT]),(C===s.TEXTURE_3D||C===s.TEXTURE_2D_ARRAY)&&s.texParameteri(C,s.TEXTURE_WRAP_R,Z[x.wrapR]),s.texParameteri(C,s.TEXTURE_MAG_FILTER,se[x.magFilter]),s.texParameteri(C,s.TEXTURE_MIN_FILTER,se[x.minFilter]),x.compareFunction&&(s.texParameteri(C,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(C,s.TEXTURE_COMPARE_FUNC,Pe[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Dt||x.minFilter!==hs&&x.minFilter!==Ti||x.type===Wt&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const B=e.get("EXT_texture_filter_anisotropic");s.texParameterf(C,B.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,r.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function qe(C,x){let B=!1;C.__webglInit===void 0&&(C.__webglInit=!0,x.addEventListener("dispose",T));const X=x.source;let K=d.get(X);K===void 0&&(K={},d.set(X,K));const V=H(x);if(V!==C.__cacheKey){K[V]===void 0&&(K[V]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,B=!0),K[V].usedTimes++;const xe=K[C.__cacheKey];xe!==void 0&&(K[C.__cacheKey].usedTimes--,xe.usedTimes===0&&S(x)),C.__cacheKey=V,C.__webglTexture=K[V].texture}return B}function Ze(C,x,B){return Math.floor(Math.floor(C/B)/x)}function $e(C,x,B,X){const K=C.updateRanges;if(K.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,x.width,x.height,B,X,x.data);else{K.sort((de,J)=>de.start-J.start);let V=0;for(let de=1;de<K.length;de++){const J=K[V],re=K[de],Oe=J.start+J.count,we=Ze(re.start,x.width,4),he=Ze(J.start,x.width,4);re.start<=Oe+1&&we===he&&Ze(re.start+re.count-1,x.width,4)===we?J.count=Math.max(J.count,re.start+re.count-J.start):(++V,K[V]=re)}K.length=V+1;const xe=s.getParameter(s.UNPACK_ROW_LENGTH),ne=s.getParameter(s.UNPACK_SKIP_PIXELS),Se=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,x.width);for(let de=0,J=K.length;de<J;de++){const re=K[de],Oe=Math.floor(re.start/4),we=Math.ceil(re.count/4),he=Oe%x.width,Re=Math.floor(Oe/x.width),P=we;s.pixelStorei(s.UNPACK_SKIP_PIXELS,he),s.pixelStorei(s.UNPACK_SKIP_ROWS,Re),t.texSubImage2D(s.TEXTURE_2D,0,he,Re,P,1,B,X,x.data)}C.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,xe),s.pixelStorei(s.UNPACK_SKIP_PIXELS,ne),s.pixelStorei(s.UNPACK_SKIP_ROWS,Se)}}function W(C,x,B){let X=s.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(X=s.TEXTURE_2D_ARRAY),x.isData3DTexture&&(X=s.TEXTURE_3D);const K=qe(C,x),V=x.source;t.bindTexture(X,C.__webglTexture,s.TEXTURE0+B);const xe=i.get(V);if(V.version!==xe.__version||K===!0){t.activeTexture(s.TEXTURE0+B);const ne=je.getPrimaries(je.workingColorSpace),Se=x.colorSpace===qi?null:je.getPrimaries(x.colorSpace),de=x.colorSpace===qi||ne===Se?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,de);let J=v(x.image,!1,r.maxTextureSize);J=Me(x,J);const re=n.convert(x.format,x.colorSpace),Oe=n.convert(x.type);let we=_(x.internalFormat,re,Oe,x.colorSpace,x.isVideoTexture);ze(X,x);let he;const Re=x.mipmaps,P=x.isVideoTexture!==!0,ae=xe.__version===void 0||K===!0,ie=V.dataReady,ce=R(x,J);if(x.isDepthTexture)we=E(x.format===Rr,x.type),ae&&(P?t.texStorage2D(s.TEXTURE_2D,1,we,J.width,J.height):t.texImage2D(s.TEXTURE_2D,0,we,J.width,J.height,0,re,Oe,null));else if(x.isDataTexture)if(Re.length>0){P&&ae&&t.texStorage2D(s.TEXTURE_2D,ce,we,Re[0].width,Re[0].height);for(let Q=0,$=Re.length;Q<$;Q++)he=Re[Q],P?ie&&t.texSubImage2D(s.TEXTURE_2D,Q,0,0,he.width,he.height,re,Oe,he.data):t.texImage2D(s.TEXTURE_2D,Q,we,he.width,he.height,0,re,Oe,he.data);x.generateMipmaps=!1}else P?(ae&&t.texStorage2D(s.TEXTURE_2D,ce,we,J.width,J.height),ie&&$e(x,J,re,Oe)):t.texImage2D(s.TEXTURE_2D,0,we,J.width,J.height,0,re,Oe,J.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){P&&ae&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,we,Re[0].width,Re[0].height,J.depth);for(let Q=0,$=Re.length;Q<$;Q++)if(he=Re[Q],x.format!==qt)if(re!==null)if(P){if(ie)if(x.layerUpdates.size>0){const ve=kc(he.width,he.height,x.format,x.type);for(const Ae of x.layerUpdates){const Lt=he.data.subarray(Ae*ve/he.data.BYTES_PER_ELEMENT,(Ae+1)*ve/he.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,Q,0,0,Ae,he.width,he.height,1,re,Lt)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,Q,0,0,0,he.width,he.height,J.depth,re,he.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,Q,we,he.width,he.height,J.depth,0,he.data,0,0);else be("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else P?ie&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,Q,0,0,0,he.width,he.height,J.depth,re,Oe,he.data):t.texImage3D(s.TEXTURE_2D_ARRAY,Q,we,he.width,he.height,J.depth,0,re,Oe,he.data)}else{P&&ae&&t.texStorage2D(s.TEXTURE_2D,ce,we,Re[0].width,Re[0].height);for(let Q=0,$=Re.length;Q<$;Q++)he=Re[Q],x.format!==qt?re!==null?P?ie&&t.compressedTexSubImage2D(s.TEXTURE_2D,Q,0,0,he.width,he.height,re,he.data):t.compressedTexImage2D(s.TEXTURE_2D,Q,we,he.width,he.height,0,he.data):be("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):P?ie&&t.texSubImage2D(s.TEXTURE_2D,Q,0,0,he.width,he.height,re,Oe,he.data):t.texImage2D(s.TEXTURE_2D,Q,we,he.width,he.height,0,re,Oe,he.data)}else if(x.isDataArrayTexture)if(P){if(ae&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,we,J.width,J.height,J.depth),ie)if(x.layerUpdates.size>0){const Q=kc(J.width,J.height,x.format,x.type);for(const $ of x.layerUpdates){const ve=J.data.subarray($*Q/J.data.BYTES_PER_ELEMENT,($+1)*Q/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,$,J.width,J.height,1,re,Oe,ve)}x.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,re,Oe,J.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,we,J.width,J.height,J.depth,0,re,Oe,J.data);else if(x.isData3DTexture)P?(ae&&t.texStorage3D(s.TEXTURE_3D,ce,we,J.width,J.height,J.depth),ie&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,re,Oe,J.data)):t.texImage3D(s.TEXTURE_3D,0,we,J.width,J.height,J.depth,0,re,Oe,J.data);else if(x.isFramebufferTexture){if(ae)if(P)t.texStorage2D(s.TEXTURE_2D,ce,we,J.width,J.height);else{let Q=J.width,$=J.height;for(let ve=0;ve<ce;ve++)t.texImage2D(s.TEXTURE_2D,ve,we,Q,$,0,re,Oe,null),Q>>=1,$>>=1}}else if(Re.length>0){if(P&&ae){const Q=De(Re[0]);t.texStorage2D(s.TEXTURE_2D,ce,we,Q.width,Q.height)}for(let Q=0,$=Re.length;Q<$;Q++)he=Re[Q],P?ie&&t.texSubImage2D(s.TEXTURE_2D,Q,0,0,re,Oe,he):t.texImage2D(s.TEXTURE_2D,Q,we,re,Oe,he);x.generateMipmaps=!1}else if(P){if(ae){const Q=De(J);t.texStorage2D(s.TEXTURE_2D,ce,we,Q.width,Q.height)}ie&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,re,Oe,J)}else t.texImage2D(s.TEXTURE_2D,0,we,re,Oe,J);f(x)&&p(X),xe.__version=V.version,x.onUpdate&&x.onUpdate(x)}C.__version=x.version}function Y(C,x,B){if(x.image.length!==6)return;const X=qe(C,x),K=x.source;t.bindTexture(s.TEXTURE_CUBE_MAP,C.__webglTexture,s.TEXTURE0+B);const V=i.get(K);if(K.version!==V.__version||X===!0){t.activeTexture(s.TEXTURE0+B);const xe=je.getPrimaries(je.workingColorSpace),ne=x.colorSpace===qi?null:je.getPrimaries(x.colorSpace),Se=x.colorSpace===qi||xe===ne?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Se);const de=x.isCompressedTexture||x.image[0].isCompressedTexture,J=x.image[0]&&x.image[0].isDataTexture,re=[];for(let $=0;$<6;$++)!de&&!J?re[$]=v(x.image[$],!0,r.maxCubemapSize):re[$]=J?x.image[$].image:x.image[$],re[$]=Me(x,re[$]);const Oe=re[0],we=n.convert(x.format,x.colorSpace),he=n.convert(x.type),Re=_(x.internalFormat,we,he,x.colorSpace),P=x.isVideoTexture!==!0,ae=V.__version===void 0||X===!0,ie=K.dataReady;let ce=R(x,Oe);ze(s.TEXTURE_CUBE_MAP,x);let Q;if(de){P&&ae&&t.texStorage2D(s.TEXTURE_CUBE_MAP,ce,Re,Oe.width,Oe.height);for(let $=0;$<6;$++){Q=re[$].mipmaps;for(let ve=0;ve<Q.length;ve++){const Ae=Q[ve];x.format!==qt?we!==null?P?ie&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,ve,0,0,Ae.width,Ae.height,we,Ae.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,ve,Re,Ae.width,Ae.height,0,Ae.data):be("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?ie&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,ve,0,0,Ae.width,Ae.height,we,he,Ae.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,ve,Re,Ae.width,Ae.height,0,we,he,Ae.data)}}}else{if(Q=x.mipmaps,P&&ae){Q.length>0&&ce++;const $=De(re[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,ce,Re,$.width,$.height)}for(let $=0;$<6;$++)if(J){P?ie&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,re[$].width,re[$].height,we,he,re[$].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,Re,re[$].width,re[$].height,0,we,he,re[$].data);for(let ve=0;ve<Q.length;ve++){const Ae=Q[ve].image[$].image;P?ie&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,ve+1,0,0,Ae.width,Ae.height,we,he,Ae.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,ve+1,Re,Ae.width,Ae.height,0,we,he,Ae.data)}}else{P?ie&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,we,he,re[$]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,Re,we,he,re[$]);for(let ve=0;ve<Q.length;ve++){const Ae=Q[ve];P?ie&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,ve+1,0,0,we,he,Ae.image[$]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+$,ve+1,Re,we,he,Ae.image[$])}}}f(x)&&p(s.TEXTURE_CUBE_MAP),V.__version=K.version,x.onUpdate&&x.onUpdate(x)}C.__version=x.version}function ue(C,x,B,X,K,V){const xe=n.convert(B.format,B.colorSpace),ne=n.convert(B.type),Se=_(B.internalFormat,xe,ne,B.colorSpace),de=i.get(x),J=i.get(B);if(J.__renderTarget=x,!de.__hasExternalTextures){const re=Math.max(1,x.width>>V),Oe=Math.max(1,x.height>>V);K===s.TEXTURE_3D||K===s.TEXTURE_2D_ARRAY?t.texImage3D(K,V,Se,re,Oe,x.depth,0,xe,ne,null):t.texImage2D(K,V,Se,re,Oe,0,xe,ne,null)}t.bindFramebuffer(s.FRAMEBUFFER,C),me(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,X,K,J.__webglTexture,0,Qe(x)):(K===s.TEXTURE_2D||K>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,X,K,J.__webglTexture,V),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ce(C,x,B){if(s.bindRenderbuffer(s.RENDERBUFFER,C),x.depthBuffer){const X=x.depthTexture,K=X&&X.isDepthTexture?X.type:null,V=E(x.stencilBuffer,K),xe=x.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ne=Qe(x);me(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ne,V,x.width,x.height):B?s.renderbufferStorageMultisample(s.RENDERBUFFER,ne,V,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,V,x.width,x.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,xe,s.RENDERBUFFER,C)}else{const X=x.textures;for(let K=0;K<X.length;K++){const V=X[K],xe=n.convert(V.format,V.colorSpace),ne=n.convert(V.type),Se=_(V.internalFormat,xe,ne,V.colorSpace),de=Qe(x);B&&me(x)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,de,Se,x.width,x.height):me(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,de,Se,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,Se,x.width,x.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Te(C,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,C),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const B=i.get(x.depthTexture);B.__renderTarget=x,(!B.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),j(x.depthTexture,0);const X=B.__webglTexture,K=Qe(x);if(x.depthTexture.format===ds)me(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,X,0,K):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,X,0);else if(x.depthTexture.format===Rr)me(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,X,0,K):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,X,0);else throw new Error("Unknown depthTexture format")}function Ee(C){const x=i.get(C),B=C.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==C.depthTexture){const X=C.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),X){const K=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",K)};X.addEventListener("dispose",K),x.__depthDisposeCallback=K}x.__boundDepthTexture=X}if(C.depthTexture&&!x.__autoAllocateDepthBuffer){if(B)throw new Error("target.depthTexture not supported in Cube render targets");const X=C.texture.mipmaps;X&&X.length>0?Te(x.__webglFramebuffer[0],C):Te(x.__webglFramebuffer,C)}else if(B){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=s.createRenderbuffer(),Ce(x.__webglDepthbuffer[X],C,!1);else{const K=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,V=x.__webglDepthbuffer[X];s.bindRenderbuffer(s.RENDERBUFFER,V),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,V)}}else{const X=C.texture.mipmaps;if(X&&X.length>0?t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=s.createRenderbuffer(),Ce(x.__webglDepthbuffer,C,!1);else{const K=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,V=x.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,V),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,V)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Je(C,x,B){const X=i.get(C);x!==void 0&&ue(X.__webglFramebuffer,C,C.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),B!==void 0&&Ee(C)}function Xe(C){const x=C.texture,B=i.get(C),X=i.get(x);C.addEventListener("dispose",A);const K=C.textures,V=C.isWebGLCubeRenderTarget===!0,xe=K.length>1;if(xe||(X.__webglTexture===void 0&&(X.__webglTexture=s.createTexture()),X.__version=x.version,a.memory.textures++),V){B.__webglFramebuffer=[];for(let ne=0;ne<6;ne++)if(x.mipmaps&&x.mipmaps.length>0){B.__webglFramebuffer[ne]=[];for(let Se=0;Se<x.mipmaps.length;Se++)B.__webglFramebuffer[ne][Se]=s.createFramebuffer()}else B.__webglFramebuffer[ne]=s.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){B.__webglFramebuffer=[];for(let ne=0;ne<x.mipmaps.length;ne++)B.__webglFramebuffer[ne]=s.createFramebuffer()}else B.__webglFramebuffer=s.createFramebuffer();if(xe)for(let ne=0,Se=K.length;ne<Se;ne++){const de=i.get(K[ne]);de.__webglTexture===void 0&&(de.__webglTexture=s.createTexture(),a.memory.textures++)}if(C.samples>0&&me(C)===!1){B.__webglMultisampledFramebuffer=s.createFramebuffer(),B.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let ne=0;ne<K.length;ne++){const Se=K[ne];B.__webglColorRenderbuffer[ne]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,B.__webglColorRenderbuffer[ne]);const de=n.convert(Se.format,Se.colorSpace),J=n.convert(Se.type),re=_(Se.internalFormat,de,J,Se.colorSpace,C.isXRRenderTarget===!0),Oe=Qe(C);s.renderbufferStorageMultisample(s.RENDERBUFFER,Oe,re,C.width,C.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ne,s.RENDERBUFFER,B.__webglColorRenderbuffer[ne])}s.bindRenderbuffer(s.RENDERBUFFER,null),C.depthBuffer&&(B.__webglDepthRenderbuffer=s.createRenderbuffer(),Ce(B.__webglDepthRenderbuffer,C,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(V){t.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture),ze(s.TEXTURE_CUBE_MAP,x);for(let ne=0;ne<6;ne++)if(x.mipmaps&&x.mipmaps.length>0)for(let Se=0;Se<x.mipmaps.length;Se++)ue(B.__webglFramebuffer[ne][Se],C,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Se);else ue(B.__webglFramebuffer[ne],C,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0);f(x)&&p(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(xe){for(let ne=0,Se=K.length;ne<Se;ne++){const de=K[ne],J=i.get(de);let re=s.TEXTURE_2D;(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(re=C.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(re,J.__webglTexture),ze(re,de),ue(B.__webglFramebuffer,C,de,s.COLOR_ATTACHMENT0+ne,re,0),f(de)&&p(re)}t.unbindTexture()}else{let ne=s.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(ne=C.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ne,X.__webglTexture),ze(ne,x),x.mipmaps&&x.mipmaps.length>0)for(let Se=0;Se<x.mipmaps.length;Se++)ue(B.__webglFramebuffer[Se],C,x,s.COLOR_ATTACHMENT0,ne,Se);else ue(B.__webglFramebuffer,C,x,s.COLOR_ATTACHMENT0,ne,0);f(x)&&p(ne),t.unbindTexture()}C.depthBuffer&&Ee(C)}function Ge(C){const x=C.textures;for(let B=0,X=x.length;B<X;B++){const K=x[B];if(f(K)){const V=y(C),xe=i.get(K).__webglTexture;t.bindTexture(V,xe),p(V),t.unbindTexture()}}}const D=[],_t=[];function We(C){if(C.samples>0){if(me(C)===!1){const x=C.textures,B=C.width,X=C.height;let K=s.COLOR_BUFFER_BIT;const V=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,xe=i.get(C),ne=x.length>1;if(ne)for(let de=0;de<x.length;de++)t.bindFramebuffer(s.FRAMEBUFFER,xe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+de,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,xe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+de,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,xe.__webglMultisampledFramebuffer);const Se=C.texture.mipmaps;Se&&Se.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,xe.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,xe.__webglFramebuffer);for(let de=0;de<x.length;de++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(K|=s.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(K|=s.STENCIL_BUFFER_BIT)),ne){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,xe.__webglColorRenderbuffer[de]);const J=i.get(x[de]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,J,0)}s.blitFramebuffer(0,0,B,X,0,0,B,X,K,s.NEAREST),l===!0&&(D.length=0,_t.length=0,D.push(s.COLOR_ATTACHMENT0+de),C.depthBuffer&&C.resolveDepthBuffer===!1&&(D.push(V),_t.push(V),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,_t)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,D))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),ne)for(let de=0;de<x.length;de++){t.bindFramebuffer(s.FRAMEBUFFER,xe.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+de,s.RENDERBUFFER,xe.__webglColorRenderbuffer[de]);const J=i.get(x[de]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,xe.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+de,s.TEXTURE_2D,J,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,xe.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const x=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[x])}}}function Qe(C){return Math.min(r.maxSamples,C.samples)}function me(C){const x=i.get(C);return C.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function at(C){const x=a.render.frame;h.get(C)!==x&&(h.set(C,x),C.update())}function Me(C,x){const B=C.colorSpace,X=C.format,K=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||B!==Nt&&B!==qi&&(je.getTransfer(B)===et?(X!==qt||K!==ni)&&be("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):He("WebGLTextures: Unsupported texture color space:",B)),x}function De(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=N,this.setTexture2D=j,this.setTexture2DArray=q,this.setTexture3D=te,this.setTextureCube=G,this.rebindTextures=Je,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=Ge,this.updateMultisampleRenderTarget=We,this.setupDepthRenderbuffer=Ee,this.setupFrameBufferTexture=ue,this.useMultisampledRTT=me}function Gv(s,e){function t(i,r=qi){let n;const a=je.getTransfer(r);if(i===ni)return s.UNSIGNED_BYTE;if(i===ea)return s.UNSIGNED_SHORT_4_4_4_4;if(i===ta)return s.UNSIGNED_SHORT_5_5_5_1;if(i===Tl)return s.UNSIGNED_INT_5_9_9_9_REV;if(i===Sl)return s.UNSIGNED_INT_10F_11F_11F_REV;if(i===bl)return s.BYTE;if(i===Ml)return s.SHORT;if(i===us)return s.UNSIGNED_SHORT;if(i===Qn)return s.INT;if(i===ar)return s.UNSIGNED_INT;if(i===Wt)return s.FLOAT;if(i===pt)return s.HALF_FLOAT;if(i===El)return s.ALPHA;if(i===wl)return s.RGB;if(i===qt)return s.RGBA;if(i===ds)return s.DEPTH_COMPONENT;if(i===Rr)return s.DEPTH_STENCIL;if(i===ia)return s.RED;if(i===ra)return s.RED_INTEGER;if(i===sa)return s.RG;if(i===na)return s.RG_INTEGER;if(i===aa)return s.RGBA_INTEGER;if(i===Vs||i===Gs||i===Ws||i===js)if(a===et)if(n=e.get("WEBGL_compressed_texture_s3tc_srgb"),n!==null){if(i===Vs)return n.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Gs)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ws)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===js)return n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(n=e.get("WEBGL_compressed_texture_s3tc"),n!==null){if(i===Vs)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Gs)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ws)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===js)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===oa||i===la||i===ca||i===ha)if(n=e.get("WEBGL_compressed_texture_pvrtc"),n!==null){if(i===oa)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===la)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ca)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===ha)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===ua||i===da||i===pa)if(n=e.get("WEBGL_compressed_texture_etc"),n!==null){if(i===ua||i===da)return a===et?n.COMPRESSED_SRGB8_ETC2:n.COMPRESSED_RGB8_ETC2;if(i===pa)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:n.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===ma||i===fa||i===ga||i===va||i===_a||i===xa||i===ya||i===ba||i===Ma||i===Ta||i===Sa||i===Ea||i===wa||i===Ca)if(n=e.get("WEBGL_compressed_texture_astc"),n!==null){if(i===ma)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:n.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===fa)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:n.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ga)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:n.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===va)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:n.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===_a)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:n.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===xa)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:n.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===ya)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:n.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ba)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:n.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ma)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:n.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Ta)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:n.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Sa)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:n.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Ea)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:n.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===wa)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:n.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ca)return a===et?n.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:n.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ra||i===Aa||i===Pa)if(n=e.get("EXT_texture_compression_bptc"),n!==null){if(i===Ra)return a===et?n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:n.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Aa)return n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Pa)return n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===La||i===Da||i===Ia||i===Ua)if(n=e.get("EXT_texture_compression_rgtc"),n!==null){if(i===La)return n.COMPRESSED_RED_RGTC1_EXT;if(i===Da)return n.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ia)return n.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Ua)return n.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Cr?s.UNSIGNED_INT_24_8:s[i]!==void 0?s[i]:null}return{convert:t}}const Wv=`
|
||
void main() {
|
||
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}`,jv=`
|
||
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 Xv{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Mc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new ot({vertexShader:Wv,fragmentShader:jv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new rt(new ws(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class qv extends or{constructor(e,t){super();const i=this;let r=null,n=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,m=null,g=null;const v=typeof XRWebGLBinding<"u",f=new Xv,p={},y=t.getContextAttributes();let _=null,E=null;const R=[],T=[],A=new oe;let I=null;const S=new Tt;S.viewport=new Ke;const M=new Tt;M.viewport=new Ke;const L=[S,M],N=new ep;let z=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let Y=R[W];return Y===void 0&&(Y=new po,R[W]=Y),Y.getTargetRaySpace()},this.getControllerGrip=function(W){let Y=R[W];return Y===void 0&&(Y=new po,R[W]=Y),Y.getGripSpace()},this.getHand=function(W){let Y=R[W];return Y===void 0&&(Y=new po,R[W]=Y),Y.getHandSpace()};function j(W){const Y=T.indexOf(W.inputSource);if(Y===-1)return;const ue=R[Y];ue!==void 0&&(ue.update(W.inputSource,W.frame,c||a),ue.dispatchEvent({type:W.type,data:W.inputSource}))}function q(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",q),r.removeEventListener("inputsourceschange",te);for(let W=0;W<R.length;W++){const Y=T[W];Y!==null&&(T[W]=null,R[W].disconnect(Y))}z=null,H=null,f.reset();for(const W in p)delete p[W];e.setRenderTarget(_),m=null,d=null,u=null,r=null,E=null,$e.stop(),i.isPresenting=!1,e.setPixelRatio(I),e.setSize(A.width,A.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(W){n=W,i.isPresenting===!0&&be("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(W){o=W,i.isPresenting===!0&&be("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(W){c=W},this.getBaseLayer=function(){return d!==null?d:m},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(W){if(r=W,r!==null){if(_=e.getRenderTarget(),r.addEventListener("select",j),r.addEventListener("selectstart",j),r.addEventListener("selectend",j),r.addEventListener("squeeze",j),r.addEventListener("squeezestart",j),r.addEventListener("squeezeend",j),r.addEventListener("end",q),r.addEventListener("inputsourceschange",te),y.xrCompatible!==!0&&await t.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(A),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Y=null,ue=null,Ce=null;y.depth&&(Ce=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Y=y.stencil?Rr:ds,ue=y.stencil?Cr:ar);const Te={colorFormat:t.RGBA8,depthFormat:Ce,scaleFactor:n};u=this.getBinding(),d=u.createProjectionLayer(Te),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),E=new bt(d.textureWidth,d.textureHeight,{format:qt,type:ni,depthTexture:new Eo(d.textureWidth,d.textureHeight,ue,void 0,void 0,void 0,void 0,void 0,void 0,Y),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const Y={antialias:y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:n};m=new XRWebGLLayer(r,t,Y),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),E=new bt(m.framebufferWidth,m.framebufferHeight,{format:qt,type:ni,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),$e.setContext(r),$e.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};function te(W){for(let Y=0;Y<W.removed.length;Y++){const ue=W.removed[Y],Ce=T.indexOf(ue);Ce>=0&&(T[Ce]=null,R[Ce].disconnect(ue))}for(let Y=0;Y<W.added.length;Y++){const ue=W.added[Y];let Ce=T.indexOf(ue);if(Ce===-1){for(let Ee=0;Ee<R.length;Ee++)if(Ee>=T.length){T.push(ue),Ce=Ee;break}else if(T[Ee]===null){T[Ee]=ue,Ce=Ee;break}if(Ce===-1)break}const Te=R[Ce];Te&&Te.connect(ue)}}const G=new w,Z=new w;function se(W,Y,ue){G.setFromMatrixPosition(Y.matrixWorld),Z.setFromMatrixPosition(ue.matrixWorld);const Ce=G.distanceTo(Z),Te=Y.projectionMatrix.elements,Ee=ue.projectionMatrix.elements,Je=Te[14]/(Te[10]-1),Xe=Te[14]/(Te[10]+1),Ge=(Te[9]+1)/Te[5],D=(Te[9]-1)/Te[5],_t=(Te[8]-1)/Te[0],We=(Ee[8]+1)/Ee[0],Qe=Je*_t,me=Je*We,at=Ce/(-_t+We),Me=at*-_t;if(Y.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Me),W.translateZ(at),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert(),Te[10]===-1)W.projectionMatrix.copy(Y.projectionMatrix),W.projectionMatrixInverse.copy(Y.projectionMatrixInverse);else{const De=Je+at,C=Xe+at,x=Qe-Me,B=me+(Ce-Me),X=Ge*Xe/C*De,K=D*Xe/C*De;W.projectionMatrix.makePerspective(x,B,X,K,De,C),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}}function Pe(W,Y){Y===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(Y.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(r===null)return;let Y=W.near,ue=W.far;f.texture!==null&&(f.depthNear>0&&(Y=f.depthNear),f.depthFar>0&&(ue=f.depthFar)),N.near=M.near=S.near=Y,N.far=M.far=S.far=ue,(z!==N.near||H!==N.far)&&(r.updateRenderState({depthNear:N.near,depthFar:N.far}),z=N.near,H=N.far),N.layers.mask=W.layers.mask|6,S.layers.mask=N.layers.mask&3,M.layers.mask=N.layers.mask&5;const Ce=W.parent,Te=N.cameras;Pe(N,Ce);for(let Ee=0;Ee<Te.length;Ee++)Pe(Te[Ee],Ce);Te.length===2?se(N,S,M):N.projectionMatrix.copy(S.projectionMatrix),ze(W,N,Ce)};function ze(W,Y,ue){ue===null?W.matrix.copy(Y.matrixWorld):(W.matrix.copy(ue.matrixWorld),W.matrix.invert(),W.matrix.multiply(Y.matrixWorld)),W.matrix.decompose(W.position,W.quaternion,W.scale),W.updateMatrixWorld(!0),W.projectionMatrix.copy(Y.projectionMatrix),W.projectionMatrixInverse.copy(Y.projectionMatrixInverse),W.isPerspectiveCamera&&(W.fov=Pr*2*Math.atan(1/W.projectionMatrix.elements[5]),W.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(d===null&&m===null))return l},this.setFoveation=function(W){l=W,d!==null&&(d.fixedFoveation=W),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=W)},this.hasDepthSensing=function(){return f.texture!==null},this.getDepthSensingMesh=function(){return f.getMesh(N)},this.getCameraTexture=function(W){return p[W]};let qe=null;function Ze(W,Y){if(h=Y.getViewerPose(c||a),g=Y,h!==null){const ue=h.views;m!==null&&(e.setRenderTargetFramebuffer(E,m.framebuffer),e.setRenderTarget(E));let Ce=!1;ue.length!==N.cameras.length&&(N.cameras.length=0,Ce=!0);for(let Ee=0;Ee<ue.length;Ee++){const Je=ue[Ee];let Xe=null;if(m!==null)Xe=m.getViewport(Je);else{const D=u.getViewSubImage(d,Je);Xe=D.viewport,Ee===0&&(e.setRenderTargetTextures(E,D.colorTexture,D.depthStencilTexture),e.setRenderTarget(E))}let Ge=L[Ee];Ge===void 0&&(Ge=new Tt,Ge.layers.enable(Ee),Ge.viewport=new Ke,L[Ee]=Ge),Ge.matrix.fromArray(Je.transform.matrix),Ge.matrix.decompose(Ge.position,Ge.quaternion,Ge.scale),Ge.projectionMatrix.fromArray(Je.projectionMatrix),Ge.projectionMatrixInverse.copy(Ge.projectionMatrix).invert(),Ge.viewport.set(Xe.x,Xe.y,Xe.width,Xe.height),Ee===0&&(N.matrix.copy(Ge.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),Ce===!0&&N.cameras.push(Ge)}const Te=r.enabledFeatures;if(Te&&Te.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const Ee=u.getDepthInformation(ue[0]);Ee&&Ee.isValid&&Ee.texture&&f.init(Ee,r.renderState)}if(Te&&Te.includes("camera-access")&&v){e.state.unbindTexture(),u=i.getBinding();for(let Ee=0;Ee<ue.length;Ee++){const Je=ue[Ee].camera;if(Je){let Xe=p[Je];Xe||(Xe=new Mc,p[Je]=Xe);const Ge=u.getCameraImage(Je);Xe.sourceTexture=Ge}}}}for(let ue=0;ue<R.length;ue++){const Ce=T[ue],Te=R[ue];Ce!==null&&Te!==void 0&&Te.update(Ce,Y,c||a)}qe&&qe(W,Y),Y.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Y}),g=null}const $e=new zc;$e.setAnimationLoop(Ze),this.setAnimationLoop=function(W){qe=W},this.dispose=function(){}}}const gr=new ui,Yv=new Le;function Kv(s,e){function t(f,p){f.matrixAutoUpdate===!0&&f.updateMatrix(),p.value.copy(f.matrix)}function i(f,p){p.color.getRGB(f.fogColor.value,tc(s)),p.isFog?(f.fogNear.value=p.near,f.fogFar.value=p.far):p.isFogExp2&&(f.fogDensity.value=p.density)}function r(f,p,y,_,E){p.isMeshBasicMaterial||p.isMeshLambertMaterial?n(f,p):p.isMeshToonMaterial?(n(f,p),u(f,p)):p.isMeshPhongMaterial?(n(f,p),h(f,p)):p.isMeshStandardMaterial?(n(f,p),d(f,p),p.isMeshPhysicalMaterial&&m(f,p,E)):p.isMeshMatcapMaterial?(n(f,p),g(f,p)):p.isMeshDepthMaterial?n(f,p):p.isMeshDistanceMaterial?(n(f,p),v(f,p)):p.isMeshNormalMaterial?n(f,p):p.isLineBasicMaterial?(a(f,p),p.isLineDashedMaterial&&o(f,p)):p.isPointsMaterial?l(f,p,y,_):p.isSpriteMaterial?c(f,p):p.isShadowMaterial?(f.color.value.copy(p.color),f.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function n(f,p){f.opacity.value=p.opacity,p.color&&f.diffuse.value.copy(p.color),p.emissive&&f.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(f.map.value=p.map,t(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.bumpMap&&(f.bumpMap.value=p.bumpMap,t(p.bumpMap,f.bumpMapTransform),f.bumpScale.value=p.bumpScale,p.side===Ft&&(f.bumpScale.value*=-1)),p.normalMap&&(f.normalMap.value=p.normalMap,t(p.normalMap,f.normalMapTransform),f.normalScale.value.copy(p.normalScale),p.side===Ft&&f.normalScale.value.negate()),p.displacementMap&&(f.displacementMap.value=p.displacementMap,t(p.displacementMap,f.displacementMapTransform),f.displacementScale.value=p.displacementScale,f.displacementBias.value=p.displacementBias),p.emissiveMap&&(f.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,f.emissiveMapTransform)),p.specularMap&&(f.specularMap.value=p.specularMap,t(p.specularMap,f.specularMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest);const y=e.get(p),_=y.envMap,E=y.envMapRotation;_&&(f.envMap.value=_,gr.copy(E),gr.x*=-1,gr.y*=-1,gr.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(gr.y*=-1,gr.z*=-1),f.envMapRotation.value.setFromMatrix4(Yv.makeRotationFromEuler(gr)),f.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=p.reflectivity,f.ior.value=p.ior,f.refractionRatio.value=p.refractionRatio),p.lightMap&&(f.lightMap.value=p.lightMap,f.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,f.lightMapTransform)),p.aoMap&&(f.aoMap.value=p.aoMap,f.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,f.aoMapTransform))}function a(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform))}function o(f,p){f.dashSize.value=p.dashSize,f.totalSize.value=p.dashSize+p.gapSize,f.scale.value=p.scale}function l(f,p,y,_){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.size.value=p.size*y,f.scale.value=_*.5,p.map&&(f.map.value=p.map,t(p.map,f.uvTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function c(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.rotation.value=p.rotation,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function h(f,p){f.specular.value.copy(p.specular),f.shininess.value=Math.max(p.shininess,1e-4)}function u(f,p){p.gradientMap&&(f.gradientMap.value=p.gradientMap)}function d(f,p){f.metalness.value=p.metalness,p.metalnessMap&&(f.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,f.metalnessMapTransform)),f.roughness.value=p.roughness,p.roughnessMap&&(f.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,f.roughnessMapTransform)),p.envMap&&(f.envMapIntensity.value=p.envMapIntensity)}function m(f,p,y){f.ior.value=p.ior,p.sheen>0&&(f.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),f.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(f.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,f.sheenColorMapTransform)),p.sheenRoughnessMap&&(f.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,f.sheenRoughnessMapTransform))),p.clearcoat>0&&(f.clearcoat.value=p.clearcoat,f.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(f.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,f.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(f.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ft&&f.clearcoatNormalScale.value.negate())),p.dispersion>0&&(f.dispersion.value=p.dispersion),p.iridescence>0&&(f.iridescence.value=p.iridescence,f.iridescenceIOR.value=p.iridescenceIOR,f.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(f.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,f.iridescenceMapTransform)),p.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),p.transmission>0&&(f.transmission.value=p.transmission,f.transmissionSamplerMap.value=y.texture,f.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(f.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,f.transmissionMapTransform)),f.thickness.value=p.thickness,p.thicknessMap&&(f.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=p.attenuationDistance,f.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(f.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(f.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=p.specularIntensity,f.specularColor.value.copy(p.specularColor),p.specularColorMap&&(f.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,f.specularColorMapTransform)),p.specularIntensityMap&&(f.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,f.specularIntensityMapTransform))}function g(f,p){p.matcap&&(f.matcap.value=p.matcap)}function v(f,p){const y=e.get(p).light;f.referencePosition.value.setFromMatrixPosition(y.matrixWorld),f.nearDistance.value=y.shadow.camera.near,f.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Zv(s,e,t,i){let r={},n={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,_){const E=_.program;i.uniformBlockBinding(y,E)}function c(y,_){let E=r[y.id];E===void 0&&(g(y),E=h(y),r[y.id]=E,y.addEventListener("dispose",f));const R=_.program;i.updateUBOMapping(y,R);const T=e.render.frame;n[y.id]!==T&&(d(y),n[y.id]=T)}function h(y){const _=u();y.__bindingPointIndex=_;const E=s.createBuffer(),R=y.__size,T=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,E),s.bufferData(s.UNIFORM_BUFFER,R,T),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,_,E),E}function u(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return He("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const _=r[y.id],E=y.uniforms,R=y.__cache;s.bindBuffer(s.UNIFORM_BUFFER,_);for(let T=0,A=E.length;T<A;T++){const I=Array.isArray(E[T])?E[T]:[E[T]];for(let S=0,M=I.length;S<M;S++){const L=I[S];if(m(L,T,S,R)===!0){const N=L.__offset,z=Array.isArray(L.value)?L.value:[L.value];let H=0;for(let j=0;j<z.length;j++){const q=z[j],te=v(q);typeof q=="number"||typeof q=="boolean"?(L.__data[0]=q,s.bufferSubData(s.UNIFORM_BUFFER,N+H,L.__data)):q.isMatrix3?(L.__data[0]=q.elements[0],L.__data[1]=q.elements[1],L.__data[2]=q.elements[2],L.__data[3]=0,L.__data[4]=q.elements[3],L.__data[5]=q.elements[4],L.__data[6]=q.elements[5],L.__data[7]=0,L.__data[8]=q.elements[6],L.__data[9]=q.elements[7],L.__data[10]=q.elements[8],L.__data[11]=0):(q.toArray(L.__data,H),H+=te.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,N,L.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function m(y,_,E,R){const T=y.value,A=_+"_"+E;if(R[A]===void 0)return typeof T=="number"||typeof T=="boolean"?R[A]=T:R[A]=T.clone(),!0;{const I=R[A];if(typeof T=="number"||typeof T=="boolean"){if(I!==T)return R[A]=T,!0}else if(I.equals(T)===!1)return I.copy(T),!0}return!1}function g(y){const _=y.uniforms;let E=0;const R=16;for(let A=0,I=_.length;A<I;A++){const S=Array.isArray(_[A])?_[A]:[_[A]];for(let M=0,L=S.length;M<L;M++){const N=S[M],z=Array.isArray(N.value)?N.value:[N.value];for(let H=0,j=z.length;H<j;H++){const q=z[H],te=v(q),G=E%R,Z=G%te.boundary,se=G+Z;E+=Z,se!==0&&R-se<te.storage&&(E+=R-se),N.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=E,E+=te.storage}}}const T=E%R;return T>0&&(E+=R-T),y.__size=E,y.__cache={},this}function v(y){const _={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(_.boundary=4,_.storage=4):y.isVector2?(_.boundary=8,_.storage=8):y.isVector3||y.isColor?(_.boundary=16,_.storage=12):y.isVector4?(_.boundary=16,_.storage=16):y.isMatrix3?(_.boundary=48,_.storage=48):y.isMatrix4?(_.boundary=64,_.storage=64):y.isTexture?be("WebGLRenderer: Texture samplers can not be part of an uniforms group."):be("WebGLRenderer: Unsupported uniform value type.",y),_}function f(y){const _=y.target;_.removeEventListener("dispose",f);const E=a.indexOf(_.__bindingPointIndex);a.splice(E,1),s.deleteBuffer(r[_.id]),delete r[_.id],delete n[_.id]}function p(){for(const y in r)s.deleteBuffer(r[y]);a=[],r={},n={}}return{bind:l,update:c,dispose:p}}const $v=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 Gi=null;function Jv(){return Gi===null&&(Gi=new Xr($v,32,32,sa,pt),Gi.minFilter=yt,Gi.magFilter=yt,Gi.wrapS=$t,Gi.wrapT=$t,Gi.generateMipmaps=!1,Gi.needsUpdate=!0),Gi}class An{constructor(e={}){const{canvas:t=Au(),context:i=null,depth:r=!0,stencil:n=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let m;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=i.getContextAttributes().alpha}else m=a;const g=new Set([aa,na,ra]),v=new Set([ni,ar,us,Cr,ea,ta]),f=new Uint32Array(4),p=new Int32Array(4);let y=null,_=null;const E=[],R=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Xi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const T=this;let A=!1;this._outputColorSpace=Ct;let I=0,S=0,M=null,L=-1,N=null;const z=new Ke,H=new Ke;let j=null;const q=new _e(0);let te=0,G=t.width,Z=t.height,se=1,Pe=null,ze=null;const qe=new Ke(0,0,G,Z),Ze=new Ke(0,0,G,Z);let $e=!1;const W=new bo;let Y=!1,ue=!1;const Ce=new Le,Te=new w,Ee=new Ke,Je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Xe=!1;function Ge(){return M===null?se:1}let D=i;function _t(b,O){return t.getContext(b,O)}try{const b={alpha:!0,depth:r,stencil:n,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r181"),t.addEventListener("webglcontextlost",Q,!1),t.addEventListener("webglcontextrestored",$,!1),t.addEventListener("webglcontextcreationerror",ve,!1),D===null){const O="webgl2";if(D=_t(O,b),D===null)throw _t(O)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(b){throw b("WebGLRenderer: "+b.message),b}let We,Qe,me,at,Me,De,C,x,B,X,K,V,xe,ne,Se,de,J,re,Oe,we,he,Re,P,ae;function ie(){We=new og(D),We.init(),Re=new Gv(D,We),Qe=new Jf(D,We,e,Re),me=new Hv(D,We),Qe.reversedDepthBuffer&&d&&me.buffers.depth.setReversed(!0),at=new hg(D),Me=new Rv,De=new Vv(D,We,me,Me,Qe,Re,at),C=new eg(T),x=new ag(T),B=new pp(D),P=new Zf(D,B),X=new lg(D,B,at,P),K=new dg(D,X,B,at),Oe=new ug(D,Qe,De),de=new Qf(Me),V=new Cv(T,C,x,We,Qe,P,de),xe=new Kv(T,Me),ne=new Pv,Se=new Ov(We),re=new Kf(T,C,x,me,K,m,l),J=new kv(T,K,Qe),ae=new Zv(D,at,Qe,me),we=new $f(D,We,at),he=new cg(D,We,at),at.programs=V.programs,T.capabilities=Qe,T.extensions=We,T.properties=Me,T.renderLists=ne,T.shadowMap=J,T.state=me,T.info=at}ie();const ce=new qv(T,D);this.xr=ce,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const b=We.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){const b=We.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(b){b!==void 0&&(se=b,this.setSize(G,Z,!1))},this.getSize=function(b){return b.set(G,Z)},this.setSize=function(b,O,F=!0){if(ce.isPresenting){be("WebGLRenderer: Can't change size while VR device is presenting.");return}G=b,Z=O,t.width=Math.floor(b*se),t.height=Math.floor(O*se),F===!0&&(t.style.width=b+"px",t.style.height=O+"px"),this.setViewport(0,0,b,O)},this.getDrawingBufferSize=function(b){return b.set(G*se,Z*se).floor()},this.setDrawingBufferSize=function(b,O,F){G=b,Z=O,se=F,t.width=Math.floor(b*F),t.height=Math.floor(O*F),this.setViewport(0,0,b,O)},this.getCurrentViewport=function(b){return b.copy(z)},this.getViewport=function(b){return b.copy(qe)},this.setViewport=function(b,O,F,k){b.isVector4?qe.set(b.x,b.y,b.z,b.w):qe.set(b,O,F,k),me.viewport(z.copy(qe).multiplyScalar(se).round())},this.getScissor=function(b){return b.copy(Ze)},this.setScissor=function(b,O,F,k){b.isVector4?Ze.set(b.x,b.y,b.z,b.w):Ze.set(b,O,F,k),me.scissor(H.copy(Ze).multiplyScalar(se).round())},this.getScissorTest=function(){return $e},this.setScissorTest=function(b){me.setScissorTest($e=b)},this.setOpaqueSort=function(b){Pe=b},this.setTransparentSort=function(b){ze=b},this.getClearColor=function(b){return b.copy(re.getClearColor())},this.setClearColor=function(){re.setClearColor(...arguments)},this.getClearAlpha=function(){return re.getClearAlpha()},this.setClearAlpha=function(){re.setClearAlpha(...arguments)},this.clear=function(b=!0,O=!0,F=!0){let k=0;if(b){let U=!1;if(M!==null){const ee=M.texture.format;U=g.has(ee)}if(U){const ee=M.texture.type,pe=v.has(ee),fe=re.getClearColor(),ge=re.getClearAlpha(),Ie=fe.r,Ne=fe.g,Ue=fe.b;pe?(f[0]=Ie,f[1]=Ne,f[2]=Ue,f[3]=ge,D.clearBufferuiv(D.COLOR,0,f)):(p[0]=Ie,p[1]=Ne,p[2]=Ue,p[3]=ge,D.clearBufferiv(D.COLOR,0,p))}else k|=D.COLOR_BUFFER_BIT}O&&(k|=D.DEPTH_BUFFER_BIT),F&&(k|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),D.clear(k)},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",Q,!1),t.removeEventListener("webglcontextrestored",$,!1),t.removeEventListener("webglcontextcreationerror",ve,!1),re.dispose(),ne.dispose(),Se.dispose(),Me.dispose(),C.dispose(),x.dispose(),K.dispose(),P.dispose(),ae.dispose(),V.dispose(),ce.dispose(),ce.removeEventListener("sessionstart",Oh),ce.removeEventListener("sessionend",Bh),_r.stop()};function Q(b){b.preventDefault(),Ks("WebGLRenderer: Context Lost."),A=!0}function $(){Ks("WebGLRenderer: Context Restored."),A=!1;const b=at.autoReset,O=J.enabled,F=J.autoUpdate,k=J.needsUpdate,U=J.type;ie(),at.autoReset=b,J.enabled=O,J.autoUpdate=F,J.needsUpdate=k,J.type=U}function ve(b){He("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Ae(b){const O=b.target;O.removeEventListener("dispose",Ae),Lt(O)}function Lt(b){nt(b),Me.remove(b)}function nt(b){const O=Me.get(b).programs;O!==void 0&&(O.forEach(function(F){V.releaseProgram(F)}),b.isShaderMaterial&&V.releaseShaderCache(b))}this.renderBufferDirect=function(b,O,F,k,U,ee){O===null&&(O=Je);const pe=U.isMesh&&U.matrixWorld.determinant()<0,fe=m1(b,O,F,k,U);me.setMaterial(k,pe);let ge=F.index,Ie=1;if(k.wireframe===!0){if(ge=X.getWireframeAttribute(F),ge===void 0)return;Ie=2}const Ne=F.drawRange,Ue=F.attributes.position;let Ye=Ne.start*Ie,lt=(Ne.start+Ne.count)*Ie;ee!==null&&(Ye=Math.max(Ye,ee.start*Ie),lt=Math.min(lt,(ee.start+ee.count)*Ie)),ge!==null?(Ye=Math.max(Ye,0),lt=Math.min(lt,ge.count)):Ue!=null&&(Ye=Math.max(Ye,0),lt=Math.min(lt,Ue.count));const ft=lt-Ye;if(ft<0||ft===1/0)return;P.setup(U,k,fe,F,ge);let ut,ct=we;if(ge!==null&&(ut=B.get(ge),ct=he,ct.setIndex(ut)),U.isMesh)k.wireframe===!0?(me.setLineWidth(k.wireframeLinewidth*Ge()),ct.setMode(D.LINES)):ct.setMode(D.TRIANGLES);else if(U.isLine){let ye=k.linewidth;ye===void 0&&(ye=1),me.setLineWidth(ye*Ge()),U.isLineSegments?ct.setMode(D.LINES):U.isLineLoop?ct.setMode(D.LINE_LOOP):ct.setMode(D.LINE_STRIP)}else U.isPoints?ct.setMode(D.POINTS):U.isSprite&&ct.setMode(D.TRIANGLES);if(U.isBatchedMesh)if(U._multiDrawInstances!==null)gs("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ct.renderMultiDrawInstances(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount,U._multiDrawInstances);else if(We.get("WEBGL_multi_draw"))ct.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else{const ye=U._multiDrawStarts,It=U._multiDrawCounts,Wi=U._multiDrawCount,xi=ge?B.get(ge).bytesPerElement:1,os=Me.get(k).currentProgram.getUniforms();for(let Zt=0;Zt<Wi;Zt++)os.setValue(D,"_gl_DrawID",Zt),ct.render(ye[Zt]/xi,It[Zt])}else if(U.isInstancedMesh)ct.renderInstances(Ye,ft,U.count);else if(F.isInstancedBufferGeometry){const ye=F._maxInstanceCount!==void 0?F._maxInstanceCount:1/0,It=Math.min(F.instanceCount,ye);ct.renderInstances(Ye,ft,It)}else ct.render(Ye,ft)};function Li(b,O,F){b.transparent===!0&&b.side===Gt&&b.forceSinglePass===!1?(b.side=Ft,b.needsUpdate=!0,Bn(b,O,F),b.side=bi,b.needsUpdate=!0,Bn(b,O,F),b.side=Gt):Bn(b,O,F)}this.compile=function(b,O,F=null){F===null&&(F=b),_=Se.get(F),_.init(O),R.push(_),F.traverseVisible(function(U){U.isLight&&U.layers.test(O.layers)&&(_.pushLight(U),U.castShadow&&_.pushShadow(U))}),b!==F&&b.traverseVisible(function(U){U.isLight&&U.layers.test(O.layers)&&(_.pushLight(U),U.castShadow&&_.pushShadow(U))}),_.setupLights();const k=new Set;return b.traverse(function(U){if(!(U.isMesh||U.isPoints||U.isLine||U.isSprite))return;const ee=U.material;if(ee)if(Array.isArray(ee))for(let pe=0;pe<ee.length;pe++){const fe=ee[pe];Li(fe,F,U),k.add(fe)}else Li(ee,F,U),k.add(ee)}),_=R.pop(),k},this.compileAsync=function(b,O,F=null){const k=this.compile(b,O,F);return new Promise(U=>{function ee(){if(k.forEach(function(pe){Me.get(pe).currentProgram.isReady()&&k.delete(pe)}),k.size===0){U(b);return}setTimeout(ee,10)}We.get("KHR_parallel_shader_compile")!==null?ee():setTimeout(ee,10)})};let _i=null;function p1(b){_i&&_i(b)}function Oh(){_r.stop()}function Bh(){_r.start()}const _r=new zc;_r.setAnimationLoop(p1),typeof self<"u"&&_r.setContext(self),this.setAnimationLoop=function(b){_i=b,ce.setAnimationLoop(b),b===null?_r.stop():_r.start()},ce.addEventListener("sessionstart",Oh),ce.addEventListener("sessionend",Bh),this.render=function(b,O){if(O!==void 0&&O.isCamera!==!0){He("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),ce.enabled===!0&&ce.isPresenting===!0&&(ce.cameraAutoUpdate===!0&&ce.updateCamera(O),O=ce.getCamera()),b.isScene===!0&&b.onBeforeRender(T,b,O,M),_=Se.get(b,R.length),_.init(O),R.push(_),Ce.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),W.setFromProjectionMatrix(Ce,Si,O.reversedDepth),ue=this.localClippingEnabled,Y=de.init(this.clippingPlanes,ue),y=ne.get(b,E.length),y.init(),E.push(y),ce.enabled===!0&&ce.isPresenting===!0){const ee=T.xr.getDepthSensingMesh();ee!==null&&il(ee,O,-1/0,T.sortObjects)}il(b,O,0,T.sortObjects),y.finish(),T.sortObjects===!0&&y.sort(Pe,ze),Xe=ce.enabled===!1||ce.isPresenting===!1||ce.hasDepthSensing()===!1,Xe&&re.addToRenderList(y,b),this.info.render.frame++,Y===!0&&de.beginShadows();const F=_.state.shadowsArray;J.render(F,b,O),Y===!0&&de.endShadows(),this.info.autoReset===!0&&this.info.reset();const k=y.opaque,U=y.transmissive;if(_.setupLights(),O.isArrayCamera){const ee=O.cameras;if(U.length>0)for(let pe=0,fe=ee.length;pe<fe;pe++){const ge=ee[pe];kh(k,U,b,ge)}Xe&&re.render(b);for(let pe=0,fe=ee.length;pe<fe;pe++){const ge=ee[pe];Fh(y,b,ge,ge.viewport)}}else U.length>0&&kh(k,U,b,O),Xe&&re.render(b),Fh(y,b,O);M!==null&&S===0&&(De.updateMultisampleRenderTarget(M),De.updateRenderTargetMipmap(M)),b.isScene===!0&&b.onAfterRender(T,b,O),P.resetDefaultState(),L=-1,N=null,R.pop(),R.length>0?(_=R[R.length-1],Y===!0&&de.setGlobalState(T.clippingPlanes,_.state.camera)):_=null,E.pop(),E.length>0?y=E[E.length-1]:y=null};function il(b,O,F,k){if(b.visible===!1)return;if(b.layers.test(O.layers)){if(b.isGroup)F=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(O);else if(b.isLight)_.pushLight(b),b.castShadow&&_.pushShadow(b);else if(b.isSprite){if(!b.frustumCulled||W.intersectsSprite(b)){k&&Ee.setFromMatrixPosition(b.matrixWorld).applyMatrix4(Ce);const ee=K.update(b),pe=b.material;pe.visible&&y.push(b,ee,pe,F,Ee.z,null)}}else if((b.isMesh||b.isLine||b.isPoints)&&(!b.frustumCulled||W.intersectsObject(b))){const ee=K.update(b),pe=b.material;if(k&&(b.boundingSphere!==void 0?(b.boundingSphere===null&&b.computeBoundingSphere(),Ee.copy(b.boundingSphere.center)):(ee.boundingSphere===null&&ee.computeBoundingSphere(),Ee.copy(ee.boundingSphere.center)),Ee.applyMatrix4(b.matrixWorld).applyMatrix4(Ce)),Array.isArray(pe)){const fe=ee.groups;for(let ge=0,Ie=fe.length;ge<Ie;ge++){const Ne=fe[ge],Ue=pe[Ne.materialIndex];Ue&&Ue.visible&&y.push(b,ee,Ue,F,Ee.z,Ne)}}else pe.visible&&y.push(b,ee,pe,F,Ee.z,null)}}const U=b.children;for(let ee=0,pe=U.length;ee<pe;ee++)il(U[ee],O,F,k)}function Fh(b,O,F,k){const{opaque:U,transmissive:ee,transparent:pe}=b;_.setupLightsView(F),Y===!0&&de.setGlobalState(T.clippingPlanes,F),k&&me.viewport(z.copy(k)),U.length>0&&On(U,O,F),ee.length>0&&On(ee,O,F),pe.length>0&&On(pe,O,F),me.buffers.depth.setTest(!0),me.buffers.depth.setMask(!0),me.buffers.color.setMask(!0),me.setPolygonOffset(!1)}function kh(b,O,F,k){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[k.id]===void 0&&(_.state.transmissionRenderTarget[k.id]=new bt(1,1,{generateMipmaps:!0,type:We.has("EXT_color_buffer_half_float")||We.has("EXT_color_buffer_float")?pt:ni,minFilter:Ti,samples:4,stencilBuffer:n,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:je.workingColorSpace}));const U=_.state.transmissionRenderTarget[k.id],ee=k.viewport||z;U.setSize(ee.z*T.transmissionResolutionScale,ee.w*T.transmissionResolutionScale);const pe=T.getRenderTarget(),fe=T.getActiveCubeFace(),ge=T.getActiveMipmapLevel();T.setRenderTarget(U),T.getClearColor(q),te=T.getClearAlpha(),te<1&&T.setClearColor(16777215,.5),T.clear(),Xe&&re.render(F);const Ie=T.toneMapping;T.toneMapping=Xi;const Ne=k.viewport;if(k.viewport!==void 0&&(k.viewport=void 0),_.setupLightsView(k),Y===!0&&de.setGlobalState(T.clippingPlanes,k),On(b,F,k),De.updateMultisampleRenderTarget(U),De.updateRenderTargetMipmap(U),We.has("WEBGL_multisampled_render_to_texture")===!1){let Ue=!1;for(let Ye=0,lt=O.length;Ye<lt;Ye++){const ft=O[Ye],{object:ut,geometry:ct,material:ye,group:It}=ft;if(ye.side===Gt&&ut.layers.test(k.layers)){const Wi=ye.side;ye.side=Ft,ye.needsUpdate=!0,zh(ut,F,k,ct,ye,It),ye.side=Wi,ye.needsUpdate=!0,Ue=!0}}Ue===!0&&(De.updateMultisampleRenderTarget(U),De.updateRenderTargetMipmap(U))}T.setRenderTarget(pe,fe,ge),T.setClearColor(q,te),Ne!==void 0&&(k.viewport=Ne),T.toneMapping=Ie}function On(b,O,F){const k=O.isScene===!0?O.overrideMaterial:null;for(let U=0,ee=b.length;U<ee;U++){const pe=b[U],{object:fe,geometry:ge,group:Ie}=pe;let Ne=pe.material;Ne.allowOverride===!0&&k!==null&&(Ne=k),fe.layers.test(F.layers)&&zh(fe,O,F,ge,Ne,Ie)}}function zh(b,O,F,k,U,ee){b.onBeforeRender(T,O,F,k,U,ee),b.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),U.onBeforeRender(T,O,F,k,b,ee),U.transparent===!0&&U.side===Gt&&U.forceSinglePass===!1?(U.side=Ft,U.needsUpdate=!0,T.renderBufferDirect(F,O,k,U,b,ee),U.side=bi,U.needsUpdate=!0,T.renderBufferDirect(F,O,k,U,b,ee),U.side=Gt):T.renderBufferDirect(F,O,k,U,b,ee),b.onAfterRender(T,O,F,k,U,ee)}function Bn(b,O,F){O.isScene!==!0&&(O=Je);const k=Me.get(b),U=_.state.lights,ee=_.state.shadowsArray,pe=U.state.version,fe=V.getParameters(b,U.state,ee,O,F),ge=V.getProgramCacheKey(fe);let Ie=k.programs;k.environment=b.isMeshStandardMaterial?O.environment:null,k.fog=O.fog,k.envMap=(b.isMeshStandardMaterial?x:C).get(b.envMap||k.environment),k.envMapRotation=k.environment!==null&&b.envMap===null?O.environmentRotation:b.envMapRotation,Ie===void 0&&(b.addEventListener("dispose",Ae),Ie=new Map,k.programs=Ie);let Ne=Ie.get(ge);if(Ne!==void 0){if(k.currentProgram===Ne&&k.lightsStateVersion===pe)return Vh(b,fe),Ne}else fe.uniforms=V.getUniforms(b),b.onBeforeCompile(fe,T),Ne=V.acquireProgram(fe,ge),Ie.set(ge,Ne),k.uniforms=fe.uniforms;const Ue=k.uniforms;return(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)&&(Ue.clippingPlanes=de.uniform),Vh(b,fe),k.needsLights=g1(b),k.lightsStateVersion=pe,k.needsLights&&(Ue.ambientLightColor.value=U.state.ambient,Ue.lightProbe.value=U.state.probe,Ue.directionalLights.value=U.state.directional,Ue.directionalLightShadows.value=U.state.directionalShadow,Ue.spotLights.value=U.state.spot,Ue.spotLightShadows.value=U.state.spotShadow,Ue.rectAreaLights.value=U.state.rectArea,Ue.ltc_1.value=U.state.rectAreaLTC1,Ue.ltc_2.value=U.state.rectAreaLTC2,Ue.pointLights.value=U.state.point,Ue.pointLightShadows.value=U.state.pointShadow,Ue.hemisphereLights.value=U.state.hemi,Ue.directionalShadowMap.value=U.state.directionalShadowMap,Ue.directionalShadowMatrix.value=U.state.directionalShadowMatrix,Ue.spotShadowMap.value=U.state.spotShadowMap,Ue.spotLightMatrix.value=U.state.spotLightMatrix,Ue.spotLightMap.value=U.state.spotLightMap,Ue.pointShadowMap.value=U.state.pointShadowMap,Ue.pointShadowMatrix.value=U.state.pointShadowMatrix),k.currentProgram=Ne,k.uniformsList=null,Ne}function Hh(b){if(b.uniformsList===null){const O=b.currentProgram.getUniforms();b.uniformsList=Cn.seqWithValue(O.seq,b.uniforms)}return b.uniformsList}function Vh(b,O){const F=Me.get(b);F.outputColorSpace=O.outputColorSpace,F.batching=O.batching,F.batchingColor=O.batchingColor,F.instancing=O.instancing,F.instancingColor=O.instancingColor,F.instancingMorph=O.instancingMorph,F.skinning=O.skinning,F.morphTargets=O.morphTargets,F.morphNormals=O.morphNormals,F.morphColors=O.morphColors,F.morphTargetsCount=O.morphTargetsCount,F.numClippingPlanes=O.numClippingPlanes,F.numIntersection=O.numClipIntersection,F.vertexAlphas=O.vertexAlphas,F.vertexTangents=O.vertexTangents,F.toneMapping=O.toneMapping}function m1(b,O,F,k,U){O.isScene!==!0&&(O=Je),De.resetTextureUnits();const ee=O.fog,pe=k.isMeshStandardMaterial?O.environment:null,fe=M===null?T.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:Nt,ge=(k.isMeshStandardMaterial?x:C).get(k.envMap||pe),Ie=k.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,Ne=!!F.attributes.tangent&&(!!k.normalMap||k.anisotropy>0),Ue=!!F.morphAttributes.position,Ye=!!F.morphAttributes.normal,lt=!!F.morphAttributes.color;let ft=Xi;k.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(ft=T.toneMapping);const ut=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,ct=ut!==void 0?ut.length:0,ye=Me.get(k),It=_.state.lights;if(Y===!0&&(ue===!0||b!==N)){const Ut=b===N&&k.id===L;de.setState(k,b,Ut)}let Wi=!1;k.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==It.state.version||ye.outputColorSpace!==fe||U.isBatchedMesh&&ye.batching===!1||!U.isBatchedMesh&&ye.batching===!0||U.isBatchedMesh&&ye.batchingColor===!0&&U.colorTexture===null||U.isBatchedMesh&&ye.batchingColor===!1&&U.colorTexture!==null||U.isInstancedMesh&&ye.instancing===!1||!U.isInstancedMesh&&ye.instancing===!0||U.isSkinnedMesh&&ye.skinning===!1||!U.isSkinnedMesh&&ye.skinning===!0||U.isInstancedMesh&&ye.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&ye.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&ye.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&ye.instancingMorph===!1&&U.morphTexture!==null||ye.envMap!==ge||k.fog===!0&&ye.fog!==ee||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==de.numPlanes||ye.numIntersection!==de.numIntersection)||ye.vertexAlphas!==Ie||ye.vertexTangents!==Ne||ye.morphTargets!==Ue||ye.morphNormals!==Ye||ye.morphColors!==lt||ye.toneMapping!==ft||ye.morphTargetsCount!==ct)&&(Wi=!0):(Wi=!0,ye.__version=k.version);let xi=ye.currentProgram;Wi===!0&&(xi=Bn(k,O,U));let os=!1,Zt=!1,Os=!1;const dt=xi.getUniforms(),Xt=ye.uniforms;if(me.useProgram(xi.program)&&(os=!0,Zt=!0,Os=!0),k.id!==L&&(L=k.id,Zt=!0),os||N!==b){me.buffers.depth.getReversed()&&b.reversedDepth!==!0&&(b._reversedDepth=!0,b.updateProjectionMatrix()),dt.setValue(D,"projectionMatrix",b.projectionMatrix),dt.setValue(D,"viewMatrix",b.matrixWorldInverse);const Ut=dt.map.cameraPosition;Ut!==void 0&&Ut.setValue(D,Te.setFromMatrixPosition(b.matrixWorld)),Qe.logarithmicDepthBuffer&&dt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)&&dt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0),N!==b&&(N=b,Zt=!0,Os=!0)}if(U.isSkinnedMesh){dt.setOptional(D,U,"bindMatrix"),dt.setOptional(D,U,"bindMatrixInverse");const Ut=U.skeleton;Ut&&(Ut.boneTexture===null&&Ut.computeBoneTexture(),dt.setValue(D,"boneTexture",Ut.boneTexture,De))}U.isBatchedMesh&&(dt.setOptional(D,U,"batchingTexture"),dt.setValue(D,"batchingTexture",U._matricesTexture,De),dt.setOptional(D,U,"batchingIdTexture"),dt.setValue(D,"batchingIdTexture",U._indirectTexture,De),dt.setOptional(D,U,"batchingColorTexture"),U._colorsTexture!==null&&dt.setValue(D,"batchingColorTexture",U._colorsTexture,De));const ii=F.morphAttributes;if((ii.position!==void 0||ii.normal!==void 0||ii.color!==void 0)&&Oe.update(U,F,xi),(Zt||ye.receiveShadow!==U.receiveShadow)&&(ye.receiveShadow=U.receiveShadow,dt.setValue(D,"receiveShadow",U.receiveShadow)),k.isMeshGouraudMaterial&&k.envMap!==null&&(Xt.envMap.value=ge,Xt.flipEnvMap.value=ge.isCubeTexture&&ge.isRenderTargetTexture===!1?-1:1),k.isMeshStandardMaterial&&k.envMap===null&&O.environment!==null&&(Xt.envMapIntensity.value=O.environmentIntensity),Xt.dfgLUT!==void 0&&(Xt.dfgLUT.value=Jv()),Zt&&(dt.setValue(D,"toneMappingExposure",T.toneMappingExposure),ye.needsLights&&f1(Xt,Os),ee&&k.fog===!0&&xe.refreshFogUniforms(Xt,ee),xe.refreshMaterialUniforms(Xt,k,se,Z,_.state.transmissionRenderTarget[b.id]),Cn.upload(D,Hh(ye),Xt,De)),k.isShaderMaterial&&k.uniformsNeedUpdate===!0&&(Cn.upload(D,Hh(ye),Xt,De),k.uniformsNeedUpdate=!1),k.isSpriteMaterial&&dt.setValue(D,"center",U.center),dt.setValue(D,"modelViewMatrix",U.modelViewMatrix),dt.setValue(D,"normalMatrix",U.normalMatrix),dt.setValue(D,"modelMatrix",U.matrixWorld),k.isShaderMaterial||k.isRawShaderMaterial){const Ut=k.uniformsGroups;for(let yi=0,rl=Ut.length;yi<rl;yi++){const xr=Ut[yi];ae.update(xr,xi),ae.bind(xr,xi)}}return xi}function f1(b,O){b.ambientLightColor.needsUpdate=O,b.lightProbe.needsUpdate=O,b.directionalLights.needsUpdate=O,b.directionalLightShadows.needsUpdate=O,b.pointLights.needsUpdate=O,b.pointLightShadows.needsUpdate=O,b.spotLights.needsUpdate=O,b.spotLightShadows.needsUpdate=O,b.rectAreaLights.needsUpdate=O,b.hemisphereLights.needsUpdate=O}function g1(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(b,O,F){const k=Me.get(b);k.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,k.__autoAllocateDepthBuffer===!1&&(k.__useRenderToTexture=!1),Me.get(b.texture).__webglTexture=O,Me.get(b.depthTexture).__webglTexture=k.__autoAllocateDepthBuffer?void 0:F,k.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,O){const F=Me.get(b);F.__webglFramebuffer=O,F.__useDefaultFramebuffer=O===void 0};const v1=D.createFramebuffer();this.setRenderTarget=function(b,O=0,F=0){M=b,I=O,S=F;let k=!0,U=null,ee=!1,pe=!1;if(b){const fe=Me.get(b);if(fe.__useDefaultFramebuffer!==void 0)me.bindFramebuffer(D.FRAMEBUFFER,null),k=!1;else if(fe.__webglFramebuffer===void 0)De.setupRenderTarget(b);else if(fe.__hasExternalTextures)De.rebindTextures(b,Me.get(b.texture).__webglTexture,Me.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){const Ne=b.depthTexture;if(fe.__boundDepthTexture!==Ne){if(Ne!==null&&Me.has(Ne)&&(b.width!==Ne.image.width||b.height!==Ne.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");De.setupDepthRenderbuffer(b)}}const ge=b.texture;(ge.isData3DTexture||ge.isDataArrayTexture||ge.isCompressedArrayTexture)&&(pe=!0);const Ie=Me.get(b).__webglFramebuffer;b.isWebGLCubeRenderTarget?(Array.isArray(Ie[O])?U=Ie[O][F]:U=Ie[O],ee=!0):b.samples>0&&De.useMultisampledRTT(b)===!1?U=Me.get(b).__webglMultisampledFramebuffer:Array.isArray(Ie)?U=Ie[F]:U=Ie,z.copy(b.viewport),H.copy(b.scissor),j=b.scissorTest}else z.copy(qe).multiplyScalar(se).floor(),H.copy(Ze).multiplyScalar(se).floor(),j=$e;if(F!==0&&(U=v1),me.bindFramebuffer(D.FRAMEBUFFER,U)&&k&&me.drawBuffers(b,U),me.viewport(z),me.scissor(H),me.setScissorTest(j),ee){const fe=Me.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+O,fe.__webglTexture,F)}else if(pe){const fe=O;for(let ge=0;ge<b.textures.length;ge++){const Ie=Me.get(b.textures[ge]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+ge,Ie.__webglTexture,F,fe)}}else if(b!==null&&F!==0){const fe=Me.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,fe.__webglTexture,F)}L=-1},this.readRenderTargetPixels=function(b,O,F,k,U,ee,pe,fe=0){if(!(b&&b.isWebGLRenderTarget)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=Me.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&pe!==void 0&&(ge=ge[pe]),ge){me.bindFramebuffer(D.FRAMEBUFFER,ge);try{const Ie=b.textures[fe],Ne=Ie.format,Ue=Ie.type;if(!Qe.textureFormatReadable(Ne)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Qe.textureTypeReadable(Ue)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=b.width-k&&F>=0&&F<=b.height-U&&(b.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+fe),D.readPixels(O,F,k,U,Re.convert(Ne),Re.convert(Ue),ee))}finally{const Ie=M!==null?Me.get(M).__webglFramebuffer:null;me.bindFramebuffer(D.FRAMEBUFFER,Ie)}}},this.readRenderTargetPixelsAsync=async function(b,O,F,k,U,ee,pe,fe=0){if(!(b&&b.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ge=Me.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&pe!==void 0&&(ge=ge[pe]),ge)if(O>=0&&O<=b.width-k&&F>=0&&F<=b.height-U){me.bindFramebuffer(D.FRAMEBUFFER,ge);const Ie=b.textures[fe],Ne=Ie.format,Ue=Ie.type;if(!Qe.textureFormatReadable(Ne))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Qe.textureTypeReadable(Ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ye=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Ye),D.bufferData(D.PIXEL_PACK_BUFFER,ee.byteLength,D.STREAM_READ),b.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+fe),D.readPixels(O,F,k,U,Re.convert(Ne),Re.convert(Ue),0);const lt=M!==null?Me.get(M).__webglFramebuffer:null;me.bindFramebuffer(D.FRAMEBUFFER,lt);const ft=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await Pu(D,ft,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Ye),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ee),D.deleteBuffer(Ye),D.deleteSync(ft),ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,O=null,F=0){const k=Math.pow(2,-F),U=Math.floor(b.image.width*k),ee=Math.floor(b.image.height*k),pe=O!==null?O.x:0,fe=O!==null?O.y:0;De.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,F,0,0,pe,fe,U,ee),me.unbindTexture()};const _1=D.createFramebuffer(),x1=D.createFramebuffer();this.copyTextureToTexture=function(b,O,F=null,k=null,U=0,ee=null){ee===null&&(U!==0?(gs("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ee=U,U=0):ee=0);let pe,fe,ge,Ie,Ne,Ue,Ye,lt,ft;const ut=b.isCompressedTexture?b.mipmaps[ee]:b.image;if(F!==null)pe=F.max.x-F.min.x,fe=F.max.y-F.min.y,ge=F.isBox3?F.max.z-F.min.z:1,Ie=F.min.x,Ne=F.min.y,Ue=F.isBox3?F.min.z:0;else{const ii=Math.pow(2,-U);pe=Math.floor(ut.width*ii),fe=Math.floor(ut.height*ii),b.isDataArrayTexture?ge=ut.depth:b.isData3DTexture?ge=Math.floor(ut.depth*ii):ge=1,Ie=0,Ne=0,Ue=0}k!==null?(Ye=k.x,lt=k.y,ft=k.z):(Ye=0,lt=0,ft=0);const ct=Re.convert(O.format),ye=Re.convert(O.type);let It;O.isData3DTexture?(De.setTexture3D(O,0),It=D.TEXTURE_3D):O.isDataArrayTexture||O.isCompressedArrayTexture?(De.setTexture2DArray(O,0),It=D.TEXTURE_2D_ARRAY):(De.setTexture2D(O,0),It=D.TEXTURE_2D),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,O.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,O.unpackAlignment);const Wi=D.getParameter(D.UNPACK_ROW_LENGTH),xi=D.getParameter(D.UNPACK_IMAGE_HEIGHT),os=D.getParameter(D.UNPACK_SKIP_PIXELS),Zt=D.getParameter(D.UNPACK_SKIP_ROWS),Os=D.getParameter(D.UNPACK_SKIP_IMAGES);D.pixelStorei(D.UNPACK_ROW_LENGTH,ut.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,ut.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,Ie),D.pixelStorei(D.UNPACK_SKIP_ROWS,Ne),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Ue);const dt=b.isDataArrayTexture||b.isData3DTexture,Xt=O.isDataArrayTexture||O.isData3DTexture;if(b.isDepthTexture){const ii=Me.get(b),Ut=Me.get(O),yi=Me.get(ii.__renderTarget),rl=Me.get(Ut.__renderTarget);me.bindFramebuffer(D.READ_FRAMEBUFFER,yi.__webglFramebuffer),me.bindFramebuffer(D.DRAW_FRAMEBUFFER,rl.__webglFramebuffer);for(let xr=0;xr<ge;xr++)dt&&(D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Me.get(b).__webglTexture,U,Ue+xr),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Me.get(O).__webglTexture,ee,ft+xr)),D.blitFramebuffer(Ie,Ne,pe,fe,Ye,lt,pe,fe,D.DEPTH_BUFFER_BIT,D.NEAREST);me.bindFramebuffer(D.READ_FRAMEBUFFER,null),me.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(U!==0||b.isRenderTargetTexture||Me.has(b)){const ii=Me.get(b),Ut=Me.get(O);me.bindFramebuffer(D.READ_FRAMEBUFFER,_1),me.bindFramebuffer(D.DRAW_FRAMEBUFFER,x1);for(let yi=0;yi<ge;yi++)dt?D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,ii.__webglTexture,U,Ue+yi):D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,ii.__webglTexture,U),Xt?D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ut.__webglTexture,ee,ft+yi):D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ut.__webglTexture,ee),U!==0?D.blitFramebuffer(Ie,Ne,pe,fe,Ye,lt,pe,fe,D.COLOR_BUFFER_BIT,D.NEAREST):Xt?D.copyTexSubImage3D(It,ee,Ye,lt,ft+yi,Ie,Ne,pe,fe):D.copyTexSubImage2D(It,ee,Ye,lt,Ie,Ne,pe,fe);me.bindFramebuffer(D.READ_FRAMEBUFFER,null),me.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else Xt?b.isDataTexture||b.isData3DTexture?D.texSubImage3D(It,ee,Ye,lt,ft,pe,fe,ge,ct,ye,ut.data):O.isCompressedArrayTexture?D.compressedTexSubImage3D(It,ee,Ye,lt,ft,pe,fe,ge,ct,ut.data):D.texSubImage3D(It,ee,Ye,lt,ft,pe,fe,ge,ct,ye,ut):b.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,ee,Ye,lt,pe,fe,ct,ye,ut.data):b.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,ee,Ye,lt,ut.width,ut.height,ct,ut.data):D.texSubImage2D(D.TEXTURE_2D,ee,Ye,lt,pe,fe,ct,ye,ut);D.pixelStorei(D.UNPACK_ROW_LENGTH,Wi),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,xi),D.pixelStorei(D.UNPACK_SKIP_PIXELS,os),D.pixelStorei(D.UNPACK_SKIP_ROWS,Zt),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Os),ee===0&&O.generateMipmaps&&D.generateMipmap(It),me.unbindTexture()},this.initRenderTarget=function(b){Me.get(b).__webglFramebuffer===void 0&&De.setupRenderTarget(b)},this.initTexture=function(b){b.isCubeTexture?De.setTextureCube(b,0):b.isData3DTexture?De.setTexture3D(b,0):b.isDataArrayTexture||b.isCompressedArrayTexture?De.setTexture2DArray(b,0):De.setTexture2D(b,0),me.unbindTexture()},this.resetState=function(){I=0,S=0,M=null,me.reset(),P.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Si}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}class Qv extends qd{constructor(e){super(e),this.type=pt}parse(e){const t=function(f,p){switch(f){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(p||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(p||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(p||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(p||""))}},i=function(f,p,y){p=p||1024;let _=f.pos,E=-1,R=0,T="",A=String.fromCharCode.apply(null,new Uint16Array(f.subarray(_,_+128)));for(;0>(E=A.indexOf(`
|
||
`))&&R<p&&_<f.byteLength;)T+=A,R+=A.length,_+=128,A+=String.fromCharCode.apply(null,new Uint16Array(f.subarray(_,_+128)));return-1<E?(f.pos+=R+E+1,T+A.slice(0,E)):!1},r=function(f){const p=/^#\?(\S+)/,y=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,E=/^\s*FORMAT=(\S+)\s*$/,R=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,T={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let A,I;for((f.pos>=f.byteLength||!(A=i(f)))&&t(1,"no header found"),(I=A.match(p))||t(3,"bad initial token"),T.valid|=1,T.programtype=I[1],T.string+=A+`
|
||
`;A=i(f),A!==!1;){if(T.string+=A+`
|
||
`,A.charAt(0)==="#"){T.comments+=A+`
|
||
`;continue}if((I=A.match(y))&&(T.gamma=parseFloat(I[1])),(I=A.match(_))&&(T.exposure=parseFloat(I[1])),(I=A.match(E))&&(T.valid|=2,T.format=I[1]),(I=A.match(R))&&(T.valid|=4,T.height=parseInt(I[1],10),T.width=parseInt(I[2],10)),T.valid&2&&T.valid&4)break}return T.valid&2||t(3,"missing format specifier"),T.valid&4||t(3,"missing image size specifier"),T},n=function(f,p,y){const _=p;if(_<8||_>32767||f[0]!==2||f[1]!==2||f[2]&128)return new Uint8Array(f);_!==(f[2]<<8|f[3])&&t(3,"wrong scanline width");const E=new Uint8Array(4*p*y);E.length||t(4,"unable to allocate buffer space");let R=0,T=0;const A=4*_,I=new Uint8Array(4),S=new Uint8Array(A);let M=y;for(;M>0&&T<f.byteLength;){T+4>f.byteLength&&t(1),I[0]=f[T++],I[1]=f[T++],I[2]=f[T++],I[3]=f[T++],(I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=_)&&t(3,"bad rgbe scanline format");let L=0,N;for(;L<A&&T<f.byteLength;){N=f[T++];const H=N>128;if(H&&(N-=128),(N===0||L+N>A)&&t(3,"bad scanline data"),H){const j=f[T++];for(let q=0;q<N;q++)S[L++]=j}else S.set(f.subarray(T,T+N),L),L+=N,T+=N}const z=_;for(let H=0;H<z;H++){let j=0;E[R]=S[H+j],j+=_,E[R+1]=S[H+j],j+=_,E[R+2]=S[H+j],j+=_,E[R+3]=S[H+j],R+=4}M--}return E},a=function(f,p,y,_){const E=f[p+3],R=Math.pow(2,E-128)/255;y[_+0]=f[p+0]*R,y[_+1]=f[p+1]*R,y[_+2]=f[p+2]*R,y[_+3]=1},o=function(f,p,y,_){const E=f[p+3],R=Math.pow(2,E-128)/255;y[_+0]=nn.toHalfFloat(Math.min(f[p+0]*R,65504)),y[_+1]=nn.toHalfFloat(Math.min(f[p+1]*R,65504)),y[_+2]=nn.toHalfFloat(Math.min(f[p+2]*R,65504)),y[_+3]=nn.toHalfFloat(1)},l=new Uint8Array(e);l.pos=0;const c=r(l),h=c.width,u=c.height,d=n(l.subarray(l.pos),h,u);let m,g,v;switch(this.type){case Wt:v=d.length/4;const f=new Float32Array(v*4);for(let y=0;y<v;y++)a(d,y*4,f,y*4);m=f,g=Wt;break;case pt:v=d.length/4;const p=new Uint16Array(v*4);for(let y=0;y<v;y++)o(d,y*4,p,y*4);m=p,g=pt;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:u,data:m,header:c.string,gamma:c.gamma,exposure:c.exposure,type:g}}setDataType(e){return this.type=e,this}load(e,t,i,r){function n(a,o){switch(a.type){case Wt:case pt:a.colorSpace=Nt,a.minFilter=yt,a.magFilter=yt,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,o)}return super.load(e,n,i,r)}}class e0 extends Qv{constructor(e){console.warn("RGBELoader has been deprecated. Please use HDRLoader instead."),super(e)}}const ir={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 rr{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 t0=new pr(-1,1,1,-1,0,1);class i0 extends ei{constructor(){super(),this.setAttribute("position",new mi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new mi([0,2,0,0,2,0],2))}}const r0=new i0;class Is{constructor(e){this._mesh=new rt(r0,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,t0)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Ho extends rr{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof ot?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=fi.clone(e.uniforms),this.material=new ot({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 Is(this.material)}render(e,t,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class mh extends rr{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,i){const r=e.getContext(),n=e.state;n.buffers.color.setMask(!1),n.buffers.depth.setMask(!1),n.buffers.color.setLocked(!0),n.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),n.buffers.stencil.setTest(!0),n.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),n.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),n.buffers.stencil.setClear(o),n.buffers.stencil.setLocked(!0),e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),n.buffers.color.setLocked(!1),n.buffers.depth.setLocked(!1),n.buffers.color.setMask(!0),n.buffers.depth.setMask(!0),n.buffers.stencil.setLocked(!1),n.buffers.stencil.setFunc(r.EQUAL,1,4294967295),n.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),n.buffers.stencil.setLocked(!0)}}class s0 extends rr{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class n0{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const i=e.getSize(new oe);this._width=i.width,this._height=i.height,t=new bt(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:pt}),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 Ho(ir),this.copyPass.material.blending=xt,this.clock=new tp}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 i=!1;for(let r=0,n=this.passes.length;r<n;r++){const a=this.passes[r];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),a.needsSwap){if(i){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}mh!==void 0&&(a instanceof mh?i=!0:a instanceof s0&&(i=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new oe);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const i=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(i,r),this.renderTarget2.setSize(i,r);for(let n=0;n<this.passes.length;n++)this.passes[n].setSize(i,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class a0 extends rr{constructor(e,t,i=null,r=null,n=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=i,this.clearColor=r,this.clearAlpha=n,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new _e}render(e,t,i){const r=e.autoClear;e.autoClear=!1;let n,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&&(n=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:i),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(n),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}}const Pn={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 oe},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new Le},cameraProjectionMatrixInverse:{value:new Le},cameraWorldMatrix:{value:new Le},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new w(-1,-1,-1)},sceneBoxMax:{value:new w(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;
|
||
}`},Ln={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 );
|
||
|
||
}`},Vo={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 o0(s=5){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=l0(e),i=t.length,r=new Uint8Array(i*4);for(let a=0;a<i;++a){const o=t[a],l=2*Math.PI*o/i,c=new w(Math.cos(l),Math.sin(l),0).normalize();r[a*4]=(c.x*.5+.5)*255,r[a*4+1]=(c.y*.5+.5)*255,r[a*4+2]=127,r[a*4+3]=255}const n=new Xr(r,e,e);return n.wrapS=Mi,n.wrapT=Mi,n.needsUpdate=!0,n}function l0(s){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=e*e,i=Array(t).fill(0);let r=Math.floor(e/2),n=e-1;for(let a=1;a<=t;){if(r===-1&&n===e?(n=e-2,r=0):(n===e&&(n=0),r<0&&(r=e-1)),i[r*e+n]!==0){n-=2,r++;continue}else i[r*e+n]=a++;n++,r--}return i}const Dn={defines:{SAMPLES:16,SAMPLE_VECTORS:fh(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 oe},cameraProjectionMatrixInverse:{value:new Le},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 fh(s,e,t){const i=c0(s,e,t);let r="vec3[SAMPLES](";for(let n=0;n<s;n++){const a=i[n];r+=`vec3(${a.x}, ${a.y}, ${a.z})${n<s-1?",":")"}`}return r}function c0(s,e,t){const i=[];for(let r=0;r<s;r++){const n=2*Math.PI*e*r/s,a=Math.pow(r/(s-1),t);i.push(new w(Math.cos(n),Math.sin(n),a))}return i}class h0{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[t&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let i,r,n;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,u=(l+c)*h,d=l-u,m=c-u,g=e-d,v=t-m;let f,p;g>v?(f=1,p=0):(f=0,p=1);const y=g-f+h,_=v-p+h,E=g-1+2*h,R=v-1+2*h,T=l&255,A=c&255,I=this.perm[T+this.perm[A]]%12,S=this.perm[T+f+this.perm[A+p]]%12,M=this.perm[T+1+this.perm[A+1]]%12;let L=.5-g*g-v*v;L<0?i=0:(L*=L,i=L*L*this._dot(this.grad3[I],g,v));let N=.5-y*y-_*_;N<0?r=0:(N*=N,r=N*N*this._dot(this.grad3[S],y,_));let z=.5-E*E-R*R;return z<0?n=0:(z*=z,n=z*z*this._dot(this.grad3[M],E,R)),70*(i+r+n)}noise3d(e,t,i){let r,n,a,o;const l=(e+t+i)*.3333333333333333,c=Math.floor(e+l),h=Math.floor(t+l),u=Math.floor(i+l),d=1/6,m=(c+h+u)*d,g=c-m,v=h-m,f=u-m,p=e-g,y=t-v,_=i-f;let E,R,T,A,I,S;p>=y?y>=_?(E=1,R=0,T=0,A=1,I=1,S=0):p>=_?(E=1,R=0,T=0,A=1,I=0,S=1):(E=0,R=0,T=1,A=1,I=0,S=1):y<_?(E=0,R=0,T=1,A=0,I=1,S=1):p<_?(E=0,R=1,T=0,A=0,I=1,S=1):(E=0,R=1,T=0,A=1,I=1,S=0);const M=p-E+d,L=y-R+d,N=_-T+d,z=p-A+2*d,H=y-I+2*d,j=_-S+2*d,q=p-1+3*d,te=y-1+3*d,G=_-1+3*d,Z=c&255,se=h&255,Pe=u&255,ze=this.perm[Z+this.perm[se+this.perm[Pe]]]%12,qe=this.perm[Z+E+this.perm[se+R+this.perm[Pe+T]]]%12,Ze=this.perm[Z+A+this.perm[se+I+this.perm[Pe+S]]]%12,$e=this.perm[Z+1+this.perm[se+1+this.perm[Pe+1]]]%12;let W=.6-p*p-y*y-_*_;W<0?r=0:(W*=W,r=W*W*this._dot3(this.grad3[ze],p,y,_));let Y=.6-M*M-L*L-N*N;Y<0?n=0:(Y*=Y,n=Y*Y*this._dot3(this.grad3[qe],M,L,N));let ue=.6-z*z-H*H-j*j;ue<0?a=0:(ue*=ue,a=ue*ue*this._dot3(this.grad3[Ze],z,H,j));let Ce=.6-q*q-te*te-G*G;return Ce<0?o=0:(Ce*=Ce,o=Ce*Ce*this._dot3(this.grad3[$e],q,te,G)),32*(r+n+a+o)}noise4d(e,t,i,r){const n=this.grad4,a=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,u,d,m,g;const v=(e+t+i+r)*l,f=Math.floor(e+v),p=Math.floor(t+v),y=Math.floor(i+v),_=Math.floor(r+v),E=(f+p+y+_)*c,R=f-E,T=p-E,A=y-E,I=_-E,S=e-R,M=t-T,L=i-A,N=r-I,z=S>M?32:0,H=S>L?16:0,j=M>L?8:0,q=S>N?4:0,te=M>N?2:0,G=L>N?1:0,Z=z+H+j+q+te+G,se=a[Z][0]>=3?1:0,Pe=a[Z][1]>=3?1:0,ze=a[Z][2]>=3?1:0,qe=a[Z][3]>=3?1:0,Ze=a[Z][0]>=2?1:0,$e=a[Z][1]>=2?1:0,W=a[Z][2]>=2?1:0,Y=a[Z][3]>=2?1:0,ue=a[Z][0]>=1?1:0,Ce=a[Z][1]>=1?1:0,Te=a[Z][2]>=1?1:0,Ee=a[Z][3]>=1?1:0,Je=S-se+c,Xe=M-Pe+c,Ge=L-ze+c,D=N-qe+c,_t=S-Ze+2*c,We=M-$e+2*c,Qe=L-W+2*c,me=N-Y+2*c,at=S-ue+3*c,Me=M-Ce+3*c,De=L-Te+3*c,C=N-Ee+3*c,x=S-1+4*c,B=M-1+4*c,X=L-1+4*c,K=N-1+4*c,V=f&255,xe=p&255,ne=y&255,Se=_&255,de=o[V+o[xe+o[ne+o[Se]]]]%32,J=o[V+se+o[xe+Pe+o[ne+ze+o[Se+qe]]]]%32,re=o[V+Ze+o[xe+$e+o[ne+W+o[Se+Y]]]]%32,Oe=o[V+ue+o[xe+Ce+o[ne+Te+o[Se+Ee]]]]%32,we=o[V+1+o[xe+1+o[ne+1+o[Se+1]]]]%32;let he=.6-S*S-M*M-L*L-N*N;he<0?h=0:(he*=he,h=he*he*this._dot4(n[de],S,M,L,N));let Re=.6-Je*Je-Xe*Xe-Ge*Ge-D*D;Re<0?u=0:(Re*=Re,u=Re*Re*this._dot4(n[J],Je,Xe,Ge,D));let P=.6-_t*_t-We*We-Qe*Qe-me*me;P<0?d=0:(P*=P,d=P*P*this._dot4(n[re],_t,We,Qe,me));let ae=.6-at*at-Me*Me-De*De-C*C;ae<0?m=0:(ae*=ae,m=ae*ae*this._dot4(n[Oe],at,Me,De,C));let ie=.6-x*x-B*B-X*X-K*K;return ie<0?g=0:(ie*=ie,g=ie*ie*this._dot4(n[we],x,B,X,K)),27*(h+u+d+m+g)}_dot(e,t,i){return e[0]*t+e[1]*i}_dot3(e,t,i,r){return e[0]*t+e[1]*i+e[2]*r}_dot4(e,t,i,r,n){return e[0]*t+e[1]*i+e[2]*r+e[3]*n}}class vi extends rr{constructor(e,t,i=512,r=512,n,a,o){super(),this.width=i,this.height=r,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=o0(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new bt(this.width,this.height,{type:pt}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new ot({defines:Object.assign({},Pn.defines),uniforms:fi.clone(Pn.uniforms),vertexShader:Pn.vertexShader,fragmentShader:Pn.fragmentShader,blending:xt,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 Dd,this.normalMaterial.blending=xt,this.pdMaterial=new ot({defines:Object.assign({},Dn.defines),uniforms:fi.clone(Dn.uniforms),vertexShader:Dn.vertexShader,fragmentShader:Dn.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 ot({defines:Object.assign({},Ln.defines),uniforms:fi.clone(Ln.uniforms),vertexShader:Ln.vertexShader,fragmentShader:Ln.fragmentShader,blending:xt}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new ot({uniforms:fi.clone(ir.uniforms),vertexShader:ir.vertexShader,fragmentShader:ir.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Vn,blendDst:cs,blendEquation:si,blendSrcAlpha:Hn,blendDstAlpha:cs,blendEquationAlpha:si}),this.blendMaterial=new ot({uniforms:fi.clone(Vo.uniforms),vertexShader:Vo.vertexShader,fragmentShader:Vo.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:ul,blendSrc:Vn,blendDst:cs,blendEquation:si,blendSrcAlpha:Hn,blendDstAlpha:cs,blendEquationAlpha:si}),this._fsQuad=new Is(null),this._originalClearColor=new _e,this.setGBuffer(n?n.depthTexture:void 0,n?n.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 Eo,this.depthTexture.format=Rr,this.depthTexture.type=Cr,this.normalRenderTarget=new bt(this.width,this.height,{minFilter:Dt,magFilter:Dt,type:pt,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const i=this.normalTexture?1:0,r=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=i,this.gtaoMaterial.defines.DEPTH_SWIZZLING=r,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=i,this.pdMaterial.defines.DEPTH_SWIZZLING=r,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=fh(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,i){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case vi.OUTPUT.Off:break;case vi.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case vi.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case vi.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case vi.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 vi.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case vi.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,i,r,n){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,r!=null&&(e.setClearColor(r),e.setClearAlpha(n||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,i,r,n){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,r=t.clearColor||r,n=t.clearAlpha||n,r!=null&&(e.setClearColor(r),e.setClearAlpha(n||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(i){(i.isPoints||i.isLine||i.isLine2)&&i.visible&&(i.visible=!1,t.push(i))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){const t=new h0,i=e*e*4,r=new Uint8Array(i);for(let a=0;a<e;a++)for(let o=0;o<e;o++){const l=a,c=o;r[(a*e+o)*4]=(t.noise(l,c)*.5+.5)*255,r[(a*e+o)*4+1]=(t.noise(l+e,c)*.5+.5)*255,r[(a*e+o)*4+2]=(t.noise(l,c+e)*.5+.5)*255,r[(a*e+o)*4+3]=(t.noise(l+e,c+e)*.5+.5)*255}const n=new Xr(r,e,e,qt,ni);return n.wrapS=Mi,n.wrapT=Mi,n.needsUpdate=!0,n}}vi.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const u0={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new _e(0)},defaultOpacity:{value:0}},vertexShader:`
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vUv = uv;
|
||
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
||
}`,fragmentShader:`
|
||
|
||
uniform sampler2D tDiffuse;
|
||
uniform vec3 defaultColor;
|
||
uniform float defaultOpacity;
|
||
uniform float luminosityThreshold;
|
||
uniform float smoothWidth;
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vec4 texel = texture2D( tDiffuse, vUv );
|
||
|
||
float v = luminance( texel.xyz );
|
||
|
||
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
|
||
|
||
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
|
||
|
||
gl_FragColor = mix( outputColor, texel, alpha );
|
||
|
||
}`};class is extends rr{constructor(e,t=1,i,r){super(),this.strength=t,this.radius=i,this.threshold=r,this.resolution=e!==void 0?new oe(e.x,e.y):new oe(256,256),this.clearColor=new _e(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let n=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new bt(n,a,{type:pt}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let h=0;h<this.nMips;h++){const u=new bt(n,a,{type:pt});u.texture.name="UnrealBloomPass.h"+h,u.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(u);const d=new bt(n,a,{type:pt});d.texture.name="UnrealBloomPass.v"+h,d.texture.generateMipmaps=!1,this.renderTargetsVertical.push(d),n=Math.round(n/2),a=Math.round(a/2)}const o=u0;this.highPassUniforms=fi.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new ot({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];const l=[6,10,14,18,22];n=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let h=0;h<this.nMips;h++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(l[h])),this.separableBlurMaterials[h].uniforms.invSize.value=new oe(1/n,1/a),n=Math.round(n/2),a=Math.round(a/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;const c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new w(1,1,1),new w(1,1,1),new w(1,1,1),new w(1,1,1),new w(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=fi.clone(ir.uniforms),this.blendMaterial=new ot({uniforms:this.copyUniforms,vertexShader:ir.vertexShader,fragmentShader:ir.fragmentShader,blending:Bs,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new _e,this._oldClearAlpha=1,this._basic=new kt,this._fsQuad=new Is(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let i=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(i,r);for(let n=0;n<this.nMips;n++)this.renderTargetsHorizontal[n].setSize(i,r),this.renderTargetsVertical[n].setSize(i,r),this.separableBlurMaterials[n].uniforms.invSize.value=new oe(1/i,1/r),i=Math.round(i/2),r=Math.round(r/2)}render(e,t,i,r,n){e.getClearColor(this._oldClearColor),this._oldClearAlpha=e.getClearAlpha();const a=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),n&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=i.texture,e.setRenderTarget(null),e.clear(),this._fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=i.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this._fsQuad.render(e);let o=this.renderTargetBright;for(let l=0;l<this.nMips;l++)this._fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=o.texture,this.separableBlurMaterials[l].uniforms.direction.value=is.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[l]),e.clear(),this._fsQuad.render(e),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=is.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[l]),e.clear(),this._fsQuad.render(e),o=this.renderTargetsVertical[l];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,n&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(i),this._fsQuad.render(e)),e.setClearColor(this._oldClearColor,this._oldClearAlpha),e.autoClear=a}_getSeparableBlurMaterial(e){const t=[],i=e/3;for(let r=0;r<e;r++)t.push(.39894*Math.exp(-.5*r*r/(i*i))/i);return new ot({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new oe(.5,.5)},direction:{value:new oe(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`#include <common>
|
||
varying vec2 vUv;
|
||
uniform sampler2D colorTexture;
|
||
uniform vec2 invSize;
|
||
uniform vec2 direction;
|
||
uniform float gaussianCoefficients[KERNEL_RADIUS];
|
||
|
||
void main() {
|
||
float weightSum = gaussianCoefficients[0];
|
||
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
|
||
for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
|
||
float x = float(i);
|
||
float w = gaussianCoefficients[i];
|
||
vec2 uvOffset = direction * invSize * x;
|
||
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
|
||
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
|
||
diffuseSum += ( sample1 + sample2 ) * w;
|
||
}
|
||
gl_FragColor = vec4( diffuseSum, 1.0 );
|
||
}`})}_getCompositeMaterial(e){return new ot({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`varying vec2 vUv;
|
||
uniform sampler2D blurTexture1;
|
||
uniform sampler2D blurTexture2;
|
||
uniform sampler2D blurTexture3;
|
||
uniform sampler2D blurTexture4;
|
||
uniform sampler2D blurTexture5;
|
||
uniform float bloomStrength;
|
||
uniform float bloomRadius;
|
||
uniform float bloomFactors[NUM_MIPS];
|
||
uniform vec3 bloomTintColors[NUM_MIPS];
|
||
|
||
float lerpBloomFactor(const in float factor) {
|
||
float mirrorFactor = 1.2 - factor;
|
||
return mix(factor, mirrorFactor, bloomRadius);
|
||
}
|
||
|
||
void main() {
|
||
gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
|
||
lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
|
||
lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
|
||
lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
|
||
lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
|
||
}`})}}is.BlurDirectionX=new oe(1,0),is.BlurDirectionY=new oe(0,1);const In={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 d0 extends rr{constructor(){super(),this.uniforms=fi.clone(In.uniforms),this.material=new Ld({name:In.name,uniforms:this.uniforms,vertexShader:In.vertexShader,fragmentShader:In.fragmentShader}),this._fsQuad=new Is(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,i){this.uniforms.tDiffuse.value=i.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},je.getTransfer(this._outputColorSpace)===et&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===dl?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===pl?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===ml?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===$n?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===gl?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===vl?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===fl&&(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 p0={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new oe(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 );
|
||
|
||
}`};function m0(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Go={exports:{}},f0=Go.exports,gh;function g0(){return gh||(gh=1,(function(s,e){(function(t,i){s.exports=i()})(f0,function(){var t=function(){function i(m){return a.appendChild(m.dom),m}function r(m){for(var g=0;g<a.children.length;g++)a.children[g].style.display=g===m?"block":"none";n=m}var n=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(m){m.preventDefault(),r(++n%a.children.length)},!1);var o=(performance||Date).now(),l=o,c=0,h=i(new t.Panel("FPS","#0ff","#002")),u=i(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=i(new t.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:a,addPanel:i,showPanel:r,begin:function(){o=(performance||Date).now()},end:function(){c++;var m=(performance||Date).now();if(u.update(m-o,200),m>l+1e3&&(h.update(1e3*c/(m-l),100),l=m,c=0,d)){var g=performance.memory;d.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return m},update:function(){o=this.end()},domElement:a,setMode:r}};return t.Panel=function(i,r,n){var a=1/0,o=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,u=48*c,d=3*c,m=2*c,g=3*c,v=15*c,f=74*c,p=30*c,y=document.createElement("canvas");y.width=h,y.height=u,y.style.cssText="width:80px;height:48px";var _=y.getContext("2d");return _.font="bold "+9*c+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=n,_.fillRect(0,0,h,u),_.fillStyle=r,_.fillText(i,d,m),_.fillRect(g,v,f,p),_.fillStyle=n,_.globalAlpha=.9,_.fillRect(g,v,f,p),{dom:y,update:function(E,R){a=Math.min(a,E),o=Math.max(o,E),_.fillStyle=n,_.globalAlpha=1,_.fillRect(0,0,h,v),_.fillStyle=r,_.fillText(l(E)+" "+i+" ("+l(a)+"-"+l(o)+")",d,m),_.drawImage(y,g+c,v,f-c,p,g,v,f-c,p),_.fillRect(g+f-c,v,c,p),_.fillStyle=n,_.globalAlpha=.9,_.fillRect(g+f-c,v,c,l((1-E/R)*p))}}},t})})(Go)),Go.exports}var v0=g0();const _0=m0(v0);class x0{scene;constructor(e){this.scene=new mo,this.setupEnvironment(e.backgroundColor),this.setupLights()}setupEnvironment(e=15790320){this.scene.background=new _e(e)}setupLights(){}setBackground(e){this.scene.background=new _e(e)}getBoundingBox(){const e=new At;return this.scene.traverse(t=>{if(t instanceof rt||t instanceof zi){const i=new At().setFromObject(t);e.union(i)}}),e.isEmpty()&&e.setFromCenterAndSize(new w(0,0,0),new w(10,10,10)),e}}const vh={type:"change"},Wo={type:"start"},_h={type:"end"},Un=new Or,xh=new wi,y0=Math.cos(70*Va.DEG2RAD),wt=new w,jt=2*Math.PI,st={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},jo=1e-6;class yh extends up{constructor(e,t=null){super(e,t),this.state=st.NONE,this.target=new w,this.cursor=new w,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:br.ROTATE,MIDDLE:br.DOLLY,RIGHT:br.PAN},this.touches={ONE:Mr.ROTATE,TWO:Mr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new w,this._lastQuaternion=new li,this._lastTargetPosition=new w,this._quat=new li().setFromUnitVectors(e.up,new w(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Fc,this._sphericalDelta=new Fc,this._scale=1,this._panOffset=new w,this._rotateStart=new oe,this._rotateEnd=new oe,this._rotateDelta=new oe,this._panStart=new oe,this._panEnd=new oe,this._panDelta=new oe,this._dollyStart=new oe,this._dollyEnd=new oe,this._dollyDelta=new oe,this._dollyDirection=new w,this._mouse=new oe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=M0.bind(this),this._onPointerDown=b0.bind(this),this._onPointerUp=T0.bind(this),this._onContextMenu=P0.bind(this),this._onMouseWheel=w0.bind(this),this._onKeyDown=C0.bind(this),this._onTouchStart=R0.bind(this),this._onTouchMove=A0.bind(this),this._onMouseDown=S0.bind(this),this._onMouseMove=E0.bind(this),this._interceptControlDown=L0.bind(this),this._interceptControlUp=D0.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(vh),this.update(),this.state=st.NONE}update(e=null){const t=this.object.position;wt.copy(t).sub(this.target),wt.applyQuaternion(this._quat),this._spherical.setFromVector3(wt),this.autoRotate&&this.state===st.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(i)&&isFinite(r)&&(i<-Math.PI?i+=jt:i>Math.PI&&(i-=jt),r<-Math.PI?r+=jt:r>Math.PI&&(r-=jt),i<=r?this._spherical.theta=Math.max(i,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+r)/2?Math.max(i,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let n=!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),n=a!=this._spherical.radius}if(wt.setFromSpherical(this._spherical),wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(wt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=wt.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),n=!!l}else if(this.object.isOrthographicCamera){const o=new w(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(),n=l!==this.object.zoom;const c=new w(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=wt.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):(Un.origin.copy(this.object.position),Un.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Un.direction))<y0?this.object.lookAt(this.target):(xh.setFromNormalAndCoplanarPoint(this.object.up,this.target),Un.intersectPlane(xh,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(),n=!0)}return this._scale=1,this._performCursorZoom=!1,n||this._lastPosition.distanceToSquared(this.object.position)>jo||8*(1-this._lastQuaternion.dot(this.object.quaternion))>jo||this._lastTargetPosition.distanceToSquared(this.target)>jo?(this.dispatchEvent(vh),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?jt/60*this.autoRotateSpeed*e:jt/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){wt.setFromMatrixColumn(t,0),wt.multiplyScalar(-e),this._panOffset.add(wt)}_panUp(e,t){this.screenSpacePanning===!0?wt.setFromMatrixColumn(t,1):(wt.setFromMatrixColumn(t,0),wt.crossVectors(this.object.up,wt)),wt.multiplyScalar(e),this._panOffset.add(wt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;wt.copy(r).sub(this.target);let n=wt.length();n*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*n/i.clientHeight,this.object.matrix),this._panUp(2*t*n/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),r=e-i.left,n=t-i.top,a=i.width,o=i.height;this._mouse.x=r/a*2-1,this._mouse.y=-(n/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(jt*this._rotateDelta.x/t.clientHeight),this._rotateUp(jt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(jt*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(-jt*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(jt*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(-jt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(i,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(i,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,n=Math.sqrt(i*i+r*r);this._dollyStart.set(0,n)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),r=.5*(e.pageX+i.x),n=.5*(e.pageY+i.y);this._rotateEnd.set(r,n)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(jt*this._rotateDelta.x/t.clientHeight),this._rotateUp(jt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(i,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,n=Math.sqrt(i*i+r*r);this._dollyEnd.set(0,n),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const 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 oe,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function b0(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 M0(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function T0(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(_h),this.state=st.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 S0(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case br.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=st.DOLLY;break;case br.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=st.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=st.ROTATE}break;case br.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=st.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=st.PAN}break;default:this.state=st.NONE}this.state!==st.NONE&&this.dispatchEvent(Wo)}function E0(s){switch(this.state){case st.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case st.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case st.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function w0(s){this.enabled===!1||this.enableZoom===!1||this.state!==st.NONE||(s.preventDefault(),this.dispatchEvent(Wo),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(_h))}function C0(s){this.enabled!==!1&&this._handleKeyDown(s)}function R0(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case Mr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=st.TOUCH_ROTATE;break;case Mr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=st.TOUCH_PAN;break;default:this.state=st.NONE}break;case 2:switch(this.touches.TWO){case Mr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=st.TOUCH_DOLLY_PAN;break;case Mr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=st.TOUCH_DOLLY_ROTATE;break;default:this.state=st.NONE}break;default:this.state=st.NONE}this.state!==st.NONE&&this.dispatchEvent(Wo)}function A0(s){switch(this._trackPointer(s),this.state){case st.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case st.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case st.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case st.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=st.NONE}}function P0(s){this.enabled!==!1&&s.preventDefault()}function L0(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function D0(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var rs=(s=>(s.Top="top",s.Bottom="bottom",s.Left="left",s.Right="right",s.Front="front",s.Back="back",s.Iso="iso",s))(rs||{}),ss=(s=>(s.Perspective="perspective",s.Orthographic="orthographic",s))(ss||{}),Nn=(s=>(s.Orbit="orbit",s.FirstPerson="walk",s.PanOnly="pan_only",s))(Nn||{});class I0{camera;controls;engineState;constructor(e,t,i,r){this.engineState=r,this.camera=new Tt(45,t/i,.1,1e4),this.camera.position.set(20,20,20),this.controls=new yh(this.camera,e,this.engineState),this.controls.enableDamping=!0,this.controls.dampingFactor=.05}updateAspect(e,t){this.camera.aspect=e/t,this.camera.updateProjectionMatrix()}tick(){this.controls.update()}setView(e){const t=this.camera.position.length();switch(e){case rs.Top:case"top":this.camera.position.set(0,t,0);break;case rs.Front:case"front":this.camera.position.set(0,0,t);break;case rs.Iso:case"iso":this.camera.position.set(t/Math.sqrt(3),t/Math.sqrt(3),t/Math.sqrt(3));break}this.camera.lookAt(0,0,0),this.controls.update()}}function bh(s,e){if(e===_u)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===Oa||e===Pl){let t=s.getIndex();if(t===null){const a=[],o=s.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);s.setIndex(a),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const i=t.count-2,r=[];if(e===Oa)for(let a=1;a<=i;a++)r.push(t.getX(0)),r.push(t.getX(a)),r.push(t.getX(a+1));else for(let a=0;a<i;a++)a%2===0?(r.push(t.getX(a)),r.push(t.getX(a+1)),r.push(t.getX(a+2))):(r.push(t.getX(a+2)),r.push(t.getX(a+1)),r.push(t.getX(a)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const n=s.clone();return n.setIndex(r),n.clearGroups(),n}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}class Mh extends er{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new F0(t)}),this.register(function(t){return new k0(t)}),this.register(function(t){return new Y0(t)}),this.register(function(t){return new K0(t)}),this.register(function(t){return new Z0(t)}),this.register(function(t){return new H0(t)}),this.register(function(t){return new V0(t)}),this.register(function(t){return new G0(t)}),this.register(function(t){return new W0(t)}),this.register(function(t){return new B0(t)}),this.register(function(t){return new j0(t)}),this.register(function(t){return new z0(t)}),this.register(function(t){return new q0(t)}),this.register(function(t){return new X0(t)}),this.register(function(t){return new N0(t)}),this.register(function(t){return new $0(t)}),this.register(function(t){return new J0(t)})}load(e,t,i,r){const n=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Ps.extractUrlBase(e);a=Ps.resolveURL(c,this.path)}else a=Ps.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){r?r(c):console.error(c),n.manager.itemError(e),n.manager.itemEnd(e)},l=new Co(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{n.parse(c,a,function(h){t(h),n.manager.itemEnd(e)},o)}catch(h){o(h)}},i,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let n;const a={},o={},l=new TextDecoder;if(typeof e=="string")n=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Th){try{a[Ve.KHR_BINARY_GLTF]=new Q0(e)}catch(h){r&&r(h);return}n=JSON.parse(a[Ve.KHR_BINARY_GLTF].content)}else n=JSON.parse(l.decode(e));else n=e;if(n.asset===void 0||n.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new d_(n,{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 u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[u.name]=u,a[u.name]=!0}if(n.extensionsUsed)for(let h=0;h<n.extensionsUsed.length;++h){const u=n.extensionsUsed[h],d=n.extensionsRequired||[];switch(u){case Ve.KHR_MATERIALS_UNLIT:a[u]=new O0;break;case Ve.KHR_DRACO_MESH_COMPRESSION:a[u]=new e_(n,this.dracoLoader);break;case Ve.KHR_TEXTURE_TRANSFORM:a[u]=new t_;break;case Ve.KHR_MESH_QUANTIZATION:a[u]=new i_;break;default:d.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,n){i.parse(e,t,r,n)})}}function U0(){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 Ve={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 N0{constructor(e){this.parser=e,this.name=Ve.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){const n=t[i];n.extensions&&n.extensions[this.name]&&n.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const n=t.json,a=((n.extensions&&n.extensions[this.name]||{}).lights||[])[e];let o;const l=new _e(16777215);a.color!==void 0&&l.setRGB(a.color[0],a.color[1],a.color[2],Nt);const c=a.range!==void 0?a.range:0;switch(a.type){case"directional":o=new Ic(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new $d(l),o.distance=c;break;case"spot":o=new Kd(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),Ai(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),r=Promise.resolve(o),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,r=i.json.nodes[e],n=(r.extensions&&r.extensions[this.name]||{}).light;return n===void 0?null:this._loadLight(n).then(function(a){return i._getNodeRef(t.cache,n,a)})}}class O0{constructor(){this.name=Ve.KHR_MATERIALS_UNLIT}getMaterialType(){return kt}extendParams(e,t,i){const r=[];e.color=new _e(1,1,1),e.opacity=1;const n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){const a=n.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Nt),e.opacity=a[3]}n.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",n.baseColorTexture,Ct))}return Promise.all(r)}}class B0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class F0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],a=r.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&n.push(i.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&n.push(i.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(n.push(i.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new oe(o,o)}return Promise.all(n)}}class k0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class z0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],a=r.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&n.push(i.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&&n.push(i.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(n)}}class H0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[];t.sheenColor=new _e(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=r.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],Nt)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&n.push(i.assignTexture(t,"sheenColorMap",a.sheenColorTexture,Ct)),a.sheenRoughnessTexture!==void 0&&n.push(i.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(n)}}class V0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],a=r.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&n.push(i.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(n)}}class G0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],a=r.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&n.push(i.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new _e().setRGB(o[0],o[1],o[2],Nt),Promise.all(n)}}class W0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class j0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],a=r.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&n.push(i.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new _e().setRGB(o[0],o[1],o[2],Nt),a.specularColorTexture!==void 0&&n.push(i.assignTexture(t,"specularColorMap",a.specularColorTexture,Ct)),Promise.all(n)}}class X0{constructor(e){this.parser=e,this.name=Ve.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],a=r.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&n.push(i.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(n)}}class q0{constructor(e){this.parser=e,this.name=Ve.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Ci}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],a=r.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&n.push(i.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(n)}}class Y0{constructor(e){this.parser=e,this.name=Ve.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const n=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,a)}}class K0{constructor(e){this.parser=e,this.name=Ve.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,r=i.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const a=n.extensions[t],o=r.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class Z0{constructor(e){this.parser=e,this.name=Ve.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,r=i.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const a=n.extensions[t],o=r.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class $0{constructor(e){this.name=Ve.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],n=this.parser.getDependency("buffer",r.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 n.then(function(o){const l=r.byteOffset||0,c=r.byteLength||0,h=r.count,u=r.byteStride,d=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,d,r.mode,r.filter).then(function(m){return m.buffer}):a.ready.then(function(){const m=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(m),h,u,d,r.mode,r.filter),m})})}else return null}}class J0{constructor(e){this.name=Ve.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const l of r.primitives)if(l.mode!==ti.TRIANGLES&&l.mode!==ti.TRIANGLE_STRIP&&l.mode!==ti.TRIANGLE_FAN&&l.mode!==void 0)return null;const n=i.extensions[this.name].attributes,a=[],o={};for(const l in n)a.push(this.parser.getDependency("accessor",n[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],u=l[0].count,d=[];for(const m of h){const g=new Le,v=new w,f=new li,p=new w(1,1,1),y=new Sd(m.geometry,m.material,u);for(let _=0;_<u;_++)o.TRANSLATION&&v.fromBufferAttribute(o.TRANSLATION,_),o.ROTATION&&f.fromBufferAttribute(o.ROTATION,_),o.SCALE&&p.fromBufferAttribute(o.SCALE,_),y.setMatrixAt(_,g.compose(v,f,p));for(const _ in o)if(_==="_COLOR_0"){const E=o[_];y.instanceColor=new xo(E.array,E.itemSize,E.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&m.geometry.setAttribute(_,o[_]);ht.prototype.copy.call(y,m),this.parser.assignFinalMaterial(y),d.push(y)}return c.isGroup?(c.clear(),c.add(...d),c):d[0]}))}}const Th="glTF",Us=12,Sh={JSON:1313821514,BIN:5130562};class Q0{constructor(e){this.name=Ve.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Us),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Th)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Us,n=new DataView(e,Us);let a=0;for(;a<r;){const o=n.getUint32(a,!0);a+=4;const l=n.getUint32(a,!0);if(a+=4,l===Sh.JSON){const c=new Uint8Array(e,Us+a,o);this.content=i.decode(c)}else if(l===Sh.BIN){const c=Us+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class e_{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ve.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,r=this.dracoLoader,n=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const h in a){const u=qo[h]||h.toLowerCase();o[u]=a[h]}for(const h in e.attributes){const u=qo[h]||h.toLowerCase();if(a[h]!==void 0){const d=i.accessors[e.attributes[h]],m=ns[d.componentType];c[u]=m.name,l[u]=d.normalized===!0}}return t.getDependency("bufferView",n).then(function(h){return new Promise(function(u,d){r.decodeDracoFile(h,function(m){for(const g in m.attributes){const v=m.attributes[g],f=l[g];f!==void 0&&(v.normalized=f)}u(m)},o,c,Nt,d)})})}}class t_{constructor(){this.name=Ve.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 i_{constructor(){this.name=Ve.KHR_MESH_QUANTIZATION}}class Eh extends Cs{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=e*r*3+r;for(let a=0;a!==r;a++)t[a]=i[n+a];return t}interpolate_(e,t,i,r){const n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,h=r-t,u=(i-t)/h,d=u*u,m=d*u,g=e*c,v=g-c,f=-2*m+3*d,p=m-d,y=1-f,_=p-d+u;for(let E=0;E!==o;E++){const R=a[v+E+o],T=a[v+E+l]*h,A=a[g+E+o],I=a[g+E]*h;n[E]=y*R+_*T+f*A+p*I}return n}}const r_=new li;class s_ extends Eh{interpolate_(e,t,i,r){const n=super.interpolate_(e,t,i,r);return r_.fromArray(n).normalize().toArray(n),n}}const ti={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ns={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},wh={9728:Dt,9729:yt,9984:yl,9985:Hs,9986:hs,9987:Ti},Ch={33071:$t,33648:zs,10497:Mi},Xo={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qo={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"},sr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},n_={CUBICSPLINE:void 0,LINEAR:ms,STEP:ps},Yo={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function a_(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new wo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:bi})),s.DefaultMaterial}function vr(s,e,t){for(const i in t.extensions)s[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function Ai(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 o_(s,e,t){let i=!1,r=!1,n=!1;for(let c=0,h=e.length;c<h;c++){const u=e[c];if(u.POSITION!==void 0&&(i=!0),u.NORMAL!==void 0&&(r=!0),u.COLOR_0!==void 0&&(n=!0),i&&r&&n)break}if(!i&&!r&&!n)return Promise.resolve(s);const a=[],o=[],l=[];for(let c=0,h=e.length;c<h;c++){const u=e[c];if(i){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;a.push(d)}if(r){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;o.push(d)}if(n){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;l.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const h=c[0],u=c[1],d=c[2];return i&&(s.morphAttributes.position=h),r&&(s.morphAttributes.normal=u),n&&(s.morphAttributes.color=d),s.morphTargetsRelative=!0,s})}function l_(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)s.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function c_(s){let e;const t=s.extensions&&s.extensions[Ve.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ko(t.attributes):e=s.indices+":"+Ko(s.attributes)+":"+s.mode,s.targets!==void 0)for(let i=0,r=s.targets.length;i<r;i++)e+=":"+Ko(s.targets[i]);return e}function Ko(s){let e="";const t=Object.keys(s).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+s[t[i]]+";";return e}function Zo(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 h_(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 u_=new Le;class d_{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new U0,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=-1,n=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);r=i&&l?parseInt(l[1],10):-1,n=o.indexOf("Firefox")>-1,a=n?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&r<17||n&&a<98?this.textureLoader=new Ac(this.options.manager):this.textureLoader=new Qd(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Co(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(a){const o={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:i,userData:{}};return vr(n,o,r),Ai(o,r),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,n=t.length;r<n;r++){const a=t[r].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let r=0,n=e.length;r<n;r++){const a=e[r];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(i[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const r=i.clone(),n=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,h]of a.children.entries())n(h,o.children[c])};return n(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const r=e(t[i]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let r=0;r<t.length;r++){const n=e(t[r]);n&&i.push(n)}return i}getDependency(e,t){const i=e+":"+t;let r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(n){return n.loadNode&&n.loadNode(t)});break;case"mesh":r=this._invokeOne(function(n){return n.loadMesh&&n.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(n){return n.loadBufferView&&n.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(n){return n.loadMaterial&&n.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(n){return n.loadTexture&&n.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(n){return n.loadAnimation&&n.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(n,a){return i.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Ve.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(n,a){i.load(Ps.resolveURL(t.uri,r.path),n,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const r=t.byteLength||0,n=t.byteOffset||0;return i.slice(n,n+r)})}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const a=Xo[r.type],o=ns[r.componentType],l=r.normalized===!0,c=new o(r.count*a);return Promise.resolve(new zt(c,a,l))}const n=[];return r.bufferView!==void 0?n.push(this.getDependency("bufferView",r.bufferView)):n.push(null),r.sparse!==void 0&&(n.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(n).then(function(a){const o=a[0],l=Xo[r.type],c=ns[r.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,d=r.byteOffset||0,m=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,g=r.normalized===!0;let v,f;if(m&&m!==u){const p=Math.floor(d/m),y="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+p+":"+r.count;let _=t.cache.get(y);_||(v=new c(o,p*m,r.count*m/h),_=new xd(v,m/h),t.cache.add(y,_)),f=new fo(_,l,d%m/h,g)}else o===null?v=new c(r.count*l):v=new c(o,d,r.count*l),f=new zt(v,l,g);if(r.sparse!==void 0){const p=Xo.SCALAR,y=ns[r.sparse.indices.componentType],_=r.sparse.indices.byteOffset||0,E=r.sparse.values.byteOffset||0,R=new y(a[1],_,r.sparse.count*p),T=new c(a[2],E,r.sparse.count*l);o!==null&&(f=new zt(f.array.slice(),f.itemSize,f.normalized)),f.normalized=!1;for(let A=0,I=R.length;A<I;A++){const S=R[A];if(f.setX(S,T[A*l]),l>=2&&f.setY(S,T[A*l+1]),l>=3&&f.setZ(S,T[A*l+2]),l>=4&&f.setW(S,T[A*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}f.normalized=g}return f})}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,n=t.images[r];let a=this.textureLoader;if(n.uri){const o=i.manager.getHandler(n.uri);o!==null&&(a=o)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,i){const r=this,n=this.json,a=n.textures[e],o=n.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const u=(n.samplers||{})[a.sampler]||{};return h.magFilter=wh[u.magFilter]||yt,h.minFilter=wh[u.minFilter]||Ti,h.wrapS=Ch[u.wrapS]||Mi,h.wrapT=Ch[u.wrapT]||Mi,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Dt&&h.minFilter!==yt,r.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,r=this.json,n=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=r.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=i.getDependency("bufferView",a.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:a.mimeType});return l=o.createObjectURL(d),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(u){return new Promise(function(d,m){let g=d;t.isImageBitmapLoader===!0&&(g=function(v){const f=new Rt(v);f.needsUpdate=!0,d(f)}),t.load(Ps.resolveURL(u,n.path),g,void 0,m)})}).then(function(u){return c===!0&&o.revokeObjectURL(l),Ai(u,a),u.userData.mimeType=a.mimeType||h_(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,i,r){const n=this;return this.getDependency("texture",i.index).then(function(a){if(!a)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(a=a.clone(),a.channel=i.texCoord),n.extensions[Ve.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[Ve.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=n.associations.get(a);a=n.extensions[Ve.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),n.associations.set(a,l)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,n=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new xc,Jt.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(o,l)),i=l}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new mc,Jt.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(o,l)),i=l}if(r||n||a){let o="ClonedMaterial:"+i.uuid+":";r&&(o+="derivative-tangents:"),n&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),n&&(l.vertexColors=!0),a&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return wo}loadMaterial(e){const t=this,i=this.json,r=this.extensions,n=i.materials[e];let a;const o={},l=n.extensions||{},c=[];if(l[Ve.KHR_MATERIALS_UNLIT]){const u=r[Ve.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),c.push(u.extendParams(o,n,t))}else{const u=n.pbrMetallicRoughness||{};if(o.color=new _e(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Nt),o.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",u.baseColorTexture,Ct)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}n.doubleSided===!0&&(o.side=Gt);const h=n.alphaMode||Yo.OPAQUE;if(h===Yo.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Yo.MASK&&(o.alphaTest=n.alphaCutoff!==void 0?n.alphaCutoff:.5)),n.normalTexture!==void 0&&a!==kt&&(c.push(t.assignTexture(o,"normalMap",n.normalTexture)),o.normalScale=new oe(1,1),n.normalTexture.scale!==void 0)){const u=n.normalTexture.scale;o.normalScale.set(u,u)}if(n.occlusionTexture!==void 0&&a!==kt&&(c.push(t.assignTexture(o,"aoMap",n.occlusionTexture)),n.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=n.occlusionTexture.strength)),n.emissiveFactor!==void 0&&a!==kt){const u=n.emissiveFactor;o.emissive=new _e().setRGB(u[0],u[1],u[2],Nt)}return n.emissiveTexture!==void 0&&a!==kt&&c.push(t.assignTexture(o,"emissiveMap",n.emissiveTexture,Ct)),Promise.all(c).then(function(){const u=new a(o);return n.name&&(u.name=n.name),Ai(u,n),t.associations.set(u,{materials:e}),n.extensions&&vr(r,u,n),u})}createUniqueName(e){const t=it.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function n(o){return i[Ve.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Rh(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c_(c),u=r[h];if(u)a.push(u.promise);else{let d;c.extensions&&c.extensions[Ve.KHR_DRACO_MESH_COMPRESSION]?d=n(c):d=Rh(new ei,c,t),r[h]={primitive:c,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){const t=this,i=this.json,r=this.extensions,n=i.meshes[e],a=n.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const h=a[l].material===void 0?a_(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],u=[];for(let m=0,g=h.length;m<g;m++){const v=h[m],f=a[m];let p;const y=c[m];if(f.mode===ti.TRIANGLES||f.mode===ti.TRIANGLE_STRIP||f.mode===ti.TRIANGLE_FAN||f.mode===void 0)p=n.isSkinnedMesh===!0?new bd(v,y):new rt(v,y),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),f.mode===ti.TRIANGLE_STRIP?p.geometry=bh(p.geometry,Pl):f.mode===ti.TRIANGLE_FAN&&(p.geometry=bh(p.geometry,Oa));else if(f.mode===ti.LINES)p=new Rd(v,y);else if(f.mode===ti.LINE_STRIP)p=new To(v,y);else if(f.mode===ti.LINE_LOOP)p=new Ad(v,y);else if(f.mode===ti.POINTS)p=new Pd(v,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);Object.keys(p.geometry.morphAttributes).length>0&&l_(p,n),p.name=t.createUniqueName(n.name||"mesh_"+e),Ai(p,n),f.extensions&&vr(r,p,f),t.assignFinalMaterial(p),u.push(p)}for(let m=0,g=u.length;m<g;m++)t.associations.set(u[m],{meshes:e,primitives:m});if(u.length===1)return n.extensions&&vr(r,u[0],n),u[0];const d=new zi;n.extensions&&vr(r,d,n),t.associations.set(d,{meshes:e});for(let m=0,g=u.length;m<g;m++)d.add(u[m]);return d})}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new Tt(Va.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new pr(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Ai(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,n=t.joints.length;r<n;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){const n=r.pop(),a=r,o=[],l=[];for(let c=0,h=a.length;c<h;c++){const u=a[c];if(u){o.push(u);const d=new Le;n!==null&&d.fromArray(n.array,c*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new _o(o,l)})}loadAnimation(e){const t=this.json,i=this,r=t.animations[e],n=r.name?r.name:"animation_"+e,a=[],o=[],l=[],c=[],h=[];for(let u=0,d=r.channels.length;u<d;u++){const m=r.channels[u],g=r.samplers[m.sampler],v=m.target,f=v.node,p=r.parameters!==void 0?r.parameters[g.input]:g.input,y=r.parameters!==void 0?r.parameters[g.output]:g.output;v.node!==void 0&&(a.push(this.getDependency("node",f)),o.push(this.getDependency("accessor",p)),l.push(this.getDependency("accessor",y)),c.push(g),h.push(v))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(u){const d=u[0],m=u[1],g=u[2],v=u[3],f=u[4],p=[];for(let _=0,E=d.length;_<E;_++){const R=d[_],T=m[_],A=g[_],I=v[_],S=f[_];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const M=i._createAnimationTracks(R,T,A,I,S);if(M)for(let L=0;L<M.length;L++)p.push(M[L])}const y=new Hd(n,void 0,p);return Ai(y,r),y})}createNodeMesh(e){const t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(n){const a=i._getNodeRef(i.meshCache,r.mesh,n);return r.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=r.weights.length;l<c;l++)o.morphTargetInfluences[l]=r.weights[l]}),a})}loadNode(e){const t=this.json,i=this,r=t.nodes[e],n=i._loadNodeShallow(e),a=[],o=r.children||[];for(let c=0,h=o.length;c<h;c++)a.push(i.getDependency("node",o[c]));const l=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([n,Promise.all(a),l]).then(function(c){const h=c[0],u=c[1],d=c[2];d!==null&&h.traverse(function(m){m.isSkinnedMesh&&m.bind(d,u_)});for(let m=0,g=u.length;m<g;m++)h.add(u[m]);return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const n=t.nodes[e],a=n.name?r.createUniqueName(n.name):"",o=[],l=r._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),n.camera!==void 0&&o.push(r.getDependency("camera",n.camera).then(function(c){return r._getNodeRef(r.cameraCache,n.camera,c)})),r._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(n.isBone===!0?h=new hc:c.length>1?h=new zi:c.length===1?h=c[0]:h=new ht,h!==c[0])for(let u=0,d=c.length;u<d;u++)h.add(c[u]);if(n.name&&(h.userData.name=n.name,h.name=a),Ai(h,n),n.extensions&&vr(i,h,n),n.matrix!==void 0){const u=new Le;u.fromArray(n.matrix),h.applyMatrix4(u)}else n.translation!==void 0&&h.position.fromArray(n.translation),n.rotation!==void 0&&h.quaternion.fromArray(n.rotation),n.scale!==void 0&&h.scale.fromArray(n.scale);if(!r.associations.has(h))r.associations.set(h,{});else if(n.mesh!==void 0&&r.meshCache.refs[n.mesh]>1){const u=r.associations.get(h);r.associations.set(h,{...u})}return r.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,n=new zi;i.name&&(n.name=r.createUniqueName(i.name)),Ai(n,i),i.extensions&&vr(t,n,i);const a=i.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(r.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let h=0,u=l.length;h<u;h++)n.add(l[h]);const c=h=>{const u=new Map;for(const[d,m]of r.associations)(d instanceof Jt||d instanceof Rt)&&u.set(d,m);return h.traverse(d=>{const m=r.associations.get(d);m!=null&&u.set(d,m)}),u};return r.associations=c(n),n})}_createAnimationTracks(e,t,i,r,n){const a=[],o=e.name?e.name:e.uuid,l=[];sr[n.path]===sr.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(o);let c;switch(sr[n.path]){case sr.weights:c=Kr;break;case sr.rotation:c=Zr;break;case sr.translation:case sr.scale:c=Jr;break;default:switch(i.itemSize){case 1:c=Kr;break;case 2:case 3:default:c=Jr;break}break}const h=r.interpolation!==void 0?n_[r.interpolation]:ms,u=this._getArrayFromAccessor(i);for(let d=0,m=l.length;d<m;d++){const g=new c(l[d]+"."+sr[n.path],t.array,u,h);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),a.push(g)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=Zo(t.constructor),r=new Float32Array(t.length);for(let n=0,a=t.length;n<a;n++)r[n]=t[n]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const i=this instanceof Zr?s_:Eh;return new i(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function p_(s,e,t){const i=e.attributes,r=new At;if(i.POSITION!==void 0){const o=t.json.accessors[i.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(r.set(new w(l[0],l[1],l[2]),new w(c[0],c[1],c[2])),o.normalized){const h=Zo(ns[o.componentType]);r.min.multiplyScalar(h),r.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const n=e.targets;if(n!==void 0){const o=new w,l=new w;for(let c=0,h=n.length;c<h;c++){const u=n[c];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],m=d.min,g=d.max;if(m!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(m[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(m[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(m[2]),Math.abs(g[2]))),d.normalized){const v=Zo(ns[d.componentType]);l.multiplyScalar(v)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(o)}s.boundingBox=r;const a=new Ei;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,s.boundingSphere=a}function Rh(s,e,t){const i=e.attributes,r=[];function n(a,o){return t.getDependency("accessor",a).then(function(l){s.setAttribute(o,l)})}for(const a in i){const o=qo[a]||a.toLowerCase();o in s.attributes||r.push(n(i[a],o))}if(e.indices!==void 0&&!s.index){const a=t.getDependency("accessor",e.indices).then(function(o){s.setIndex(o)});r.push(a)}return je.workingColorSpace!==Nt&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${je.workingColorSpace}" not supported.`),Ai(s,e),p_(s,e,t),Promise.all(r).then(function(){return e.targets!==void 0?o_(s,e.targets,t):s})}class m_{loader;scene;models=[];constructor(e){this.scene=e,this.loader=new Mh}async loadGLTF(e){return new Promise((t,i)=>{this.loader.load(e,r=>{const n=r.scene;n.traverse(a=>{a instanceof rt&&(a.receiveShadow=!0,a.castShadow=!0)}),this.scene.add(n),this.models.push({children:this.extractMeshes(n)}),t(n)},void 0,r=>{console.error("An error happened loading the model:",r),i(r)})})}extractMeshes(e){const t=[];return e.traverse(i=>{i instanceof rt&&t.push(i)}),t}clearModels(){this.models=[]}}class f_{scene;highlightMaterial;originalMaterials=new Map;originalRenderOrders=new Map;selectedObjects=[];constructor(e,t,i,r){this.scene=e,this.highlightMaterial=new kt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.8,side:Gt})}setEventModule(e){}setSelectedWithMaterial(e){this.clearSelected(),e.forEach(t=>{t.isMesh&&(this.originalMaterials.has(t.uuid)||this.originalMaterials.set(t.uuid,t.material),this.originalRenderOrders.has(t.uuid)||this.originalRenderOrders.set(t.uuid,t.renderOrder),t.material=this.highlightMaterial,t.renderOrder=999,this.selectedObjects.push(t))})}clearSelected(){this.selectedObjects.forEach(e=>{const t=this.originalMaterials.get(e.uuid);t&&(e.material=t);const i=this.originalRenderOrders.get(e.uuid);i!==void 0&&(e.renderOrder=i)}),this.selectedObjects=[],this.originalMaterials.clear(),this.originalRenderOrders.clear()}highlight(e){this.setSelectedWithMaterial(e)}clearHighlight(){this.clearSelected()}setVisibility(e,t){this.scene.traverse(i=>{(e.includes(i.uuid)||e.includes(i.name))&&(i.visible=t)})}}class nr extends rr{constructor(e,t,i,r){super(),this.renderScene=t,this.renderCamera=i,this.selectedObjects=r!==void 0?r:[],this.visibleEdgeColor=new _e(1,1,1),this.hiddenEdgeColor=new _e(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.patternTexture=null,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this._selectionCache=new Set,this.resolution=e!==void 0?new oe(e.x,e.y):new oe(256,256);const n=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new bt(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Tc,this.depthMaterial.side=Gt,this.depthMaterial.depthPacking=Ll,this.depthMaterial.blending=xt,this.prepareMaskMaterial=this._getPrepareMaskMaterial(),this.prepareMaskMaterial.side=Gt,this.prepareMaskMaterial.fragmentShader=h(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new bt(this.resolution.x,this.resolution.y,{type:pt}),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new bt(n,a,{type:pt}),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new bt(n,a,{type:pt}),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new bt(Math.round(n/2),Math.round(a/2),{type:pt}),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new bt(n,a,{type:pt}),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new bt(Math.round(n/2),Math.round(a/2),{type:pt}),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;const o=4,l=4;this.separableBlurMaterial1=this._getSeparableBlurMaterial(o),this.separableBlurMaterial1.uniforms.texSize.value.set(n,a),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeparableBlurMaterial(l),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(n/2),Math.round(a/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=l,this.overlayMaterial=this._getOverlayMaterial();const c=ir;this.copyUniforms=fi.clone(c.uniforms),this.materialCopy=new ot({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:xt,depthTest:!1,depthWrite:!1}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new _e,this.oldClearAlpha=1,this._fsQuad=new Is(null),this.tempPulseColor1=new _e,this.tempPulseColor2=new _e,this.textureMatrix=new Le;function h(u,d){const m=d.isPerspectiveCamera?"perspective":"orthographic";return u.replace(/DEPTH_TO_VIEW_Z/g,m+"DepthToViewZ")}}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.depthMaterial.dispose(),this.prepareMaskMaterial.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this._fsQuad.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t),this.renderTargetDepthBuffer.setSize(e,t);let i=Math.round(e/this.downSampleRatio),r=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(i,r),this.renderTargetBlurBuffer1.setSize(i,r),this.renderTargetEdgeBuffer1.setSize(i,r),this.separableBlurMaterial1.uniforms.texSize.value.set(i,r),i=Math.round(i/2),r=Math.round(r/2),this.renderTargetBlurBuffer2.setSize(i,r),this.renderTargetEdgeBuffer2.setSize(i,r),this.separableBlurMaterial2.uniforms.texSize.value.set(i,r)}render(e,t,i,r,n){if(this.selectedObjects.length>0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const a=e.autoClear;e.autoClear=!1,n&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._updateSelectionCache(),this._changeVisibilityOfSelectedObjects(!1);const o=this.renderScene.background,l=this.renderScene.overrideMaterial;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this._selectionCache.clear(),this.renderScene.background=o,this.renderScene.overrideMaterial=l,this._fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this._fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const c=.625+Math.cos(performance.now()*.01/this.pulsePeriod)*.75/2;this.tempPulseColor1.multiplyScalar(c),this.tempPulseColor2.multiplyScalar(c)}this._fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=nr.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this._fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=nr.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=nr.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this._fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=nr.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,n&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(i),this._fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}this.renderToScreen&&(this._fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=i.texture,e.setRenderTarget(null),this._fsQuad.render(e))}_updateSelectionCache(){const e=this._selectionCache;function t(i){i.isMesh&&e.add(i)}e.clear();for(let i=0;i<this.selectedObjects.length;i++)this.selectedObjects[i].traverse(t)}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;for(const i of this._selectionCache)e===!0?i.visible=t.get(i):(t.set(i,i.visible),i.visible=e)}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,i=this._selectionCache;function r(n){if(n.isPoints||n.isLine||n.isLine2)e===!0?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e);else if((n.isMesh||n.isSprite)&&!i.has(n)){const a=n.visible;(e===!1||t.get(n)===!0)&&(n.visible=e),t.set(n,a)}}this.renderScene.traverse(r)}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}_getPrepareMaskMaterial(){return new ot({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new oe(.5,.5)},textureMatrix:{value:null}},vertexShader:`#include <batching_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
|
||
varying vec4 projTexCoord;
|
||
varying vec4 vPosition;
|
||
uniform mat4 textureMatrix;
|
||
|
||
void main() {
|
||
|
||
#include <batching_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <project_vertex>
|
||
|
||
vPosition = mvPosition;
|
||
|
||
vec4 worldPosition = vec4( transformed, 1.0 );
|
||
|
||
#ifdef USE_INSTANCING
|
||
|
||
worldPosition = instanceMatrix * worldPosition;
|
||
|
||
#endif
|
||
|
||
worldPosition = modelMatrix * worldPosition;
|
||
|
||
projTexCoord = textureMatrix * worldPosition;
|
||
|
||
}`,fragmentShader:`#include <packing>
|
||
varying vec4 vPosition;
|
||
varying vec4 projTexCoord;
|
||
uniform sampler2D depthTexture;
|
||
uniform vec2 cameraNearFar;
|
||
|
||
void main() {
|
||
|
||
float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));
|
||
float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );
|
||
float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;
|
||
gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);
|
||
|
||
}`})}_getEdgeDetectionMaterial(){return new ot({uniforms:{maskTexture:{value:null},texSize:{value:new oe(.5,.5)},visibleEdgeColor:{value:new w(1,1,1)},hiddenEdgeColor:{value:new w(1,1,1)}},vertexShader:`varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`varying vec2 vUv;
|
||
|
||
uniform sampler2D maskTexture;
|
||
uniform vec2 texSize;
|
||
uniform vec3 visibleEdgeColor;
|
||
uniform vec3 hiddenEdgeColor;
|
||
|
||
void main() {
|
||
vec2 invSize = 1.0 / texSize;
|
||
vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);
|
||
vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);
|
||
vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);
|
||
vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);
|
||
vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);
|
||
float diff1 = (c1.r - c2.r)*0.5;
|
||
float diff2 = (c3.r - c4.r)*0.5;
|
||
float d = length( vec2(diff1, diff2) );
|
||
float a1 = min(c1.g, c2.g);
|
||
float a2 = min(c3.g, c4.g);
|
||
float visibilityFactor = min(a1, a2);
|
||
vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
|
||
gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);
|
||
}`})}_getSeparableBlurMaterial(e){return new ot({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new oe(.5,.5)},direction:{value:new oe(.5,.5)},kernelRadius:{value:1}},vertexShader:`varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`#include <common>
|
||
varying vec2 vUv;
|
||
uniform sampler2D colorTexture;
|
||
uniform vec2 texSize;
|
||
uniform vec2 direction;
|
||
uniform float kernelRadius;
|
||
|
||
float gaussianPdf(in float x, in float sigma) {
|
||
return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
|
||
}
|
||
|
||
void main() {
|
||
vec2 invSize = 1.0 / texSize;
|
||
float sigma = kernelRadius/2.0;
|
||
float weightSum = gaussianPdf(0.0, sigma);
|
||
vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;
|
||
vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);
|
||
vec2 uvOffset = delta;
|
||
for( int i = 1; i <= MAX_RADIUS; i ++ ) {
|
||
float x = kernelRadius * float(i) / float(MAX_RADIUS);
|
||
float w = gaussianPdf(x, sigma);
|
||
vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);
|
||
vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);
|
||
diffuseSum += ((sample1 + sample2) * w);
|
||
weightSum += (2.0 * w);
|
||
uvOffset += delta;
|
||
}
|
||
gl_FragColor = diffuseSum/weightSum;
|
||
}`})}_getOverlayMaterial(){return new ot({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:`varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`varying vec2 vUv;
|
||
|
||
uniform sampler2D maskTexture;
|
||
uniform sampler2D edgeTexture1;
|
||
uniform sampler2D edgeTexture2;
|
||
uniform sampler2D patternTexture;
|
||
uniform float edgeStrength;
|
||
uniform float edgeGlow;
|
||
uniform bool usePatternTexture;
|
||
|
||
void main() {
|
||
vec4 edgeValue1 = texture2D(edgeTexture1, vUv);
|
||
vec4 edgeValue2 = texture2D(edgeTexture2, vUv);
|
||
vec4 maskColor = texture2D(maskTexture, vUv);
|
||
vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);
|
||
float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;
|
||
vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;
|
||
vec4 finalColor = edgeStrength * maskColor.r * edgeValue;
|
||
if(usePatternTexture)
|
||
finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);
|
||
gl_FragColor = finalColor;
|
||
}`,blending:Bs,depthTest:!1,depthWrite:!1,transparent:!0})}}nr.BlurDirectionX=new oe(1,0),nr.BlurDirectionY=new oe(0,1);class g_{outlinePass;hoveredObjects=[];selectedObjects=[];constructor(e,t,i,r){this.outlinePass=new nr(new oe(i,r),e,t),this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.edgeThickness=1,this.outlinePass.pulsePeriod=0,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800")}getPass(){return this.outlinePass}setHoveredObjects(e){this.hoveredObjects=e,this.updateOutline(),e.length>0&&(this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800"))}setSelectedObjects(e){this.selectedObjects=e,this.updateOutline(),e.length>0&&(this.outlinePass.edgeStrength=5,this.outlinePass.edgeGlow=1,this.outlinePass.visibleEdgeColor.set("#00aaff"),this.outlinePass.hiddenEdgeColor.set("#00aaff"))}clearHovered(){this.hoveredObjects=[],this.updateOutline()}clearSelected(){this.selectedObjects=[],this.updateOutline()}clearAll(){this.hoveredObjects=[],this.selectedObjects=[],this.updateOutline()}updateOutline(){this.selectedObjects.length>0?(this.outlinePass.selectedObjects=this.selectedObjects,this.outlinePass.edgeStrength=5,this.outlinePass.edgeGlow=1,this.outlinePass.visibleEdgeColor.set("#00aaff"),this.outlinePass.hiddenEdgeColor.set("#00aaff")):this.hoveredObjects.length>0?(this.outlinePass.selectedObjects=this.hoveredObjects,this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800")):this.outlinePass.selectedObjects=[]}resize(e,t){this.outlinePass.setSize(e,t)}setHoverStyle(e){e.color&&(this.outlinePass.visibleEdgeColor.set(e.color),this.outlinePass.hiddenEdgeColor.set(e.color)),e.strength!==void 0&&(this.outlinePass.edgeStrength=e.strength),e.glow!==void 0&&(this.outlinePass.edgeGlow=e.glow),e.thickness!==void 0&&(this.outlinePass.edgeThickness=e.thickness)}setSelectedStyle(e){}}class v_{scene;camera;canvas;controls;outlineManager;isSelecting=!1;startPoint=new oe;endPoint=new oe;ctrlPressed=!1;controlsEnabled=!0;selectionBox=null;selectedObjects=[];constructor(e,t,i,r,n){this.scene=e,this.camera=t,this.canvas=i,this.controls=r,this.outlineManager=n,this.setupEventListeners(),this.createSelectionBoxElement()}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.canvas.parentElement&&this.canvas.parentElement.appendChild(this.selectionBox)}setupEventListeners(){window.addEventListener("keydown",this.onKeyDown.bind(this)),window.addEventListener("keyup",this.onKeyUp.bind(this)),this.canvas.addEventListener("mousedown",this.onMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.onMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.onMouseUp.bind(this))}onKeyDown(e){(e.key==="Control"||e.key==="Meta")&&(this.ctrlPressed=!0)}onKeyUp(e){(e.key==="Control"||e.key==="Meta")&&(this.ctrlPressed=!1,this.isSelecting&&this.endSelection())}onMouseDown(e){if(e.button!==0||!this.ctrlPressed)return;const t=this.canvas.getBoundingClientRect();this.startPoint.set(e.clientX-t.left,e.clientY-t.top),this.endPoint.copy(this.startPoint),this.isSelecting=!0,this.controls&&this.controls.enabled!==void 0&&(this.controlsEnabled=this.controls.enabled,this.controls.enabled=!1),this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation()}onMouseMove(e){if(!this.isSelecting)return;const t=this.canvas.getBoundingClientRect();this.endPoint.set(e.clientX-t.left,e.clientY-t.top),this.updateSelectionBoxUI(),this.updateSelectedObjects(),e.preventDefault(),e.stopPropagation()}onMouseUp(e){this.isSelecting&&(this.endSelection(),e.preventDefault(),e.stopPropagation())}endSelection(){this.isSelecting&&(this.isSelecting=!1,this.controls&&this.controls.enabled!==void 0&&(this.controls.enabled=this.controlsEnabled),this.selectionBox&&(this.selectionBox.style.display="none"),this.updateSelectedObjects())}updateSelectionBoxUI(){if(!this.selectionBox)return;const e=Math.min(this.startPoint.x,this.endPoint.x),t=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),r=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${e}px`,this.selectionBox.style.top=`${t}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${r}px`}updateSelectedObjects(){const e=this.endPoint.x>this.startPoint.x,t=this.endPoint.y>this.startPoint.y,i=e&&t,r=this.canvas.getBoundingClientRect(),n=r.width,a=r.height,o=new oe(Math.min(this.startPoint.x,this.endPoint.x)/n,Math.min(this.startPoint.y,this.endPoint.y)/a),l=new oe(Math.max(this.startPoint.x,this.endPoint.x)/n,Math.max(this.startPoint.y,this.endPoint.y)/a),c=[];this.scene.traverse(h=>{if(!h.isMesh||!h.visible)return;const u=h;if(!u.geometry)return;u.geometry.boundingBox||u.geometry.computeBoundingBox();const d=u.geometry.boundingBox;if(!d)return;const m=this.getBoundingBoxCorners(d,u).map(f=>this.worldToScreen(f)),g=this.getScreenBoundingBox(m);let v=!1;i?v=this.isFullyContained(g,o,l):v=this.isPartiallyContained(g,o,l),v&&c.push(h)}),this.selectedObjects=c,this.outlineManager.setSelectedObjects(this.selectedObjects)}getBoundingBoxCorners(e,t){const i=[],r=e.min,n=e.max;return i.push(new w(r.x,r.y,r.z)),i.push(new w(n.x,r.y,r.z)),i.push(new w(r.x,n.y,r.z)),i.push(new w(n.x,n.y,r.z)),i.push(new w(r.x,r.y,n.z)),i.push(new w(n.x,r.y,n.z)),i.push(new w(r.x,n.y,n.z)),i.push(new w(n.x,n.y,n.z)),i.forEach(a=>{a.applyMatrix4(t.matrixWorld)}),i}worldToScreen(e){const t=e.clone();t.project(this.camera);const i=(t.x+1)/2,r=(1-t.y)/2;return new oe(i,r)}getScreenBoundingBox(e){const t=new oe(1/0,1/0),i=new oe(-1/0,-1/0);return e.forEach(r=>{t.x=Math.min(t.x,r.x),t.y=Math.min(t.y,r.y),i.x=Math.max(i.x,r.x),i.y=Math.max(i.y,r.y)}),{min:t,max:i}}isFullyContained(e,t,i){return e.min.x>=t.x&&e.min.y>=t.y&&e.max.x<=i.x&&e.max.y<=i.y}isPartiallyContained(e,t,i){return!(e.max.x<t.x||e.min.x>i.x||e.max.y<t.y||e.min.y>i.y)}clearSelection(){this.selectedObjects=[],this.outlineManager.clearSelected()}getSelectedObjects(){return this.selectedObjects}dispose(){window.removeEventListener("keydown",this.onKeyDown.bind(this)),window.removeEventListener("keyup",this.onKeyUp.bind(this)),this.canvas.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.canvas.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.canvas.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.selectionBox&&this.selectionBox.parentElement&&this.selectionBox.parentElement.removeChild(this.selectionBox),this.clearSelection()}}class __{scene;clippingPlane;stencilGroup=null;isEnabledFlag=!1;capMesh=null;planeInitialized=!1;tempCenter=new w;sceneBounds=new At;capColor=new _e(16711680);constructor(e){this.scene=e,this.clippingPlane=new wi(new w(0,-1,0),0)}enable(){this.isEnabledFlag=!0,this.refresh()}disable(){this.isEnabledFlag=!1,this.cleanup()}refresh(){this.isEnabledFlag&&(this.cleanupStencilGroup(),this.ensurePlaneInitialized(),this.updateSceneMaterials(!0),this.createStencilGroup())}setPlane(e,t){this.planeInitialized=!0,this.clippingPlane.normal.copy(e).normalize(),this.clippingPlane.constant=t,this.isEnabledFlag&&this.updateCapPlane()}isEnabled(){return this.isEnabledFlag}setCapColor(e){if(this.capColor.set(e),this.capMesh){const t=this.capMesh.material;t.color.copy(this.capColor),t.needsUpdate=!0}}updateSceneMaterials(e){this.scene.traverse(t=>{if(t instanceof rt){if(t.userData.isStencilCap)return;(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>{i&&(e?((!i.clippingPlanes||i.clippingPlanes.indexOf(this.clippingPlane)===-1)&&(i.clippingPlanes=[this.clippingPlane]),i.clipShadows=!0):i.clippingPlanes=[],i.needsUpdate=!0)})}})}createStencilGroup(){this.stencilGroup=new zi,this.stencilGroup.name="ClippingStencilGroup",this.scene.add(this.stencilGroup);let e=0;this.scene.traverse(t=>{if(t instanceof rt&&t.visible&&!t.userData.isStencilCap){if(!t.geometry)return;this.createStencilMeshesForObject(t),e++}}),console.log(`ClippingManager: Generated stencil geometry for ${e} meshes.`),this.addCapPlane(),this.updateCapPlane()}createStencilMeshesForObject(e){const t=e.geometry;e.updateMatrixWorld(!0);const i=e.matrixWorld,r=new kt({depthWrite:!1,depthTest:!1,colorWrite:!1,stencilWrite:!0,stencilFunc:ka,clippingPlanes:[this.clippingPlane]}),n=r.clone();n.side=Ft,n.stencilFail=Ba,n.stencilZFail=Ba,n.stencilZPass=Ba;const a=new rt(t,n);a.applyMatrix4(i),a.matrixAutoUpdate=!1,a.userData.isStencilCap=!0,a.renderOrder=1,this.stencilGroup.add(a);const o=r.clone();o.side=bi,o.stencilFail=Fa,o.stencilZFail=Fa,o.stencilZPass=Fa;const l=new rt(t,o);l.applyMatrix4(i),l.matrixAutoUpdate=!1,l.userData.isStencilCap=!0,l.renderOrder=1,this.stencilGroup.add(l)}addCapPlane(){const e=new kt({color:this.capColor,side:Gt,stencilWrite:!0,transparent:!0,opacity:0,stencilFunc:bu,stencilRef:0,clippingPlanes:[],depthTest:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),t=new ws(1e5,1e5),i=new rt(t,e);i.userData.isCapPlane=!0,i.userData.isStencilCap=!0,i.renderOrder=2,this.capMesh=i,this.stencilGroup.add(i)}updateCapPlane(){if(!this.stencilGroup||!this.capMesh)return;const e=this.capMesh,t=this.clippingPlane.normal,i=-this.clippingPlane.constant;e.quaternion.setFromUnitVectors(new w(0,0,1),t),e.position.copy(t).multiplyScalar(i)}cleanupStencilGroup(){this.stencilGroup&&(this.scene.remove(this.stencilGroup),this.stencilGroup.traverse(e=>{e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose()),e.geometry&&e.userData.isCapPlane&&e.geometry.dispose()}),this.stencilGroup=null,this.capMesh=null)}cleanup(){this.updateSceneMaterials(!1),this.cleanupStencilGroup()}ensurePlaneInitialized(){if(this.planeInitialized||(this.sceneBounds.makeEmpty(),this.sceneBounds.setFromObject(this.scene),this.sceneBounds.isEmpty()))return;this.sceneBounds.getCenter(this.tempCenter);const e=this.clippingPlane.normal;this.clippingPlane.constant=-e.dot(this.tempCenter),this.planeInitialized=!0,this.updateCapPlane()}}class x_{_lastClickWorldPosition=null;_lastClickScreenPosition=null;constructor(){}setLastClickWorldPosition(e){this._lastClickWorldPosition=e.clone()}getLastClickWorldPosition(){return this._lastClickWorldPosition}setLastClickScreenPosition(e){this._lastClickScreenPosition=e.clone()}getLastClickScreenPosition(){return this._lastClickScreenPosition}clearClickState(){this._lastClickWorldPosition=null,this._lastClickScreenPosition=null}}function y_(s){let e=new Object;return e.updataSceneOctreeBox=function(){s.octreeBoxModels=[];let t=e.getBoundingBox();e.ocBox=e.splitBoxIntoAuto(t);let i=0;s.models.forEach(a=>{a.children.forEach(o=>{o.info.forEach(l=>{n(l,e.ocBox)})}),i=i+1}),r(e.ocBox);function r(a){for(let o=a.children.length-1;o>=0;o--){let l=a.children[o];l.isLeaf==!1&&r(l),l.children.length==0&&(l.isLeaf=!0),l.isLeaf&&(l.elements==null||l.elements.length==0)&&a.children.splice(o,1)}}function n(a,o){var l={min:a.box.min,max:a.box.max};if(e.boxContainBox(o,l)==!0)if(o.elements==null&&(o.elements=[]),o.isLeaf==!1){let c=!1;for(let h=0;h<o.children.length;h++)if(n(a,o.children[h])==!0){c=!0;break}c==!1&&o.elements.push([i,...a.index])}else o.elements.push([i,...a.index]);else return!1;return!0}},e.rayInterationModel=function(t){var i=[];n(t,e.ocBox);var r=a(t,i);return r;function n(o,l){if(l==null)return;let c=new At(l.min,l.max),h=o.ray.intersectsBox(c);if(!(h==null||h==!1))if(l.children==null||l.children.length==0){if(l.elements!=null)for(var u of l.elements)i.push(u)}else{if(l.elements!=null)for(var u of l.elements)i.push(u);for(let d of l.children)n(o,d)}}function a(o,l){let c=[];const h=new kt({color:16711680});for(let u of l){let d=s.models[u[0]].children[u[1]];if(d.TypeName=="Mesh"&&d.geometry.groups[u[2]].visibility!==!1){let m=new rt(d.geometryArray[u[2]],h);m.indexs=u,m.TypeName=d.TypeName,c.push(m)}else d.TypeName=="InstancedMesh"||d.TypeName=="InstancedMesh-Pipe"}return o.intersectObjects(c,!1)}},e.boxContainBox=function(t,i){return i.min.x>=t.min.x&&i.min.y>=t.min.y&&i.min.z>=t.min.z&&i.max.x<=t.max.x&&i.max.y<=t.max.y&&i.max.z<=t.max.z},e.splitBoxIntoAuto=function(t,i=10){let r=[],n=[],a=[],o=(t.max.x-t.min.x)*.5,l=(t.max.y-t.min.y)*.5,c=(t.max.z-t.min.z)*.5;if(o>i){let h=t,u={min:h.min,max:new w(h.min.x+o,h.max.y,h.max.z)},d={min:new w(h.min.x+o,h.min.y,h.min.z),max:h.max};r.push(u),r.push(d)}if(l>i)for(let h of r){let u={min:h.min,max:new w(h.max.x,h.min.y+l,h.max.z)},d={min:new w(h.min.x,h.min.y+l,h.min.z),max:h.max};n.push(u),n.push(d)}else n=r;if(c>i)for(let h of n){let u={min:h.min,max:new w(h.max.x,h.max.y,h.min.z+c)},d={min:new w(h.min.x,h.min.y,h.min.z+c),max:h.max};a.push(u),a.push(d)}else a=n;if(t.children=a,t.children.length>0){t.isLeaf=!1;for(let h=0;h<t.children.length;h++)t.children[h]=e.splitBoxIntoAuto(t.children[h])}else t.isLeaf=!0;return t.length=t.min.distanceTo(t.max),t},e.splitBoxInto8=function(t){const i=t.min,r=t.max,n=new w().addVectors(i,r).multiplyScalar(.5),a=[];for(let o=0;o<2;o++)for(let l=0;l<2;l++)for(let c=0;c<2;c++){const h=new w(o===0?i.x:n.x,l===0?i.y:n.y,c===0?i.z:n.z),u=new w(o===1?r.x:n.x,l===1?r.y:n.y,c===1?r.z:n.z),d=new At(h,u);a.push(d)}return a},e.boundingSphereToBox=function(t){let i=t.center,r=new w(i.x-t.radius*.5,i.y-t.radius*.5,i.z-t.radius*.5),n=new w(i.x+t.radius*.5,i.y+t.radius*.5,i.z+t.radius*.5);return{min:r,max:n}},e.getBoundingBox=function(){let t=s.models,i=new w(1e8,1e9,1e10),r=new w(-1e8,-1e9,-1e10);return t.forEach(n=>{n.children.forEach(a=>{a.geometry.computeBoundingBox();let o=a.geometry.boundingBox.min,l=a.geometry.boundingBox.max;o.x<i.x&&(i.x=o.x),o.y<i.y&&(i.y=o.y),o.z<i.z&&(i.z=o.z),l.x>r.x&&(r.x=l.x),l.y>r.y&&(r.y=l.y),l.z>r.z&&(r.z=l.z)})}),{min:i,max:r}},e}var as=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-as.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?as.Bounce.In(s*2)*.5:as.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}}}}),Ns=function(){return performance.now()},b_=(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=Ns()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<i.length;r++){var n=this._tweens[i[r]],a=!t;n&&n.update(e,a)===!1&&!t&&delete this._tweens[i[r]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},s})(),$o={Linear:function(s,e){var t=s.length-1,i=t*e,r=Math.floor(i),n=$o.Utils.Linear;return e<0?n(s[0],s[1],i):e>1?n(s[t],s[t-1],t-i):n(s[r],s[r+1>t?t:r+1],i-r)},Utils:{Linear:function(s,e,t){return(e-s)*t+s}}},Ah=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),Jo=new b_,M_=(function(){function s(e,t){t===void 0&&(t=Jo),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=as.Linear.None,this._interpolationFunction=$o.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Ah.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=Ns()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var n in this._valuesEnd)r[n]=this._valuesEnd[n];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},s.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},s.prototype._setupProperties=function(e,t,i,r,n){for(var a in i){var o=e[a],l=Array.isArray(o),c=l?"array":typeof o,h=!l&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(h){var u=i[a];if(u.length===0)continue;for(var d=[o],m=0,g=u.length;m<g;m+=1){var v=this._handleRelativeValue(o,u[m]);if(isNaN(v)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}d.push(v)}h&&(i[a]=d)}if((c==="object"||l)&&o&&!h){t[a]=l?[]:{};var f=o;for(var p in f)t[a][p]=f[p];r[a]=l?[]:{};var u=i[a];if(!this._isDynamic){var y={};for(var p in u)y[p]=u[p];i[a]=u=y}this._setupProperties(f,t[a],u,r[a],n)}else(typeof t[a]>"u"||n)&&(t[a]=o),l||(t[a]*=1),h?r[a]=i[a].slice().reverse():r[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=Ns()),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=Ns()),!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=Jo),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=as.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=$o.Linear),this._interpolationFunction=e,this},s.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},s.prototype.onStart=function(e){return this._onStartCallback=e,this},s.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},s.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},s.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},s.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},s.prototype.onStop=function(e){return this._onStopCallback=e,this},s.prototype.update=function(e,t){var i=this,r;if(e===void 0&&(e=Ns()),t===void 0&&(t=!0),this._isPaused)return!0;var n,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+((r=this._repeatDelayTime)!==null&&r!==void 0?r:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(i._duration===0||o>c)return 1;var f=Math.trunc(o/l),p=o-f*l,y=Math.min(p/i._duration,1);return y===0&&o===i._duration?1:y},u=h(),d=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,d),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||o>=this._duration)if(this._repeat>0){var m=Math.min(Math.trunc((o-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=m);for(n in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[n]=="string"&&(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*m,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,v=this._chainedTweens.length;g<v;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},s.prototype._updateProperties=function(e,t,i,r){for(var n in i)if(t[n]!==void 0){var a=t[n]||0,o=i[n],l=Array.isArray(e[n]),c=Array.isArray(o),h=!l&&c;h?e[n]=this._interpolationFunction(o,r):typeof o=="object"&&o?this._updateProperties(e[n],a,o,r):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(e[n]=a+(o-a)*r))}},s.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},s.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},s})();Ah.nextId;var Pi=Jo;Pi.getAll.bind(Pi),Pi.removeAll.bind(Pi),Pi.add.bind(Pi),Pi.remove.bind(Pi),Pi.update.bind(Pi);var Qo={Easing:as,Tween:M_};function T_(){return new mo}function S_(s,e){s.appendChild(e.domElement)}function E_(s,e,t){var i=new Object;i.visible=!0;let r=null,n,a,o=[];i.init=function(){n||(c(),h(),u())},i.Hide=function(){n.style.display="none",i.visible=!1},i.Show=function(){n.style.display="block",i.visible=!0},i.RenderScene=function(){i.camera.quaternion.copy(e.camera.quaternion);let g=new w(0,0,-1).clone().applyMatrix4(e.camera.matrixWorld.clone()),v=e.camera.position.clone().sub(g.clone()).setLength(100);i.camera.position.copy(v),i.camera.lookAt(new w),i.sceneOrtho.renderer.render(i.sceneOrtho,i.camera)},i.ToggleDirectionView=function(g){console.log(g);var v=new w(0,0,0);g=="top"?v=new w(0,1,0):g=="down"?v=new w(0,-1,0):g=="front"?v=new w(0,0,1):g=="left"?v=new w(-1,0,0):g=="back"?v=new w(0,0,-1):g=="right"?v=new w(1,0,0):g=="top_front"?v=new w(1,1,0):g=="top_left"?v=new w(0,1,-1):g=="top_back"?v=new w(-1,1,0):g=="top_right"?v=new w(0,1,1):g=="down_front"?v=new w(1,-1,0):g=="down_left"?v=new w(0,-1,-1):g=="down_back"?v=new w(-1,-1,0):g=="down_right"?v=new w(0,-1,1):g=="front_right"?v=new w(1,0,1):g=="right_back"?v=new w(-1,0,1):g=="back_left"?v=new w(-1,0,-1):g=="left_front"?v=new w(1,0,-1):g=="top_left_front"?v=new w(1,1,-1):g=="top_front_right"?v=new w(1,1,1):g=="top_right_back"?v=new w(-1,1,1):g=="top_back_left"?v=new w(-1,1,-1):g=="button_left_front"?v=new w(1,-1,-1):g=="button_front_right"?v=new w(1,-1,1):g=="button_right_back"?v=new w(-1,1,1):g=="button_back_left"&&(v=new w(-1,-1,-1));var f=s.octreeBox.getBoundingBox(),p=f.min,y=f.max,_=p.clone().add(y.clone()).multiplyScalar(.5),E=_.clone().add(v.multiplyScalar(1*y.distanceTo(p)));l(e.camera.position,E,s.controls.target.clone(),_)},i.GetCameraPose=function(){var g=e.camera.quaternion,v=e.camera.position,f=s.controls.target,p={quaternion:g,position:v,target:f};return p},i.ReductionCameraPose=function(g,v=1e3,f){var p=new li(g.quaternion._x,g.quaternion._y,g.quaternion._z,g.quaternion._w),y=new w(g.position.x,g.position.y,g.position.z),_=new w(g.target.x,g.target.y,g.target.z);let E=!1;l(e.camera.position,y,s.controls.target.clone(),_,e.camera.quaternion,p,v,R=>{f&&(E||(f(R),E=!0))}),f&&setTimeout(()=>{E||(f(!0),E=!0)},v+10)},i.CameraGoHome=function(){var g=s.octreeBox.getBoundingBox(),v=g.min.clone().add(g.max.clone()).multiplyScalar(.5);let f=new w(1,1,1);var p=v.clone().add(f.multiplyScalar(1*g.max.distanceTo(g.min)));l(e.camera.position,p,s.controls.target.clone(),v)};function l(g,v,f,p,y,_,E=1e3,R){var T;y&&_?(T=new Qo.Tween({x1:g.x,y1:g.y,z1:g.z,x2:f.x,y2:f.y,z2:f.z,_x:y._x,_y:y._y,_z:y._z,_w:y._w}),T.to({x1:v.x,y1:v.y,z1:v.z,x2:p.x,y2:p.y,z2:p.z,_x:_._x,_y:_._y,_z:_._z,_w:_._w},E)):(T=new Qo.Tween({x1:g.x,y1:g.y,z1:g.z,x2:f.x,y2:f.y,z2:f.z}),T.to({x1:v.x,y1:v.y,z1:v.z,x2:p.x,y2:p.y,z2:p.z},E)),T.onUpdate(function(I){y&&_?(e.camera.quaternion._x=I._x,e.camera.quaternion._y=I._y,e.camera.quaternion._z=I._z,e.camera.quaternion._w=I._w):s.controls.auto=!0,e.camera.position.x=I.x1,e.camera.position.y=I.y1,e.camera.position.z=I.z1,s.controls.target.x=I.x2,s.controls.target.y=I.y2,s.controls.target.z=I.z2,s.controls.update(),i.RenderScene()}),T.onComplete(function(I){s.controls.auto=!1,i.RenderScene(),R&&R(!0),cancelAnimationFrame(r),r=null}),T.easing(Qo.Easing.Cubic.InOut);function A(I){r=requestAnimationFrame(A),T.update()}T.start(),A()}function c(){n=document.createElement("div"),n.className="ViewCube",t.appendChild(n),a=document.createElement("div"),a.className="ViewAttr",t.appendChild(a)}function h(){i.sceneOrtho=T_();var f=window.innerWidth,p=window.innerHeight,g=f>p?f/p:p/f,v=150;i.camera=new pr(v*g/-2,v*g/2,2*v/2,1.4*v/-2,.01,1e4);var f=n.clientWidth,p=n.clientHeight,y=new An({alpha:!0});y.setSize(f,p),y.setClearAlpha(0),i.sceneOrtho.renderer=y;let _=new Uc(16777215,.8);i.sceneOrtho.add(_),S_(n,y)}function u(){let g=[{label:"右",icon:"cube/cn_right.png"},{label:"左",icon:"cube/cn_left.png"},{label:"顶",icon:"cube/cn_top.png"},{label:"底",icon:"cube/cn_bottom.png"},{label:"前",icon:"cube/cn_front.png"},{label:"后",icon:"cube/cn_back.png"}];var v=[];for(const p of g)v.push(new kt({color:16777215,map:new Ac().load(p.icon)}));new Id({color:255});var f=new rt(new ur(110,110,110),v);i.sceneOrtho.add(f),d(122),n.addEventListener("mousedown",p=>{var y={};y.x=p.offsetX/n.clientWidth*2-1,y.y=-(p.offsetY/n.clientHeight)*2+1;var _=new Oc;_.setFromCamera(y,i.camera);const E=_.intersectObjects(o,!1);E.length>0&&i.ToggleDirectionView(E[0].object.name)}),n.addEventListener("mousemove",p=>{var y={};y.x=p.offsetX/n.clientWidth*2-1,y.y=-(p.offsetY/n.clientHeight)*2+1;var _=new Oc;_.setFromCamera(y,i.camera);const E=_.intersectObjects(o,!1);for(var R of o)R.material.opacity=.01;E.length>0&&(E[0].object.material.opacity=.2)})}function d(g){for(var v=g*.5-20,f=[{name:"right",a:30,b:75,c:75,point:new w(v,0,0)},{name:"back",a:75,b:75,c:30,point:new w(0,0,-v)},{name:"left",a:30,b:75,c:75,point:new w(-v,0,0)},{name:"front",a:75,b:75,c:30,point:new w(0,0,v)},{name:"top",a:75,b:30,c:75,point:new w(0,v,0)},{name:"button",a:75,b:30,c:75,point:new w(0,-v,0)}],p=[{name:"top_right_back",a:30,b:30,c:30,point:new w(-v,v,v)},{name:"button_front_right",a:30,b:30,c:30,point:new w(-v,-v,v)},{name:"top_front_right",a:30,b:30,c:30,point:new w(v,v,v)},{name:"button_right_back",a:30,b:30,c:30,point:new w(v,-v,v)},{name:"top_back_left",a:30,b:30,c:30,point:new w(-v,v,-v)},{name:"button_back_left",a:30,b:30,c:30,point:new w(-v,-v,-v)},{name:"top_left_front",a:30,b:30,c:30,point:new w(v,v,-v)},{name:"button_left_front",a:30,b:30,c:30,point:new w(v,-v,-v)}],y=[{name:"top_front",a:30,b:30,c:75,point:new w(v,v,0)},{name:"top_right",a:75,b:30,c:30,point:new w(0,v,v)},{name:"top_back",a:30,b:30,c:75,point:new w(-v,v,0)},{name:"top_left",a:75,b:30,c:30,point:new w(0,v,-v)},{name:"button_front",a:30,b:30,c:75,point:new w(v,-v,0)},{name:"button_right",a:75,b:30,c:30,point:new w(0,-v,v)},{name:"button_back",a:30,b:30,c:75,point:new w(-v,-v,0)},{name:"button_left",a:75,b:30,c:30,point:new w(0,-v,-v)},{name:"front_right",a:30,b:75,c:30,point:new w(v,0,v)},{name:"right_back",a:30,b:75,c:30,point:new w(-v,0,v)},{name:"back_left",a:30,b:75,c:30,point:new w(-v,0,-v)},{name:"left_front",a:30,b:75,c:30,point:new w(v,0,-v)}],_=0;_<f.length;_++)o.push(m(f[_]));for(var _=0;_<p.length;_++)o.push(m(p[_]));for(var _=0;_<y.length;_++)o.push(m(y[_]))}function m(g){const v=new ur(g.a,g.b,g.c),f=new kt({color:"blue",transparent:!0,opacity:.01}),p=new Le().makeTranslation(g.point.x,g.point.y,g.point.z);let y=v.applyMatrix4(p),_=new rt(y,f);return _.name=g.name,i.sceneOrtho.add(_),_}return i}class Ph{constructor(e,t){this.object=e,this.id=t}get uuid(){return this.object.uuid}get name(){return this.object.name}set name(e){this.object.name=e}get visible(){return this.object.visible}set visible(e){this.object.visible=e}getBoundingBox(){const e=new At().setFromObject(this.object);return{min:e.min,max:e.max}}setMatrix(e){this.object.matrix.fromArray(e),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale)}}let w_=class{constructor(s,e,t){this.manager=s,this.scene=e,this.clippingManager=t}models=new Map;async loadModel(s,e){const t=await this.manager.loadGLTF(s),i=e?.id||t.uuid;t.name=i,e?.position&&t.position.fromArray(e.position),e?.scale&&t.scale.fromArray(e.scale),e?.rotation&&t.rotation.setFromVector3(new w(...e.rotation));const r=new Ph(t,i);return this.models.set(i,r),this.clippingManager?.refresh(),r}unloadModel(s){const e=this.models.get(s);e&&e instanceof Ph&&(this.scene.remove(e.object),this.models.delete(s))}getAllModels(){return Array.from(this.models.values())}getModel(s){return this.models.get(s)}},C_=class{constructor(s){this.manager=s}setView(s,e){this.manager.setView(s)}fitToView(s,e){console.log("[V1] fitToView not fully implemented in manager, resetting camera"),this.manager.camera.position.set(20,20,20),this.manager.camera.lookAt(0,0,0),this.manager.controls.update()}goHome(s){this.manager.camera.position.set(20,20,20),this.manager.camera.lookAt(0,0,0),this.manager.controls.update()}setProjection(s){console.warn("[V1] Projection switching not supported in V1 CameraManager")}setNavigationMode(s){s===Nn.PanOnly?this.manager.controls.enableRotate=!1:this.manager.controls.enableRotate=!0}getState(){return{position:this.manager.camera.position.toArray(),target:this.manager.controls.target.toArray(),up:this.manager.camera.up.toArray(),projection:ss.Perspective}}restoreState(s,e){this.manager.camera.position.fromArray(s.position),this.manager.camera.up.fromArray(s.up),this.manager.controls.target.fromArray(s.target),this.manager.controls.update()}},R_=class{constructor(s,e){this.manager=s,this.scene=e}getSelection(){return console.warn("[V1] getSelection not fully supported by InteractionManager"),[]}select(s){const e=[];this.scene.traverse(t=>{t instanceof rt&&s.includes(t.name)&&e.push(t)}),this.manager.highlight(e)}addSelection(s){this.select(s)}removeSelection(s){this.manager.clearHighlight()}clearSelection(){this.manager.clearHighlight()}getHiddenComponents(){const s=[];return this.scene.traverse(e=>{e.visible||s.push(e.name)}),s}setVisibility(s,e){this.manager.setVisibility(s,e)}isolate(s){this.scene.traverse(e=>e.visible=!1),this.setVisibility(s,!0)}clearIsolation(){this.scene.traverse(s=>s.visible=!0)}setColor(s,e){console.warn("[V1] setColor not implemented")}restoreColor(s){console.warn("[V1] restoreColor not implemented")}setOpacity(s,e){console.warn("[V1] setOpacity not implemented")}restoreOpacity(s){console.warn("[V1] restoreOpacity not implemented")}clearAllOverrides(){}getBoundingBox(s){let e;if(this.scene.traverse(t=>{t.name===s&&(e=t)}),e){const t=new At().setFromObject(e);return{min:t.min,max:t.max}}return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}}},A_=class{constructor(s,e){this.sceneManager=s,this.renderer=e}setBackgroundColor(s){this.sceneManager.setBackground(s)}setSkybox(s){const e=new Rc().load(s);this.sceneManager.scene.background=e}enableShadows(s){}enableAntialiasing(s){}enableAmbientOcclusion(s){}addSectionPlane(s,e){return""}removeSectionPlane(s){}clearSectionPlanes(){}enableSectioning(s){}captureScreen(s,e){return this.renderer.domElement.toDataURL()}getViewerConfig(){return{shadows:!1,ambientOcclusion:!1,sectioning:!1}}getRenderStatistics(){const s=this.renderer.info||{},e=s.render||{},t=s.memory||{};return{calls:e.calls||0,triangles:e.triangles||0,points:e.points||0,lines:e.lines||0,memory:{geometries:t.geometries||0,textures:t.textures||0}}}},P_=class{async getProperties(s){return[{name:"Identity Data",properties:[{name:"Element ID",value:s},{name:"Version",value:"V1 Engine"}]}]}async getPropertyValue(s,e){return"Unknown"}async getModelTree(s){return[{id:"root",name:"Model Root (V1)",type:"Model",hasChildren:!1}]}async search(s){return[]}},L_=class{activeTool=null;tools=new Map;activate(s,e){console.log(`[V1] Activating tool: ${s}`,e),this.activeTool=s}deactivate(){this.activeTool&&(console.log(`[V1] Deactivating tool: ${this.activeTool}`),this.activeTool=null)}getActiveTool(){return this.activeTool}registerTool(s,e){this.tools.set(s,e)}},D_=class{listeners=new Map;on(s,e){this.listeners.has(s)||this.listeners.set(s,[]),this.listeners.get(s).push(e)}off(s,e){if(!this.listeners.has(s))return;const t=this.listeners.get(s),i=t.indexOf(e);i!==-1&&t.splice(i,1)}trigger(s,e){this.listeners.has(s)&&this.listeners.get(s).forEach(t=>{try{t(e)}catch(i){console.error(`Error in event listener for ${s}:`,i)}})}},I_=class{container;renderer;composer=null;stats=null;engineState;sceneManager;cameraManager;loaderManager;interactionManager;outlineManager;selectionBoxManager=null;clippingManager;octreeBox;loader;cameraTool;components;data;viewer;tools;events;viewCube;scene;camera;models;controls;measure;animationId=null;constructor(s){const e=document.getElementById(s.containerId);if(!e)throw new Error(`Container ${s.containerId} not found`);this.container=e,this.models=[],this.engineState=new x_,this.sceneManager=new x0(s);const{width:t,height:i}=this.getContainerSize();this.cameraManager=new I0(this.container,t,i,this.engineState);try{this.renderer=new An({antialias:s.antialias??!0}),console.log("Engine: Using WebGPURenderer")}catch(r){console.warn("WebGPURenderer failed",r),this.renderer=new An({antialias:s.antialias??!0})}this.renderer.setSize(t,i),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=ll,this.renderer.toneMapping=$n,this.renderer.toneMappingExposure=1,this.renderer.localClippingEnabled=!0,this.container.appendChild(this.renderer.domElement),this.loaderManager=new m_(this.sceneManager.scene),this.outlineManager=new g_(this.sceneManager.scene,this.cameraManager.camera,t,i),this.interactionManager=new f_(this.sceneManager.scene,this.cameraManager.camera,this.renderer.domElement,this.engineState),this.selectionBoxManager=new v_(this.sceneManager.scene,this.cameraManager.camera,this.renderer.domElement,this.cameraManager.controls,this.outlineManager),this.clippingManager=new __(this.sceneManager.scene),setTimeout(()=>{this.clippingManager.enable()},1e3),this.events=new D_,this.interactionManager.setEventModule(this.events),this.loader=new w_(this.loaderManager,this.sceneManager.scene,this.clippingManager),this.cameraTool=new C_(this.cameraManager),this.components=new R_(this.interactionManager,this.sceneManager.scene),this.viewer=new A_(this.sceneManager,this.renderer),this.data=new P_,this.tools=new L_,this.scene=this.sceneManager.scene,this.scene.camera=this.cameraManager.camera,this.camera=this.cameraManager.camera,this.controls=this.cameraManager.controls,this.octreeBox=y_(this),this.viewCube=E_(this,this.scene,this.container),this.viewCube.init(),this.setupVisuals(),this.setupPostProcessing(),s.showStats!==!1&&this.initStats(),this.setupResizeObserver(),this.animate()}initStats(){this.stats=new _0,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)}toggleStats(s){s&&!this.stats?this.initStats():!s&&this.stats&&(this.container.removeChild(this.stats.dom),this.stats=null)}getVersion(){return"1.2.0 (WebGPU Experimental)"}setupVisuals(){const s=this.sceneManager.scene;s.children.filter(r=>r instanceof Rs).forEach(r=>s.remove(r));const e=new Ic(16777215,4.5);e.position.set(10,20,10),e.castShadow=!0,e.shadow.mapSize.width=4096,e.shadow.mapSize.height=4096,e.shadow.camera.near=.1,e.shadow.camera.far=500,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,s.add(e);const i=new Uc(4210752,.4);s.add(i),new e0().load("https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/equirectangular/royal_esplanade_1k.hdr",r=>{r.mapping=Fs,s.environment=r,s.environmentIntensity=1})}setupPostProcessing(){if(!this.renderer)return;const{width:s,height:e}=this.getContainerSize(),t=window.devicePixelRatio,i=this.sceneManager.scene,r=this.cameraManager.camera;this.composer=new n0(this.renderer),this.composer.setPixelRatio(t),this.composer.setSize(s,e);const n=new a0(i,r);this.composer.addPass(n);const a=new vi(i,r,s,e);a.output=vi.OUTPUT.Default,a.blendIntensity=1,a.updateGtaoMaterial&&a.updateGtaoMaterial({radius:3,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!1}),this.composer.addPass(a);const o=this.outlineManager.getPass();this.composer.addPass(o);const l=new is(new oe(s,e),.05,.1,.5);this.composer.addPass(l);const c=new d0;this.composer.addPass(c);const h=new Ho(p0);h.material.uniforms.resolution.value.x=1/(s*t),h.material.uniforms.resolution.value.y=1/(e*t),this.composer.addPass(h)}resize(){const{width:s,height:e}=this.getContainerSize(),t=window.devicePixelRatio;if(this.cameraManager.updateAspect(s,e),this.renderer.setSize(s,e),this.renderer.setPixelRatio(t),this.outlineManager&&this.outlineManager.resize(s,e),this.composer){this.composer.setPixelRatio(t),this.composer.setSize(s,e);const i=this.composer.passes.find(r=>r instanceof Ho&&r.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(s*t),i.material.uniforms.resolution.value.y=1/(e*t))}}getContainerSize(){return{width:this.container.clientWidth,height:this.container.clientHeight}}setupResizeObserver(){new ResizeObserver(()=>{this.resize()}).observe(this.container)}animate=()=>{this.animationId=requestAnimationFrame(this.animate),this.viewCube.RenderScene(),this.stats&&this.stats.begin(),this.cameraManager.tick(),this.composer?this.composer.render():this.renderer.renderAsync?this.renderer.renderAsync(this.sceneManager.scene,this.cameraManager.camera):this.renderer.render(this.sceneManager.scene,this.cameraManager.camera),this.stats&&this.stats.end()};dispose(){this.animationId&&cancelAnimationFrame(this.animationId),this.selectionBoxManager&&this.selectionBoxManager.dispose(),this.renderer.dispose(),this.container.innerHTML=""}};class Lh{constructor(e,t,i){this.object=e,this.id=t,this.uuid=i,this.object.name=t}get name(){return this.object.name}set name(e){this.object.name=e}get visible(){return this.object.visible}set visible(e){this.object.visible=e}getBoundingBox(){const e=new At().setFromObject(this.object);return{min:e.min,max:e.max}}setMatrix(e){this.object.matrix.fromArray(e),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale)}}class U_{scene;gltfLoader;models=new Map;constructor(e){this.scene=e,this.gltfLoader=new Mh}async loadModel(e,t){return new Promise((i,r)=>{this.gltfLoader.load(e,n=>{const a=n.scene,o=t?.id||Va.generateUUID();t?.position&&a.position.fromArray(t.position),t?.scale&&a.scale.fromArray(t.scale),t?.rotation&&a.rotation.setFromVector3(new w(...t.rotation)),this.scene.add(a);const l=new Lh(a,o,a.uuid);this.models.set(o,l),i(l)},n=>{t?.onProgress&&t.onProgress(n.loaded/n.total*100)},n=>r(n))})}unloadModel(e){const t=this.models.get(e);t&&t instanceof Lh&&(this.scene.remove(t.object),this.models.delete(e))}getAllModels(){return Array.from(this.models.values())}getModel(e){return this.models.get(e)}}class N_{camera;controls;container;constructor(e,t,i){this.container=e,this.camera=new Tt(75,t/i,.1,1e3),this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.controls=new yh(this.camera,this.container),this.controls.enableDamping=!0}getCamera(){return this.camera}update(){this.controls.update()}updateAspect(e,t){if(this.camera instanceof Tt)this.camera.aspect=e/t,this.camera.updateProjectionMatrix();else if(this.camera instanceof pr){const i=e/t,r=20;this.camera.left=-r*i/2,this.camera.right=r*i/2,this.camera.top=r/2,this.camera.bottom=-r/2,this.camera.updateProjectionMatrix()}}setView(e,t){switch(e){case rs.Top:this.camera.position.set(0,20,0);break;case rs.Front:this.camera.position.set(0,0,20);break;default:console.warn("View not fully implemented:",e)}this.camera.lookAt(0,0,0),this.controls.update()}fitToView(e,t){}goHome(e){this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.controls.update()}setProjection(e){e===ss.Perspective&&!(this.camera instanceof Tt)||e===ss.Orthographic&&this.camera instanceof pr}setNavigationMode(e){e===Nn.Orbit?(this.controls.enabled=!0,this.controls.enableRotate=!0):e===Nn.PanOnly&&(this.controls.enableRotate=!1)}getState(){const e=this.controls.target;return{position:this.camera.position.toArray(),target:e.toArray(),up:this.camera.up.toArray(),projection:this.camera instanceof Tt?ss.Perspective:ss.Orthographic}}restoreState(e,t){this.camera.position.fromArray(e.position),this.camera.up.fromArray(e.up),this.controls.target.fromArray(e.target),this.controls.update()}}class O_{scene;selectedIds=new Set;materialCache=new Map;constructor(e){this.scene=e}findObject(e){let t;return this.scene.traverse(i=>{i.name===e&&(t=i)}),t}getSelection(){return Array.from(this.selectedIds)}select(e){this.clearSelection(),this.addSelection(e)}addSelection(e){e.forEach(t=>{this.selectedIds.add(t),this.findObject(t)})}removeSelection(e){e.forEach(t=>this.selectedIds.delete(t))}clearSelection(){this.selectedIds.clear()}getHiddenComponents(){const e=[];return this.scene.traverse(t=>{t.visible||e.push(t.name)}),e}setVisibility(e,t){e.forEach(i=>{const r=this.findObject(i);r&&(r.visible=t)})}isolate(e){this.scene.traverse(t=>t.visible=!1),this.setVisibility(e,!0)}clearIsolation(){this.scene.traverse(e=>e.visible=!0)}setColor(e,t){e.forEach(i=>{const r=this.findObject(i);if(r&&r instanceof rt){this.materialCache.has(i)||this.materialCache.set(i,r.material);const n=new kt({color:t});r.material=n}})}restoreColor(e){e.forEach(t=>{const i=this.findObject(t);i&&this.materialCache.has(t)&&(i.material=this.materialCache.get(t),this.materialCache.delete(t))})}setOpacity(e,t){}restoreOpacity(e){}clearAllOverrides(){this.materialCache.forEach((e,t)=>{const i=this.findObject(t);i&&i instanceof rt&&(i.material=e)}),this.materialCache.clear()}getBoundingBox(e){const t=this.findObject(e);if(t){const i=new At().setFromObject(t);return{min:i.min,max:i.max}}return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}}}class B_{async getProperties(e){return[{name:"Identity Data",properties:[{name:"Element ID",value:e},{name:"Name",value:"Sample Element"}]}]}async getPropertyValue(e,t){return"Unknown"}async getModelTree(e){return[{id:"root",name:"Model Root",type:"Model",hasChildren:!0,children:[{id:"l1",name:"Level 1",type:"Level",hasChildren:!1}]}]}async search(e){return console.log("Searching for:",e),[]}}class F_{scene;renderer;_shadowsEnabled=!1;_aoEnabled=!1;_sectioningEnabled=!1;constructor(e,t){this.scene=e,this.renderer=t}setBackgroundColor(e){this.scene.background=new _e(e)}setSkybox(e){const t=new Rc().load(e);this.scene.background=t}enableShadows(e){this._shadowsEnabled=e,this.renderer.shadowMap.enabled=e,this.scene.traverse(t=>{t instanceof rt&&(t.castShadow=e,t.receiveShadow=e)})}enableAntialiasing(e){console.warn("Changing antialiasing at runtime requires recreating the WebGL context, which is complex. Ignored.")}enableAmbientOcclusion(e){this._aoEnabled=e,console.log("AO enabled:",e,"(Requires PostProcessing pass - not implemented in this basic kernel)")}addSectionPlane(e,t){const i=new wi(new w(...e),t);return this.renderer.clippingPlanes.push(i),"plane-"+(this.renderer.clippingPlanes.length-1)}removeSectionPlane(e){this.renderer.clippingPlanes.pop()}clearSectionPlanes(){this.renderer.clippingPlanes=[]}enableSectioning(e){this._sectioningEnabled=e,this.renderer.localClippingEnabled=e}captureScreen(e,t){return this.renderer.domElement.toDataURL()}getViewerConfig(){return{shadows:this._shadowsEnabled,ambientOcclusion:this._aoEnabled,sectioning:this._sectioningEnabled}}getRenderStatistics(){const e=this.renderer.info;return{calls:e.render.calls,triangles:e.render.triangles,points:e.render.points,lines:e.render.lines,memory:{geometries:e.memory.geometries,textures:e.memory.textures}}}}class k_{activeTool=null;tools=new Map;activate(e,t){console.log(`Activating tool: ${e}`,t),this.activeTool=e}deactivate(){this.activeTool&&(console.log(`Deactivating tool: ${this.activeTool}`),this.activeTool=null)}getActiveTool(){return this.activeTool}registerTool(e,t){this.tools.set(e,t)}}class z_{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}off(e,t){if(!this.listeners.has(e))return;const i=this.listeners.get(e),r=i.indexOf(t);r!==-1&&i.splice(r,1)}trigger(e,t){this.listeners.has(e)&&this.listeners.get(e).forEach(i=>{try{i(t)}catch(r){console.error(`Error in event listener for ${e}:`,r)}})}}class Dh{loader;cameraTool;components;data;viewer;tools;events;viewCube;container;scene;renderer;_cameraModule;animationId=null;constructor(e){const t=document.getElementById(e.containerId);if(!t)throw new Error(`Container ${e.containerId} not found`);this.container=t,this.scene=new mo,this.renderer=new An({antialias:e.antialias??!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.container.appendChild(this.renderer.domElement),this.events=new z_,this._cameraModule=new N_(this.container,this.container.clientWidth,this.container.clientHeight),this.cameraTool=this._cameraModule,this.loader=new U_(this.scene),this.components=new O_(this.scene),this.data=new B_,this.viewer=new F_(this.scene,this.renderer),this.tools=new k_,this.viewCube={show:()=>console.warn("[V2] ViewCube not implemented"),hide:()=>{},setDirection:()=>{},goHome:()=>{},isVisible:()=>!1,updateOptions:()=>{}},this.resize(),this.setupResizeObserver(),this.animate()}getVersion(){return"2.0.0"}resize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this._cameraModule.updateAspect(e,t)}dispose(){this.animationId&&cancelAnimationFrame(this.animationId),this.renderer.dispose(),this.container.innerHTML=""}setupResizeObserver(){new ResizeObserver(()=>{this.resize()}).observe(this.container)}animate=()=>{this.animationId=requestAnimationFrame(this.animate),this._cameraModule.update(),this.renderer.render(this.scene,this._cameraModule.getCamera())}}function H_(s){const e=s.version||"v1";switch(e){case"v2":return new Dh(s);case"v1":return new I_(s);default:return console.warn(`Version '${e}' not found. Falling back to v2.`),new Dh(s)}}class V_{engine=null;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e){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:e.backgroundColor??1710618,version:e.version??"v1",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{const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,version:this.options.version,showStats:this.options.showStats,showViewCube:this.options.showViewCube};if(this.engine=H_(e),!this.engine)throw new Error("Failed to create engine instance");this._isInitialized=!0,this.unsubscribeTheme=vt.subscribe(t=>{this.setTheme(t)}),this.setTheme(vt.getTheme())}catch(e){throw console.error("[Engine] Failed to initialize engine:",e),this._isInitialized=!1,e}}setTheme(e){if(!this._isInitialized||!this.engine)return;let t;e.name==="dark"?t=1710618:e.name==="light"?t=16119285:t=this.options.backgroundColor??1710618,this.engine&&typeof this.engine.setBackgroundColor=="function"?this.engine.setBackgroundColor(t):this.engine&&this.engine.scene&&this.engine.scene.background&&this.engine.scene.background.setHex(t)}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){console.error("[Engine] Model URL is required.");return}this.engine.loader.loadModel(e,t)}getEngine(){return this.engine}destroy(){this._isDestroyed||(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1)}}class G_{element;content=null;isVisible=!1;onCloseCallback;options;mouseDownTime=0;CLICK_THRESHOLD=200;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())};handleContainerMouseUp=e=>{e.button!==2||Date.now()-this.mouseDownTime>this.CLICK_THRESHOLD||this.options?.onContext&&this.options.onContext(e)};handleContainerContextMenu=e=>{e.preventDefault()};setOnClose(e){this.onCloseCallback=e}mount(e){this.unmountContent(),this.content=e,this.element.appendChild(e.getElement())}unmountContent(){this.content&&(this.content.destroy(),this.element.innerHTML="",this.content=null)}show(e,t){this.element.classList.add("visible"),this.isVisible=!0,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`;const i=this.element.getBoundingClientRect(),r=window.innerWidth,n=window.innerHeight;let a=e,o=t;e+i.width>r&&(a=e-i.width),t+i.height>n&&(o=t-i.height),this.element.style.left=`${a}px`,this.element.style.top=`${o}px`}hide(){this.element.classList.remove("visible"),this.isVisible=!1,this.unmountContent(),this.onCloseCallback&&this.onCloseCallback()}handleGlobalClick=e=>{this.isVisible&&(this.element.contains(e.target)||this.hide())}}class el{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=ri.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=vt.subscribe(e=>{this.setTheme(e)})}setTheme(e){const t=this.element.style;t.setProperty("--bim-ui_bg_color",e.panelBackground),t.setProperty("--bim-ui_text_primary",e.textPrimary),t.setProperty("--bim-ui_border_color",e.border),t.setProperty("--bim-ui_bg_hover",e.componentHover)}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}render(){const{items:e,groupOrder:t}=this.options,i=new Map,r="default";e.forEach(a=>{const o=a.group||r;i.has(o)||i.set(o,[]),i.get(o).push(a)});let n=[];if(t){n=t.filter(a=>i.has(a));for(const a of i.keys())n.includes(a)||n.push(a)}else n=Array.from(i.keys());n.forEach((a,o)=>{if(o>0){const c=document.createElement("li");c.className="bim-menu-divider",this.element.appendChild(c)}const l=i.get(a);l.sort((c,h)=>(c.order||0)-(h.order||0)),l.forEach(c=>{c.visible!==!1&&this.element.appendChild(this.createItemElement(c))})})}createItemElement(e){const t=document.createElement("li"),i=!e.disabled;t.className=`bim-menu-item ${i?"":"disabled"}`;const r=document.createElement("div");r.className="bim-menu-item-icon",e.icon&&(r.innerHTML=e.icon),t.appendChild(r);const n=document.createElement("div");n.className="bim-menu-item-label",n.textContent=gt(e.label),t.appendChild(n);const a=e.children,o=a&&a.length>0;if(o){const l=document.createElement("div");l.className="bim-menu-item-arrow",l.innerHTML='<svg viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',t.appendChild(l),t.addEventListener("mouseenter",()=>this.openSubMenu(e,t))}else t.addEventListener("mouseenter",()=>this.closeSubMenu());return i&&t.addEventListener("click",l=>{l.stopPropagation(),console.log(`[BimMenu] Clicked item: ${e.id}`),o||(e.onClick?(console.log(`[BimMenu] Executing onClick for ${e.id}`),e.onClick()):console.warn(`[BimMenu] No onClick handler for ${e.id}`))}),t}openSubMenu(e,t){const i=e.children;if(!i||i.length===0)return;this.closeSubMenu();const r=document.createElement("div");r.style.position="fixed",r.style.zIndex="10001";const n=t.getBoundingClientRect();r.style.top=`${n.top}px`,r.style.left=`${n.right}px`,r.addEventListener("mousedown",l=>l.stopPropagation());const a=new el({items:i});a.init(),r.appendChild(a.element),document.body.appendChild(r),this.activeSubMenu={menu:a,container:r};const o=r.getBoundingClientRect();o.right>window.innerWidth&&(r.style.left=`${n.left-o.width}px`)}closeSubMenu(){this.activeSubMenu&&(this.activeSubMenu.menu.destroy(),this.activeSubMenu.container.remove(),this.activeSubMenu=null)}}class Ih extends ji{container;rightKeyPanel;contextHandlers=[];constructor(e,t){super(e),this.container=t,this.rightKeyPanel=new G_({zIndex:9e3,container:this.container,onContext:this.handleContextMenu}),this.rightKeyPanel.init()}destroy(){this.rightKeyPanel.destroy()}registerHandler(e){this.contextHandlers.push(e)}showMenu(e,t,i,r){if(!i||i.length===0)return;const n=new el({items:i,groupOrder:r});n.init(),this.rightKeyPanel.mount(n),this.rightKeyPanel.show(e,t)}hide(){this.rightKeyPanel.hide()}handleContextMenu=e=>{let t=null;for(const i of this.contextHandlers){const r=i(e);r&&r.length>0&&(t||(t=[]),t=t.concat(r))}t&&t.length>0?this.showMenu(e.clientX,e.clientY,t):this.hide()}}const W_=s=>({id:"infoMenu",label:"menu.info",group:"info",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M12 7q.425 0 .713-.288T13 6t-.288-.712T12 5t-.712.288T11 6t.288.713T12 7m0 8q.425 0 .713-.288T13 14v-4q0-.425-.288-.712T12 9t-.712.288T11 10v4q0 .425.288.713T12 15m-6 3l-2.3 2.3q-.475.475-1.088.213T2 19.575V4q0-.825.588-1.412T4 2h16q.825 0 1.413.588T22 4v12q0 .825-.587 1.413T20 18z"/></svg>',onClick:()=>{console.log("dianjile"),s.dialog?.showInfoDialog(),s.engine?.rightKey?.hide()}}),j_=s=>({id:"fourMenu",label:"menu.info",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M12 7q.425 0 .713-.288T13 6t-.288-.712T12 5t-.712.288T11 6t.288.713T12 7m0 8q.425 0 .713-.288T13 14v-4q0-.425-.288-.712T12 9t-.712.288T11 10v4q0 .425.288.713T12 15m-6 3l-2.3 2.3q-.475.475-1.088.213T2 19.575V4q0-.825.588-1.412T4 2h16q.825 0 1.413.588T22 4v12q0 .825-.587 1.413T20 18z"/></svg>',onClick:()=>{console.log("dianjile"),s.dialog?.showInfoDialog(),s.engine?.rightKey?.hide()}}),X_=s=>({id:"infoMenu",label:"menu.info",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M12 7q.425 0 .713-.288T13 6t-.288-.712T12 5t-.712.288T11 6t.288.713T12 7m0 8q.425 0 .713-.288T13 14v-4q0-.425-.288-.712T12 9t-.712.288T11 10v4q0 .425.288.713T12 15m-6 3l-2.3 2.3q-.475.475-1.088.213T2 19.575V4q0-.825.588-1.412T4 2h16q.825 0 1.413.588T22 4v12q0 .825-.587 1.413T20 18z"/></svg>',onClick:()=>{console.log("dianjile"),s.dialog?.showInfoDialog(),s.engine?.rightKey?.hide()}}),q_=s=>({id:"homeMenu",label:"menu.home",group:"home",children:[X_(s),j_(s)],icon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M12 7q.425 0 .713-.288T13 6t-.288-.712T12 5t-.712.288T11 6t.288.713T12 7m0 8q.425 0 .713-.288T13 14v-4q0-.425-.288-.712T12 9t-.712.288T11 10v4q0 .425.288.713T12 15m-6 3l-2.3 2.3q-.475.475-1.088.213T2 19.575V4q0-.825.588-1.412T4 2h16q.825 0 1.413.588T22 4v12q0 .825-.587 1.413T20 18z"/></svg>',onClick:()=>{s.dialog?.showInfoDialog(),s.engine?.rightKey?.hide()}});class Y_ extends ji{container;engineInstance=null;rightKey=null;constructor(e,t){super(e),this.container=t}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 V_({container:this.container,...e}),this.engineInstance.init(),this.rightKey=new Ih(this.engine,this.container),this.rightKey.registerHandler(t=>[W_(this.engine),q_(this.engine)]),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||!this.engineInstance.isInitialized()){console.error("[EngineManager] 3D Engine not initialized. Please call initialize() first.");return}this.engineInstance.loadModel(e,t)}getEngine(){return this.engineInstance?this.engineInstance.getEngine():(console.warn("[EngineManager] 3D Engine not initialized."),null)}destroy(){this.engineInstance&&(this.engineInstance.destroy(),this.engineInstance=null),this.rightKey&&(this.rightKey.destroy(),this.rightKey=null)}}var mt=(s=>(s[s.Unchecked=0]="Unchecked",s[s.Checked=1]="Checked",s[s.Indeterminate=2]="Indeterminate",s))(mt||{});class K_{config;element;children=[];parent=null;checkState=mt.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,i){this.config=e,this.onExpandChange=i.onExpand,this.onCheckChange=i.onCheck,this.onNodeClick=i.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?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 i=this.config.children&&this.config.children.length>0;if(i?this.config.expanded&&this.switcherEl.classList.add("is-expanded"):this.switcherEl.classList.add("is-hidden"),this.switcherEl.addEventListener("click",n=>{n.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",n=>{n.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const n=document.createElement("span");n.className="bim-tree-icon",n.innerHTML=this.config.icon.includes("<svg")?this.config.icon:`<img src="${this.config.icon}" />`,this.contentEl.appendChild(n)}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",n=>{n.stopPropagation()}),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",n=>{if(n.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 r=e.indent||24;return this.childrenContainer.style.paddingLeft=`${r}px`,this.config.expanded&&i&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==mt.Checked;this.setChecked(e?mt.Checked:mt.Unchecked,!0)}setChecked(e,t=!1){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 Z_{element;contentElement;searchInput=null;searchResults=null;options;nodeMap=new Map;rootNodes=[];selectedNode=null;unsubscribeLocale=null;unsubscribeTheme=null;clickOutsideHandler=null;onNodeCheck;onNodeSelect;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.onNodeExpand&&(this.onNodeExpand=e.onNodeExpand)}createSearchDOM(){const e=document.createElement("div");e.className="bim-tree-search";const t=document.createElement("div");t.className="bim-tree-search-wrapper";const i=document.createElement("span");i.className="bim-tree-search-icon",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m21 21l-4.343-4.343m0 0A8 8 0 1 0 5.343 5.343a8 8 0 0 0 11.314 11.314"/></svg>',t.appendChild(i),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=gt(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",r=>{const n=r.target.value;this.handleSearch(n)}),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=r=>{this.searchResults&&!this.searchResults.contains(r.target)&&!this.searchInput?.contains(r.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=ri.subscribe(()=>this.setLocales()),this.unsubscribeTheme=vt.subscribe(e=>this.setTheme(e)),this.setTheme(vt.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],i=e.toLowerCase();this.nodeMap.forEach(r=>{const n=r.config.label;n.toLowerCase().includes(i)&&t.push({node:r,label:n,path:this.getNodePath(r)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let i=e.parent;for(;i;)t.unshift(i.config.label),i=i.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const i=document.createElement("div");i.className="bim-tree-search-item";const r=document.createElement("span");r.className="bim-tree-search-item-title",r.textContent=t.label;const n=document.createElement("span");n.className="bim-tree-search-item-path",n.textContent=t.path,i.appendChild(r),t.path&&i.appendChild(n),i.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(i)});this.searchResults.classList.add("is-visible")}}revealNode(e){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),setTimeout(()=>{e.element.scrollIntoView({behavior:"smooth",block:"center"})},100)}setTheme(e){const t=this.element.style;t.setProperty("--bim-ui_bg_color",e.panelBackground),t.setProperty("--bim-ui_text_primary",e.textPrimary),t.setProperty("--bim-ui_text_secondary",e.textSecondary||"#999"),t.setProperty("--bim-ui_border_color",e.border),t.setProperty("--bim-ui_bg_hover",e.componentHover),t.setProperty("--bim-primary_color",e.primary)}setLocales(){this.nodeMap.forEach(e=>e.updateLabel()),this.searchInput&&(this.searchInput.placeholder=gt(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.element.remove(),this.selectedNode=null}render(){this.contentElement.innerHTML="",this.nodeMap.clear(),this.rootNodes=[],this.options.data.forEach(e=>{this.createNodeRecursively(e,null)})}createNodeRecursively(e,t){e.expanded===void 0&&(e.expanded=this.options.defaultExpandAll);const i=new K_(e,this.options,{onExpand:r=>{this.onNodeExpand&&this.onNodeExpand(r)},onCheck:r=>this.handleNodeCheck(r),onClick:r=>this.handleNodeSelect(r)});this.nodeMap.set(e.id,i),t?t.appendChild(i):(this.rootNodes.push(i),this.contentElement.appendChild(i.element)),e.children&&e.children.length>0&&e.children.forEach(r=>{this.createNodeRecursively(r,i)})}handleNodeSelect(e){this.selectedNode&&this.selectedNode!==e&&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 i=(n,a)=>{n.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,mt.Checked):i(e,mt.Unchecked);let r=e.parent;for(;r;){if(r.config.disabled){r=r.parent;continue}const n=r.children,a=n.every(l=>l.checkState===mt.Checked),o=n.every(l=>l.checkState===mt.Unchecked);a?r.setChecked(mt.Checked,!1):o?r.setChecked(mt.Unchecked,!1):r.setChecked(mt.Indeterminate,!1),r=r.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const i=this.nodeMap.get(e);i&&i.setChecked(t?mt.Checked:mt.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===mt.Checked||e&&i.checkState===mt.Indeterminate)&&t.push(i.config)}),t}}class Uh{element;navElement;contentElement;options;activeId;tabMap=new Map;panelMap=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(vt.getTheme()),this.unsubscribeLocale=ri.subscribe(()=>this.setLocales()),this.unsubscribeTheme=vt.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const i=t.dataset.id;!i||this.tabMap.get(i)?.disabled||this.activateTab(i)},this.navElement.addEventListener("click",this.navClickHandler),this.options.tabs.forEach(e=>{const t=document.createElement("button");if(t.type="button",t.className="bim-tab__item",t.dataset.id=e.id,t.setAttribute("role","tab"),t.id=`tab-${e.id}`,t.setAttribute("aria-selected",`${e.id===this.activeId}`),e.disabled&&(t.disabled=!0,t.setAttribute("aria-disabled","true"),t.classList.add("is-disabled")),e.icon){const r=document.createElement("span");r.className="bim-tab__icon",r.innerHTML=e.icon,t.appendChild(r)}const i=document.createElement("span");i.className="bim-tab__title",i.textContent=this.resolveTitle(e.title),t.appendChild(i),e.id===this.activeId&&t.classList.add("is-active"),this.navElement.appendChild(t)})}renderPanels(){this.contentElement.innerHTML="",this.panelMap.clear(),this.options.tabs.forEach(e=>{const t=document.createElement("div");t.className="bim-tab__panel",t.dataset.id=e.id,t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",`tab-${e.id}`),e.content instanceof HTMLElement?t.appendChild(e.content):typeof e.content=="string"&&(t.innerHTML=e.content),e.id===this.activeId?t.classList.add("is-active"):t.style.display="none",this.panelMap.set(e.id,t),this.contentElement.appendChild(t)})}activateTab(e){if(this.activeId===e)return;const t=this.tabMap.get(e);if(!t||t.disabled)return;this.activeId=e,this.navElement.querySelectorAll(".bim-tab__item").forEach(r=>{const n=r.dataset.id===e;r.classList.toggle("is-active",n),r.setAttribute("aria-selected",`${n}`)}),this.panelMap.forEach((r,n)=>{const a=n===e;r.classList.toggle("is-active",a),r.style.display=a?"block":"none"}),this.options.onChange&&this.options.onChange(e,t)}setTheme(e){const t=this.element.style;t.setProperty("--bim-tab-bg",e.panelBackground),t.setProperty("--bim-tab-nav-bg",e.panelBackground),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.border),t.setProperty("--bim-tab-hover-bg",e.componentHover),t.setProperty("--bim-tab-active-bg",e.componentActive),t.setProperty("--bim-tab-icon",e.icon)}setLocales(){this.navElement.querySelectorAll(".bim-tab__item").forEach(t=>{const i=t.dataset.id;if(!i)return;const r=this.tabMap.get(i);if(!r)return;const n=t.querySelector(".bim-tab__title");n&&(n.textContent=this.resolveTitle(r.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.tabMap.clear(),this.element.remove()}resolveTitle(e){try{return gt(e)||e}catch{return e}}}const $_=[{id:"root",label:"全部构件",expanded:!0,clickAction:"expand",children:[{id:"level-1",label:"一层",expanded:!1,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M20.73 16.52V7.59a.7.7 0 0 0-.08-.33a.74.74 0 0 0-.36-.36l-8-3.58a.75.75 0 0 0-.62 0l-8 3.58a.8.8 0 0 0-.44.69v8.82a.83.83 0 0 0 .44.69l8 3.58a.72.72 0 0 0 .62 0l8-3.58a.77.77 0 0 0 .44-.58m-16-7.78l6.5 2.92v7.18l-6.5-2.91Zm8 2.92l6.5-2.92v7.19l-6.5 2.91ZM12 4.82l6.17 2.77L12 10.35L5.83 7.59Z"/></svg>',clickAction:"expand",children:[{id:"l1-wall",label:"墙体(128)"},{id:"l1-column",label:"柱(46)"},{id:"l1-beam",label:"梁(82)"},{id:"l1-slab",label:"楼板(12)"},{id:"l1-door",label:"门(24)"},{id:"l1-window",label:"窗(36)"}]},{id:"level-2",label:"二层",expanded:!1,clickAction:"expand",children:[{id:"l2-wall",label:"墙体(141)"},{id:"l2-column",label:"柱(52)"},{id:"l2-beam",label:"梁(90)"},{id:"l2-slab",label:"楼板(12)"},{id:"l2-door",label:"门(18)"},{id:"l2-window",label:"窗(40)"}]},{id:"level-3",label:"三层",expanded:!1,clickAction:"expand",children:[{id:"l3-wall",label:"墙体(136)"},{id:"l3-column",label:"柱(48)"},{id:"l3-beam",label:"梁(88)"},{id:"l3-slab",label:"楼板(12)"},{id:"l3-door",label:"门(16)"},{id:"l3-window",label:"窗(38)"}]},{id:"level-roof",label:"屋面层",expanded:!1,clickAction:"expand",children:[{id:"rf-slab",label:"屋面板(6)"},{id:"rf-beam",label:"屋面梁(24)"},{id:"rf-parapet",label:"女儿墙(18)"}]}]}];class J_ extends ji{toolbar=null;toolbarContainer=null;container;dialog=null;constructor(e,t){super(e),this.container=t,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="bim-construct-tree",this.container.appendChild(this.toolbarContainer),this.toolbar=new Fn({container:this.toolbarContainer,showLabel:!1,direction:"column",position:"top-left",align:"vertical",expand:"up"}),this.toolbar.init(),this.toolbar.setEngine(this.engine),this.toolbar.addGroup("construct-tree"),this.toolbar.addButton({id:"construct-tree-btn",groupId:"construct-tree",type:"button",label:"construct-tree",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M15 21v-3h-4V8H9v3H2V3h7v3h6V3h7v8h-7V8h-2v8h2v-3h7v8zM4 5v4zm13 10v4zm0-10v4zm0 4h3V5h-3zm0 10h3v-4h-3zM4 9h3V5H4z"/></svg>',onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}openConstructTreeDialog(){this.setVisible(!1);const e=new Z_({data:$_,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,renderActions:o=>'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="1.5" d="m14.828 6.343l2.829 2.829m1.414-1.415L8.464 18.364l-3.535.707l.707-3.536L16.243 4.93a2 2 0 0 1 2.828 2.828Z"/></svg>',onNodeCheck:o=>{console.log("onNodeCheck",o)},onNodeSelect:o=>{console.log("onNodeSelect",o)},onNodeExpand:o=>{console.log("onNodeExpand",o),this.dialog?.fitWidth()}});e.init();const t=document.createElement("div");t.className="construct-tab__panel-content";const i=document.createElement("div");i.className="construct-tab__panel-content";const r=document.createElement("div");r.className="construct-tab__panel-content",r.appendChild(e.element);const n=document.createElement("div");n.className="construct-tab__container",n.style.height="100%",n.style.overflow="hidden";const a=new Uh({container:n,tabs:[{id:"component",title:"tab.component",content:r},{id:"system",title:"tab.system",content:t},{id:"space",title:"tab.space",content:i}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});a.init(),this.dialog=this.engine.dialog.create({title:"constructTree.title",minWidth:320,height:420,content:n,position:{x:20,y:20},resizable:!1,onClose:()=>{a.destroy(),e.destroy(),this.setVisible(!0)}}),this.dialog?.fitWidth()}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null}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 Q_{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=gt(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=gt(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 Nh{element;options;items=new Map;activeIds=new Set;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e){this.options={bordered:!0,accordion:!1,...e},this.element=document.createElement("div"),this.element.className=`bim-collapse ${this.options.className||""}`,this.options.bordered||(this.element.style.border="none"),this.options.ghost&&this.element.classList.add("is-ghost");const t=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;t&&t.appendChild(this.element),this.options.activeIds&&this.options.activeIds.forEach(i=>this.activeIds.add(i)),this.init()}init(){this.options.items.forEach(e=>{const t=new Q_(e,this);this.items.set(e.id,t),this.element.appendChild(t.element),this.activeIds.has(e.id)&&t.setActive(!0)}),this.unsubscribeLocale=ri.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=vt.subscribe(e=>{this.setTheme(e)}),this.setTheme(vt.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-color",e.panelBackground),t.setProperty("--bim-border-color",e.border),t.setProperty("--bim-text-color",e.textPrimary),t.setProperty("--bim-header-bg-color",e.componentHover),t.setProperty("--bim-header-hover-bg-color",e.componentHover),t.setProperty("--bim-content-bg-color",e.panelBackground),t.setProperty("--bim-disabled-color",e.textSecondary)}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 tl{element;options;unsubscribeTheme=null;constructor(e){this.options={bordered:!1,...e},this.element=this.createDom();const t=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;t&&t.appendChild(this.element),this.init()}init(){this.applyCustomStyles(),this.renderItems(),this.unsubscribeTheme=vt.subscribe(e=>{this.setTheme(e)}),this.setTheme(vt.getTheme())}createDom(){const e=document.createElement("div");return e.className=`bim-description ${this.options.className||""}`,this.options.bordered&&e.classList.add("is-bordered"),e}applyCustomStyles(){const e=this.element.style;this.options.fontSize&&e.setProperty("--bim-desc-font-size",this.options.fontSize),this.options.labelColor&&e.setProperty("--bim-desc-label-color",this.options.labelColor),this.options.valueColor&&e.setProperty("--bim-desc-value-color",this.options.valueColor),this.options.labelPadding&&e.setProperty("--bim-desc-label-padding",this.options.labelPadding),this.options.valuePadding&&e.setProperty("--bim-desc-value-padding",this.options.valuePadding)}renderItems(){this.element.innerHTML="",this.options.items.forEach(e=>{const t=document.createElement("div");t.className=`bim-description-item ${e.className||""}`;const i=document.createElement("div");i.className="bim-description-label",e.labelColor&&(i.style.color=e.labelColor),this.options.labelWidth&&(i.style.width=this.options.labelWidth),i.textContent=this.options.bordered?e.label:e.label+":";const r=document.createElement("div");r.className="bim-description-value",e.valueColor&&(r.style.color=e.valueColor),typeof e.value=="string"?r.innerHTML=e.value:r.appendChild(e.value),t.appendChild(i),t.appendChild(r),this.element.appendChild(t)})}setItems(e){this.options.items=e,this.renderItems()}setTheme(e){const t=this.element.style;t.setProperty("--bim-text-color",e.textPrimary),t.setProperty("--bim-label-color",e.textSecondary),t.setProperty("--bim-value-color",e.textPrimary),t.setProperty("--bim-border-color",e.border)}setLocales(){}destroy(){this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}}class e1 extends ji{dialogId="property-panel-dialog";constructor(e){super(e)}init(){document.addEventListener("bim-demo:open-property-panel",()=>{this.show()})}show(){if(!this.engine.dialog){console.warn("Dialog manager is not initialized");return}const e=360,t=document.body.clientWidth-e-40;console.log("x",t);const i=this.engine.dialog.create({id:this.dialogId,title:"panel.property.title",content:"",width:`${e}px`,height:"500px",position:{x:t,y:20},showMask:!1,resizable:!0}),r=document.createElement("div");r.style.height="100%",r.style.display="flex",r.style.flexDirection="column",i.setContent(r),new Uh({container:r,tabs:[{id:"props",title:"panel.property.tab.props",content:this.createPropsTabContent()},{id:"material",title:"panel.property.tab.material",content:this.createMaterialTabContent()}]}).init()}createPropsTabContent(){const e=document.createElement("div");return e.style.height="100%",e.style.overflowY="auto",new Nh({container:e,accordion:!0,activeIds:["base","location"],items:[{id:"base",title:"panel.property.base",content:this.createBaseInfoContent()},{id:"advanced",title:"panel.property.advanced",content:this.createAdvancedInfoContent(),disabled:!1}]}),e}createMaterialTabContent(){const e=document.createElement("div");return e.style.height="100%",e.style.overflowY="auto",new Nh({container:e,accordion:!0,activeIds:["material"],items:[{id:"material",title:"panel.property.material",content:this.createMaterialContent()}]}),e}createBaseInfoContent(){const e=document.createElement("div");return new tl({container:e,labelWidth:"80px",bordered:!0,items:[{label:"Guid",value:'<span style="color:#666">1f8d-4a2e-9c</span>'},{label:"Name",value:"<b>Basic Wall: Generic - 200mm</b>"},{label:"Type",value:"Basic Wall"},{label:"Level",value:"Trane - Centrifugal Water Chiller - CVHF 2 Stage direct drive TAG(BP-RHS-1100RT) 0202104531 1"}]}),e}createAdvancedInfoContent(){const e=document.createElement("div");return new tl({container:e,labelWidth:"100px",bordered:!0,items:[{label:"Area",value:"32.5 m²"},{label:"Volume",value:"6.5 m³"},{label:"Length",value:"5000 mm"},{label:"Phase",value:"New Construction"}]}),e}createMaterialContent(){const e=document.createElement("div"),t=document.createElement("div");t.style.display="flex",t.style.alignItems="center",t.style.marginBottom="4px",t.innerHTML=`
|
||
<div style="width:24px;height:24px;background:#9ca3af;margin-right:8px;border:1px solid #6b7280;border-radius:2px;"></div>
|
||
<span>Concrete - Cast-in-Place Gray</span>
|
||
`;const i=document.createElement("div");return new tl({container:i,items:[{label:"Preview",value:t},{label:"Class",value:"Concrete"},{label:"Density",value:"2400 kg/m³"},{label:"Thermal",value:"0.6 W/(m·K)"}]}),e.appendChild(i),e}destroy(){}}class t1{element;options;activeMode;isExpanded;result=null;toolButtons=new Map;toggleBtn;toggleTextEl;currentModeValueEl;mainValueValueEl;mainValueLabelEl;xyzXEl;xyzYEl;xyzZEl;clearBtn;settingsBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.activeMode=e.defaultMode??"distance",this.isExpanded=e.defaultExpanded??!1,this.element=this.createDom()}init(){this.unsubscribeLocale=ri.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=vt.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(vt.getTheme()),this.applyExpandedState(),this.applyActiveModeState(),this.renderResult()}setTheme(e){const t=this.element.style;t.setProperty("--bim-measure-border",e.border??"rgba(255, 255, 255, 0.12)"),t.setProperty("--bim-measure-divider",e.border??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-measure-icon-color",e.icon??"#ddd"),t.setProperty("--bim-measure-label-color",e.textSecondary??"rgba(255, 255, 255, 0.70)"),t.setProperty("--bim-measure-value-color",e.textPrimary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-measure-danger",e.primary??"#46d369"),t.setProperty("--bim-measure-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-measure-btn-hover-bg",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-measure-btn-active-bg",e.componentActive??"rgba(255, 255, 255, 0.14)")}setLocales(){for(const[t,i]of this.toolButtons.entries())i.title=gt(this.getModeI18nKey(t)),i.setAttribute("aria-label",i.title);this.toggleBtn.title=this.isExpanded?gt("measure.actions.collapse"):gt("measure.actions.expand"),this.toggleBtn.setAttribute("aria-label",this.toggleBtn.title),this.toggleTextEl&&(this.toggleTextEl.textContent=this.toggleBtn.title),this.clearBtn.textContent=gt("measure.actions.clearAll"),this.settingsBtn.title=gt("measure.actions.settings"),this.settingsBtn.setAttribute("aria-label",this.settingsBtn.title),this.currentModeValueEl.textContent=gt(this.getModeI18nKey(this.activeMode)),this.mainValueLabelEl.textContent=gt(this.getModeValueLabelI18nKey(this.activeMode)),this.element.querySelectorAll("[data-i18n-key]").forEach(t=>{const i=t.dataset.i18nKey;i&&(t.textContent=gt(i))})}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}getActiveMode(){return this.activeMode}switchMode(e){this.setActiveMode(e)}setActiveMode(e){this.activeMode!==e&&(this.activeMode=e,this.applyActiveModeState(),this.mainValueLabelEl.textContent=gt(this.getModeValueLabelI18nKey(this.activeMode)),this.currentModeValueEl.textContent=gt(this.getModeI18nKey(this.activeMode)),this.options.onModeChange&&this.options.onModeChange(e),this.renderResult())}setResult(e){this.result=e,this.renderResult()}clearAll(){this.result=null,this.renderResult(),this.options.onClearAll&&this.options.onClearAll()}openSettings(){if(this.options.onSettings){this.options.onSettings();return}console.warn("[MeasurePanel] 未提供设置回调 onSettings,当前仅预留接口。")}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";const t=document.createElement("div");t.className="bim-measure-tools";const i=document.createElement("div");i.className="bim-measure-tool-grid";const r=["distance","minDistance","angle","elevation","volume","laserDistance","slope","spaceVolume"],n=`
|
||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||
<circle cx="12" cy="12" r="9"></circle>
|
||
</svg>
|
||
`;for(let y=0;y<r.length;y++){const _=r[y],E=document.createElement("button");E.type="button",E.className="bim-measure-tool-btn",E.dataset.mode=_;const R=document.createElement("span");R.className="bim-measure-tool-icon",R.innerHTML=n,E.appendChild(R),E.addEventListener("click",()=>{this.setActiveMode(_)}),this.toolButtons.set(_,E),i.appendChild(E)}t.appendChild(i);const a=document.createElement("div");a.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 o=document.createElement("span");o.className="bim-measure-toggle-icon",o.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(o),this.toggleBtn.addEventListener("click",()=>{this.isExpanded=!this.isExpanded,this.applyExpandedState(),this.setLocales(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}),a.appendChild(this.toggleBtn),t.appendChild(a),e.appendChild(t);const l=document.createElement("div");l.className="bim-measure-result";const c=document.createElement("div");c.className="bim-measure-row";const h=document.createElement("span");h.className="label",h.dataset.i18nKey="measure.labels.currentMode";const u=document.createElement("span");u.className="value",this.currentModeValueEl=u,c.appendChild(h),c.appendChild(u),l.appendChild(c);const d=document.createElement("div");d.className="bim-measure-row";const m=document.createElement("span");m.className="label",this.mainValueLabelEl=m;const g=document.createElement("span");g.className="value",this.mainValueValueEl=g,d.appendChild(m),d.appendChild(g),l.appendChild(d);const v=document.createElement("div");v.className="bim-measure-xyz";const f=(y,_)=>{const E=document.createElement("div");E.className="bim-measure-row";const R=document.createElement("span");R.className="label",R.dataset.i18nKey=y;const T=document.createElement("span");return T.className="value",_(T),E.appendChild(R),E.appendChild(T),E};v.appendChild(f("measure.labels.x",y=>this.xyzXEl=y)),v.appendChild(f("measure.labels.y",y=>this.xyzYEl=y)),v.appendChild(f("measure.labels.z",y=>this.xyzZEl=y)),l.appendChild(v),e.appendChild(l);const p=document.createElement("div");return p.className="bim-measure-footer",this.clearBtn=document.createElement("button"),this.clearBtn.type="button",this.clearBtn.className="bim-measure-clear-btn",this.clearBtn.addEventListener("click",()=>{this.clearAll()}),this.settingsBtn=document.createElement("button"),this.settingsBtn.type="button",this.settingsBtn.className="bim-measure-settings-btn",this.settingsBtn.innerHTML=`
|
||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||
<path d="M19.14 12.94c.04-.31.06-.63.06-.94s-.02-.63-.06-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.6-.22l-2.39.96a7.27 7.27 0 0 0-1.63-.94l-.36-2.54A.5.5 0 0 0 13.9 1h-3.8a.5.5 0 0 0-.49.42l-.36 2.54c-.58.23-1.12.54-1.63.94l-2.39-.96a.5.5 0 0 0-.6.22L2.71 7.48a.5.5 0 0 0 .12.64l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94L2.83 14.52a.5.5 0 0 0-.12.64l1.92 3.32c.13.22.39.3.6.22l2.39-.96c.5.4 1.05.71 1.63.94l.36 2.54c.04.24.25.42.49.42h3.8c.24 0 .45-.18.49-.42l.36-2.54c.58-.23 1.12-.54 1.63-.94l2.39.96c.22.09.47 0 .6-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58zM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5z"></path>
|
||
</svg>
|
||
`,this.settingsBtn.addEventListener("click",()=>{this.openSettings()}),p.appendChild(this.clearBtn),p.appendChild(this.settingsBtn),e.appendChild(p),e}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(){const e=this.formatMainValue(this.activeMode,this.result);this.mainValueValueEl.textContent=e;const t=this.result?.xyz;if(!t){this.xyzXEl.textContent="--",this.xyzYEl.textContent="--",this.xyzZEl.textContent="--";return}this.xyzXEl.textContent=this.formatNumber(t.x),this.xyzYEl.textContent=this.formatNumber(t.y),this.xyzZEl.textContent=this.formatNumber(t.z)}getModeI18nKey(e){return`measure.modes.${e}`}getModeValueLabelI18nKey(e){return`measure.labels.value.${e}`}formatMainValue(e,t){if(!t)return"--";switch(e){case"distance":return this.formatWithUnit(t.distanceMm,"measure.units.mm");case"minDistance":return this.formatWithUnit(t.minDistanceMm,"measure.units.mm");case"angle":return this.formatWithUnit(t.angleDeg,"measure.units.deg");case"elevation":return this.formatWithUnit(t.elevationMm,"measure.units.mm");case"volume":return this.formatWithUnit(t.volumeM3,"measure.units.m3");case"laserDistance":return this.formatWithUnit(t.laserDistanceMm,"measure.units.mm");case"slope":return this.formatWithUnit(t.slopePercent,"measure.units.percent");case"spaceVolume":return this.formatWithUnit(t.spaceVolumeM3,"measure.units.m3");default:return"--"}}formatWithUnit(e,t){return e==null||Number.isNaN(e)?"--":`${this.formatNumber(e)} ${gt(t)}`}formatNumber(e){return Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/g,"").replace(/\.$/g,"")}}class i1 extends ji{dialogId="measure-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}const e=250,t=300,i=20,r=this.engine.container,n=r.clientWidth,a=r.clientHeight,o=n-e-i,l=(a-t)/2;this.destroy(),this.panel=new t1({defaultMode:"distance",defaultExpanded:!1,onModeChange:h=>{console.log("[MeasureDialogManager] 当前测量方式已切换:",h)},onClearAll:()=>{console.log("[MeasureDialogManager] 删除全部(仅 UI 清空,本次不清理引擎侧内容)")},onSettings:()=>{console.log("[MeasureDialogManager] 打开设置(仅预留接口)")},onExpandedChange:()=>{this.dialog?.fitHeight(!1)}}),this.panel.init();const c=document.createElement("div");c.style.padding="12px",c.appendChild(this.panel.element),this.dialog=this.engine.dialog.create({id:this.dialogId,title:"measure.dialogTitle",content:c,width:e,height:"auto",position:{x:o,y:l},onClose:()=>{this.engine.toolbar?.setBtnActive("measure",!1)}}),this.dialog.init(),this.dialog.fitHeight(!1)}getActiveMode(){return this.panel?this.panel.getActiveMode():null}switchMode(e){this.panel&&this.panel.switchMode(e)}setResult(e){this.panel&&this.panel.setResult(e)}clearAll(){this.panel&&this.panel.clearAll()}openSettings(){this.panel&&this.panel.openSettings()}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}class r1{events=new Map;on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),()=>this.off(e,t)}off(e,t){const i=this.events.get(e);if(!i)return;const r=i.indexOf(t);r!==-1&&i.splice(r,1)}emit(e,t){const i=this.events.get(e);i&&i.forEach(r=>{try{r(t)}catch(n){console.error(`[EventEmitter] Error in listener for event "${e}":`,n)}})}clear(){this.events.clear()}}class s1 extends r1{container;wrapper=null;toolbar=null;constructTreeBtn=null;buttonGroup=null;dialog=null;engine=null;rightKey=null;propertyPanel=null;measure=null;constructor(e,t){super();const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,t?.locale&&ri.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):vt.setTheme(t.theme)),this.init()}emit(e,t){super.emit(e,t)}on(e,t){return super.on(e,t)}setLocale(e){ri.setLocale(e)}getLocale(){return ri.getLocale()}setTheme(e){vt.setTheme(e)}setCustomTheme(e){vt.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper),this.engine=new Y_(this,this.wrapper),this.dialog=new $h(this,this.wrapper),this.toolbar=new Yh(this,this.wrapper),this.buttonGroup=new Kh(this,this.wrapper),this.rightKey=new Ih(this,this.wrapper),this.constructTreeBtn=new J_(this,this.wrapper),this.propertyPanel=new e1(this),this.measure=new i1(this),this.updateTheme(vt.getTheme()),vt.subscribe(e=>{this.updateTheme(e)})}updateTheme(e){this.wrapper&&(this.wrapper.style.backgroundColor=e.background,this.wrapper.style.color=e.textPrimary)}destroy(){this.toolbar?.destroy(),this.buttonGroup?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.propertyPanel?.destroy(),this.measure?.destroy(),this.container.innerHTML="",this.clear()}}const n1=Object.freeze(Object.defineProperty({__proto__:null,createHomeButton:s=>({id:"home",groupId:"group-1",type:"button",label:"toolbar.home",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M4 21V9l8-6l8 6v12h-6v-7h-4v7z"/></svg>',keepActive:!0,onClick:e=>{console.log("首页按钮被点击:",e.id),s.emit("ui:open-dialog",{id:"home-info"})}})},Symbol.toStringTag,{value:"Module"})),a1=Object.freeze(Object.defineProperty({__proto__:null,locationButton:{id:"location",groupId:"group-1",type:"button",label:"toolbar.location",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 13h2v-2.75h2V13h2V8.25l-3-2l-3 2zm3 9q-4.025-3.425-6.012-6.362T4 10.2q0-3.75 2.413-5.975T12 2t5.588 2.225T20 10.2q0 2.5-1.987 5.438T12 22"/></svg>',keepActive:!1,onClick:s=>{console.log("定位按钮被点击:",s.id)}}},Symbol.toStringTag,{value:"Module"})),o1=Object.freeze(Object.defineProperty({__proto__:null,walkMenuButton:{id:"walk",groupId:"group-1",type:"menu",label:"toolbar.walk",align:"vertical",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 22V8.775q-2.275-.6-3.637-2.512T4 2h2q0 2.075 1.338 3.538T10.75 7h2.5q.75 0 1.4.275t1.175.8L20.35 12.6l-1.4 1.4L15 10.05V22h-2v-6h-2v6zm3-16q-.825 0-1.412-.587T10 4t.588-1.412T12 2t1.413.588T14 4t-.587 1.413T12 6"/></svg>',keepActive:!0,onClick:s=>{console.log("漫游按钮被点击:",s.id)}}},Symbol.toStringTag,{value:"Module"})),l1=Object.freeze(Object.defineProperty({__proto__:null,walkPersonButton:{id:"walk-person",groupId:"group-1",parentId:"walk",type:"button",align:"vertical",label:"toolbar.walkPerson",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 22V8.775q-2.275-.6-3.637-2.512T4 2h2q0 2.075 1.338 3.538T10.75 7h2.5q.75 0 1.4.275t1.175.8L20.35 12.6l-1.4 1.4L15 10.05V22h-2v-6h-2v6zm3-16q-.825 0-1.412-.587T10 4t.588-1.412T12 2t1.413.588T14 4t-.587 1.413T12 6"/></svg>',onClick:s=>{console.log("人视漫游被点击:",s.id)}}},Symbol.toStringTag,{value:"Module"})),c1=Object.freeze(Object.defineProperty({__proto__:null,walkBirdButton:{id:"walk-bird",groupId:"group-1",parentId:"walk",align:"vertical",type:"button",label:"toolbar.walkBird",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 22V8.775q-2.275-.6-3.637-2.512T4 2h2q0 2.075 1.338 3.538T10.75 7h2.5q.75 0 1.4.275t1.175.8L20.35 12.6l-1.4 1.4L15 10.05V22h-2v-6h-2v6zm3-16q-.825 0-1.412-.587T10 4t.588-1.412T12 2t1.413.588T14 4t-.587 1.413T12 6"/></svg>',onClick:s=>{console.log("鸟瞰漫游被点击:",s.id)}}},Symbol.toStringTag,{value:"Module"})),h1=Object.freeze(Object.defineProperty({__proto__:null,settingButton:{id:"setting",groupId:"group-2",type:"button",label:"toolbar.setting",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="m9.25 22l-.4-3.2q-.325-.125-.612-.3t-.563-.375L4.7 19.375l-2.75-4.75l2.575-1.95Q4.5 12.5 4.5 12.338v-.675q0-.163.025-.338L1.95 9.375l2.75-4.75l2.975 1.25q.275-.2.575-.375t.6-.3l.4-3.2h5.5l.4 3.2q.325.125.613.3t.562.375l2.975-1.25l2.75 4.75l-2.575 1.95q.025.175.025.338v.674q0 .163-.05.338l2.575 1.95l-2.75 4.75l-2.95-1.25q-.275.2-.575.375t-.6.3l-.4 3.2zM11 20h1.975l.35-2.65q.775-.2 1.438-.587t1.212-.938l2.475 1.025l.975-1.7l-2.15-1.625q.125-.35.175-.737T17.5 12t-.05-.787t-.175-.738l2.15-1.625l-.975-1.7l-2.475 1.05q-.55-.575-1.212-.962t-1.438-.588L13 4h-1.975l-.35 2.65q-.775.2-1.437.588t-1.213.937L5.55 7.15l-.975 1.7l2.15 1.6q-.125.375-.175.75t-.05.8q0 .4.05.775t.175.75l-2.15 1.625l.975 1.7l2.475-1.05q.55.575 1.213.963t1.437.587zm1.05-4.5q1.45 0 2.475-1.025T15.55 12t-1.025-2.475T12.05 8.5q-1.475 0-2.488 1.025T8.55 12t1.013 2.475T12.05 15.5M12 12"/></svg>',keepActive:!1,onClick:s=>{console.log("设置按钮被点击:",s.id)}}},Symbol.toStringTag,{value:"Module"})),u1=Object.freeze(Object.defineProperty({__proto__:null,infoButton:{id:"toolbar-info",type:"button",label:"toolbar.info",icon:'<svg viewBox="0 0 1024 1024"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" fill="currentColor"/><path d="M464 336a48 48 0 1 0 96 0 48 48 0 1 0-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z" fill="currentColor"/></svg>',onClick:()=>{document.dispatchEvent(new CustomEvent("bim-demo:open-property-panel"))}}},Symbol.toStringTag,{value:"Module"})),d1=Object.freeze(Object.defineProperty({__proto__:null,createMeasureButton:s=>({id:"measure",groupId:"group-1",type:"button",label:"toolbar.measure",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" fill-rule="evenodd" d="M3 6a3 3 0 0 0-3 3v7a3 3 0 0 0 3 3h18a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3zm6 2H7v5a1 1 0 1 1-2 0V8H3a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1h-2v3a1 1 0 1 1-2 0V8h-2v5a1 1 0 1 1-2 0V8h-2v3a1 1 0 1 1-2 0z" clip-rule="evenodd"/></svg>',keepActive:!0,onClick:e=>{e.isActive?s.measure?.show():s.measure?.destroy()}})},Symbol.toStringTag,{value:"Module"}));yr.BimEngine=s1,Object.defineProperty(yr,Symbol.toStringTag,{value:"Module"})}));
|
||
//# sourceMappingURL=bim-engine-sdk.umd.js.map
|