(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.bim-engine-wrapper{position:relative;width:100%;height:100%;font-family:sans-serif;box-sizing:border-box;overflow:hidden;background:linear-gradient(to bottom,#d6e0eb,#f6faff)}.bim-engine-opt-btn-container{z-index:100}.bim-construct-tree-btn{position:absolute;top:20px;left:20px!important;z-index:100}.bim-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,border-color .2s;color:var(--bim-btn-text-color, #ccc);background-color:var(--bim-btn-bg, transparent);padding:6px;align-items:center;position:relative;justify-content:center;border:1px solid transparent;outline:none}.opt-btn:hover{background-color:var(--bim-btn-hover-bg, #444)}.opt-btn.active{background-color:var(--bim-btn-active-bg, rgba(255, 255, 255, .15));color:var(--bim-btn-text-active-color, #fff)}.opt-btn.disabled{opacity:.5;cursor:not-allowed}.opt-btn-icon{width:var(--bim-icon-size, 24px);height:var(--bim-icon-size, 24px);display:flex;align-items:center;justify-content:center;color:var(--bim-icon-color, #ccc);flex-shrink:0}.opt-btn-icon svg{width:100%;height:100%;fill:currentColor}.opt-btn-arrow{font-size:10px;opacity:.6;transition:transform .2s;display:inline-block;margin-left:4px}.opt-btn-arrow.rotated{transform:rotate(180deg)}.opt-btn-text-wrapper{display:flex;align-items:center;justify-content:center;pointer-events:none}.opt-btn-label{display:inline}.opt-btn.no-label .opt-btn-label{display:none}.opt-btn.align-vertical:not(.no-label){flex-direction:column;text-align:center}.opt-btn.align-vertical:not(.no-label) .opt-btn-text-wrapper{margin-top:4px}.opt-btn.align-vertical:not(.no-label) .opt-btn-label{font-size:12px;line-height:1.2}.opt-btn.align-horizontal:not(.no-label){flex-direction:row}.opt-btn.align-horizontal:not(.no-label) .opt-btn-text-wrapper{margin-left:8px}.opt-btn.align-horizontal:not(.no-label) .opt-btn-label{font-size:14px}.opt-btn.no-label .opt-btn-text-wrapper{width:0;height:0;margin:0;padding:0;overflow:visible;position:absolute;top:0;right:0}.opt-btn.no-label .opt-btn-arrow{position:absolute;top:2px;right:2px;margin:0;font-size:8px}.opt-btn-dropdown{position:absolute;background-color:var(--bim-toolbar-bg, rgba(17, 17, 17, .95));border-radius:4px;padding:4px;box-shadow:0 4px 12px #0003;z-index:1001;display:flex;flex-direction:column;border:1px solid rgba(255,255,255,.1);opacity:0;visibility:hidden;transform:translateY(-10px);transition:opacity .2s ease,transform .2s cubic-bezier(.2,0,.2,1),visibility .2s}@keyframes dropdown-fade-in{0%{opacity:0;transform:translateY(-8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}.opt-btn-dropdown{animation:dropdown-fade-in .2s cubic-bezier(.2,0,.2,1) forwards;opacity:1;visibility:visible;transform:none}.opt-btn-dropdown-item{display:flex;align-items:center;padding:8px 12px;cursor:pointer;border-radius:4px;color:var(--bim-btn-text-color, #ccc);transition:background .2s,border-color .2s,color .2s;box-sizing:border-box;border:1px solid transparent;outline:none}.opt-btn-dropdown-item .opt-btn-icon{color:var(--bim-icon-color, #ccc)}.opt-btn-dropdown-item:hover{background-color:var(--bim-btn-hover-bg, #444)}.opt-btn-dropdown-item.active{background-color:var(--bim-btn-active-bg, rgba(255, 255, 255, .15));color:var(--bim-btn-text-active-color, #fff)}.opt-btn-dropdown-item.align-horizontal{flex-direction:row}.opt-btn-dropdown-item.align-horizontal .opt-btn-icon{width:18px;height:18px;margin-right:8px}.opt-btn-dropdown-item.align-vertical{flex-direction:column;text-align:center}.opt-btn-dropdown-item.align-vertical .opt-btn-icon{width:24px;height:24px;margin-bottom:4px}.opt-btn-dropdown-item.align-vertical .opt-btn-dropdown-label{font-size:12px}.bim-btn-group-root.is-bottom-toolbar .opt-btn-icon{width:32px;height:32px}.bim-btn-group-root.is-bottom-toolbar .opt-btn{padding:8px}.bim-btn-group-root.type-glass-pill .bim-btn-group-section{background:var(--bim-floating-bg);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--bim-floating-border);border-radius:9999px;box-shadow:var(--bim-floating-shadow);padding:8px;gap:10px}.bim-btn-group-root.type-glass-pill .opt-btn{width:48px;height:48px;min-width:48px;border-radius:9999px;background:var(--bim-floating-btn-bg);border:1px solid var(--bim-floating-btn-border);box-shadow:var(--bim-floating-btn-shadow);color:var(--bim-text-primary);padding:0;transition:all .2s ease-out}.bim-btn-group-root.type-glass-pill .opt-btn:hover{background:var(--bim-floating-btn-bg-hover);transform:scale(1.05);box-shadow:var(--bim-floating-btn-shadow-hover)}.bim-btn-group-root.type-glass-pill .opt-btn:active{transform:scale(.98)}.bim-btn-group-root.type-glass-pill .opt-btn.active{background:var(--bim-primary);border:1px solid var(--bim-primary-active);color:var(--bim-text-inverse);box-shadow:var(--bim-shadow-glow)}.bim-btn-group-root.type-glass-pill .opt-btn.active:hover{background:var(--bim-primary-hover);transform:scale(1.05)}.bim-btn-group-root.type-glass-pill .opt-btn.active:active{transform:scale(.98)}.bim-btn-group-root.type-glass-pill .opt-btn.active .opt-btn-icon{color:var(--bim-icon-inverse)}.bim-btn-group-root.type-glass-pill .opt-btn.disabled{opacity:.3;cursor:not-allowed;transform:none;box-shadow:none}.bim-btn-group-root.type-glass-pill .opt-btn-icon{width:18px;height:18px;color:var(--bim-floating-icon-color);transition:color .2s ease-out}.bim-btn-group-root.type-glass-pill .opt-btn-icon svg{width:18px;height:18px}.bim-btn-group-root.type-glass-pill .opt-btn:hover .opt-btn-icon{color:var(--bim-floating-icon-color-hover)}.bim-btn-group-root.type-glass-pill .opt-btn-label{display:none!important}.bim-btn-group-root.type-glass-pill .opt-btn-text-wrapper{position:absolute;top:2px;right:2px;width:0;height:0;margin:0;padding:0}.bim-btn-group-root.type-glass-pill .opt-btn-arrow{font-size:8px;position:absolute;top:0;right:0;color:var(--bim-text-tertiary)}.opt-btn-dropdown.type-glass-pill{background:#fffffff2;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(226,232,240,.6);border-radius:12px;box-shadow:0 8px 24px #0000001f;padding:6px}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item{display:flex;flex-direction:row;align-items:center;gap:10px;border-radius:8px;color:#334155;padding:8px 12px;font-size:13px;font-weight:400;transition:all .1s ease-out}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item:hover{background:#f1f5f9}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item:active{background:#e2e8f0}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active{background:#3b82f6;color:#fff}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active .opt-btn-icon,.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active .opt-btn-dropdown-label{color:#fff}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-icon{width:18px;height:18px;color:#334155;flex-shrink:0}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-icon svg{width:18px;height:18px}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-dropdown-label{white-space:nowrap;color:#334155}.opt-btn-dropdown.type-glass-pill.theme-dark{background:var(--bim-bg-overlay);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid var(--bim-border-default);box-shadow:var(--bim-shadow-lg)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item{color:var(--bim-text-primary)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item:hover{background:var(--bim-floating-btn-bg)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item:active{background:var(--bim-floating-btn-bg-hover)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item.active{background:var(--bim-primary);color:var(--bim-text-inverse)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item .opt-btn-icon{color:var(--bim-floating-icon-color)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item .opt-btn-dropdown-label{color:var(--bim-text-primary)}.bim-dialog{position:absolute;background-color:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);border-radius:var(--bim-panel-radius, 12px);box-shadow:var(--bim-shadow-lg);display:flex;flex-direction:column;z-index:10001;color:var(--bim-dialog-title-color, var(--bim-text-primary));overflow:hidden;min-width:200px;min-height:100px;pointer-events:auto}.bim-dialog-header{height:40px;background-color:var(--bim-bg-inset);display:flex;align-items:center;justify-content:space-between;padding:0 12px;cursor:default;-webkit-user-select:none;user-select:none;border-bottom:1px solid var(--bim-border-default);flex-shrink:0}.bim-dialog-header.draggable{cursor:move}.bim-dialog-title{font-size:14px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--bim-dialog-title-color)}.bim-dialog-close{cursor:pointer;font-size:18px;color:var(--bim-text-tertiary);line-height:1;margin-left:8px}.bim-dialog-close:hover{color:var(--bim-text-primary)}.bim-dialog-content{flex:1;overflow:auto;font-size:14px;color:var(--bim-dialog-text-color, var(--bim-text-secondary))}.bim-dialog-resize-handle{position:absolute;width:10px;height:10px;bottom:0;right:0;cursor:se-resize;z-index:10}.bim-dialog-resize-handle:after{content:"";position:absolute;bottom:3px;right:3px;width:6px;height:6px;border-right:2px solid var(--bim-text-tertiary);border-bottom:2px solid var(--bim-text-tertiary)}.bim-dialog-resize-handle:hover:after{border-color:var(--bim-text-primary)}.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-bg-elevated);border:1px solid var(--bim-border-default);border-radius:8px;padding:6px;margin:0;list-style:none;min-width:160px;box-shadow:var(--bim-shadow-lg);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;-webkit-user-select:none;user-select:none;color:var(--bim-text-primary)}.bim-menu-group{display:flex;flex-direction:column}.bim-menu-divider{height:1px;background-color:var(--bim-divider);margin:4px 0}.bim-menu-item{display:flex;align-items:center;padding:8px 12px;cursor:pointer;transition:all .2s ease;font-size:13px;position:relative;color:var(--bim-text-primary);border-radius:6px}.bim-menu-item:hover{background-color:var(--bim-floating-btn-bg);transform:translate(2px)}.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-text-primary);-webkit-user-select:none;user-select:none;position:relative;background:transparent}.bim-tree-search{padding:6px;background-color:transparent;flex-shrink:0;position:relative}.bim-tree-search-wrapper{position:relative;width:100%;display:flex;align-items:center}.bim-tree-search-icon{position:absolute;left:8px;width:16px;height:16px;color:var(--bim-text-secondary);pointer-events:none;display:flex;align-items:center;justify-content:center}.bim-tree-search-icon svg{width:100%;height:100%}.bim-tree-search-input{width:100%;height:30px;padding:4px 8px 4px 30px;border:1px solid var(--bim-border-default);border-radius:4px;outline:none;font-size:13px;color:inherit;background-color:var(--bim-bg-elevated);transition:all .2s;box-sizing:border-box}.bim-tree-search-input:focus{border-color:var(--bim-primary);box-shadow:var(--bim-focus-ring)}.bim-tree-search-results{position:absolute;top:100%;left:8px;right:8px;background-color:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);box-shadow:var(--bim-shadow-md);border-radius:4px;max-height:200px;overflow-y:auto;z-index:10;display:none}.bim-tree-search-results.is-visible{display:block}.bim-tree-search-item{padding:8px 12px;cursor:pointer;border-bottom:1px solid rgba(0,0,0,.03)}.bim-tree-search-item:last-child{border-bottom:none}.bim-tree-search-item:hover{background-color:var(--bim-component-bg-hover)}.bim-tree-search-item-title{font-weight:500;display:block}.bim-tree-search-item-path{font-size:12px;color:var(--bim-text-secondary);margin-top:2px;display:block}.bim-tree-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-component-bg-hover)}.bim-tree-switcher{width:24px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--bim-text-secondary);transition:transform .2s;flex-shrink:0}.bim-tree-switcher svg{width:12px;height:12px;fill:currentColor;transition:transform .2s}.bim-tree-switcher.is-expanded svg{transform:rotate(90deg)}.bim-tree-switcher.is-hidden{visibility:hidden}.bim-tree-checkbox{width:16px;height:16px;border:1px solid var(--bim-border-default);border-radius:2px;margin-right:8px;background-color:var(--bim-bg-elevated);position:relative;cursor:pointer;flex-shrink:0;transition:all .2s}.bim-tree-checkbox:hover{border-color:var(--bim-primary)}.bim-tree-checkbox.is-checked{background-color:var(--bim-primary);border-color:var(--bim-primary)}.bim-tree-checkbox.is-checked:after{content:"";position:absolute;top:1px;left:4px;width:5px;height:9px;border:2px solid var(--bim-text-inverse);border-top:0;border-left:0;transform:rotate(45deg)}.bim-tree-checkbox.is-indeterminate{background-color:var(--bim-bg-elevated);border-color:var(--bim-primary)}.bim-tree-checkbox.is-indeterminate:after{content:"";position:absolute;top:6px;left:3px;width:8px;height:2px;background-color:var(--bim-primary)}.bim-tree-node.is-disabled .bim-tree-checkbox{background-color:var(--bim-component-bg-disabled);border-color:var(--bim-border-disabled);cursor:not-allowed}.bim-tree-node.is-disabled .bim-tree-checkbox.is-checked{background-color:var(--bim-text-disabled)}.bim-tree-node.is-disabled .bim-tree-node-content{color:var(--bim-text-disabled);cursor:not-allowed}.bim-tree-icon{width:16px;height:16px;margin-right:6px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.bim-tree-icon img,.bim-tree-icon svg{width:100%;height:100%}.bim-tree-title{flex:1;white-space:nowrap}.bim-tree-children{display:none;overflow:visible}.bim-tree-children.is-visible{display:block}.bim-tree-node-content.is-selected{background-color:var(--bim-component-bg-selected);color:var(--bim-primary)}.bim-tree-node-actions{display:none;align-items:center;margin-left:8px;flex-shrink:0}.bim-tree-node-content.is-selected .bim-tree-node-actions{display:flex}.bim-tree-content{flex:1;overflow: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-text-secondary)}.bim-tab__nav{display:flex;align-items:center;gap:4px;padding:4px;margin:8px 12px;background:var(--bim-bg-inset);border-radius:8px;border:1px solid var(--bim-border-subtle)}.bim-tab__item{flex:1;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;border:none;border-radius:6px;background:transparent;color:var(--bim-text-secondary);cursor:pointer;transition:all .2s ease;font-size:13px;font-weight:500}.bim-tab__item:hover{color:var(--bim-text-primary);background-color:var(--bim-component-bg-hover)}.bim-tab__item.is-active{color:var(--bim-primary);background-color:var(--bim-bg-elevated);box-shadow:0 1px 3px #0000001a}.bim-tab__item.is-disabled{opacity:.5;cursor:not-allowed}.bim-tab__icon{width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--bim-tab-icon, currentColor)}.bim-tab__icon svg{width:100%;height:100%;fill:currentColor}.bim-tab__title{white-space:nowrap}.bim-tab__content{flex:1;display:flex;position:relative;min-height:0;overflow:hidden}.bim-tab__panel{display:none;width:100%;height:100%;flex:1}.bim-tab__panel.is-active{display:flex;flex-direction:column;height:100%}.construct-tab__container{height:100%;display:flex;flex-direction:column}.construct-tab__panel-content{flex:1;display:flex;flex-direction:column;min-height:0;overflow:hidden}.construct-tab__panel-content .bim-tree{flex:1}.bim-collapse{background-color:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);border-radius:8px;font-size:14px;color:var(--bim-text-primary)}.bim-collapse.is-ghost{background-color:transparent;border:none}.bim-collapse.is-ghost .bim-collapse-item{border-bottom:none}.bim-collapse.is-ghost .bim-collapse-header{background-color: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-subtle)}.bim-collapse-item:last-child{border-bottom:none}.bim-collapse-item.is-disabled .bim-collapse-header{color:var(--bim-text-disabled);cursor:not-allowed}.bim-collapse-header{display:flex;align-items:center;padding:12px 16px;background-color:var(--bim-component-bg);cursor:pointer;transition:all .2s ease;position:relative}.bim-collapse-header:hover{background-color:var(--bim-component-bg-hover)}.bim-collapse-arrow{margin-right:12px;font-size:12px;width:12px;height:12px;transition:transform .24s;display:inline-flex;align-items:center;justify-content:center}.bim-collapse-arrow svg{width:100%;height:100%;fill:currentColor}.bim-collapse-item.is-active .bim-collapse-arrow{transform:rotate(90deg)}.bim-collapse-icon{margin-right:8px;display:inline-flex;align-items:center}.bim-collapse-icon svg{width:16px;height:16px;fill:currentColor}.bim-collapse-title{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.bim-collapse-extra{margin-left:auto}.bim-collapse-content{overflow:hidden;background-color:var(--bim-bg-elevated);border-top:1px solid var(--bim-border-subtle);transition:height .2s ease-in-out,opacity .2s ease-in-out}.bim-collapse-content.is-hidden{display:none}.bim-description{display:flex;flex-direction:column;width:100%;font-size:14px;color:var(--bim-text-primary);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-subtle)}.bim-description-label{color:var(--bim-text-secondary);flex-shrink:0;padding:4px;display:flex;align-items:center}.bim-description.is-bordered .bim-description-label{border-right:1px solid var(--bim-border-subtle)}.bim-description-value{color:var(--bim-text-primary);flex:1;word-break:break-all;padding:4px;display:flex;align-items:center}.bim-measure-panel{width:100%;display:flex;flex-direction:column;box-sizing:border-box;color:var(--bim-text-secondary)}.bim-measure-settings{display:none;box-sizing:border-box;color:var(--bim-text-secondary)}.bim-measure-settings-title{font-size:14px;font-weight:600;margin-bottom:10px}.bim-measure-settings-row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}.bim-measure-settings-row .label{color:var(--bim-text-secondary);font-size:13px;flex:0 0 auto}.bim-measure-settings-select{flex:0 0 auto;width:120px;height:28px;border-radius:6px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);color:var(--bim-text-primary);padding:0 8px;box-sizing:border-box;outline:none}.bim-measure-settings-hint{font-size:12px;line-height:1.4;color:var(--bim-text-tertiary);margin-top:-4px;margin-bottom:8px}.bim-measure-settings-actions{margin-top:14px;display:flex;justify-content:flex-start;gap:10px}.bim-measure-settings-save,.bim-measure-settings-cancel{flex:0 0 auto!important;width:auto;min-width:0;height:30px;padding:0 12px;border-radius:4px;cursor:pointer;box-sizing:border-box}.bim-measure-settings-save{border:none;background:var(--bim-primary);color:var(--bim-text-inverse)}.bim-measure-settings-cancel{border:1px solid var(--bim-border-default);background:transparent;color:var(--bim-text-secondary)}.bim-measure-settings-save:hover,.bim-measure-settings-save:active,.bim-measure-settings-save:focus,.bim-measure-settings-cancel:hover,.bim-measure-settings-cancel:active,.bim-measure-settings-cancel:focus{background:inherit;outline:none}.bim-measure-settings-save:hover{background:var(--bim-primary-hover)}.bim-measure-tools{display:flex;flex-direction:column;gap:8px}.bim-measure-tool-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}.bim-measure-tool-btn{width:100%;height:42px;border-radius:6px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .2s ease;padding:0;box-sizing:border-box}.bim-measure-tool-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.bim-measure-tool-btn.is-active{border-color:var(--bim-primary);background:var(--bim-primary-subtle)}.bim-measure-tool-btn.is-active .bim-measure-tool-icon{color:var(--bim-primary)}.bim-measure-tool-icon{width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;color:var(--bim-icon-default)}.bim-measure-tool-icon svg{width:100%;height:100%;fill:currentColor}.bim-measure-toggle{display:flex;justify-content:flex-end}.bim-measure-toggle-btn{height:22px;border-radius:4px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:all .2s ease;padding:0 6px;gap:4px;font-size:12px;line-height:1}.bim-measure-toggle-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.bim-measure-toggle-text{color:var(--bim-text-secondary)}.bim-measure-toggle-icon svg{width:14px;height:14px;fill:currentColor;color:var(--bim-icon-default);transition:transform .15s ease}.bim-measure-toggle-btn.is-expanded .bim-measure-toggle-icon svg{transform:rotate(180deg)}.bim-measure-result{margin-top:12px;padding-top:12px;border-top:1px solid var(--bim-divider);display:flex;flex-direction:column;gap:10px}.bim-measure-row{display:flex;align-items:baseline;gap:8px;font-size:13px;line-height:1.4}.bim-measure-row .label{color:var(--bim-text-secondary);min-width:84px}.bim-measure-row .value{color:var(--bim-text-primary);flex:1;word-break:break-word}.bim-measure-main-number{color:#ffd24a}.bim-measure-main-number.is-laser-text,.bim-measure-main-unit{color:var(--bim-text-primary)}.bim-measure-xyz{display:flex;flex-direction:column;gap:6px}.bim-measure-xyz .value{font-variant-numeric:tabular-nums}.bim-measure-xyz-x{color:#ff4d4f!important}.bim-measure-xyz-y{color:#52c41a!important}.bim-measure-xyz-z{color:#1677ff!important}.bim-measure-footer{margin-top:12px;padding-top:10px;border-top:1px solid var(--bim-divider);display:flex;align-items:center;justify-content:flex-start;gap:10px}.bim-measure-clear-btn{background:transparent;border:none;color:var(--bim-danger);cursor:pointer;padding:0;font-size:13px;flex:0 0 auto!important;width:auto;min-width:0}.bim-measure-clear-btn{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-icon-default)}.section-plane-panel{display:flex;gap:8px;padding:12px 12px 16px;box-sizing:border-box}.section-plane-btn{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:10px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);border-radius:8px;cursor:pointer;transition:all .2s ease;min-width:60px;outline:none;color:var(--bim-text-primary)}.section-plane-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.section-plane-btn:active{background:var(--bim-primary-subtle);border-color:var(--bim-primary)}.section-plane-btn.is-active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.section-plane-btn.is-active .section-plane-btn-icon{color:var(--bim-primary)}.section-plane-btn-icon{width:24px;height:24px;display:flex;align-items:center;justify-content:center;color:var(--bim-icon-default)}.section-plane-btn-icon svg{width:100%;height:100%;fill:currentColor}.section-plane-btn-label{font-size:12px;color:inherit;text-align:center;line-height:1.2}.section-axis-panel{display:flex;flex-direction:column;gap:8px;padding:12px 12px 16px;box-sizing:border-box}.section-axis-row-1{display:flex;gap:8px;padding-bottom:8px;border-bottom:1px solid var(--bim-divider)}.section-axis-row-2{display:flex;gap:8px;padding-top:8px}.section-axis-btn{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:8px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:8px;cursor:pointer;transition:all .2s ease;outline:none;color:var(--bim-text-primary);min-height:48px}.section-axis-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.section-axis-btn.active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.section-axis-btn.active .section-axis-btn-icon{color:var(--bim-primary)}.section-axis-btn-icon{width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;color:var(--bim-icon-default)}.section-axis-btn-icon svg{width:100%;height:100%}.section-axis-btn-label{font-size:12px;color:inherit;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}.section-axis-btn-text{min-height:40px}.section-axis-btn-text .section-axis-btn-label{font-size:18px;font-weight:600}.section-box-panel{display:flex;flex-direction:column;padding:12px;box-sizing:border-box;-webkit-user-select:none;user-select:none}.section-box-row-buttons{display:flex;gap:6px;padding-bottom:12px;border-bottom:1px solid var(--bim-divider)}.section-box-btn{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:6px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:8px;cursor:pointer;color:var(--bim-text-primary);min-height:44px;transition:all .2s ease}.section-box-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.section-box-btn.active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.section-box-btn.active .section-box-btn-icon{color:var(--bim-primary)}.section-box-btn-icon{width:24px;height:24px;color:var(--bim-icon-default)}.section-box-btn-icon svg{width:100%;height:100%}.section-box-btn-label{font-size:11px;white-space:nowrap}.section-box-sliders{display:flex;flex-direction:column;gap:16px;padding-top:16px}.section-box-slider{display:flex;align-items:center;gap:12px;position:relative;z-index:1}.section-box-slider:hover{z-index:10}.section-box-slider-label{font-size:13px;font-weight:700;color:var(--bim-text-primary);min-width:14px}.section-box-slider-track{position:relative;flex:1;height:4px;background:var(--bim-border-default);border-radius:2px}.section-box-slider-range{position:absolute;top:0;height:100%;background:var(--bim-primary);border-radius:2px;pointer-events:none}.section-box-slider-handle{position:absolute;top:50%;width:14px;height:14px;background:var(--bim-bg-elevated);border:2px solid var(--bim-primary);border-radius:50%;transform:translate(-50%,-50%);cursor:grab;z-index:5;touch-action:none;transition:transform .2s,box-shadow .2s}.section-box-slider-handle:hover{transform:translate(-50%,-50%) scale(1.2);box-shadow:0 0 0 4px var(--bim-primary-subtle)}.section-box-slider-handle.dragging{cursor:grabbing;transform:translate(-50%,-50%) scale(1.2);background:var(--bim-primary)}.walk-control-panel{display:flex;align-items:center;gap:20px;padding:12px 20px;background-color:var(--bim-bg-base, #152232);border:1px solid var(--bim-border-strong, #475569);border-radius:12px;box-shadow:var(--bim-shadow-xl, 0 20px 40px rgba(0, 0, 0, .3));-webkit-user-select:none;user-select:none}.walk-divider{width:1px;height:40px;background:var(--bim-divider);flex-shrink:0}.walk-control-left{display:flex;gap:8px}.walk-icon-btn{width:48px;height:48px;display:flex;align-items:center;justify-content:center;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:8px;cursor:pointer;transition:all .2s ease;color:var(--bim-icon-default);padding:8px}.walk-icon-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.walk-icon-btn.active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.walk-icon-btn.active svg{fill:var(--bim-primary)}.walk-icon-btn svg{width:32px;height:32px}.walk-control-settings{display:flex;align-items:center;gap:16px;flex:1}.walk-speed-control{display:flex;align-items:center;gap:12px}.walk-speed-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-speed-group{display:flex;align-items:center;gap:8px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-subtle);border-radius:6px;padding:4px}.walk-speed-btn{width:32px;height:32px;background:var(--bim-bg-elevated);border:1px solid var(--bim-border-subtle);border-radius:4px;color:var(--bim-text-primary);font-size:18px;cursor:pointer;transition:all .2s ease}.walk-speed-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.walk-speed-btn:disabled{opacity:.5;cursor:not-allowed}.walk-speed-display{min-width:40px;text-align:center;color:var(--bim-text-primary);font-size:14px;font-weight:700}.walk-checkbox-wrapper{display:flex;align-items:center;gap:8px;cursor:pointer}.walk-checkbox{width:18px;height:18px;cursor:pointer}.walk-checkbox:disabled{opacity:.5;cursor:not-allowed}.walk-checkbox-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-checkbox-wrapper input:disabled+.walk-checkbox-label{opacity:.5}.walk-select-wrapper{display:flex;align-items:center;gap:8px}.walk-select-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-select{padding:6px 12px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:6px;color:var(--bim-text-primary);font-size:14px;cursor:pointer;min-width:120px}.walk-select option{background:var(--bim-bg-elevated);color:var(--bim-text-primary)}.walk-exit-btn{padding:10px 24px;background:var(--bim-primary);border:none;border-radius:8px;color:var(--bim-text-inverse);font-size:14px;font-weight:600;cursor:pointer;transition:all .2s ease;white-space:nowrap}.walk-exit-btn:hover{background:var(--bim-primary-hover);transform:scale(1.02)}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})(); const bf = { common: { title: "BimEngine", description: "这是一个使用 BIM-ENGINE。", openTestDialog: "打开测试弹窗", openInfoDialog: "打开信息弹窗 (封装版)" }, toolbar: { home: "首页", measure: "测量", zoomBox: "选框放大", info: "信息", location: "定位", setting: "设置", walk: "漫游", map: "地图", property: "构件详情", fullscreen: "全屏", walkMenu: "漫游菜单", walkPerson: "第一人称", walkBird: "第三人称", tree: "模型树", section: "剖切", sectionPlane: "拾取面剖切", sectionAxis: "轴向剖切", sectionBox: "剖切盒" }, dialog: { testTitle: "测试弹窗", testContent: '
这是一个 可拖拽可缩放 的弹窗。

你可以尝试拖动标题栏,或者拖动右下角改变大小。
' }, 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", cm: "cm", m: "m", km: "km", deg: "°", m3: "m³", percent: "%" }, settings: { title: "设置", unit: "单位:", precision: "精度:", hint: "距离、最小距离和标高默认使用该单位;角度和体积有各自默认单位。", save: "保存设置", cancel: "取消" } }, sectionPlane: { dialogTitle: "拾取面剖切", actions: { hide: "隐藏", reverse: "反向", reset: "重置" } }, sectionAxis: { dialogTitle: "轴向剖切", actions: { hide: "隐藏", reverse: "反向", axisX: "X", axisY: "Y", axisZ: "Z" } }, sectionBox: { dialogTitle: "剖切盒", actions: { hide: "隐藏", reverse: "反向", fitToModel: "适应", reset: "重置" }, axes: { x: "X", y: "Y", z: "Z" } }, walkControl: { speed: "移动速度:", gravity: "重力", collision: "碰撞", characterModel: { label: "建筑工人", constructionWorker: "建筑工人", officeMale: "办公室男性" }, walkMode: { label: "行走模式", walk: "行走模式", run: "奔跑模式" }, exit: "退出", path: { dialogTitle: "路径漫游" } }, map: { dialogTitle: "地图" } }, _f = { common: { title: "BimEngine", description: "This is a BIM-ENGINE demo.", openTestDialog: "Open Test Dialog", openInfoDialog: "Open Info Dialog (Wrapped)" }, toolbar: { home: "Home", measure: "Measure", zoomBox: "Zoom Box", info: "Info", location: "Location", setting: "Settings", walk: "Walk", map: "Map", property: "Property", fullscreen: "Fullscreen", walkPerson: "Person", walkBird: "Bird Eye", walkMenu: "Menu", tree: "Tree", section: "Section", sectionPlane: "Plane Section", sectionAxis: "Axis Section", sectionBox: "Section Box" }, dialog: { testTitle: "Test Dialog", testContent: '
This is a draggable and resizable dialog.

Try dragging the title bar or resizing from the bottom-right corner.
' }, 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", cm: "cm", m: "m", km: "km", deg: "°", m3: "m³", percent: "%" }, settings: { title: "Settings", unit: "Unit:", precision: "Precision:", hint: "Distance, min distance and elevation use this unit by default; angle and volume use their own units.", save: "Save", cancel: "Cancel" } }, sectionPlane: { dialogTitle: "Plane Section", actions: { hide: "Hide", reverse: "Reverse", reset: "Reset" } }, sectionAxis: { dialogTitle: "Axis Section", actions: { hide: "Hide", reverse: "Reverse", axisX: "X", axisY: "Y", axisZ: "Z" } }, sectionBox: { dialogTitle: "Section Box", actions: { hide: "Hide", reverse: "Reverse", fitToModel: "Fit", reset: "Reset" }, axes: { x: "X", y: "Y", z: "Z" } }, walkControl: { speed: "Speed:", gravity: "Gravity", collision: "Collision", characterModel: { label: "Construction Worker", constructionWorker: "Construction Worker", officeMale: "Office Male" }, walkMode: { label: "Walk Mode", walk: "Walk", run: "Run" }, exit: "Exit", path: { dialogTitle: "Path Walk" } }, map: { dialogTitle: "Map" } }; class yf { currentLocale = "zh-CN"; messages = { "zh-CN": bf, "en-US": _f }; listeners = []; constructor() { } /** * 获取当前语言 */ getLocale() { return this.currentLocale; } /** * 切换语言 */ setLocale(e) { this.currentLocale !== e && (this.currentLocale = e, this.notifyListeners()); } /** * 翻译核心方法 */ t(e) { if (!e) return ""; const t = e.split("."); let n = this.messages[this.currentLocale]; for (const i of t) if (n && typeof n == "object" && i in n) n = n[i]; else return e; return n; } /** * 订阅变更 */ subscribe(e) { return this.listeners.push(e), () => { this.listeners = this.listeners.filter((t) => t !== e); }; } notifyListeners() { this.listeners.forEach((e) => e(this.currentLocale)); } } const Vt = new yf(), Ae = (s) => Vt.t(s), Pc = { name: "light", primary: "#2563eb", primaryHover: "#1d4ed8", primaryActive: "#1e40af", primarySubtle: "rgba(37, 99, 235, 0.1)", success: "#16a34a", successHover: "#15803d", successSubtle: "rgba(22, 163, 74, 0.1)", warning: "#d97706", warningHover: "#b45309", warningSubtle: "rgba(217, 119, 6, 0.1)", danger: "#dc2626", dangerHover: "#b91c1c", dangerSubtle: "rgba(220, 38, 38, 0.1)", info: "#0891b2", infoHover: "#0e7490", infoSubtle: "rgba(8, 145, 178, 0.1)", bgBase: "#f8fafc", bgElevated: "#ffffff", bgOverlay: "rgba(255, 255, 255, 0.98)", bgInset: "#f1f5f9", bgGlass: "rgba(255, 255, 255, 0.8)", bgGlassBlur: "24px", textPrimary: "#0f172a", textSecondary: "#475569", textTertiary: "#94a3b8", textDisabled: "#cbd5e1", textInverse: "#ffffff", textLink: "#2563eb", textLinkHover: "#1d4ed8", iconDefault: "#64748b", iconHover: "#334155", iconActive: "#2563eb", iconDisabled: "#cbd5e1", iconInverse: "#ffffff", borderDefault: "#e2e8f0", borderSubtle: "#f1f5f9", borderStrong: "#cbd5e1", borderDisabled: "#f1f5f9", divider: "#e2e8f0", componentBg: "transparent", componentBgHover: "rgba(15, 23, 42, 0.04)", componentBgActive: "rgba(15, 23, 42, 0.08)", componentBgSelected: "rgba(37, 99, 235, 0.08)", componentBgDisabled: "#f8fafc", focusRing: "rgba(37, 99, 235, 0.5)", focusRingOffset: "#ffffff", selectionBg: "rgba(37, 99, 235, 0.15)", selectionText: "#0f172a", shadowSm: "0 2px 8px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08)", shadowMd: "0 4px 12px rgba(0, 0, 0, 0.12), 0 6px 20px rgba(0, 0, 0, 0.1)", shadowLg: "0 10px 25px rgba(0, 0, 0, 0.15), 0 6px 10px rgba(0, 0, 0, 0.1)", shadowXl: "0 20px 40px rgba(0, 0, 0, 0.2), 0 10px 15px rgba(0, 0, 0, 0.1)", shadowGlow: "0 2px 8px rgba(59, 130, 246, 0.3), 0 4px 16px rgba(59, 130, 246, 0.2)", scrollbarTrack: "#f1f5f9", scrollbarThumb: "#cbd5e1", scrollbarThumbHover: "#94a3b8", floatingBg: "rgba(255, 255, 255, 0.8)", floatingBorder: "rgba(226, 232, 240, 0.5)", floatingShadow: "0 4px 24px rgba(0, 0, 0, 0.06)", floatingBtnBg: "rgba(255, 255, 255, 0.9)", floatingBtnBorder: "rgba(203, 213, 225, 0.6)", floatingBtnShadow: "0 2px 8px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08)", floatingBtnBgHover: "#ffffff", floatingBtnShadowHover: "0 4px 12px rgba(0, 0, 0, 0.12), 0 6px 20px rgba(0, 0, 0, 0.1)", floatingIconColor: "#334155", floatingIconColorHover: "#1e293b", panelBg: "rgba(255, 255, 255, 0.95)", panelBorder: "rgba(226, 232, 240, 0.6)", panelHeaderBg: "rgba(248, 250, 252, 0.9)", panelRadius: "12px", tabBg: "#f1f5f9", tabItemBg: "transparent", tabItemBgHover: "rgba(255, 255, 255, 0.6)", tabItemBgActive: "#ffffff", tabItemTextActive: "#2563eb", overrides: { dialog: { headerBg: "#f8fafc" }, toolbar: { bg: "rgba(255, 255, 255, 0.9)", buttonBg: "rgba(255, 255, 255, 0.95)", buttonBgHover: "#ffffff", buttonBgActive: "#2563eb" }, input: { bg: "#ffffff", bgFocus: "#ffffff", placeholder: "#94a3b8" } } }, Mf = { name: "dark", primary: "#3b82f6", primaryHover: "#60a5fa", primaryActive: "#2563eb", primarySubtle: "rgba(59, 130, 246, 0.15)", success: "#22c55e", successHover: "#4ade80", successSubtle: "rgba(34, 197, 94, 0.15)", warning: "#f59e0b", warningHover: "#fbbf24", warningSubtle: "rgba(245, 158, 11, 0.15)", danger: "#ef4444", dangerHover: "#f87171", dangerSubtle: "rgba(239, 68, 68, 0.15)", info: "#06b6d4", infoHover: "#22d3ee", infoSubtle: "rgba(6, 182, 212, 0.15)", bgBase: "#152232", bgElevated: "#1f2d3e", bgOverlay: "rgba(21, 34, 50, 0.98)", bgInset: "#152232", bgGlass: "rgba(21, 34, 50, 0.85)", bgGlassBlur: "24px", textPrimary: "#ffffff", textSecondary: "#94a3b8", textTertiary: "#64748b", textDisabled: "#475569", textInverse: "#152232", textLink: "#60a5fa", textLinkHover: "#93c5fd", iconDefault: "#ffffff", iconHover: "#ffffff", iconActive: "#3b82f6", iconDisabled: "#475569", iconInverse: "#152232", borderDefault: "rgba(51, 65, 85, 0.5)", borderSubtle: "rgba(51, 65, 85, 0.5)", borderStrong: "#475569", borderDisabled: "#1e293b", divider: "#334155", componentBg: "transparent", componentBgHover: "rgba(248, 250, 252, 0.06)", componentBgActive: "rgba(248, 250, 252, 0.1)", componentBgSelected: "rgba(59, 130, 246, 0.2)", componentBgDisabled: "#1e293b", focusRing: "rgba(59, 130, 246, 0.5)", focusRingOffset: "#1e293b", selectionBg: "rgba(59, 130, 246, 0.3)", selectionText: "#f8fafc", shadowSm: "0 2px 8px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3)", shadowMd: "0 4px 12px rgba(0, 0, 0, 0.5), 0 6px 20px rgba(0, 0, 0, 0.4)", shadowLg: "0 10px 25px rgba(0, 0, 0, 0.6), 0 6px 10px rgba(0, 0, 0, 0.4)", shadowXl: "0 20px 40px rgba(0, 0, 0, 0.7), 0 10px 15px rgba(0, 0, 0, 0.5)", shadowGlow: "0 2px 8px rgba(59, 130, 246, 0.4), 0 4px 16px rgba(59, 130, 246, 0.25)", scrollbarTrack: "#1e293b", scrollbarThumb: "#475569", scrollbarThumbHover: "#64748b", floatingBg: "rgba(15, 23, 42, 0.85)", floatingBorder: "rgba(51, 65, 85, 0.4)", floatingShadow: "0 4px 24px rgba(0, 0, 0, 0.25)", floatingBtnBg: "rgba(51, 65, 85, 0.6)", floatingBtnBorder: "rgba(100, 116, 139, 0.5)", floatingBtnShadow: "0 2px 8px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25)", floatingBtnBgHover: "rgba(71, 85, 105, 0.7)", floatingBtnShadowHover: "0 4px 12px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.3)", floatingIconColor: "#e2e8f0", floatingIconColorHover: "#f8fafc", panelBg: "rgba(15, 23, 42, 0.95)", panelBorder: "rgba(51, 65, 85, 0.5)", panelHeaderBg: "rgba(15, 23, 42, 0.9)", panelRadius: "12px", tabBg: "rgba(30, 41, 59, 0.6)", tabItemBg: "transparent", tabItemBgHover: "rgba(51, 65, 85, 0.5)", tabItemBgActive: "rgba(51, 65, 85, 0.8)", tabItemTextActive: "#60a5fa", overrides: { dialog: { headerBg: "#0f172a" }, toolbar: { bg: "rgba(30, 41, 59, 0.9)", buttonBg: "rgba(51, 65, 85, 0.6)", buttonBgHover: "rgba(71, 85, 105, 0.7)", buttonBgActive: "#3b82f6" }, input: { bg: "#0f172a", bgFocus: "#1e293b", placeholder: "#64748b" } } }; class Sf { currentTheme = Pc; listeners = []; constructor() { } /** * 获取当前主题配置 */ getTheme() { return this.currentTheme; } /** * 切换预设主题 * @param themeName 'dark' | 'light' */ setTheme(e) { e === "light" ? this.applyTheme(Pc) : this.applyTheme(Mf); } /** * 应用自定义主题配置 * @param theme 配置对象 */ 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 st = new Sf(); class jl { container; options; groups = []; activeBtnIds = /* @__PURE__ */ new Set(); btnRefs = /* @__PURE__ */ new Map(); dropdownElement = null; hoverTimeout = null; customColors = /* @__PURE__ */ new Set(); // 记录用户自定义的颜色属性 unsubscribeLocale = null; unsubscribeTheme = null; engine = null; DEFAULT_ICON = ''; constructor(e) { const t = typeof e.container == "string" ? document.getElementById(e.container) : e.container; if (!t) throw new Error("Container not found"); this.container = t, this.options = { showLabel: !0, visibility: {}, direction: "row", // 默认横向 position: "static", // 默认静态定位 align: "vertical", // 默认图标在上 expand: "down", // 默认向下展开 ...e }, [ "backgroundColor", "btnBackgroundColor", "btnHoverColor", "btnActiveColor", "iconColor", "iconActiveColor", "textColor", "textActiveColor" ].forEach((i) => { e[i] && this.customColors.add(i); }), this.initContainer(), this.applyStyles(); } 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.options.type && this.options.type !== "default" && this.container.classList.add(`type-${this.options.type}`), this.updatePosition(), this.setupEventInterception(this.container); } /** * 设置事件拦截,防止事件冒泡到下层元素(如 3D 引擎) */ setupEventInterception(e) { const t = (i) => { i.stopPropagation(); }; [ "click", "dblclick", "contextmenu", "wheel", "mousedown", "mouseup", "mousemove", "touchstart", "touchend", "touchmove", "pointerdown", "pointerup", "pointermove", "pointerenter", "pointerleave", "pointerover", "pointerout" ].forEach((i) => { e.addEventListener(i, t, { passive: !1 }); }); } updatePosition() { const e = this.options.position, t = this.container.style; if (t.top = "", t.bottom = "", t.left = "", t.right = "", t.transform = "", e === "static") { this.container.classList.add("static"); return; } if (this.container.classList.remove("static"), this.container.style.position = "absolute", typeof e == "object" && "x" in e) t.left = `${e.x}px`, t.top = `${e.y}px`; else { const n = "20px"; switch (e) { case "top-left": t.top = n, t.left = n; break; case "top-center": t.top = n, t.left = "50%", t.transform = "translateX(-50%)"; break; case "top-right": t.top = n, t.right = n; break; case "bottom-left": t.bottom = n, t.left = n; break; case "bottom-center": t.bottom = n, t.left = "50%", t.transform = "translateX(-50%)"; break; case "bottom-right": t.bottom = n, t.right = n; break; case "left-center": t.left = n, t.top = "50%", t.transform = "translateY(-50%)"; break; case "right-center": t.right = n, t.top = "50%", t.transform = "translateY(-50%)"; break; case "center": t.top = "50%", t.left = "50%", t.transform = "translate(-50%, -50%)"; break; } } } /** * 应用样式到容器 */ applyStyles() { const e = this.container.style; this.options.backgroundColor && e.setProperty("--bim-btn-group-section-bg", this.options.backgroundColor), this.options.btnBackgroundColor && e.setProperty("--bim-btn-bg", this.options.btnBackgroundColor), this.options.btnHoverColor && e.setProperty("--bim-btn-hover-bg", this.options.btnHoverColor), this.options.btnActiveColor && e.setProperty("--bim-btn-active-bg", this.options.btnActiveColor), this.options.iconColor && e.setProperty("--bim-icon-color", this.options.iconColor), this.options.iconActiveColor && e.setProperty("--bim-icon-active-color", this.options.iconActiveColor), this.options.textColor && e.setProperty("--bim-btn-text-color", this.options.textColor), this.options.textActiveColor && e.setProperty("--bim-btn-text-active-color", this.options.textActiveColor), document.querySelectorAll(".opt-btn-dropdown").forEach((n) => { const i = n.style; this.options.iconColor && i.setProperty("--bim-icon-color", this.options.iconColor), this.options.iconActiveColor && i.setProperty("--bim-icon-active-color", this.options.iconActiveColor), this.options.textColor && i.setProperty("--bim-btn-text-color", this.options.textColor), this.options.textActiveColor && i.setProperty("--bim-btn-text-active-color", this.options.textActiveColor), this.options.btnBackgroundColor && i.setProperty("--bim-btn-bg", this.options.btnBackgroundColor), this.options.btnHoverColor && i.setProperty("--bim-btn-hover-bg", this.options.btnHoverColor), this.options.btnActiveColor && i.setProperty("--bim-btn-active-bg", this.options.btnActiveColor); }); } /** * 设置主题的primary颜色(用于边框等) */ setPrimaryColor(e) { this.container.style.setProperty("--bim-primary-color", e), document.querySelectorAll(".opt-btn-dropdown").forEach((n) => { n.style.setProperty("--bim-primary-color", e); }); } /** * 设置主题颜色 * 只会应用到没有被用户自定义的颜色属性上 */ setTheme(e) { const t = { backgroundColor: e.bgElevated, btnBackgroundColor: e.componentBg, btnHoverColor: e.componentBgHover, btnActiveColor: e.componentBgActive, iconColor: e.iconDefault, iconActiveColor: e.iconActive, textColor: e.textSecondary, textActiveColor: e.textPrimary }; Object.entries(t).forEach(([n, i]) => { const r = n; this.customColors.has(r) || (this.options[r] = i); }), this.container.classList.remove("theme-dark", "theme-light"), this.container.classList.add(`theme-${e.name}`), this.applyStyles(), this.setPrimaryColor(e.primary), this.applyThemeCssVars(e); } /** * 应用主题系统的 CSS 变量到容器 * 供 glass-pill 等样式变体使用 */ applyThemeCssVars(e) { const t = this.container.style; t.setProperty("--bim-primary", e.primary), t.setProperty("--bim-primary-hover", e.primaryHover), t.setProperty("--bim-primary-active", e.primaryActive), t.setProperty("--bim-bg-glass", e.bgGlass), t.setProperty("--bim-bg-glass-blur", e.bgGlassBlur), t.setProperty("--bim-bg-elevated", e.bgElevated), t.setProperty("--bim-bg-overlay", e.bgOverlay), t.setProperty("--bim-bg-inset", e.bgInset), t.setProperty("--bim-text-primary", e.textPrimary), t.setProperty("--bim-text-secondary", e.textSecondary), t.setProperty("--bim-text-tertiary", e.textTertiary), t.setProperty("--bim-text-inverse", e.textInverse), t.setProperty("--bim-icon-default", e.iconDefault), t.setProperty("--bim-icon-hover", e.iconHover), t.setProperty("--bim-icon-active", e.iconActive), t.setProperty("--bim-icon-inverse", e.iconInverse), t.setProperty("--bim-border-default", e.borderDefault), t.setProperty("--bim-border-subtle", e.borderSubtle), t.setProperty("--bim-component-bg-hover", e.componentBgHover), t.setProperty("--bim-component-bg-active", e.componentBgActive), t.setProperty("--bim-shadow-sm", e.shadowSm), t.setProperty("--bim-shadow-md", e.shadowMd), t.setProperty("--bim-shadow-lg", e.shadowLg), t.setProperty("--bim-shadow-glow", e.shadowGlow), t.setProperty("--bim-floating-bg", e.floatingBg), t.setProperty("--bim-floating-border", e.floatingBorder), t.setProperty("--bim-floating-shadow", e.floatingShadow), t.setProperty("--bim-floating-btn-bg", e.floatingBtnBg), t.setProperty("--bim-floating-btn-border", e.floatingBtnBorder), t.setProperty("--bim-floating-btn-shadow", e.floatingBtnShadow), t.setProperty("--bim-floating-btn-bg-hover", e.floatingBtnBgHover), t.setProperty("--bim-floating-btn-shadow-hover", e.floatingBtnShadowHover), t.setProperty("--bim-floating-icon-color", e.floatingIconColor), t.setProperty("--bim-floating-icon-color-hover", e.floatingIconColorHover), this.syncDropdownCssVars(e); } /** * 同步 CSS 变量到所有 dropdown 元素 * dropdown 被添加到 body,无法继承容器的 CSS 变量 */ syncDropdownCssVars(e) { document.querySelectorAll(".opt-btn-dropdown").forEach((n) => { const i = n.style; i.setProperty("--bim-primary", e.primary), i.setProperty("--bim-bg-overlay", e.bgOverlay), i.setProperty("--bim-border-default", e.borderDefault), i.setProperty("--bim-text-primary", e.textPrimary), i.setProperty("--bim-text-inverse", e.textInverse), i.setProperty("--bim-shadow-lg", e.shadowLg), i.setProperty("--bim-floating-btn-bg", e.floatingBtnBg), i.setProperty("--bim-floating-btn-bg-hover", e.floatingBtnBgHover), i.setProperty("--bim-floating-icon-color", e.floatingIconColor); }); } /** * 直接设置颜色(强制覆盖) * 设置的颜色会被标记为自定义,后续的 setTheme 不会覆盖它们 */ setColors(e) { this.options = { ...this.options, ...e }, Object.keys(e).forEach((t) => { this.customColors.add(t); }), this.applyStyles(); } async init() { this.render(), this.unsubscribeLocale = Vt.subscribe(() => { this.setLocales(); }), this.unsubscribeTheme = st.subscribe((e) => { this.setTheme(e); }); } setLocales() { this.render(); } addGroup(e, t) { if (this.groups.some((i) => i.id === e)) return; const n = { id: e, buttons: [] }; if (t) { const i = this.groups.findIndex((r) => r.id === t); i !== -1 ? this.groups.splice(i, 0, n) : this.groups.push(n); } else this.groups.push(n); } addButton(e) { const { groupId: t, parentId: n } = e, i = this.groups.find((a) => a.id === t); if (!i) return; const r = { ...e, children: e.children || [] }; if (n) { const a = this.findButton(i.buttons, n); a && (a.children || (a.children = []), a.children.push(r)); } else i.buttons.push(r); } findButton(e, t) { for (const n of e) { if (n.id === t) return n; if (n.children) { const i = this.findButton(n.children, t); if (i) return i; } } } render() { this.container.innerHTML = "", this.btnRefs.clear(), this.groups.forEach((e, t) => { const n = this.renderGroup(e, t, this.groups.length); this.container.appendChild(n); }); } renderGroup(e, t, n) { const i = document.createElement("div"); return i.className = "bim-btn-group-section", t < n - 1 && i.classList.add("has-divider"), e.buttons.forEach((r) => { if (this.isVisible(r.id)) { const a = this.renderButton(r); i.appendChild(a); } }), i; } renderButton(e) { const t = document.createElement("div"); t.className = "opt-btn-wrapper"; const n = document.createElement("div"); n.className = "opt-btn", e.isActive && this.activeBtnIds.add(e.id), (e.align || this.options.align || "vertical") === "horizontal" ? n.classList.add("align-horizontal") : n.classList.add("align-vertical"), this.activeBtnIds.has(e.id) && n.classList.add("active"), e.disabled && n.classList.add("disabled"), this.options.showLabel && e.label || (n.classList.add("no-label"), e.label && (n.title = Ae(e.label))); const a = e.iconSize || 32, o = e.minWidth || 50; n.style.minWidth = `${o}px`; const l = document.createElement("div"); l.className = "opt-btn-icon", l.style.width = `${a}px`, l.style.height = `${a}px`, l.innerHTML = this.getIcon(e.icon), n.appendChild(l); const c = document.createElement("div"); if (c.className = "opt-btn-text-wrapper", this.options.showLabel && e.label) { const h = document.createElement("span"); h.className = "opt-btn-label", h.textContent = Ae(e.label), c.appendChild(h); } return c.hasChildNodes() && n.appendChild(c), n.addEventListener("click", () => this.handleClick(e)), n.addEventListener("mouseenter", () => this.handleMouseEnter(e, n)), n.addEventListener("mouseleave", () => this.handleMouseLeave()), this.btnRefs.set(e.id, n), t.appendChild(n), t; } /** * 设置按钮的激活状态 * @param id 按钮 ID * @param active 可选,如果不传则切换(toggle)当前状态 */ setBtnActive(e, t) { const n = this.findButtonById(e); if (!n) return; const i = t !== void 0 ? t : !this.activeBtnIds.has(e); i ? this.activeBtnIds.add(e) : this.activeBtnIds.delete(e), n.isActive = i, this.updateButtonState(e); } handleClick(e) { if (!e.disabled && (!e.children || e.children.length === 0)) { if (e.keepActive) { const n = !this.activeBtnIds.has(e.id); this.setBtnActive(e.id, n), n && e.exclusive && e.groupId && this.deactivateExclusiveSiblings(e); } this.closeDropdown(), e.onClick && e.onClick(e); } } /** * 互斥关闭同范围内的其它已激活按钮,并触发它们的 onClick * @param button 当前被激活的按钮 */ deactivateExclusiveSiblings(e) { const t = this.groups.find((n) => n.id === e.groupId); if (t) { if (e.parentId) { const i = this.findButton(t.buttons, e.parentId)?.children || []; for (const r of i) r && r.id !== e.id && r.parentId === e.parentId && r.groupId === e.groupId && this.activeBtnIds.has(r.id) && (this.setBtnActive(r.id, !1), r.onClick && r.onClick(r)); return; } for (const n of t.buttons) n.id !== e.id && n.groupId === e.groupId && (n.parentId || this.activeBtnIds.has(n.id) && (this.setBtnActive(n.id, !1), n.onClick && n.onClick(n))); } } handleMouseEnter(e, t) { this.hoverTimeout && clearTimeout(this.hoverTimeout), e.children && e.children.length > 0 ? this.showDropdown(e, t) : this.closeDropdown(); } handleMouseLeave() { this.hoverTimeout = window.setTimeout(() => this.closeDropdown(), 200); } showDropdown(e, t) { if (this.closeDropdown(), !e.children) return; const n = document.createElement("div"); n.className = "opt-btn-dropdown", this.options.backgroundColor && n.style.setProperty("--bim-toolbar-bg", this.options.backgroundColor); const i = n.style; this.options.iconColor && i.setProperty("--bim-icon-color", this.options.iconColor), this.options.iconActiveColor && i.setProperty("--bim-icon-active-color", this.options.iconActiveColor), this.options.textColor && i.setProperty("--bim-btn-text-color", this.options.textColor), this.options.textActiveColor && i.setProperty("--bim-btn-text-active-color", this.options.textActiveColor), this.options.btnBackgroundColor && i.setProperty("--bim-btn-bg", this.options.btnBackgroundColor), this.options.btnHoverColor && i.setProperty("--bim-btn-hover-bg", this.options.btnHoverColor), this.options.btnActiveColor && i.setProperty("--bim-btn-active-bg", this.options.btnActiveColor); const r = t.getBoundingClientRect(), a = this.options.expand || "down"; this.options.direction === "row" ? n.style.flexDirection = "column" : n.style.flexDirection = "row", this.options.type && this.options.type !== "default" && n.classList.add(`type-${this.options.type}`); const o = st.getTheme(); n.classList.add(`theme-${o.name}`), i.setProperty("--bim-primary", o.primary), i.setProperty("--bim-bg-overlay", o.bgOverlay), i.setProperty("--bim-border-default", o.borderDefault), i.setProperty("--bim-text-primary", o.textPrimary), i.setProperty("--bim-text-inverse", o.textInverse), i.setProperty("--bim-shadow-lg", o.shadowLg), i.setProperty("--bim-floating-btn-bg", o.floatingBtnBg), i.setProperty("--bim-floating-btn-bg-hover", o.floatingBtnBgHover), i.setProperty("--bim-floating-icon-color", o.floatingIconColor), document.body.appendChild(n), this.setupEventInterception(n), e.children.forEach((c) => { if (this.isVisible(c.id)) { const h = this.renderDropdownItem(c); n.appendChild(h); } }); const l = n.getBoundingClientRect(); a === "up" ? (n.style.bottom = window.innerHeight - r.top + 8 + "px", n.style.left = r.left + (r.width - l.width) / 2 + "px") : a === "down" ? (n.style.top = r.bottom + 8 + "px", n.style.left = r.left + (r.width - l.width) / 2 + "px") : a === "right" ? (n.style.top = r.top + (r.height - l.height) / 2 + "px", n.style.left = r.right + 8 + "px") : a === "left" && (n.style.top = r.top + (r.height - l.height) / 2 + "px", n.style.right = window.innerWidth - r.left + 8 + "px"), n.addEventListener("mouseenter", () => { this.hoverTimeout && clearTimeout(this.hoverTimeout); }), n.addEventListener("mouseleave", () => this.handleMouseLeave()), this.dropdownElement = n; } renderDropdownItem(e) { const t = document.createElement("div"); t.className = "opt-btn-dropdown-item", (e.align || "horizontal") === "horizontal" ? t.classList.add("align-horizontal") : t.classList.add("align-vertical"), (this.activeBtnIds.has(e.id) || e.isActive) && t.classList.add("active"); const i = e.iconSize || 32, r = e.minWidth; r && (t.style.minWidth = `${r}px`); const a = document.createElement("div"); if (a.className = "opt-btn-icon", a.style.width = `${i}px`, a.style.height = `${i}px`, a.innerHTML = this.getIcon(e.icon), t.appendChild(a), this.options.showLabel && e.label) { const o = document.createElement("span"); o.className = "opt-btn-dropdown-label", o.textContent = Ae(e.label), t.appendChild(o); } else e.label && (t.title = Ae(e.label)); return t.addEventListener("click", (o) => { o.stopPropagation(), this.handleClick(e); }), t; } closeDropdown() { this.dropdownElement && (this.dropdownElement.remove(), this.dropdownElement = null), this.btnRefs.forEach((e) => { const t = e.querySelector(".opt-btn-arrow"); t && t.classList.remove("rotated"); }); } updateButtonState(e) { const t = this.btnRefs.get(e); t && (this.activeBtnIds.has(e) ? t.classList.add("active") : t.classList.remove("active")); } getIcon(e) { return e || this.DEFAULT_ICON; } updateButtonVisibility(e, t) { this.options.visibility || (this.options.visibility = {}), this.options.visibility[e] = t, this.render(); } setShowLabel(e) { this.options.showLabel = e, this.updateLabelsVisibility(); } updateLabelsVisibility() { this.btnRefs.forEach((e, t) => { const n = this.findButtonById(t); if (!n) return; this.options.showLabel && n.label ? (e.classList.remove("no-label"), e.removeAttribute("title")) : (e.classList.add("no-label"), n.label && (e.title = Ae(n.label))); }); } findButtonById(e) { for (const t of this.groups) { const n = this.findButton(t.buttons, e); if (n) return n; } } setBackgroundColor(e) { this.setColors({ backgroundColor: e }); } isVisible(e) { return this.options.visibility?.[e] !== !1; } destroy() { this.unsubscribeLocale && (this.unsubscribeLocale(), this.unsubscribeLocale = null), this.unsubscribeTheme && (this.unsubscribeTheme(), this.unsubscribeTheme = null), this.closeDropdown(), this.container.innerHTML = "", this.btnRefs.clear(); } } class wf extends jl { /** * 重写初始化,加载默认按钮 */ async init() { await super.init(); const { createHomeButton: e } = await Promise.resolve().then(() => M3), { createZoomBoxButton: t } = await Promise.resolve().then(() => w3), { createWalkMenuButton: n } = await Promise.resolve().then(() => T3), { createMapButton: i } = await Promise.resolve().then(() => A3), { createPropertyButton: r } = await Promise.resolve().then(() => R3), { createSettingButton: a } = await Promise.resolve().then(() => D3), { createInfoButton: o } = await Promise.resolve().then(() => k3), { createFullscreenButton: l } = await Promise.resolve().then(() => B3), { createMeasureButton: c } = await Promise.resolve().then(() => F3), { createSectionMenuButton: h } = await Promise.resolve().then(() => H3), { createSectionPlaneButton: u } = await Promise.resolve().then(() => G3), { createSectionAxisButton: f } = await Promise.resolve().then(() => X3), { createSectionBoxButton: d } = await Promise.resolve().then(() => Z3); this.addGroup("group-1"), this.engine ? (this.addButton(e(this.engine)), this.addButton(t(this.engine)), this.addButton(c(this.engine)), this.addButton(h(this.engine)), this.addButton(u(this.engine)), this.addButton(f(this.engine)), this.addButton(d(this.engine)), this.addButton(n(this.engine)), this.addButton(i(this.engine)), this.addButton(r(this.engine)), this.addGroup("group-2"), this.addButton(a(this.engine)), this.addButton(o(this.engine)), this.addButton(l(this.engine))) : console.warn("[Toolbar] Engine not available when creating buttons."), this.render(); } } class hn { engine; constructor(e) { this.engine = e; } /** * Helper to send events easily */ emit(e, t) { this.engine.emit(e, t); } /** * Helper to listen to events easily * Returns an unsubscribe function */ on(e, t) { return this.engine.on(e, t); } } class Ef extends hn { 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 wf({ container: this.toolbarContainer, type: "glass-pill", showLabel: !0, direction: "row", position: "bottom-right", 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; } // --- 转发 API --- 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); } /** * 隐藏工具栏 */ hide() { this.toolbarContainer && (this.toolbarContainer.style.display = "none"); } /** * 显示工具栏 */ show() { this.toolbarContainer && (this.toolbarContainer.style.display = ""); } /** * 获取工具栏容器 */ getContainer() { return this.toolbarContainer; } } class Tf extends hn { groups = /* @__PURE__ */ new Map(); container; constructor(e, t) { super(e), this.container = t; } create(e, t) { const n = new jl({ container: this.container, ...t }); return n.setEngine(this.engine), n.init(), this.groups.set(e, n), n; } get(e) { return this.groups.get(e); } updateTheme(e) { this.groups.forEach((t) => t.setTheme(e)); } destroy() { this.groups.forEach((e) => e.destroy()), this.groups.clear(); } } class Du { element; options; container; header; contentArea; _isDestroyed = !1; _isInitialized = !1; unsubscribeTheme = null; unsubscribeLocale = null; // 性能优化:用于存储 requestAnimationFrame 的 ID rafId = null; /** * 构造函数 * @param options 弹窗配置选项 */ 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(); } /** * 设置主题 * @param theme 全局主题配置 */ setTheme(e) { const t = this.element.style; this.options.backgroundColor || t.setProperty("--bim-dialog-bg", e.bgElevated), this.options.headerBackgroundColor || t.setProperty("--bim-dialog-header-bg", e.bgInset), this.options.titleColor || t.setProperty("--bim-dialog-title-color", e.textPrimary), this.options.textColor || t.setProperty("--bim-dialog-text-color", e.textSecondary), this.options.borderColor || t.setProperty("--bim-dialog-border-color", e.borderDefault), t.setProperty("--bim-bg-elevated", e.bgElevated), t.setProperty("--bim-bg-inset", e.bgInset), t.setProperty("--bim-text-primary", e.textPrimary), t.setProperty("--bim-text-secondary", e.textSecondary), t.setProperty("--bim-text-tertiary", e.textTertiary), t.setProperty("--bim-border-default", e.borderDefault), t.setProperty("--bim-shadow-lg", e.shadowLg); } /** * 初始化组件功能 (接口实现) */ init() { this._isInitialized || (this.container.appendChild(this.element), this.initPosition(), this.options.draggable && this.initDrag(), this.options.resizable && this.initResize(), this._isInitialized = !0, this.options.onOpen && this.options.onOpen(), this.unsubscribeTheme = st.subscribe((e) => { this.setTheme(e); }), this.unsubscribeLocale = Vt.subscribe(() => { this.setLocales(); })); } setLocales() { if (this.options.title) { const e = this.header.querySelector(".bim-dialog-title"); e && (e.textContent = Ae(this.options.title)); } } /** * 创建弹窗的 DOM 结构 */ createDom() { const e = document.createElement("div"); e.className = "bim-dialog", this.options.id && (e.id = this.options.id); const t = e.style; this.options.backgroundColor && t.setProperty("--bim-dialog-bg", this.options.backgroundColor), this.options.headerBackgroundColor && t.setProperty("--bim-dialog-header-bg", this.options.headerBackgroundColor), this.options.titleColor && t.setProperty("--bim-dialog-title-color", this.options.titleColor), this.options.textColor && t.setProperty("--bim-dialog-text-color", this.options.textColor), this.options.borderColor && t.setProperty("--bim-dialog-border-color", this.options.borderColor), this.setSize(e, this.options.width, this.options.height), this.options.minWidth && (e.style.minWidth = `${this.options.minWidth}px`); const n = document.createElement("div"); n.className = "bim-dialog-header", this.options.draggable && n.classList.add("draggable"); const i = document.createElement("span"); i.className = "bim-dialog-title", i.textContent = this.options.title ? Ae(this.options.title) : ""; const r = document.createElement("span"); r.className = "bim-dialog-close", r.innerHTML = "×", r.onclick = () => { this.close(); }, n.appendChild(i), n.appendChild(r); const a = document.createElement("div"); if (a.className = "bim-dialog-content", typeof this.options.content == "string" ? a.innerHTML = this.options.content : this.options.content instanceof HTMLElement && a.appendChild(this.options.content), e.appendChild(n), e.appendChild(a), this.options.resizable) { const c = document.createElement("div"); c.className = "bim-dialog-resize-handle", e.appendChild(c); } const o = (c) => { c.stopPropagation(); }; return [ "click", "dblclick", "contextmenu", "wheel", "mousedown", "mouseup", "mousemove", "touchstart", "touchend", "touchmove", "pointerdown", "pointerup", "pointermove", "pointerenter", "pointerleave", "pointerover", "pointerout" ].forEach((c) => { e.addEventListener(c, o, { passive: !1 }); }), e; } /** * 设置元素尺寸 */ setSize(e, t, n) { t !== void 0 && (t === "auto" || t === "fit-content" ? e.style.width = t : e.style.width = typeof t == "number" ? `${t}px` : t), n !== void 0 && (n === "auto" || n === "fit-content" ? e.style.height = n : e.style.height = typeof n == "number" ? `${n}px` : n); } /** * 根据内容自动调整弹窗宽度 * @param recenter 是否重新计算定位(例如保持居中),默认 true */ fitWidth(e = !1) { this.element.style.width = "fit-content", e && this.initPosition(); } /** * 根据内容自动调整弹窗高度 * * 设计说明: * - 主要用于“内容展开/收起”场景(比如测量面板展开后,Dialog 高度跟随变化) * - 默认不改变用户拖拽后的当前位置,只做边界夹紧,避免弹窗超出容器 * * @param recenter 是否根据 options.position 重新定位(默认 false) */ fitHeight(e = !1) { this.element.style.height = "auto"; const t = this.element.getBoundingClientRect().height, n = this.options.minHeight ?? 100, i = this.container.clientHeight || 0; let r = Math.max(n, t); i > 0 && (r = Math.min(r, i)), this.element.style.height = `${r}px`, e ? this.initPosition() : this.clampToContainer(); } /** * 边界夹紧:保持当前 left/top 不变的前提下,确保弹窗不超出容器 * 说明:用于 fitHeight / fitWidth 后的“尺寸变化”场景,避免弹窗被裁切。 */ clampToContainer() { const e = this.container.clientWidth, t = this.container.clientHeight, n = this.element.offsetWidth, i = this.element.offsetHeight, r = this.element.offsetLeft, a = this.element.offsetTop, o = Math.max(0, e - n), l = Math.max(0, t - i), c = Math.max(0, Math.min(r, 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 n = 0, i = 0; const r = this.container.clientWidth, a = this.container.clientHeight, o = t.width, l = t.height; if (typeof e == "object" && "x" in e) n = e.x, i = e.y; else switch (e) { case "center": n = (r - o) / 2, i = (a - l) / 2; break; case "top-left": n = 0, i = 0; break; case "top-center": n = (r - o) / 2, i = 0; break; case "top-right": n = r - o, i = 0; break; case "left-center": n = 0, i = (a - l) / 2; break; case "right-center": n = r - o, i = (a - l) / 2; break; case "bottom-left": n = 0, i = a - l; break; case "bottom-center": n = (r - o) / 2, i = a - l; break; case "bottom-right": n = r - o, i = a - l; break; default: n = (r - o) / 2, i = (a - l) / 2; } n = Math.max(0, Math.min(n, r - o)), i = Math.max(0, Math.min(i, a - l)), this.element.style.left = `${n}px`, this.element.style.top = `${i}px`; } /** * 初始化拖拽功能 (性能优化 + 解决粘手) */ initDrag() { let e = 0, t = 0, n = 0, i = 0, r = 0, a = 0, o = 0, l = 0; const c = (f) => { f.preventDefault(), f.stopPropagation(), e = f.clientX, t = f.clientY, n = this.element.offsetLeft, i = this.element.offsetTop, r = this.container.clientWidth, a = this.container.clientHeight, o = this.element.offsetWidth, l = this.element.offsetHeight, document.addEventListener("mousemove", h, { capture: !0 }), document.addEventListener("mouseup", u, { capture: !0 }); }, h = (f) => { f.preventDefault(), f.stopPropagation(), !this.rafId && (this.rafId = requestAnimationFrame(() => { const d = f.clientX - e, p = f.clientY - t; let g = n + d, x = i + p; const m = r - o, v = a - l; g = Math.max(0, Math.min(g, m)), x = Math.max(0, Math.min(x, v)), this.element.style.left = `${g}px`, this.element.style.top = `${x}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, n = 0, i = 0, r = 0; const a = (c) => { c.preventDefault(), c.stopPropagation(), t = c.clientX, n = c.clientY, i = this.element.offsetWidth, r = 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 - n, f = Math.max(this.options.minWidth || 100, i + h), d = Math.max(this.options.minHeight || 50, r + u); this.element.style.width = `${f}px`, this.element.style.height = `${d}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); } /** * 动态设置内容 * @param content 内容元素或 HTML 字符串 */ 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 Cf extends Du { /** * 构造函数 * @param container 父容器 */ constructor(e) { const t = document.createElement("div"); t.className = "bim-info-dialog-content"; const n = document.createElement("h3"); n.textContent = "Model Information"; const i = document.createElement("ul"); i.innerHTML = `
  • Name: Sample Project
  • Version: 1.0.0
  • Date: ${(/* @__PURE__ */ new Date()).toLocaleDateString()}
  • Status: Active
  • `; const r = document.createElement("button"); r.textContent = "Update Status", r.style.marginTop = "10px", r.onclick = () => { alert("Status updated!"); }, t.appendChild(n), t.appendChild(i), t.appendChild(r), super({ container: e, title: "dialog.testTitle", content: t, width: 320, height: "auto", position: "center", resizable: !0, draggable: !0, // 可以在这里添加特定的 onClose 逻辑 onClose: () => { console.log("Info dialog closed"); }, onOpen: () => { console.log("Info dialog opened"); } }); } // 不需要再手动实现 setTheme, destroy, close, init // 它们都已从 BimDialog 继承 } class Af extends hn { /** 弹窗挂载的父容器 */ container; /** 活跃的弹窗实例列表 */ activeDialogs = []; /** * 构造函数 * @param engine 引擎实例 * @param container 弹窗挂载的目标容器 */ constructor(e, t) { super(e), this.container = t, this.on("ui:open-dialog", (n) => { console.log("[DialogManager] Received open-dialog event:", n), n.id === "info" && this.showInfoDialog(); }); } /** * 创建一个通用弹窗 * @param options 弹窗配置选项(不需要传 container,自动使用管理器绑定的容器) * @returns BimDialog 实例 */ create(e) { const t = new Du({ container: this.container, ...e, onClose: () => { this.activeDialogs = this.activeDialogs.filter((n) => n !== t), e.onClose && e.onClose(); } }); return t.setTheme(st.getTheme()), this.activeDialogs.push(t), t; } /** * 显示二次封装的模型信息弹窗 * 演示如何调用特定的业务弹窗组件 */ showInfoDialog() { new Cf(this.container); } /** * 响应全局主题变更 * @param theme 全局主题配置 */ updateTheme(e) { this.activeDialogs.forEach((t) => { t.setTheme && t.setTheme(e); }); } destroy() { this.activeDialogs.forEach((e) => e.destroy()), this.activeDialogs = []; } } const Zl = "181", ls = { ROTATE: 0, DOLLY: 1, PAN: 2 }, rs = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, Pf = 0, Rc = 1, Rf = 2, Iu = 1, Nu = 2, ei = 3, Rn = 0, Jt = 1, Dt = 2, Ot = 0, cs = 1, Fo = 2, Lc = 3, Dc = 4, ku = 5, Tn = 100, Lf = 101, Df = 102, If = 103, Nf = 104, Xs = 200, kf = 201, Uf = 202, Bf = 203, zo = 204, Ho = 205, Vo = 206, Of = 207, Go = 208, Ff = 209, zf = 210, Hf = 211, Vf = 212, Gf = 213, Wf = 214, Wo = 0, Xo = 1, jo = 2, fs = 3, Zo = 4, qo = 5, Yo = 6, Ko = 7, Ca = 0, Xf = 1, jf = 2, gi = 0, Uu = 1, Bu = 2, Ou = 3, ql = 4, Fu = 5, zu = 6, Hu = 7, Ic = "attached", Zf = "detached", Vu = 300, ps = 301, ms = 302, $o = 303, Jo = 304, Aa = 306, Gn = 1e3, Hn = 1001, va = 1002, Gt = 1003, Gu = 1004, js = 1005, Ht = 1006, la = 1007, ti = 1008, Ln = 1009, Wu = 1010, Xu = 1011, ir = 1012, Yl = 1013, Ri = 1014, Pn = 1015, _n = 1016, Kl = 1017, $l = 1018, gs = 1020, ju = 35902, Zu = 35899, qu = 1021, Yu = 1022, sn = 1023, sr = 1026, xs = 1027, Jl = 1028, Ql = 1029, ec = 1030, tc = 1031, nc = 1033, ca = 33776, ha = 33777, ua = 33778, da = 33779, Qo = 35840, el = 35841, tl = 35842, nl = 35843, il = 36196, sl = 37492, rl = 37496, al = 37808, ol = 37809, ll = 37810, cl = 37811, hl = 37812, ul = 37813, dl = 37814, fl = 37815, pl = 37816, ml = 37817, gl = 37818, xl = 37819, vl = 37820, bl = 37821, _l = 36492, yl = 36494, Ml = 36495, Sl = 36283, wl = 36284, El = 36285, Tl = 36286, rr = 2300, ar = 2301, Ha = 2302, Nc = 2400, kc = 2401, Uc = 2402, qf = 2500, Yf = 0, Ku = 1, Cl = 2, Kf = 3200, $f = 3201, fr = 0, Jf = 1, pi = "", mt = "srgb", Tt = "srgb-linear", ba = "linear", ot = "srgb", Gi = 7680, Va = 7681, Ga = 34055, Wa = 34056, Qf = 517, Al = 519, ep = 512, tp = 513, np = 514, $u = 515, ip = 516, sp = 517, rp = 518, ap = 519, Pl = 35044, Bc = "300 es", Vn = 2e3, _a = 2001; function Ju(s) { for (let e = s.length - 1; e >= 0; --e) if (s[e] >= 65535) return !0; return !1; } function or(s) { return document.createElementNS("http://www.w3.org/1999/xhtml", s); } function op() { const s = or("canvas"); return s.style.display = "block", s; } const Oc = {}; function ya(...s) { const e = "THREE." + s.shift(); console.log(e, ...s); } function ze(...s) { const e = "THREE." + s.shift(); console.warn(e, ...s); } function et(...s) { const e = "THREE." + s.shift(); console.error(e, ...s); } function lr(...s) { const e = s.join(" "); e in Oc || (Oc[e] = !0, ze(...s)); } function lp(s, e, t) { return new Promise(function(n, i) { function r() { switch (s.clientWaitSync(e, s.SYNC_FLUSH_COMMANDS_BIT, 0)) { case s.WAIT_FAILED: i(); break; case s.TIMEOUT_EXPIRED: setTimeout(r, t); break; default: n(); } } setTimeout(r, t); }); } class Ui { /** * Adds the given event listener to the given event type. * * @param {string} type - The type of event to listen to. * @param {Function} listener - The function that gets called when the event is fired. */ addEventListener(e, t) { this._listeners === void 0 && (this._listeners = {}); const n = this._listeners; n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t); } /** * Returns `true` if the given event listener has been added to the given event type. * * @param {string} type - The type of event. * @param {Function} listener - The listener to check. * @return {boolean} Whether the given event listener has been added to the given event type. */ hasEventListener(e, t) { const n = this._listeners; return n === void 0 ? !1 : n[e] !== void 0 && n[e].indexOf(t) !== -1; } /** * Removes the given event listener from the given event type. * * @param {string} type - The type of event. * @param {Function} listener - The listener to remove. */ removeEventListener(e, t) { const n = this._listeners; if (n === void 0) return; const i = n[e]; if (i !== void 0) { const r = i.indexOf(t); r !== -1 && i.splice(r, 1); } } /** * Dispatches an event object. * * @param {Object} event - The event that gets fired. */ dispatchEvent(e) { const t = this._listeners; if (t === void 0) return; const n = t[e.type]; if (n !== void 0) { e.target = this; const i = n.slice(0); for (let r = 0, a = i.length; r < a; r++) i[r].call(this, e); e.target = null; } } } const Wt = ["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 Fc = 1234567; const Ks = Math.PI / 180, vs = 180 / Math.PI; function yn() { const s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; return (Wt[s & 255] + Wt[s >> 8 & 255] + Wt[s >> 16 & 255] + Wt[s >> 24 & 255] + "-" + Wt[e & 255] + Wt[e >> 8 & 255] + "-" + Wt[e >> 16 & 15 | 64] + Wt[e >> 24 & 255] + "-" + Wt[t & 63 | 128] + Wt[t >> 8 & 255] + "-" + Wt[t >> 16 & 255] + Wt[t >> 24 & 255] + Wt[n & 255] + Wt[n >> 8 & 255] + Wt[n >> 16 & 255] + Wt[n >> 24 & 255]).toLowerCase(); } function Je(s, e, t) { return Math.max(e, Math.min(t, s)); } function ic(s, e) { return (s % e + e) % e; } function cp(s, e, t, n, i) { return n + (s - e) * (i - n) / (t - e); } function hp(s, e, t) { return s !== e ? (t - s) / (e - s) : 0; } function $s(s, e, t) { return (1 - t) * s + t * e; } function up(s, e, t, n) { return $s(s, e, 1 - Math.exp(-t * n)); } function dp(s, e = 1) { return e - Math.abs(ic(s, e * 2) - e); } function fp(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s)); } function pp(s, e, t) { return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10)); } function mp(s, e) { return s + Math.floor(Math.random() * (e - s + 1)); } function gp(s, e) { return s + Math.random() * (e - s); } function xp(s) { return s * (0.5 - Math.random()); } function vp(s) { s !== void 0 && (Fc = s); let e = Fc += 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 bp(s) { return s * Ks; } function _p(s) { return s * vs; } function yp(s) { return (s & s - 1) === 0 && s !== 0; } function Mp(s) { return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2)); } function Sp(s) { return Math.pow(2, Math.floor(Math.log(s) / Math.LN2)); } function wp(s, e, t, n, i) { const r = Math.cos, a = Math.sin, o = r(t / 2), l = a(t / 2), c = r((e + n) / 2), h = a((e + n) / 2), u = r((e - n) / 2), f = a((e - n) / 2), d = r((n - e) / 2), p = a((n - e) / 2); switch (i) { case "XYX": s.set(o * h, l * u, l * f, o * c); break; case "YZY": s.set(l * f, o * h, l * u, o * c); break; case "ZXZ": s.set(l * u, l * f, o * h, o * c); break; case "XZX": s.set(o * h, l * p, l * d, o * c); break; case "YXY": s.set(l * d, o * h, l * p, o * c); break; case "ZYZ": s.set(l * p, l * d, o * h, o * c); break; default: ze("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i); } } function Cn(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 lt(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 Js = { DEG2RAD: Ks, RAD2DEG: vs, /** * Generate a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) * (universally unique identifier). * * @static * @method * @return {string} The UUID. */ generateUUID: yn, /** * Clamps the given value between min and max. * * @static * @method * @param {number} value - The value to clamp. * @param {number} min - The min value. * @param {number} max - The max value. * @return {number} The clamped value. */ clamp: Je, /** * Computes the Euclidean modulo of the given parameters that * is `( ( n % m ) + m ) % m`. * * @static * @method * @param {number} n - The first parameter. * @param {number} m - The second parameter. * @return {number} The Euclidean modulo. */ euclideanModulo: ic, /** * Performs a linear mapping from range `` to range `` * for the given value. * * @static * @method * @param {number} x - The value to be mapped. * @param {number} a1 - Minimum value for range A. * @param {number} a2 - Maximum value for range A. * @param {number} b1 - Minimum value for range B. * @param {number} b2 - Maximum value for range B. * @return {number} The mapped value. */ mapLinear: cp, /** * Returns the percentage in the closed interval `[0, 1]` of the given value * between the start and end point. * * @static * @method * @param {number} x - The start point * @param {number} y - The end point. * @param {number} value - A value between start and end. * @return {number} The interpolation factor. */ inverseLerp: hp, /** * Returns a value linearly interpolated from two known points based on the given interval - * `t = 0` will return `x` and `t = 1` will return `y`. * * @static * @method * @param {number} x - The start point * @param {number} y - The end point. * @param {number} t - The interpolation factor in the closed interval `[0, 1]`. * @return {number} The interpolated value. */ lerp: $s, /** * Smoothly interpolate a number from `x` to `y` in a spring-like manner using a delta * time to maintain frame rate independent movement. For details, see * [Frame rate independent damping using lerp](http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/). * * @static * @method * @param {number} x - The current point. * @param {number} y - The target point. * @param {number} lambda - A higher lambda value will make the movement more sudden, * and a lower value will make the movement more gradual. * @param {number} dt - Delta time in seconds. * @return {number} The interpolated value. */ damp: up, /** * Returns a value that alternates between `0` and the given `length` parameter. * * @static * @method * @param {number} x - The value to pingpong. * @param {number} [length=1] - The positive value the function will pingpong to. * @return {number} The alternated value. */ pingpong: dp, /** * Returns a value in the range `[0,1]` that represents the percentage that `x` has * moved between `min` and `max`, but smoothed or slowed down the closer `x` is to * the `min` and `max`. * * See [Smoothstep](http://en.wikipedia.org/wiki/Smoothstep) for more details. * * @static * @method * @param {number} x - The value to evaluate based on its position between min and max. * @param {number} min - The min value. Any x value below min will be `0`. * @param {number} max - The max value. Any x value above max will be `1`. * @return {number} The alternated value. */ smoothstep: fp, /** * A [variation on smoothstep](https://en.wikipedia.org/wiki/Smoothstep#Variations) * that has zero 1st and 2nd order derivatives at x=0 and x=1. * * @static * @method * @param {number} x - The value to evaluate based on its position between min and max. * @param {number} min - The min value. Any x value below min will be `0`. * @param {number} max - The max value. Any x value above max will be `1`. * @return {number} The alternated value. */ smootherstep: pp, /** * Returns a random integer from `` interval. * * @static * @method * @param {number} low - The lower value boundary. * @param {number} high - The upper value boundary * @return {number} A random integer. */ randInt: mp, /** * Returns a random float from `` interval. * * @static * @method * @param {number} low - The lower value boundary. * @param {number} high - The upper value boundary * @return {number} A random float. */ randFloat: gp, /** * Returns a random integer from `<-range/2, range/2>` interval. * * @static * @method * @param {number} range - Defines the value range. * @return {number} A random float. */ randFloatSpread: xp, /** * Returns a deterministic pseudo-random float in the interval `[0, 1]`. * * @static * @method * @param {number} [s] - The integer seed. * @return {number} A random float. */ seededRandom: vp, /** * Converts degrees to radians. * * @static * @method * @param {number} degrees - A value in degrees. * @return {number} The converted value in radians. */ degToRad: bp, /** * Converts radians to degrees. * * @static * @method * @param {number} radians - A value in radians. * @return {number} The converted value in degrees. */ radToDeg: _p, /** * Returns `true` if the given number is a power of two. * * @static * @method * @param {number} value - The value to check. * @return {boolean} Whether the given number is a power of two or not. */ isPowerOfTwo: yp, /** * Returns the smallest power of two that is greater than or equal to the given number. * * @static * @method * @param {number} value - The value to find a POT for. * @return {number} The smallest power of two that is greater than or equal to the given number. */ ceilPowerOfTwo: Mp, /** * Returns the largest power of two that is less than or equal to the given number. * * @static * @method * @param {number} value - The value to find a POT for. * @return {number} The largest power of two that is less than or equal to the given number. */ floorPowerOfTwo: Sp, /** * Sets the given quaternion from the [Intrinsic Proper Euler Angles](https://en.wikipedia.org/wiki/Euler_angles) * defined by the given angles and order. * * Rotations are applied to the axes in the order specified by order: * rotation by angle `a` is applied first, then by angle `b`, then by angle `c`. * * @static * @method * @param {Quaternion} q - The quaternion to set. * @param {number} a - The rotation applied to the first axis, in radians. * @param {number} b - The rotation applied to the second axis, in radians. * @param {number} c - The rotation applied to the third axis, in radians. * @param {('XYX'|'XZX'|'YXY'|'YZY'|'ZXZ'|'ZYZ')} order - A string specifying the axes order. */ setQuaternionFromProperEuler: wp, /** * Normalizes the given value according to the given typed array. * * @static * @method * @param {number} value - The float value in the range `[0,1]` to normalize. * @param {TypedArray} array - The typed array that defines the data type of the value. * @return {number} The normalize value. */ normalize: lt, /** * Denormalizes the given value according to the given typed array. * * @static * @method * @param {number} value - The value to denormalize. * @param {TypedArray} array - The typed array that defines the data type of the value. * @return {number} The denormalize (float) value in the range `[0,1]`. */ denormalize: Cn }; class ue { /** * Constructs a new 2D vector. * * @param {number} [x=0] - The x value of this vector. * @param {number} [y=0] - The y value of this vector. */ constructor(e = 0, t = 0) { ue.prototype.isVector2 = !0, this.x = e, this.y = t; } /** * Alias for {@link Vector2#x}. * * @type {number} */ get width() { return this.x; } set width(e) { this.x = e; } /** * Alias for {@link Vector2#y}. * * @type {number} */ get height() { return this.y; } set height(e) { this.y = e; } /** * Sets the vector components. * * @param {number} x - The value of the x component. * @param {number} y - The value of the y component. * @return {Vector2} A reference to this vector. */ set(e, t) { return this.x = e, this.y = t, this; } /** * Sets the vector components to the same value. * * @param {number} scalar - The value to set for all vector components. * @return {Vector2} A reference to this vector. */ setScalar(e) { return this.x = e, this.y = e, this; } /** * Sets the vector's x component to the given value * * @param {number} x - The value to set. * @return {Vector2} A reference to this vector. */ setX(e) { return this.x = e, this; } /** * Sets the vector's y component to the given value * * @param {number} y - The value to set. * @return {Vector2} A reference to this vector. */ setY(e) { return this.y = e, this; } /** * Allows to set a vector component with an index. * * @param {number} index - The component index. `0` equals to x, `1` equals to y. * @param {number} value - The value to set. * @return {Vector2} A reference to this vector. */ 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; } /** * Returns the value of the vector component which matches the given index. * * @param {number} index - The component index. `0` equals to x, `1` equals to y. * @return {number} A vector component value. */ getComponent(e) { switch (e) { case 0: return this.x; case 1: return this.y; default: throw new Error("index is out of range: " + e); } } /** * Returns a new vector with copied values from this instance. * * @return {Vector2} A clone of this instance. */ clone() { return new this.constructor(this.x, this.y); } /** * Copies the values of the given vector to this instance. * * @param {Vector2} v - The vector to copy. * @return {Vector2} A reference to this vector. */ copy(e) { return this.x = e.x, this.y = e.y, this; } /** * Adds the given vector to this instance. * * @param {Vector2} v - The vector to add. * @return {Vector2} A reference to this vector. */ add(e) { return this.x += e.x, this.y += e.y, this; } /** * Adds the given scalar value to all components of this instance. * * @param {number} s - The scalar to add. * @return {Vector2} A reference to this vector. */ addScalar(e) { return this.x += e, this.y += e, this; } /** * Adds the given vectors and stores the result in this instance. * * @param {Vector2} a - The first vector. * @param {Vector2} b - The second vector. * @return {Vector2} A reference to this vector. */ addVectors(e, t) { return this.x = e.x + t.x, this.y = e.y + t.y, this; } /** * Adds the given vector scaled by the given factor to this instance. * * @param {Vector2} v - The vector. * @param {number} s - The factor that scales `v`. * @return {Vector2} A reference to this vector. */ addScaledVector(e, t) { return this.x += e.x * t, this.y += e.y * t, this; } /** * Subtracts the given vector from this instance. * * @param {Vector2} v - The vector to subtract. * @return {Vector2} A reference to this vector. */ sub(e) { return this.x -= e.x, this.y -= e.y, this; } /** * Subtracts the given scalar value from all components of this instance. * * @param {number} s - The scalar to subtract. * @return {Vector2} A reference to this vector. */ subScalar(e) { return this.x -= e, this.y -= e, this; } /** * Subtracts the given vectors and stores the result in this instance. * * @param {Vector2} a - The first vector. * @param {Vector2} b - The second vector. * @return {Vector2} A reference to this vector. */ subVectors(e, t) { return this.x = e.x - t.x, this.y = e.y - t.y, this; } /** * Multiplies the given vector with this instance. * * @param {Vector2} v - The vector to multiply. * @return {Vector2} A reference to this vector. */ multiply(e) { return this.x *= e.x, this.y *= e.y, this; } /** * Multiplies the given scalar value with all components of this instance. * * @param {number} scalar - The scalar to multiply. * @return {Vector2} A reference to this vector. */ multiplyScalar(e) { return this.x *= e, this.y *= e, this; } /** * Divides this instance by the given vector. * * @param {Vector2} v - The vector to divide. * @return {Vector2} A reference to this vector. */ divide(e) { return this.x /= e.x, this.y /= e.y, this; } /** * Divides this vector by the given scalar. * * @param {number} scalar - The scalar to divide. * @return {Vector2} A reference to this vector. */ divideScalar(e) { return this.multiplyScalar(1 / e); } /** * Multiplies this vector (with an implicit 1 as the 3rd component) by * the given 3x3 matrix. * * @param {Matrix3} m - The matrix to apply. * @return {Vector2} A reference to this vector. */ applyMatrix3(e) { const t = this.x, n = this.y, i = e.elements; return this.x = i[0] * t + i[3] * n + i[6], this.y = i[1] * t + i[4] * n + i[7], this; } /** * If this vector's x or y value is greater than the given vector's x or y * value, replace that value with the corresponding min value. * * @param {Vector2} v - The vector. * @return {Vector2} A reference to this vector. */ min(e) { return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this; } /** * If this vector's x or y value is less than the given vector's x or y * value, replace that value with the corresponding max value. * * @param {Vector2} v - The vector. * @return {Vector2} A reference to this vector. */ max(e) { return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this; } /** * If this vector's x or y value is greater than the max vector's x or y * value, it is replaced by the corresponding value. * If this vector's x or y value is less than the min vector's x or y value, * it is replaced by the corresponding value. * * @param {Vector2} min - The minimum x and y values. * @param {Vector2} max - The maximum x and y values in the desired range. * @return {Vector2} A reference to this vector. */ clamp(e, t) { return this.x = Je(this.x, e.x, t.x), this.y = Je(this.y, e.y, t.y), this; } /** * If this vector's x or y values are greater than the max value, they are * replaced by the max value. * If this vector's x or y values are less than the min value, they are * replaced by the min value. * * @param {number} minVal - The minimum value the components will be clamped to. * @param {number} maxVal - The maximum value the components will be clamped to. * @return {Vector2} A reference to this vector. */ clampScalar(e, t) { return this.x = Je(this.x, e, t), this.y = Je(this.y, e, t), this; } /** * If this vector's length is greater than the max value, it is replaced by * the max value. * If this vector's length is less than the min value, it is replaced by the * min value. * * @param {number} min - The minimum value the vector length will be clamped to. * @param {number} max - The maximum value the vector length will be clamped to. * @return {Vector2} A reference to this vector. */ clampLength(e, t) { const n = this.length(); return this.divideScalar(n || 1).multiplyScalar(Je(n, e, t)); } /** * The components of this vector are rounded down to the nearest integer value. * * @return {Vector2} A reference to this vector. */ floor() { return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this; } /** * The components of this vector are rounded up to the nearest integer value. * * @return {Vector2} A reference to this vector. */ ceil() { return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this; } /** * The components of this vector are rounded to the nearest integer value * * @return {Vector2} A reference to this vector. */ round() { return this.x = Math.round(this.x), this.y = Math.round(this.y), this; } /** * The components of this vector are rounded towards zero (up if negative, * down if positive) to an integer value. * * @return {Vector2} A reference to this vector. */ roundToZero() { return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this; } /** * Inverts this vector - i.e. sets x = -x and y = -y. * * @return {Vector2} A reference to this vector. */ negate() { return this.x = -this.x, this.y = -this.y, this; } /** * Calculates the dot product of the given vector with this instance. * * @param {Vector2} v - The vector to compute the dot product with. * @return {number} The result of the dot product. */ dot(e) { return this.x * e.x + this.y * e.y; } /** * Calculates the cross product of the given vector with this instance. * * @param {Vector2} v - The vector to compute the cross product with. * @return {number} The result of the cross product. */ cross(e) { return this.x * e.y - this.y * e.x; } /** * Computes the square of the Euclidean length (straight-line length) from * (0, 0) to (x, y). If you are comparing the lengths of vectors, you should * compare the length squared instead as it is slightly more efficient to calculate. * * @return {number} The square length of this vector. */ lengthSq() { return this.x * this.x + this.y * this.y; } /** * Computes the Euclidean length (straight-line length) from (0, 0) to (x, y). * * @return {number} The length of this vector. */ length() { return Math.sqrt(this.x * this.x + this.y * this.y); } /** * Computes the Manhattan length of this vector. * * @return {number} The length of this vector. */ manhattanLength() { return Math.abs(this.x) + Math.abs(this.y); } /** * Converts this vector to a unit vector - that is, sets it equal to a vector * with the same direction as this one, but with a vector length of `1`. * * @return {Vector2} A reference to this vector. */ normalize() { return this.divideScalar(this.length() || 1); } /** * Computes the angle in radians of this vector with respect to the positive x-axis. * * @return {number} The angle in radians. */ angle() { return Math.atan2(-this.y, -this.x) + Math.PI; } /** * Returns the angle between the given vector and this instance in radians. * * @param {Vector2} v - The vector to compute the angle with. * @return {number} The angle in radians. */ angleTo(e) { const t = Math.sqrt(this.lengthSq() * e.lengthSq()); if (t === 0) return Math.PI / 2; const n = this.dot(e) / t; return Math.acos(Je(n, -1, 1)); } /** * Computes the distance from the given vector to this instance. * * @param {Vector2} v - The vector to compute the distance to. * @return {number} The distance. */ distanceTo(e) { return Math.sqrt(this.distanceToSquared(e)); } /** * Computes the squared distance from the given vector to this instance. * If you are just comparing the distance with another distance, you should compare * the distance squared instead as it is slightly more efficient to calculate. * * @param {Vector2} v - The vector to compute the squared distance to. * @return {number} The squared distance. */ distanceToSquared(e) { const t = this.x - e.x, n = this.y - e.y; return t * t + n * n; } /** * Computes the Manhattan distance from the given vector to this instance. * * @param {Vector2} v - The vector to compute the Manhattan distance to. * @return {number} The Manhattan distance. */ manhattanDistanceTo(e) { return Math.abs(this.x - e.x) + Math.abs(this.y - e.y); } /** * Sets this vector to a vector with the same direction as this one, but * with the specified length. * * @param {number} length - The new length of this vector. * @return {Vector2} A reference to this vector. */ setLength(e) { return this.normalize().multiplyScalar(e); } /** * Linearly interpolates between the given vector and this instance, where * alpha is the percent distance along the line - alpha = 0 will be this * vector, and alpha = 1 will be the given one. * * @param {Vector2} v - The vector to interpolate towards. * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`. * @return {Vector2} A reference to this vector. */ lerp(e, t) { return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this; } /** * Linearly interpolates between the given vectors, where alpha is the percent * distance along the line - alpha = 0 will be first vector, and alpha = 1 will * be the second one. The result is stored in this instance. * * @param {Vector2} v1 - The first vector. * @param {Vector2} v2 - The second vector. * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`. * @return {Vector2} A reference to this vector. */ lerpVectors(e, t, n) { return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this; } /** * Returns `true` if this vector is equal with the given one. * * @param {Vector2} v - The vector to test for equality. * @return {boolean} Whether this vector is equal with the given one. */ equals(e) { return e.x === this.x && e.y === this.y; } /** * Sets this vector's x value to be `array[ offset ]` and y * value to be `array[ offset + 1 ]`. * * @param {Array} array - An array holding the vector component values. * @param {number} [offset=0] - The offset into the array. * @return {Vector2} A reference to this vector. */ fromArray(e, t = 0) { return this.x = e[t], this.y = e[t + 1], this; } /** * Writes the components of this vector to the given array. If no array is provided, * the method returns a new instance. * * @param {Array} [array=[]] - The target array holding the vector components. * @param {number} [offset=0] - Index of the first element in the array. * @return {Array} The vector components. */ toArray(e = [], t = 0) { return e[t] = this.x, e[t + 1] = this.y, e; } /** * Sets the components of this vector from the given buffer attribute. * * @param {BufferAttribute} attribute - The buffer attribute holding vector data. * @param {number} index - The index into the attribute. * @return {Vector2} A reference to this vector. */ fromBufferAttribute(e, t) { return this.x = e.getX(t), this.y = e.getY(t), this; } /** * Rotates this vector around the given center by the given angle. * * @param {Vector2} center - The point around which to rotate. * @param {number} angle - The angle to rotate, in radians. * @return {Vector2} A reference to this vector. */ rotateAround(e, t) { const n = Math.cos(t), i = Math.sin(t), r = this.x - e.x, a = this.y - e.y; return this.x = r * n - a * i + e.x, this.y = r * i + a * n + e.y, this; } /** * Sets each component of this vector to a pseudo-random value between `0` and * `1`, excluding `1`. * * @return {Vector2} A reference to this vector. */ random() { return this.x = Math.random(), this.y = Math.random(), this; } *[Symbol.iterator]() { yield this.x, yield this.y; } } class Dn { /** * Constructs a new quaternion. * * @param {number} [x=0] - The x value of this quaternion. * @param {number} [y=0] - The y value of this quaternion. * @param {number} [z=0] - The z value of this quaternion. * @param {number} [w=1] - The w value of this quaternion. */ constructor(e = 0, t = 0, n = 0, i = 1) { this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = i; } /** * Interpolates between two quaternions via SLERP. This implementation assumes the * quaternion data are managed in flat arrays. * * @param {Array} dst - The destination array. * @param {number} dstOffset - An offset into the destination array. * @param {Array} src0 - The source array of the first quaternion. * @param {number} srcOffset0 - An offset into the first source array. * @param {Array} src1 - The source array of the second quaternion. * @param {number} srcOffset1 - An offset into the second source array. * @param {number} t - The interpolation factor in the range `[0,1]`. * @see {@link Quaternion#slerp} */ static slerpFlat(e, t, n, i, r, a, o) { let l = n[i + 0], c = n[i + 1], h = n[i + 2], u = n[i + 3], f = r[a + 0], d = r[a + 1], p = r[a + 2], g = r[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] = f, e[t + 1] = d, e[t + 2] = p, e[t + 3] = g; return; } if (u !== g || l !== f || c !== d || h !== p) { let x = l * f + c * d + h * p + u * g; x < 0 && (f = -f, d = -d, p = -p, g = -g, x = -x); let m = 1 - o; if (x < 0.9995) { const v = Math.acos(x), b = Math.sin(v); m = Math.sin(m * v) / b, o = Math.sin(o * v) / b, l = l * m + f * o, c = c * m + d * o, h = h * m + p * o, u = u * m + g * o; } else { l = l * m + f * o, c = c * m + d * o, h = h * m + p * o, u = u * m + g * o; const v = 1 / Math.sqrt(l * l + c * c + h * h + u * u); l *= v, c *= v, h *= v, u *= v; } } e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; } /** * Multiplies two quaternions. This implementation assumes the quaternion data are managed * in flat arrays. * * @param {Array} dst - The destination array. * @param {number} dstOffset - An offset into the destination array. * @param {Array} src0 - The source array of the first quaternion. * @param {number} srcOffset0 - An offset into the first source array. * @param {Array} src1 - The source array of the second quaternion. * @param {number} srcOffset1 - An offset into the second source array. * @return {Array} The destination array. * @see {@link Quaternion#multiplyQuaternions}. */ static multiplyQuaternionsFlat(e, t, n, i, r, a) { const o = n[i], l = n[i + 1], c = n[i + 2], h = n[i + 3], u = r[a], f = r[a + 1], d = r[a + 2], p = r[a + 3]; return e[t] = o * p + h * u + l * d - c * f, e[t + 1] = l * p + h * f + c * u - o * d, e[t + 2] = c * p + h * d + o * f - l * u, e[t + 3] = h * p - o * u - l * f - c * d, e; } /** * The x value of this quaternion. * * @type {number} * @default 0 */ get x() { return this._x; } set x(e) { this._x = e, this._onChangeCallback(); } /** * The y value of this quaternion. * * @type {number} * @default 0 */ get y() { return this._y; } set y(e) { this._y = e, this._onChangeCallback(); } /** * The z value of this quaternion. * * @type {number} * @default 0 */ get z() { return this._z; } set z(e) { this._z = e, this._onChangeCallback(); } /** * The w value of this quaternion. * * @type {number} * @default 1 */ get w() { return this._w; } set w(e) { this._w = e, this._onChangeCallback(); } /** * Sets the quaternion components. * * @param {number} x - The x value of this quaternion. * @param {number} y - The y value of this quaternion. * @param {number} z - The z value of this quaternion. * @param {number} w - The w value of this quaternion. * @return {Quaternion} A reference to this quaternion. */ set(e, t, n, i) { return this._x = e, this._y = t, this._z = n, this._w = i, this._onChangeCallback(), this; } /** * Returns a new quaternion with copied values from this instance. * * @return {Quaternion} A clone of this instance. */ clone() { return new this.constructor(this._x, this._y, this._z, this._w); } /** * Copies the values of the given quaternion to this instance. * * @param {Quaternion} quaternion - The quaternion to copy. * @return {Quaternion} A reference to this quaternion. */ copy(e) { return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this; } /** * Sets this quaternion from the rotation specified by the given * Euler angles. * * @param {Euler} euler - The Euler angles. * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not. * @return {Quaternion} A reference to this quaternion. */ setFromEuler(e, t = !0) { const n = e._x, i = e._y, r = e._z, a = e._order, o = Math.cos, l = Math.sin, c = o(n / 2), h = o(i / 2), u = o(r / 2), f = l(n / 2), d = l(i / 2), p = l(r / 2); switch (a) { case "XYZ": this._x = f * h * u + c * d * p, this._y = c * d * u - f * h * p, this._z = c * h * p + f * d * u, this._w = c * h * u - f * d * p; break; case "YXZ": this._x = f * h * u + c * d * p, this._y = c * d * u - f * h * p, this._z = c * h * p - f * d * u, this._w = c * h * u + f * d * p; break; case "ZXY": this._x = f * h * u - c * d * p, this._y = c * d * u + f * h * p, this._z = c * h * p + f * d * u, this._w = c * h * u - f * d * p; break; case "ZYX": this._x = f * h * u - c * d * p, this._y = c * d * u + f * h * p, this._z = c * h * p - f * d * u, this._w = c * h * u + f * d * p; break; case "YZX": this._x = f * h * u + c * d * p, this._y = c * d * u + f * h * p, this._z = c * h * p - f * d * u, this._w = c * h * u - f * d * p; break; case "XZY": this._x = f * h * u - c * d * p, this._y = c * d * u - f * h * p, this._z = c * h * p + f * d * u, this._w = c * h * u + f * d * p; break; default: ze("Quaternion: .setFromEuler() encountered an unknown order: " + a); } return t === !0 && this._onChangeCallback(), this; } /** * Sets this quaternion from the given axis and angle. * * @param {Vector3} axis - The normalized axis. * @param {number} angle - The angle in radians. * @return {Quaternion} A reference to this quaternion. */ setFromAxisAngle(e, t) { const n = t / 2, i = Math.sin(n); return this._x = e.x * i, this._y = e.y * i, this._z = e.z * i, this._w = Math.cos(n), this._onChangeCallback(), this; } /** * Sets this quaternion from the given rotation matrix. * * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled). * @return {Quaternion} A reference to this quaternion. */ setFromRotationMatrix(e) { const t = e.elements, n = t[0], i = t[4], r = t[8], a = t[1], o = t[5], l = t[9], c = t[2], h = t[6], u = t[10], f = n + o + u; if (f > 0) { const d = 0.5 / Math.sqrt(f + 1); this._w = 0.25 / d, this._x = (h - l) * d, this._y = (r - c) * d, this._z = (a - i) * d; } else if (n > o && n > u) { const d = 2 * Math.sqrt(1 + n - o - u); this._w = (h - l) / d, this._x = 0.25 * d, this._y = (i + a) / d, this._z = (r + c) / d; } else if (o > u) { const d = 2 * Math.sqrt(1 + o - n - u); this._w = (r - c) / d, this._x = (i + a) / d, this._y = 0.25 * d, this._z = (l + h) / d; } else { const d = 2 * Math.sqrt(1 + u - n - o); this._w = (a - i) / d, this._x = (r + c) / d, this._y = (l + h) / d, this._z = 0.25 * d; } return this._onChangeCallback(), this; } /** * Sets this quaternion to the rotation required to rotate the direction vector * `vFrom` to the direction vector `vTo`. * * @param {Vector3} vFrom - The first (normalized) direction vector. * @param {Vector3} vTo - The second (normalized) direction vector. * @return {Quaternion} A reference to this quaternion. */ setFromUnitVectors(e, t) { let n = e.dot(t) + 1; return n < 1e-8 ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize(); } /** * Returns the angle between this quaternion and the given one in radians. * * @param {Quaternion} q - The quaternion to compute the angle with. * @return {number} The angle in radians. */ angleTo(e) { return 2 * Math.acos(Math.abs(Je(this.dot(e), -1, 1))); } /** * Rotates this quaternion by a given angular step to the given quaternion. * The method ensures that the final quaternion will not overshoot `q`. * * @param {Quaternion} q - The target quaternion. * @param {number} step - The angular step in radians. * @return {Quaternion} A reference to this quaternion. */ rotateTowards(e, t) { const n = this.angleTo(e); if (n === 0) return this; const i = Math.min(1, t / n); return this.slerp(e, i), this; } /** * Sets this quaternion to the identity quaternion; that is, to the * quaternion that represents "no rotation". * * @return {Quaternion} A reference to this quaternion. */ identity() { return this.set(0, 0, 0, 1); } /** * Inverts this quaternion via {@link Quaternion#conjugate}. The * quaternion is assumed to have unit length. * * @return {Quaternion} A reference to this quaternion. */ invert() { return this.conjugate(); } /** * Returns the rotational conjugate of this quaternion. The conjugate of a * quaternion represents the same rotation in the opposite direction about * the rotational axis. * * @return {Quaternion} A reference to this quaternion. */ conjugate() { return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this; } /** * Calculates the dot product of this quaternion and the given one. * * @param {Quaternion} v - The quaternion to compute the dot product with. * @return {number} The result of the dot product. */ dot(e) { return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w; } /** * Computes the squared Euclidean length (straight-line length) of this quaternion, * considered as a 4 dimensional vector. This can be useful if you are comparing the * lengths of two quaternions, as this is a slightly more efficient calculation than * {@link Quaternion#length}. * * @return {number} The squared Euclidean length. */ lengthSq() { return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; } /** * Computes the Euclidean length (straight-line length) of this quaternion, * considered as a 4 dimensional vector. * * @return {number} The Euclidean length. */ length() { return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w); } /** * Normalizes this quaternion - that is, calculated the quaternion that performs * the same rotation as this one, but has a length equal to `1`. * * @return {Quaternion} A reference to this quaternion. */ 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; } /** * Multiplies this quaternion by the given one. * * @param {Quaternion} q - The quaternion. * @return {Quaternion} A reference to this quaternion. */ multiply(e) { return this.multiplyQuaternions(this, e); } /** * Pre-multiplies this quaternion by the given one. * * @param {Quaternion} q - The quaternion. * @return {Quaternion} A reference to this quaternion. */ premultiply(e) { return this.multiplyQuaternions(e, this); } /** * Multiplies the given quaternions and stores the result in this instance. * * @param {Quaternion} a - The first quaternion. * @param {Quaternion} b - The second quaternion. * @return {Quaternion} A reference to this quaternion. */ multiplyQuaternions(e, t) { const n = e._x, i = e._y, r = e._z, a = e._w, o = t._x, l = t._y, c = t._z, h = t._w; return this._x = n * h + a * o + i * c - r * l, this._y = i * h + a * l + r * o - n * c, this._z = r * h + a * c + n * l - i * o, this._w = a * h - n * o - i * l - r * c, this._onChangeCallback(), this; } /** * Performs a spherical linear interpolation between quaternions. * * @param {Quaternion} qb - The target quaternion. * @param {number} t - The interpolation factor in the closed interval `[0, 1]`. * @return {Quaternion} A reference to this quaternion. */ slerp(e, t) { if (t <= 0) return this; if (t >= 1) return this.copy(e); let n = e._x, i = e._y, r = e._z, a = e._w, o = this.dot(e); o < 0 && (n = -n, i = -i, r = -r, a = -a, o = -o); let l = 1 - t; if (o < 0.9995) { const c = Math.acos(o), h = Math.sin(c); l = Math.sin(l * c) / h, t = Math.sin(t * c) / h, this._x = this._x * l + n * t, this._y = this._y * l + i * t, this._z = this._z * l + r * t, this._w = this._w * l + a * t, this._onChangeCallback(); } else this._x = this._x * l + n * t, this._y = this._y * l + i * t, this._z = this._z * l + r * t, this._w = this._w * l + a * t, this.normalize(); return this; } /** * Performs a spherical linear interpolation between the given quaternions * and stores the result in this quaternion. * * @param {Quaternion} qa - The source quaternion. * @param {Quaternion} qb - The target quaternion. * @param {number} t - The interpolation factor in the closed interval `[0, 1]`. * @return {Quaternion} A reference to this quaternion. */ slerpQuaternions(e, t, n) { return this.copy(e).slerp(t, n); } /** * Sets this quaternion to a uniformly random, normalized quaternion. * * @return {Quaternion} A reference to this quaternion. */ random() { const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), i = Math.sqrt(1 - n), r = Math.sqrt(n); return this.set( i * Math.sin(e), i * Math.cos(e), r * Math.sin(t), r * Math.cos(t) ); } /** * Returns `true` if this quaternion is equal with the given one. * * @param {Quaternion} quaternion - The quaternion to test for equality. * @return {boolean} Whether this quaternion is equal with the given one. */ equals(e) { return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w; } /** * Sets this quaternion's components from the given array. * * @param {Array} array - An array holding the quaternion component values. * @param {number} [offset=0] - The offset into the array. * @return {Quaternion} A reference to this quaternion. */ 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; } /** * Writes the components of this quaternion to the given array. If no array is provided, * the method returns a new instance. * * @param {Array} [array=[]] - The target array holding the quaternion components. * @param {number} [offset=0] - Index of the first element in the array. * @return {Array} The quaternion components. */ 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; } /** * Sets the components of this quaternion from the given buffer attribute. * * @param {BufferAttribute} attribute - The buffer attribute holding quaternion data. * @param {number} index - The index into the attribute. * @return {Quaternion} A reference to this quaternion. */ 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; } /** * This methods defines the serialization result of this class. Returns the * numerical elements of this quaternion in an array of format `[x, y, z, w]`. * * @return {Array} The serialized quaternion. */ 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 R { /** * Constructs a new 3D vector. * * @param {number} [x=0] - The x value of this vector. * @param {number} [y=0] - The y value of this vector. * @param {number} [z=0] - The z value of this vector. */ constructor(e = 0, t = 0, n = 0) { R.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = n; } /** * Sets the vector components. * * @param {number} x - The value of the x component. * @param {number} y - The value of the y component. * @param {number} z - The value of the z component. * @return {Vector3} A reference to this vector. */ set(e, t, n) { return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this; } /** * Sets the vector components to the same value. * * @param {number} scalar - The value to set for all vector components. * @return {Vector3} A reference to this vector. */ setScalar(e) { return this.x = e, this.y = e, this.z = e, this; } /** * Sets the vector's x component to the given value * * @param {number} x - The value to set. * @return {Vector3} A reference to this vector. */ setX(e) { return this.x = e, this; } /** * Sets the vector's y component to the given value * * @param {number} y - The value to set. * @return {Vector3} A reference to this vector. */ setY(e) { return this.y = e, this; } /** * Sets the vector's z component to the given value * * @param {number} z - The value to set. * @return {Vector3} A reference to this vector. */ setZ(e) { return this.z = e, this; } /** * Allows to set a vector component with an index. * * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z. * @param {number} value - The value to set. * @return {Vector3} A reference to this vector. */ 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; } /** * Returns the value of the vector component which matches the given index. * * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z. * @return {number} A vector component value. */ 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); } } /** * Returns a new vector with copied values from this instance. * * @return {Vector3} A clone of this instance. */ clone() { return new this.constructor(this.x, this.y, this.z); } /** * Copies the values of the given vector to this instance. * * @param {Vector3} v - The vector to copy. * @return {Vector3} A reference to this vector. */ copy(e) { return this.x = e.x, this.y = e.y, this.z = e.z, this; } /** * Adds the given vector to this instance. * * @param {Vector3} v - The vector to add. * @return {Vector3} A reference to this vector. */ add(e) { return this.x += e.x, this.y += e.y, this.z += e.z, this; } /** * Adds the given scalar value to all components of this instance. * * @param {number} s - The scalar to add. * @return {Vector3} A reference to this vector. */ addScalar(e) { return this.x += e, this.y += e, this.z += e, this; } /** * Adds the given vectors and stores the result in this instance. * * @param {Vector3} a - The first vector. * @param {Vector3} b - The second vector. * @return {Vector3} A reference to this vector. */ addVectors(e, t) { return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this; } /** * Adds the given vector scaled by the given factor to this instance. * * @param {Vector3|Vector4} v - The vector. * @param {number} s - The factor that scales `v`. * @return {Vector3} A reference to this vector. */ addScaledVector(e, t) { return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this; } /** * Subtracts the given vector from this instance. * * @param {Vector3} v - The vector to subtract. * @return {Vector3} A reference to this vector. */ sub(e) { return this.x -= e.x, this.y -= e.y, this.z -= e.z, this; } /** * Subtracts the given scalar value from all components of this instance. * * @param {number} s - The scalar to subtract. * @return {Vector3} A reference to this vector. */ subScalar(e) { return this.x -= e, this.y -= e, this.z -= e, this; } /** * Subtracts the given vectors and stores the result in this instance. * * @param {Vector3} a - The first vector. * @param {Vector3} b - The second vector. * @return {Vector3} A reference to this vector. */ subVectors(e, t) { return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this; } /** * Multiplies the given vector with this instance. * * @param {Vector3} v - The vector to multiply. * @return {Vector3} A reference to this vector. */ multiply(e) { return this.x *= e.x, this.y *= e.y, this.z *= e.z, this; } /** * Multiplies the given scalar value with all components of this instance. * * @param {number} scalar - The scalar to multiply. * @return {Vector3} A reference to this vector. */ multiplyScalar(e) { return this.x *= e, this.y *= e, this.z *= e, this; } /** * Multiplies the given vectors and stores the result in this instance. * * @param {Vector3} a - The first vector. * @param {Vector3} b - The second vector. * @return {Vector3} A reference to this vector. */ multiplyVectors(e, t) { return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this; } /** * Applies the given Euler rotation to this vector. * * @param {Euler} euler - The Euler angles. * @return {Vector3} A reference to this vector. */ applyEuler(e) { return this.applyQuaternion(zc.setFromEuler(e)); } /** * Applies a rotation specified by an axis and an angle to this vector. * * @param {Vector3} axis - A normalized vector representing the rotation axis. * @param {number} angle - The angle in radians. * @return {Vector3} A reference to this vector. */ applyAxisAngle(e, t) { return this.applyQuaternion(zc.setFromAxisAngle(e, t)); } /** * Multiplies this vector with the given 3x3 matrix. * * @param {Matrix3} m - The 3x3 matrix. * @return {Vector3} A reference to this vector. */ applyMatrix3(e) { const t = this.x, n = this.y, i = this.z, r = e.elements; return this.x = r[0] * t + r[3] * n + r[6] * i, this.y = r[1] * t + r[4] * n + r[7] * i, this.z = r[2] * t + r[5] * n + r[8] * i, this; } /** * Multiplies this vector by the given normal matrix and normalizes * the result. * * @param {Matrix3} m - The normal matrix. * @return {Vector3} A reference to this vector. */ applyNormalMatrix(e) { return this.applyMatrix3(e).normalize(); } /** * Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and * divides by perspective. * * @param {Matrix4} m - The matrix to apply. * @return {Vector3} A reference to this vector. */ applyMatrix4(e) { const t = this.x, n = this.y, i = this.z, r = e.elements, a = 1 / (r[3] * t + r[7] * n + r[11] * i + r[15]); return this.x = (r[0] * t + r[4] * n + r[8] * i + r[12]) * a, this.y = (r[1] * t + r[5] * n + r[9] * i + r[13]) * a, this.z = (r[2] * t + r[6] * n + r[10] * i + r[14]) * a, this; } /** * Applies the given Quaternion to this vector. * * @param {Quaternion} q - The Quaternion. * @return {Vector3} A reference to this vector. */ applyQuaternion(e) { const t = this.x, n = this.y, i = this.z, r = e.x, a = e.y, o = e.z, l = e.w, c = 2 * (a * i - o * n), h = 2 * (o * t - r * i), u = 2 * (r * n - a * t); return this.x = t + l * c + a * u - o * h, this.y = n + l * h + o * c - r * u, this.z = i + l * u + r * h - a * c, this; } /** * Projects this vector from world space into the camera's normalized * device coordinate (NDC) space. * * @param {Camera} camera - The camera. * @return {Vector3} A reference to this vector. */ project(e) { return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix); } /** * Unprojects this vector from the camera's normalized device coordinate (NDC) * space into world space. * * @param {Camera} camera - The camera. * @return {Vector3} A reference to this vector. */ unproject(e) { return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld); } /** * Transforms the direction of this vector by a matrix (the upper left 3 x 3 * subset of the given 4x4 matrix and then normalizes the result. * * @param {Matrix4} m - The matrix. * @return {Vector3} A reference to this vector. */ transformDirection(e) { const t = this.x, n = this.y, i = this.z, r = e.elements; return this.x = r[0] * t + r[4] * n + r[8] * i, this.y = r[1] * t + r[5] * n + r[9] * i, this.z = r[2] * t + r[6] * n + r[10] * i, this.normalize(); } /** * Divides this instance by the given vector. * * @param {Vector3} v - The vector to divide. * @return {Vector3} A reference to this vector. */ divide(e) { return this.x /= e.x, this.y /= e.y, this.z /= e.z, this; } /** * Divides this vector by the given scalar. * * @param {number} scalar - The scalar to divide. * @return {Vector3} A reference to this vector. */ divideScalar(e) { return this.multiplyScalar(1 / e); } /** * If this vector's x, y or z value is greater than the given vector's x, y or z * value, replace that value with the corresponding min value. * * @param {Vector3} v - The vector. * @return {Vector3} A reference to this vector. */ 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; } /** * If this vector's x, y or z value is less than the given vector's x, y or z * value, replace that value with the corresponding max value. * * @param {Vector3} v - The vector. * @return {Vector3} A reference to this vector. */ 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; } /** * If this vector's x, y or z value is greater than the max vector's x, y or z * value, it is replaced by the corresponding value. * If this vector's x, y or z value is less than the min vector's x, y or z value, * it is replaced by the corresponding value. * * @param {Vector3} min - The minimum x, y and z values. * @param {Vector3} max - The maximum x, y and z values in the desired range. * @return {Vector3} A reference to this vector. */ clamp(e, t) { return this.x = Je(this.x, e.x, t.x), this.y = Je(this.y, e.y, t.y), this.z = Je(this.z, e.z, t.z), this; } /** * If this vector's x, y or z values are greater than the max value, they are * replaced by the max value. * If this vector's x, y or z values are less than the min value, they are * replaced by the min value. * * @param {number} minVal - The minimum value the components will be clamped to. * @param {number} maxVal - The maximum value the components will be clamped to. * @return {Vector3} A reference to this vector. */ clampScalar(e, t) { return this.x = Je(this.x, e, t), this.y = Je(this.y, e, t), this.z = Je(this.z, e, t), this; } /** * If this vector's length is greater than the max value, it is replaced by * the max value. * If this vector's length is less than the min value, it is replaced by the * min value. * * @param {number} min - The minimum value the vector length will be clamped to. * @param {number} max - The maximum value the vector length will be clamped to. * @return {Vector3} A reference to this vector. */ clampLength(e, t) { const n = this.length(); return this.divideScalar(n || 1).multiplyScalar(Je(n, e, t)); } /** * The components of this vector are rounded down to the nearest integer value. * * @return {Vector3} A reference to this vector. */ floor() { return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this; } /** * The components of this vector are rounded up to the nearest integer value. * * @return {Vector3} A reference to this vector. */ ceil() { return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this; } /** * The components of this vector are rounded to the nearest integer value * * @return {Vector3} A reference to this vector. */ round() { return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this; } /** * The components of this vector are rounded towards zero (up if negative, * down if positive) to an integer value. * * @return {Vector3} A reference to this vector. */ roundToZero() { return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this; } /** * Inverts this vector - i.e. sets x = -x, y = -y and z = -z. * * @return {Vector3} A reference to this vector. */ negate() { return this.x = -this.x, this.y = -this.y, this.z = -this.z, this; } /** * Calculates the dot product of the given vector with this instance. * * @param {Vector3} v - The vector to compute the dot product with. * @return {number} The result of the dot product. */ dot(e) { return this.x * e.x + this.y * e.y + this.z * e.z; } // TODO lengthSquared? /** * Computes the square of the Euclidean length (straight-line length) from * (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should * compare the length squared instead as it is slightly more efficient to calculate. * * @return {number} The square length of this vector. */ lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z; } /** * Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z). * * @return {number} The length of this vector. */ length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } /** * Computes the Manhattan length of this vector. * * @return {number} The length of this vector. */ manhattanLength() { return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z); } /** * Converts this vector to a unit vector - that is, sets it equal to a vector * with the same direction as this one, but with a vector length of `1`. * * @return {Vector3} A reference to this vector. */ normalize() { return this.divideScalar(this.length() || 1); } /** * Sets this vector to a vector with the same direction as this one, but * with the specified length. * * @param {number} length - The new length of this vector. * @return {Vector3} A reference to this vector. */ setLength(e) { return this.normalize().multiplyScalar(e); } /** * Linearly interpolates between the given vector and this instance, where * alpha is the percent distance along the line - alpha = 0 will be this * vector, and alpha = 1 will be the given one. * * @param {Vector3} v - The vector to interpolate towards. * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`. * @return {Vector3} A reference to this vector. */ 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; } /** * Linearly interpolates between the given vectors, where alpha is the percent * distance along the line - alpha = 0 will be first vector, and alpha = 1 will * be the second one. The result is stored in this instance. * * @param {Vector3} v1 - The first vector. * @param {Vector3} v2 - The second vector. * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`. * @return {Vector3} A reference to this vector. */ lerpVectors(e, t, n) { return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this; } /** * Calculates the cross product of the given vector with this instance. * * @param {Vector3} v - The vector to compute the cross product with. * @return {Vector3} The result of the cross product. */ cross(e) { return this.crossVectors(this, e); } /** * Calculates the cross product of the given vectors and stores the result * in this instance. * * @param {Vector3} a - The first vector. * @param {Vector3} b - The second vector. * @return {Vector3} A reference to this vector. */ crossVectors(e, t) { const n = e.x, i = e.y, r = e.z, a = t.x, o = t.y, l = t.z; return this.x = i * l - r * o, this.y = r * a - n * l, this.z = n * o - i * a, this; } /** * Projects this vector onto the given one. * * @param {Vector3} v - The vector to project to. * @return {Vector3} A reference to this vector. */ projectOnVector(e) { const t = e.lengthSq(); if (t === 0) return this.set(0, 0, 0); const n = e.dot(this) / t; return this.copy(e).multiplyScalar(n); } /** * Projects this vector onto a plane by subtracting this * vector projected onto the plane's normal from this vector. * * @param {Vector3} planeNormal - The plane normal. * @return {Vector3} A reference to this vector. */ projectOnPlane(e) { return Xa.copy(this).projectOnVector(e), this.sub(Xa); } /** * Reflects this vector off a plane orthogonal to the given normal vector. * * @param {Vector3} normal - The (normalized) normal vector. * @return {Vector3} A reference to this vector. */ reflect(e) { return this.sub(Xa.copy(e).multiplyScalar(2 * this.dot(e))); } /** * Returns the angle between the given vector and this instance in radians. * * @param {Vector3} v - The vector to compute the angle with. * @return {number} The angle in radians. */ angleTo(e) { const t = Math.sqrt(this.lengthSq() * e.lengthSq()); if (t === 0) return Math.PI / 2; const n = this.dot(e) / t; return Math.acos(Je(n, -1, 1)); } /** * Computes the distance from the given vector to this instance. * * @param {Vector3} v - The vector to compute the distance to. * @return {number} The distance. */ distanceTo(e) { return Math.sqrt(this.distanceToSquared(e)); } /** * Computes the squared distance from the given vector to this instance. * If you are just comparing the distance with another distance, you should compare * the distance squared instead as it is slightly more efficient to calculate. * * @param {Vector3} v - The vector to compute the squared distance to. * @return {number} The squared distance. */ distanceToSquared(e) { const t = this.x - e.x, n = this.y - e.y, i = this.z - e.z; return t * t + n * n + i * i; } /** * Computes the Manhattan distance from the given vector to this instance. * * @param {Vector3} v - The vector to compute the Manhattan distance to. * @return {number} The Manhattan distance. */ manhattanDistanceTo(e) { return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z); } /** * Sets the vector components from the given spherical coordinates. * * @param {Spherical} s - The spherical coordinates. * @return {Vector3} A reference to this vector. */ setFromSpherical(e) { return this.setFromSphericalCoords(e.radius, e.phi, e.theta); } /** * Sets the vector components from the given spherical coordinates. * * @param {number} radius - The radius. * @param {number} phi - The phi angle in radians. * @param {number} theta - The theta angle in radians. * @return {Vector3} A reference to this vector. */ setFromSphericalCoords(e, t, n) { const i = Math.sin(t) * e; return this.x = i * Math.sin(n), this.y = Math.cos(t) * e, this.z = i * Math.cos(n), this; } /** * Sets the vector components from the given cylindrical coordinates. * * @param {Cylindrical} c - The cylindrical coordinates. * @return {Vector3} A reference to this vector. */ setFromCylindrical(e) { return this.setFromCylindricalCoords(e.radius, e.theta, e.y); } /** * Sets the vector components from the given cylindrical coordinates. * * @param {number} radius - The radius. * @param {number} theta - The theta angle in radians. * @param {number} y - The y value. * @return {Vector3} A reference to this vector. */ setFromCylindricalCoords(e, t, n) { return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this; } /** * Sets the vector components to the position elements of the * given transformation matrix. * * @param {Matrix4} m - The 4x4 matrix. * @return {Vector3} A reference to this vector. */ setFromMatrixPosition(e) { const t = e.elements; return this.x = t[12], this.y = t[13], this.z = t[14], this; } /** * Sets the vector components to the scale elements of the * given transformation matrix. * * @param {Matrix4} m - The 4x4 matrix. * @return {Vector3} A reference to this vector. */ setFromMatrixScale(e) { const t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), i = this.setFromMatrixColumn(e, 2).length(); return this.x = t, this.y = n, this.z = i, this; } /** * Sets the vector components from the specified matrix column. * * @param {Matrix4} m - The 4x4 matrix. * @param {number} index - The column index. * @return {Vector3} A reference to this vector. */ setFromMatrixColumn(e, t) { return this.fromArray(e.elements, t * 4); } /** * Sets the vector components from the specified matrix column. * * @param {Matrix3} m - The 3x3 matrix. * @param {number} index - The column index. * @return {Vector3} A reference to this vector. */ setFromMatrix3Column(e, t) { return this.fromArray(e.elements, t * 3); } /** * Sets the vector components from the given Euler angles. * * @param {Euler} e - The Euler angles to set. * @return {Vector3} A reference to this vector. */ setFromEuler(e) { return this.x = e._x, this.y = e._y, this.z = e._z, this; } /** * Sets the vector components from the RGB components of the * given color. * * @param {Color} c - The color to set. * @return {Vector3} A reference to this vector. */ setFromColor(e) { return this.x = e.r, this.y = e.g, this.z = e.b, this; } /** * Returns `true` if this vector is equal with the given one. * * @param {Vector3} v - The vector to test for equality. * @return {boolean} Whether this vector is equal with the given one. */ equals(e) { return e.x === this.x && e.y === this.y && e.z === this.z; } /** * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]` * and z value to be `array[ offset + 2 ]`. * * @param {Array} array - An array holding the vector component values. * @param {number} [offset=0] - The offset into the array. * @return {Vector3} A reference to this vector. */ fromArray(e, t = 0) { return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this; } /** * Writes the components of this vector to the given array. If no array is provided, * the method returns a new instance. * * @param {Array} [array=[]] - The target array holding the vector components. * @param {number} [offset=0] - Index of the first element in the array. * @return {Array} The vector components. */ toArray(e = [], t = 0) { return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e; } /** * Sets the components of this vector from the given buffer attribute. * * @param {BufferAttribute} attribute - The buffer attribute holding vector data. * @param {number} index - The index into the attribute. * @return {Vector3} A reference to this vector. */ fromBufferAttribute(e, t) { return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this; } /** * Sets each component of this vector to a pseudo-random value between `0` and * `1`, excluding `1`. * * @return {Vector3} A reference to this vector. */ random() { return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this; } /** * Sets this vector to a uniformly random point on a unit sphere. * * @return {Vector3} A reference to this vector. */ randomDirection() { const e = Math.random() * Math.PI * 2, t = Math.random() * 2 - 1, n = Math.sqrt(1 - t * t); return this.x = n * Math.cos(e), this.y = t, this.z = n * Math.sin(e), this; } *[Symbol.iterator]() { yield this.x, yield this.y, yield this.z; } } const Xa = /* @__PURE__ */ new R(), zc = /* @__PURE__ */ new Dn(); class $e { /** * Constructs a new 3x3 matrix. The arguments are supposed to be * in row-major order. If no arguments are provided, the constructor * initializes the matrix as an identity matrix. * * @param {number} [n11] - 1-1 matrix element. * @param {number} [n12] - 1-2 matrix element. * @param {number} [n13] - 1-3 matrix element. * @param {number} [n21] - 2-1 matrix element. * @param {number} [n22] - 2-2 matrix element. * @param {number} [n23] - 2-3 matrix element. * @param {number} [n31] - 3-1 matrix element. * @param {number} [n32] - 3-2 matrix element. * @param {number} [n33] - 3-3 matrix element. */ constructor(e, t, n, i, r, a, o, l, c) { $e.prototype.isMatrix3 = !0, this.elements = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ], e !== void 0 && this.set(e, t, n, i, r, a, o, l, c); } /** * Sets the elements of the matrix.The arguments are supposed to be * in row-major order. * * @param {number} [n11] - 1-1 matrix element. * @param {number} [n12] - 1-2 matrix element. * @param {number} [n13] - 1-3 matrix element. * @param {number} [n21] - 2-1 matrix element. * @param {number} [n22] - 2-2 matrix element. * @param {number} [n23] - 2-3 matrix element. * @param {number} [n31] - 3-1 matrix element. * @param {number} [n32] - 3-2 matrix element. * @param {number} [n33] - 3-3 matrix element. * @return {Matrix3} A reference to this matrix. */ set(e, t, n, i, r, a, o, l, c) { const h = this.elements; return h[0] = e, h[1] = i, h[2] = o, h[3] = t, h[4] = r, h[5] = l, h[6] = n, h[7] = a, h[8] = c, this; } /** * Sets this matrix to the 3x3 identity matrix. * * @return {Matrix3} A reference to this matrix. */ identity() { return this.set( 1, 0, 0, 0, 1, 0, 0, 0, 1 ), this; } /** * Copies the values of the given matrix to this instance. * * @param {Matrix3} m - The matrix to copy. * @return {Matrix3} A reference to this matrix. */ copy(e) { const t = this.elements, n = e.elements; return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this; } /** * Extracts the basis of this matrix into the three axis vectors provided. * * @param {Vector3} xAxis - The basis's x axis. * @param {Vector3} yAxis - The basis's y axis. * @param {Vector3} zAxis - The basis's z axis. * @return {Matrix3} A reference to this matrix. */ extractBasis(e, t, n) { return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this; } /** * Set this matrix to the upper 3x3 matrix of the given 4x4 matrix. * * @param {Matrix4} m - The 4x4 matrix. * @return {Matrix3} A reference to this matrix. */ 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; } /** * Post-multiplies this matrix by the given 3x3 matrix. * * @param {Matrix3} m - The matrix to multiply with. * @return {Matrix3} A reference to this matrix. */ multiply(e) { return this.multiplyMatrices(this, e); } /** * Pre-multiplies this matrix by the given 3x3 matrix. * * @param {Matrix3} m - The matrix to multiply with. * @return {Matrix3} A reference to this matrix. */ premultiply(e) { return this.multiplyMatrices(e, this); } /** * Multiples the given 3x3 matrices and stores the result * in this matrix. * * @param {Matrix3} a - The first matrix. * @param {Matrix3} b - The second matrix. * @return {Matrix3} A reference to this matrix. */ multiplyMatrices(e, t) { const n = e.elements, i = t.elements, r = this.elements, a = n[0], o = n[3], l = n[6], c = n[1], h = n[4], u = n[7], f = n[2], d = n[5], p = n[8], g = i[0], x = i[3], m = i[6], v = i[1], b = i[4], M = i[7], C = i[2], T = i[5], D = i[8]; return r[0] = a * g + o * v + l * C, r[3] = a * x + o * b + l * T, r[6] = a * m + o * M + l * D, r[1] = c * g + h * v + u * C, r[4] = c * x + h * b + u * T, r[7] = c * m + h * M + u * D, r[2] = f * g + d * v + p * C, r[5] = f * x + d * b + p * T, r[8] = f * m + d * M + p * D, this; } /** * Multiplies every component of the matrix by the given scalar. * * @param {number} s - The scalar. * @return {Matrix3} A reference to this matrix. */ 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; } /** * Computes and returns the determinant of this matrix. * * @return {number} The determinant. */ determinant() { const e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8]; return t * a * h - t * o * c - n * r * h + n * o * l + i * r * c - i * a * l; } /** * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution). * You can not invert with a determinant of zero. If you attempt this, the method produces * a zero matrix instead. * * @return {Matrix3} A reference to this matrix. */ invert() { const e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8], u = h * a - o * c, f = o * l - h * r, d = c * r - a * l, p = t * u + n * f + i * d; if (p === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); const g = 1 / p; return e[0] = u * g, e[1] = (i * c - h * n) * g, e[2] = (o * n - i * a) * g, e[3] = f * g, e[4] = (h * t - i * l) * g, e[5] = (i * r - o * t) * g, e[6] = d * g, e[7] = (n * l - c * t) * g, e[8] = (a * t - n * r) * g, this; } /** * Transposes this matrix in place. * * @return {Matrix3} A reference to this matrix. */ 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; } /** * Computes the normal matrix which is the inverse transpose of the upper * left 3x3 portion of the given 4x4 matrix. * * @param {Matrix4} matrix4 - The 4x4 matrix. * @return {Matrix3} A reference to this matrix. */ getNormalMatrix(e) { return this.setFromMatrix4(e).invert().transpose(); } /** * Transposes this matrix into the supplied array, and returns itself unchanged. * * @param {Array} r - An array to store the transposed matrix elements. * @return {Matrix3} A reference to this matrix. */ 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; } /** * Sets the UV transform matrix from offset, repeat, rotation, and center. * * @param {number} tx - Offset x. * @param {number} ty - Offset y. * @param {number} sx - Repeat x. * @param {number} sy - Repeat y. * @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise. * @param {number} cx - Center x of rotation. * @param {number} cy - Center y of rotation * @return {Matrix3} A reference to this matrix. */ setUvTransform(e, t, n, i, r, a, o) { const l = Math.cos(r), c = Math.sin(r); return this.set( n * l, n * c, -n * (l * a + c * o) + a + e, -i * c, i * l, -i * (-c * a + l * o) + o + t, 0, 0, 1 ), this; } /** * Scales this matrix with the given scalar values. * * @param {number} sx - The amount to scale in the X axis. * @param {number} sy - The amount to scale in the Y axis. * @return {Matrix3} A reference to this matrix. */ scale(e, t) { return this.premultiply(ja.makeScale(e, t)), this; } /** * Rotates this matrix by the given angle. * * @param {number} theta - The rotation in radians. * @return {Matrix3} A reference to this matrix. */ rotate(e) { return this.premultiply(ja.makeRotation(-e)), this; } /** * Translates this matrix by the given scalar values. * * @param {number} tx - The amount to translate in the X axis. * @param {number} ty - The amount to translate in the Y axis. * @return {Matrix3} A reference to this matrix. */ translate(e, t) { return this.premultiply(ja.makeTranslation(e, t)), this; } // for 2D Transforms /** * Sets this matrix as a 2D translation transform. * * @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector. * @param {number} y - The amount to translate in the Y axis. * @return {Matrix3} A reference to this matrix. */ 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; } /** * Sets this matrix as a 2D rotational transformation. * * @param {number} theta - The rotation in radians. * @return {Matrix3} A reference to this matrix. */ makeRotation(e) { const t = Math.cos(e), n = Math.sin(e); return this.set( t, -n, 0, n, t, 0, 0, 0, 1 ), this; } /** * Sets this matrix as a 2D scale transform. * * @param {number} x - The amount to scale in the X axis. * @param {number} y - The amount to scale in the Y axis. * @return {Matrix3} A reference to this matrix. */ makeScale(e, t) { return this.set( e, 0, 0, 0, t, 0, 0, 0, 1 ), this; } /** * Returns `true` if this matrix is equal with the given one. * * @param {Matrix3} matrix - The matrix to test for equality. * @return {boolean} Whether this matrix is equal with the given one. */ equals(e) { const t = this.elements, n = e.elements; for (let i = 0; i < 9; i++) if (t[i] !== n[i]) return !1; return !0; } /** * Sets the elements of the matrix from the given array. * * @param {Array} array - The matrix elements in column-major order. * @param {number} [offset=0] - Index of the first element in the array. * @return {Matrix3} A reference to this matrix. */ fromArray(e, t = 0) { for (let n = 0; n < 9; n++) this.elements[n] = e[n + t]; return this; } /** * Writes the elements of this matrix to the given array. If no array is provided, * the method returns a new instance. * * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order. * @param {number} [offset=0] - Index of the first element in the array. * @return {Array} The matrix elements in column-major order. */ toArray(e = [], t = 0) { const n = this.elements; return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e; } /** * Returns a matrix with copied values from this instance. * * @return {Matrix3} A clone of this instance. */ clone() { return new this.constructor().fromArray(this.elements); } } const ja = /* @__PURE__ */ new $e(), Hc = /* @__PURE__ */ new $e().set( 0.4123908, 0.3575843, 0.1804808, 0.212639, 0.7151687, 0.0721923, 0.0193308, 0.1191948, 0.9505322 ), Vc = /* @__PURE__ */ new $e().set( 3.2409699, -1.5373832, -0.4986108, -0.9692436, 1.8759675, 0.0415551, 0.0556301, -0.203977, 1.0569715 ); function Ep() { const s = { enabled: !0, workingColorSpace: Tt, /** * Implementations of supported color spaces. * * Required: * - primaries: chromaticity coordinates [ rx ry gx gy bx by ] * - whitePoint: reference white [ x y ] * - transfer: transfer function (pre-defined) * - toXYZ: Matrix3 RGB to XYZ transform * - fromXYZ: Matrix3 XYZ to RGB transform * - luminanceCoefficients: RGB luminance coefficients * * Optional: * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' } * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace } * * Reference: * - https://www.russellcottrell.com/photo/matrixCalculator.htm */ spaces: {}, convert: function(i, r, a) { return this.enabled === !1 || r === a || !r || !a || (this.spaces[r].transfer === ot && (i.r = ii(i.r), i.g = ii(i.g), i.b = ii(i.b)), this.spaces[r].primaries !== this.spaces[a].primaries && (i.applyMatrix3(this.spaces[r].toXYZ), i.applyMatrix3(this.spaces[a].fromXYZ)), this.spaces[a].transfer === ot && (i.r = hs(i.r), i.g = hs(i.g), i.b = hs(i.b))), i; }, workingToColorSpace: function(i, r) { return this.convert(i, this.workingColorSpace, r); }, colorSpaceToWorking: function(i, r) { return this.convert(i, r, this.workingColorSpace); }, getPrimaries: function(i) { return this.spaces[i].primaries; }, getTransfer: function(i) { return i === pi ? ba : this.spaces[i].transfer; }, getToneMappingMode: function(i) { return this.spaces[i].outputColorSpaceConfig.toneMappingMode || "standard"; }, getLuminanceCoefficients: function(i, r = this.workingColorSpace) { return i.fromArray(this.spaces[r].luminanceCoefficients); }, define: function(i) { Object.assign(this.spaces, i); }, // Internal APIs _getMatrix: function(i, r, a) { return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ); }, _getDrawingBufferColorSpace: function(i) { return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace; }, _getUnpackColorSpace: function(i = this.workingColorSpace) { return this.spaces[i].workingColorSpaceConfig.unpackColorSpace; }, // Deprecated fromWorkingColorSpace: function(i, r) { return lr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."), s.workingToColorSpace(i, r); }, toWorkingColorSpace: function(i, r) { return lr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."), s.colorSpaceToWorking(i, r); } }, e = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], t = [0.2126, 0.7152, 0.0722], n = [0.3127, 0.329]; return s.define({ [Tt]: { primaries: e, whitePoint: n, transfer: ba, toXYZ: Hc, fromXYZ: Vc, luminanceCoefficients: t, workingColorSpaceConfig: { unpackColorSpace: mt }, outputColorSpaceConfig: { drawingBufferColorSpace: mt } }, [mt]: { primaries: e, whitePoint: n, transfer: ot, toXYZ: Hc, fromXYZ: Vc, luminanceCoefficients: t, outputColorSpaceConfig: { drawingBufferColorSpace: mt } } }), s; } const it = /* @__PURE__ */ Ep(); function ii(s) { return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4); } function hs(s) { return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055; } let Wi; class Tp { /** * Returns a data URI containing a representation of the given image. * * @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object. * @param {string} [type='image/png'] - Indicates the image format. * @return {string} The data URI. */ static getDataURL(e, t = "image/png") { if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src; let n; if (e instanceof HTMLCanvasElement) n = e; else { Wi === void 0 && (Wi = or("canvas")), Wi.width = e.width, Wi.height = e.height; const i = Wi.getContext("2d"); e instanceof ImageData ? i.putImageData(e, 0, 0) : i.drawImage(e, 0, 0, e.width, e.height), n = Wi; } return n.toDataURL(t); } /** * Converts the given sRGB image data to linear color space. * * @param {(HTMLImageElement|HTMLCanvasElement|ImageBitmap|Object)} image - The image object. * @return {HTMLCanvasElement|Object} The converted image. */ static sRGBToLinear(e) { if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) { const t = or("canvas"); t.width = e.width, t.height = e.height; const n = t.getContext("2d"); n.drawImage(e, 0, 0, e.width, e.height); const i = n.getImageData(0, 0, e.width, e.height), r = i.data; for (let a = 0; a < r.length; a++) r[a] = ii(r[a] / 255) * 255; return n.putImageData(i, 0, 0), t; } else if (e.data) { const t = e.data.slice(0); for (let n = 0; n < t.length; n++) t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[n] = Math.floor(ii(t[n] / 255) * 255) : t[n] = ii(t[n]); return { data: t, width: e.width, height: e.height }; } else return ze("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e; } } let Cp = 0; class sc { /** * Constructs a new video texture. * * @param {any} [data=null] - The data definition of a texture. */ constructor(e = null) { this.isSource = !0, Object.defineProperty(this, "id", { value: Cp++ }), this.uuid = yn(), this.data = e, this.dataReady = !0, this.version = 0; } /** * Returns the dimensions of the source into the given target vector. * * @param {(Vector2|Vector3)} target - The target object the result is written into. * @return {(Vector2|Vector3)} The dimensions of the source. */ 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; } /** * When the property is set to `true`, the engine allocates the memory * for the texture (if necessary) and triggers the actual texture upload * to the GPU next time the source is used. * * @type {boolean} * @default false * @param {boolean} value */ set needsUpdate(e) { e === !0 && this.version++; } /** * Serializes the source into JSON. * * @param {?(Object|string)} meta - An optional value holding meta information about the serialization. * @return {Object} A JSON object representing the serialized source. * @see {@link ObjectLoader#parse} */ toJSON(e) { const t = e === void 0 || typeof e == "string"; if (!t && e.images[this.uuid] !== void 0) return e.images[this.uuid]; const n = { uuid: this.uuid, url: "" }, i = this.data; if (i !== null) { let r; if (Array.isArray(i)) { r = []; for (let a = 0, o = i.length; a < o; a++) i[a].isDataTexture ? r.push(Za(i[a].image)) : r.push(Za(i[a])); } else r = Za(i); n.url = r; } return t || (e.images[this.uuid] = n), n; } } function Za(s) { return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? Tp.getDataURL(s) : s.data ? { data: Array.from(s.data), width: s.width, height: s.height, type: s.data.constructor.name } : (ze("Texture: Unable to serialize Texture."), {}); } let Ap = 0; const qa = /* @__PURE__ */ new R(); class Ft extends Ui { /** * Constructs a new texture. * * @param {?Object} [image=Texture.DEFAULT_IMAGE] - The image holding the texture data. * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping. * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value. * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value. * @param {number} [magFilter=LinearFilter] - The mag filter value. * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value. * @param {number} [format=RGBAFormat] - The texture format. * @param {number} [type=UnsignedByteType] - The texture type. * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value. * @param {string} [colorSpace=NoColorSpace] - The color space. */ constructor(e = Ft.DEFAULT_IMAGE, t = Ft.DEFAULT_MAPPING, n = Hn, i = Hn, r = Ht, a = ti, o = sn, l = Ln, c = Ft.DEFAULT_ANISOTROPY, h = pi) { super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: Ap++ }), this.uuid = yn(), this.name = "", this.source = new sc(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = i, this.magFilter = r, this.minFilter = a, this.anisotropy = c, this.format = o, this.internalFormat = null, this.type = l, this.offset = new ue(0, 0), this.repeat = new ue(1, 1), this.center = new ue(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new $e(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = h, this.userData = {}, this.updateRanges = [], this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = !1, this.isArrayTexture = !!(e && e.depth && e.depth > 1), this.pmremVersion = 0; } /** * The width of the texture in pixels. */ get width() { return this.source.getSize(qa).x; } /** * The height of the texture in pixels. */ get height() { return this.source.getSize(qa).y; } /** * The depth of the texture in pixels. */ get depth() { return this.source.getSize(qa).z; } /** * The image object holding the texture data. * * @type {?Object} */ get image() { return this.source.data; } set image(e = null) { this.source.data = e; } /** * Updates the texture transformation matrix from the from the properties {@link Texture#offset}, * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}. */ updateMatrix() { this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); } /** * Adds a range of data in the data texture to be updated on the GPU. * * @param {number} start - Position at which to start update. * @param {number} count - The number of components to update. */ addUpdateRange(e, t) { this.updateRanges.push({ start: e, count: t }); } /** * Clears the update ranges. */ clearUpdateRanges() { this.updateRanges.length = 0; } /** * Returns a new texture with copied values from this instance. * * @return {Texture} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Copies the values of the given texture to this instance. * * @param {Texture} source - The texture to copy. * @return {Texture} A reference to this instance. */ 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; } /** * Sets this texture's properties based on `values`. * @param {Object} values - A container with texture parameters. */ setValues(e) { for (const t in e) { const n = e[t]; if (n === void 0) { ze(`Texture.setValues(): parameter '${t}' has value of undefined.`); continue; } const i = this[t]; if (i === void 0) { ze(`Texture.setValues(): property '${t}' does not exist.`); continue; } i && n && i.isVector2 && n.isVector2 || i && n && i.isVector3 && n.isVector3 || i && n && i.isMatrix3 && n.isMatrix3 ? i.copy(n) : this[t] = n; } } /** * Serializes the texture into JSON. * * @param {?(Object|string)} meta - An optional value holding meta information about the serialization. * @return {Object} A JSON object representing the serialized texture. * @see {@link ObjectLoader#parse} */ toJSON(e) { const t = e === void 0 || typeof e == "string"; if (!t && e.textures[this.uuid] !== void 0) return e.textures[this.uuid]; const n = { metadata: { version: 4.7, type: "Texture", generator: "Texture.toJSON" }, uuid: this.uuid, name: this.name, image: this.source.toJSON(e).uuid, mapping: this.mapping, channel: this.channel, repeat: [this.repeat.x, this.repeat.y], offset: [this.offset.x, this.offset.y], center: [this.center.x, this.center.y], rotation: this.rotation, wrap: [this.wrapS, this.wrapT], format: this.format, internalFormat: this.internalFormat, type: this.type, colorSpace: this.colorSpace, minFilter: this.minFilter, magFilter: this.magFilter, anisotropy: this.anisotropy, flipY: this.flipY, generateMipmaps: this.generateMipmaps, premultiplyAlpha: this.premultiplyAlpha, unpackAlignment: this.unpackAlignment }; return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n; } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. * * @fires Texture#dispose */ dispose() { this.dispatchEvent({ type: "dispose" }); } /** * Transforms the given uv vector with the textures uv transformation matrix. * * @param {Vector2} uv - The uv vector. * @return {Vector2} The transformed uv vector. */ transformUv(e) { if (this.mapping !== Vu) return e; if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch (this.wrapS) { case Gn: e.x = e.x - Math.floor(e.x); break; case Hn: e.x = e.x < 0 ? 0 : 1; break; case va: 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 Gn: e.y = e.y - Math.floor(e.y); break; case Hn: e.y = e.y < 0 ? 0 : 1; break; case va: 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; } /** * Setting this property to `true` indicates the engine the texture * must be updated in the next render. This triggers a texture upload * to the GPU and ensures correct texture parameter configuration. * * @type {boolean} * @default false * @param {boolean} value */ set needsUpdate(e) { e === !0 && (this.version++, this.source.needsUpdate = !0); } /** * Setting this property to `true` indicates the engine the PMREM * must be regenerated. * * @type {boolean} * @default false * @param {boolean} value */ set needsPMREMUpdate(e) { e === !0 && this.pmremVersion++; } } Ft.DEFAULT_IMAGE = null; Ft.DEFAULT_MAPPING = Vu; Ft.DEFAULT_ANISOTROPY = 1; class at { /** * Constructs a new 4D vector. * * @param {number} [x=0] - The x value of this vector. * @param {number} [y=0] - The y value of this vector. * @param {number} [z=0] - The z value of this vector. * @param {number} [w=1] - The w value of this vector. */ constructor(e = 0, t = 0, n = 0, i = 1) { at.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = n, this.w = i; } /** * Alias for {@link Vector4#z}. * * @type {number} */ get width() { return this.z; } set width(e) { this.z = e; } /** * Alias for {@link Vector4#w}. * * @type {number} */ get height() { return this.w; } set height(e) { this.w = e; } /** * Sets the vector components. * * @param {number} x - The value of the x component. * @param {number} y - The value of the y component. * @param {number} z - The value of the z component. * @param {number} w - The value of the w component. * @return {Vector4} A reference to this vector. */ set(e, t, n, i) { return this.x = e, this.y = t, this.z = n, this.w = i, this; } /** * Sets the vector components to the same value. * * @param {number} scalar - The value to set for all vector components. * @return {Vector4} A reference to this vector. */ setScalar(e) { return this.x = e, this.y = e, this.z = e, this.w = e, this; } /** * Sets the vector's x component to the given value * * @param {number} x - The value to set. * @return {Vector4} A reference to this vector. */ setX(e) { return this.x = e, this; } /** * Sets the vector's y component to the given value * * @param {number} y - The value to set. * @return {Vector4} A reference to this vector. */ setY(e) { return this.y = e, this; } /** * Sets the vector's z component to the given value * * @param {number} z - The value to set. * @return {Vector4} A reference to this vector. */ setZ(e) { return this.z = e, this; } /** * Sets the vector's w component to the given value * * @param {number} w - The value to set. * @return {Vector4} A reference to this vector. */ setW(e) { return this.w = e, this; } /** * Allows to set a vector component with an index. * * @param {number} index - The component index. `0` equals to x, `1` equals to y, * `2` equals to z, `3` equals to w. * @param {number} value - The value to set. * @return {Vector4} A reference to this vector. */ 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; } /** * Returns the value of the vector component which matches the given index. * * @param {number} index - The component index. `0` equals to x, `1` equals to y, * `2` equals to z, `3` equals to w. * @return {number} A vector component value. */ 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); } } /** * Returns a new vector with copied values from this instance. * * @return {Vector4} A clone of this instance. */ clone() { return new this.constructor(this.x, this.y, this.z, this.w); } /** * Copies the values of the given vector to this instance. * * @param {Vector3|Vector4} v - The vector to copy. * @return {Vector4} A reference to this vector. */ 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; } /** * Adds the given vector to this instance. * * @param {Vector4} v - The vector to add. * @return {Vector4} A reference to this vector. */ add(e) { return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this; } /** * Adds the given scalar value to all components of this instance. * * @param {number} s - The scalar to add. * @return {Vector4} A reference to this vector. */ addScalar(e) { return this.x += e, this.y += e, this.z += e, this.w += e, this; } /** * Adds the given vectors and stores the result in this instance. * * @param {Vector4} a - The first vector. * @param {Vector4} b - The second vector. * @return {Vector4} A reference to this vector. */ 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; } /** * Adds the given vector scaled by the given factor to this instance. * * @param {Vector4} v - The vector. * @param {number} s - The factor that scales `v`. * @return {Vector4} A reference to this vector. */ 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; } /** * Subtracts the given vector from this instance. * * @param {Vector4} v - The vector to subtract. * @return {Vector4} A reference to this vector. */ sub(e) { return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this; } /** * Subtracts the given scalar value from all components of this instance. * * @param {number} s - The scalar to subtract. * @return {Vector4} A reference to this vector. */ subScalar(e) { return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this; } /** * Subtracts the given vectors and stores the result in this instance. * * @param {Vector4} a - The first vector. * @param {Vector4} b - The second vector. * @return {Vector4} A reference to this vector. */ 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; } /** * Multiplies the given vector with this instance. * * @param {Vector4} v - The vector to multiply. * @return {Vector4} A reference to this vector. */ multiply(e) { return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this; } /** * Multiplies the given scalar value with all components of this instance. * * @param {number} scalar - The scalar to multiply. * @return {Vector4} A reference to this vector. */ multiplyScalar(e) { return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this; } /** * Multiplies this vector with the given 4x4 matrix. * * @param {Matrix4} m - The 4x4 matrix. * @return {Vector4} A reference to this vector. */ applyMatrix4(e) { const t = this.x, n = this.y, i = this.z, r = this.w, a = e.elements; return this.x = a[0] * t + a[4] * n + a[8] * i + a[12] * r, this.y = a[1] * t + a[5] * n + a[9] * i + a[13] * r, this.z = a[2] * t + a[6] * n + a[10] * i + a[14] * r, this.w = a[3] * t + a[7] * n + a[11] * i + a[15] * r, this; } /** * Divides this instance by the given vector. * * @param {Vector4} v - The vector to divide. * @return {Vector4} A reference to this vector. */ divide(e) { return this.x /= e.x, this.y /= e.y, this.z /= e.z, this.w /= e.w, this; } /** * Divides this vector by the given scalar. * * @param {number} scalar - The scalar to divide. * @return {Vector4} A reference to this vector. */ divideScalar(e) { return this.multiplyScalar(1 / e); } /** * Sets the x, y and z components of this * vector to the quaternion's axis and w to the angle. * * @param {Quaternion} q - The Quaternion to set. * @return {Vector4} A reference to this vector. */ 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; } /** * Sets the x, y and z components of this * vector to the axis of rotation and w to the angle. * * @param {Matrix4} m - A 4x4 matrix of which the upper left 3x3 matrix is a pure rotation matrix. * @return {Vector4} A reference to this vector. */ setAxisAngleFromRotationMatrix(e) { let t, n, i, r; const l = e.elements, c = l[0], h = l[4], u = l[8], f = l[1], d = l[5], p = l[9], g = l[2], x = l[6], m = l[10]; if (Math.abs(h - f) < 0.01 && Math.abs(u - g) < 0.01 && Math.abs(p - x) < 0.01) { if (Math.abs(h + f) < 0.1 && Math.abs(u + g) < 0.1 && Math.abs(p + x) < 0.1 && Math.abs(c + d + m - 3) < 0.1) return this.set(1, 0, 0, 0), this; t = Math.PI; const b = (c + 1) / 2, M = (d + 1) / 2, C = (m + 1) / 2, T = (h + f) / 4, D = (u + g) / 4, U = (p + x) / 4; return b > M && b > C ? b < 0.01 ? (n = 0, i = 0.707106781, r = 0.707106781) : (n = Math.sqrt(b), i = T / n, r = D / n) : M > C ? M < 0.01 ? (n = 0.707106781, i = 0, r = 0.707106781) : (i = Math.sqrt(M), n = T / i, r = U / i) : C < 0.01 ? (n = 0.707106781, i = 0.707106781, r = 0) : (r = Math.sqrt(C), n = D / r, i = U / r), this.set(n, i, r, t), this; } let v = Math.sqrt((x - p) * (x - p) + (u - g) * (u - g) + (f - h) * (f - h)); return Math.abs(v) < 1e-3 && (v = 1), this.x = (x - p) / v, this.y = (u - g) / v, this.z = (f - h) / v, this.w = Math.acos((c + d + m - 1) / 2), this; } /** * Sets the vector components to the position elements of the * given transformation matrix. * * @param {Matrix4} m - The 4x4 matrix. * @return {Vector4} A reference to this vector. */ setFromMatrixPosition(e) { const t = e.elements; return this.x = t[12], this.y = t[13], this.z = t[14], this.w = t[15], this; } /** * If this vector's x, y, z or w value is greater than the given vector's x, y, z or w * value, replace that value with the corresponding min value. * * @param {Vector4} v - The vector. * @return {Vector4} A reference to this vector. */ 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; } /** * If this vector's x, y, z or w value is less than the given vector's x, y, z or w * value, replace that value with the corresponding max value. * * @param {Vector4} v - The vector. * @return {Vector4} A reference to this vector. */ 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; } /** * If this vector's x, y, z or w value is greater than the max vector's x, y, z or w * value, it is replaced by the corresponding value. * If this vector's x, y, z or w value is less than the min vector's x, y, z or w value, * it is replaced by the corresponding value. * * @param {Vector4} min - The minimum x, y and z values. * @param {Vector4} max - The maximum x, y and z values in the desired range. * @return {Vector4} A reference to this vector. */ clamp(e, t) { return this.x = Je(this.x, e.x, t.x), this.y = Je(this.y, e.y, t.y), this.z = Je(this.z, e.z, t.z), this.w = Je(this.w, e.w, t.w), this; } /** * If this vector's x, y, z or w values are greater than the max value, they are * replaced by the max value. * If this vector's x, y, z or w values are less than the min value, they are * replaced by the min value. * * @param {number} minVal - The minimum value the components will be clamped to. * @param {number} maxVal - The maximum value the components will be clamped to. * @return {Vector4} A reference to this vector. */ clampScalar(e, t) { return this.x = Je(this.x, e, t), this.y = Je(this.y, e, t), this.z = Je(this.z, e, t), this.w = Je(this.w, e, t), this; } /** * If this vector's length is greater than the max value, it is replaced by * the max value. * If this vector's length is less than the min value, it is replaced by the * min value. * * @param {number} min - The minimum value the vector length will be clamped to. * @param {number} max - The maximum value the vector length will be clamped to. * @return {Vector4} A reference to this vector. */ clampLength(e, t) { const n = this.length(); return this.divideScalar(n || 1).multiplyScalar(Je(n, e, t)); } /** * The components of this vector are rounded down to the nearest integer value. * * @return {Vector4} A reference to this vector. */ 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; } /** * The components of this vector are rounded up to the nearest integer value. * * @return {Vector4} A reference to this vector. */ 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; } /** * The components of this vector are rounded to the nearest integer value * * @return {Vector4} A reference to this vector. */ 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; } /** * The components of this vector are rounded towards zero (up if negative, * down if positive) to an integer value. * * @return {Vector4} A reference to this vector. */ 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; } /** * Inverts this vector - i.e. sets x = -x, y = -y, z = -z, w = -w. * * @return {Vector4} A reference to this vector. */ negate() { return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this; } /** * Calculates the dot product of the given vector with this instance. * * @param {Vector4} v - The vector to compute the dot product with. * @return {number} The result of the dot product. */ dot(e) { return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w; } /** * Computes the square of the Euclidean length (straight-line length) from * (0, 0, 0, 0) to (x, y, z, w). If you are comparing the lengths of vectors, you should * compare the length squared instead as it is slightly more efficient to calculate. * * @return {number} The square length of this vector. */ lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; } /** * Computes the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w). * * @return {number} The length of this vector. */ length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } /** * Computes the Manhattan length of this vector. * * @return {number} The length of this vector. */ manhattanLength() { return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w); } /** * Converts this vector to a unit vector - that is, sets it equal to a vector * with the same direction as this one, but with a vector length of `1`. * * @return {Vector4} A reference to this vector. */ normalize() { return this.divideScalar(this.length() || 1); } /** * Sets this vector to a vector with the same direction as this one, but * with the specified length. * * @param {number} length - The new length of this vector. * @return {Vector4} A reference to this vector. */ setLength(e) { return this.normalize().multiplyScalar(e); } /** * Linearly interpolates between the given vector and this instance, where * alpha is the percent distance along the line - alpha = 0 will be this * vector, and alpha = 1 will be the given one. * * @param {Vector4} v - The vector to interpolate towards. * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`. * @return {Vector4} A reference to this vector. */ 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; } /** * Linearly interpolates between the given vectors, where alpha is the percent * distance along the line - alpha = 0 will be first vector, and alpha = 1 will * be the second one. The result is stored in this instance. * * @param {Vector4} v1 - The first vector. * @param {Vector4} v2 - The second vector. * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`. * @return {Vector4} A reference to this vector. */ lerpVectors(e, t, n) { return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this; } /** * Returns `true` if this vector is equal with the given one. * * @param {Vector4} v - The vector to test for equality. * @return {boolean} Whether this vector is equal with the given one. */ equals(e) { return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w; } /** * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`, * z value to be `array[ offset + 2 ]`, w value to be `array[ offset + 3 ]`. * * @param {Array} array - An array holding the vector component values. * @param {number} [offset=0] - The offset into the array. * @return {Vector4} A reference to this vector. */ 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; } /** * Writes the components of this vector to the given array. If no array is provided, * the method returns a new instance. * * @param {Array} [array=[]] - The target array holding the vector components. * @param {number} [offset=0] - Index of the first element in the array. * @return {Array} The vector components. */ 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; } /** * Sets the components of this vector from the given buffer attribute. * * @param {BufferAttribute} attribute - The buffer attribute holding vector data. * @param {number} index - The index into the attribute. * @return {Vector4} A reference to this vector. */ 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; } /** * Sets each component of this vector to a pseudo-random value between `0` and * `1`, excluding `1`. * * @return {Vector4} A reference to this vector. */ 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 Pp extends Ui { /** * Render target options. * * @typedef {Object} RenderTarget~Options * @property {boolean} [generateMipmaps=false] - Whether to generate mipmaps or not. * @property {number} [magFilter=LinearFilter] - The mag filter. * @property {number} [minFilter=LinearFilter] - The min filter. * @property {number} [format=RGBAFormat] - The texture format. * @property {number} [type=UnsignedByteType] - The texture type. * @property {?string} [internalFormat=null] - The texture's internal format. * @property {number} [wrapS=ClampToEdgeWrapping] - The texture's uv wrapping mode. * @property {number} [wrapT=ClampToEdgeWrapping] - The texture's uv wrapping mode. * @property {number} [anisotropy=1] - The texture's anisotropy value. * @property {string} [colorSpace=NoColorSpace] - The texture's color space. * @property {boolean} [depthBuffer=true] - Whether to allocate a depth buffer or not. * @property {boolean} [stencilBuffer=false] - Whether to allocate a stencil buffer or not. * @property {boolean} [resolveDepthBuffer=true] - Whether to resolve the depth buffer or not. * @property {boolean} [resolveStencilBuffer=true] - Whether to resolve the stencil buffer or not. * @property {?Texture} [depthTexture=null] - Reference to a depth texture. * @property {number} [samples=0] - The MSAA samples count. * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`. * @property {number} [depth=1] - The texture depth. * @property {boolean} [multiview=false] - Whether this target is used for multiview rendering. */ /** * Constructs a new render target. * * @param {number} [width=1] - The width of the render target. * @param {number} [height=1] - The height of the render target. * @param {RenderTarget~Options} [options] - The configuration object. */ constructor(e = 1, t = 1, n = {}) { super(), n = Object.assign({ generateMipmaps: !1, internalFormat: null, minFilter: Ht, depthBuffer: !0, stencilBuffer: !1, resolveDepthBuffer: !0, resolveStencilBuffer: !0, depthTexture: null, samples: 0, count: 1, depth: 1, multiview: !1 }, n), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = n.depth, this.scissor = new at(0, 0, e, t), this.scissorTest = !1, this.viewport = new at(0, 0, e, t); const i = { width: e, height: t, depth: n.depth }, r = new Ft(i); this.textures = []; const a = n.count; for (let o = 0; o < a; o++) this.textures[o] = r.clone(), this.textures[o].isRenderTargetTexture = !0, this.textures[o].renderTarget = this; this._setTextureOptions(n), this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.resolveDepthBuffer = n.resolveDepthBuffer, this.resolveStencilBuffer = n.resolveStencilBuffer, this._depthTexture = null, this.depthTexture = n.depthTexture, this.samples = n.samples, this.multiview = n.multiview; } _setTextureOptions(e = {}) { const t = { minFilter: Ht, generateMipmaps: !1, flipY: !1, internalFormat: null }; e.mapping !== void 0 && (t.mapping = e.mapping), e.wrapS !== void 0 && (t.wrapS = e.wrapS), e.wrapT !== void 0 && (t.wrapT = e.wrapT), e.wrapR !== void 0 && (t.wrapR = e.wrapR), e.magFilter !== void 0 && (t.magFilter = e.magFilter), e.minFilter !== void 0 && (t.minFilter = e.minFilter), e.format !== void 0 && (t.format = e.format), e.type !== void 0 && (t.type = e.type), e.anisotropy !== void 0 && (t.anisotropy = e.anisotropy), e.colorSpace !== void 0 && (t.colorSpace = e.colorSpace), e.flipY !== void 0 && (t.flipY = e.flipY), e.generateMipmaps !== void 0 && (t.generateMipmaps = e.generateMipmaps), e.internalFormat !== void 0 && (t.internalFormat = e.internalFormat); for (let n = 0; n < this.textures.length; n++) this.textures[n].setValues(t); } /** * The texture representing the default color attachment. * * @type {Texture} */ 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; } /** * Instead of saving the depth in a renderbuffer, a texture * can be used instead which is useful for further processing * e.g. in context of post-processing. * * @type {?DepthTexture} * @default null */ get depthTexture() { return this._depthTexture; } /** * Sets the size of this render target. * * @param {number} width - The width. * @param {number} height - The height. * @param {number} [depth=1] - The depth. */ setSize(e, t, n = 1) { if (this.width !== e || this.height !== t || this.depth !== n) { this.width = e, this.height = t, this.depth = n; for (let i = 0, r = this.textures.length; i < r; i++) this.textures[i].image.width = e, this.textures[i].image.height = t, this.textures[i].image.depth = n, this.textures[i].isData3DTexture !== !0 && (this.textures[i].isArrayTexture = this.textures[i].image.depth > 1); this.dispose(); } this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); } /** * Returns a new render target with copied values from this instance. * * @return {RenderTarget} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Copies the settings of the given render target. This is a structural copy so * no resources are shared between render targets after the copy. That includes * all MRT textures and the depth texture. * * @param {RenderTarget} source - The render target to copy. * @return {RenderTarget} A reference to this instance. */ copy(e) { this.width = e.width, this.height = e.height, this.depth = e.depth, this.scissor.copy(e.scissor), this.scissorTest = e.scissorTest, this.viewport.copy(e.viewport), this.textures.length = 0; for (let t = 0, n = e.textures.length; t < n; t++) { this.textures[t] = e.textures[t].clone(), this.textures[t].isRenderTargetTexture = !0, this.textures[t].renderTarget = this; const i = Object.assign({}, e.textures[t].image); this.textures[t].source = new sc(i); } return this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.resolveDepthBuffer = e.resolveDepthBuffer, this.resolveStencilBuffer = e.resolveStencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this; } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. * * @fires RenderTarget#dispose */ dispose() { this.dispatchEvent({ type: "dispose" }); } } class rn extends Pp { /** * Constructs a new 3D render target. * * @param {number} [width=1] - The width of the render target. * @param {number} [height=1] - The height of the render target. * @param {RenderTarget~Options} [options] - The configuration object. */ constructor(e = 1, t = 1, n = {}) { super(e, t, n), this.isWebGLRenderTarget = !0; } } class Qu extends Ft { /** * Constructs a new data array texture. * * @param {?TypedArray} [data=null] - The buffer data. * @param {number} [width=1] - The width of the texture. * @param {number} [height=1] - The height of the texture. * @param {number} [depth=1] - The depth of the texture. */ constructor(e = null, t = 1, n = 1, i = 1) { super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: n, depth: i }, this.magFilter = Gt, this.minFilter = Gt, this.wrapR = Hn, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set(); } /** * Describes that a specific layer of the texture needs to be updated. * Normally when {@link Texture#needsUpdate} is set to `true`, the * entire data texture array is sent to the GPU. Marking specific * layers will only transmit subsets of all mipmaps associated with a * specific depth in the array which is often much more performant. * * @param {number} layerIndex - The layer index that should be updated. */ addLayerUpdate(e) { this.layerUpdates.add(e); } /** * Resets the layer updates registry. */ clearLayerUpdates() { this.layerUpdates.clear(); } } class Rp extends Ft { /** * Constructs a new data array texture. * * @param {?TypedArray} [data=null] - The buffer data. * @param {number} [width=1] - The width of the texture. * @param {number} [height=1] - The height of the texture. * @param {number} [depth=1] - The depth of the texture. */ constructor(e = null, t = 1, n = 1, i = 1) { super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: n, depth: i }, this.magFilter = Gt, this.minFilter = Gt, this.wrapR = Hn, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } class zt { /** * Constructs a new bounding box. * * @param {Vector3} [min=(Infinity,Infinity,Infinity)] - A vector representing the lower boundary of the box. * @param {Vector3} [max=(-Infinity,-Infinity,-Infinity)] - A vector representing the upper boundary of the box. */ constructor(e = new R(1 / 0, 1 / 0, 1 / 0), t = new R(-1 / 0, -1 / 0, -1 / 0)) { this.isBox3 = !0, this.min = e, this.max = t; } /** * Sets the lower and upper boundaries of this box. * Please note that this method only copies the values from the given objects. * * @param {Vector3} min - The lower boundary of the box. * @param {Vector3} max - The upper boundary of the box. * @return {Box3} A reference to this bounding box. */ set(e, t) { return this.min.copy(e), this.max.copy(t), this; } /** * Sets the upper and lower bounds of this box so it encloses the position data * in the given array. * * @param {Array} array - An array holding 3D position data. * @return {Box3} A reference to this bounding box. */ setFromArray(e) { this.makeEmpty(); for (let t = 0, n = e.length; t < n; t += 3) this.expandByPoint(Sn.fromArray(e, t)); return this; } /** * Sets the upper and lower bounds of this box so it encloses the position data * in the given buffer attribute. * * @param {BufferAttribute} attribute - A buffer attribute holding 3D position data. * @return {Box3} A reference to this bounding box. */ setFromBufferAttribute(e) { this.makeEmpty(); for (let t = 0, n = e.count; t < n; t++) this.expandByPoint(Sn.fromBufferAttribute(e, t)); return this; } /** * Sets the upper and lower bounds of this box so it encloses the position data * in the given array. * * @param {Array} points - An array holding 3D position data as instances of {@link Vector3}. * @return {Box3} A reference to this bounding box. */ setFromPoints(e) { this.makeEmpty(); for (let t = 0, n = e.length; t < n; t++) this.expandByPoint(e[t]); return this; } /** * Centers this box on the given center vector and sets this box's width, height and * depth to the given size values. * * @param {Vector3} center - The center of the box. * @param {Vector3} size - The x, y and z dimensions of the box. * @return {Box3} A reference to this bounding box. */ setFromCenterAndSize(e, t) { const n = Sn.copy(t).multiplyScalar(0.5); return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; } /** * Computes the world-axis-aligned bounding box for the given 3D object * (including its children), accounting for the object's, and children's, * world transforms. The function may result in a larger box than strictly necessary. * * @param {Object3D} object - The 3D object to compute the bounding box for. * @param {boolean} [precise=false] - If set to `true`, the method computes the smallest * world-axis-aligned bounding box at the expense of more computation. * @return {Box3} A reference to this bounding box. */ setFromObject(e, t = !1) { return this.makeEmpty(), this.expandByObject(e, t); } /** * Returns a new box with copied values from this instance. * * @return {Box3} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Copies the values of the given box to this instance. * * @param {Box3} box - The box to copy. * @return {Box3} A reference to this bounding box. */ copy(e) { return this.min.copy(e.min), this.max.copy(e.max), this; } /** * Makes this box empty which means in encloses a zero space in 3D. * * @return {Box3} A reference to this bounding box. */ 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; } /** * Returns true if this box includes zero points within its bounds. * Note that a box with equal lower and upper bounds still includes one * point, the one both bounds share. * * @return {boolean} Whether this box is empty or not. */ isEmpty() { return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z; } /** * Returns the center point of this box. * * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The center point. */ getCenter(e) { return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5); } /** * Returns the dimensions of this box. * * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The size. */ getSize(e) { return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min); } /** * Expands the boundaries of this box to include the given point. * * @param {Vector3} point - The point that should be included by the bounding box. * @return {Box3} A reference to this bounding box. */ expandByPoint(e) { return this.min.min(e), this.max.max(e), this; } /** * Expands this box equilaterally by the given vector. The width of this * box will be expanded by the x component of the vector in both * directions. The height of this box will be expanded by the y component of * the vector in both directions. The depth of this box will be * expanded by the z component of the vector in both directions. * * @param {Vector3} vector - The vector that should expand the bounding box. * @return {Box3} A reference to this bounding box. */ expandByVector(e) { return this.min.sub(e), this.max.add(e), this; } /** * Expands each dimension of the box by the given scalar. If negative, the * dimensions of the box will be contracted. * * @param {number} scalar - The scalar value that should expand the bounding box. * @return {Box3} A reference to this bounding box. */ expandByScalar(e) { return this.min.addScalar(-e), this.max.addScalar(e), this; } /** * Expands the boundaries of this box to include the given 3D object and * its children, accounting for the object's, and children's, world * transforms. The function may result in a larger box than strictly * necessary (unless the precise parameter is set to true). * * @param {Object3D} object - The 3D object that should expand the bounding box. * @param {boolean} precise - If set to `true`, the method expands the bounding box * as little as necessary at the expense of more computation. * @return {Box3} A reference to this bounding box. */ expandByObject(e, t = !1) { e.updateWorldMatrix(!1, !1); const n = e.geometry; if (n !== void 0) { const r = n.getAttribute("position"); if (t === !0 && r !== void 0 && e.isInstancedMesh !== !0) for (let a = 0, o = r.count; a < o; a++) e.isMesh === !0 ? e.getVertexPosition(a, Sn) : Sn.fromBufferAttribute(r, a), Sn.applyMatrix4(e.matrixWorld), this.expandByPoint(Sn); else e.boundingBox !== void 0 ? (e.boundingBox === null && e.computeBoundingBox(), Mr.copy(e.boundingBox)) : (n.boundingBox === null && n.computeBoundingBox(), Mr.copy(n.boundingBox)), Mr.applyMatrix4(e.matrixWorld), this.union(Mr); } const i = e.children; for (let r = 0, a = i.length; r < a; r++) this.expandByObject(i[r], t); return this; } /** * Returns `true` if the given point lies within or on the boundaries of this box. * * @param {Vector3} point - The point to test. * @return {boolean} Whether the bounding box contains the given point or not. */ 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; } /** * Returns `true` if this bounding box includes the entirety of the given bounding box. * If this box and the given one are identical, this function also returns `true`. * * @param {Box3} box - The bounding box to test. * @return {boolean} Whether the bounding box contains the given bounding box or not. */ 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; } /** * Returns a point as a proportion of this box's width, height and depth. * * @param {Vector3} point - A point in 3D space. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} A point as a proportion of this box's width, height and depth. */ 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) ); } /** * Returns `true` if the given bounding box intersects with this bounding box. * * @param {Box3} box - The bounding box to test. * @return {boolean} Whether the given bounding box intersects with this bounding box. */ 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; } /** * Returns `true` if the given bounding sphere intersects with this bounding box. * * @param {Sphere} sphere - The bounding sphere to test. * @return {boolean} Whether the given bounding sphere intersects with this bounding box. */ intersectsSphere(e) { return this.clampPoint(e.center, Sn), Sn.distanceToSquared(e.center) <= e.radius * e.radius; } /** * Returns `true` if the given plane intersects with this bounding box. * * @param {Plane} plane - The plane to test. * @return {boolean} Whether the given plane intersects with this bounding box. */ intersectsPlane(e) { let t, n; return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant; } /** * Returns `true` if the given triangle intersects with this bounding box. * * @param {Triangle} triangle - The triangle to test. * @return {boolean} Whether the given triangle intersects with this bounding box. */ intersectsTriangle(e) { if (this.isEmpty()) return !1; this.getCenter(Ns), Sr.subVectors(this.max, Ns), Xi.subVectors(e.a, Ns), ji.subVectors(e.b, Ns), Zi.subVectors(e.c, Ns), oi.subVectors(ji, Xi), li.subVectors(Zi, ji), bi.subVectors(Xi, Zi); let t = [ 0, -oi.z, oi.y, 0, -li.z, li.y, 0, -bi.z, bi.y, oi.z, 0, -oi.x, li.z, 0, -li.x, bi.z, 0, -bi.x, -oi.y, oi.x, 0, -li.y, li.x, 0, -bi.y, bi.x, 0 ]; return !Ya(t, Xi, ji, Zi, Sr) || (t = [1, 0, 0, 0, 1, 0, 0, 0, 1], !Ya(t, Xi, ji, Zi, Sr)) ? !1 : (wr.crossVectors(oi, li), t = [wr.x, wr.y, wr.z], Ya(t, Xi, ji, Zi, Sr)); } /** * Clamps the given point within the bounds of this box. * * @param {Vector3} point - The point to clamp. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The clamped point. */ clampPoint(e, t) { return t.copy(e).clamp(this.min, this.max); } /** * Returns the euclidean distance from any edge of this box to the specified point. If * the given point lies inside of this box, the distance will be `0`. * * @param {Vector3} point - The point to compute the distance to. * @return {number} The euclidean distance. */ distanceToPoint(e) { return this.clampPoint(e, Sn).distanceTo(e); } /** * Returns a bounding sphere that encloses this bounding box. * * @param {Sphere} target - The target sphere that is used to store the method's result. * @return {Sphere} The bounding sphere that encloses this bounding box. */ getBoundingSphere(e) { return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(Sn).length() * 0.5), e; } /** * Computes the intersection of this bounding box and the given one, setting the upper * bound of this box to the lesser of the two boxes' upper bounds and the * lower bound of this box to the greater of the two boxes' lower bounds. If * there's no overlap, makes this box empty. * * @param {Box3} box - The bounding box to intersect with. * @return {Box3} A reference to this bounding box. */ intersect(e) { return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this; } /** * Computes the union of this box and another and the given one, setting the upper * bound of this box to the greater of the two boxes' upper bounds and the * lower bound of this box to the lesser of the two boxes' lower bounds. * * @param {Box3} box - The bounding box that will be unioned with this instance. * @return {Box3} A reference to this bounding box. */ union(e) { return this.min.min(e.min), this.max.max(e.max), this; } /** * Transforms this bounding box by the given 4x4 transformation matrix. * * @param {Matrix4} matrix - The transformation matrix. * @return {Box3} A reference to this bounding box. */ applyMatrix4(e) { return this.isEmpty() ? this : (Zn[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), Zn[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), Zn[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), Zn[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), Zn[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), Zn[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), Zn[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), Zn[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(Zn), this); } /** * Adds the given offset to both the upper and lower bounds of this bounding box, * effectively moving it in 3D space. * * @param {Vector3} offset - The offset that should be used to translate the bounding box. * @return {Box3} A reference to this bounding box. */ translate(e) { return this.min.add(e), this.max.add(e), this; } /** * Returns `true` if this bounding box is equal with the given one. * * @param {Box3} box - The box to test for equality. * @return {boolean} Whether this bounding box is equal with the given one. */ equals(e) { return e.min.equals(this.min) && e.max.equals(this.max); } /** * Returns a serialized structure of the bounding box. * * @return {Object} Serialized structure with fields representing the object state. */ toJSON() { return { min: this.min.toArray(), max: this.max.toArray() }; } /** * Returns a serialized structure of the bounding box. * * @param {Object} json - The serialized json to set the box from. * @return {Box3} A reference to this bounding box. */ fromJSON(e) { return this.min.fromArray(e.min), this.max.fromArray(e.max), this; } } const Zn = [ /* @__PURE__ */ new R(), /* @__PURE__ */ new R(), /* @__PURE__ */ new R(), /* @__PURE__ */ new R(), /* @__PURE__ */ new R(), /* @__PURE__ */ new R(), /* @__PURE__ */ new R(), /* @__PURE__ */ new R() ], Sn = /* @__PURE__ */ new R(), Mr = /* @__PURE__ */ new zt(), Xi = /* @__PURE__ */ new R(), ji = /* @__PURE__ */ new R(), Zi = /* @__PURE__ */ new R(), oi = /* @__PURE__ */ new R(), li = /* @__PURE__ */ new R(), bi = /* @__PURE__ */ new R(), Ns = /* @__PURE__ */ new R(), Sr = /* @__PURE__ */ new R(), wr = /* @__PURE__ */ new R(), _i = /* @__PURE__ */ new R(); function Ya(s, e, t, n, i) { for (let r = 0, a = s.length - 3; r <= a; r += 3) { _i.fromArray(s, r); const o = i.x * Math.abs(_i.x) + i.y * Math.abs(_i.y) + i.z * Math.abs(_i.z), l = e.dot(_i), c = t.dot(_i), h = n.dot(_i); if (Math.max(-Math.max(l, c, h), Math.min(l, c, h)) > o) return !1; } return !0; } const Lp = /* @__PURE__ */ new zt(), ks = /* @__PURE__ */ new R(), Ka = /* @__PURE__ */ new R(); class Xn { /** * Constructs a new sphere. * * @param {Vector3} [center=(0,0,0)] - The center of the sphere * @param {number} [radius=-1] - The radius of the sphere. */ constructor(e = new R(), t = -1) { this.isSphere = !0, this.center = e, this.radius = t; } /** * Sets the sphere's components by copying the given values. * * @param {Vector3} center - The center. * @param {number} radius - The radius. * @return {Sphere} A reference to this sphere. */ set(e, t) { return this.center.copy(e), this.radius = t, this; } /** * Computes the minimum bounding sphere for list of points. * If the optional center point is given, it is used as the sphere's * center. Otherwise, the center of the axis-aligned bounding box * encompassing the points is calculated. * * @param {Array} points - A list of points in 3D space. * @param {Vector3} [optionalCenter] - The center of the sphere. * @return {Sphere} A reference to this sphere. */ setFromPoints(e, t) { const n = this.center; t !== void 0 ? n.copy(t) : Lp.setFromPoints(e).getCenter(n); let i = 0; for (let r = 0, a = e.length; r < a; r++) i = Math.max(i, n.distanceToSquared(e[r])); return this.radius = Math.sqrt(i), this; } /** * Copies the values of the given sphere to this instance. * * @param {Sphere} sphere - The sphere to copy. * @return {Sphere} A reference to this sphere. */ copy(e) { return this.center.copy(e.center), this.radius = e.radius, this; } /** * Returns `true` if the sphere is empty (the radius set to a negative number). * * Spheres with a radius of `0` contain only their center point and are not * considered to be empty. * * @return {boolean} Whether this sphere is empty or not. */ isEmpty() { return this.radius < 0; } /** * Makes this sphere empty which means in encloses a zero space in 3D. * * @return {Sphere} A reference to this sphere. */ makeEmpty() { return this.center.set(0, 0, 0), this.radius = -1, this; } /** * Returns `true` if this sphere contains the given point inclusive of * the surface of the sphere. * * @param {Vector3} point - The point to check. * @return {boolean} Whether this sphere contains the given point or not. */ containsPoint(e) { return e.distanceToSquared(this.center) <= this.radius * this.radius; } /** * Returns the closest distance from the boundary of the sphere to the * given point. If the sphere contains the point, the distance will * be negative. * * @param {Vector3} point - The point to compute the distance to. * @return {number} The distance to the point. */ distanceToPoint(e) { return e.distanceTo(this.center) - this.radius; } /** * Returns `true` if this sphere intersects with the given one. * * @param {Sphere} sphere - The sphere to test. * @return {boolean} Whether this sphere intersects with the given one or not. */ intersectsSphere(e) { const t = this.radius + e.radius; return e.center.distanceToSquared(this.center) <= t * t; } /** * Returns `true` if this sphere intersects with the given box. * * @param {Box3} box - The box to test. * @return {boolean} Whether this sphere intersects with the given box or not. */ intersectsBox(e) { return e.intersectsSphere(this); } /** * Returns `true` if this sphere intersects with the given plane. * * @param {Plane} plane - The plane to test. * @return {boolean} Whether this sphere intersects with the given plane or not. */ intersectsPlane(e) { return Math.abs(e.distanceToPoint(this.center)) <= this.radius; } /** * Clamps a point within the sphere. If the point is outside the sphere, it * will clamp it to the closest point on the edge of the sphere. Points * already inside the sphere will not be affected. * * @param {Vector3} point - The plane to clamp. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The clamped point. */ clampPoint(e, t) { const n = this.center.distanceToSquared(e); return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t; } /** * Returns a bounding box that encloses this sphere. * * @param {Box3} target - The target box that is used to store the method's result. * @return {Box3} The bounding box that encloses this sphere. */ getBoundingBox(e) { return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e); } /** * Transforms this sphere with the given 4x4 transformation matrix. * * @param {Matrix4} matrix - The transformation matrix. * @return {Sphere} A reference to this sphere. */ applyMatrix4(e) { return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this; } /** * Translates the sphere's center by the given offset. * * @param {Vector3} offset - The offset. * @return {Sphere} A reference to this sphere. */ translate(e) { return this.center.add(e), this; } /** * Expands the boundaries of this sphere to include the given point. * * @param {Vector3} point - The point to include. * @return {Sphere} A reference to this sphere. */ expandByPoint(e) { if (this.isEmpty()) return this.center.copy(e), this.radius = 0, this; ks.subVectors(e, this.center); const t = ks.lengthSq(); if (t > this.radius * this.radius) { const n = Math.sqrt(t), i = (n - this.radius) * 0.5; this.center.addScaledVector(ks, i / n), this.radius += i; } return this; } /** * Expands this sphere to enclose both the original sphere and the given sphere. * * @param {Sphere} sphere - The sphere to include. * @return {Sphere} A reference to this sphere. */ 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(ks.copy(e.center).add(Ka)), this.expandByPoint(ks.copy(e.center).sub(Ka))), this); } /** * Returns `true` if this sphere is equal with the given one. * * @param {Sphere} sphere - The sphere to test for equality. * @return {boolean} Whether this bounding sphere is equal with the given one. */ equals(e) { return e.center.equals(this.center) && e.radius === this.radius; } /** * Returns a new sphere with copied values from this instance. * * @return {Sphere} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Returns a serialized structure of the bounding sphere. * * @return {Object} Serialized structure with fields representing the object state. */ toJSON() { return { radius: this.radius, center: this.center.toArray() }; } /** * Returns a serialized structure of the bounding sphere. * * @param {Object} json - The serialized json to set the sphere from. * @return {Box3} A reference to this bounding sphere. */ fromJSON(e) { return this.radius = e.radius, this.center.fromArray(e.center), this; } } const qn = /* @__PURE__ */ new R(), $a = /* @__PURE__ */ new R(), Er = /* @__PURE__ */ new R(), ci = /* @__PURE__ */ new R(), Ja = /* @__PURE__ */ new R(), Tr = /* @__PURE__ */ new R(), Qa = /* @__PURE__ */ new R(); class Ts { /** * Constructs a new ray. * * @param {Vector3} [origin=(0,0,0)] - The origin of the ray. * @param {Vector3} [direction=(0,0,-1)] - The (normalized) direction of the ray. */ constructor(e = new R(), t = new R(0, 0, -1)) { this.origin = e, this.direction = t; } /** * Sets the ray's components by copying the given values. * * @param {Vector3} origin - The origin. * @param {Vector3} direction - The direction. * @return {Ray} A reference to this ray. */ set(e, t) { return this.origin.copy(e), this.direction.copy(t), this; } /** * Copies the values of the given ray to this instance. * * @param {Ray} ray - The ray to copy. * @return {Ray} A reference to this ray. */ copy(e) { return this.origin.copy(e.origin), this.direction.copy(e.direction), this; } /** * Returns a vector that is located at a given distance along this ray. * * @param {number} t - The distance along the ray to retrieve a position for. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} A position on the ray. */ at(e, t) { return t.copy(this.origin).addScaledVector(this.direction, e); } /** * Adjusts the direction of the ray to point at the given vector in world space. * * @param {Vector3} v - The target position. * @return {Ray} A reference to this ray. */ lookAt(e) { return this.direction.copy(e).sub(this.origin).normalize(), this; } /** * Shift the origin of this ray along its direction by the given distance. * * @param {number} t - The distance along the ray to interpolate. * @return {Ray} A reference to this ray. */ recast(e) { return this.origin.copy(this.at(e, qn)), this; } /** * Returns the point along this ray that is closest to the given point. * * @param {Vector3} point - A point in 3D space to get the closet location on the ray for. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The closest point on this ray. */ closestPointToPoint(e, t) { t.subVectors(e, this.origin); const n = t.dot(this.direction); return n < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, n); } /** * Returns the distance of the closest approach between this ray and the given point. * * @param {Vector3} point - A point in 3D space to compute the distance to. * @return {number} The distance. */ distanceToPoint(e) { return Math.sqrt(this.distanceSqToPoint(e)); } /** * Returns the squared distance of the closest approach between this ray and the given point. * * @param {Vector3} point - A point in 3D space to compute the distance to. * @return {number} The squared distance. */ distanceSqToPoint(e) { const t = qn.subVectors(e, this.origin).dot(this.direction); return t < 0 ? this.origin.distanceToSquared(e) : (qn.copy(this.origin).addScaledVector(this.direction, t), qn.distanceToSquared(e)); } /** * Returns the squared distance between this ray and the given line segment. * * @param {Vector3} v0 - The start point of the line segment. * @param {Vector3} v1 - The end point of the line segment. * @param {Vector3} [optionalPointOnRay] - When provided, it receives the point on this ray that is closest to the segment. * @param {Vector3} [optionalPointOnSegment] - When provided, it receives the point on the line segment that is closest to this ray. * @return {number} The squared distance. */ distanceSqToSegment(e, t, n, i) { $a.copy(e).add(t).multiplyScalar(0.5), Er.copy(t).sub(e).normalize(), ci.copy(this.origin).sub($a); const r = e.distanceTo(t) * 0.5, a = -this.direction.dot(Er), o = ci.dot(this.direction), l = -ci.dot(Er), c = ci.lengthSq(), h = Math.abs(1 - a * a); let u, f, d, p; if (h > 0) if (u = a * l - o, f = a * o - l, p = r * h, u >= 0) if (f >= -p) if (f <= p) { const g = 1 / h; u *= g, f *= g, d = u * (u + a * f + 2 * o) + f * (a * u + f + 2 * l) + c; } else f = r, u = Math.max(0, -(a * f + o)), d = -u * u + f * (f + 2 * l) + c; else f = -r, u = Math.max(0, -(a * f + o)), d = -u * u + f * (f + 2 * l) + c; else f <= -p ? (u = Math.max(0, -(-a * r + o)), f = u > 0 ? -r : Math.min(Math.max(-r, -l), r), d = -u * u + f * (f + 2 * l) + c) : f <= p ? (u = 0, f = Math.min(Math.max(-r, -l), r), d = f * (f + 2 * l) + c) : (u = Math.max(0, -(a * r + o)), f = u > 0 ? r : Math.min(Math.max(-r, -l), r), d = -u * u + f * (f + 2 * l) + c); else f = a > 0 ? -r : r, u = Math.max(0, -(a * f + o)), d = -u * u + f * (f + 2 * l) + c; return n && n.copy(this.origin).addScaledVector(this.direction, u), i && i.copy($a).addScaledVector(Er, f), d; } /** * Intersects this ray with the given sphere, returning the intersection * point or `null` if there is no intersection. * * @param {Sphere} sphere - The sphere to intersect. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The intersection point. */ intersectSphere(e, t) { qn.subVectors(e.center, this.origin); const n = qn.dot(this.direction), i = qn.dot(qn) - n * n, r = e.radius * e.radius; if (i > r) return null; const a = Math.sqrt(r - i), o = n - a, l = n + a; return l < 0 ? null : o < 0 ? this.at(l, t) : this.at(o, t); } /** * Returns `true` if this ray intersects with the given sphere. * * @param {Sphere} sphere - The sphere to intersect. * @return {boolean} Whether this ray intersects with the given sphere or not. */ intersectsSphere(e) { return e.radius < 0 ? !1 : this.distanceSqToPoint(e.center) <= e.radius * e.radius; } /** * Computes the distance from the ray's origin to the given plane. Returns `null` if the ray * does not intersect with the plane. * * @param {Plane} plane - The plane to compute the distance to. * @return {?number} Whether this ray intersects with the given sphere or not. */ distanceToPlane(e) { const t = e.normal.dot(this.direction); if (t === 0) return e.distanceToPoint(this.origin) === 0 ? 0 : null; const n = -(this.origin.dot(e.normal) + e.constant) / t; return n >= 0 ? n : null; } /** * Intersects this ray with the given plane, returning the intersection * point or `null` if there is no intersection. * * @param {Plane} plane - The plane to intersect. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The intersection point. */ intersectPlane(e, t) { const n = this.distanceToPlane(e); return n === null ? null : this.at(n, t); } /** * Returns `true` if this ray intersects with the given plane. * * @param {Plane} plane - The plane to intersect. * @return {boolean} Whether this ray intersects with the given plane or not. */ intersectsPlane(e) { const t = e.distanceToPoint(this.origin); return t === 0 || e.normal.dot(this.direction) * t < 0; } /** * Intersects this ray with the given bounding box, returning the intersection * point or `null` if there is no intersection. * * @param {Box3} box - The box to intersect. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The intersection point. */ intersectBox(e, t) { let n, i, r, a, o, l; const c = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, f = this.origin; return c >= 0 ? (n = (e.min.x - f.x) * c, i = (e.max.x - f.x) * c) : (n = (e.max.x - f.x) * c, i = (e.min.x - f.x) * c), h >= 0 ? (r = (e.min.y - f.y) * h, a = (e.max.y - f.y) * h) : (r = (e.max.y - f.y) * h, a = (e.min.y - f.y) * h), n > a || r > i || ((r > n || isNaN(n)) && (n = r), (a < i || isNaN(i)) && (i = a), u >= 0 ? (o = (e.min.z - f.z) * u, l = (e.max.z - f.z) * u) : (o = (e.max.z - f.z) * u, l = (e.min.z - f.z) * u), n > l || o > i) || ((o > n || n !== n) && (n = o), (l < i || i !== i) && (i = l), i < 0) ? null : this.at(n >= 0 ? n : i, t); } /** * Returns `true` if this ray intersects with the given box. * * @param {Box3} box - The box to intersect. * @return {boolean} Whether this ray intersects with the given box or not. */ intersectsBox(e) { return this.intersectBox(e, qn) !== null; } /** * Intersects this ray with the given triangle, returning the intersection * point or `null` if there is no intersection. * * @param {Vector3} a - The first vertex of the triangle. * @param {Vector3} b - The second vertex of the triangle. * @param {Vector3} c - The third vertex of the triangle. * @param {boolean} backfaceCulling - Whether to use backface culling or not. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The intersection point. */ intersectTriangle(e, t, n, i, r) { Ja.subVectors(t, e), Tr.subVectors(n, e), Qa.crossVectors(Ja, Tr); let a = this.direction.dot(Qa), o; if (a > 0) { if (i) return null; o = 1; } else if (a < 0) o = -1, a = -a; else return null; ci.subVectors(this.origin, e); const l = o * this.direction.dot(Tr.crossVectors(ci, Tr)); if (l < 0) return null; const c = o * this.direction.dot(Ja.cross(ci)); if (c < 0 || l + c > a) return null; const h = -o * ci.dot(Qa); return h < 0 ? null : this.at(h / a, r); } /** * Transforms this ray with the given 4x4 transformation matrix. * * @param {Matrix4} matrix4 - The transformation matrix. * @return {Ray} A reference to this ray. */ applyMatrix4(e) { return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this; } /** * Returns `true` if this ray is equal with the given one. * * @param {Ray} ray - The ray to test for equality. * @return {boolean} Whether this ray is equal with the given one. */ equals(e) { return e.origin.equals(this.origin) && e.direction.equals(this.direction); } /** * Returns a new ray with copied values from this instance. * * @return {Ray} A clone of this instance. */ clone() { return new this.constructor().copy(this); } } class je { /** * Constructs a new 4x4 matrix. The arguments are supposed to be * in row-major order. If no arguments are provided, the constructor * initializes the matrix as an identity matrix. * * @param {number} [n11] - 1-1 matrix element. * @param {number} [n12] - 1-2 matrix element. * @param {number} [n13] - 1-3 matrix element. * @param {number} [n14] - 1-4 matrix element. * @param {number} [n21] - 2-1 matrix element. * @param {number} [n22] - 2-2 matrix element. * @param {number} [n23] - 2-3 matrix element. * @param {number} [n24] - 2-4 matrix element. * @param {number} [n31] - 3-1 matrix element. * @param {number} [n32] - 3-2 matrix element. * @param {number} [n33] - 3-3 matrix element. * @param {number} [n34] - 3-4 matrix element. * @param {number} [n41] - 4-1 matrix element. * @param {number} [n42] - 4-2 matrix element. * @param {number} [n43] - 4-3 matrix element. * @param {number} [n44] - 4-4 matrix element. */ constructor(e, t, n, i, r, a, o, l, c, h, u, f, d, p, g, x) { je.prototype.isMatrix4 = !0, this.elements = [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ], e !== void 0 && this.set(e, t, n, i, r, a, o, l, c, h, u, f, d, p, g, x); } /** * Sets the elements of the matrix.The arguments are supposed to be * in row-major order. * * @param {number} [n11] - 1-1 matrix element. * @param {number} [n12] - 1-2 matrix element. * @param {number} [n13] - 1-3 matrix element. * @param {number} [n14] - 1-4 matrix element. * @param {number} [n21] - 2-1 matrix element. * @param {number} [n22] - 2-2 matrix element. * @param {number} [n23] - 2-3 matrix element. * @param {number} [n24] - 2-4 matrix element. * @param {number} [n31] - 3-1 matrix element. * @param {number} [n32] - 3-2 matrix element. * @param {number} [n33] - 3-3 matrix element. * @param {number} [n34] - 3-4 matrix element. * @param {number} [n41] - 4-1 matrix element. * @param {number} [n42] - 4-2 matrix element. * @param {number} [n43] - 4-3 matrix element. * @param {number} [n44] - 4-4 matrix element. * @return {Matrix4} A reference to this matrix. */ set(e, t, n, i, r, a, o, l, c, h, u, f, d, p, g, x) { const m = this.elements; return m[0] = e, m[4] = t, m[8] = n, m[12] = i, m[1] = r, m[5] = a, m[9] = o, m[13] = l, m[2] = c, m[6] = h, m[10] = u, m[14] = f, m[3] = d, m[7] = p, m[11] = g, m[15] = x, this; } /** * Sets this matrix to the 4x4 identity matrix. * * @return {Matrix4} A reference to this matrix. */ identity() { return this.set( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ), this; } /** * Returns a matrix with copied values from this instance. * * @return {Matrix4} A clone of this instance. */ clone() { return new je().fromArray(this.elements); } /** * Copies the values of the given matrix to this instance. * * @param {Matrix4} m - The matrix to copy. * @return {Matrix4} A reference to this matrix. */ copy(e) { const t = this.elements, n = e.elements; return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this; } /** * Copies the translation component of the given matrix * into this matrix's translation component. * * @param {Matrix4} m - The matrix to copy the translation component. * @return {Matrix4} A reference to this matrix. */ copyPosition(e) { const t = this.elements, n = e.elements; return t[12] = n[12], t[13] = n[13], t[14] = n[14], this; } /** * Set the upper 3x3 elements of this matrix to the values of given 3x3 matrix. * * @param {Matrix3} m - The 3x3 matrix. * @return {Matrix4} A reference to this matrix. */ 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; } /** * Extracts the basis of this matrix into the three axis vectors provided. * * @param {Vector3} xAxis - The basis's x axis. * @param {Vector3} yAxis - The basis's y axis. * @param {Vector3} zAxis - The basis's z axis. * @return {Matrix4} A reference to this matrix. */ extractBasis(e, t, n) { return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this; } /** * Sets the given basis vectors to this matrix. * * @param {Vector3} xAxis - The basis's x axis. * @param {Vector3} yAxis - The basis's y axis. * @param {Vector3} zAxis - The basis's z axis. * @return {Matrix4} A reference to this matrix. */ makeBasis(e, t, n) { return this.set( e.x, t.x, n.x, 0, e.y, t.y, n.y, 0, e.z, t.z, n.z, 0, 0, 0, 0, 1 ), this; } /** * Extracts the rotation component of the given matrix * into this matrix's rotation component. * * Note: This method does not support reflection matrices. * * @param {Matrix4} m - The matrix. * @return {Matrix4} A reference to this matrix. */ extractRotation(e) { const t = this.elements, n = e.elements, i = 1 / qi.setFromMatrixColumn(e, 0).length(), r = 1 / qi.setFromMatrixColumn(e, 1).length(), a = 1 / qi.setFromMatrixColumn(e, 2).length(); return t[0] = n[0] * i, t[1] = n[1] * i, t[2] = n[2] * i, t[3] = 0, t[4] = n[4] * r, t[5] = n[5] * r, t[6] = n[6] * r, t[7] = 0, t[8] = n[8] * a, t[9] = n[9] * a, t[10] = n[10] * a, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; } /** * Sets the rotation component (the upper left 3x3 matrix) of this matrix to * the rotation specified by the given Euler angles. The rest of * the matrix is set to the identity. Depending on the {@link Euler#order}, * there are six possible outcomes. See [this page](https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix) * for a complete list. * * @param {Euler} euler - The Euler angles. * @return {Matrix4} A reference to this matrix. */ makeRotationFromEuler(e) { const t = this.elements, n = e.x, i = e.y, r = e.z, a = Math.cos(n), o = Math.sin(n), l = Math.cos(i), c = Math.sin(i), h = Math.cos(r), u = Math.sin(r); if (e.order === "XYZ") { const f = a * h, d = a * u, p = o * h, g = o * u; t[0] = l * h, t[4] = -l * u, t[8] = c, t[1] = d + p * c, t[5] = f - g * c, t[9] = -o * l, t[2] = g - f * c, t[6] = p + d * c, t[10] = a * l; } else if (e.order === "YXZ") { const f = l * h, d = l * u, p = c * h, g = c * u; t[0] = f + g * o, t[4] = p * o - d, t[8] = a * c, t[1] = a * u, t[5] = a * h, t[9] = -o, t[2] = d * o - p, t[6] = g + f * o, t[10] = a * l; } else if (e.order === "ZXY") { const f = l * h, d = l * u, p = c * h, g = c * u; t[0] = f - g * o, t[4] = -a * u, t[8] = p + d * o, t[1] = d + p * o, t[5] = a * h, t[9] = g - f * o, t[2] = -a * c, t[6] = o, t[10] = a * l; } else if (e.order === "ZYX") { const f = a * h, d = a * u, p = o * h, g = o * u; t[0] = l * h, t[4] = p * c - d, t[8] = f * c + g, t[1] = l * u, t[5] = g * c + f, t[9] = d * c - p, t[2] = -c, t[6] = o * l, t[10] = a * l; } else if (e.order === "YZX") { const f = a * l, d = a * c, p = o * l, g = o * c; t[0] = l * h, t[4] = g - f * u, t[8] = p * u + d, t[1] = u, t[5] = a * h, t[9] = -o * h, t[2] = -c * h, t[6] = d * u + p, t[10] = f - g * u; } else if (e.order === "XZY") { const f = a * l, d = a * c, p = o * l, g = o * c; t[0] = l * h, t[4] = -u, t[8] = c * h, t[1] = f * u + g, t[5] = a * h, t[9] = d * u - p, t[2] = p * u - d, t[6] = o * h, t[10] = g * u + f; } return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; } /** * Sets the rotation component of this matrix to the rotation specified by * the given Quaternion as outlined [here](https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion) * The rest of the matrix is set to the identity. * * @param {Quaternion} q - The Quaternion. * @return {Matrix4} A reference to this matrix. */ makeRotationFromQuaternion(e) { return this.compose(Dp, e, Ip); } /** * Sets the rotation component of the transformation matrix, looking from `eye` towards * `target`, and oriented by the up-direction. * * @param {Vector3} eye - The eye vector. * @param {Vector3} target - The target vector. * @param {Vector3} up - The up vector. * @return {Matrix4} A reference to this matrix. */ lookAt(e, t, n) { const i = this.elements; return fn.subVectors(e, t), fn.lengthSq() === 0 && (fn.z = 1), fn.normalize(), hi.crossVectors(n, fn), hi.lengthSq() === 0 && (Math.abs(n.z) === 1 ? fn.x += 1e-4 : fn.z += 1e-4, fn.normalize(), hi.crossVectors(n, fn)), hi.normalize(), Cr.crossVectors(fn, hi), i[0] = hi.x, i[4] = Cr.x, i[8] = fn.x, i[1] = hi.y, i[5] = Cr.y, i[9] = fn.y, i[2] = hi.z, i[6] = Cr.z, i[10] = fn.z, this; } /** * Post-multiplies this matrix by the given 4x4 matrix. * * @param {Matrix4} m - The matrix to multiply with. * @return {Matrix4} A reference to this matrix. */ multiply(e) { return this.multiplyMatrices(this, e); } /** * Pre-multiplies this matrix by the given 4x4 matrix. * * @param {Matrix4} m - The matrix to multiply with. * @return {Matrix4} A reference to this matrix. */ premultiply(e) { return this.multiplyMatrices(e, this); } /** * Multiples the given 4x4 matrices and stores the result * in this matrix. * * @param {Matrix4} a - The first matrix. * @param {Matrix4} b - The second matrix. * @return {Matrix4} A reference to this matrix. */ multiplyMatrices(e, t) { const n = e.elements, i = t.elements, r = this.elements, a = n[0], o = n[4], l = n[8], c = n[12], h = n[1], u = n[5], f = n[9], d = n[13], p = n[2], g = n[6], x = n[10], m = n[14], v = n[3], b = n[7], M = n[11], C = n[15], T = i[0], D = i[4], U = i[8], S = i[12], w = i[1], B = i[5], P = i[9], O = i[13], y = i[2], H = i[6], Y = i[10], j = i[14], J = i[3], Z = i[7], ae = i[11], X = i[15]; return r[0] = a * T + o * w + l * y + c * J, r[4] = a * D + o * B + l * H + c * Z, r[8] = a * U + o * P + l * Y + c * ae, r[12] = a * S + o * O + l * j + c * X, r[1] = h * T + u * w + f * y + d * J, r[5] = h * D + u * B + f * H + d * Z, r[9] = h * U + u * P + f * Y + d * ae, r[13] = h * S + u * O + f * j + d * X, r[2] = p * T + g * w + x * y + m * J, r[6] = p * D + g * B + x * H + m * Z, r[10] = p * U + g * P + x * Y + m * ae, r[14] = p * S + g * O + x * j + m * X, r[3] = v * T + b * w + M * y + C * J, r[7] = v * D + b * B + M * H + C * Z, r[11] = v * U + b * P + M * Y + C * ae, r[15] = v * S + b * O + M * j + C * X, this; } /** * Multiplies every component of the matrix by the given scalar. * * @param {number} s - The scalar. * @return {Matrix4} A reference to this matrix. */ 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; } /** * Computes and returns the determinant of this matrix. * * Based on the method outlined [here](http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html). * * @return {number} The determinant. */ determinant() { const e = this.elements, t = e[0], n = e[4], i = e[8], r = e[12], a = e[1], o = e[5], l = e[9], c = e[13], h = e[2], u = e[6], f = e[10], d = e[14], p = e[3], g = e[7], x = e[11], m = e[15]; return p * (+r * l * u - i * c * u - r * o * f + n * c * f + i * o * d - n * l * d) + g * (+t * l * d - t * c * f + r * a * f - i * a * d + i * c * h - r * l * h) + x * (+t * c * u - t * o * d - r * a * u + n * a * d + r * o * h - n * c * h) + m * (-i * o * h - t * l * u + t * o * f + i * a * u - n * a * f + n * l * h); } /** * Transposes this matrix in place. * * @return {Matrix4} A reference to this matrix. */ 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; } /** * Sets the position component for this matrix from the given vector, * without affecting the rest of the matrix. * * @param {number|Vector3} x - The x component of the vector or alternatively the vector object. * @param {number} y - The y component of the vector. * @param {number} z - The z component of the vector. * @return {Matrix4} A reference to this matrix. */ setPosition(e, t, n) { const i = this.elements; return e.isVector3 ? (i[12] = e.x, i[13] = e.y, i[14] = e.z) : (i[12] = e, i[13] = t, i[14] = n), this; } /** * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution). * You can not invert with a determinant of zero. If you attempt this, the method produces * a zero matrix instead. * * @return {Matrix4} A reference to this matrix. */ invert() { const e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8], u = e[9], f = e[10], d = e[11], p = e[12], g = e[13], x = e[14], m = e[15], v = u * x * c - g * f * c + g * l * d - o * x * d - u * l * m + o * f * m, b = p * f * c - h * x * c - p * l * d + a * x * d + h * l * m - a * f * m, M = h * g * c - p * u * c + p * o * d - a * g * d - h * o * m + a * u * m, C = p * u * l - h * g * l - p * o * f + a * g * f + h * o * x - a * u * x, T = t * v + n * b + i * M + r * C; if (T === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); const D = 1 / T; return e[0] = v * D, e[1] = (g * f * r - u * x * r - g * i * d + n * x * d + u * i * m - n * f * m) * D, e[2] = (o * x * r - g * l * r + g * i * c - n * x * c - o * i * m + n * l * m) * D, e[3] = (u * l * r - o * f * r - u * i * c + n * f * c + o * i * d - n * l * d) * D, e[4] = b * D, e[5] = (h * x * r - p * f * r + p * i * d - t * x * d - h * i * m + t * f * m) * D, e[6] = (p * l * r - a * x * r - p * i * c + t * x * c + a * i * m - t * l * m) * D, e[7] = (a * f * r - h * l * r + h * i * c - t * f * c - a * i * d + t * l * d) * D, e[8] = M * D, e[9] = (p * u * r - h * g * r - p * n * d + t * g * d + h * n * m - t * u * m) * D, e[10] = (a * g * r - p * o * r + p * n * c - t * g * c - a * n * m + t * o * m) * D, e[11] = (h * o * r - a * u * r - h * n * c + t * u * c + a * n * d - t * o * d) * D, e[12] = C * D, e[13] = (h * g * i - p * u * i + p * n * f - t * g * f - h * n * x + t * u * x) * D, e[14] = (p * o * i - a * g * i - p * n * l + t * g * l + a * n * x - t * o * x) * D, e[15] = (a * u * i - h * o * i + h * n * l - t * u * l - a * n * f + t * o * f) * D, this; } /** * Multiplies the columns of this matrix by the given vector. * * @param {Vector3} v - The scale vector. * @return {Matrix4} A reference to this matrix. */ scale(e) { const t = this.elements, n = e.x, i = e.y, r = e.z; return t[0] *= n, t[4] *= i, t[8] *= r, t[1] *= n, t[5] *= i, t[9] *= r, t[2] *= n, t[6] *= i, t[10] *= r, t[3] *= n, t[7] *= i, t[11] *= r, this; } /** * Gets the maximum scale value of the three axes. * * @return {number} The maximum scale. */ getMaxScaleOnAxis() { const e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], i = e[8] * e[8] + e[9] * e[9] + e[10] * e[10]; return Math.sqrt(Math.max(t, n, i)); } /** * Sets this matrix as a translation transform from the given vector. * * @param {number|Vector3} x - The amount to translate in the X axis or alternatively a translation vector. * @param {number} y - The amount to translate in the Y axis. * @param {number} z - The amount to translate in the z axis. * @return {Matrix4} A reference to this matrix. */ makeTranslation(e, t, n) { return e.isVector3 ? this.set( 1, 0, 0, e.x, 0, 1, 0, e.y, 0, 0, 1, e.z, 0, 0, 0, 1 ) : this.set( 1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, n, 0, 0, 0, 1 ), this; } /** * Sets this matrix as a rotational transformation around the X axis by * the given angle. * * @param {number} theta - The rotation in radians. * @return {Matrix4} A reference to this matrix. */ makeRotationX(e) { const t = Math.cos(e), n = Math.sin(e); return this.set( 1, 0, 0, 0, 0, t, -n, 0, 0, n, t, 0, 0, 0, 0, 1 ), this; } /** * Sets this matrix as a rotational transformation around the Y axis by * the given angle. * * @param {number} theta - The rotation in radians. * @return {Matrix4} A reference to this matrix. */ makeRotationY(e) { const t = Math.cos(e), n = Math.sin(e); return this.set( t, 0, n, 0, 0, 1, 0, 0, -n, 0, t, 0, 0, 0, 0, 1 ), this; } /** * Sets this matrix as a rotational transformation around the Z axis by * the given angle. * * @param {number} theta - The rotation in radians. * @return {Matrix4} A reference to this matrix. */ makeRotationZ(e) { const t = Math.cos(e), n = Math.sin(e); return this.set( t, -n, 0, 0, n, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ), this; } /** * Sets this matrix as a rotational transformation around the given axis by * the given angle. * * This is a somewhat controversial but mathematically sound alternative to * rotating via Quaternions. See the discussion [here](https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199). * * @param {Vector3} axis - The normalized rotation axis. * @param {number} angle - The rotation in radians. * @return {Matrix4} A reference to this matrix. */ makeRotationAxis(e, t) { const n = Math.cos(t), i = Math.sin(t), r = 1 - n, a = e.x, o = e.y, l = e.z, c = r * a, h = r * o; return this.set( c * a + n, c * o - i * l, c * l + i * o, 0, c * o + i * l, h * o + n, h * l - i * a, 0, c * l - i * o, h * l + i * a, r * l * l + n, 0, 0, 0, 0, 1 ), this; } /** * Sets this matrix as a scale transformation. * * @param {number} x - The amount to scale in the X axis. * @param {number} y - The amount to scale in the Y axis. * @param {number} z - The amount to scale in the Z axis. * @return {Matrix4} A reference to this matrix. */ makeScale(e, t, n) { return this.set( e, 0, 0, 0, 0, t, 0, 0, 0, 0, n, 0, 0, 0, 0, 1 ), this; } /** * Sets this matrix as a shear transformation. * * @param {number} xy - The amount to shear X by Y. * @param {number} xz - The amount to shear X by Z. * @param {number} yx - The amount to shear Y by X. * @param {number} yz - The amount to shear Y by Z. * @param {number} zx - The amount to shear Z by X. * @param {number} zy - The amount to shear Z by Y. * @return {Matrix4} A reference to this matrix. */ makeShear(e, t, n, i, r, a) { return this.set( 1, n, r, 0, e, 1, a, 0, t, i, 1, 0, 0, 0, 0, 1 ), this; } /** * Sets this matrix to the transformation composed of the given position, * rotation (Quaternion) and scale. * * @param {Vector3} position - The position vector. * @param {Quaternion} quaternion - The rotation as a Quaternion. * @param {Vector3} scale - The scale vector. * @return {Matrix4} A reference to this matrix. */ compose(e, t, n) { const i = this.elements, r = t._x, a = t._y, o = t._z, l = t._w, c = r + r, h = a + a, u = o + o, f = r * c, d = r * h, p = r * u, g = a * h, x = a * u, m = o * u, v = l * c, b = l * h, M = l * u, C = n.x, T = n.y, D = n.z; return i[0] = (1 - (g + m)) * C, i[1] = (d + M) * C, i[2] = (p - b) * C, i[3] = 0, i[4] = (d - M) * T, i[5] = (1 - (f + m)) * T, i[6] = (x + v) * T, i[7] = 0, i[8] = (p + b) * D, i[9] = (x - v) * D, i[10] = (1 - (f + g)) * D, i[11] = 0, i[12] = e.x, i[13] = e.y, i[14] = e.z, i[15] = 1, this; } /** * Decomposes this matrix into its position, rotation and scale components * and provides the result in the given objects. * * Note: Not all matrices are decomposable in this way. For example, if an * object has a non-uniformly scaled parent, then the object's world matrix * may not be decomposable, and this method may not be appropriate. * * @param {Vector3} position - The position vector. * @param {Quaternion} quaternion - The rotation as a Quaternion. * @param {Vector3} scale - The scale vector. * @return {Matrix4} A reference to this matrix. */ decompose(e, t, n) { const i = this.elements; let r = qi.set(i[0], i[1], i[2]).length(); const a = qi.set(i[4], i[5], i[6]).length(), o = qi.set(i[8], i[9], i[10]).length(); this.determinant() < 0 && (r = -r), e.x = i[12], e.y = i[13], e.z = i[14], wn.copy(this); const c = 1 / r, h = 1 / a, u = 1 / o; return wn.elements[0] *= c, wn.elements[1] *= c, wn.elements[2] *= c, wn.elements[4] *= h, wn.elements[5] *= h, wn.elements[6] *= h, wn.elements[8] *= u, wn.elements[9] *= u, wn.elements[10] *= u, t.setFromRotationMatrix(wn), n.x = r, n.y = a, n.z = o, this; } /** * Creates a perspective projection matrix. This is used internally by * {@link PerspectiveCamera#updateProjectionMatrix}. * @param {number} left - Left boundary of the viewing frustum at the near plane. * @param {number} right - Right boundary of the viewing frustum at the near plane. * @param {number} top - Top boundary of the viewing frustum at the near plane. * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane. * @param {number} near - The distance from the camera to the near plane. * @param {number} far - The distance from the camera to the far plane. * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system. * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth. * @return {Matrix4} A reference to this matrix. */ makePerspective(e, t, n, i, r, a, o = Vn, l = !1) { const c = this.elements, h = 2 * r / (t - e), u = 2 * r / (n - i), f = (t + e) / (t - e), d = (n + i) / (n - i); let p, g; if (l) p = r / (a - r), g = a * r / (a - r); else if (o === Vn) p = -(a + r) / (a - r), g = -2 * a * r / (a - r); else if (o === _a) p = -a / (a - r), g = -a * r / (a - r); else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o); return c[0] = h, c[4] = 0, c[8] = f, c[12] = 0, c[1] = 0, c[5] = u, c[9] = d, c[13] = 0, c[2] = 0, c[6] = 0, c[10] = p, c[14] = g, c[3] = 0, c[7] = 0, c[11] = -1, c[15] = 0, this; } /** * Creates a orthographic projection matrix. This is used internally by * {@link OrthographicCamera#updateProjectionMatrix}. * @param {number} left - Left boundary of the viewing frustum at the near plane. * @param {number} right - Right boundary of the viewing frustum at the near plane. * @param {number} top - Top boundary of the viewing frustum at the near plane. * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane. * @param {number} near - The distance from the camera to the near plane. * @param {number} far - The distance from the camera to the far plane. * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system. * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth. * @return {Matrix4} A reference to this matrix. */ makeOrthographic(e, t, n, i, r, a, o = Vn, l = !1) { const c = this.elements, h = 2 / (t - e), u = 2 / (n - i), f = -(t + e) / (t - e), d = -(n + i) / (n - i); let p, g; if (l) p = 1 / (a - r), g = a / (a - r); else if (o === Vn) p = -2 / (a - r), g = -(a + r) / (a - r); else if (o === _a) p = -1 / (a - r), g = -r / (a - r); else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o); return c[0] = h, c[4] = 0, c[8] = 0, c[12] = f, c[1] = 0, c[5] = u, c[9] = 0, c[13] = d, c[2] = 0, c[6] = 0, c[10] = p, c[14] = g, c[3] = 0, c[7] = 0, c[11] = 0, c[15] = 1, this; } /** * Returns `true` if this matrix is equal with the given one. * * @param {Matrix4} matrix - The matrix to test for equality. * @return {boolean} Whether this matrix is equal with the given one. */ equals(e) { const t = this.elements, n = e.elements; for (let i = 0; i < 16; i++) if (t[i] !== n[i]) return !1; return !0; } /** * Sets the elements of the matrix from the given array. * * @param {Array} array - The matrix elements in column-major order. * @param {number} [offset=0] - Index of the first element in the array. * @return {Matrix4} A reference to this matrix. */ fromArray(e, t = 0) { for (let n = 0; n < 16; n++) this.elements[n] = e[n + t]; return this; } /** * Writes the elements of this matrix to the given array. If no array is provided, * the method returns a new instance. * * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order. * @param {number} [offset=0] - Index of the first element in the array. * @return {Array} The matrix elements in column-major order. */ toArray(e = [], t = 0) { const n = this.elements; return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e; } } const qi = /* @__PURE__ */ new R(), wn = /* @__PURE__ */ new je(), Dp = /* @__PURE__ */ new R(0, 0, 0), Ip = /* @__PURE__ */ new R(1, 1, 1), hi = /* @__PURE__ */ new R(), Cr = /* @__PURE__ */ new R(), fn = /* @__PURE__ */ new R(), Gc = /* @__PURE__ */ new je(), Wc = /* @__PURE__ */ new Dn(); class cn { /** * Constructs a new euler instance. * * @param {number} [x=0] - The angle of the x axis in radians. * @param {number} [y=0] - The angle of the y axis in radians. * @param {number} [z=0] - The angle of the z axis in radians. * @param {string} [order=Euler.DEFAULT_ORDER] - A string representing the order that the rotations are applied. */ constructor(e = 0, t = 0, n = 0, i = cn.DEFAULT_ORDER) { this.isEuler = !0, this._x = e, this._y = t, this._z = n, this._order = i; } /** * The angle of the x axis in radians. * * @type {number} * @default 0 */ get x() { return this._x; } set x(e) { this._x = e, this._onChangeCallback(); } /** * The angle of the y axis in radians. * * @type {number} * @default 0 */ get y() { return this._y; } set y(e) { this._y = e, this._onChangeCallback(); } /** * The angle of the z axis in radians. * * @type {number} * @default 0 */ get z() { return this._z; } set z(e) { this._z = e, this._onChangeCallback(); } /** * A string representing the order that the rotations are applied. * * @type {string} * @default 'XYZ' */ get order() { return this._order; } set order(e) { this._order = e, this._onChangeCallback(); } /** * Sets the Euler components. * * @param {number} x - The angle of the x axis in radians. * @param {number} y - The angle of the y axis in radians. * @param {number} z - The angle of the z axis in radians. * @param {string} [order] - A string representing the order that the rotations are applied. * @return {Euler} A reference to this Euler instance. */ set(e, t, n, i = this._order) { return this._x = e, this._y = t, this._z = n, this._order = i, this._onChangeCallback(), this; } /** * Returns a new Euler instance with copied values from this instance. * * @return {Euler} A clone of this instance. */ clone() { return new this.constructor(this._x, this._y, this._z, this._order); } /** * Copies the values of the given Euler instance to this instance. * * @param {Euler} euler - The Euler instance to copy. * @return {Euler} A reference to this Euler instance. */ copy(e) { return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this; } /** * Sets the angles of this Euler instance from a pure rotation matrix. * * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled). * @param {string} [order] - A string representing the order that the rotations are applied. * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not. * @return {Euler} A reference to this Euler instance. */ setFromRotationMatrix(e, t = this._order, n = !0) { const i = e.elements, r = i[0], a = i[4], o = i[8], l = i[1], c = i[5], h = i[9], u = i[2], f = i[6], d = i[10]; switch (t) { case "XYZ": this._y = Math.asin(Je(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-h, d), this._z = Math.atan2(-a, r)) : (this._x = Math.atan2(f, c), this._z = 0); break; case "YXZ": this._x = Math.asin(-Je(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._y = Math.atan2(o, d), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-u, r), this._z = 0); break; case "ZXY": this._x = Math.asin(Je(f, -1, 1)), Math.abs(f) < 0.9999999 ? (this._y = Math.atan2(-u, d), this._z = Math.atan2(-a, c)) : (this._y = 0, this._z = Math.atan2(l, r)); break; case "ZYX": this._y = Math.asin(-Je(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._x = Math.atan2(f, d), this._z = Math.atan2(l, r)) : (this._x = 0, this._z = Math.atan2(-a, c)); break; case "YZX": this._z = Math.asin(Je(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(-h, c), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(o, d)); break; case "XZY": this._z = Math.asin(-Je(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(f, c), this._y = Math.atan2(o, r)) : (this._x = Math.atan2(-h, d), this._y = 0); break; default: ze("Euler: .setFromRotationMatrix() encountered an unknown order: " + t); } return this._order = t, n === !0 && this._onChangeCallback(), this; } /** * Sets the angles of this Euler instance from a normalized quaternion. * * @param {Quaternion} q - A normalized Quaternion. * @param {string} [order] - A string representing the order that the rotations are applied. * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not. * @return {Euler} A reference to this Euler instance. */ setFromQuaternion(e, t, n) { return Gc.makeRotationFromQuaternion(e), this.setFromRotationMatrix(Gc, t, n); } /** * Sets the angles of this Euler instance from the given vector. * * @param {Vector3} v - The vector. * @param {string} [order] - A string representing the order that the rotations are applied. * @return {Euler} A reference to this Euler instance. */ setFromVector3(e, t = this._order) { return this.set(e.x, e.y, e.z, t); } /** * Resets the euler angle with a new order by creating a quaternion from this * euler angle and then setting this euler angle with the quaternion and the * new order. * * Warning: This discards revolution information. * * @param {string} [newOrder] - A string representing the new order that the rotations are applied. * @return {Euler} A reference to this Euler instance. */ reorder(e) { return Wc.setFromEuler(this), this.setFromQuaternion(Wc, e); } /** * Returns `true` if this Euler instance is equal with the given one. * * @param {Euler} euler - The Euler instance to test for equality. * @return {boolean} Whether this Euler instance is equal with the given one. */ equals(e) { return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order; } /** * Sets this Euler instance's components to values from the given array. The first three * entries of the array are assign to the x,y and z components. An optional fourth entry * defines the Euler order. * * @param {Array} array - An array holding the Euler component values. * @return {Euler} A reference to this Euler instance. */ 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; } /** * Writes the components of this Euler instance to the given array. If no array is provided, * the method returns a new instance. * * @param {Array} [array=[]] - The target array holding the Euler components. * @param {number} [offset=0] - Index of the first element in the array. * @return {Array} The Euler components. */ 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; } } cn.DEFAULT_ORDER = "XYZ"; class rc { /** * Constructs a new layers instance, with membership * initially set to layer `0`. */ constructor() { this.mask = 1; } /** * Sets membership to the given layer, and remove membership all other layers. * * @param {number} layer - The layer to set. */ set(e) { this.mask = (1 << e | 0) >>> 0; } /** * Adds membership of the given layer. * * @param {number} layer - The layer to enable. */ enable(e) { this.mask |= 1 << e | 0; } /** * Adds membership to all layers. */ enableAll() { this.mask = -1; } /** * Toggles the membership of the given layer. * * @param {number} layer - The layer to toggle. */ toggle(e) { this.mask ^= 1 << e | 0; } /** * Removes membership of the given layer. * * @param {number} layer - The layer to enable. */ disable(e) { this.mask &= ~(1 << e | 0); } /** * Removes the membership from all layers. */ disableAll() { this.mask = 0; } /** * Returns `true` if this and the given layers object have at least one * layer in common. * * @param {Layers} layers - The layers to test. * @return {boolean } Whether this and the given layers object have at least one layer in common or not. */ test(e) { return (this.mask & e.mask) !== 0; } /** * Returns `true` if the given layer is enabled. * * @param {number} layer - The layer to test. * @return {boolean } Whether the given layer is enabled or not. */ isEnabled(e) { return (this.mask & (1 << e | 0)) !== 0; } } let Np = 0; const Xc = /* @__PURE__ */ new R(), Yi = /* @__PURE__ */ new Dn(), Yn = /* @__PURE__ */ new je(), Ar = /* @__PURE__ */ new R(), Us = /* @__PURE__ */ new R(), kp = /* @__PURE__ */ new R(), Up = /* @__PURE__ */ new Dn(), jc = /* @__PURE__ */ new R(1, 0, 0), Zc = /* @__PURE__ */ new R(0, 1, 0), qc = /* @__PURE__ */ new R(0, 0, 1), Yc = { type: "added" }, Bp = { type: "removed" }, Ki = { type: "childadded", child: null }, eo = { type: "childremoved", child: null }; class Mt extends Ui { /** * Constructs a new 3D object. */ constructor() { super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: Np++ }), this.uuid = yn(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = Mt.DEFAULT_UP.clone(); const e = new R(), t = new cn(), n = new Dn(), i = new R(1, 1, 1); function r() { n.setFromEuler(t, !1); } function a() { t.setFromQuaternion(n, void 0, !1); } t._onChange(r), n._onChange(a), Object.defineProperties(this, { /** * Represents the object's local position. * * @name Object3D#position * @type {Vector3} * @default (0,0,0) */ position: { configurable: !0, enumerable: !0, value: e }, /** * Represents the object's local rotation as Euler angles, in radians. * * @name Object3D#rotation * @type {Euler} * @default (0,0,0) */ rotation: { configurable: !0, enumerable: !0, value: t }, /** * Represents the object's local rotation as Quaternions. * * @name Object3D#quaternion * @type {Quaternion} */ quaternion: { configurable: !0, enumerable: !0, value: n }, /** * Represents the object's local scale. * * @name Object3D#scale * @type {Vector3} * @default (1,1,1) */ scale: { configurable: !0, enumerable: !0, value: i }, /** * Represents the object's model-view matrix. * * @name Object3D#modelViewMatrix * @type {Matrix4} */ modelViewMatrix: { value: new je() }, /** * Represents the object's normal matrix. * * @name Object3D#normalMatrix * @type {Matrix3} */ normalMatrix: { value: new $e() } }), this.matrix = new je(), this.matrixWorld = new je(), this.matrixAutoUpdate = Mt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = Mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new rc(), 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 = {}; } /** * A callback that is executed immediately before a 3D object is rendered to a shadow map. * * @param {Renderer|WebGLRenderer} renderer - The renderer. * @param {Object3D} object - The 3D object. * @param {Camera} camera - The camera that is used to render the scene. * @param {Camera} shadowCamera - The shadow camera. * @param {BufferGeometry} geometry - The 3D object's geometry. * @param {Material} depthMaterial - The depth material. * @param {Object} group - The geometry group data. */ onBeforeShadow() { } /** * A callback that is executed immediately after a 3D object is rendered to a shadow map. * * @param {Renderer|WebGLRenderer} renderer - The renderer. * @param {Object3D} object - The 3D object. * @param {Camera} camera - The camera that is used to render the scene. * @param {Camera} shadowCamera - The shadow camera. * @param {BufferGeometry} geometry - The 3D object's geometry. * @param {Material} depthMaterial - The depth material. * @param {Object} group - The geometry group data. */ onAfterShadow() { } /** * A callback that is executed immediately before a 3D object is rendered. * * @param {Renderer|WebGLRenderer} renderer - The renderer. * @param {Object3D} object - The 3D object. * @param {Camera} camera - The camera that is used to render the scene. * @param {BufferGeometry} geometry - The 3D object's geometry. * @param {Material} material - The 3D object's material. * @param {Object} group - The geometry group data. */ onBeforeRender() { } /** * A callback that is executed immediately after a 3D object is rendered. * * @param {Renderer|WebGLRenderer} renderer - The renderer. * @param {Object3D} object - The 3D object. * @param {Camera} camera - The camera that is used to render the scene. * @param {BufferGeometry} geometry - The 3D object's geometry. * @param {Material} material - The 3D object's material. * @param {Object} group - The geometry group data. */ onAfterRender() { } /** * Applies the given transformation matrix to the object and updates the object's position, * rotation and scale. * * @param {Matrix4} matrix - The transformation matrix. */ applyMatrix4(e) { this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale); } /** * Applies a rotation represented by given the quaternion to the 3D object. * * @param {Quaternion} q - The quaternion. * @return {Object3D} A reference to this instance. */ applyQuaternion(e) { return this.quaternion.premultiply(e), this; } /** * Sets the given rotation represented as an axis/angle couple to the 3D object. * * @param {Vector3} axis - The (normalized) axis vector. * @param {number} angle - The angle in radians. */ setRotationFromAxisAngle(e, t) { this.quaternion.setFromAxisAngle(e, t); } /** * Sets the given rotation represented as Euler angles to the 3D object. * * @param {Euler} euler - The Euler angles. */ setRotationFromEuler(e) { this.quaternion.setFromEuler(e, !0); } /** * Sets the given rotation represented as rotation matrix to the 3D object. * * @param {Matrix4} m - Although a 4x4 matrix is expected, the upper 3x3 portion must be * a pure rotation matrix (i.e, unscaled). */ setRotationFromMatrix(e) { this.quaternion.setFromRotationMatrix(e); } /** * Sets the given rotation represented as a Quaternion to the 3D object. * * @param {Quaternion} q - The Quaternion */ setRotationFromQuaternion(e) { this.quaternion.copy(e); } /** * Rotates the 3D object along an axis in local space. * * @param {Vector3} axis - The (normalized) axis vector. * @param {number} angle - The angle in radians. * @return {Object3D} A reference to this instance. */ rotateOnAxis(e, t) { return Yi.setFromAxisAngle(e, t), this.quaternion.multiply(Yi), this; } /** * Rotates the 3D object along an axis in world space. * * @param {Vector3} axis - The (normalized) axis vector. * @param {number} angle - The angle in radians. * @return {Object3D} A reference to this instance. */ rotateOnWorldAxis(e, t) { return Yi.setFromAxisAngle(e, t), this.quaternion.premultiply(Yi), this; } /** * Rotates the 3D object around its X axis in local space. * * @param {number} angle - The angle in radians. * @return {Object3D} A reference to this instance. */ rotateX(e) { return this.rotateOnAxis(jc, e); } /** * Rotates the 3D object around its Y axis in local space. * * @param {number} angle - The angle in radians. * @return {Object3D} A reference to this instance. */ rotateY(e) { return this.rotateOnAxis(Zc, e); } /** * Rotates the 3D object around its Z axis in local space. * * @param {number} angle - The angle in radians. * @return {Object3D} A reference to this instance. */ rotateZ(e) { return this.rotateOnAxis(qc, e); } /** * Translate the 3D object by a distance along the given axis in local space. * * @param {Vector3} axis - The (normalized) axis vector. * @param {number} distance - The distance in world units. * @return {Object3D} A reference to this instance. */ translateOnAxis(e, t) { return Xc.copy(e).applyQuaternion(this.quaternion), this.position.add(Xc.multiplyScalar(t)), this; } /** * Translate the 3D object by a distance along its X-axis in local space. * * @param {number} distance - The distance in world units. * @return {Object3D} A reference to this instance. */ translateX(e) { return this.translateOnAxis(jc, e); } /** * Translate the 3D object by a distance along its Y-axis in local space. * * @param {number} distance - The distance in world units. * @return {Object3D} A reference to this instance. */ translateY(e) { return this.translateOnAxis(Zc, e); } /** * Translate the 3D object by a distance along its Z-axis in local space. * * @param {number} distance - The distance in world units. * @return {Object3D} A reference to this instance. */ translateZ(e) { return this.translateOnAxis(qc, e); } /** * Converts the given vector from this 3D object's local space to world space. * * @param {Vector3} vector - The vector to convert. * @return {Vector3} The converted vector. */ localToWorld(e) { return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld); } /** * Converts the given vector from this 3D object's word space to local space. * * @param {Vector3} vector - The vector to convert. * @return {Vector3} The converted vector. */ worldToLocal(e) { return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Yn.copy(this.matrixWorld).invert()); } /** * Rotates the object to face a point in world space. * * This method does not support objects having non-uniformly-scaled parent(s). * * @param {number|Vector3} x - The x coordinate in world space. Alternatively, a vector representing a position in world space * @param {number} [y] - The y coordinate in world space. * @param {number} [z] - The z coordinate in world space. */ lookAt(e, t, n) { e.isVector3 ? Ar.copy(e) : Ar.set(e, t, n); const i = this.parent; this.updateWorldMatrix(!0, !1), Us.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Yn.lookAt(Us, Ar, this.up) : Yn.lookAt(Ar, Us, this.up), this.quaternion.setFromRotationMatrix(Yn), i && (Yn.extractRotation(i.matrixWorld), Yi.setFromRotationMatrix(Yn), this.quaternion.premultiply(Yi.invert())); } /** * Adds the given 3D object as a child to this 3D object. An arbitrary number of * objects may be added. Any current parent on an object passed in here will be * removed, since an object can have at most one parent. * * @fires Object3D#added * @fires Object3D#childadded * @param {Object3D} object - The 3D object to add. * @return {Object3D} A reference to this instance. */ add(e) { if (arguments.length > 1) { for (let t = 0; t < arguments.length; t++) this.add(arguments[t]); return this; } return e === this ? (et("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(Yc), Ki.child = e, this.dispatchEvent(Ki), Ki.child = null) : et("Object3D.add: object not an instance of THREE.Object3D.", e), this); } /** * Removes the given 3D object as child from this 3D object. * An arbitrary number of objects may be removed. * * @fires Object3D#removed * @fires Object3D#childremoved * @param {Object3D} object - The 3D object to remove. * @return {Object3D} A reference to this instance. */ remove(e) { if (arguments.length > 1) { for (let n = 0; n < arguments.length; n++) this.remove(arguments[n]); return this; } const t = this.children.indexOf(e); return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(Bp), eo.child = e, this.dispatchEvent(eo), eo.child = null), this; } /** * Removes this 3D object from its current parent. * * @fires Object3D#removed * @fires Object3D#childremoved * @return {Object3D} A reference to this instance. */ removeFromParent() { const e = this.parent; return e !== null && e.remove(this), this; } /** * Removes all child objects. * * @fires Object3D#removed * @fires Object3D#childremoved * @return {Object3D} A reference to this instance. */ clear() { return this.remove(...this.children); } /** * Adds the given 3D object as a child of this 3D object, while maintaining the object's world * transform. This method does not support scene graphs having non-uniformly-scaled nodes(s). * * @fires Object3D#added * @fires Object3D#childadded * @param {Object3D} object - The 3D object to attach. * @return {Object3D} A reference to this instance. */ attach(e) { return this.updateWorldMatrix(!0, !1), Yn.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Yn.multiply(e.parent.matrixWorld)), e.applyMatrix4(Yn), e.removeFromParent(), e.parent = this, this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(Yc), Ki.child = e, this.dispatchEvent(Ki), Ki.child = null, this; } /** * Searches through the 3D object and its children, starting with the 3D object * itself, and returns the first with a matching ID. * * @param {number} id - The id. * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found. */ getObjectById(e) { return this.getObjectByProperty("id", e); } /** * Searches through the 3D object and its children, starting with the 3D object * itself, and returns the first with a matching name. * * @param {string} name - The name. * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found. */ getObjectByName(e) { return this.getObjectByProperty("name", e); } /** * Searches through the 3D object and its children, starting with the 3D object * itself, and returns the first with a matching property value. * * @param {string} name - The name of the property. * @param {any} value - The value. * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found. */ getObjectByProperty(e, t) { if (this[e] === t) return this; for (let n = 0, i = this.children.length; n < i; n++) { const a = this.children[n].getObjectByProperty(e, t); if (a !== void 0) return a; } } /** * Searches through the 3D object and its children, starting with the 3D object * itself, and returns all 3D objects with a matching property value. * * @param {string} name - The name of the property. * @param {any} value - The value. * @param {Array} result - The method stores the result in this array. * @return {Array} The found 3D objects. */ getObjectsByProperty(e, t, n = []) { this[e] === t && n.push(this); const i = this.children; for (let r = 0, a = i.length; r < a; r++) i[r].getObjectsByProperty(e, t, n); return n; } /** * Returns a vector representing the position of the 3D object in world space. * * @param {Vector3} target - The target vector the result is stored to. * @return {Vector3} The 3D object's position in world space. */ getWorldPosition(e) { return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld); } /** * Returns a Quaternion representing the position of the 3D object in world space. * * @param {Quaternion} target - The target Quaternion the result is stored to. * @return {Quaternion} The 3D object's rotation in world space. */ getWorldQuaternion(e) { return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Us, e, kp), e; } /** * Returns a vector representing the scale of the 3D object in world space. * * @param {Vector3} target - The target vector the result is stored to. * @return {Vector3} The 3D object's scale in world space. */ getWorldScale(e) { return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Us, Up, e), e; } /** * Returns a vector representing the ("look") direction of the 3D object in world space. * * @param {Vector3} target - The target vector the result is stored to. * @return {Vector3} The 3D object's direction in world space. */ getWorldDirection(e) { this.updateWorldMatrix(!0, !1); const t = this.matrixWorld.elements; return e.set(t[8], t[9], t[10]).normalize(); } /** * Abstract method to get intersections between a casted ray and this * 3D object. Renderable 3D objects such as {@link Mesh}, {@link Line} or {@link Points} * implement this method in order to use raycasting. * * @abstract * @param {Raycaster} raycaster - The raycaster. * @param {Array} intersects - An array holding the result of the method. */ raycast() { } /** * Executes the callback on this 3D object and all descendants. * * Note: Modifying the scene graph inside the callback is discouraged. * * @param {Function} callback - A callback function that allows to process the current 3D object. */ traverse(e) { e(this); const t = this.children; for (let n = 0, i = t.length; n < i; n++) t[n].traverse(e); } /** * Like {@link Object3D#traverse}, but the callback will only be executed for visible 3D objects. * Descendants of invisible 3D objects are not traversed. * * Note: Modifying the scene graph inside the callback is discouraged. * * @param {Function} callback - A callback function that allows to process the current 3D object. */ traverseVisible(e) { if (this.visible === !1) return; e(this); const t = this.children; for (let n = 0, i = t.length; n < i; n++) t[n].traverseVisible(e); } /** * Like {@link Object3D#traverse}, but the callback will only be executed for all ancestors. * * Note: Modifying the scene graph inside the callback is discouraged. * * @param {Function} callback - A callback function that allows to process the current 3D object. */ traverseAncestors(e) { const t = this.parent; t !== null && (e(t), t.traverseAncestors(e)); } /** * Updates the transformation matrix in local space by computing it from the current * position, rotation and scale values. */ updateMatrix() { this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0; } /** * Updates the transformation matrix in world space of this 3D objects and its descendants. * * To ensure correct results, this method also recomputes the 3D object's transformation matrix in * local space. The computation of the local and world matrix can be controlled with the * {@link Object3D#matrixAutoUpdate} and {@link Object3D#matrixWorldAutoUpdate} flags which are both * `true` by default. Set these flags to `false` if you need more control over the update matrix process. * * @param {boolean} [force=false] - When set to `true`, a recomputation of world matrices is forced even * when {@link Object3D#matrixWorldAutoUpdate} is set to `false`. */ updateMatrixWorld(e) { this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, e = !0); const t = this.children; for (let n = 0, i = t.length; n < i; n++) t[n].updateMatrixWorld(e); } /** * An alternative version of {@link Object3D#updateMatrixWorld} with more control over the * update of ancestor and descendant nodes. * * @param {boolean} [updateParents=false] Whether ancestor nodes should be updated or not. * @param {boolean} [updateChildren=false] Whether descendant nodes should be updated or not. */ updateWorldMatrix(e, t) { const n = this.parent; if (e === !0 && n !== null && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), t === !0) { const i = this.children; for (let r = 0, a = i.length; r < a; r++) i[r].updateWorldMatrix(!1, !0); } } /** * Serializes the 3D object into JSON. * * @param {?(Object|string)} meta - An optional value holding meta information about the serialization. * @return {Object} A JSON object representing the serialized 3D object. * @see {@link ObjectLoader#parse} */ toJSON(e) { const t = e === void 0 || typeof e == "string", n = {}; t && (e = { geometries: {}, materials: {}, textures: {}, images: {}, shapes: {}, skeletons: {}, animations: {}, nodes: {} }, n.metadata = { version: 4.7, type: "Object", generator: "Object3D.toJSON" }); const i = {}; i.uuid = this.uuid, i.type = this.type, this.name !== "" && (i.name = this.name), this.castShadow === !0 && (i.castShadow = !0), this.receiveShadow === !0 && (i.receiveShadow = !0), this.visible === !1 && (i.visible = !1), this.frustumCulled === !1 && (i.frustumCulled = !1), this.renderOrder !== 0 && (i.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (i.userData = this.userData), i.layers = this.layers.mask, i.matrix = this.matrix.toArray(), i.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (i.matrixAutoUpdate = !1), this.isInstancedMesh && (i.type = "InstancedMesh", i.count = this.count, i.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (i.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (i.type = "BatchedMesh", i.perObjectFrustumCulled = this.perObjectFrustumCulled, i.sortObjects = this.sortObjects, i.drawRanges = this._drawRanges, i.reservedRanges = this._reservedRanges, i.geometryInfo = this._geometryInfo.map((o) => ({ ...o, boundingBox: o.boundingBox ? o.boundingBox.toJSON() : void 0, boundingSphere: o.boundingSphere ? o.boundingSphere.toJSON() : void 0 })), i.instanceInfo = this._instanceInfo.map((o) => ({ ...o })), i.availableInstanceIds = this._availableInstanceIds.slice(), i.availableGeometryIds = this._availableGeometryIds.slice(), i.nextIndexStart = this._nextIndexStart, i.nextVertexStart = this._nextVertexStart, i.geometryCount = this._geometryCount, i.maxInstanceCount = this._maxInstanceCount, i.maxVertexCount = this._maxVertexCount, i.maxIndexCount = this._maxIndexCount, i.geometryInitialized = this._geometryInitialized, i.matricesTexture = this._matricesTexture.toJSON(e), i.indirectTexture = this._indirectTexture.toJSON(e), this._colorsTexture !== null && (i.colorsTexture = this._colorsTexture.toJSON(e)), this.boundingSphere !== null && (i.boundingSphere = this.boundingSphere.toJSON()), this.boundingBox !== null && (i.boundingBox = this.boundingBox.toJSON())); function r(o, l) { return o[l.uuid] === void 0 && (o[l.uuid] = l.toJSON(e)), l.uuid; } if (this.isScene) this.background && (this.background.isColor ? i.background = this.background.toJSON() : this.background.isTexture && (i.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (i.environment = this.environment.toJSON(e).uuid); else if (this.isMesh || this.isLine || this.isPoints) { i.geometry = r(e.geometries, this.geometry); const o = this.geometry.parameters; if (o !== void 0 && o.shapes !== void 0) { const l = o.shapes; if (Array.isArray(l)) for (let c = 0, h = l.length; c < h; c++) { const u = l[c]; r(e.shapes, u); } else r(e.shapes, l); } } if (this.isSkinnedMesh && (i.bindMode = this.bindMode, i.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(e.skeletons, this.skeleton), i.skeleton = this.skeleton.uuid)), this.material !== void 0) if (Array.isArray(this.material)) { const o = []; for (let l = 0, c = this.material.length; l < c; l++) o.push(r(e.materials, this.material[l])); i.material = o; } else i.material = r(e.materials, this.material); if (this.children.length > 0) { i.children = []; for (let o = 0; o < this.children.length; o++) i.children.push(this.children[o].toJSON(e).object); } if (this.animations.length > 0) { i.animations = []; for (let o = 0; o < this.animations.length; o++) { const l = this.animations[o]; i.animations.push(r(e.animations, l)); } } if (t) { const o = a(e.geometries), l = a(e.materials), c = a(e.textures), h = a(e.images), u = a(e.shapes), f = a(e.skeletons), d = a(e.animations), p = a(e.nodes); o.length > 0 && (n.geometries = o), l.length > 0 && (n.materials = l), c.length > 0 && (n.textures = c), h.length > 0 && (n.images = h), u.length > 0 && (n.shapes = u), f.length > 0 && (n.skeletons = f), d.length > 0 && (n.animations = d), p.length > 0 && (n.nodes = p); } return n.object = i, n; function a(o) { const l = []; for (const c in o) { const h = o[c]; delete h.metadata, l.push(h); } return l; } } /** * Returns a new 3D object with copied values from this instance. * * @param {boolean} [recursive=true] - When set to `true`, descendants of the 3D object are also cloned. * @return {Object3D} A clone of this instance. */ clone(e) { return new this.constructor().copy(this, e); } /** * Copies the values of the given 3D object to this instance. * * @param {Object3D} source - The 3D object to copy. * @param {boolean} [recursive=true] - When set to `true`, descendants of the 3D object are cloned. * @return {Object3D} A reference to this instance. */ copy(e, t = !0) { if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.animations = e.animations.slice(), this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0) for (let n = 0; n < e.children.length; n++) { const i = e.children[n]; this.add(i.clone()); } return this; } } Mt.DEFAULT_UP = /* @__PURE__ */ new R(0, 1, 0); Mt.DEFAULT_MATRIX_AUTO_UPDATE = !0; Mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0; const En = /* @__PURE__ */ new R(), Kn = /* @__PURE__ */ new R(), to = /* @__PURE__ */ new R(), $n = /* @__PURE__ */ new R(), $i = /* @__PURE__ */ new R(), Ji = /* @__PURE__ */ new R(), Kc = /* @__PURE__ */ new R(), no = /* @__PURE__ */ new R(), io = /* @__PURE__ */ new R(), so = /* @__PURE__ */ new R(), ro = /* @__PURE__ */ new at(), ao = /* @__PURE__ */ new at(), oo = /* @__PURE__ */ new at(); class An { /** * Constructs a new triangle. * * @param {Vector3} [a=(0,0,0)] - The first corner of the triangle. * @param {Vector3} [b=(0,0,0)] - The second corner of the triangle. * @param {Vector3} [c=(0,0,0)] - The third corner of the triangle. */ constructor(e = new R(), t = new R(), n = new R()) { this.a = e, this.b = t, this.c = n; } /** * Computes the normal vector of a triangle. * * @param {Vector3} a - The first corner of the triangle. * @param {Vector3} b - The second corner of the triangle. * @param {Vector3} c - The third corner of the triangle. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The triangle's normal. */ static getNormal(e, t, n, i) { i.subVectors(n, t), En.subVectors(e, t), i.cross(En); const r = i.lengthSq(); return r > 0 ? i.multiplyScalar(1 / Math.sqrt(r)) : i.set(0, 0, 0); } /** * Computes a barycentric coordinates from the given vector. * Returns `null` if the triangle is degenerate. * * @param {Vector3} point - A point in 3D space. * @param {Vector3} a - The first corner of the triangle. * @param {Vector3} b - The second corner of the triangle. * @param {Vector3} c - The third corner of the triangle. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The barycentric coordinates for the given point */ static getBarycoord(e, t, n, i, r) { En.subVectors(i, t), Kn.subVectors(n, t), to.subVectors(e, t); const a = En.dot(En), o = En.dot(Kn), l = En.dot(to), c = Kn.dot(Kn), h = Kn.dot(to), u = a * c - o * o; if (u === 0) return r.set(0, 0, 0), null; const f = 1 / u, d = (c * l - o * h) * f, p = (a * h - o * l) * f; return r.set(1 - d - p, p, d); } /** * Returns `true` if the given point, when projected onto the plane of the * triangle, lies within the triangle. * * @param {Vector3} point - The point in 3D space to test. * @param {Vector3} a - The first corner of the triangle. * @param {Vector3} b - The second corner of the triangle. * @param {Vector3} c - The third corner of the triangle. * @return {boolean} Whether the given point, when projected onto the plane of the * triangle, lies within the triangle or not. */ static containsPoint(e, t, n, i) { return this.getBarycoord(e, t, n, i, $n) === null ? !1 : $n.x >= 0 && $n.y >= 0 && $n.x + $n.y <= 1; } /** * Computes the value barycentrically interpolated for the given point on the * triangle. Returns `null` if the triangle is degenerate. * * @param {Vector3} point - Position of interpolated point. * @param {Vector3} p1 - The first corner of the triangle. * @param {Vector3} p2 - The second corner of the triangle. * @param {Vector3} p3 - The third corner of the triangle. * @param {Vector3} v1 - Value to interpolate of first vertex. * @param {Vector3} v2 - Value to interpolate of second vertex. * @param {Vector3} v3 - Value to interpolate of third vertex. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The interpolated value. */ static getInterpolation(e, t, n, i, r, a, o, l) { return this.getBarycoord(e, t, n, i, $n) === null ? (l.x = 0, l.y = 0, "z" in l && (l.z = 0), "w" in l && (l.w = 0), null) : (l.setScalar(0), l.addScaledVector(r, $n.x), l.addScaledVector(a, $n.y), l.addScaledVector(o, $n.z), l); } /** * Computes the value barycentrically interpolated for the given attribute and indices. * * @param {BufferAttribute} attr - The attribute to interpolate. * @param {number} i1 - Index of first vertex. * @param {number} i2 - Index of second vertex. * @param {number} i3 - Index of third vertex. * @param {Vector3} barycoord - The barycoordinate value to use to interpolate. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The interpolated attribute value. */ static getInterpolatedAttribute(e, t, n, i, r, a) { return ro.setScalar(0), ao.setScalar(0), oo.setScalar(0), ro.fromBufferAttribute(e, t), ao.fromBufferAttribute(e, n), oo.fromBufferAttribute(e, i), a.setScalar(0), a.addScaledVector(ro, r.x), a.addScaledVector(ao, r.y), a.addScaledVector(oo, r.z), a; } /** * Returns `true` if the triangle is oriented towards the given direction. * * @param {Vector3} a - The first corner of the triangle. * @param {Vector3} b - The second corner of the triangle. * @param {Vector3} c - The third corner of the triangle. * @param {Vector3} direction - The (normalized) direction vector. * @return {boolean} Whether the triangle is oriented towards the given direction or not. */ static isFrontFacing(e, t, n, i) { return En.subVectors(n, t), Kn.subVectors(e, t), En.cross(Kn).dot(i) < 0; } /** * Sets the triangle's vertices by copying the given values. * * @param {Vector3} a - The first corner of the triangle. * @param {Vector3} b - The second corner of the triangle. * @param {Vector3} c - The third corner of the triangle. * @return {Triangle} A reference to this triangle. */ set(e, t, n) { return this.a.copy(e), this.b.copy(t), this.c.copy(n), this; } /** * Sets the triangle's vertices by copying the given array values. * * @param {Array} points - An array with 3D points. * @param {number} i0 - The array index representing the first corner of the triangle. * @param {number} i1 - The array index representing the second corner of the triangle. * @param {number} i2 - The array index representing the third corner of the triangle. * @return {Triangle} A reference to this triangle. */ setFromPointsAndIndices(e, t, n, i) { return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[i]), this; } /** * Sets the triangle's vertices by copying the given attribute values. * * @param {BufferAttribute} attribute - A buffer attribute with 3D points data. * @param {number} i0 - The attribute index representing the first corner of the triangle. * @param {number} i1 - The attribute index representing the second corner of the triangle. * @param {number} i2 - The attribute index representing the third corner of the triangle. * @return {Triangle} A reference to this triangle. */ setFromAttributeAndIndices(e, t, n, i) { return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, i), this; } /** * Returns a new triangle with copied values from this instance. * * @return {Triangle} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Copies the values of the given triangle to this instance. * * @param {Triangle} triangle - The triangle to copy. * @return {Triangle} A reference to this triangle. */ copy(e) { return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this; } /** * Computes the area of the triangle. * * @return {number} The triangle's area. */ getArea() { return En.subVectors(this.c, this.b), Kn.subVectors(this.a, this.b), En.cross(Kn).length() * 0.5; } /** * Computes the midpoint of the triangle. * * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The triangle's midpoint. */ getMidpoint(e) { return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3); } /** * Computes the normal of the triangle. * * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The triangle's normal. */ getNormal(e) { return An.getNormal(this.a, this.b, this.c, e); } /** * Computes a plane the triangle lies within. * * @param {Plane} target - The target vector that is used to store the method's result. * @return {Plane} The plane the triangle lies within. */ getPlane(e) { return e.setFromCoplanarPoints(this.a, this.b, this.c); } /** * Computes a barycentric coordinates from the given vector. * Returns `null` if the triangle is degenerate. * * @param {Vector3} point - A point in 3D space. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The barycentric coordinates for the given point */ getBarycoord(e, t) { return An.getBarycoord(e, this.a, this.b, this.c, t); } /** * Computes the value barycentrically interpolated for the given point on the * triangle. Returns `null` if the triangle is degenerate. * * @param {Vector3} point - Position of interpolated point. * @param {Vector3} v1 - Value to interpolate of first vertex. * @param {Vector3} v2 - Value to interpolate of second vertex. * @param {Vector3} v3 - Value to interpolate of third vertex. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The interpolated value. */ getInterpolation(e, t, n, i, r) { return An.getInterpolation(e, this.a, this.b, this.c, t, n, i, r); } /** * Returns `true` if the given point, when projected onto the plane of the * triangle, lies within the triangle. * * @param {Vector3} point - The point in 3D space to test. * @return {boolean} Whether the given point, when projected onto the plane of the * triangle, lies within the triangle or not. */ containsPoint(e) { return An.containsPoint(e, this.a, this.b, this.c); } /** * Returns `true` if the triangle is oriented towards the given direction. * * @param {Vector3} direction - The (normalized) direction vector. * @return {boolean} Whether the triangle is oriented towards the given direction or not. */ isFrontFacing(e) { return An.isFrontFacing(this.a, this.b, this.c, e); } /** * Returns `true` if this triangle intersects with the given box. * * @param {Box3} box - The box to intersect. * @return {boolean} Whether this triangle intersects with the given box or not. */ intersectsBox(e) { return e.intersectsTriangle(this); } /** * Returns the closest point on the triangle to the given point. * * @param {Vector3} p - The point to compute the closest point for. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The closest point on the triangle. */ closestPointToPoint(e, t) { const n = this.a, i = this.b, r = this.c; let a, o; $i.subVectors(i, n), Ji.subVectors(r, n), no.subVectors(e, n); const l = $i.dot(no), c = Ji.dot(no); if (l <= 0 && c <= 0) return t.copy(n); io.subVectors(e, i); const h = $i.dot(io), u = Ji.dot(io); if (h >= 0 && u <= h) return t.copy(i); const f = l * u - h * c; if (f <= 0 && l >= 0 && h <= 0) return a = l / (l - h), t.copy(n).addScaledVector($i, a); so.subVectors(e, r); const d = $i.dot(so), p = Ji.dot(so); if (p >= 0 && d <= p) return t.copy(r); const g = d * c - l * p; if (g <= 0 && c >= 0 && p <= 0) return o = c / (c - p), t.copy(n).addScaledVector(Ji, o); const x = h * p - d * u; if (x <= 0 && u - h >= 0 && d - p >= 0) return Kc.subVectors(r, i), o = (u - h) / (u - h + (d - p)), t.copy(i).addScaledVector(Kc, o); const m = 1 / (x + g + f); return a = g * m, o = f * m, t.copy(n).addScaledVector($i, a).addScaledVector(Ji, o); } /** * Returns `true` if this triangle is equal with the given one. * * @param {Triangle} triangle - The triangle to test for equality. * @return {boolean} Whether this triangle is equal with the given one. */ equals(e) { return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c); } } const ed = { 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 }, ui = { h: 0, s: 0, l: 0 }, Pr = { 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 Fe { /** * Constructs a new color. * * Note that standard method of specifying color in three.js is with a hexadecimal triplet, * and that method is used throughout the rest of the documentation. * * @param {(number|string|Color)} [r] - The red component of the color. If `g` and `b` are * not provided, it can be hexadecimal triplet, a CSS-style string or another `Color` instance. * @param {number} [g] - The green component. * @param {number} [b] - The blue component. */ constructor(e, t, n) { return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(e, t, n); } /** * Sets the colors's components from the given values. * * @param {(number|string|Color)} [r] - The red component of the color. If `g` and `b` are * not provided, it can be hexadecimal triplet, a CSS-style string or another `Color` instance. * @param {number} [g] - The green component. * @param {number} [b] - The blue component. * @return {Color} A reference to this color. */ set(e, t, n) { if (t === void 0 && n === void 0) { const i = e; i && i.isColor ? this.copy(i) : typeof i == "number" ? this.setHex(i) : typeof i == "string" && this.setStyle(i); } else this.setRGB(e, t, n); return this; } /** * Sets the colors's components to the given scalar value. * * @param {number} scalar - The scalar value. * @return {Color} A reference to this color. */ setScalar(e) { return this.r = e, this.g = e, this.b = e, this; } /** * Sets this color from a hexadecimal value. * * @param {number} hex - The hexadecimal value. * @param {string} [colorSpace=SRGBColorSpace] - The color space. * @return {Color} A reference to this color. */ setHex(e, t = mt) { return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, it.colorSpaceToWorking(this, t), this; } /** * Sets this color from RGB values. * * @param {number} r - Red channel value between `0.0` and `1.0`. * @param {number} g - Green channel value between `0.0` and `1.0`. * @param {number} b - Blue channel value between `0.0` and `1.0`. * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space. * @return {Color} A reference to this color. */ setRGB(e, t, n, i = it.workingColorSpace) { return this.r = e, this.g = t, this.b = n, it.colorSpaceToWorking(this, i), this; } /** * Sets this color from RGB values. * * @param {number} h - Hue value between `0.0` and `1.0`. * @param {number} s - Saturation value between `0.0` and `1.0`. * @param {number} l - Lightness value between `0.0` and `1.0`. * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space. * @return {Color} A reference to this color. */ setHSL(e, t, n, i = it.workingColorSpace) { if (e = ic(e, 1), t = Je(t, 0, 1), n = Je(n, 0, 1), t === 0) this.r = this.g = this.b = n; else { const r = n <= 0.5 ? n * (1 + t) : n + t - n * t, a = 2 * n - r; this.r = lo(a, r, e + 1 / 3), this.g = lo(a, r, e), this.b = lo(a, r, e - 1 / 3); } return it.colorSpaceToWorking(this, i), this; } /** * Sets this color from a CSS-style string. For example, `rgb(250, 0,0)`, * `rgb(100%, 0%, 0%)`, `hsl(0, 100%, 50%)`, `#ff0000`, `#f00`, or `red` ( or * any [X11 color name](https://en.wikipedia.org/wiki/X11_color_names#Color_name_chart) - * all 140 color names are supported). * * @param {string} style - Color as a CSS-style string. * @param {string} [colorSpace=SRGBColorSpace] - The color space. * @return {Color} A reference to this color. */ setStyle(e, t = mt) { function n(r) { r !== void 0 && parseFloat(r) < 1 && ze("Color: Alpha component of " + e + " will be ignored."); } let i; if (i = /^(\w+)\(([^\)]*)\)/.exec(e)) { let r; const a = i[1], o = i[2]; switch (a) { case "rgb": case "rgba": if (r = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(r[4]), this.setRGB( Math.min(255, parseInt(r[1], 10)) / 255, Math.min(255, parseInt(r[2], 10)) / 255, Math.min(255, parseInt(r[3], 10)) / 255, t ); if (r = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(r[4]), this.setRGB( Math.min(100, parseInt(r[1], 10)) / 100, Math.min(100, parseInt(r[2], 10)) / 100, Math.min(100, parseInt(r[3], 10)) / 100, t ); break; case "hsl": case "hsla": if (r = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(r[4]), this.setHSL( parseFloat(r[1]) / 360, parseFloat(r[2]) / 100, parseFloat(r[3]) / 100, t ); break; default: ze("Color: Unknown color model " + e); } } else if (i = /^\#([A-Fa-f\d]+)$/.exec(e)) { const r = i[1], a = r.length; if (a === 3) return this.setRGB( parseInt(r.charAt(0), 16) / 15, parseInt(r.charAt(1), 16) / 15, parseInt(r.charAt(2), 16) / 15, t ); if (a === 6) return this.setHex(parseInt(r, 16), t); ze("Color: Invalid hex color " + e); } else if (e && e.length > 0) return this.setColorName(e, t); return this; } /** * Sets this color from a color name. Faster than {@link Color#setStyle} if * you don't need the other CSS-style formats. * * For convenience, the list of names is exposed in `Color.NAMES` as a hash. * ```js * Color.NAMES.aliceblue // returns 0xF0F8FF * ``` * * @param {string} style - The color name. * @param {string} [colorSpace=SRGBColorSpace] - The color space. * @return {Color} A reference to this color. */ setColorName(e, t = mt) { const n = ed[e.toLowerCase()]; return n !== void 0 ? this.setHex(n, t) : ze("Color: Unknown color " + e), this; } /** * Returns a new color with copied values from this instance. * * @return {Color} A clone of this instance. */ clone() { return new this.constructor(this.r, this.g, this.b); } /** * Copies the values of the given color to this instance. * * @param {Color} color - The color to copy. * @return {Color} A reference to this color. */ copy(e) { return this.r = e.r, this.g = e.g, this.b = e.b, this; } /** * Copies the given color into this color, and then converts this color from * `SRGBColorSpace` to `LinearSRGBColorSpace`. * * @param {Color} color - The color to copy/convert. * @return {Color} A reference to this color. */ copySRGBToLinear(e) { return this.r = ii(e.r), this.g = ii(e.g), this.b = ii(e.b), this; } /** * Copies the given color into this color, and then converts this color from * `LinearSRGBColorSpace` to `SRGBColorSpace`. * * @param {Color} color - The color to copy/convert. * @return {Color} A reference to this color. */ copyLinearToSRGB(e) { return this.r = hs(e.r), this.g = hs(e.g), this.b = hs(e.b), this; } /** * Converts this color from `SRGBColorSpace` to `LinearSRGBColorSpace`. * * @return {Color} A reference to this color. */ convertSRGBToLinear() { return this.copySRGBToLinear(this), this; } /** * Converts this color from `LinearSRGBColorSpace` to `SRGBColorSpace`. * * @return {Color} A reference to this color. */ convertLinearToSRGB() { return this.copyLinearToSRGB(this), this; } /** * Returns the hexadecimal value of this color. * * @param {string} [colorSpace=SRGBColorSpace] - The color space. * @return {number} The hexadecimal value. */ getHex(e = mt) { return it.workingToColorSpace(Xt.copy(this), e), Math.round(Je(Xt.r * 255, 0, 255)) * 65536 + Math.round(Je(Xt.g * 255, 0, 255)) * 256 + Math.round(Je(Xt.b * 255, 0, 255)); } /** * Returns the hexadecimal value of this color as a string (for example, 'FFFFFF'). * * @param {string} [colorSpace=SRGBColorSpace] - The color space. * @return {string} The hexadecimal value as a string. */ getHexString(e = mt) { return ("000000" + this.getHex(e).toString(16)).slice(-6); } /** * Converts the colors RGB values into the HSL format and stores them into the * given target object. * * @param {{h:number,s:number,l:number}} target - The target object that is used to store the method's result. * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space. * @return {{h:number,s:number,l:number}} The HSL representation of this color. */ getHSL(e, t = it.workingColorSpace) { it.workingToColorSpace(Xt.copy(this), t); const n = Xt.r, i = Xt.g, r = Xt.b, a = Math.max(n, i, r), o = Math.min(n, i, r); let l, c; const h = (o + a) / 2; if (o === a) l = 0, c = 0; else { const u = a - o; switch (c = h <= 0.5 ? u / (a + o) : u / (2 - a - o), a) { case n: l = (i - r) / u + (i < r ? 6 : 0); break; case i: l = (r - n) / u + 2; break; case r: l = (n - i) / u + 4; break; } l /= 6; } return e.h = l, e.s = c, e.l = h, e; } /** * Returns the RGB values of this color and stores them into the given target object. * * @param {Color} target - The target color that is used to store the method's result. * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space. * @return {Color} The RGB representation of this color. */ getRGB(e, t = it.workingColorSpace) { return it.workingToColorSpace(Xt.copy(this), t), e.r = Xt.r, e.g = Xt.g, e.b = Xt.b, e; } /** * Returns the value of this color as a CSS style string. Example: `rgb(255,0,0)`. * * @param {string} [colorSpace=SRGBColorSpace] - The color space. * @return {string} The CSS representation of this color. */ getStyle(e = mt) { it.workingToColorSpace(Xt.copy(this), e); const t = Xt.r, n = Xt.g, i = Xt.b; return e !== mt ? `color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})` : `rgb(${Math.round(t * 255)},${Math.round(n * 255)},${Math.round(i * 255)})`; } /** * Adds the given HSL values to this color's values. * Internally, this converts the color's RGB values to HSL, adds HSL * and then converts the color back to RGB. * * @param {number} h - Hue value between `0.0` and `1.0`. * @param {number} s - Saturation value between `0.0` and `1.0`. * @param {number} l - Lightness value between `0.0` and `1.0`. * @return {Color} A reference to this color. */ offsetHSL(e, t, n) { return this.getHSL(ui), this.setHSL(ui.h + e, ui.s + t, ui.l + n); } /** * Adds the RGB values of the given color to the RGB values of this color. * * @param {Color} color - The color to add. * @return {Color} A reference to this color. */ add(e) { return this.r += e.r, this.g += e.g, this.b += e.b, this; } /** * Adds the RGB values of the given colors and stores the result in this instance. * * @param {Color} color1 - The first color. * @param {Color} color2 - The second color. * @return {Color} A reference to this color. */ addColors(e, t) { return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this; } /** * Adds the given scalar value to the RGB values of this color. * * @param {number} s - The scalar to add. * @return {Color} A reference to this color. */ addScalar(e) { return this.r += e, this.g += e, this.b += e, this; } /** * Subtracts the RGB values of the given color from the RGB values of this color. * * @param {Color} color - The color to subtract. * @return {Color} A reference to this color. */ 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; } /** * Multiplies the RGB values of the given color with the RGB values of this color. * * @param {Color} color - The color to multiply. * @return {Color} A reference to this color. */ multiply(e) { return this.r *= e.r, this.g *= e.g, this.b *= e.b, this; } /** * Multiplies the given scalar value with the RGB values of this color. * * @param {number} s - The scalar to multiply. * @return {Color} A reference to this color. */ multiplyScalar(e) { return this.r *= e, this.g *= e, this.b *= e, this; } /** * Linearly interpolates this color's RGB values toward the RGB values of the * given color. The alpha argument can be thought of as the ratio between * the two colors, where `0.0` is this color and `1.0` is the first argument. * * @param {Color} color - The color to converge on. * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`. * @return {Color} A reference to this color. */ 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; } /** * Linearly interpolates between the given colors and stores the result in this instance. * The alpha argument can be thought of as the ratio between the two colors, where `0.0` * is the first and `1.0` is the second color. * * @param {Color} color1 - The first color. * @param {Color} color2 - The second color. * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`. * @return {Color} A reference to this color. */ lerpColors(e, t, n) { return this.r = e.r + (t.r - e.r) * n, this.g = e.g + (t.g - e.g) * n, this.b = e.b + (t.b - e.b) * n, this; } /** * Linearly interpolates this color's HSL values toward the HSL values of the * given color. It differs from {@link Color#lerp} by not interpolating straight * from one color to the other, but instead going through all the hues in between * those two colors. The alpha argument can be thought of as the ratio between * the two colors, where 0.0 is this color and 1.0 is the first argument. * * @param {Color} color - The color to converge on. * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`. * @return {Color} A reference to this color. */ lerpHSL(e, t) { this.getHSL(ui), e.getHSL(Pr); const n = $s(ui.h, Pr.h, t), i = $s(ui.s, Pr.s, t), r = $s(ui.l, Pr.l, t); return this.setHSL(n, i, r), this; } /** * Sets the color's RGB components from the given 3D vector. * * @param {Vector3} v - The vector to set. * @return {Color} A reference to this color. */ setFromVector3(e) { return this.r = e.x, this.g = e.y, this.b = e.z, this; } /** * Transforms this color with the given 3x3 matrix. * * @param {Matrix3} m - The matrix. * @return {Color} A reference to this color. */ applyMatrix3(e) { const t = this.r, n = this.g, i = this.b, r = e.elements; return this.r = r[0] * t + r[3] * n + r[6] * i, this.g = r[1] * t + r[4] * n + r[7] * i, this.b = r[2] * t + r[5] * n + r[8] * i, this; } /** * Returns `true` if this color is equal with the given one. * * @param {Color} c - The color to test for equality. * @return {boolean} Whether this bounding color is equal with the given one. */ equals(e) { return e.r === this.r && e.g === this.g && e.b === this.b; } /** * Sets this color's RGB components from the given array. * * @param {Array} array - An array holding the RGB values. * @param {number} [offset=0] - The offset into the array. * @return {Color} A reference to this color. */ fromArray(e, t = 0) { return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this; } /** * Writes the RGB components of this color to the given array. If no array is provided, * the method returns a new instance. * * @param {Array} [array=[]] - The target array holding the color components. * @param {number} [offset=0] - Index of the first element in the array. * @return {Array} The color components. */ toArray(e = [], t = 0) { return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e; } /** * Sets the components of this color from the given buffer attribute. * * @param {BufferAttribute} attribute - The buffer attribute holding color data. * @param {number} index - The index into the attribute. * @return {Color} A reference to this color. */ fromBufferAttribute(e, t) { return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), this; } /** * This methods defines the serialization result of this class. Returns the color * as a hexadecimal value. * * @return {number} The hexadecimal value. */ toJSON() { return this.getHex(); } *[Symbol.iterator]() { yield this.r, yield this.g, yield this.b; } } const Xt = /* @__PURE__ */ new Fe(); Fe.NAMES = ed; let Op = 0; class mn extends Ui { /** * Constructs a new material. */ constructor() { super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: Op++ }), this.uuid = yn(), this.name = "", this.type = "Material", this.blending = cs, this.side = Rn, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = zo, this.blendDst = Ho, this.blendEquation = Tn, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new Fe(0, 0, 0), this.blendAlpha = 0, this.depthFunc = fs, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = Al, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = Gi, this.stencilZFail = Gi, this.stencilZPass = Gi, 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; } /** * Sets the alpha value to be used when running an alpha test. The material * will not be rendered if the opacity is lower than this value. * * @type {number} * @readonly * @default 0 */ get alphaTest() { return this._alphaTest; } set alphaTest(e) { this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e; } /** * An optional callback that is executed immediately before the material is used to render a 3D object. * * This method can only be used when rendering with {@link WebGLRenderer}. * * @param {WebGLRenderer} renderer - The renderer. * @param {Scene} scene - The scene. * @param {Camera} camera - The camera that is used to render the scene. * @param {BufferGeometry} geometry - The 3D object's geometry. * @param {Object3D} object - The 3D object. * @param {Object} group - The geometry group data. */ onBeforeRender() { } /** * An optional callback that is executed immediately before the shader * program is compiled. This function is called with the shader source code * as a parameter. Useful for the modification of built-in materials. * * This method can only be used when rendering with {@link WebGLRenderer}. The * recommended approach when customizing materials is to use `WebGPURenderer` with the new * Node Material system and [TSL](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language). * * @param {{vertexShader:string,fragmentShader:string,uniforms:Object}} shaderobject - The object holds the uniforms and the vertex and fragment shader source. * @param {WebGLRenderer} renderer - A reference to the renderer. */ onBeforeCompile() { } /** * In case {@link Material#onBeforeCompile} is used, this callback can be used to identify * values of settings used in `onBeforeCompile()`, so three.js can reuse a cached * shader or recompile the shader for this material as needed. * * This method can only be used when rendering with {@link WebGLRenderer}. * * @return {string} The custom program cache key. */ customProgramCacheKey() { return this.onBeforeCompile.toString(); } /** * This method can be used to set default values from parameter objects. * It is a generic implementation so it can be used with different types * of materials. * * @param {Object} [values] - The material values to set. */ setValues(e) { if (e !== void 0) for (const t in e) { const n = e[t]; if (n === void 0) { ze(`Material: parameter '${t}' has value of undefined.`); continue; } const i = this[t]; if (i === void 0) { ze(`Material: '${t}' is not a property of THREE.${this.type}.`); continue; } i && i.isColor ? i.set(n) : i && i.isVector3 && n && n.isVector3 ? i.copy(n) : this[t] = n; } } /** * Serializes the material into JSON. * * @param {?(Object|string)} meta - An optional value holding meta information about the serialization. * @return {Object} A JSON object representing the serialized material. * @see {@link ObjectLoader#parse} */ toJSON(e) { const t = e === void 0 || typeof e == "string"; t && (e = { textures: {}, images: {} }); const n = { metadata: { version: 4.7, type: "Material", generator: "Material.toJSON" } }; n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.color && this.color.isColor && (n.color = this.color.getHex()), this.roughness !== void 0 && (n.roughness = this.roughness), this.metalness !== void 0 && (n.metalness = this.metalness), this.sheen !== void 0 && (n.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (n.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (n.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (n.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (n.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (n.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (n.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (n.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (n.shininess = this.shininess), this.clearcoat !== void 0 && (n.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (n.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (n.clearcoatMap = this.clearcoatMap.toJSON(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.sheenColorMap && this.sheenColorMap.isTexture && (n.sheenColorMap = this.sheenColorMap.toJSON(e).uuid), this.sheenRoughnessMap && this.sheenRoughnessMap.isTexture && (n.sheenRoughnessMap = this.sheenRoughnessMap.toJSON(e).uuid), this.dispersion !== void 0 && (n.dispersion = this.dispersion), this.iridescence !== void 0 && (n.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (n.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (n.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (n.iridescenceMap = this.iridescenceMap.toJSON(e).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (n.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid), this.anisotropy !== void 0 && (n.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (n.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (n.anisotropyMap = this.anisotropyMap.toJSON(e).uuid), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), this.envMapRotation !== void 0 && (n.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (n.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (n.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (n.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (n.gradientMap = this.gradientMap.toJSON(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (n.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (n.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (n.size = this.size), this.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== cs && (n.blending = this.blending), this.side !== Rn && (n.side = this.side), this.vertexColors === !0 && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.transparent === !0 && (n.transparent = !0), this.blendSrc !== zo && (n.blendSrc = this.blendSrc), this.blendDst !== Ho && (n.blendDst = this.blendDst), this.blendEquation !== Tn && (n.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (n.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (n.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (n.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (n.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (n.blendAlpha = this.blendAlpha), this.depthFunc !== fs && (n.depthFunc = this.depthFunc), this.depthTest === !1 && (n.depthTest = this.depthTest), this.depthWrite === !1 && (n.depthWrite = this.depthWrite), this.colorWrite === !1 && (n.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (n.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== Al && (n.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (n.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (n.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== Gi && (n.stencilFail = this.stencilFail), this.stencilZFail !== Gi && (n.stencilZFail = this.stencilZFail), this.stencilZPass !== Gi && (n.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (n.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (n.linewidth = this.linewidth), this.dashSize !== void 0 && (n.dashSize = this.dashSize), this.gapSize !== void 0 && (n.gapSize = this.gapSize), this.scale !== void 0 && (n.scale = this.scale), this.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaHash === !0 && (n.alphaHash = !0), this.alphaToCoverage === !0 && (n.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = !0), this.forceSinglePass === !0 && (n.forceSinglePass = !0), this.wireframe === !0 && (n.wireframe = !0), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = !0), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), this.fog === !1 && (n.fog = !1), Object.keys(this.userData).length > 0 && (n.userData = this.userData); function i(r) { const a = []; for (const o in r) { const l = r[o]; delete l.metadata, a.push(l); } return a; } if (t) { const r = i(e.textures), a = i(e.images); r.length > 0 && (n.textures = r), a.length > 0 && (n.images = a); } return n; } /** * Returns a new material with copied values from this instance. * * @return {Material} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Copies the values of the given material to this instance. * * @param {Material} source - The material to copy. * @return {Material} A reference to this instance. */ copy(e) { this.name = e.name, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.blendColor.copy(e.blendColor), this.blendAlpha = e.blendAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite; const t = e.clippingPlanes; let n = null; if (t !== null) { const i = t.length; n = new Array(i); for (let r = 0; r !== i; ++r) n[r] = t[r].clone(); } return this.clippingPlanes = n, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaHash = e.alphaHash, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.forceSinglePass = e.forceSinglePass, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this; } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. * * @fires Material#dispose */ dispose() { this.dispatchEvent({ type: "dispose" }); } /** * Setting this property to `true` indicates the engine the material * needs to be recompiled. * * @type {boolean} * @default false * @param {boolean} value */ set needsUpdate(e) { e === !0 && this.version++; } } class Nt extends mn { /** * Constructs a new mesh basic material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new Fe(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new cn(), this.combine = Ca, this.reflectivity = 1, this.refractionRatio = 0.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 Lt = /* @__PURE__ */ new R(), Rr = /* @__PURE__ */ new ue(); let Fp = 0; class gt { /** * Constructs a new buffer attribute. * * @param {TypedArray} array - The array holding the attribute data. * @param {number} itemSize - The item size. * @param {boolean} [normalized=false] - Whether the data are normalized or not. */ constructor(e, t, n = !1) { if (Array.isArray(e)) throw new TypeError("THREE.BufferAttribute: array should be a Typed Array."); this.isBufferAttribute = !0, Object.defineProperty(this, "id", { value: Fp++ }), this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = n, this.usage = Pl, this.updateRanges = [], this.gpuType = Pn, this.version = 0; } /** * A callback function that is executed after the renderer has transferred the attribute * array data to the GPU. */ onUploadCallback() { } /** * Flag to indicate that this attribute has changed and should be re-sent to * the GPU. Set this to `true` when you modify the value of the array. * * @type {number} * @default false * @param {boolean} value */ set needsUpdate(e) { e === !0 && this.version++; } /** * Sets the usage of this buffer attribute. * * @param {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)} value - The usage to set. * @return {BufferAttribute} A reference to this buffer attribute. */ setUsage(e) { return this.usage = e, this; } /** * Adds a range of data in the data array to be updated on the GPU. * * @param {number} start - Position at which to start update. * @param {number} count - The number of components to update. */ addUpdateRange(e, t) { this.updateRanges.push({ start: e, count: t }); } /** * Clears the update ranges. */ clearUpdateRanges() { this.updateRanges.length = 0; } /** * Copies the values of the given buffer attribute to this instance. * * @param {BufferAttribute} source - The buffer attribute to copy. * @return {BufferAttribute} A reference to this instance. */ 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; } /** * Copies a vector from the given buffer attribute to this one. The start * and destination position in the attribute buffers are represented by the * given indices. * * @param {number} index1 - The destination index into this buffer attribute. * @param {BufferAttribute} attribute - The buffer attribute to copy from. * @param {number} index2 - The source index into the given buffer attribute. * @return {BufferAttribute} A reference to this instance. */ copyAt(e, t, n) { e *= this.itemSize, n *= t.itemSize; for (let i = 0, r = this.itemSize; i < r; i++) this.array[e + i] = t.array[n + i]; return this; } /** * Copies the given array data into this buffer attribute. * * @param {(TypedArray|Array)} array - The array to copy. * @return {BufferAttribute} A reference to this instance. */ copyArray(e) { return this.array.set(e), this; } /** * Applies the given 3x3 matrix to the given attribute. Works with * item size `2` and `3`. * * @param {Matrix3} m - The matrix to apply. * @return {BufferAttribute} A reference to this instance. */ applyMatrix3(e) { if (this.itemSize === 2) for (let t = 0, n = this.count; t < n; t++) Rr.fromBufferAttribute(this, t), Rr.applyMatrix3(e), this.setXY(t, Rr.x, Rr.y); else if (this.itemSize === 3) for (let t = 0, n = this.count; t < n; t++) Lt.fromBufferAttribute(this, t), Lt.applyMatrix3(e), this.setXYZ(t, Lt.x, Lt.y, Lt.z); return this; } /** * Applies the given 4x4 matrix to the given attribute. Only works with * item size `3`. * * @param {Matrix4} m - The matrix to apply. * @return {BufferAttribute} A reference to this instance. */ applyMatrix4(e) { for (let t = 0, n = this.count; t < n; t++) Lt.fromBufferAttribute(this, t), Lt.applyMatrix4(e), this.setXYZ(t, Lt.x, Lt.y, Lt.z); return this; } /** * Applies the given 3x3 normal matrix to the given attribute. Only works with * item size `3`. * * @param {Matrix3} m - The normal matrix to apply. * @return {BufferAttribute} A reference to this instance. */ applyNormalMatrix(e) { for (let t = 0, n = this.count; t < n; t++) Lt.fromBufferAttribute(this, t), Lt.applyNormalMatrix(e), this.setXYZ(t, Lt.x, Lt.y, Lt.z); return this; } /** * Applies the given 4x4 matrix to the given attribute. Only works with * item size `3` and with direction vectors. * * @param {Matrix4} m - The matrix to apply. * @return {BufferAttribute} A reference to this instance. */ transformDirection(e) { for (let t = 0, n = this.count; t < n; t++) Lt.fromBufferAttribute(this, t), Lt.transformDirection(e), this.setXYZ(t, Lt.x, Lt.y, Lt.z); return this; } /** * Sets the given array data in the buffer attribute. * * @param {(TypedArray|Array)} value - The array data to set. * @param {number} [offset=0] - The offset in this buffer attribute's array. * @return {BufferAttribute} A reference to this instance. */ set(e, t = 0) { return this.array.set(e, t), this; } /** * Returns the given component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} component - The component index. * @return {number} The returned value. */ getComponent(e, t) { let n = this.array[e * this.itemSize + t]; return this.normalized && (n = Cn(n, this.array)), n; } /** * Sets the given value to the given component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} component - The component index. * @param {number} value - The value to set. * @return {BufferAttribute} A reference to this instance. */ setComponent(e, t, n) { return this.normalized && (n = lt(n, this.array)), this.array[e * this.itemSize + t] = n, this; } /** * Returns the x component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @return {number} The x component. */ getX(e) { let t = this.array[e * this.itemSize]; return this.normalized && (t = Cn(t, this.array)), t; } /** * Sets the x component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} x - The value to set. * @return {BufferAttribute} A reference to this instance. */ setX(e, t) { return this.normalized && (t = lt(t, this.array)), this.array[e * this.itemSize] = t, this; } /** * Returns the y component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @return {number} The y component. */ getY(e) { let t = this.array[e * this.itemSize + 1]; return this.normalized && (t = Cn(t, this.array)), t; } /** * Sets the y component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} y - The value to set. * @return {BufferAttribute} A reference to this instance. */ setY(e, t) { return this.normalized && (t = lt(t, this.array)), this.array[e * this.itemSize + 1] = t, this; } /** * Returns the z component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @return {number} The z component. */ getZ(e) { let t = this.array[e * this.itemSize + 2]; return this.normalized && (t = Cn(t, this.array)), t; } /** * Sets the z component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} z - The value to set. * @return {BufferAttribute} A reference to this instance. */ setZ(e, t) { return this.normalized && (t = lt(t, this.array)), this.array[e * this.itemSize + 2] = t, this; } /** * Returns the w component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @return {number} The w component. */ getW(e) { let t = this.array[e * this.itemSize + 3]; return this.normalized && (t = Cn(t, this.array)), t; } /** * Sets the w component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} w - The value to set. * @return {BufferAttribute} A reference to this instance. */ setW(e, t) { return this.normalized && (t = lt(t, this.array)), this.array[e * this.itemSize + 3] = t, this; } /** * Sets the x and y component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} x - The value for the x component to set. * @param {number} y - The value for the y component to set. * @return {BufferAttribute} A reference to this instance. */ setXY(e, t, n) { return e *= this.itemSize, this.normalized && (t = lt(t, this.array), n = lt(n, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this; } /** * Sets the x, y and z component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} x - The value for the x component to set. * @param {number} y - The value for the y component to set. * @param {number} z - The value for the z component to set. * @return {BufferAttribute} A reference to this instance. */ setXYZ(e, t, n, i) { return e *= this.itemSize, this.normalized && (t = lt(t, this.array), n = lt(n, this.array), i = lt(i, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = i, this; } /** * Sets the x, y, z and w component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} x - The value for the x component to set. * @param {number} y - The value for the y component to set. * @param {number} z - The value for the z component to set. * @param {number} w - The value for the w component to set. * @return {BufferAttribute} A reference to this instance. */ setXYZW(e, t, n, i, r) { return e *= this.itemSize, this.normalized && (t = lt(t, this.array), n = lt(n, this.array), i = lt(i, this.array), r = lt(r, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = i, this.array[e + 3] = r, this; } /** * Sets the given callback function that is executed after the Renderer has transferred * the attribute array data to the GPU. Can be used to perform clean-up operations after * the upload when attribute data are not needed anymore on the CPU side. * * @param {Function} callback - The `onUpload()` callback. * @return {BufferAttribute} A reference to this instance. */ onUpload(e) { return this.onUploadCallback = e, this; } /** * Returns a new buffer attribute with copied values from this instance. * * @return {BufferAttribute} A clone of this instance. */ clone() { return new this.constructor(this.array, this.itemSize).copy(this); } /** * Serializes the buffer attribute into JSON. * * @return {Object} A JSON object representing the serialized buffer attribute. */ 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 !== Pl && (e.usage = this.usage), e; } } class td extends gt { /** * Constructs a new buffer attribute. * * @param {(Array|Uint16Array)} array - The array holding the attribute data. * @param {number} itemSize - The item size. * @param {boolean} [normalized=false] - Whether the data are normalized or not. */ constructor(e, t, n) { super(new Uint16Array(e), t, n); } } class nd extends gt { /** * Constructs a new buffer attribute. * * @param {(Array|Uint32Array)} array - The array holding the attribute data. * @param {number} itemSize - The item size. * @param {boolean} [normalized=false] - Whether the data are normalized or not. */ constructor(e, t, n) { super(new Uint32Array(e), t, n); } } class an extends gt { /** * Constructs a new buffer attribute. * * @param {(Array|Float32Array)} array - The array holding the attribute data. * @param {number} itemSize - The item size. * @param {boolean} [normalized=false] - Whether the data are normalized or not. */ constructor(e, t, n) { super(new Float32Array(e), t, n); } } let zp = 0; const xn = /* @__PURE__ */ new je(), co = /* @__PURE__ */ new Mt(), Qi = /* @__PURE__ */ new R(), pn = /* @__PURE__ */ new zt(), Bs = /* @__PURE__ */ new zt(), Bt = /* @__PURE__ */ new R(); class xt extends Ui { /** * Constructs a new geometry. */ constructor() { super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: zp++ }), this.uuid = yn(), 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 = {}; } /** * Returns the index of this geometry. * * @return {?BufferAttribute} The index. Returns `null` if no index is defined. */ getIndex() { return this.index; } /** * Sets the given index to this geometry. * * @param {Array|BufferAttribute} index - The index to set. * @return {BufferGeometry} A reference to this instance. */ setIndex(e) { return Array.isArray(e) ? this.index = new (Ju(e) ? nd : td)(e, 1) : this.index = e, this; } /** * Sets the given indirect attribute to this geometry. * * @param {BufferAttribute} indirect - The attribute holding indirect draw calls. * @return {BufferGeometry} A reference to this instance. */ setIndirect(e) { return this.indirect = e, this; } /** * Returns the indirect attribute of this geometry. * * @return {?BufferAttribute} The indirect attribute. Returns `null` if no indirect attribute is defined. */ getIndirect() { return this.indirect; } /** * Returns the buffer attribute for the given name. * * @param {string} name - The attribute name. * @return {BufferAttribute|InterleavedBufferAttribute|undefined} The buffer attribute. * Returns `undefined` if not attribute has been found. */ getAttribute(e) { return this.attributes[e]; } /** * Sets the given attribute for the given name. * * @param {string} name - The attribute name. * @param {BufferAttribute|InterleavedBufferAttribute} attribute - The attribute to set. * @return {BufferGeometry} A reference to this instance. */ setAttribute(e, t) { return this.attributes[e] = t, this; } /** * Deletes the attribute for the given name. * * @param {string} name - The attribute name to delete. * @return {BufferGeometry} A reference to this instance. */ deleteAttribute(e) { return delete this.attributes[e], this; } /** * Returns `true` if this geometry has an attribute for the given name. * * @param {string} name - The attribute name. * @return {boolean} Whether this geometry has an attribute for the given name or not. */ hasAttribute(e) { return this.attributes[e] !== void 0; } /** * Adds a group to this geometry. * * @param {number} start - The first element in this draw call. That is the first * vertex for non-indexed geometry, otherwise the first triangle index. * @param {number} count - Specifies how many vertices (or indices) are part of this group. * @param {number} [materialIndex=0] - The material array index to use. */ addGroup(e, t, n = 0) { this.groups.push({ start: e, count: t, materialIndex: n }); } /** * Clears all groups. */ clearGroups() { this.groups = []; } /** * Sets the draw range for this geometry. * * @param {number} start - The first vertex for non-indexed geometry, otherwise the first triangle index. * @param {number} count - For non-indexed BufferGeometry, `count` is the number of vertices to render. * For indexed BufferGeometry, `count` is the number of indices to render. */ setDrawRange(e, t) { this.drawRange.start = e, this.drawRange.count = t; } /** * Applies the given 4x4 transformation matrix to the geometry. * * @param {Matrix4} matrix - The matrix to apply. * @return {BufferGeometry} A reference to this instance. */ applyMatrix4(e) { const t = this.attributes.position; t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0); const n = this.attributes.normal; if (n !== void 0) { const r = new $e().getNormalMatrix(e); n.applyNormalMatrix(r), n.needsUpdate = !0; } const i = this.attributes.tangent; return i !== void 0 && (i.transformDirection(e), i.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this; } /** * Applies the rotation represented by the Quaternion to the geometry. * * @param {Quaternion} q - The Quaternion to apply. * @return {BufferGeometry} A reference to this instance. */ applyQuaternion(e) { return xn.makeRotationFromQuaternion(e), this.applyMatrix4(xn), this; } /** * Rotates the geometry about the X axis. This is typically done as a one time * operation, and not during a loop. Use {@link Object3D#rotation} for typical * real-time mesh rotation. * * @param {number} angle - The angle in radians. * @return {BufferGeometry} A reference to this instance. */ rotateX(e) { return xn.makeRotationX(e), this.applyMatrix4(xn), this; } /** * Rotates the geometry about the Y axis. This is typically done as a one time * operation, and not during a loop. Use {@link Object3D#rotation} for typical * real-time mesh rotation. * * @param {number} angle - The angle in radians. * @return {BufferGeometry} A reference to this instance. */ rotateY(e) { return xn.makeRotationY(e), this.applyMatrix4(xn), this; } /** * Rotates the geometry about the Z axis. This is typically done as a one time * operation, and not during a loop. Use {@link Object3D#rotation} for typical * real-time mesh rotation. * * @param {number} angle - The angle in radians. * @return {BufferGeometry} A reference to this instance. */ rotateZ(e) { return xn.makeRotationZ(e), this.applyMatrix4(xn), this; } /** * Translates the geometry. This is typically done as a one time * operation, and not during a loop. Use {@link Object3D#position} for typical * real-time mesh rotation. * * @param {number} x - The x offset. * @param {number} y - The y offset. * @param {number} z - The z offset. * @return {BufferGeometry} A reference to this instance. */ translate(e, t, n) { return xn.makeTranslation(e, t, n), this.applyMatrix4(xn), this; } /** * Scales the geometry. This is typically done as a one time * operation, and not during a loop. Use {@link Object3D#scale} for typical * real-time mesh rotation. * * @param {number} x - The x scale. * @param {number} y - The y scale. * @param {number} z - The z scale. * @return {BufferGeometry} A reference to this instance. */ scale(e, t, n) { return xn.makeScale(e, t, n), this.applyMatrix4(xn), this; } /** * Rotates the geometry to face a point in 3D space. This is typically done as a one time * operation, and not during a loop. Use {@link Object3D#lookAt} for typical * real-time mesh rotation. * * @param {Vector3} vector - The target point. * @return {BufferGeometry} A reference to this instance. */ lookAt(e) { return co.lookAt(e), co.updateMatrix(), this.applyMatrix4(co.matrix), this; } /** * Center the geometry based on its bounding box. * * @return {BufferGeometry} A reference to this instance. */ center() { return this.computeBoundingBox(), this.boundingBox.getCenter(Qi).negate(), this.translate(Qi.x, Qi.y, Qi.z), this; } /** * Defines a geometry by creating a `position` attribute based on the given array of points. The array * can hold 2D or 3D vectors. When using two-dimensional data, the `z` coordinate for all vertices is * set to `0`. * * If the method is used with an existing `position` attribute, the vertex data are overwritten with the * data from the array. The length of the array must match the vertex count. * * @param {Array|Array} points - The points. * @return {BufferGeometry} A reference to this instance. */ setFromPoints(e) { const t = this.getAttribute("position"); if (t === void 0) { const n = []; for (let i = 0, r = e.length; i < r; i++) { const a = e[i]; n.push(a.x, a.y, a.z || 0); } this.setAttribute("position", new an(n, 3)); } else { const n = Math.min(e.length, t.count); for (let i = 0; i < n; i++) { const r = e[i]; t.setXYZ(i, r.x, r.y, r.z || 0); } e.length > t.count && ze("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."), t.needsUpdate = !0; } return this; } /** * Computes the bounding box of the geometry, and updates the `boundingBox` member. * The bounding box is not computed by the engine; it must be computed by your app. * You may need to recompute the bounding box if the geometry vertices are modified. */ computeBoundingBox() { this.boundingBox === null && (this.boundingBox = new zt()); const e = this.attributes.position, t = this.morphAttributes.position; if (e && e.isGLBufferAttribute) { et("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set( new R(-1 / 0, -1 / 0, -1 / 0), new R(1 / 0, 1 / 0, 1 / 0) ); return; } if (e !== void 0) { if (this.boundingBox.setFromBufferAttribute(e), t) for (let n = 0, i = t.length; n < i; n++) { const r = t[n]; pn.setFromBufferAttribute(r), this.morphTargetsRelative ? (Bt.addVectors(this.boundingBox.min, pn.min), this.boundingBox.expandByPoint(Bt), Bt.addVectors(this.boundingBox.max, pn.max), this.boundingBox.expandByPoint(Bt)) : (this.boundingBox.expandByPoint(pn.min), this.boundingBox.expandByPoint(pn.max)); } } else this.boundingBox.makeEmpty(); (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && et('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this); } /** * Computes the bounding sphere of the geometry, and updates the `boundingSphere` member. * The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling. * You may need to recompute the bounding sphere if the geometry vertices are modified. */ computeBoundingSphere() { this.boundingSphere === null && (this.boundingSphere = new Xn()); const e = this.attributes.position, t = this.morphAttributes.position; if (e && e.isGLBufferAttribute) { et("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new R(), 1 / 0); return; } if (e) { const n = this.boundingSphere.center; if (pn.setFromBufferAttribute(e), t) for (let r = 0, a = t.length; r < a; r++) { const o = t[r]; Bs.setFromBufferAttribute(o), this.morphTargetsRelative ? (Bt.addVectors(pn.min, Bs.min), pn.expandByPoint(Bt), Bt.addVectors(pn.max, Bs.max), pn.expandByPoint(Bt)) : (pn.expandByPoint(Bs.min), pn.expandByPoint(Bs.max)); } pn.getCenter(n); let i = 0; for (let r = 0, a = e.count; r < a; r++) Bt.fromBufferAttribute(e, r), i = Math.max(i, n.distanceToSquared(Bt)); if (t) for (let r = 0, a = t.length; r < a; r++) { const o = t[r], l = this.morphTargetsRelative; for (let c = 0, h = o.count; c < h; c++) Bt.fromBufferAttribute(o, c), l && (Qi.fromBufferAttribute(e, c), Bt.add(Qi)), i = Math.max(i, n.distanceToSquared(Bt)); } this.boundingSphere.radius = Math.sqrt(i), isNaN(this.boundingSphere.radius) && et('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this); } } /** * Calculates and adds a tangent attribute to this geometry. * * The computation is only supported for indexed geometries and if position, normal, and uv attributes * are defined. When using a tangent space normal map, prefer the MikkTSpace algorithm provided by * {@link BufferGeometryUtils#computeMikkTSpaceTangents} instead. */ computeTangents() { const e = this.index, t = this.attributes; if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) { et("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)"); return; } const n = t.position, i = t.normal, r = t.uv; this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new gt(new Float32Array(4 * n.count), 4)); const a = this.getAttribute("tangent"), o = [], l = []; for (let U = 0; U < n.count; U++) o[U] = new R(), l[U] = new R(); const c = new R(), h = new R(), u = new R(), f = new ue(), d = new ue(), p = new ue(), g = new R(), x = new R(); function m(U, S, w) { c.fromBufferAttribute(n, U), h.fromBufferAttribute(n, S), u.fromBufferAttribute(n, w), f.fromBufferAttribute(r, U), d.fromBufferAttribute(r, S), p.fromBufferAttribute(r, w), h.sub(c), u.sub(c), d.sub(f), p.sub(f); const B = 1 / (d.x * p.y - p.x * d.y); isFinite(B) && (g.copy(h).multiplyScalar(p.y).addScaledVector(u, -d.y).multiplyScalar(B), x.copy(u).multiplyScalar(d.x).addScaledVector(h, -p.x).multiplyScalar(B), o[U].add(g), o[S].add(g), o[w].add(g), l[U].add(x), l[S].add(x), l[w].add(x)); } let v = this.groups; v.length === 0 && (v = [{ start: 0, count: e.count }]); for (let U = 0, S = v.length; U < S; ++U) { const w = v[U], B = w.start, P = w.count; for (let O = B, y = B + P; O < y; O += 3) m( e.getX(O + 0), e.getX(O + 1), e.getX(O + 2) ); } const b = new R(), M = new R(), C = new R(), T = new R(); function D(U) { C.fromBufferAttribute(i, U), T.copy(C); const S = o[U]; b.copy(S), b.sub(C.multiplyScalar(C.dot(S))).normalize(), M.crossVectors(T, S); const B = M.dot(l[U]) < 0 ? -1 : 1; a.setXYZW(U, b.x, b.y, b.z, B); } for (let U = 0, S = v.length; U < S; ++U) { const w = v[U], B = w.start, P = w.count; for (let O = B, y = B + P; O < y; O += 3) D(e.getX(O + 0)), D(e.getX(O + 1)), D(e.getX(O + 2)); } } /** * Computes vertex normals for the given vertex data. For indexed geometries, the method sets * each vertex normal to be the average of the face normals of the faces that share that vertex. * For non-indexed geometries, vertices are not shared, and the method sets each vertex normal * to be the same as the face normal. */ computeVertexNormals() { const e = this.index, t = this.getAttribute("position"); if (t !== void 0) { let n = this.getAttribute("normal"); if (n === void 0) n = new gt(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n); else for (let f = 0, d = n.count; f < d; f++) n.setXYZ(f, 0, 0, 0); const i = new R(), r = new R(), a = new R(), o = new R(), l = new R(), c = new R(), h = new R(), u = new R(); if (e) for (let f = 0, d = e.count; f < d; f += 3) { const p = e.getX(f + 0), g = e.getX(f + 1), x = e.getX(f + 2); i.fromBufferAttribute(t, p), r.fromBufferAttribute(t, g), a.fromBufferAttribute(t, x), h.subVectors(a, r), u.subVectors(i, r), h.cross(u), o.fromBufferAttribute(n, p), l.fromBufferAttribute(n, g), c.fromBufferAttribute(n, x), o.add(h), l.add(h), c.add(h), n.setXYZ(p, o.x, o.y, o.z), n.setXYZ(g, l.x, l.y, l.z), n.setXYZ(x, c.x, c.y, c.z); } else for (let f = 0, d = t.count; f < d; f += 3) i.fromBufferAttribute(t, f + 0), r.fromBufferAttribute(t, f + 1), a.fromBufferAttribute(t, f + 2), h.subVectors(a, r), u.subVectors(i, r), h.cross(u), n.setXYZ(f + 0, h.x, h.y, h.z), n.setXYZ(f + 1, h.x, h.y, h.z), n.setXYZ(f + 2, h.x, h.y, h.z); this.normalizeNormals(), n.needsUpdate = !0; } } /** * Ensures every normal vector in a geometry will have a magnitude of `1`. This will * correct lighting on the geometry surfaces. */ normalizeNormals() { const e = this.attributes.normal; for (let t = 0, n = e.count; t < n; t++) Bt.fromBufferAttribute(e, t), Bt.normalize(), e.setXYZ(t, Bt.x, Bt.y, Bt.z); } /** * Return a new non-index version of this indexed geometry. If the geometry * is already non-indexed, the method is a NOOP. * * @return {BufferGeometry} The non-indexed version of this indexed geometry. */ toNonIndexed() { function e(o, l) { const c = o.array, h = o.itemSize, u = o.normalized, f = new c.constructor(l.length * h); let d = 0, p = 0; for (let g = 0, x = l.length; g < x; g++) { o.isInterleavedBufferAttribute ? d = l[g] * o.data.stride + o.offset : d = l[g] * h; for (let m = 0; m < h; m++) f[p++] = c[d++]; } return new gt(f, h, u); } if (this.index === null) return ze("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this; const t = new xt(), n = this.index.array, i = this.attributes; for (const o in i) { const l = i[o], c = e(l, n); t.setAttribute(o, c); } const r = this.morphAttributes; for (const o in r) { const l = [], c = r[o]; for (let h = 0, u = c.length; h < u; h++) { const f = c[h], d = e(f, n); l.push(d); } 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; } /** * Serializes the geometry into JSON. * * @return {Object} A JSON object representing the serialized geometry. */ toJSON() { const e = { metadata: { version: 4.7, type: "BufferGeometry", generator: "BufferGeometry.toJSON" } }; if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) { const l = this.parameters; for (const c in l) l[c] !== void 0 && (e[c] = l[c]); return e; } e.data = { attributes: {} }; const t = this.index; t !== null && (e.data.index = { type: t.array.constructor.name, array: Array.prototype.slice.call(t.array) }); const n = this.attributes; for (const l in n) { const c = n[l]; e.data.attributes[l] = c.toJSON(e.data); } const i = {}; let r = !1; for (const l in this.morphAttributes) { const c = this.morphAttributes[l], h = []; for (let u = 0, f = c.length; u < f; u++) { const d = c[u]; h.push(d.toJSON(e.data)); } h.length > 0 && (i[l] = h, r = !0); } r && (e.data.morphAttributes = i, e.data.morphTargetsRelative = this.morphTargetsRelative); const a = this.groups; a.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(a))); const o = this.boundingSphere; return o !== null && (e.data.boundingSphere = o.toJSON()), e; } /** * Returns a new geometry with copied values from this instance. * * @return {BufferGeometry} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Copies the values of the given geometry to this instance. * * @param {BufferGeometry} source - The geometry to copy. * @return {BufferGeometry} A reference to this instance. */ copy(e) { this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null; const t = {}; this.name = e.name; const n = e.index; n !== null && this.setIndex(n.clone()); const i = e.attributes; for (const c in i) { const h = i[c]; this.setAttribute(c, h.clone(t)); } const r = e.morphAttributes; for (const c in r) { const h = [], u = r[c]; for (let f = 0, d = u.length; f < d; f++) h.push(u[f].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; } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. * * @fires BufferGeometry#dispose */ dispose() { this.dispatchEvent({ type: "dispose" }); } } const $c = /* @__PURE__ */ new je(), yi = /* @__PURE__ */ new Ts(), Lr = /* @__PURE__ */ new Xn(), Jc = /* @__PURE__ */ new R(), Dr = /* @__PURE__ */ new R(), Ir = /* @__PURE__ */ new R(), Nr = /* @__PURE__ */ new R(), ho = /* @__PURE__ */ new R(), kr = /* @__PURE__ */ new R(), Qc = /* @__PURE__ */ new R(), Ur = /* @__PURE__ */ new R(); class ft extends Mt { /** * Constructs a new mesh. * * @param {BufferGeometry} [geometry] - The mesh geometry. * @param {Material|Array} [material] - The mesh material. */ constructor(e = new xt(), t = new Nt()) { 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; } /** * Sets the values of {@link Mesh#morphTargetDictionary} and {@link Mesh#morphTargetInfluences} * to make sure existing morph targets can influence this 3D object. */ updateMorphTargets() { const t = this.geometry.morphAttributes, n = Object.keys(t); if (n.length > 0) { const i = t[n[0]]; if (i !== void 0) { this.morphTargetInfluences = [], this.morphTargetDictionary = {}; for (let r = 0, a = i.length; r < a; r++) { const o = i[r].name || String(r); this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r; } } } } /** * Returns the local-space position of the vertex at the given index, taking into * account the current animation state of both morph targets and skinning. * * @param {number} index - The vertex index. * @param {Vector3} target - The target object that is used to store the method's result. * @return {Vector3} The vertex position in local space. */ getVertexPosition(e, t) { const n = this.geometry, i = n.attributes.position, r = n.morphAttributes.position, a = n.morphTargetsRelative; t.fromBufferAttribute(i, e); const o = this.morphTargetInfluences; if (r && o) { kr.set(0, 0, 0); for (let l = 0, c = r.length; l < c; l++) { const h = o[l], u = r[l]; h !== 0 && (ho.fromBufferAttribute(u, e), a ? kr.addScaledVector(ho, h) : kr.addScaledVector(ho.sub(t), h)); } t.add(kr); } return t; } /** * Computes intersection points between a casted ray and this line. * * @param {Raycaster} raycaster - The raycaster. * @param {Array} intersects - The target array that holds the intersection points. */ raycast(e, t) { const n = this.geometry, i = this.material, r = this.matrixWorld; i !== void 0 && (n.boundingSphere === null && n.computeBoundingSphere(), Lr.copy(n.boundingSphere), Lr.applyMatrix4(r), yi.copy(e.ray).recast(e.near), !(Lr.containsPoint(yi.origin) === !1 && (yi.intersectSphere(Lr, Jc) === null || yi.origin.distanceToSquared(Jc) > (e.far - e.near) ** 2)) && ($c.copy(r).invert(), yi.copy(e.ray).applyMatrix4($c), !(n.boundingBox !== null && yi.intersectsBox(n.boundingBox) === !1) && this._computeIntersections(e, t, yi))); } _computeIntersections(e, t, n) { let i; const r = this.geometry, a = this.material, o = r.index, l = r.attributes.position, c = r.attributes.uv, h = r.attributes.uv1, u = r.attributes.normal, f = r.groups, d = r.drawRange; if (o !== null) if (Array.isArray(a)) for (let p = 0, g = f.length; p < g; p++) { const x = f[p], m = a[x.materialIndex], v = Math.max(x.start, d.start), b = Math.min(o.count, Math.min(x.start + x.count, d.start + d.count)); for (let M = v, C = b; M < C; M += 3) { const T = o.getX(M), D = o.getX(M + 1), U = o.getX(M + 2); i = Br(this, m, e, n, c, h, u, T, D, U), i && (i.faceIndex = Math.floor(M / 3), i.face.materialIndex = x.materialIndex, t.push(i)); } } else { const p = Math.max(0, d.start), g = Math.min(o.count, d.start + d.count); for (let x = p, m = g; x < m; x += 3) { const v = o.getX(x), b = o.getX(x + 1), M = o.getX(x + 2); i = Br(this, a, e, n, c, h, u, v, b, M), i && (i.faceIndex = Math.floor(x / 3), t.push(i)); } } else if (l !== void 0) if (Array.isArray(a)) for (let p = 0, g = f.length; p < g; p++) { const x = f[p], m = a[x.materialIndex], v = Math.max(x.start, d.start), b = Math.min(l.count, Math.min(x.start + x.count, d.start + d.count)); for (let M = v, C = b; M < C; M += 3) { const T = M, D = M + 1, U = M + 2; i = Br(this, m, e, n, c, h, u, T, D, U), i && (i.faceIndex = Math.floor(M / 3), i.face.materialIndex = x.materialIndex, t.push(i)); } } else { const p = Math.max(0, d.start), g = Math.min(l.count, d.start + d.count); for (let x = p, m = g; x < m; x += 3) { const v = x, b = x + 1, M = x + 2; i = Br(this, a, e, n, c, h, u, v, b, M), i && (i.faceIndex = Math.floor(x / 3), t.push(i)); } } } } function Hp(s, e, t, n, i, r, a, o) { let l; if (e.side === Jt ? l = n.intersectTriangle(a, r, i, !0, o) : l = n.intersectTriangle(i, r, a, e.side === Rn, o), l === null) return null; Ur.copy(o), Ur.applyMatrix4(s.matrixWorld); const c = t.ray.origin.distanceTo(Ur); return c < t.near || c > t.far ? null : { distance: c, point: Ur.clone(), object: s }; } function Br(s, e, t, n, i, r, a, o, l, c) { s.getVertexPosition(o, Dr), s.getVertexPosition(l, Ir), s.getVertexPosition(c, Nr); const h = Hp(s, e, t, n, Dr, Ir, Nr, Qc); if (h) { const u = new R(); An.getBarycoord(Qc, Dr, Ir, Nr, u), i && (h.uv = An.getInterpolatedAttribute(i, o, l, c, u, new ue())), r && (h.uv1 = An.getInterpolatedAttribute(r, o, l, c, u, new ue())), a && (h.normal = An.getInterpolatedAttribute(a, o, l, c, u, new R()), h.normal.dot(n.direction) > 0 && h.normal.multiplyScalar(-1)); const f = { a: o, b: l, c, normal: new R(), materialIndex: 0 }; An.getNormal(Dr, Ir, Nr, f.normal), h.face = f, h.barycoord = u; } return h; } class Li extends xt { /** * Constructs a new box geometry. * * @param {number} [width=1] - The width. That is, the length of the edges parallel to the X axis. * @param {number} [height=1] - The height. That is, the length of the edges parallel to the Y axis. * @param {number} [depth=1] - The depth. That is, the length of the edges parallel to the Z axis. * @param {number} [widthSegments=1] - Number of segmented rectangular faces along the width of the sides. * @param {number} [heightSegments=1] - Number of segmented rectangular faces along the height of the sides. * @param {number} [depthSegments=1] - Number of segmented rectangular faces along the depth of the sides. */ constructor(e = 1, t = 1, n = 1, i = 1, r = 1, a = 1) { super(), this.type = "BoxGeometry", this.parameters = { width: e, height: t, depth: n, widthSegments: i, heightSegments: r, depthSegments: a }; const o = this; i = Math.floor(i), r = Math.floor(r), a = Math.floor(a); const l = [], c = [], h = [], u = []; let f = 0, d = 0; p("z", "y", "x", -1, -1, n, t, e, a, r, 0), p("z", "y", "x", 1, -1, n, t, -e, a, r, 1), p("x", "z", "y", 1, 1, e, n, t, i, a, 2), p("x", "z", "y", 1, -1, e, n, -t, i, a, 3), p("x", "y", "z", 1, -1, e, t, n, i, r, 4), p("x", "y", "z", -1, -1, e, t, -n, i, r, 5), this.setIndex(l), this.setAttribute("position", new an(c, 3)), this.setAttribute("normal", new an(h, 3)), this.setAttribute("uv", new an(u, 2)); function p(g, x, m, v, b, M, C, T, D, U, S) { const w = M / D, B = C / U, P = M / 2, O = C / 2, y = T / 2, H = D + 1, Y = U + 1; let j = 0, J = 0; const Z = new R(); for (let ae = 0; ae < Y; ae++) { const X = ae * B - O; for (let q = 0; q < H; q++) { const ge = q * w - P; Z[g] = ge * v, Z[x] = X * b, Z[m] = y, c.push(Z.x, Z.y, Z.z), Z[g] = 0, Z[x] = 0, Z[m] = T > 0 ? 1 : -1, h.push(Z.x, Z.y, Z.z), u.push(q / D), u.push(1 - ae / U), j += 1; } } for (let ae = 0; ae < U; ae++) for (let X = 0; X < D; X++) { const q = f + X + H * ae, ge = f + X + H * (ae + 1), pe = f + (X + 1) + H * (ae + 1), de = f + (X + 1) + H * ae; l.push(q, ge, de), l.push(ge, pe, de), J += 6; } o.addGroup(d, J, S), d += J, f += j; } } copy(e) { return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; } /** * Factory method for creating an instance of this class from the given * JSON object. * * @param {Object} data - A JSON object representing the serialized geometry. * @return {BoxGeometry} A new instance. */ static fromJSON(e) { return new Li(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments); } } function bs(s) { const e = {}; for (const t in s) { e[t] = {}; for (const n in s[t]) { const i = s[t][n]; i && (i.isColor || i.isMatrix3 || i.isMatrix4 || i.isVector2 || i.isVector3 || i.isVector4 || i.isTexture || i.isQuaternion) ? i.isRenderTargetTexture ? (ze("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), e[t][n] = null) : e[t][n] = i.clone() : Array.isArray(i) ? e[t][n] = i.slice() : e[t][n] = i; } } return e; } function Kt(s) { const e = {}; for (let t = 0; t < s.length; t++) { const n = bs(s[t]); for (const i in n) e[i] = n[i]; } return e; } function Vp(s) { const e = []; for (let t = 0; t < s.length; t++) e.push(s[t].clone()); return e; } function id(s) { const e = s.getRenderTarget(); return e === null ? s.outputColorSpace : e.isXRRenderTarget === !0 ? e.texture.colorSpace : it.workingColorSpace; } const zn = { clone: bs, merge: Kt }; var Gp = `void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`, Wp = `void main() { gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); }`; class Pt extends mn { /** * Constructs a new shader material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = Gp, this.fragmentShader = Wp, 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, // set to use vertex shader clipping multiDraw: !1 // set to use vertex shader multi_draw / enable gl_DrawID }, 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 = bs(e.uniforms), this.uniformsGroups = Vp(e.uniformsGroups), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.fog = e.fog, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this; } toJSON(e) { const t = super.toJSON(e); t.glslVersion = this.glslVersion, t.uniforms = {}; for (const i in this.uniforms) { const a = this.uniforms[i].value; a && a.isTexture ? t.uniforms[i] = { type: "t", value: a.toJSON(e).uuid } : a && a.isColor ? t.uniforms[i] = { type: "c", value: a.getHex() } : a && a.isVector2 ? t.uniforms[i] = { type: "v2", value: a.toArray() } : a && a.isVector3 ? t.uniforms[i] = { type: "v3", value: a.toArray() } : a && a.isVector4 ? t.uniforms[i] = { type: "v4", value: a.toArray() } : a && a.isMatrix3 ? t.uniforms[i] = { type: "m3", value: a.toArray() } : a && a.isMatrix4 ? t.uniforms[i] = { type: "m4", value: a.toArray() } : t.uniforms[i] = { value: a }; } Object.keys(this.defines).length > 0 && (t.defines = this.defines), t.vertexShader = this.vertexShader, t.fragmentShader = this.fragmentShader, t.lights = this.lights, t.clipping = this.clipping; const n = {}; for (const i in this.extensions) this.extensions[i] === !0 && (n[i] = !0); return Object.keys(n).length > 0 && (t.extensions = n), t; } } class sd extends Mt { /** * Constructs a new camera. */ constructor() { super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new je(), this.projectionMatrix = new je(), this.projectionMatrixInverse = new je(), this.coordinateSystem = Vn, this._reversedDepth = !1; } /** * The flag that indicates whether the camera uses a reversed depth buffer. * * @type {boolean} * @default false */ 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; } /** * Returns a vector representing the ("look") direction of the 3D object in world space. * * This method is overwritten since cameras have a different forward vector compared to other * 3D objects. A camera looks down its local, negative z-axis by default. * * @param {Vector3} target - The target vector the result is stored to. * @return {Vector3} The 3D object's direction in world space. */ 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 di = /* @__PURE__ */ new R(), eh = /* @__PURE__ */ new ue(), th = /* @__PURE__ */ new ue(); class jt extends sd { /** * Constructs a new perspective camera. * * @param {number} [fov=50] - The vertical field of view. * @param {number} [aspect=1] - The aspect ratio. * @param {number} [near=0.1] - The camera's near plane. * @param {number} [far=2000] - The camera's far plane. */ constructor(e = 50, t = 1, n = 0.1, i = 2e3) { super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = i, this.focus = 10, this.aspect = t, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix(); } copy(e, t) { return super.copy(e, t), this.fov = e.fov, this.zoom = e.zoom, this.near = e.near, this.far = e.far, this.focus = e.focus, this.aspect = e.aspect, this.view = e.view === null ? null : Object.assign({}, e.view), this.filmGauge = e.filmGauge, this.filmOffset = e.filmOffset, this; } /** * Sets the FOV by focal length in respect to the current {@link PerspectiveCamera#filmGauge}. * * The default film gauge is 35, so that the focal length can be specified for * a 35mm (full frame) camera. * * @param {number} focalLength - Values for focal length and film gauge must have the same unit. */ setFocalLength(e) { const t = 0.5 * this.getFilmHeight() / e; this.fov = vs * 2 * Math.atan(t), this.updateProjectionMatrix(); } /** * Returns the focal length from the current {@link PerspectiveCamera#fov} and * {@link PerspectiveCamera#filmGauge}. * * @return {number} The computed focal length. */ getFocalLength() { const e = Math.tan(Ks * 0.5 * this.fov); return 0.5 * this.getFilmHeight() / e; } /** * Returns the current vertical field of view angle in degrees considering {@link PerspectiveCamera#zoom}. * * @return {number} The effective FOV. */ getEffectiveFOV() { return vs * 2 * Math.atan( Math.tan(Ks * 0.5 * this.fov) / this.zoom ); } /** * Returns the width of the image on the film. If {@link PerspectiveCamera#aspect} is greater than or * equal to one (landscape format), the result equals {@link PerspectiveCamera#filmGauge}. * * @return {number} The film width. */ getFilmWidth() { return this.filmGauge * Math.min(this.aspect, 1); } /** * Returns the height of the image on the film. If {@link PerspectiveCamera#aspect} is greater than or * equal to one (landscape format), the result equals {@link PerspectiveCamera#filmGauge}. * * @return {number} The film width. */ getFilmHeight() { return this.filmGauge / Math.max(this.aspect, 1); } /** * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction. * Sets `minTarget` and `maxTarget` to the coordinates of the lower-left and upper-right corners of the view rectangle. * * @param {number} distance - The viewing distance. * @param {Vector2} minTarget - The lower-left corner of the view rectangle is written into this vector. * @param {Vector2} maxTarget - The upper-right corner of the view rectangle is written into this vector. */ getViewBounds(e, t, n) { di.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), t.set(di.x, di.y).multiplyScalar(-e / di.z), di.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), n.set(di.x, di.y).multiplyScalar(-e / di.z); } /** * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction. * * @param {number} distance - The viewing distance. * @param {Vector2} target - The target vector that is used to store result where x is width and y is height. * @returns {Vector2} The view size. */ getViewSize(e, t) { return this.getViewBounds(e, eh, th), t.subVectors(th, eh); } /** * Sets an offset in a larger frustum. This is useful for multi-window or * multi-monitor/multi-machine setups. * * For example, if you have 3x2 monitors and each monitor is 1920x1080 and * the monitors are in grid like this *``` * +---+---+---+ * | A | B | C | * +---+---+---+ * | D | E | F | * +---+---+---+ *``` * then for each monitor you would call it like this: *```js * const w = 1920; * const h = 1080; * const fullWidth = w * 3; * const fullHeight = h * 2; * * // --A-- * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); * // --B-- * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); * // --C-- * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); * // --D-- * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); * // --E-- * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); * // --F-- * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); * ``` * * Note there is no reason monitors have to be the same size or in a grid. * * @param {number} fullWidth - The full width of multiview setup. * @param {number} fullHeight - The full height of multiview setup. * @param {number} x - The horizontal offset of the subcamera. * @param {number} y - The vertical offset of the subcamera. * @param {number} width - The width of subcamera. * @param {number} height - The height of subcamera. */ setViewOffset(e, t, n, i, r, a) { this.aspect = e / t, this.view === null && (this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = a, this.updateProjectionMatrix(); } /** * Removes the view offset from the projection matrix. */ clearViewOffset() { this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); } /** * Updates the camera's projection matrix. Must be called after any change of * camera properties. */ updateProjectionMatrix() { const e = this.near; let t = e * Math.tan(Ks * 0.5 * this.fov) / this.zoom, n = 2 * t, i = this.aspect * n, r = -0.5 * i; const a = this.view; if (this.view !== null && this.view.enabled) { const l = a.fullWidth, c = a.fullHeight; r += a.offsetX * i / l, t -= a.offsetY * n / c, i *= a.width / l, n *= a.height / c; } const o = this.filmOffset; o !== 0 && (r += e * o / this.getFilmWidth()), this.projectionMatrix.makePerspective(r, r + i, t, t - n, e, this.far, this.coordinateSystem, this.reversedDepth), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); } toJSON(e) { const t = super.toJSON(e); return t.object.fov = this.fov, t.object.zoom = this.zoom, t.object.near = this.near, t.object.far = this.far, t.object.focus = this.focus, t.object.aspect = this.aspect, this.view !== null && (t.object.view = Object.assign({}, this.view)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t; } } const es = -90, ts = 1; class Xp extends Mt { /** * Constructs a new cube camera. * * @param {number} near - The camera's near plane. * @param {number} far - The camera's far plane. * @param {WebGLCubeRenderTarget} renderTarget - The cube render target. */ constructor(e, t, n) { super(), this.type = "CubeCamera", this.renderTarget = n, this.coordinateSystem = null, this.activeMipmapLevel = 0; const i = new jt(es, ts, e, t); i.layers = this.layers, this.add(i); const r = new jt(es, ts, e, t); r.layers = this.layers, this.add(r); const a = new jt(es, ts, e, t); a.layers = this.layers, this.add(a); const o = new jt(es, ts, e, t); o.layers = this.layers, this.add(o); const l = new jt(es, ts, e, t); l.layers = this.layers, this.add(l); const c = new jt(es, ts, e, t); c.layers = this.layers, this.add(c); } /** * Must be called when the coordinate system of the cube camera is changed. */ updateCoordinateSystem() { const e = this.coordinateSystem, t = this.children.concat(), [n, i, r, a, o, l] = t; for (const c of t) this.remove(c); if (e === Vn) n.up.set(0, 1, 0), n.lookAt(1, 0, 0), i.up.set(0, 1, 0), i.lookAt(-1, 0, 0), r.up.set(0, 0, -1), r.lookAt(0, 1, 0), a.up.set(0, 0, 1), a.lookAt(0, -1, 0), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), l.up.set(0, 1, 0), l.lookAt(0, 0, -1); else if (e === _a) n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), i.up.set(0, -1, 0), i.lookAt(1, 0, 0), r.up.set(0, 0, 1), r.lookAt(0, 1, 0), a.up.set(0, 0, -1), a.lookAt(0, -1, 0), o.up.set(0, -1, 0), o.lookAt(0, 0, 1), l.up.set(0, -1, 0), l.lookAt(0, 0, -1); else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e); for (const c of t) this.add(c), c.updateMatrixWorld(); } /** * Calling this method will render the given scene with the given renderer * into the cube render target of the camera. * * @param {(Renderer|WebGLRenderer)} renderer - The renderer. * @param {Scene} scene - The scene to render. */ update(e, t) { this.parent === null && this.updateMatrixWorld(); const { renderTarget: n, activeMipmapLevel: i } = this; this.coordinateSystem !== e.coordinateSystem && (this.coordinateSystem = e.coordinateSystem, this.updateCoordinateSystem()); const [r, a, o, l, c, h] = this.children, u = e.getRenderTarget(), f = e.getActiveCubeFace(), d = e.getActiveMipmapLevel(), p = e.xr.enabled; e.xr.enabled = !1; const g = n.texture.generateMipmaps; n.texture.generateMipmaps = !1, e.setRenderTarget(n, 0, i), e.render(t, r), e.setRenderTarget(n, 1, i), e.render(t, a), e.setRenderTarget(n, 2, i), e.render(t, o), e.setRenderTarget(n, 3, i), e.render(t, l), e.setRenderTarget(n, 4, i), e.render(t, c), n.texture.generateMipmaps = g, e.setRenderTarget(n, 5, i), e.render(t, h), e.setRenderTarget(u, f, d), e.xr.enabled = p, n.texture.needsPMREMUpdate = !0; } } class rd extends Ft { /** * Constructs a new cube texture. * * @param {Array} [images=[]] - An array holding a image for each side of a cube. * @param {number} [mapping=CubeReflectionMapping] - The texture mapping. * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value. * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value. * @param {number} [magFilter=LinearFilter] - The mag filter value. * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value. * @param {number} [format=RGBAFormat] - The texture format. * @param {number} [type=UnsignedByteType] - The texture type. * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value. * @param {string} [colorSpace=NoColorSpace] - The color space value. */ constructor(e = [], t = ps, n, i, r, a, o, l, c, h) { super(e, t, n, i, r, a, o, l, c, h), this.isCubeTexture = !0, this.flipY = !1; } /** * Alias for {@link CubeTexture#image}. * * @type {Array} */ get images() { return this.image; } set images(e) { this.image = e; } } class jp extends rn { /** * Constructs a new cube render target. * * @param {number} [size=1] - The size of the render target. * @param {RenderTarget~Options} [options] - The configuration object. */ constructor(e = 1, t = {}) { super(e, e, t), this.isWebGLCubeRenderTarget = !0; const n = { width: e, height: e, depth: 1 }, i = [n, n, n, n, n, n]; this.texture = new rd(i), this._setTextureOptions(t), this.texture.isRenderTargetTexture = !0; } /** * Converts the given equirectangular texture to a cube map. * * @param {WebGLRenderer} renderer - The renderer. * @param {Texture} texture - The equirectangular texture. * @return {WebGLCubeRenderTarget} A reference to this cube render target. */ fromEquirectangularTexture(e, t) { this.texture.type = t.type, this.texture.colorSpace = t.colorSpace, this.texture.generateMipmaps = t.generateMipmaps, this.texture.minFilter = t.minFilter, this.texture.magFilter = t.magFilter; const n = { uniforms: { tEquirect: { value: null } }, vertexShader: ( /* glsl */ ` 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 #include } ` ), fragmentShader: ( /* glsl */ ` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } ` ) }, i = new Li(5, 5, 5), r = new Pt({ name: "CubemapFromEquirect", uniforms: bs(n.uniforms), vertexShader: n.vertexShader, fragmentShader: n.fragmentShader, side: Jt, blending: Ot }); r.uniforms.tEquirect.value = t; const a = new ft(i, r), o = t.minFilter; return t.minFilter === ti && (t.minFilter = Ht), new Xp(1, 10, this).update(e, a), t.minFilter = o, a.geometry.dispose(), a.material.dispose(), this; } /** * Clears this cube render target. * * @param {WebGLRenderer} renderer - The renderer. * @param {boolean} [color=true] - Whether the color buffer should be cleared or not. * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not. * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not. */ clear(e, t = !0, n = !0, i = !0) { const r = e.getRenderTarget(); for (let a = 0; a < 6; a++) e.setRenderTarget(this, a), e.clear(t, n, i); e.setRenderTarget(r); } } class $t extends Mt { constructor() { super(), this.isGroup = !0, this.type = "Group"; } } const Zp = { type: "move" }; class uo { /** * Constructs a new XR controller. */ constructor() { this._targetRay = null, this._grip = null, this._hand = null; } /** * Returns a group representing the hand space of the XR controller. * * @return {Group} A group representing the hand space of the XR controller. */ getHandSpace() { return this._hand === null && (this._hand = new $t(), this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand; } /** * Returns a group representing the target ray space of the XR controller. * * @return {Group} A group representing the target ray space of the XR controller. */ getTargetRaySpace() { return this._targetRay === null && (this._targetRay = new $t(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new R(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new R()), this._targetRay; } /** * Returns a group representing the grip space of the XR controller. * * @return {Group} A group representing the grip space of the XR controller. */ getGripSpace() { return this._grip === null && (this._grip = new $t(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new R(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new R()), this._grip; } /** * Dispatches the given event to the groups representing * the different coordinate spaces of the XR controller. * * @param {Object} event - The event to dispatch. * @return {WebXRController} A reference to this instance. */ 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; } /** * Connects the controller with the given XR input source. * * @param {XRInputSource} inputSource - The input source. * @return {WebXRController} A reference to this instance. */ connect(e) { if (e && e.hand) { const t = this._hand; if (t) for (const n of e.hand.values()) this._getHandJoint(t, n); } return this.dispatchEvent({ type: "connected", data: e }), this; } /** * Disconnects the controller from the given XR input source. * * @param {XRInputSource} inputSource - The input source. * @return {WebXRController} A reference to this instance. */ 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; } /** * Updates the controller with the given input source, XR frame and reference space. * This updates the transformations of the groups that represent the different * coordinate systems of the controller. * * @param {XRInputSource} inputSource - The input source. * @param {XRFrame} frame - The XR frame. * @param {XRReferenceSpace} referenceSpace - The reference space. * @return {WebXRController} A reference to this instance. */ update(e, t, n) { let i = null, r = null, a = null; const o = this._targetRay, l = this._grip, c = this._hand; if (e && t.session.visibilityState !== "visible-blurred") { if (c && e.hand) { a = !0; for (const g of e.hand.values()) { const x = t.getJointPose(g, n), m = this._getHandJoint(c, g); x !== null && (m.matrix.fromArray(x.transform.matrix), m.matrix.decompose(m.position, m.rotation, m.scale), m.matrixWorldNeedsUpdate = !0, m.jointRadius = x.radius), m.visible = x !== null; } const h = c.joints["index-finger-tip"], u = c.joints["thumb-tip"], f = h.position.distanceTo(u.position), d = 0.02, p = 5e-3; c.inputState.pinching && f > d + p ? (c.inputState.pinching = !1, this.dispatchEvent({ type: "pinchend", handedness: e.handedness, target: this })) : !c.inputState.pinching && f <= d - p && (c.inputState.pinching = !0, this.dispatchEvent({ type: "pinchstart", handedness: e.handedness, target: this })); } else l !== null && e.gripSpace && (r = t.getPose(e.gripSpace, n), r !== null && (l.matrix.fromArray(r.transform.matrix), l.matrix.decompose(l.position, l.rotation, l.scale), l.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (l.hasLinearVelocity = !0, l.linearVelocity.copy(r.linearVelocity)) : l.hasLinearVelocity = !1, r.angularVelocity ? (l.hasAngularVelocity = !0, l.angularVelocity.copy(r.angularVelocity)) : l.hasAngularVelocity = !1)); o !== null && (i = t.getPose(e.targetRaySpace, n), i === null && r !== null && (i = r), i !== null && (o.matrix.fromArray(i.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), o.matrixWorldNeedsUpdate = !0, i.linearVelocity ? (o.hasLinearVelocity = !0, o.linearVelocity.copy(i.linearVelocity)) : o.hasLinearVelocity = !1, i.angularVelocity ? (o.hasAngularVelocity = !0, o.angularVelocity.copy(i.angularVelocity)) : o.hasAngularVelocity = !1, this.dispatchEvent(Zp))); } return o !== null && (o.visible = i !== null), l !== null && (l.visible = r !== null), c !== null && (c.visible = a !== null), this; } /** * Returns a group representing the hand joint for the given input joint. * * @private * @param {Group} hand - The group representing the hand space. * @param {XRJointSpace} inputjoint - The hand joint data. * @return {Group} A group representing the hand joint for the given input joint. */ _getHandJoint(e, t) { if (e.joints[t.jointName] === void 0) { const n = new $t(); n.matrixAutoUpdate = !1, n.visible = !1, e.joints[t.jointName] = n, e.add(n); } return e.joints[t.jointName]; } } class ad extends Mt { /** * Constructs a new scene. */ 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 cn(), this.environmentIntensity = 1, this.environmentRotation = new cn(), 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 od { /** * Constructs a new interleaved buffer. * * @param {TypedArray} array - A typed array with a shared buffer storing attribute data. * @param {number} stride - The number of typed-array elements per vertex. */ constructor(e, t) { this.isInterleavedBuffer = !0, this.array = e, this.stride = t, this.count = e !== void 0 ? e.length / t : 0, this.usage = Pl, this.updateRanges = [], this.version = 0, this.uuid = yn(); } /** * A callback function that is executed after the renderer has transferred the attribute array * data to the GPU. */ onUploadCallback() { } /** * Flag to indicate that this attribute has changed and should be re-sent to * the GPU. Set this to `true` when you modify the value of the array. * * @type {number} * @default false * @param {boolean} value */ set needsUpdate(e) { e === !0 && this.version++; } /** * Sets the usage of this interleaved buffer. * * @param {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)} value - The usage to set. * @return {InterleavedBuffer} A reference to this interleaved buffer. */ setUsage(e) { return this.usage = e, this; } /** * Adds a range of data in the data array to be updated on the GPU. * * @param {number} start - Position at which to start update. * @param {number} count - The number of components to update. */ addUpdateRange(e, t) { this.updateRanges.push({ start: e, count: t }); } /** * Clears the update ranges. */ clearUpdateRanges() { this.updateRanges.length = 0; } /** * Copies the values of the given interleaved buffer to this instance. * * @param {InterleavedBuffer} source - The interleaved buffer to copy. * @return {InterleavedBuffer} A reference to this instance. */ copy(e) { return this.array = new e.array.constructor(e.array), this.count = e.count, this.stride = e.stride, this.usage = e.usage, this; } /** * Copies a vector from the given interleaved buffer to this one. The start * and destination position in the attribute buffers are represented by the * given indices. * * @param {number} index1 - The destination index into this interleaved buffer. * @param {InterleavedBuffer} interleavedBuffer - The interleaved buffer to copy from. * @param {number} index2 - The source index into the given interleaved buffer. * @return {InterleavedBuffer} A reference to this instance. */ copyAt(e, t, n) { e *= this.stride, n *= t.stride; for (let i = 0, r = this.stride; i < r; i++) this.array[e + i] = t.array[n + i]; return this; } /** * Sets the given array data in the interleaved buffer. * * @param {(TypedArray|Array)} value - The array data to set. * @param {number} [offset=0] - The offset in this interleaved buffer's array. * @return {InterleavedBuffer} A reference to this instance. */ set(e, t = 0) { return this.array.set(e, t), this; } /** * Returns a new interleaved buffer with copied values from this instance. * * @param {Object} [data] - An object with shared array buffers that allows to retain shared structures. * @return {InterleavedBuffer} A clone of this instance. */ clone(e) { e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = yn()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer); const t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(t, this.stride); return n.setUsage(this.usage), n; } /** * Sets the given callback function that is executed after the Renderer has transferred * the array data to the GPU. Can be used to perform clean-up operations after * the upload when data are not needed anymore on the CPU side. * * @param {Function} callback - The `onUpload()` callback. * @return {InterleavedBuffer} A reference to this instance. */ onUpload(e) { return this.onUploadCallback = e, this; } /** * Serializes the interleaved buffer into JSON. * * @param {Object} [data] - An optional value holding meta information about the serialization. * @return {Object} A JSON object representing the serialized interleaved buffer. */ toJSON(e) { return e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = yn()), 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 Yt = /* @__PURE__ */ new R(); class Pa { /** * Constructs a new interleaved buffer attribute. * * @param {InterleavedBuffer} interleavedBuffer - The buffer holding the interleaved data. * @param {number} itemSize - The item size. * @param {number} offset - The attribute offset into the buffer. * @param {boolean} [normalized=false] - Whether the data are normalized or not. */ constructor(e, t, n, i = !1) { this.isInterleavedBufferAttribute = !0, this.name = "", this.data = e, this.itemSize = t, this.offset = n, this.normalized = i; } /** * The item count of this buffer attribute. * * @type {number} * @readonly */ get count() { return this.data.count; } /** * The array holding the interleaved buffer attribute data. * * @type {TypedArray} */ get array() { return this.data.array; } /** * Flag to indicate that this attribute has changed and should be re-sent to * the GPU. Set this to `true` when you modify the value of the array. * * @type {number} * @default false * @param {boolean} value */ set needsUpdate(e) { this.data.needsUpdate = e; } /** * Applies the given 4x4 matrix to the given attribute. Only works with * item size `3`. * * @param {Matrix4} m - The matrix to apply. * @return {InterleavedBufferAttribute} A reference to this instance. */ applyMatrix4(e) { for (let t = 0, n = this.data.count; t < n; t++) Yt.fromBufferAttribute(this, t), Yt.applyMatrix4(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z); return this; } /** * Applies the given 3x3 normal matrix to the given attribute. Only works with * item size `3`. * * @param {Matrix3} m - The normal matrix to apply. * @return {InterleavedBufferAttribute} A reference to this instance. */ applyNormalMatrix(e) { for (let t = 0, n = this.count; t < n; t++) Yt.fromBufferAttribute(this, t), Yt.applyNormalMatrix(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z); return this; } /** * Applies the given 4x4 matrix to the given attribute. Only works with * item size `3` and with direction vectors. * * @param {Matrix4} m - The matrix to apply. * @return {InterleavedBufferAttribute} A reference to this instance. */ transformDirection(e) { for (let t = 0, n = this.count; t < n; t++) Yt.fromBufferAttribute(this, t), Yt.transformDirection(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z); return this; } /** * Returns the given component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} component - The component index. * @return {number} The returned value. */ getComponent(e, t) { let n = this.array[e * this.data.stride + this.offset + t]; return this.normalized && (n = Cn(n, this.array)), n; } /** * Sets the given value to the given component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} component - The component index. * @param {number} value - The value to set. * @return {InterleavedBufferAttribute} A reference to this instance. */ setComponent(e, t, n) { return this.normalized && (n = lt(n, this.array)), this.data.array[e * this.data.stride + this.offset + t] = n, this; } /** * Sets the x component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} x - The value to set. * @return {InterleavedBufferAttribute} A reference to this instance. */ setX(e, t) { return this.normalized && (t = lt(t, this.array)), this.data.array[e * this.data.stride + this.offset] = t, this; } /** * Sets the y component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} y - The value to set. * @return {InterleavedBufferAttribute} A reference to this instance. */ setY(e, t) { return this.normalized && (t = lt(t, this.array)), this.data.array[e * this.data.stride + this.offset + 1] = t, this; } /** * Sets the z component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} z - The value to set. * @return {InterleavedBufferAttribute} A reference to this instance. */ setZ(e, t) { return this.normalized && (t = lt(t, this.array)), this.data.array[e * this.data.stride + this.offset + 2] = t, this; } /** * Sets the w component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} w - The value to set. * @return {InterleavedBufferAttribute} A reference to this instance. */ setW(e, t) { return this.normalized && (t = lt(t, this.array)), this.data.array[e * this.data.stride + this.offset + 3] = t, this; } /** * Returns the x component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @return {number} The x component. */ getX(e) { let t = this.data.array[e * this.data.stride + this.offset]; return this.normalized && (t = Cn(t, this.array)), t; } /** * Returns the y component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @return {number} The y component. */ getY(e) { let t = this.data.array[e * this.data.stride + this.offset + 1]; return this.normalized && (t = Cn(t, this.array)), t; } /** * Returns the z component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @return {number} The z component. */ getZ(e) { let t = this.data.array[e * this.data.stride + this.offset + 2]; return this.normalized && (t = Cn(t, this.array)), t; } /** * Returns the w component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @return {number} The w component. */ getW(e) { let t = this.data.array[e * this.data.stride + this.offset + 3]; return this.normalized && (t = Cn(t, this.array)), t; } /** * Sets the x and y component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} x - The value for the x component to set. * @param {number} y - The value for the y component to set. * @return {InterleavedBufferAttribute} A reference to this instance. */ setXY(e, t, n) { return e = e * this.data.stride + this.offset, this.normalized && (t = lt(t, this.array), n = lt(n, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this; } /** * Sets the x, y and z component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} x - The value for the x component to set. * @param {number} y - The value for the y component to set. * @param {number} z - The value for the z component to set. * @return {InterleavedBufferAttribute} A reference to this instance. */ setXYZ(e, t, n, i) { return e = e * this.data.stride + this.offset, this.normalized && (t = lt(t, this.array), n = lt(n, this.array), i = lt(i, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = i, this; } /** * Sets the x, y, z and w component of the vector at the given index. * * @param {number} index - The index into the buffer attribute. * @param {number} x - The value for the x component to set. * @param {number} y - The value for the y component to set. * @param {number} z - The value for the z component to set. * @param {number} w - The value for the w component to set. * @return {InterleavedBufferAttribute} A reference to this instance. */ setXYZW(e, t, n, i, r) { return e = e * this.data.stride + this.offset, this.normalized && (t = lt(t, this.array), n = lt(n, this.array), i = lt(i, this.array), r = lt(r, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = i, this.data.array[e + 3] = r, this; } /** * Returns a new buffer attribute with copied values from this instance. * * If no parameter is provided, cloning an interleaved buffer attribute will de-interleave buffer data. * * @param {Object} [data] - An object with interleaved buffers that allows to retain the interleaved property. * @return {BufferAttribute|InterleavedBufferAttribute} A clone of this instance. */ clone(e) { if (e === void 0) { ya("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data."); const t = []; for (let n = 0; n < this.count; n++) { const i = n * this.data.stride + this.offset; for (let r = 0; r < this.itemSize; r++) t.push(this.data.array[i + r]); } return new gt(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 Pa(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized); } /** * Serializes the buffer attribute into JSON. * * If no parameter is provided, cloning an interleaved buffer attribute will de-interleave buffer data. * * @param {Object} [data] - An optional value holding meta information about the serialization. * @return {Object} A JSON object representing the serialized buffer attribute. */ toJSON(e) { if (e === void 0) { ya("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data."); const t = []; for (let n = 0; n < this.count; n++) { const i = n * this.data.stride + this.offset; for (let r = 0; r < this.itemSize; r++) t.push(this.data.array[i + r]); } return { itemSize: this.itemSize, type: this.array.constructor.name, array: t, normalized: this.normalized }; } else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), { isInterleavedBufferAttribute: !0, itemSize: this.itemSize, data: this.data.uuid, offset: this.offset, normalized: this.normalized }; } } const nh = /* @__PURE__ */ new R(), ih = /* @__PURE__ */ new at(), sh = /* @__PURE__ */ new at(), qp = /* @__PURE__ */ new R(), rh = /* @__PURE__ */ new je(), Or = /* @__PURE__ */ new R(), fo = /* @__PURE__ */ new Xn(), ah = /* @__PURE__ */ new je(), po = /* @__PURE__ */ new Ts(); class Yp extends ft { /** * Constructs a new skinned mesh. * * @param {BufferGeometry} [geometry] - The mesh geometry. * @param {Material|Array} [material] - The mesh material. */ constructor(e, t) { super(e, t), this.isSkinnedMesh = !0, this.type = "SkinnedMesh", this.bindMode = Ic, this.bindMatrix = new je(), this.bindMatrixInverse = new je(), this.boundingBox = null, this.boundingSphere = null; } /** * Computes the bounding box of the skinned mesh, and updates {@link SkinnedMesh#boundingBox}. * The bounding box is not automatically computed by the engine; this method must be called by your app. * If the skinned mesh is animated, the bounding box should be recomputed per frame in order to reflect * the current animation state. */ computeBoundingBox() { const e = this.geometry; this.boundingBox === null && (this.boundingBox = new zt()), this.boundingBox.makeEmpty(); const t = e.getAttribute("position"); for (let n = 0; n < t.count; n++) this.getVertexPosition(n, Or), this.boundingBox.expandByPoint(Or); } /** * Computes the bounding sphere of the skinned mesh, and updates {@link SkinnedMesh#boundingSphere}. * The bounding sphere is automatically computed by the engine once when it is needed, e.g., for ray casting * and view frustum culling. If the skinned mesh is animated, the bounding sphere should be recomputed * per frame in order to reflect the current animation state. */ computeBoundingSphere() { const e = this.geometry; this.boundingSphere === null && (this.boundingSphere = new Xn()), this.boundingSphere.makeEmpty(); const t = e.getAttribute("position"); for (let n = 0; n < t.count; n++) this.getVertexPosition(n, Or), this.boundingSphere.expandByPoint(Or); } copy(e, t) { return super.copy(e, t), this.bindMode = e.bindMode, this.bindMatrix.copy(e.bindMatrix), this.bindMatrixInverse.copy(e.bindMatrixInverse), this.skeleton = e.skeleton, e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), this; } raycast(e, t) { const n = this.material, i = this.matrixWorld; n !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), fo.copy(this.boundingSphere), fo.applyMatrix4(i), e.ray.intersectsSphere(fo) !== !1 && (ah.copy(i).invert(), po.copy(e.ray).applyMatrix4(ah), !(this.boundingBox !== null && po.intersectsBox(this.boundingBox) === !1) && this._computeIntersections(e, t, po))); } getVertexPosition(e, t) { return super.getVertexPosition(e, t), this.applyBoneTransform(e, t), t; } /** * Binds the given skeleton to the skinned mesh. * * @param {Skeleton} skeleton - The skeleton to bind. * @param {Matrix4} [bindMatrix] - The bind matrix. If no bind matrix is provided, * the skinned mesh's world matrix will be used instead. */ 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(); } /** * This method sets the skinned mesh in the rest pose). */ pose() { this.skeleton.pose(); } /** * Normalizes the skin weights which are defined as a buffer attribute * in the skinned mesh's geometry. */ normalizeSkinWeights() { const e = new at(), t = this.geometry.attributes.skinWeight; for (let n = 0, i = t.count; n < i; n++) { e.fromBufferAttribute(t, n); const r = 1 / e.manhattanLength(); r !== 1 / 0 ? e.multiplyScalar(r) : e.set(1, 0, 0, 0), t.setXYZW(n, e.x, e.y, e.z, e.w); } } updateMatrixWorld(e) { super.updateMatrixWorld(e), this.bindMode === Ic ? this.bindMatrixInverse.copy(this.matrixWorld).invert() : this.bindMode === Zf ? this.bindMatrixInverse.copy(this.bindMatrix).invert() : ze("SkinnedMesh: Unrecognized bindMode: " + this.bindMode); } /** * Applies the bone transform associated with the given index to the given * vertex position. Returns the updated vector. * * @param {number} index - The vertex index. * @param {Vector3} target - The target object that is used to store the method's result. * the skinned mesh's world matrix will be used instead. * @return {Vector3} The updated vertex position. */ applyBoneTransform(e, t) { const n = this.skeleton, i = this.geometry; ih.fromBufferAttribute(i.attributes.skinIndex, e), sh.fromBufferAttribute(i.attributes.skinWeight, e), nh.copy(t).applyMatrix4(this.bindMatrix), t.set(0, 0, 0); for (let r = 0; r < 4; r++) { const a = sh.getComponent(r); if (a !== 0) { const o = ih.getComponent(r); rh.multiplyMatrices(n.bones[o].matrixWorld, n.boneInverses[o]), t.addScaledVector(qp.copy(nh).applyMatrix4(rh), a); } } return t.applyMatrix4(this.bindMatrixInverse); } } class ld extends Mt { /** * Constructs a new bone. */ constructor() { super(), this.isBone = !0, this.type = "Bone"; } } class pr extends Ft { /** * Constructs a new data texture. * * @param {?TypedArray} [data=null] - The buffer data. * @param {number} [width=1] - The width of the texture. * @param {number} [height=1] - The height of the texture. * @param {number} [format=RGBAFormat] - The texture format. * @param {number} [type=UnsignedByteType] - The texture type. * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping. * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value. * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value. * @param {number} [magFilter=NearestFilter] - The mag filter value. * @param {number} [minFilter=NearestFilter] - The min filter value. * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value. * @param {string} [colorSpace=NoColorSpace] - The color space. */ constructor(e = null, t = 1, n = 1, i, r, a, o, l, c = Gt, h = Gt, u, f) { super(null, a, o, l, c, h, i, r, u, f), this.isDataTexture = !0, this.image = { data: e, width: t, height: n }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } } const oh = /* @__PURE__ */ new je(), Kp = /* @__PURE__ */ new je(); class ac { /** * Constructs a new skeleton. * * @param {Array} [bones] - An array of bones. * @param {Array} [boneInverses] - An array of bone inverse matrices. * If not provided, these matrices will be computed automatically via {@link Skeleton#calculateInverses}. */ constructor(e = [], t = []) { this.uuid = yn(), this.bones = e.slice(0), this.boneInverses = t, this.boneMatrices = null, this.boneTexture = null, this.init(); } /** * Initializes the skeleton. This method gets automatically called by the constructor * but depending on how the skeleton is created it might be necessary to call this method * manually. */ 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) { ze("Skeleton: Number of inverse bone matrices does not match amount of bones."), this.boneInverses = []; for (let n = 0, i = this.bones.length; n < i; n++) this.boneInverses.push(new je()); } } /** * Computes the bone inverse matrices. This method resets {@link Skeleton#boneInverses} * and fills it with new matrices. */ calculateInverses() { this.boneInverses.length = 0; for (let e = 0, t = this.bones.length; e < t; e++) { const n = new je(); this.bones[e] && n.copy(this.bones[e].matrixWorld).invert(), this.boneInverses.push(n); } } /** * Resets the skeleton to the base pose. */ pose() { for (let e = 0, t = this.bones.length; e < t; e++) { const n = this.bones[e]; n && n.matrixWorld.copy(this.boneInverses[e]).invert(); } for (let e = 0, t = this.bones.length; e < t; e++) { const n = this.bones[e]; n && (n.parent && n.parent.isBone ? (n.matrix.copy(n.parent.matrixWorld).invert(), n.matrix.multiply(n.matrixWorld)) : n.matrix.copy(n.matrixWorld), n.matrix.decompose(n.position, n.quaternion, n.scale)); } } /** * Resets the skeleton to the base pose. */ update() { const e = this.bones, t = this.boneInverses, n = this.boneMatrices, i = this.boneTexture; for (let r = 0, a = e.length; r < a; r++) { const o = e[r] ? e[r].matrixWorld : Kp; oh.multiplyMatrices(o, t[r]), oh.toArray(n, r * 16); } i !== null && (i.needsUpdate = !0); } /** * Returns a new skeleton with copied values from this instance. * * @return {Skeleton} A clone of this instance. */ clone() { return new ac(this.bones, this.boneInverses); } /** * Computes a data texture for passing bone data to the vertex shader. * * @return {Skeleton} A reference of this instance. */ computeBoneTexture() { let e = Math.sqrt(this.bones.length * 4); e = Math.ceil(e / 4) * 4, e = Math.max(e, 4); const t = new Float32Array(e * e * 4); t.set(this.boneMatrices); const n = new pr(t, e, e, sn, Pn); return n.needsUpdate = !0, this.boneMatrices = t, this.boneTexture = n, this; } /** * Searches through the skeleton's bone array and returns the first with a * matching name. * * @param {string} name - The name of the bone. * @return {Bone|undefined} The found bone. `undefined` if no bone has been found. */ getBoneByName(e) { for (let t = 0, n = this.bones.length; t < n; t++) { const i = this.bones[t]; if (i.name === e) return i; } } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. */ dispose() { this.boneTexture !== null && (this.boneTexture.dispose(), this.boneTexture = null); } /** * Setups the skeleton by the given JSON and bones. * * @param {Object} json - The skeleton as serialized JSON. * @param {Object} bones - An array of bones. * @return {Skeleton} A reference of this instance. */ fromJSON(e, t) { this.uuid = e.uuid; for (let n = 0, i = e.bones.length; n < i; n++) { const r = e.bones[n]; let a = t[r]; a === void 0 && (ze("Skeleton: No bone found with UUID:", r), a = new ld()), this.bones.push(a), this.boneInverses.push(new je().fromArray(e.boneInverses[n])); } return this.init(), this; } /** * Serializes the skeleton into JSON. * * @return {Object} A JSON object representing the serialized skeleton. * @see {@link ObjectLoader#parse} */ toJSON() { const e = { metadata: { version: 4.7, type: "Skeleton", generator: "Skeleton.toJSON" }, bones: [], boneInverses: [] }; e.uuid = this.uuid; const t = this.bones, n = this.boneInverses; for (let i = 0, r = t.length; i < r; i++) { const a = t[i]; e.bones.push(a.uuid); const o = n[i]; e.boneInverses.push(o.toArray()); } return e; } } class Rl extends gt { /** * Constructs a new instanced buffer attribute. * * @param {TypedArray} array - The array holding the attribute data. * @param {number} itemSize - The item size. * @param {boolean} [normalized=false] - Whether the data are normalized or not. * @param {number} [meshPerAttribute=1] - How often a value of this buffer attribute should be repeated. */ constructor(e, t, n, i = 1) { super(e, t, n), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = i; } copy(e) { return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; } toJSON() { const e = super.toJSON(); return e.meshPerAttribute = this.meshPerAttribute, e.isInstancedBufferAttribute = !0, e; } } const ns = /* @__PURE__ */ new je(), lh = /* @__PURE__ */ new je(), Fr = [], ch = /* @__PURE__ */ new zt(), $p = /* @__PURE__ */ new je(), Os = /* @__PURE__ */ new ft(), Fs = /* @__PURE__ */ new Xn(); class oc extends ft { /** * Constructs a new instanced mesh. * * @param {BufferGeometry} [geometry] - The mesh geometry. * @param {Material|Array} [material] - The mesh material. * @param {number} count - The number of instances. */ constructor(e, t, n) { super(e, t), this.isInstancedMesh = !0, this.instanceMatrix = new Rl(new Float32Array(n * 16), 16), this.instanceColor = null, this.morphTexture = null, this.count = n, this.boundingBox = null, this.boundingSphere = null; for (let i = 0; i < n; i++) this.setMatrixAt(i, $p); } /** * Computes the bounding box of the instanced mesh, and updates {@link InstancedMesh#boundingBox}. * The bounding box is not automatically computed by the engine; this method must be called by your app. * You may need to recompute the bounding box if an instance is transformed via {@link InstancedMesh#setMatrixAt}. */ computeBoundingBox() { const e = this.geometry, t = this.count; this.boundingBox === null && (this.boundingBox = new zt()), e.boundingBox === null && e.computeBoundingBox(), this.boundingBox.makeEmpty(); for (let n = 0; n < t; n++) this.getMatrixAt(n, ns), ch.copy(e.boundingBox).applyMatrix4(ns), this.boundingBox.union(ch); } /** * Computes the bounding sphere of the instanced mesh, and updates {@link InstancedMesh#boundingSphere} * The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling. * You may need to recompute the bounding sphere if an instance is transformed via {@link InstancedMesh#setMatrixAt}. */ computeBoundingSphere() { const e = this.geometry, t = this.count; this.boundingSphere === null && (this.boundingSphere = new Xn()), e.boundingSphere === null && e.computeBoundingSphere(), this.boundingSphere.makeEmpty(); for (let n = 0; n < t; n++) this.getMatrixAt(n, ns), Fs.copy(e.boundingSphere).applyMatrix4(ns), this.boundingSphere.union(Fs); } 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; } /** * Gets the color of the defined instance. * * @param {number} index - The instance index. * @param {Color} color - The target object that is used to store the method's result. */ getColorAt(e, t) { t.fromArray(this.instanceColor.array, e * 3); } /** * Gets the local transformation matrix of the defined instance. * * @param {number} index - The instance index. * @param {Matrix4} matrix - The target object that is used to store the method's result. */ getMatrixAt(e, t) { t.fromArray(this.instanceMatrix.array, e * 16); } /** * Gets the morph target weights of the defined instance. * * @param {number} index - The instance index. * @param {Mesh} object - The target object that is used to store the method's result. */ getMorphAt(e, t) { const n = t.morphTargetInfluences, i = this.morphTexture.source.data.data, r = n.length + 1, a = e * r + 1; for (let o = 0; o < n.length; o++) n[o] = i[a + o]; } raycast(e, t) { const n = this.matrixWorld, i = this.count; if (Os.geometry = this.geometry, Os.material = this.material, Os.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), Fs.copy(this.boundingSphere), Fs.applyMatrix4(n), e.ray.intersectsSphere(Fs) !== !1)) for (let r = 0; r < i; r++) { this.getMatrixAt(r, ns), lh.multiplyMatrices(n, ns), Os.matrixWorld = lh, Os.raycast(e, Fr); for (let a = 0, o = Fr.length; a < o; a++) { const l = Fr[a]; l.instanceId = r, l.object = this, t.push(l); } Fr.length = 0; } } /** * Sets the given color to the defined instance. Make sure you set the `needsUpdate` flag of * {@link InstancedMesh#instanceColor} to `true` after updating all the colors. * * @param {number} index - The instance index. * @param {Color} color - The instance color. */ setColorAt(e, t) { this.instanceColor === null && (this.instanceColor = new Rl(new Float32Array(this.instanceMatrix.count * 3).fill(1), 3)), t.toArray(this.instanceColor.array, e * 3); } /** * Sets the given local transformation matrix to the defined instance. Make sure you set the `needsUpdate` flag of * {@link InstancedMesh#instanceMatrix} to `true` after updating all the colors. * * @param {number} index - The instance index. * @param {Matrix4} matrix - The local transformation. */ setMatrixAt(e, t) { t.toArray(this.instanceMatrix.array, e * 16); } /** * Sets the morph target weights to the defined instance. Make sure you set the `needsUpdate` flag of * {@link InstancedMesh#morphTexture} to `true` after updating all the influences. * * @param {number} index - The instance index. * @param {Mesh} object - A mesh which `morphTargetInfluences` property containing the morph target weights * of a single instance. */ setMorphAt(e, t) { const n = t.morphTargetInfluences, i = n.length + 1; this.morphTexture === null && (this.morphTexture = new pr(new Float32Array(i * this.count), i, this.count, Jl, Pn)); const r = this.morphTexture.source.data.data; let a = 0; for (let c = 0; c < n.length; c++) a += n[c]; const o = this.geometry.morphTargetsRelative ? 1 : 1 - a, l = i * e; r[l] = o, r.set(n, l + 1); } updateMorphTargets() { } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. */ dispose() { this.dispatchEvent({ type: "dispose" }), this.morphTexture !== null && (this.morphTexture.dispose(), this.morphTexture = null); } } const mo = /* @__PURE__ */ new R(), Jp = /* @__PURE__ */ new R(), Qp = /* @__PURE__ */ new $e(); class Ct { /** * Constructs a new plane. * * @param {Vector3} [normal=(1,0,0)] - A unit length vector defining the normal of the plane. * @param {number} [constant=0] - The signed distance from the origin to the plane. */ constructor(e = new R(1, 0, 0), t = 0) { this.isPlane = !0, this.normal = e, this.constant = t; } /** * Sets the plane components by copying the given values. * * @param {Vector3} normal - The normal. * @param {number} constant - The constant. * @return {Plane} A reference to this plane. */ set(e, t) { return this.normal.copy(e), this.constant = t, this; } /** * Sets the plane components by defining `x`, `y`, `z` as the * plane normal and `w` as the constant. * * @param {number} x - The value for the normal's x component. * @param {number} y - The value for the normal's y component. * @param {number} z - The value for the normal's z component. * @param {number} w - The constant value. * @return {Plane} A reference to this plane. */ setComponents(e, t, n, i) { return this.normal.set(e, t, n), this.constant = i, this; } /** * Sets the plane from the given normal and coplanar point (that is a point * that lies onto the plane). * * @param {Vector3} normal - The normal. * @param {Vector3} point - A coplanar point. * @return {Plane} A reference to this plane. */ setFromNormalAndCoplanarPoint(e, t) { return this.normal.copy(e), this.constant = -t.dot(this.normal), this; } /** * Sets the plane from three coplanar points. The winding order is * assumed to be counter-clockwise, and determines the direction of * the plane normal. * * @param {Vector3} a - The first coplanar point. * @param {Vector3} b - The second coplanar point. * @param {Vector3} c - The third coplanar point. * @return {Plane} A reference to this plane. */ setFromCoplanarPoints(e, t, n) { const i = mo.subVectors(n, t).cross(Jp.subVectors(e, t)).normalize(); return this.setFromNormalAndCoplanarPoint(i, e), this; } /** * Copies the values of the given plane to this instance. * * @param {Plane} plane - The plane to copy. * @return {Plane} A reference to this plane. */ copy(e) { return this.normal.copy(e.normal), this.constant = e.constant, this; } /** * Normalizes the plane normal and adjusts the constant accordingly. * * @return {Plane} A reference to this plane. */ normalize() { const e = 1 / this.normal.length(); return this.normal.multiplyScalar(e), this.constant *= e, this; } /** * Negates both the plane normal and the constant. * * @return {Plane} A reference to this plane. */ negate() { return this.constant *= -1, this.normal.negate(), this; } /** * Returns the signed distance from the given point to this plane. * * @param {Vector3} point - The point to compute the distance for. * @return {number} The signed distance. */ distanceToPoint(e) { return this.normal.dot(e) + this.constant; } /** * Returns the signed distance from the given sphere to this plane. * * @param {Sphere} sphere - The sphere to compute the distance for. * @return {number} The signed distance. */ distanceToSphere(e) { return this.distanceToPoint(e.center) - e.radius; } /** * Projects a the given point onto the plane. * * @param {Vector3} point - The point to project. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The projected point on the plane. */ projectPoint(e, t) { return t.copy(e).addScaledVector(this.normal, -this.distanceToPoint(e)); } /** * Returns the intersection point of the passed line and the plane. Returns * `null` if the line does not intersect. Returns the line's starting point if * the line is coplanar with the plane. * * @param {Line3} line - The line to compute the intersection for. * @param {Vector3} target - The target vector that is used to store the method's result. * @return {?Vector3} The intersection point. */ intersectLine(e, t) { const n = e.delta(mo), i = this.normal.dot(n); if (i === 0) return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null; const r = -(e.start.dot(this.normal) + this.constant) / i; return r < 0 || r > 1 ? null : t.copy(e.start).addScaledVector(n, r); } /** * Returns `true` if the given line segment intersects with (passes through) the plane. * * @param {Line3} line - The line to test. * @return {boolean} Whether the given line segment intersects with the plane or not. */ intersectsLine(e) { const t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end); return t < 0 && n > 0 || n < 0 && t > 0; } /** * Returns `true` if the given bounding box intersects with the plane. * * @param {Box3} box - The bounding box to test. * @return {boolean} Whether the given bounding box intersects with the plane or not. */ intersectsBox(e) { return e.intersectsPlane(this); } /** * Returns `true` if the given bounding sphere intersects with the plane. * * @param {Sphere} sphere - The bounding sphere to test. * @return {boolean} Whether the given bounding sphere intersects with the plane or not. */ intersectsSphere(e) { return e.intersectsPlane(this); } /** * Returns a coplanar vector to the plane, by calculating the * projection of the normal at the origin onto the plane. * * @param {Vector3} target - The target vector that is used to store the method's result. * @return {Vector3} The coplanar point. */ coplanarPoint(e) { return e.copy(this.normal).multiplyScalar(-this.constant); } /** * Apply a 4x4 matrix to the plane. The matrix must be an affine, homogeneous transform. * * The optional normal matrix can be pre-computed like so: * ```js * const optionalNormalMatrix = new THREE.Matrix3().getNormalMatrix( matrix ); * ``` * * @param {Matrix4} matrix - The transformation matrix. * @param {Matrix4} [optionalNormalMatrix] - A pre-computed normal matrix. * @return {Plane} A reference to this plane. */ applyMatrix4(e, t) { const n = t || Qp.getNormalMatrix(e), i = this.coplanarPoint(mo).applyMatrix4(e), r = this.normal.applyMatrix3(n).normalize(); return this.constant = -i.dot(r), this; } /** * Translates the plane by the distance defined by the given offset vector. * Note that this only affects the plane constant and will not affect the normal vector. * * @param {Vector3} offset - The offset vector. * @return {Plane} A reference to this plane. */ translate(e) { return this.constant -= e.dot(this.normal), this; } /** * Returns `true` if this plane is equal with the given one. * * @param {Plane} plane - The plane to test for equality. * @return {boolean} Whether this plane is equal with the given one. */ equals(e) { return e.normal.equals(this.normal) && e.constant === this.constant; } /** * Returns a new plane with copied values from this instance. * * @return {Plane} A clone of this instance. */ clone() { return new this.constructor().copy(this); } } const Mi = /* @__PURE__ */ new Xn(), em = /* @__PURE__ */ new ue(0.5, 0.5), zr = /* @__PURE__ */ new R(); class lc { /** * Constructs a new frustum. * * @param {Plane} [p0] - The first plane that encloses the frustum. * @param {Plane} [p1] - The second plane that encloses the frustum. * @param {Plane} [p2] - The third plane that encloses the frustum. * @param {Plane} [p3] - The fourth plane that encloses the frustum. * @param {Plane} [p4] - The fifth plane that encloses the frustum. * @param {Plane} [p5] - The sixth plane that encloses the frustum. */ constructor(e = new Ct(), t = new Ct(), n = new Ct(), i = new Ct(), r = new Ct(), a = new Ct()) { this.planes = [e, t, n, i, r, a]; } /** * Sets the frustum planes by copying the given planes. * * @param {Plane} [p0] - The first plane that encloses the frustum. * @param {Plane} [p1] - The second plane that encloses the frustum. * @param {Plane} [p2] - The third plane that encloses the frustum. * @param {Plane} [p3] - The fourth plane that encloses the frustum. * @param {Plane} [p4] - The fifth plane that encloses the frustum. * @param {Plane} [p5] - The sixth plane that encloses the frustum. * @return {Frustum} A reference to this frustum. */ set(e, t, n, i, r, a) { const o = this.planes; return o[0].copy(e), o[1].copy(t), o[2].copy(n), o[3].copy(i), o[4].copy(r), o[5].copy(a), this; } /** * Copies the values of the given frustum to this instance. * * @param {Frustum} frustum - The frustum to copy. * @return {Frustum} A reference to this frustum. */ copy(e) { const t = this.planes; for (let n = 0; n < 6; n++) t[n].copy(e.planes[n]); return this; } /** * Sets the frustum planes from the given projection matrix. * * @param {Matrix4} m - The projection matrix. * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} coordinateSystem - The coordinate system. * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth. * @return {Frustum} A reference to this frustum. */ setFromProjectionMatrix(e, t = Vn, n = !1) { const i = this.planes, r = e.elements, a = r[0], o = r[1], l = r[2], c = r[3], h = r[4], u = r[5], f = r[6], d = r[7], p = r[8], g = r[9], x = r[10], m = r[11], v = r[12], b = r[13], M = r[14], C = r[15]; if (i[0].setComponents(c - a, d - h, m - p, C - v).normalize(), i[1].setComponents(c + a, d + h, m + p, C + v).normalize(), i[2].setComponents(c + o, d + u, m + g, C + b).normalize(), i[3].setComponents(c - o, d - u, m - g, C - b).normalize(), n) i[4].setComponents(l, f, x, M).normalize(), i[5].setComponents(c - l, d - f, m - x, C - M).normalize(); else if (i[4].setComponents(c - l, d - f, m - x, C - M).normalize(), t === Vn) i[5].setComponents(c + l, d + f, m + x, C + M).normalize(); else if (t === _a) i[5].setComponents(l, f, x, M).normalize(); else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t); return this; } /** * Returns `true` if the 3D object's bounding sphere is intersecting this frustum. * * Note that the 3D object must have a geometry so that the bounding sphere can be calculated. * * @param {Object3D} object - The 3D object to test. * @return {boolean} Whether the 3D object's bounding sphere is intersecting this frustum or not. */ intersectsObject(e) { if (e.boundingSphere !== void 0) e.boundingSphere === null && e.computeBoundingSphere(), Mi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld); else { const t = e.geometry; t.boundingSphere === null && t.computeBoundingSphere(), Mi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld); } return this.intersectsSphere(Mi); } /** * Returns `true` if the given sprite is intersecting this frustum. * * @param {Sprite} sprite - The sprite to test. * @return {boolean} Whether the sprite is intersecting this frustum or not. */ intersectsSprite(e) { Mi.center.set(0, 0, 0); const t = em.distanceTo(e.center); return Mi.radius = 0.7071067811865476 + t, Mi.applyMatrix4(e.matrixWorld), this.intersectsSphere(Mi); } /** * Returns `true` if the given bounding sphere is intersecting this frustum. * * @param {Sphere} sphere - The bounding sphere to test. * @return {boolean} Whether the bounding sphere is intersecting this frustum or not. */ intersectsSphere(e) { const t = this.planes, n = e.center, i = -e.radius; for (let r = 0; r < 6; r++) if (t[r].distanceToPoint(n) < i) return !1; return !0; } /** * Returns `true` if the given bounding box is intersecting this frustum. * * @param {Box3} box - The bounding box to test. * @return {boolean} Whether the bounding box is intersecting this frustum or not. */ intersectsBox(e) { const t = this.planes; for (let n = 0; n < 6; n++) { const i = t[n]; if (zr.x = i.normal.x > 0 ? e.max.x : e.min.x, zr.y = i.normal.y > 0 ? e.max.y : e.min.y, zr.z = i.normal.z > 0 ? e.max.z : e.min.z, i.distanceToPoint(zr) < 0) return !1; } return !0; } /** * Returns `true` if the given point lies within the frustum. * * @param {Vector3} point - The point to test. * @return {boolean} Whether the point lies within this frustum or not. */ containsPoint(e) { const t = this.planes; for (let n = 0; n < 6; n++) if (t[n].distanceToPoint(e) < 0) return !1; return !0; } /** * Returns a new frustum with copied values from this instance. * * @return {Frustum} A clone of this instance. */ clone() { return new this.constructor().copy(this); } } class Bi extends mn { /** * Constructs a new line basic material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new Fe(16777215), this.map = null, this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.fog = !0, this.setValues(e); } copy(e) { return super.copy(e), this.color.copy(e.color), this.map = e.map, this.linewidth = e.linewidth, this.linecap = e.linecap, this.linejoin = e.linejoin, this.fog = e.fog, this; } } const Ma = /* @__PURE__ */ new R(), Sa = /* @__PURE__ */ new R(), hh = /* @__PURE__ */ new je(), zs = /* @__PURE__ */ new Ts(), Hr = /* @__PURE__ */ new Xn(), go = /* @__PURE__ */ new R(), uh = /* @__PURE__ */ new R(); class Oi extends Mt { /** * Constructs a new line. * * @param {BufferGeometry} [geometry] - The line geometry. * @param {Material|Array} [material] - The line material. */ constructor(e = new xt(), t = new Bi()) { super(), this.isLine = !0, this.type = "Line", this.geometry = e, this.material = t, this.morphTargetDictionary = void 0, this.morphTargetInfluences = void 0, this.updateMorphTargets(); } copy(e, t) { return super.copy(e, t), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this; } /** * Computes an array of distance values which are necessary for rendering dashed lines. * For each vertex in the geometry, the method calculates the cumulative length from the * current point to the very beginning of the line. * * @return {Line} A reference to this line. */ computeLineDistances() { const e = this.geometry; if (e.index === null) { const t = e.attributes.position, n = [0]; for (let i = 1, r = t.count; i < r; i++) Ma.fromBufferAttribute(t, i - 1), Sa.fromBufferAttribute(t, i), n[i] = n[i - 1], n[i] += Ma.distanceTo(Sa); e.setAttribute("lineDistance", new an(n, 1)); } else ze("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); return this; } /** * Computes intersection points between a casted ray and this line. * * @param {Raycaster} raycaster - The raycaster. * @param {Array} intersects - The target array that holds the intersection points. */ raycast(e, t) { const n = this.geometry, i = this.matrixWorld, r = e.params.Line.threshold, a = n.drawRange; if (n.boundingSphere === null && n.computeBoundingSphere(), Hr.copy(n.boundingSphere), Hr.applyMatrix4(i), Hr.radius += r, e.ray.intersectsSphere(Hr) === !1) return; hh.copy(i).invert(), zs.copy(e.ray).applyMatrix4(hh); const o = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = o * o, c = this.isLineSegments ? 2 : 1, h = n.index, f = n.attributes.position; if (h !== null) { const d = Math.max(0, a.start), p = Math.min(h.count, a.start + a.count); for (let g = d, x = p - 1; g < x; g += c) { const m = h.getX(g), v = h.getX(g + 1), b = Vr(this, e, zs, l, m, v, g); b && t.push(b); } if (this.isLineLoop) { const g = h.getX(p - 1), x = h.getX(d), m = Vr(this, e, zs, l, g, x, p - 1); m && t.push(m); } } else { const d = Math.max(0, a.start), p = Math.min(f.count, a.start + a.count); for (let g = d, x = p - 1; g < x; g += c) { const m = Vr(this, e, zs, l, g, g + 1, g); m && t.push(m); } if (this.isLineLoop) { const g = Vr(this, e, zs, l, p - 1, d, p - 1); g && t.push(g); } } } /** * Sets the values of {@link Line#morphTargetDictionary} and {@link Line#morphTargetInfluences} * to make sure existing morph targets can influence this 3D object. */ updateMorphTargets() { const t = this.geometry.morphAttributes, n = Object.keys(t); if (n.length > 0) { const i = t[n[0]]; if (i !== void 0) { this.morphTargetInfluences = [], this.morphTargetDictionary = {}; for (let r = 0, a = i.length; r < a; r++) { const o = i[r].name || String(r); this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r; } } } } } function Vr(s, e, t, n, i, r, a) { const o = s.geometry.attributes.position; if (Ma.fromBufferAttribute(o, i), Sa.fromBufferAttribute(o, r), t.distanceSqToSegment(Ma, Sa, go, uh) > n) return; go.applyMatrix4(s.matrixWorld); const c = e.ray.origin.distanceTo(go); if (!(c < e.near || c > e.far)) return { distance: c, // What do we want? intersection point on the ray or on the segment?? // point: raycaster.ray.at( distance ), point: uh.clone().applyMatrix4(s.matrixWorld), index: a, face: null, faceIndex: null, barycoord: null, object: s }; } const dh = /* @__PURE__ */ new R(), fh = /* @__PURE__ */ new R(); class cd extends Oi { /** * Constructs a new line segments. * * @param {BufferGeometry} [geometry] - The line geometry. * @param {Material|Array} [material] - The line material. */ constructor(e, t) { super(e, t), this.isLineSegments = !0, this.type = "LineSegments"; } computeLineDistances() { const e = this.geometry; if (e.index === null) { const t = e.attributes.position, n = []; for (let i = 0, r = t.count; i < r; i += 2) dh.fromBufferAttribute(t, i), fh.fromBufferAttribute(t, i + 1), n[i] = i === 0 ? 0 : n[i - 1], n[i + 1] = n[i] + dh.distanceTo(fh); e.setAttribute("lineDistance", new an(n, 1)); } else ze("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); return this; } } class tm extends Oi { /** * Constructs a new line loop. * * @param {BufferGeometry} [geometry] - The line geometry. * @param {Material|Array} [material] - The line material. */ constructor(e, t) { super(e, t), this.isLineLoop = !0, this.type = "LineLoop"; } } class hd extends mn { /** * Constructs a new points material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isPointsMaterial = !0, this.type = "PointsMaterial", this.color = new Fe(16777215), this.map = null, this.alphaMap = null, this.size = 1, this.sizeAttenuation = !0, this.fog = !0, this.setValues(e); } copy(e) { return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.size = e.size, this.sizeAttenuation = e.sizeAttenuation, this.fog = e.fog, this; } } const ph = /* @__PURE__ */ new je(), Ll = /* @__PURE__ */ new Ts(), Gr = /* @__PURE__ */ new Xn(), Wr = /* @__PURE__ */ new R(); class nm extends Mt { /** * Constructs a new point cloud. * * @param {BufferGeometry} [geometry] - The points geometry. * @param {Material|Array} [material] - The points material. */ constructor(e = new xt(), t = new hd()) { 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; } /** * Computes intersection points between a casted ray and this point cloud. * * @param {Raycaster} raycaster - The raycaster. * @param {Array} intersects - The target array that holds the intersection points. */ raycast(e, t) { const n = this.geometry, i = this.matrixWorld, r = e.params.Points.threshold, a = n.drawRange; if (n.boundingSphere === null && n.computeBoundingSphere(), Gr.copy(n.boundingSphere), Gr.applyMatrix4(i), Gr.radius += r, e.ray.intersectsSphere(Gr) === !1) return; ph.copy(i).invert(), Ll.copy(e.ray).applyMatrix4(ph); const o = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = o * o, c = n.index, u = n.attributes.position; if (c !== null) { const f = Math.max(0, a.start), d = Math.min(c.count, a.start + a.count); for (let p = f, g = d; p < g; p++) { const x = c.getX(p); Wr.fromBufferAttribute(u, x), mh(Wr, x, l, i, e, t, this); } } else { const f = Math.max(0, a.start), d = Math.min(u.count, a.start + a.count); for (let p = f, g = d; p < g; p++) Wr.fromBufferAttribute(u, p), mh(Wr, p, l, i, e, t, this); } } /** * Sets the values of {@link Points#morphTargetDictionary} and {@link Points#morphTargetInfluences} * to make sure existing morph targets can influence this 3D object. */ updateMorphTargets() { const t = this.geometry.morphAttributes, n = Object.keys(t); if (n.length > 0) { const i = t[n[0]]; if (i !== void 0) { this.morphTargetInfluences = [], this.morphTargetDictionary = {}; for (let r = 0, a = i.length; r < a; r++) { const o = i[r].name || String(r); this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r; } } } } } function mh(s, e, t, n, i, r, a) { const o = Ll.distanceSqToPoint(s); if (o < t) { const l = new R(); Ll.closestPointToPoint(s, l), l.applyMatrix4(n); const c = i.ray.origin.distanceTo(l); if (c < i.near || c > i.far) return; r.push({ distance: c, distanceToRay: Math.sqrt(o), point: l, index: e, face: null, faceIndex: null, barycoord: null, object: a }); } } class cc extends Ft { /** * Constructs a new depth texture. * * @param {number} width - The width of the texture. * @param {number} height - The height of the texture. * @param {number} [type=UnsignedIntType] - The texture type. * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping. * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value. * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value. * @param {number} [magFilter=LinearFilter] - The mag filter value. * @param {number} [minFilter=LinearFilter] - The min filter value. * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value. * @param {number} [format=DepthFormat] - The texture format. * @param {number} [depth=1] - The depth of the texture. */ constructor(e, t, n = Ri, i, r, a, o = Gt, l = Gt, c, h = sr, u = 1) { if (h !== sr && h !== xs) throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); const f = { width: e, height: t, depth: u }; super(f, i, r, a, o, l, h, n, c), this.isDepthTexture = !0, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null; } copy(e) { return super.copy(e), this.source = new sc(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 ud extends Ft { /** * Creates a new raw texture. * * @param {?(WebGLTexture|GPUTexture)} [sourceTexture=null] - The external texture. */ constructor(e = null) { super(), this.sourceTexture = e, this.isExternalTexture = !0; } copy(e) { return super.copy(e), this.sourceTexture = e.sourceTexture, this; } } class jn { /** * Constructs a new curve. */ constructor() { this.type = "Curve", this.arcLengthDivisions = 200, this.needsUpdate = !1, this.cacheArcLengths = null; } /** * This method returns a vector in 2D or 3D space (depending on the curve definition) * for the given interpolation factor. * * @abstract * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {(Vector2|Vector3)} [optionalTarget] - The optional target vector the result is written to. * @return {(Vector2|Vector3)} The position on the curve. It can be a 2D or 3D vector depending on the curve definition. */ getPoint() { ze("Curve: .getPoint() not implemented."); } /** * This method returns a vector in 2D or 3D space (depending on the curve definition) * for the given interpolation factor. Unlike {@link Curve#getPoint}, this method honors the length * of the curve which equidistant samples. * * @param {number} u - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {(Vector2|Vector3)} [optionalTarget] - The optional target vector the result is written to. * @return {(Vector2|Vector3)} The position on the curve. It can be a 2D or 3D vector depending on the curve definition. */ getPointAt(e, t) { const n = this.getUtoTmapping(e); return this.getPoint(n, t); } /** * This method samples the curve via {@link Curve#getPoint} and returns an array of points representing * the curve shape. * * @param {number} [divisions=5] - The number of divisions. * @return {Array<(Vector2|Vector3)>} An array holding the sampled curve values. The number of points is `divisions + 1`. */ getPoints(e = 5) { const t = []; for (let n = 0; n <= e; n++) t.push(this.getPoint(n / e)); return t; } // Get sequence of points using getPointAt( u ) /** * This method samples the curve via {@link Curve#getPointAt} and returns an array of points representing * the curve shape. Unlike {@link Curve#getPoints}, this method returns equi-spaced points across the entire * curve. * * @param {number} [divisions=5] - The number of divisions. * @return {Array<(Vector2|Vector3)>} An array holding the sampled curve values. The number of points is `divisions + 1`. */ getSpacedPoints(e = 5) { const t = []; for (let n = 0; n <= e; n++) t.push(this.getPointAt(n / e)); return t; } /** * Returns the total arc length of the curve. * * @return {number} The length of the curve. */ getLength() { const e = this.getLengths(); return e[e.length - 1]; } /** * Returns an array of cumulative segment lengths of the curve. * * @param {number} [divisions=this.arcLengthDivisions] - The number of divisions. * @return {Array} An array holding the cumulative segment lengths. */ getLengths(e = this.arcLengthDivisions) { if (this.cacheArcLengths && this.cacheArcLengths.length === e + 1 && !this.needsUpdate) return this.cacheArcLengths; this.needsUpdate = !1; const t = []; let n, i = this.getPoint(0), r = 0; t.push(0); for (let a = 1; a <= e; a++) n = this.getPoint(a / e), r += n.distanceTo(i), t.push(r), i = n; return this.cacheArcLengths = t, t; } /** * Update the cumulative segment distance cache. The method must be called * every time curve parameters are changed. If an updated curve is part of a * composed curve like {@link CurvePath}, this method must be called on the * composed curve, too. */ updateArcLengths() { this.needsUpdate = !0, this.getLengths(); } /** * Given an interpolation factor in the range `[0,1]`, this method returns an updated * interpolation factor in the same range that can be ued to sample equidistant points * from a curve. * * @param {number} u - The interpolation factor. * @param {?number} distance - An optional distance on the curve. * @return {number} The updated interpolation factor. */ getUtoTmapping(e, t = null) { const n = this.getLengths(); let i = 0; const r = n.length; let a; t ? a = t : a = e * n[r - 1]; let o = 0, l = r - 1, c; for (; o <= l; ) if (i = Math.floor(o + (l - o) / 2), c = n[i] - a, c < 0) o = i + 1; else if (c > 0) l = i - 1; else { l = i; break; } if (i = l, n[i] === a) return i / (r - 1); const h = n[i], f = n[i + 1] - h, d = (a - h) / f; return (i + d) / (r - 1); } /** * Returns a unit vector tangent for the given interpolation factor. * If the derived curve does not implement its tangent derivation, * two points a small delta apart will be used to find its gradient * which seems to give a reasonable approximation. * * @param {number} t - The interpolation factor. * @param {(Vector2|Vector3)} [optionalTarget] - The optional target vector the result is written to. * @return {(Vector2|Vector3)} The tangent vector. */ getTangent(e, t) { let i = e - 1e-4, r = e + 1e-4; i < 0 && (i = 0), r > 1 && (r = 1); const a = this.getPoint(i), o = this.getPoint(r), l = t || (a.isVector2 ? new ue() : new R()); return l.copy(o).sub(a).normalize(), l; } /** * Same as {@link Curve#getTangent} but with equidistant samples. * * @param {number} u - The interpolation factor. * @param {(Vector2|Vector3)} [optionalTarget] - The optional target vector the result is written to. * @return {(Vector2|Vector3)} The tangent vector. * @see {@link Curve#getPointAt} */ getTangentAt(e, t) { const n = this.getUtoTmapping(e); return this.getTangent(n, t); } /** * Generates the Frenet Frames. Requires a curve definition in 3D space. Used * in geometries like {@link TubeGeometry} or {@link ExtrudeGeometry}. * * @param {number} segments - The number of segments. * @param {boolean} [closed=false] - Whether the curve is closed or not. * @return {{tangents: Array, normals: Array, binormals: Array}} The Frenet Frames. */ computeFrenetFrames(e, t = !1) { const n = new R(), i = [], r = [], a = [], o = new R(), l = new je(); for (let d = 0; d <= e; d++) { const p = d / e; i[d] = this.getTangentAt(p, new R()); } r[0] = new R(), a[0] = new R(); let c = Number.MAX_VALUE; const h = Math.abs(i[0].x), u = Math.abs(i[0].y), f = Math.abs(i[0].z); h <= c && (c = h, n.set(1, 0, 0)), u <= c && (c = u, n.set(0, 1, 0)), f <= c && n.set(0, 0, 1), o.crossVectors(i[0], n).normalize(), r[0].crossVectors(i[0], o), a[0].crossVectors(i[0], r[0]); for (let d = 1; d <= e; d++) { if (r[d] = r[d - 1].clone(), a[d] = a[d - 1].clone(), o.crossVectors(i[d - 1], i[d]), o.length() > Number.EPSILON) { o.normalize(); const p = Math.acos(Je(i[d - 1].dot(i[d]), -1, 1)); r[d].applyMatrix4(l.makeRotationAxis(o, p)); } a[d].crossVectors(i[d], r[d]); } if (t === !0) { let d = Math.acos(Je(r[0].dot(r[e]), -1, 1)); d /= e, i[0].dot(o.crossVectors(r[0], r[e])) > 0 && (d = -d); for (let p = 1; p <= e; p++) r[p].applyMatrix4(l.makeRotationAxis(i[p], d * p)), a[p].crossVectors(i[p], r[p]); } return { tangents: i, normals: r, binormals: a }; } /** * Returns a new curve with copied values from this instance. * * @return {Curve} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Copies the values of the given curve to this instance. * * @param {Curve} source - The curve to copy. * @return {Curve} A reference to this curve. */ copy(e) { return this.arcLengthDivisions = e.arcLengthDivisions, this; } /** * Serializes the curve into JSON. * * @return {Object} A JSON object representing the serialized curve. * @see {@link ObjectLoader#parse} */ toJSON() { const e = { metadata: { version: 4.7, type: "Curve", generator: "Curve.toJSON" } }; return e.arcLengthDivisions = this.arcLengthDivisions, e.type = this.type, e; } /** * Deserializes the curve from the given JSON. * * @param {Object} json - The JSON holding the serialized curve. * @return {Curve} A reference to this curve. */ fromJSON(e) { return this.arcLengthDivisions = e.arcLengthDivisions, this; } } class hc extends jn { /** * Constructs a new ellipse curve. * * @param {number} [aX=0] - The X center of the ellipse. * @param {number} [aY=0] - The Y center of the ellipse. * @param {number} [xRadius=1] - The radius of the ellipse in the x direction. * @param {number} [yRadius=1] - The radius of the ellipse in the y direction. * @param {number} [aStartAngle=0] - The start angle of the curve in radians starting from the positive X axis. * @param {number} [aEndAngle=Math.PI*2] - The end angle of the curve in radians starting from the positive X axis. * @param {boolean} [aClockwise=false] - Whether the ellipse is drawn clockwise or not. * @param {number} [aRotation=0] - The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. */ constructor(e = 0, t = 0, n = 1, i = 1, r = 0, a = Math.PI * 2, o = !1, l = 0) { super(), this.isEllipseCurve = !0, this.type = "EllipseCurve", this.aX = e, this.aY = t, this.xRadius = n, this.yRadius = i, this.aStartAngle = r, this.aEndAngle = a, this.aClockwise = o, this.aRotation = l; } /** * Returns a point on the curve. * * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {Vector2} [optionalTarget] - The optional target vector the result is written to. * @return {Vector2} The position on the curve. */ getPoint(e, t = new ue()) { const n = t, i = Math.PI * 2; let r = this.aEndAngle - this.aStartAngle; const a = Math.abs(r) < Number.EPSILON; for (; r < 0; ) r += i; for (; r > i; ) r -= i; r < Number.EPSILON && (a ? r = 0 : r = i), this.aClockwise === !0 && !a && (r === i ? r = -i : r = r - i); const o = this.aStartAngle + e * r; let l = this.aX + this.xRadius * Math.cos(o), c = this.aY + this.yRadius * Math.sin(o); if (this.aRotation !== 0) { const h = Math.cos(this.aRotation), u = Math.sin(this.aRotation), f = l - this.aX, d = c - this.aY; l = f * h - d * u + this.aX, c = f * u + d * h + this.aY; } return n.set(l, c); } copy(e) { return super.copy(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this; } toJSON() { const e = super.toJSON(); return e.aX = this.aX, e.aY = this.aY, e.xRadius = this.xRadius, e.yRadius = this.yRadius, e.aStartAngle = this.aStartAngle, e.aEndAngle = this.aEndAngle, e.aClockwise = this.aClockwise, e.aRotation = this.aRotation, e; } fromJSON(e) { return super.fromJSON(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this; } } class im extends hc { /** * Constructs a new arc curve. * * @param {number} [aX=0] - The X center of the ellipse. * @param {number} [aY=0] - The Y center of the ellipse. * @param {number} [aRadius=1] - The radius of the ellipse in the x direction. * @param {number} [aStartAngle=0] - The start angle of the curve in radians starting from the positive X axis. * @param {number} [aEndAngle=Math.PI*2] - The end angle of the curve in radians starting from the positive X axis. * @param {boolean} [aClockwise=false] - Whether the ellipse is drawn clockwise or not. */ constructor(e, t, n, i, r, a) { super(e, t, n, n, i, r, a), this.isArcCurve = !0, this.type = "ArcCurve"; } } function uc() { let s = 0, e = 0, t = 0, n = 0; function i(r, a, o, l) { s = r, e = o, t = -3 * r + 3 * a - 2 * o - l, n = 2 * r - 2 * a + o + l; } return { initCatmullRom: function(r, a, o, l, c) { i(a, o, c * (o - r), c * (l - a)); }, initNonuniformCatmullRom: function(r, a, o, l, c, h, u) { let f = (a - r) / c - (o - r) / (c + h) + (o - a) / h, d = (o - a) / h - (l - a) / (h + u) + (l - o) / u; f *= h, d *= h, i(a, o, f, d); }, calc: function(r) { const a = r * r, o = a * r; return s + e * r + t * a + n * o; } }; } const Xr = /* @__PURE__ */ new R(), xo = /* @__PURE__ */ new uc(), vo = /* @__PURE__ */ new uc(), bo = /* @__PURE__ */ new uc(); class sm extends jn { /** * Constructs a new Catmull-Rom curve. * * @param {Array} [points] - An array of 3D points defining the curve. * @param {boolean} [closed=false] - Whether the curve is closed or not. * @param {('centripetal'|'chordal'|'catmullrom')} [curveType='centripetal'] - The curve type. * @param {number} [tension=0.5] - Tension of the curve. */ constructor(e = [], t = !1, n = "centripetal", i = 0.5) { super(), this.isCatmullRomCurve3 = !0, this.type = "CatmullRomCurve3", this.points = e, this.closed = t, this.curveType = n, this.tension = i; } /** * Returns a point on the curve. * * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {Vector3} [optionalTarget] - The optional target vector the result is written to. * @return {Vector3} The position on the curve. */ getPoint(e, t = new R()) { const n = t, i = this.points, r = i.length, a = (r - (this.closed ? 0 : 1)) * e; let o = Math.floor(a), l = a - o; this.closed ? o += o > 0 ? 0 : (Math.floor(Math.abs(o) / r) + 1) * r : l === 0 && o === r - 1 && (o = r - 2, l = 1); let c, h; this.closed || o > 0 ? c = i[(o - 1) % r] : (Xr.subVectors(i[0], i[1]).add(i[0]), c = Xr); const u = i[o % r], f = i[(o + 1) % r]; if (this.closed || o + 2 < r ? h = i[(o + 2) % r] : (Xr.subVectors(i[r - 1], i[r - 2]).add(i[r - 1]), h = Xr), this.curveType === "centripetal" || this.curveType === "chordal") { const d = this.curveType === "chordal" ? 0.5 : 0.25; let p = Math.pow(c.distanceToSquared(u), d), g = Math.pow(u.distanceToSquared(f), d), x = Math.pow(f.distanceToSquared(h), d); g < 1e-4 && (g = 1), p < 1e-4 && (p = g), x < 1e-4 && (x = g), xo.initNonuniformCatmullRom(c.x, u.x, f.x, h.x, p, g, x), vo.initNonuniformCatmullRom(c.y, u.y, f.y, h.y, p, g, x), bo.initNonuniformCatmullRom(c.z, u.z, f.z, h.z, p, g, x); } else this.curveType === "catmullrom" && (xo.initCatmullRom(c.x, u.x, f.x, h.x, this.tension), vo.initCatmullRom(c.y, u.y, f.y, h.y, this.tension), bo.initCatmullRom(c.z, u.z, f.z, h.z, this.tension)); return n.set( xo.calc(l), vo.calc(l), bo.calc(l) ), n; } copy(e) { super.copy(e), this.points = []; for (let t = 0, n = e.points.length; t < n; t++) { const i = e.points[t]; this.points.push(i.clone()); } return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this; } toJSON() { const e = super.toJSON(); e.points = []; for (let t = 0, n = this.points.length; t < n; t++) { const i = this.points[t]; e.points.push(i.toArray()); } return e.closed = this.closed, e.curveType = this.curveType, e.tension = this.tension, e; } fromJSON(e) { super.fromJSON(e), this.points = []; for (let t = 0, n = e.points.length; t < n; t++) { const i = e.points[t]; this.points.push(new R().fromArray(i)); } return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this; } } function gh(s, e, t, n, i) { const r = (n - e) * 0.5, a = (i - t) * 0.5, o = s * s, l = s * o; return (2 * t - 2 * n + r + a) * l + (-3 * t + 3 * n - 2 * r - a) * o + r * s + t; } function rm(s, e) { const t = 1 - s; return t * t * e; } function am(s, e) { return 2 * (1 - s) * s * e; } function om(s, e) { return s * s * e; } function Qs(s, e, t, n) { return rm(s, e) + am(s, t) + om(s, n); } function lm(s, e) { const t = 1 - s; return t * t * t * e; } function cm(s, e) { const t = 1 - s; return 3 * t * t * s * e; } function hm(s, e) { return 3 * (1 - s) * s * s * e; } function um(s, e) { return s * s * s * e; } function er(s, e, t, n, i) { return lm(s, e) + cm(s, t) + hm(s, n) + um(s, i); } class dd extends jn { /** * Constructs a new Cubic Bezier curve. * * @param {Vector2} [v0] - The start point. * @param {Vector2} [v1] - The first control point. * @param {Vector2} [v2] - The second control point. * @param {Vector2} [v3] - The end point. */ constructor(e = new ue(), t = new ue(), n = new ue(), i = new ue()) { super(), this.isCubicBezierCurve = !0, this.type = "CubicBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = i; } /** * Returns a point on the curve. * * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {Vector2} [optionalTarget] - The optional target vector the result is written to. * @return {Vector2} The position on the curve. */ getPoint(e, t = new ue()) { const n = t, i = this.v0, r = this.v1, a = this.v2, o = this.v3; return n.set( er(e, i.x, r.x, a.x, o.x), er(e, i.y, r.y, a.y, o.y) ), n; } copy(e) { return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; } toJSON() { const e = super.toJSON(); return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e; } fromJSON(e) { return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; } } class dm extends jn { /** * Constructs a new Cubic Bezier curve. * * @param {Vector3} [v0] - The start point. * @param {Vector3} [v1] - The first control point. * @param {Vector3} [v2] - The second control point. * @param {Vector3} [v3] - The end point. */ constructor(e = new R(), t = new R(), n = new R(), i = new R()) { super(), this.isCubicBezierCurve3 = !0, this.type = "CubicBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = i; } /** * Returns a point on the curve. * * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {Vector3} [optionalTarget] - The optional target vector the result is written to. * @return {Vector3} The position on the curve. */ getPoint(e, t = new R()) { const n = t, i = this.v0, r = this.v1, a = this.v2, o = this.v3; return n.set( er(e, i.x, r.x, a.x, o.x), er(e, i.y, r.y, a.y, o.y), er(e, i.z, r.z, a.z, o.z) ), n; } copy(e) { return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; } toJSON() { const e = super.toJSON(); return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e; } fromJSON(e) { return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; } } class fd extends jn { /** * Constructs a new line curve. * * @param {Vector2} [v1] - The start point. * @param {Vector2} [v2] - The end point. */ constructor(e = new ue(), t = new ue()) { super(), this.isLineCurve = !0, this.type = "LineCurve", this.v1 = e, this.v2 = t; } /** * Returns a point on the line. * * @param {number} t - A interpolation factor representing a position on the line. Must be in the range `[0,1]`. * @param {Vector2} [optionalTarget] - The optional target vector the result is written to. * @return {Vector2} The position on the line. */ getPoint(e, t = new ue()) { const n = t; return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n; } // Line curve is linear, so we can overwrite default getPointAt getPointAt(e, t) { return this.getPoint(e, t); } getTangent(e, t = new ue()) { return t.subVectors(this.v2, this.v1).normalize(); } getTangentAt(e, t) { return this.getTangent(e, t); } copy(e) { return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; } toJSON() { const e = super.toJSON(); return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; } fromJSON(e) { return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; } } class fm extends jn { /** * Constructs a new line curve. * * @param {Vector3} [v1] - The start point. * @param {Vector3} [v2] - The end point. */ constructor(e = new R(), t = new R()) { super(), this.isLineCurve3 = !0, this.type = "LineCurve3", this.v1 = e, this.v2 = t; } /** * Returns a point on the line. * * @param {number} t - A interpolation factor representing a position on the line. Must be in the range `[0,1]`. * @param {Vector3} [optionalTarget] - The optional target vector the result is written to. * @return {Vector3} The position on the line. */ getPoint(e, t = new R()) { const n = t; return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n; } // Line curve is linear, so we can overwrite default getPointAt getPointAt(e, t) { return this.getPoint(e, t); } getTangent(e, t = new R()) { return t.subVectors(this.v2, this.v1).normalize(); } getTangentAt(e, t) { return this.getTangent(e, t); } copy(e) { return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; } toJSON() { const e = super.toJSON(); return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; } fromJSON(e) { return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; } } class pd extends jn { /** * Constructs a new Quadratic Bezier curve. * * @param {Vector2} [v0] - The start point. * @param {Vector2} [v1] - The control point. * @param {Vector2} [v2] - The end point. */ constructor(e = new ue(), t = new ue(), n = new ue()) { super(), this.isQuadraticBezierCurve = !0, this.type = "QuadraticBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n; } /** * Returns a point on the curve. * * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {Vector2} [optionalTarget] - The optional target vector the result is written to. * @return {Vector2} The position on the curve. */ getPoint(e, t = new ue()) { const n = t, i = this.v0, r = this.v1, a = this.v2; return n.set( Qs(e, i.x, r.x, a.x), Qs(e, i.y, r.y, a.y) ), n; } copy(e) { return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; } toJSON() { const e = super.toJSON(); return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; } fromJSON(e) { return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; } } class pm extends jn { /** * Constructs a new Quadratic Bezier curve. * * @param {Vector3} [v0] - The start point. * @param {Vector3} [v1] - The control point. * @param {Vector3} [v2] - The end point. */ constructor(e = new R(), t = new R(), n = new R()) { super(), this.isQuadraticBezierCurve3 = !0, this.type = "QuadraticBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n; } /** * Returns a point on the curve. * * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {Vector3} [optionalTarget] - The optional target vector the result is written to. * @return {Vector3} The position on the curve. */ getPoint(e, t = new R()) { const n = t, i = this.v0, r = this.v1, a = this.v2; return n.set( Qs(e, i.x, r.x, a.x), Qs(e, i.y, r.y, a.y), Qs(e, i.z, r.z, a.z) ), n; } copy(e) { return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; } toJSON() { const e = super.toJSON(); return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; } fromJSON(e) { return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; } } class md extends jn { /** * Constructs a new 2D spline curve. * * @param {Array} [points] - An array of 2D points defining the curve. */ constructor(e = []) { super(), this.isSplineCurve = !0, this.type = "SplineCurve", this.points = e; } /** * Returns a point on the curve. * * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {Vector2} [optionalTarget] - The optional target vector the result is written to. * @return {Vector2} The position on the curve. */ getPoint(e, t = new ue()) { const n = t, i = this.points, r = (i.length - 1) * e, a = Math.floor(r), o = r - a, l = i[a === 0 ? a : a - 1], c = i[a], h = i[a > i.length - 2 ? i.length - 1 : a + 1], u = i[a > i.length - 3 ? i.length - 1 : a + 2]; return n.set( gh(o, l.x, c.x, h.x, u.x), gh(o, l.y, c.y, h.y, u.y) ), n; } copy(e) { super.copy(e), this.points = []; for (let t = 0, n = e.points.length; t < n; t++) { const i = e.points[t]; this.points.push(i.clone()); } return this; } toJSON() { const e = super.toJSON(); e.points = []; for (let t = 0, n = this.points.length; t < n; t++) { const i = this.points[t]; e.points.push(i.toArray()); } return e; } fromJSON(e) { super.fromJSON(e), this.points = []; for (let t = 0, n = e.points.length; t < n; t++) { const i = e.points[t]; this.points.push(new ue().fromArray(i)); } return this; } } var Dl = /* @__PURE__ */ Object.freeze({ __proto__: null, ArcCurve: im, CatmullRomCurve3: sm, CubicBezierCurve: dd, CubicBezierCurve3: dm, EllipseCurve: hc, LineCurve: fd, LineCurve3: fm, QuadraticBezierCurve: pd, QuadraticBezierCurve3: pm, SplineCurve: md }); class mm extends jn { /** * Constructs a new curve path. */ constructor() { super(), this.type = "CurvePath", this.curves = [], this.autoClose = !1; } /** * Adds a curve to this curve path. * * @param {Curve} curve - The curve to add. */ add(e) { this.curves.push(e); } /** * Adds a line curve to close the path. * * @return {CurvePath} A reference to this curve path. */ closePath() { const e = this.curves[0].getPoint(0), t = this.curves[this.curves.length - 1].getPoint(1); if (!e.equals(t)) { const n = e.isVector2 === !0 ? "LineCurve" : "LineCurve3"; this.curves.push(new Dl[n](t, e)); } return this; } /** * This method returns a vector in 2D or 3D space (depending on the curve definitions) * for the given interpolation factor. * * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param {(Vector2|Vector3)} [optionalTarget] - The optional target vector the result is written to. * @return {?(Vector2|Vector3)} The position on the curve. It can be a 2D or 3D vector depending on the curve definition. */ getPoint(e, t) { const n = e * this.getLength(), i = this.getCurveLengths(); let r = 0; for (; r < i.length; ) { if (i[r] >= n) { const a = i[r] - n, o = this.curves[r], l = o.getLength(), c = l === 0 ? 0 : 1 - a / l; return o.getPointAt(c, t); } r++; } return null; } getLength() { const e = this.getCurveLengths(); return e[e.length - 1]; } updateArcLengths() { this.needsUpdate = !0, this.cacheLengths = null, this.getCurveLengths(); } /** * Returns list of cumulative curve lengths of the defined curves. * * @return {Array} The curve lengths. */ getCurveLengths() { if (this.cacheLengths && this.cacheLengths.length === this.curves.length) return this.cacheLengths; const e = []; let t = 0; for (let n = 0, i = this.curves.length; n < i; n++) t += this.curves[n].getLength(), e.push(t); return this.cacheLengths = e, e; } getSpacedPoints(e = 40) { const t = []; for (let n = 0; n <= e; n++) t.push(this.getPoint(n / e)); return this.autoClose && t.push(t[0]), t; } getPoints(e = 12) { const t = []; let n; for (let i = 0, r = this.curves; i < r.length; i++) { const a = r[i], o = a.isEllipseCurve ? e * 2 : a.isLineCurve || a.isLineCurve3 ? 1 : a.isSplineCurve ? e * a.points.length : e, l = a.getPoints(o); for (let c = 0; c < l.length; c++) { const h = l[c]; n && n.equals(h) || (t.push(h), n = h); } } return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t; } copy(e) { super.copy(e), this.curves = []; for (let t = 0, n = e.curves.length; t < n; t++) { const i = e.curves[t]; this.curves.push(i.clone()); } return this.autoClose = e.autoClose, this; } toJSON() { const e = super.toJSON(); e.autoClose = this.autoClose, e.curves = []; for (let t = 0, n = this.curves.length; t < n; t++) { const i = this.curves[t]; e.curves.push(i.toJSON()); } return e; } fromJSON(e) { super.fromJSON(e), this.autoClose = e.autoClose, this.curves = []; for (let t = 0, n = e.curves.length; t < n; t++) { const i = e.curves[t]; this.curves.push(new Dl[i.type]().fromJSON(i)); } return this; } } class xh extends mm { /** * Constructs a new path. * * @param {Array} [points] - An array of 2D points defining the path. */ constructor(e) { super(), this.type = "Path", this.currentPoint = new ue(), e && this.setFromPoints(e); } /** * Creates a path from the given list of points. The points are added * to the path as instances of {@link LineCurve}. * * @param {Array} points - An array of 2D points. * @return {Path} A reference to this path. */ setFromPoints(e) { this.moveTo(e[0].x, e[0].y); for (let t = 1, n = e.length; t < n; t++) this.lineTo(e[t].x, e[t].y); return this; } /** * Moves {@link Path#currentPoint} to the given point. * * @param {number} x - The x coordinate. * @param {number} y - The y coordinate. * @return {Path} A reference to this path. */ moveTo(e, t) { return this.currentPoint.set(e, t), this; } /** * Adds an instance of {@link LineCurve} to the path by connecting * the current point with the given one. * * @param {number} x - The x coordinate of the end point. * @param {number} y - The y coordinate of the end point. * @return {Path} A reference to this path. */ lineTo(e, t) { const n = new fd(this.currentPoint.clone(), new ue(e, t)); return this.curves.push(n), this.currentPoint.set(e, t), this; } /** * Adds an instance of {@link QuadraticBezierCurve} to the path by connecting * the current point with the given one. * * @param {number} aCPx - The x coordinate of the control point. * @param {number} aCPy - The y coordinate of the control point. * @param {number} aX - The x coordinate of the end point. * @param {number} aY - The y coordinate of the end point. * @return {Path} A reference to this path. */ quadraticCurveTo(e, t, n, i) { const r = new pd( this.currentPoint.clone(), new ue(e, t), new ue(n, i) ); return this.curves.push(r), this.currentPoint.set(n, i), this; } /** * Adds an instance of {@link CubicBezierCurve} to the path by connecting * the current point with the given one. * * @param {number} aCP1x - The x coordinate of the first control point. * @param {number} aCP1y - The y coordinate of the first control point. * @param {number} aCP2x - The x coordinate of the second control point. * @param {number} aCP2y - The y coordinate of the second control point. * @param {number} aX - The x coordinate of the end point. * @param {number} aY - The y coordinate of the end point. * @return {Path} A reference to this path. */ bezierCurveTo(e, t, n, i, r, a) { const o = new dd( this.currentPoint.clone(), new ue(e, t), new ue(n, i), new ue(r, a) ); return this.curves.push(o), this.currentPoint.set(r, a), this; } /** * Adds an instance of {@link SplineCurve} to the path by connecting * the current point with the given list of points. * * @param {Array} pts - An array of points in 2D space. * @return {Path} A reference to this path. */ splineThru(e) { const t = [this.currentPoint.clone()].concat(e), n = new md(t); return this.curves.push(n), this.currentPoint.copy(e[e.length - 1]), this; } /** * Adds an arc as an instance of {@link EllipseCurve} to the path, positioned relative * to the current point. * * @param {number} [aX=0] - The x coordinate of the center of the arc offsetted from the previous curve. * @param {number} [aY=0] - The y coordinate of the center of the arc offsetted from the previous curve. * @param {number} [aRadius=1] - The radius of the arc. * @param {number} [aStartAngle=0] - The start angle in radians. * @param {number} [aEndAngle=Math.PI*2] - The end angle in radians. * @param {boolean} [aClockwise=false] - Whether to sweep the arc clockwise or not. * @return {Path} A reference to this path. */ arc(e, t, n, i, r, a) { const o = this.currentPoint.x, l = this.currentPoint.y; return this.absarc( e + o, t + l, n, i, r, a ), this; } /** * Adds an absolutely positioned arc as an instance of {@link EllipseCurve} to the path. * * @param {number} [aX=0] - The x coordinate of the center of the arc. * @param {number} [aY=0] - The y coordinate of the center of the arc. * @param {number} [aRadius=1] - The radius of the arc. * @param {number} [aStartAngle=0] - The start angle in radians. * @param {number} [aEndAngle=Math.PI*2] - The end angle in radians. * @param {boolean} [aClockwise=false] - Whether to sweep the arc clockwise or not. * @return {Path} A reference to this path. */ absarc(e, t, n, i, r, a) { return this.absellipse(e, t, n, n, i, r, a), this; } /** * Adds an ellipse as an instance of {@link EllipseCurve} to the path, positioned relative * to the current point * * @param {number} [aX=0] - The x coordinate of the center of the ellipse offsetted from the previous curve. * @param {number} [aY=0] - The y coordinate of the center of the ellipse offsetted from the previous curve. * @param {number} [xRadius=1] - The radius of the ellipse in the x axis. * @param {number} [yRadius=1] - The radius of the ellipse in the y axis. * @param {number} [aStartAngle=0] - The start angle in radians. * @param {number} [aEndAngle=Math.PI*2] - The end angle in radians. * @param {boolean} [aClockwise=false] - Whether to sweep the ellipse clockwise or not. * @param {number} [aRotation=0] - The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. * @return {Path} A reference to this path. */ ellipse(e, t, n, i, r, a, o, l) { const c = this.currentPoint.x, h = this.currentPoint.y; return this.absellipse(e + c, t + h, n, i, r, a, o, l), this; } /** * Adds an absolutely positioned ellipse as an instance of {@link EllipseCurve} to the path. * * @param {number} [aX=0] - The x coordinate of the absolute center of the ellipse. * @param {number} [aY=0] - The y coordinate of the absolute center of the ellipse. * @param {number} [xRadius=1] - The radius of the ellipse in the x axis. * @param {number} [yRadius=1] - The radius of the ellipse in the y axis. * @param {number} [aStartAngle=0] - The start angle in radians. * @param {number} [aEndAngle=Math.PI*2] - The end angle in radians. * @param {boolean} [aClockwise=false] - Whether to sweep the ellipse clockwise or not. * @param {number} [aRotation=0] - The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. * @return {Path} A reference to this path. */ absellipse(e, t, n, i, r, a, o, l) { const c = new hc(e, t, n, i, r, a, o, l); if (this.curves.length > 0) { const u = c.getPoint(0); u.equals(this.currentPoint) || this.lineTo(u.x, u.y); } this.curves.push(c); const h = c.getPoint(1); return this.currentPoint.copy(h), this; } copy(e) { return super.copy(e), this.currentPoint.copy(e.currentPoint), this; } toJSON() { const e = super.toJSON(); return e.currentPoint = this.currentPoint.toArray(), e; } fromJSON(e) { return super.fromJSON(e), this.currentPoint.fromArray(e.currentPoint), this; } } class gd extends xh { /** * Constructs a new shape. * * @param {Array} [points] - An array of 2D points defining the shape. */ constructor(e) { super(e), this.uuid = yn(), this.type = "Shape", this.holes = []; } /** * Returns an array representing each contour of the holes * as a list of 2D points. * * @param {number} divisions - The fineness of the result. * @return {Array>} The holes as a series of 2D points. */ getPointsHoles(e) { const t = []; for (let n = 0, i = this.holes.length; n < i; n++) t[n] = this.holes[n].getPoints(e); return t; } // get points of shape and holes (keypoints based on segments parameter) /** * Returns an object that holds contour data for the shape and its holes as * arrays of 2D points. * * @param {number} divisions - The fineness of the result. * @return {{shape:Array,holes:Array>}} An object with contour data. */ extractPoints(e) { return { shape: this.getPoints(e), holes: this.getPointsHoles(e) }; } copy(e) { super.copy(e), this.holes = []; for (let t = 0, n = e.holes.length; t < n; t++) { const i = e.holes[t]; this.holes.push(i.clone()); } return this; } toJSON() { const e = super.toJSON(); e.uuid = this.uuid, e.holes = []; for (let t = 0, n = this.holes.length; t < n; t++) { const i = this.holes[t]; e.holes.push(i.toJSON()); } return e; } fromJSON(e) { super.fromJSON(e), this.uuid = e.uuid, this.holes = []; for (let t = 0, n = e.holes.length; t < n; t++) { const i = e.holes[t]; this.holes.push(new xh().fromJSON(i)); } return this; } } function gm(s, e, t = 2) { const n = e && e.length, i = n ? e[0] * t : s.length; let r = xd(s, 0, i, t, !0); const a = []; if (!r || r.next === r.prev) return a; let o, l, c; if (n && (r = ym(s, e, r, t)), s.length > 80 * t) { o = s[0], l = s[1]; let h = o, u = l; for (let f = t; f < i; f += t) { const d = s[f], p = s[f + 1]; d < o && (o = d), p < l && (l = p), d > h && (h = d), p > u && (u = p); } c = Math.max(h - o, u - l), c = c !== 0 ? 32767 / c : 0; } return cr(r, a, t, o, l, c, 0), a; } function xd(s, e, t, n, i) { let r; if (i === Dm(s, e, t, n) > 0) for (let a = e; a < t; a += n) r = vh(a / n | 0, s[a], s[a + 1], r); else for (let a = t - n; a >= e; a -= n) r = vh(a / n | 0, s[a], s[a + 1], r); return r && _s(r, r.next) && (ur(r), r = r.next), r; } function Di(s, e) { if (!s) return s; e || (e = s); let t = s, n; do if (n = !1, !t.steiner && (_s(t, t.next) || yt(t.prev, t, t.next) === 0)) { if (ur(t), t = e = t.prev, t === t.next) break; n = !0; } else t = t.next; while (n || t !== e); return e; } function cr(s, e, t, n, i, r, a) { if (!s) return; !a && r && Tm(s, n, i, r); let o = s; for (; s.prev !== s.next; ) { const l = s.prev, c = s.next; if (r ? vm(s, n, i, r) : xm(s)) { e.push(l.i, s.i, c.i), ur(s), s = c.next, o = c.next; continue; } if (s = c, s === o) { a ? a === 1 ? (s = bm(Di(s), e), cr(s, e, t, n, i, r, 2)) : a === 2 && _m(s, e, t, n, i, r) : cr(Di(s), e, t, n, i, r, 1); break; } } } function xm(s) { const e = s.prev, t = s, n = s.next; if (yt(e, t, n) >= 0) return !1; const i = e.x, r = t.x, a = n.x, o = e.y, l = t.y, c = n.y, h = Math.min(i, r, a), u = Math.min(o, l, c), f = Math.max(i, r, a), d = Math.max(o, l, c); let p = n.next; for (; p !== e; ) { if (p.x >= h && p.x <= f && p.y >= u && p.y <= d && Zs(i, o, r, l, a, c, p.x, p.y) && yt(p.prev, p, p.next) >= 0) return !1; p = p.next; } return !0; } function vm(s, e, t, n) { const i = s.prev, r = s, a = s.next; if (yt(i, r, a) >= 0) return !1; const o = i.x, l = r.x, c = a.x, h = i.y, u = r.y, f = a.y, d = Math.min(o, l, c), p = Math.min(h, u, f), g = Math.max(o, l, c), x = Math.max(h, u, f), m = Il(d, p, e, t, n), v = Il(g, x, e, t, n); let b = s.prevZ, M = s.nextZ; for (; b && b.z >= m && M && M.z <= v; ) { if (b.x >= d && b.x <= g && b.y >= p && b.y <= x && b !== i && b !== a && Zs(o, h, l, u, c, f, b.x, b.y) && yt(b.prev, b, b.next) >= 0 || (b = b.prevZ, M.x >= d && M.x <= g && M.y >= p && M.y <= x && M !== i && M !== a && Zs(o, h, l, u, c, f, M.x, M.y) && yt(M.prev, M, M.next) >= 0)) return !1; M = M.nextZ; } for (; b && b.z >= m; ) { if (b.x >= d && b.x <= g && b.y >= p && b.y <= x && b !== i && b !== a && Zs(o, h, l, u, c, f, b.x, b.y) && yt(b.prev, b, b.next) >= 0) return !1; b = b.prevZ; } for (; M && M.z <= v; ) { if (M.x >= d && M.x <= g && M.y >= p && M.y <= x && M !== i && M !== a && Zs(o, h, l, u, c, f, M.x, M.y) && yt(M.prev, M, M.next) >= 0) return !1; M = M.nextZ; } return !0; } function bm(s, e) { let t = s; do { const n = t.prev, i = t.next.next; !_s(n, i) && bd(n, t, t.next, i) && hr(n, i) && hr(i, n) && (e.push(n.i, t.i, i.i), ur(t), ur(t.next), t = s = i), t = t.next; } while (t !== s); return Di(t); } function _m(s, e, t, n, i, r) { let a = s; do { let o = a.next.next; for (; o !== a.prev; ) { if (a.i !== o.i && Pm(a, o)) { let l = _d(a, o); a = Di(a, a.next), l = Di(l, l.next), cr(a, e, t, n, i, r, 0), cr(l, e, t, n, i, r, 0); return; } o = o.next; } a = a.next; } while (a !== s); } function ym(s, e, t, n) { const i = []; for (let r = 0, a = e.length; r < a; r++) { const o = e[r] * n, l = r < a - 1 ? e[r + 1] * n : s.length, c = xd(s, o, l, n, !1); c === c.next && (c.steiner = !0), i.push(Am(c)); } i.sort(Mm); for (let r = 0; r < i.length; r++) t = Sm(i[r], t); return t; } function Mm(s, e) { let t = s.x - e.x; if (t === 0 && (t = s.y - e.y, t === 0)) { const n = (s.next.y - s.y) / (s.next.x - s.x), i = (e.next.y - e.y) / (e.next.x - e.x); t = n - i; } return t; } function Sm(s, e) { const t = wm(s, e); if (!t) return e; const n = _d(t, s); return Di(n, n.next), Di(t, t.next); } function wm(s, e) { let t = e; const n = s.x, i = s.y; let r = -1 / 0, a; if (_s(s, t)) return t; do { if (_s(s, t.next)) return t.next; if (i <= t.y && i >= t.next.y && t.next.y !== t.y) { const u = t.x + (i - t.y) * (t.next.x - t.x) / (t.next.y - t.y); if (u <= n && u > r && (r = u, a = t.x < t.next.x ? t : t.next, u === n)) return a; } t = t.next; } while (t !== e); if (!a) return null; const o = a, l = a.x, c = a.y; let h = 1 / 0; t = a; do { if (n >= t.x && t.x >= l && n !== t.x && vd(i < c ? n : r, i, l, c, i < c ? r : n, i, t.x, t.y)) { const u = Math.abs(i - t.y) / (n - t.x); hr(t, s) && (u < h || u === h && (t.x > a.x || t.x === a.x && Em(a, t))) && (a = t, h = u); } t = t.next; } while (t !== o); return a; } function Em(s, e) { return yt(s.prev, s, e.prev) < 0 && yt(e.next, s, s.next) < 0; } function Tm(s, e, t, n) { let i = s; do i.z === 0 && (i.z = Il(i.x, i.y, e, t, n)), i.prevZ = i.prev, i.nextZ = i.next, i = i.next; while (i !== s); i.prevZ.nextZ = null, i.prevZ = null, Cm(i); } function Cm(s) { let e, t = 1; do { let n = s, i; s = null; let r = null; for (e = 0; n; ) { e++; let a = n, o = 0; for (let c = 0; c < t && (o++, a = a.nextZ, !!a); c++) ; let l = t; for (; o > 0 || l > 0 && a; ) o !== 0 && (l === 0 || !a || n.z <= a.z) ? (i = n, n = n.nextZ, o--) : (i = a, a = a.nextZ, l--), r ? r.nextZ = i : s = i, i.prevZ = r, r = i; n = a; } r.nextZ = null, t *= 2; } while (e > 1); return s; } function Il(s, e, t, n, i) { return s = (s - t) * i | 0, e = (e - n) * i | 0, s = (s | s << 8) & 16711935, s = (s | s << 4) & 252645135, s = (s | s << 2) & 858993459, s = (s | s << 1) & 1431655765, e = (e | e << 8) & 16711935, e = (e | e << 4) & 252645135, e = (e | e << 2) & 858993459, e = (e | e << 1) & 1431655765, s | e << 1; } function Am(s) { let e = s, t = s; do (e.x < t.x || e.x === t.x && e.y < t.y) && (t = e), e = e.next; while (e !== s); return t; } function vd(s, e, t, n, i, r, a, o) { return (i - a) * (e - o) >= (s - a) * (r - o) && (s - a) * (n - o) >= (t - a) * (e - o) && (t - a) * (r - o) >= (i - a) * (n - o); } function Zs(s, e, t, n, i, r, a, o) { return !(s === a && e === o) && vd(s, e, t, n, i, r, a, o); } function Pm(s, e) { return s.next.i !== e.i && s.prev.i !== e.i && !Rm(s, e) && // doesn't intersect other edges (hr(s, e) && hr(e, s) && Lm(s, e) && // locally visible (yt(s.prev, s, e.prev) || yt(s, e.prev, e)) || // does not create opposite-facing sectors _s(s, e) && yt(s.prev, s, s.next) > 0 && yt(e.prev, e, e.next) > 0); } function yt(s, e, t) { return (e.y - s.y) * (t.x - e.x) - (e.x - s.x) * (t.y - e.y); } function _s(s, e) { return s.x === e.x && s.y === e.y; } function bd(s, e, t, n) { const i = Zr(yt(s, e, t)), r = Zr(yt(s, e, n)), a = Zr(yt(t, n, s)), o = Zr(yt(t, n, e)); return !!(i !== r && a !== o || i === 0 && jr(s, t, e) || r === 0 && jr(s, n, e) || a === 0 && jr(t, s, n) || o === 0 && jr(t, e, n)); } function jr(s, e, t) { return e.x <= Math.max(s.x, t.x) && e.x >= Math.min(s.x, t.x) && e.y <= Math.max(s.y, t.y) && e.y >= Math.min(s.y, t.y); } function Zr(s) { return s > 0 ? 1 : s < 0 ? -1 : 0; } function Rm(s, e) { let t = s; do { if (t.i !== s.i && t.next.i !== s.i && t.i !== e.i && t.next.i !== e.i && bd(t, t.next, s, e)) return !0; t = t.next; } while (t !== s); return !1; } function hr(s, e) { return yt(s.prev, s, s.next) < 0 ? yt(s, e, s.next) >= 0 && yt(s, s.prev, e) >= 0 : yt(s, e, s.prev) < 0 || yt(s, s.next, e) < 0; } function Lm(s, e) { let t = s, n = !1; const i = (s.x + e.x) / 2, r = (s.y + e.y) / 2; do t.y > r != t.next.y > r && t.next.y !== t.y && i < (t.next.x - t.x) * (r - t.y) / (t.next.y - t.y) + t.x && (n = !n), t = t.next; while (t !== s); return n; } function _d(s, e) { const t = Nl(s.i, s.x, s.y), n = Nl(e.i, e.x, e.y), i = s.next, r = e.prev; return s.next = e, e.prev = s, t.next = i, i.prev = t, n.next = t, t.prev = n, r.next = n, n.prev = r, n; } function vh(s, e, t, n) { const i = Nl(s, e, t); return n ? (i.next = n.next, i.prev = n, n.next.prev = i, n.next = i) : (i.prev = i, i.next = i), i; } function ur(s) { s.next.prev = s.prev, s.prev.next = s.next, s.prevZ && (s.prevZ.nextZ = s.nextZ), s.nextZ && (s.nextZ.prevZ = s.prevZ); } function Nl(s, e, t) { return { i: s, // vertex index in coordinates array x: e, y: t, // vertex coordinates prev: null, // previous and next vertex nodes in a polygon ring next: null, z: 0, // z-order curve value prevZ: null, // previous and next nodes in z-order nextZ: null, steiner: !1 // indicates whether this is a steiner point }; } function Dm(s, e, t, n) { let i = 0; for (let r = e, a = t - n; r < t; r += n) i += (s[a] - s[r]) * (s[r + 1] + s[a + 1]), a = r; return i; } class Im { /** * Triangulates the given shape definition by returning an array of triangles. * * @param {Array} data - An array with 2D points. * @param {Array} holeIndices - An array with indices defining holes. * @param {number} [dim=2] - The number of coordinates per vertex in the input array. * @return {Array} An array representing the triangulated faces. Each face is defined by three consecutive numbers * representing vertex indices. */ static triangulate(e, t, n = 2) { return gm(e, t, n); } } class as { /** * Calculate area of a ( 2D ) contour polygon. * * @param {Array} contour - An array of 2D points. * @return {number} The area. */ static area(e) { const t = e.length; let n = 0; for (let i = t - 1, r = 0; r < t; i = r++) n += e[i].x * e[r].y - e[r].x * e[i].y; return n * 0.5; } /** * Returns `true` if the given contour uses a clockwise winding order. * * @param {Array} pts - An array of 2D points defining a polygon. * @return {boolean} Whether the given contour uses a clockwise winding order or not. */ static isClockWise(e) { return as.area(e) < 0; } /** * Triangulates the given shape definition. * * @param {Array} contour - An array of 2D points defining the contour. * @param {Array>} holes - An array that holds arrays of 2D points defining the holes. * @return {Array>} An array that holds for each face definition an array with three indices. */ static triangulateShape(e, t) { const n = [], i = [], r = []; bh(e), _h(n, e); let a = e.length; t.forEach(bh); for (let l = 0; l < t.length; l++) i.push(a), a += t[l].length, _h(n, t[l]); const o = Im.triangulate(n, i); for (let l = 0; l < o.length; l += 3) r.push(o.slice(l, l + 3)); return r; } } function bh(s) { const e = s.length; e > 2 && s[e - 1].equals(s[0]) && s.pop(); } function _h(s, e) { for (let t = 0; t < e.length; t++) s.push(e[t].x), s.push(e[t].y); } class dc extends xt { /** * Constructs a new extrude geometry. * * @param {Shape|Array} [shapes] - A shape or an array of shapes. * @param {ExtrudeGeometry~Options} [options] - The extrude settings. */ constructor(e = new gd([new ue(0.5, 0.5), new ue(-0.5, 0.5), new ue(-0.5, -0.5), new ue(0.5, -0.5)]), t = {}) { super(), this.type = "ExtrudeGeometry", this.parameters = { shapes: e, options: t }, e = Array.isArray(e) ? e : [e]; const n = this, i = [], r = []; for (let o = 0, l = e.length; o < l; o++) { const c = e[o]; a(c); } this.setAttribute("position", new an(i, 3)), this.setAttribute("uv", new an(r, 2)), this.computeVertexNormals(); function a(o) { const l = [], c = t.curveSegments !== void 0 ? t.curveSegments : 12, h = t.steps !== void 0 ? t.steps : 1, u = t.depth !== void 0 ? t.depth : 1; let f = t.bevelEnabled !== void 0 ? t.bevelEnabled : !0, d = t.bevelThickness !== void 0 ? t.bevelThickness : 0.2, p = t.bevelSize !== void 0 ? t.bevelSize : d - 0.1, g = t.bevelOffset !== void 0 ? t.bevelOffset : 0, x = t.bevelSegments !== void 0 ? t.bevelSegments : 3; const m = t.extrudePath, v = t.UVGenerator !== void 0 ? t.UVGenerator : Nm; let b, M = !1, C, T, D, U; m && (b = m.getSpacedPoints(h), M = !0, f = !1, C = m.computeFrenetFrames(h, !1), T = new R(), D = new R(), U = new R()), f || (x = 0, d = 0, p = 0, g = 0); const S = o.extractPoints(c); let w = S.shape; const B = S.holes; if (!as.isClockWise(w)) { w = w.reverse(); for (let _ = 0, A = B.length; _ < A; _++) { const V = B[_]; as.isClockWise(V) && (B[_] = V.reverse()); } } function O(_) { const V = 10000000000000001e-36; let N = _[0]; for (let I = 1; I <= _.length; I++) { const F = I % _.length, ee = _[F], $ = ee.x - N.x, G = ee.y - N.y, L = $ * $ + G * G, E = Math.max( Math.abs(ee.x), Math.abs(ee.y), Math.abs(N.x), Math.abs(N.y) ), z = V * E * E; if (L <= z) { _.splice(F, 1), I--; continue; } N = ee; } } O(w), B.forEach(O); const y = B.length, H = w; for (let _ = 0; _ < y; _++) { const A = B[_]; w = w.concat(A); } function Y(_, A, V) { return A || et("ExtrudeGeometry: vec does not exist"), _.clone().addScaledVector(A, V); } const j = w.length; function J(_, A, V) { let N, I, F; const ee = _.x - A.x, $ = _.y - A.y, G = V.x - _.x, L = V.y - _.y, E = ee * ee + $ * $, z = ee * L - $ * G; if (Math.abs(z) > Number.EPSILON) { const K = Math.sqrt(E), le = Math.sqrt(G * G + L * L), te = A.x - $ / K, Te = A.y + ee / K, be = V.x - L / le, Re = V.y + G / le, De = ((be - te) * L - (Re - Te) * G) / (ee * L - $ * G); N = te + ee * De - _.x, I = Te + $ * De - _.y; const he = N * N + I * I; if (he <= 2) return new ue(N, I); F = Math.sqrt(he / 2); } else { let K = !1; ee > Number.EPSILON ? G > Number.EPSILON && (K = !0) : ee < -Number.EPSILON ? G < -Number.EPSILON && (K = !0) : Math.sign($) === Math.sign(L) && (K = !0), K ? (N = -$, I = ee, F = Math.sqrt(E)) : (N = ee, I = $, F = Math.sqrt(E / 2)); } return new ue(N / F, I / F); } const Z = []; for (let _ = 0, A = H.length, V = A - 1, N = _ + 1; _ < A; _++, V++, N++) V === A && (V = 0), N === A && (N = 0), Z[_] = J(H[_], H[V], H[N]); const ae = []; let X, q = Z.concat(); for (let _ = 0, A = y; _ < A; _++) { const V = B[_]; X = []; for (let N = 0, I = V.length, F = I - 1, ee = N + 1; N < I; N++, F++, ee++) F === I && (F = 0), ee === I && (ee = 0), X[N] = J(V[N], V[F], V[ee]); ae.push(X), q = q.concat(X); } let ge; if (x === 0) ge = as.triangulateShape(H, B); else { const _ = [], A = []; for (let V = 0; V < x; V++) { const N = V / x, I = d * Math.cos(N * Math.PI / 2), F = p * Math.sin(N * Math.PI / 2) + g; for (let ee = 0, $ = H.length; ee < $; ee++) { const G = Y(H[ee], Z[ee], F); ve(G.x, G.y, -I), N === 0 && _.push(G); } for (let ee = 0, $ = y; ee < $; ee++) { const G = B[ee]; X = ae[ee]; const L = []; for (let E = 0, z = G.length; E < z; E++) { const K = Y(G[E], X[E], F); ve(K.x, K.y, -I), N === 0 && L.push(K); } N === 0 && A.push(L); } } ge = as.triangulateShape(_, A); } const pe = ge.length, de = p + g; for (let _ = 0; _ < j; _++) { const A = f ? Y(w[_], q[_], de) : w[_]; M ? (D.copy(C.normals[0]).multiplyScalar(A.x), T.copy(C.binormals[0]).multiplyScalar(A.y), U.copy(b[0]).add(D).add(T), ve(U.x, U.y, U.z)) : ve(A.x, A.y, 0); } for (let _ = 1; _ <= h; _++) for (let A = 0; A < j; A++) { const V = f ? Y(w[A], q[A], de) : w[A]; M ? (D.copy(C.normals[_]).multiplyScalar(V.x), T.copy(C.binormals[_]).multiplyScalar(V.y), U.copy(b[_]).add(D).add(T), ve(U.x, U.y, U.z)) : ve(V.x, V.y, u / h * _); } for (let _ = x - 1; _ >= 0; _--) { const A = _ / x, V = d * Math.cos(A * Math.PI / 2), N = p * Math.sin(A * Math.PI / 2) + g; for (let I = 0, F = H.length; I < F; I++) { const ee = Y(H[I], Z[I], N); ve(ee.x, ee.y, u + V); } for (let I = 0, F = B.length; I < F; I++) { const ee = B[I]; X = ae[I]; for (let $ = 0, G = ee.length; $ < G; $++) { const L = Y(ee[$], X[$], N); M ? ve(L.x, L.y + b[h - 1].y, b[h - 1].x + V) : ve(L.x, L.y, u + V); } } } ie(), ce(); function ie() { const _ = i.length / 3; if (f) { let A = 0, V = j * A; for (let N = 0; N < pe; N++) { const I = ge[N]; Ee(I[2] + V, I[1] + V, I[0] + V); } A = h + x * 2, V = j * A; for (let N = 0; N < pe; N++) { const I = ge[N]; Ee(I[0] + V, I[1] + V, I[2] + V); } } else { for (let A = 0; A < pe; A++) { const V = ge[A]; Ee(V[2], V[1], V[0]); } for (let A = 0; A < pe; A++) { const V = ge[A]; Ee(V[0] + j * h, V[1] + j * h, V[2] + j * h); } } n.addGroup(_, i.length / 3 - _, 0); } function ce() { const _ = i.length / 3; let A = 0; fe(H, A), A += H.length; for (let V = 0, N = B.length; V < N; V++) { const I = B[V]; fe(I, A), A += I.length; } n.addGroup(_, i.length / 3 - _, 1); } function fe(_, A) { let V = _.length; for (; --V >= 0; ) { const N = V; let I = V - 1; I < 0 && (I = _.length - 1); for (let F = 0, ee = h + x * 2; F < ee; F++) { const $ = j * F, G = j * (F + 1), L = A + N + $, E = A + I + $, z = A + I + G, K = A + N + G; Ne(L, E, z, K); } } } function ve(_, A, V) { l.push(_), l.push(A), l.push(V); } function Ee(_, A, V) { Ye(_), Ye(A), Ye(V); const N = i.length / 3, I = v.generateTopUV(n, i, N - 3, N - 2, N - 1); ke(I[0]), ke(I[1]), ke(I[2]); } function Ne(_, A, V, N) { Ye(_), Ye(A), Ye(N), Ye(A), Ye(V), Ye(N); const I = i.length / 3, F = v.generateSideWallUV(n, i, I - 6, I - 3, I - 2, I - 1); ke(F[0]), ke(F[1]), ke(F[3]), ke(F[1]), ke(F[2]), ke(F[3]); } function Ye(_) { i.push(l[_ * 3 + 0]), i.push(l[_ * 3 + 1]), i.push(l[_ * 3 + 2]); } function ke(_) { r.push(_.x), r.push(_.y); } } } copy(e) { return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; } toJSON() { const e = super.toJSON(), t = this.parameters.shapes, n = this.parameters.options; return km(t, n, e); } /** * Factory method for creating an instance of this class from the given * JSON object. * * @param {Object} data - A JSON object representing the serialized geometry. * @param {Array} shapes - An array of shapes. * @return {ExtrudeGeometry} A new instance. */ static fromJSON(e, t) { const n = []; for (let r = 0, a = e.shapes.length; r < a; r++) { const o = t[e.shapes[r]]; n.push(o); } const i = e.options.extrudePath; return i !== void 0 && (e.options.extrudePath = new Dl[i.type]().fromJSON(i)), new dc(n, e.options); } } const Nm = { generateTopUV: function(s, e, t, n, i) { const r = e[t * 3], a = e[t * 3 + 1], o = e[n * 3], l = e[n * 3 + 1], c = e[i * 3], h = e[i * 3 + 1]; return [ new ue(r, a), new ue(o, l), new ue(c, h) ]; }, generateSideWallUV: function(s, e, t, n, i, r) { const a = e[t * 3], o = e[t * 3 + 1], l = e[t * 3 + 2], c = e[n * 3], h = e[n * 3 + 1], u = e[n * 3 + 2], f = e[i * 3], d = e[i * 3 + 1], p = e[i * 3 + 2], g = e[r * 3], x = e[r * 3 + 1], m = e[r * 3 + 2]; return Math.abs(o - h) < Math.abs(a - c) ? [ new ue(a, 1 - l), new ue(c, 1 - u), new ue(f, 1 - p), new ue(g, 1 - m) ] : [ new ue(o, 1 - l), new ue(h, 1 - u), new ue(d, 1 - p), new ue(x, 1 - m) ]; } }; function km(s, e, t) { if (t.shapes = [], Array.isArray(s)) for (let n = 0, i = s.length; n < i; n++) { const r = s[n]; t.shapes.push(r.uuid); } else t.shapes.push(s.uuid); return t.options = Object.assign({}, e), e.extrudePath !== void 0 && (t.options.extrudePath = e.extrudePath.toJSON()), t; } class Ii extends xt { /** * Constructs a new plane geometry. * * @param {number} [width=1] - The width along the X axis. * @param {number} [height=1] - The height along the Y axis * @param {number} [widthSegments=1] - The number of segments along the X axis. * @param {number} [heightSegments=1] - The number of segments along the Y axis. */ constructor(e = 1, t = 1, n = 1, i = 1) { super(), this.type = "PlaneGeometry", this.parameters = { width: e, height: t, widthSegments: n, heightSegments: i }; const r = e / 2, a = t / 2, o = Math.floor(n), l = Math.floor(i), c = o + 1, h = l + 1, u = e / o, f = t / l, d = [], p = [], g = [], x = []; for (let m = 0; m < h; m++) { const v = m * f - a; for (let b = 0; b < c; b++) { const M = b * u - r; p.push(M, -v, 0), g.push(0, 0, 1), x.push(b / o), x.push(1 - m / l); } } for (let m = 0; m < l; m++) for (let v = 0; v < o; v++) { const b = v + c * m, M = v + c * (m + 1), C = v + 1 + c * (m + 1), T = v + 1 + c * m; d.push(b, M, T), d.push(M, C, T); } this.setIndex(d), this.setAttribute("position", new an(p, 3)), this.setAttribute("normal", new an(g, 3)), this.setAttribute("uv", new an(x, 2)); } copy(e) { return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; } /** * Factory method for creating an instance of this class from the given * JSON object. * * @param {Object} data - A JSON object representing the serialized geometry. * @return {PlaneGeometry} A new instance. */ static fromJSON(e) { return new Ii(e.width, e.height, e.widthSegments, e.heightSegments); } } class Um extends Pt { /** * Constructs a new raw shader material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(e), this.isRawShaderMaterial = !0, this.type = "RawShaderMaterial"; } } class Cs extends mn { /** * Constructs a new mesh standard material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isMeshStandardMaterial = !0, this.type = "MeshStandardMaterial", this.defines = { STANDARD: "" }, this.color = new Fe(16777215), this.roughness = 1, this.metalness = 0, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new Fe(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = fr, this.normalScale = new ue(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 cn(), 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 In extends Cs { /** * Constructs a new mesh physical material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ 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 ue(1, 1), this.clearcoatNormalMap = null, this.ior = 1.5, Object.defineProperty(this, "reflectivity", { get: function() { return Je(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1); }, set: function(t) { this.ior = (1 + 0.4 * t) / (1 - 0.4 * t); } }), this.iridescenceMap = null, this.iridescenceIOR = 1.3, this.iridescenceThicknessRange = [100, 400], this.iridescenceThicknessMap = null, this.sheenColor = new Fe(0), this.sheenColorMap = null, this.sheenRoughness = 1, this.sheenRoughnessMap = null, this.transmissionMap = null, this.thickness = 0, this.thicknessMap = null, this.attenuationDistance = 1 / 0, this.attenuationColor = new Fe(1, 1, 1), this.specularIntensity = 1, this.specularIntensityMap = null, this.specularColor = new Fe(1, 1, 1), this.specularColorMap = null, this._anisotropy = 0, this._clearcoat = 0, this._dispersion = 0, this._iridescence = 0, this._sheen = 0, this._transmission = 0, this.setValues(e); } /** * The anisotropy strength, from `0.0` to `1.0`. * * @type {number} * @default 0 */ get anisotropy() { return this._anisotropy; } set anisotropy(e) { this._anisotropy > 0 != e > 0 && this.version++, this._anisotropy = e; } /** * Represents the intensity of the clear coat layer, from `0.0` to `1.0`. Use * clear coat related properties to enable multilayer materials that have a * thin translucent layer over the base layer. * * @type {number} * @default 0 */ get clearcoat() { return this._clearcoat; } set clearcoat(e) { this._clearcoat > 0 != e > 0 && this.version++, this._clearcoat = e; } /** * The intensity of the iridescence layer, simulating RGB color shift based on the angle between * the surface and the viewer, from `0.0` to `1.0`. * * @type {number} * @default 0 */ get iridescence() { return this._iridescence; } set iridescence(e) { this._iridescence > 0 != e > 0 && this.version++, this._iridescence = e; } /** * Defines the strength of the angular separation of colors (chromatic aberration) transmitting * through a relatively clear volume. Any value zero or larger is valid, the typical range of * realistic values is `[0, 1]`. This property can be only be used with transmissive objects. * * @type {number} * @default 0 */ get dispersion() { return this._dispersion; } set dispersion(e) { this._dispersion > 0 != e > 0 && this.version++, this._dispersion = e; } /** * The intensity of the sheen layer, from `0.0` to `1.0`. * * @type {number} * @default 0 */ get sheen() { return this._sheen; } set sheen(e) { this._sheen > 0 != e > 0 && this.version++, this._sheen = e; } /** * Degree of transmission (or optical transparency), from `0.0` to `1.0`. * * Thin, transparent or semitransparent, plastic or glass materials remain * largely reflective even if they are fully transmissive. The transmission * property can be used to model these materials. * * When transmission is non-zero, `opacity` should be set to `1`. * * @type {number} * @default 0 */ 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 Bm extends mn { /** * Constructs a new mesh phong material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isMeshPhongMaterial = !0, this.type = "MeshPhongMaterial", this.color = new Fe(16777215), this.specular = new Fe(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new Fe(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = fr, this.normalScale = new ue(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new cn(), this.combine = Ca, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.fog = !0, this.setValues(e); } copy(e) { return super.copy(e), this.color.copy(e.color), this.specular.copy(e.specular), this.shininess = e.shininess, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.combine = e.combine, this.reflectivity = e.reflectivity, this.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 Om extends mn { /** * Constructs a new mesh normal material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isMeshNormalMaterial = !0, this.type = "MeshNormalMaterial", this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = fr, this.normalScale = new ue(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 yd extends mn { /** * Constructs a new mesh lambert material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isMeshLambertMaterial = !0, this.type = "MeshLambertMaterial", this.color = new Fe(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new Fe(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = fr, this.normalScale = new ue(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new cn(), this.combine = Ca, this.reflectivity = 1, this.refractionRatio = 0.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 Fm extends mn { /** * Constructs a new mesh depth material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ constructor(e) { super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = Kf, 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 zm extends mn { /** * Constructs a new mesh distance material. * * @param {Object} [parameters] - An object with one or more properties * defining the material's appearance. Any property of the material * (including any property from inherited materials) can be passed * in here. Color values can be passed any type of value accepted * by {@link Color#set}. */ 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 qr(s, e) { return !s || s.constructor === e ? s : typeof e.BYTES_PER_ELEMENT == "number" ? new e(s) : Array.prototype.slice.call(s); } function Hm(s) { return ArrayBuffer.isView(s) && !(s instanceof DataView); } function Vm(s) { function e(i, r) { return s[i] - s[r]; } const t = s.length, n = new Array(t); for (let i = 0; i !== t; ++i) n[i] = i; return n.sort(e), n; } function yh(s, e, t) { const n = s.length, i = new s.constructor(n); for (let r = 0, a = 0; a !== n; ++r) { const o = t[r] * e; for (let l = 0; l !== e; ++l) i[a++] = s[o + l]; } return i; } function Md(s, e, t, n) { let i = 1, r = s[0]; for (; r !== void 0 && r[n] === void 0; ) r = s[i++]; if (r === void 0) return; let a = r[n]; if (a !== void 0) if (Array.isArray(a)) do a = r[n], a !== void 0 && (e.push(r.time), t.push(...a)), r = s[i++]; while (r !== void 0); else if (a.toArray !== void 0) do a = r[n], a !== void 0 && (e.push(r.time), a.toArray(t, t.length)), r = s[i++]; while (r !== void 0); else do a = r[n], a !== void 0 && (e.push(r.time), t.push(a)), r = s[i++]; while (r !== void 0); } class mr { /** * Constructs a new interpolant. * * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors. * @param {TypedArray} sampleValues - The sample values. * @param {number} sampleSize - The sample size * @param {TypedArray} [resultBuffer] - The result buffer. */ constructor(e, t, n, i) { this.parameterPositions = e, this._cachedIndex = 0, this.resultBuffer = i !== void 0 ? i : new t.constructor(n), this.sampleValues = t, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {}; } /** * Evaluate the interpolant at position `t`. * * @param {number} t - The interpolation factor. * @return {TypedArray} The result buffer. */ evaluate(e) { const t = this.parameterPositions; let n = this._cachedIndex, i = t[n], r = t[n - 1]; e: { t: { let a; n: { i: if (!(e < i)) { for (let o = n + 2; ; ) { if (i === void 0) { if (e < r) break i; return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1); } if (n === o) break; if (r = i, i = t[++n], e < i) break t; } a = t.length; break n; } if (!(e >= r)) { const o = t[1]; e < o && (n = 2, r = o); for (let l = n - 2; ; ) { if (r === void 0) return this._cachedIndex = 0, this.copySampleValue_(0); if (n === l) break; if (i = r, r = t[--n - 1], e >= r) break t; } a = n, n = 0; break n; } break e; } for (; n < a; ) { const o = n + a >>> 1; e < t[o] ? a = o : n = o + 1; } if (i = t[n], r = t[n - 1], r === void 0) return this._cachedIndex = 0, this.copySampleValue_(0); if (i === void 0) return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1); } this._cachedIndex = n, this.intervalChanged_(n, r, i); } return this.interpolate_(n, r, e, i); } /** * Returns the interpolation settings. * * @return {Object} The interpolation settings. */ getSettings_() { return this.settings || this.DefaultSettings_; } /** * Copies a sample value to the result buffer. * * @param {number} index - An index into the sample value buffer. * @return {TypedArray} The result buffer. */ copySampleValue_(e) { const t = this.resultBuffer, n = this.sampleValues, i = this.valueSize, r = e * i; for (let a = 0; a !== i; ++a) t[a] = n[r + a]; return t; } /** * Copies a sample value to the result buffer. * * @abstract * @param {number} i1 - An index into the sample value buffer. * @param {number} t0 - The previous interpolation factor. * @param {number} t - The current interpolation factor. * @param {number} t1 - The next interpolation factor. * @return {TypedArray} The result buffer. */ interpolate_() { throw new Error("call to abstract method"); } /** * Optional method that is executed when the interval has changed. * * @param {number} i1 - An index into the sample value buffer. * @param {number} t0 - The previous interpolation factor. * @param {number} t - The current interpolation factor. */ intervalChanged_() { } } class Gm extends mr { /** * Constructs a new cubic interpolant. * * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors. * @param {TypedArray} sampleValues - The sample values. * @param {number} sampleSize - The sample size * @param {TypedArray} [resultBuffer] - The result buffer. */ constructor(e, t, n, i) { super(e, t, n, i), this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = { endingStart: Nc, endingEnd: Nc }; } intervalChanged_(e, t, n) { const i = this.parameterPositions; let r = e - 2, a = e + 1, o = i[r], l = i[a]; if (o === void 0) switch (this.getSettings_().endingStart) { case kc: r = e, o = 2 * t - n; break; case Uc: r = i.length - 2, o = t + i[r] - i[r + 1]; break; default: r = e, o = n; } if (l === void 0) switch (this.getSettings_().endingEnd) { case kc: a = e, l = 2 * n - t; break; case Uc: a = 1, l = n + i[1] - i[0]; break; default: a = e - 1, l = t; } const c = (n - t) * 0.5, h = this.valueSize; this._weightPrev = c / (t - o), this._weightNext = c / (l - n), this._offsetPrev = r * h, this._offsetNext = a * h; } interpolate_(e, t, n, i) { const r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, l = e * o, c = l - o, h = this._offsetPrev, u = this._offsetNext, f = this._weightPrev, d = this._weightNext, p = (n - t) / (i - t), g = p * p, x = g * p, m = -f * x + 2 * f * g - f * p, v = (1 + f) * x + (-1.5 - 2 * f) * g + (-0.5 + f) * p + 1, b = (-1 - d) * x + (1.5 + d) * g + 0.5 * p, M = d * x - d * g; for (let C = 0; C !== o; ++C) r[C] = m * a[h + C] + v * a[c + C] + b * a[l + C] + M * a[u + C]; return r; } } class Wm extends mr { /** * Constructs a new linear interpolant. * * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors. * @param {TypedArray} sampleValues - The sample values. * @param {number} sampleSize - The sample size * @param {TypedArray} [resultBuffer] - The result buffer. */ constructor(e, t, n, i) { super(e, t, n, i); } interpolate_(e, t, n, i) { const r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, l = e * o, c = l - o, h = (n - t) / (i - t), u = 1 - h; for (let f = 0; f !== o; ++f) r[f] = a[c + f] * u + a[l + f] * h; return r; } } class Xm extends mr { /** * Constructs a new discrete interpolant. * * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors. * @param {TypedArray} sampleValues - The sample values. * @param {number} sampleSize - The sample size * @param {TypedArray} [resultBuffer] - The result buffer. */ constructor(e, t, n, i) { super(e, t, n, i); } interpolate_(e) { return this.copySampleValue_(e - 1); } } class Nn { /** * Constructs a new keyframe track. * * @param {string} name - The keyframe track's name. * @param {Array} times - A list of keyframe times. * @param {Array} values - A list of keyframe values. * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type. */ constructor(e, t, n, i) { if (e === void 0) throw new Error("THREE.KeyframeTrack: track name is undefined"); if (t === void 0 || t.length === 0) throw new Error("THREE.KeyframeTrack: no keyframes in track named " + e); this.name = e, this.times = qr(t, this.TimeBufferType), this.values = qr(n, this.ValueBufferType), this.setInterpolation(i || this.DefaultInterpolation); } /** * Converts the keyframe track to JSON. * * @static * @param {KeyframeTrack} track - The keyframe track to serialize. * @return {Object} The serialized keyframe track as JSON. */ static toJSON(e) { const t = e.constructor; let n; if (t.toJSON !== this.toJSON) n = t.toJSON(e); else { n = { name: e.name, times: qr(e.times, Array), values: qr(e.values, Array) }; const i = e.getInterpolation(); i !== e.DefaultInterpolation && (n.interpolation = i); } return n.type = e.ValueTypeName, n; } /** * Factory method for creating a new discrete interpolant. * * @static * @param {TypedArray} [result] - The result buffer. * @return {DiscreteInterpolant} The new interpolant. */ InterpolantFactoryMethodDiscrete(e) { return new Xm(this.times, this.values, this.getValueSize(), e); } /** * Factory method for creating a new linear interpolant. * * @static * @param {TypedArray} [result] - The result buffer. * @return {LinearInterpolant} The new interpolant. */ InterpolantFactoryMethodLinear(e) { return new Wm(this.times, this.values, this.getValueSize(), e); } /** * Factory method for creating a new smooth interpolant. * * @static * @param {TypedArray} [result] - The result buffer. * @return {CubicInterpolant} The new interpolant. */ InterpolantFactoryMethodSmooth(e) { return new Gm(this.times, this.values, this.getValueSize(), e); } /** * Defines the interpolation factor method for this keyframe track. * * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} interpolation - The interpolation type. * @return {KeyframeTrack} A reference to this keyframe track. */ setInterpolation(e) { let t; switch (e) { case rr: t = this.InterpolantFactoryMethodDiscrete; break; case ar: t = this.InterpolantFactoryMethodLinear; break; case Ha: t = this.InterpolantFactoryMethodSmooth; break; } if (t === void 0) { const n = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name; if (this.createInterpolant === void 0) if (e !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation); else throw new Error(n); return ze("KeyframeTrack:", n), this; } return this.createInterpolant = t, this; } /** * Returns the current interpolation type. * * @return {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} The interpolation type. */ getInterpolation() { switch (this.createInterpolant) { case this.InterpolantFactoryMethodDiscrete: return rr; case this.InterpolantFactoryMethodLinear: return ar; case this.InterpolantFactoryMethodSmooth: return Ha; } } /** * Returns the value size. * * @return {number} The value size. */ getValueSize() { return this.values.length / this.times.length; } /** * Moves all keyframes either forward or backward in time. * * @param {number} timeOffset - The offset to move the time values. * @return {KeyframeTrack} A reference to this keyframe track. */ shift(e) { if (e !== 0) { const t = this.times; for (let n = 0, i = t.length; n !== i; ++n) t[n] += e; } return this; } /** * Scale all keyframe times by a factor (useful for frame - seconds conversions). * * @param {number} timeScale - The time scale. * @return {KeyframeTrack} A reference to this keyframe track. */ scale(e) { if (e !== 1) { const t = this.times; for (let n = 0, i = t.length; n !== i; ++n) t[n] *= e; } return this; } /** * Removes keyframes before and after animation without changing any values within the defined time range. * * Note: The method does not shift around keys to the start of the track time, because for interpolated * keys this will change their values * * @param {number} startTime - The start time. * @param {number} endTime - The end time. * @return {KeyframeTrack} A reference to this keyframe track. */ trim(e, t) { const n = this.times, i = n.length; let r = 0, a = i - 1; for (; r !== i && n[r] < e; ) ++r; for (; a !== -1 && n[a] > t; ) --a; if (++a, r !== 0 || a !== i) { r >= a && (a = Math.max(a, 1), r = a - 1); const o = this.getValueSize(); this.times = n.slice(r, a), this.values = this.values.slice(r * o, a * o); } return this; } /** * Performs minimal validation on the keyframe track. Returns `true` if the values * are valid. * * @return {boolean} Whether the keyframes are valid or not. */ validate() { let e = !0; const t = this.getValueSize(); t - Math.floor(t) !== 0 && (et("KeyframeTrack: Invalid value size in track.", this), e = !1); const n = this.times, i = this.values, r = n.length; r === 0 && (et("KeyframeTrack: Track is empty.", this), e = !1); let a = null; for (let o = 0; o !== r; o++) { const l = n[o]; if (typeof l == "number" && isNaN(l)) { et("KeyframeTrack: Time is not a valid number.", this, o, l), e = !1; break; } if (a !== null && a > l) { et("KeyframeTrack: Out of order keys.", this, o, l, a), e = !1; break; } a = l; } if (i !== void 0 && Hm(i)) for (let o = 0, l = i.length; o !== l; ++o) { const c = i[o]; if (isNaN(c)) { et("KeyframeTrack: Value is not a valid number.", this, o, c), e = !1; break; } } return e; } /** * Optimizes this keyframe track by removing equivalent sequential keys (which are * common in morph target sequences). * * @return {AnimationClip} A reference to this animation clip. */ optimize() { const e = this.times.slice(), t = this.values.slice(), n = this.getValueSize(), i = this.getInterpolation() === Ha, r = e.length - 1; let a = 1; for (let o = 1; o < r; ++o) { let l = !1; const c = e[o], h = e[o + 1]; if (c !== h && (o !== 1 || c !== e[0])) if (i) l = !0; else { const u = o * n, f = u - n, d = u + n; for (let p = 0; p !== n; ++p) { const g = t[u + p]; if (g !== t[f + p] || g !== t[d + p]) { l = !0; break; } } } if (l) { if (o !== a) { e[a] = e[o]; const u = o * n, f = a * n; for (let d = 0; d !== n; ++d) t[f + d] = t[u + d]; } ++a; } } if (r > 0) { e[a] = e[r]; for (let o = r * n, l = a * n, c = 0; c !== n; ++c) t[l + c] = t[o + c]; ++a; } return a !== e.length ? (this.times = e.slice(0, a), this.values = t.slice(0, a * n)) : (this.times = e, this.values = t), this; } /** * Returns a new keyframe track with copied values from this instance. * * @return {KeyframeTrack} A clone of this instance. */ clone() { const e = this.times.slice(), t = this.values.slice(), n = this.constructor, i = new n(this.name, e, t); return i.createInterpolant = this.createInterpolant, i; } } Nn.prototype.ValueTypeName = ""; Nn.prototype.TimeBufferType = Float32Array; Nn.prototype.ValueBufferType = Float32Array; Nn.prototype.DefaultInterpolation = ar; class As extends Nn { /** * Constructs a new boolean keyframe track. * * This keyframe track type has no `interpolation` parameter because the * interpolation is always discrete. * * @param {string} name - The keyframe track's name. * @param {Array} times - A list of keyframe times. * @param {Array} values - A list of keyframe values. */ constructor(e, t, n) { super(e, t, n); } } As.prototype.ValueTypeName = "bool"; As.prototype.ValueBufferType = Array; As.prototype.DefaultInterpolation = rr; As.prototype.InterpolantFactoryMethodLinear = void 0; As.prototype.InterpolantFactoryMethodSmooth = void 0; class Sd extends Nn { /** * Constructs a new color keyframe track. * * @param {string} name - The keyframe track's name. * @param {Array} times - A list of keyframe times. * @param {Array} values - A list of keyframe values. * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type. */ constructor(e, t, n, i) { super(e, t, n, i); } } Sd.prototype.ValueTypeName = "color"; class ys extends Nn { /** * Constructs a new number keyframe track. * * @param {string} name - The keyframe track's name. * @param {Array} times - A list of keyframe times. * @param {Array} values - A list of keyframe values. * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type. */ constructor(e, t, n, i) { super(e, t, n, i); } } ys.prototype.ValueTypeName = "number"; class jm extends mr { /** * Constructs a new SLERP interpolant. * * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors. * @param {TypedArray} sampleValues - The sample values. * @param {number} sampleSize - The sample size * @param {TypedArray} [resultBuffer] - The result buffer. */ constructor(e, t, n, i) { super(e, t, n, i); } interpolate_(e, t, n, i) { const r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, l = (n - t) / (i - t); let c = e * o; for (let h = c + o; c !== h; c += 4) Dn.slerpFlat(r, 0, a, c - o, a, c, l); return r; } } class Ms extends Nn { /** * Constructs a new Quaternion keyframe track. * * @param {string} name - The keyframe track's name. * @param {Array} times - A list of keyframe times. * @param {Array} values - A list of keyframe values. * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type. */ constructor(e, t, n, i) { super(e, t, n, i); } /** * Overwritten so the method returns Quaternion based interpolant. * * @static * @param {TypedArray} [result] - The result buffer. * @return {QuaternionLinearInterpolant} The new interpolant. */ InterpolantFactoryMethodLinear(e) { return new jm(this.times, this.values, this.getValueSize(), e); } } Ms.prototype.ValueTypeName = "quaternion"; Ms.prototype.InterpolantFactoryMethodSmooth = void 0; class Ps extends Nn { /** * Constructs a new string keyframe track. * * This keyframe track type has no `interpolation` parameter because the * interpolation is always discrete. * * @param {string} name - The keyframe track's name. * @param {Array} times - A list of keyframe times. * @param {Array} values - A list of keyframe values. */ constructor(e, t, n) { super(e, t, n); } } Ps.prototype.ValueTypeName = "string"; Ps.prototype.ValueBufferType = Array; Ps.prototype.DefaultInterpolation = rr; Ps.prototype.InterpolantFactoryMethodLinear = void 0; Ps.prototype.InterpolantFactoryMethodSmooth = void 0; class Ss extends Nn { /** * Constructs a new vector keyframe track. * * @param {string} name - The keyframe track's name. * @param {Array} times - A list of keyframe times. * @param {Array} values - A list of keyframe values. * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type. */ constructor(e, t, n, i) { super(e, t, n, i); } } Ss.prototype.ValueTypeName = "vector"; class Zm { /** * Constructs a new animation clip. * * Note: Instead of instantiating an AnimationClip directly with the constructor, you can * use the static interface of this class for creating clips. In most cases though, animation clips * will automatically be created by loaders when importing animated 3D assets. * * @param {string} [name=''] - The clip's name. * @param {number} [duration=-1] - The clip's duration in seconds. If a negative value is passed, * the duration will be calculated from the passed keyframes. * @param {Array} tracks - An array of keyframe tracks. * @param {(NormalAnimationBlendMode|AdditiveAnimationBlendMode)} [blendMode=NormalAnimationBlendMode] - Defines how the animation * is blended/combined when two or more animations are simultaneously played. */ constructor(e = "", t = -1, n = [], i = qf) { this.name = e, this.tracks = n, this.duration = t, this.blendMode = i, this.uuid = yn(), this.userData = {}, this.duration < 0 && this.resetDuration(); } /** * Factory method for creating an animation clip from the given JSON. * * @static * @param {Object} json - The serialized animation clip. * @return {AnimationClip} The new animation clip. */ static parse(e) { const t = [], n = e.tracks, i = 1 / (e.fps || 1); for (let a = 0, o = n.length; a !== o; ++a) t.push(Ym(n[a]).scale(i)); const r = new this(e.name, e.duration, t, e.blendMode); return r.uuid = e.uuid, r.userData = JSON.parse(e.userData || "{}"), r; } /** * Serializes the given animation clip into JSON. * * @static * @param {AnimationClip} clip - The animation clip to serialize. * @return {Object} The JSON object. */ static toJSON(e) { const t = [], n = e.tracks, i = { name: e.name, duration: e.duration, tracks: t, uuid: e.uuid, blendMode: e.blendMode, userData: JSON.stringify(e.userData) }; for (let r = 0, a = n.length; r !== a; ++r) t.push(Nn.toJSON(n[r])); return i; } /** * Returns a new animation clip from the passed morph targets array of a * geometry, taking a name and the number of frames per second. * * Note: The fps parameter is required, but the animation speed can be * overridden via {@link AnimationAction#setDuration}. * * @static * @param {string} name - The name of the animation clip. * @param {Array} morphTargetSequence - A sequence of morph targets. * @param {number} fps - The Frames-Per-Second value. * @param {boolean} noLoop - Whether the clip should be no loop or not. * @return {AnimationClip} The new animation clip. */ static CreateFromMorphTargetSequence(e, t, n, i) { const r = t.length, a = []; for (let o = 0; o < r; o++) { let l = [], c = []; l.push( (o + r - 1) % r, o, (o + 1) % r ), c.push(0, 1, 0); const h = Vm(l); l = yh(l, 1, h), c = yh(c, 1, h), !i && l[0] === 0 && (l.push(r), c.push(c[0])), a.push( new ys( ".morphTargetInfluences[" + t[o].name + "]", l, c ).scale(1 / n) ); } return new this(e, -1, a); } /** * Searches for an animation clip by name, taking as its first parameter * either an array of clips, or a mesh or geometry that contains an * array named "animations" property. * * @static * @param {(Array|Object3D)} objectOrClipArray - The array or object to search through. * @param {string} name - The name to search for. * @return {?AnimationClip} The found animation clip. Returns `null` if no clip has been found. */ static findByName(e, t) { let n = e; if (!Array.isArray(e)) { const i = e; n = i.geometry && i.geometry.animations || i.animations; } for (let i = 0; i < n.length; i++) if (n[i].name === t) return n[i]; return null; } /** * Returns an array of new AnimationClips created from the morph target * sequences of a geometry, trying to sort morph target names into * animation-group-based patterns like "Walk_001, Walk_002, Run_001, Run_002...". * * See {@link MD2Loader#parse} as an example for how the method should be used. * * @static * @param {Array} morphTargets - A sequence of morph targets. * @param {number} fps - The Frames-Per-Second value. * @param {boolean} noLoop - Whether the clip should be no loop or not. * @return {Array} An array of new animation clips. */ static CreateClipsFromMorphTargetSequences(e, t, n) { const i = {}, r = /^([\w-]*?)([\d]+)$/; for (let o = 0, l = e.length; o < l; o++) { const c = e[o], h = c.name.match(r); if (h && h.length > 1) { const u = h[1]; let f = i[u]; f || (i[u] = f = []), f.push(c); } } const a = []; for (const o in i) a.push(this.CreateFromMorphTargetSequence(o, i[o], t, n)); return a; } /** * Parses the `animation.hierarchy` format and returns a new animation clip. * * @static * @deprecated since r175. * @param {Object} animation - A serialized animation clip as JSON. * @param {Array} bones - An array of bones. * @return {?AnimationClip} The new animation clip. */ static parseAnimation(e, t) { if (ze("AnimationClip: parseAnimation() is deprecated and will be removed with r185"), !e) return et("AnimationClip: No animation in JSONLoader data."), null; const n = function(u, f, d, p, g) { if (d.length !== 0) { const x = [], m = []; Md(d, x, m, p), x.length !== 0 && g.push(new u(f, x, m)); } }, i = [], r = e.name || "default", a = e.fps || 30, o = e.blendMode; let l = e.length || -1; const c = e.hierarchy || []; for (let u = 0; u < c.length; u++) { const f = c[u].keys; if (!(!f || f.length === 0)) if (f[0].morphTargets) { const d = {}; let p; for (p = 0; p < f.length; p++) if (f[p].morphTargets) for (let g = 0; g < f[p].morphTargets.length; g++) d[f[p].morphTargets[g]] = -1; for (const g in d) { const x = [], m = []; for (let v = 0; v !== f[p].morphTargets.length; ++v) { const b = f[p]; x.push(b.time), m.push(b.morphTarget === g ? 1 : 0); } i.push(new ys(".morphTargetInfluence[" + g + "]", x, m)); } l = d.length * a; } else { const d = ".bones[" + t[u].name + "]"; n( Ss, d + ".position", f, "pos", i ), n( Ms, d + ".quaternion", f, "rot", i ), n( Ss, d + ".scale", f, "scl", i ); } } return i.length === 0 ? null : new this(r, l, i, o); } /** * Sets the duration of this clip to the duration of its longest keyframe track. * * @return {AnimationClip} A reference to this animation clip. */ resetDuration() { const e = this.tracks; let t = 0; for (let n = 0, i = e.length; n !== i; ++n) { const r = this.tracks[n]; t = Math.max(t, r.times[r.times.length - 1]); } return this.duration = t, this; } /** * Trims all tracks to the clip's duration. * * @return {AnimationClip} A reference to this animation clip. */ trim() { for (let e = 0; e < this.tracks.length; e++) this.tracks[e].trim(0, this.duration); return this; } /** * Performs minimal validation on each track in the clip. Returns `true` if all * tracks are valid. * * @return {boolean} Whether the clip's keyframes are valid or not. */ validate() { let e = !0; for (let t = 0; t < this.tracks.length; t++) e = e && this.tracks[t].validate(); return e; } /** * Optimizes each track by removing equivalent sequential keys (which are * common in morph target sequences). * * @return {AnimationClip} A reference to this animation clip. */ optimize() { for (let e = 0; e < this.tracks.length; e++) this.tracks[e].optimize(); return this; } /** * Returns a new animation clip with copied values from this instance. * * @return {AnimationClip} A clone of this instance. */ clone() { const e = []; for (let n = 0; n < this.tracks.length; n++) e.push(this.tracks[n].clone()); const t = new this.constructor(this.name, this.duration, e, this.blendMode); return t.userData = JSON.parse(JSON.stringify(this.userData)), t; } /** * Serializes this animation clip into JSON. * * @return {Object} The JSON object. */ toJSON() { return this.constructor.toJSON(this); } } function qm(s) { switch (s.toLowerCase()) { case "scalar": case "double": case "float": case "number": case "integer": return ys; case "vector": case "vector2": case "vector3": case "vector4": return Ss; case "color": return Sd; case "quaternion": return Ms; case "bool": case "boolean": return As; case "string": return Ps; } throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + s); } function Ym(s) { if (s.type === void 0) throw new Error("THREE.KeyframeTrack: track type undefined, can not parse"); const e = qm(s.type); if (s.times === void 0) { const t = [], n = []; Md(s.keys, t, n, "value"), s.times = t, s.values = n; } return e.parse !== void 0 ? e.parse(s) : new e(s.name, s.times, s.values, s.interpolation); } const ni = { /** * Whether caching is enabled or not. * * @static * @type {boolean} * @default false */ enabled: !1, /** * A dictionary that holds cached files. * * @static * @type {Object} */ files: {}, /** * Adds a cache entry with a key to reference the file. If this key already * holds a file, it is overwritten. * * @static * @param {string} key - The key to reference the cached file. * @param {Object} file - The file to be cached. */ add: function(s, e) { this.enabled !== !1 && (this.files[s] = e); }, /** * Gets the cached value for the given key. * * @static * @param {string} key - The key to reference the cached file. * @return {Object|undefined} The cached file. If the key does not exist `undefined` is returned. */ get: function(s) { if (this.enabled !== !1) return this.files[s]; }, /** * Removes the cached file associated with the given key. * * @static * @param {string} key - The key to reference the cached file. */ remove: function(s) { delete this.files[s]; }, /** * Remove all values from the cache. * * @static */ clear: function() { this.files = {}; } }; class Km { /** * Constructs a new loading manager. * * @param {Function} [onLoad] - Executes when all items have been loaded. * @param {Function} [onProgress] - Executes when single items have been loaded. * @param {Function} [onError] - Executes when an error occurs. */ constructor(e, t, n) { const i = this; let r = !1, a = 0, o = 0, l; const c = []; this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = n, this._abortController = null, this.itemStart = function(h) { o++, r === !1 && i.onStart !== void 0 && i.onStart(h, a, o), r = !0; }, this.itemEnd = function(h) { a++, i.onProgress !== void 0 && i.onProgress(h, a, o), a === o && (r = !1, i.onLoad !== void 0 && i.onLoad()); }, this.itemError = function(h) { i.onError !== void 0 && i.onError(h); }, this.resolveURL = function(h) { return l ? l(h) : h; }, this.setURLModifier = function(h) { return l = h, this; }, this.addHandler = function(h, 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, f = c.length; u < f; u += 2) { const d = c[u], p = c[u + 1]; if (d.global && (d.lastIndex = 0), d.test(h)) return p; } return null; }, this.abort = function() { return this.abortController.abort(), this._abortController = null, this; }; } // TODO: Revert this back to a single member variable once this issue has been fixed // https://github.com/cloudflare/workerd/issues/3657 /** * Used for aborting ongoing requests in loaders using this manager. * * @type {AbortController} */ get abortController() { return this._abortController || (this._abortController = new AbortController()), this._abortController; } } const $m = /* @__PURE__ */ new Km(); class Fi { /** * Constructs a new loader. * * @param {LoadingManager} [manager] - The loading manager. */ constructor(e) { this.manager = e !== void 0 ? e : $m, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {}; } /** * This method needs to be implemented by all concrete loaders. It holds the * logic for loading assets from the backend. * * @abstract * @param {string} url - The path/URL of the file to be loaded. * @param {Function} onLoad - Executed when the loading process has been finished. * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress. * @param {onErrorCallback} [onError] - Executed when errors occur. */ load() { } /** * A async version of {@link Loader#load}. * * @param {string} url - The path/URL of the file to be loaded. * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress. * @return {Promise} A Promise that resolves when the asset has been loaded. */ loadAsync(e, t) { const n = this; return new Promise(function(i, r) { n.load(e, i, t, r); }); } /** * This method needs to be implemented by all concrete loaders. It holds the * logic for parsing the asset into three.js entities. * * @abstract * @param {any} data - The data to parse. */ parse() { } /** * Sets the `crossOrigin` String to implement CORS for loading the URL * from a different domain that allows CORS. * * @param {string} crossOrigin - The `crossOrigin` value. * @return {Loader} A reference to this instance. */ setCrossOrigin(e) { return this.crossOrigin = e, this; } /** * Whether the XMLHttpRequest uses credentials such as cookies, authorization * headers or TLS client certificates, see [XMLHttpRequest.withCredentials](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials). * * Note: This setting has no effect if you are loading files locally or from the same domain. * * @param {boolean} value - The `withCredentials` value. * @return {Loader} A reference to this instance. */ setWithCredentials(e) { return this.withCredentials = e, this; } /** * Sets the base path for the asset. * * @param {string} path - The base path. * @return {Loader} A reference to this instance. */ setPath(e) { return this.path = e, this; } /** * Sets the base path for dependent resources like textures. * * @param {string} resourcePath - The resource path. * @return {Loader} A reference to this instance. */ setResourcePath(e) { return this.resourcePath = e, this; } /** * Sets the given request header. * * @param {Object} requestHeader - A [request header](https://developer.mozilla.org/en-US/docs/Glossary/Request_header) * for configuring the HTTP request. * @return {Loader} A reference to this instance. */ setRequestHeader(e) { return this.requestHeader = e, this; } /** * This method can be implemented in loaders for aborting ongoing requests. * * @abstract * @return {Loader} A reference to this instance. */ abort() { return this; } } Fi.DEFAULT_MATERIAL_NAME = "__DEFAULT"; const Jn = {}; class Jm extends Error { constructor(e, t) { super(e), this.response = t; } } class wa extends Fi { /** * Constructs a new file loader. * * @param {LoadingManager} [manager] - The loading manager. */ constructor(e) { super(e), this.mimeType = "", this.responseType = "", this._abortController = new AbortController(); } /** * Starts loading from the given URL and pass the loaded response to the `onLoad()` callback. * * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI. * @param {function(any)} onLoad - Executed when the loading process has been finished. * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress. * @param {onErrorCallback} [onError] - Executed when errors occur. * @return {any|undefined} The cached resource if available. */ load(e, t, n, i) { e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); const r = ni.get(`file:${e}`); if (r !== void 0) return this.manager.itemStart(e), setTimeout(() => { t && t(r), this.manager.itemEnd(e); }, 0), r; if (Jn[e] !== void 0) { Jn[e].push({ onLoad: t, onProgress: n, onError: i }); return; } Jn[e] = [], Jn[e].push({ onLoad: t, onProgress: n, onError: i }); const a = new Request(e, { headers: new Headers(this.requestHeader), credentials: this.withCredentials ? "include" : "same-origin", signal: typeof AbortSignal.any == "function" ? AbortSignal.any([this._abortController.signal, this.manager.abortController.signal]) : this._abortController.signal }), o = this.mimeType, l = this.responseType; fetch(a).then((c) => { if (c.status === 200 || c.status === 0) { if (c.status === 0 && ze("FileLoader: HTTP Status 0 received."), typeof ReadableStream > "u" || c.body === void 0 || c.body.getReader === void 0) return c; const h = Jn[e], u = c.body.getReader(), f = c.headers.get("X-File-Size") || c.headers.get("Content-Length"), d = f ? parseInt(f) : 0, p = d !== 0; let g = 0; const x = new ReadableStream({ start(m) { v(); function v() { u.read().then(({ done: b, value: M }) => { if (b) m.close(); else { g += M.byteLength; const C = new ProgressEvent("progress", { lengthComputable: p, loaded: g, total: d }); for (let T = 0, D = h.length; T < D; T++) { const U = h[T]; U.onProgress && U.onProgress(C); } m.enqueue(M), v(); } }, (b) => { m.error(b); }); } } }); return new Response(x); } else throw new Jm(`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 u = /charset="?([^;"\s]*)"?/i.exec(o), f = u && u[1] ? u[1].toLowerCase() : void 0, d = new TextDecoder(f); return c.arrayBuffer().then((p) => d.decode(p)); } } }).then((c) => { ni.add(`file:${e}`, c); const h = Jn[e]; delete Jn[e]; for (let u = 0, f = h.length; u < f; u++) { const d = h[u]; d.onLoad && d.onLoad(c); } }).catch((c) => { const h = Jn[e]; if (h === void 0) throw this.manager.itemError(e), c; delete Jn[e]; for (let u = 0, f = h.length; u < f; u++) { const d = h[u]; d.onError && d.onError(c); } this.manager.itemError(e); }).finally(() => { this.manager.itemEnd(e); }), this.manager.itemStart(e); } /** * Sets the expected response type. * * @param {('arraybuffer'|'blob'|'document'|'json'|'')} value - The response type. * @return {FileLoader} A reference to this file loader. */ setResponseType(e) { return this.responseType = e, this; } /** * Sets the expected mime type of the loaded file. * * @param {string} value - The mime type. * @return {FileLoader} A reference to this file loader. */ setMimeType(e) { return this.mimeType = e, this; } /** * Aborts ongoing fetch requests. * * @return {FileLoader} A reference to this instance. */ abort() { return this._abortController.abort(), this._abortController = new AbortController(), this; } } const is = /* @__PURE__ */ new WeakMap(); class Qm extends Fi { /** * Constructs a new image loader. * * @param {LoadingManager} [manager] - The loading manager. */ constructor(e) { super(e); } /** * Starts loading from the given URL and passes the loaded image * to the `onLoad()` callback. The method also returns a new `Image` object which can * directly be used for texture creation. If you do it this way, the texture * may pop up in your scene once the respective loading process is finished. * * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI. * @param {function(Image)} onLoad - Executed when the loading process has been finished. * @param {onProgressCallback} onProgress - Unsupported in this loader. * @param {onErrorCallback} onError - Executed when errors occur. * @return {Image} The image. */ load(e, t, n, i) { this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); const r = this, a = ni.get(`image:${e}`); if (a !== void 0) { if (a.complete === !0) r.manager.itemStart(e), setTimeout(function() { t && t(a), r.manager.itemEnd(e); }, 0); else { let u = is.get(a); u === void 0 && (u = [], is.set(a, u)), u.push({ onLoad: t, onError: i }); } return a; } const o = or("img"); function l() { h(), t && t(this); const u = is.get(this) || []; for (let f = 0; f < u.length; f++) { const d = u[f]; d.onLoad && d.onLoad(this); } is.delete(this), r.manager.itemEnd(e); } function c(u) { h(), i && i(u), ni.remove(`image:${e}`); const f = is.get(this) || []; for (let d = 0; d < f.length; d++) { const p = f[d]; p.onError && p.onError(u); } is.delete(this), r.manager.itemError(e), r.manager.itemEnd(e); } function h() { o.removeEventListener("load", l, !1), o.removeEventListener("error", c, !1); } return o.addEventListener("load", l, !1), o.addEventListener("error", c, !1), e.slice(0, 5) !== "data:" && this.crossOrigin !== void 0 && (o.crossOrigin = this.crossOrigin), ni.add(`image:${e}`, o), r.manager.itemStart(e), o.src = e, o; } } class wd extends Fi { /** * Constructs a new texture loader. * * @param {LoadingManager} [manager] - The loading manager. */ constructor(e) { super(e); } /** * Starts loading from the given URL and pass the fully loaded texture * to the `onLoad()` callback. The method also returns a new texture object which can * directly be used for material creation. If you do it this way, the texture * may pop up in your scene once the respective loading process is finished. * * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI. * @param {function(Texture)} onLoad - Executed when the loading process has been finished. * @param {onProgressCallback} onProgress - Unsupported in this loader. * @param {onErrorCallback} onError - Executed when errors occur. * @return {Texture} The texture. */ load(e, t, n, i) { const r = new Ft(), a = new Qm(this.manager); return a.setCrossOrigin(this.crossOrigin), a.setPath(this.path), a.load(e, function(o) { r.image = o, r.needsUpdate = !0, t !== void 0 && t(r); }, n, i), r; } } class Ra extends Mt { /** * Constructs a new light. * * @param {(number|Color|string)} [color=0xffffff] - The light's color. * @param {number} [intensity=1] - The light's strength/intensity. */ constructor(e, t = 1) { super(), this.isLight = !0, this.type = "Light", this.color = new Fe(e), this.intensity = t; } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. */ 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 _o = /* @__PURE__ */ new je(), Mh = /* @__PURE__ */ new R(), Sh = /* @__PURE__ */ new R(); class fc { /** * Constructs a new light shadow. * * @param {Camera} camera - The light's view of the world. */ constructor(e) { this.camera = e, this.intensity = 1, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new ue(512, 512), this.mapType = Ln, this.map = null, this.mapPass = null, this.matrix = new je(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new lc(), this._frameExtents = new ue(1, 1), this._viewportCount = 1, this._viewports = [ new at(0, 0, 1, 1) ]; } /** * Used internally by the renderer to get the number of viewports that need * to be rendered for this shadow. * * @return {number} The viewport count. */ getViewportCount() { return this._viewportCount; } /** * Gets the shadow cameras frustum. Used internally by the renderer to cull objects. * * @return {Frustum} The shadow camera frustum. */ getFrustum() { return this._frustum; } /** * Update the matrices for the camera and shadow, used internally by the renderer. * * @param {Light} light - The light for which the shadow is being rendered. */ updateMatrices(e) { const t = this.camera, n = this.matrix; Mh.setFromMatrixPosition(e.matrixWorld), t.position.copy(Mh), Sh.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(Sh), t.updateMatrixWorld(), _o.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(_o, t.coordinateSystem, t.reversedDepth), t.reversedDepth ? n.set( 0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1 ) : n.set( 0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 0.5, 0.5, 0, 0, 0, 1 ), n.multiply(_o); } /** * Returns a viewport definition for the given viewport index. * * @param {number} viewportIndex - The viewport index. * @return {Vector4} The viewport. */ getViewport(e) { return this._viewports[e]; } /** * Returns the frame extends. * * @return {Vector2} The frame extends. */ getFrameExtents() { return this._frameExtents; } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. */ dispose() { this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose(); } /** * Copies the values of the given light shadow instance to this instance. * * @param {LightShadow} source - The light shadow to copy. * @return {LightShadow} A reference to this light shadow instance. */ 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; } /** * Returns a new light shadow instance with copied values from this instance. * * @return {LightShadow} A clone of this instance. */ clone() { return new this.constructor().copy(this); } /** * Serializes the light shadow into JSON. * * @return {Object} A JSON object representing the serialized light shadow. * @see {@link ObjectLoader#parse} */ 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 e0 extends fc { /** * Constructs a new spot light shadow. */ constructor() { super(new jt(50, 1, 0.5, 500)), this.isSpotLightShadow = !0, this.focus = 1, this.aspect = 1; } updateMatrices(e) { const t = this.camera, n = vs * 2 * e.angle * this.focus, i = this.mapSize.width / this.mapSize.height * this.aspect, r = e.distance || t.far; (n !== t.fov || i !== t.aspect || r !== t.far) && (t.fov = n, t.aspect = i, t.far = r, t.updateProjectionMatrix()), super.updateMatrices(e); } copy(e) { return super.copy(e), this.focus = e.focus, this; } } class t0 extends Ra { /** * Constructs a new spot light. * * @param {(number|Color|string)} [color=0xffffff] - The light's color. * @param {number} [intensity=1] - The light's strength/intensity measured in candela (cd). * @param {number} [distance=0] - Maximum range of the light. `0` means no limit. * @param {number} [angle=Math.PI/3] - Maximum angle of light dispersion from its direction whose upper bound is `Math.PI/2`. * @param {number} [penumbra=0] - Percent of the spotlight cone that is attenuated due to penumbra. Value range is `[0,1]`. * @param {number} [decay=2] - The amount the light dims along the distance of the light. */ constructor(e, t, n = 0, i = Math.PI / 3, r = 0, a = 2) { super(e, t), this.isSpotLight = !0, this.type = "SpotLight", this.position.copy(Mt.DEFAULT_UP), this.updateMatrix(), this.target = new Mt(), this.distance = n, this.angle = i, this.penumbra = r, this.decay = a, this.map = null, this.shadow = new e0(); } /** * The light's power. Power is the luminous power of the light measured in lumens (lm). * Changing the power will also change the light's intensity. * * @type {number} */ 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 wh = /* @__PURE__ */ new je(), Hs = /* @__PURE__ */ new R(), yo = /* @__PURE__ */ new R(); class n0 extends fc { /** * Constructs a new point light shadow. */ constructor() { super(new jt(90, 1, 0.5, 500)), this.isPointLightShadow = !0, this._frameExtents = new ue(4, 2), this._viewportCount = 6, this._viewports = [ // These viewports map a cube-map onto a 2D texture with the // following orientation: // // xzXZ // y Y // // X - Positive x direction // x - Negative x direction // Y - Positive y direction // y - Negative y direction // Z - Positive z direction // z - Negative z direction // positive X new at(2, 1, 1, 1), // negative X new at(0, 1, 1, 1), // positive Z new at(3, 1, 1, 1), // negative Z new at(1, 1, 1, 1), // positive Y new at(3, 0, 1, 1), // negative Y new at(1, 0, 1, 1) ], this._cubeDirections = [ new R(1, 0, 0), new R(-1, 0, 0), new R(0, 0, 1), new R(0, 0, -1), new R(0, 1, 0), new R(0, -1, 0) ], this._cubeUps = [ new R(0, 1, 0), new R(0, 1, 0), new R(0, 1, 0), new R(0, 1, 0), new R(0, 0, 1), new R(0, 0, -1) ]; } /** * Update the matrices for the camera and shadow, used internally by the renderer. * * @param {Light} light - The light for which the shadow is being rendered. * @param {number} [viewportIndex=0] - The viewport index. */ updateMatrices(e, t = 0) { const n = this.camera, i = this.matrix, r = e.distance || n.far; r !== n.far && (n.far = r, n.updateProjectionMatrix()), Hs.setFromMatrixPosition(e.matrixWorld), n.position.copy(Hs), yo.copy(n.position), yo.add(this._cubeDirections[t]), n.up.copy(this._cubeUps[t]), n.lookAt(yo), n.updateMatrixWorld(), i.makeTranslation(-Hs.x, -Hs.y, -Hs.z), wh.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(wh, n.coordinateSystem, n.reversedDepth); } } class i0 extends Ra { /** * Constructs a new point light. * * @param {(number|Color|string)} [color=0xffffff] - The light's color. * @param {number} [intensity=1] - The light's strength/intensity measured in candela (cd). * @param {number} [distance=0] - Maximum range of the light. `0` means no limit. * @param {number} [decay=2] - The amount the light dims along the distance of the light. */ constructor(e, t, n = 0, i = 2) { super(e, t), this.isPointLight = !0, this.type = "PointLight", this.distance = n, this.decay = i, this.shadow = new n0(); } /** * The light's power. Power is the luminous power of the light measured in lumens (lm). * Changing the power will also change the light's intensity. * * @type {number} */ 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 zi extends sd { /** * Constructs a new orthographic camera. * * @param {number} [left=-1] - The left plane of the camera's frustum. * @param {number} [right=1] - The right plane of the camera's frustum. * @param {number} [top=1] - The top plane of the camera's frustum. * @param {number} [bottom=-1] - The bottom plane of the camera's frustum. * @param {number} [near=0.1] - The camera's near plane. * @param {number} [far=2000] - The camera's far plane. */ constructor(e = -1, t = 1, n = 1, i = -1, r = 0.1, a = 2e3) { super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = n, this.bottom = i, this.near = r, this.far = a, this.updateProjectionMatrix(); } copy(e, t) { return super.copy(e, t), this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.near = e.near, this.far = e.far, this.zoom = e.zoom, this.view = e.view === null ? null : Object.assign({}, e.view), this; } /** * Sets an offset in a larger frustum. This is useful for multi-window or * multi-monitor/multi-machine setups. * * @param {number} fullWidth - The full width of multiview setup. * @param {number} fullHeight - The full height of multiview setup. * @param {number} x - The horizontal offset of the subcamera. * @param {number} y - The vertical offset of the subcamera. * @param {number} width - The width of subcamera. * @param {number} height - The height of subcamera. * @see {@link PerspectiveCamera#setViewOffset} */ setViewOffset(e, t, n, i, r, a) { this.view === null && (this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = a, this.updateProjectionMatrix(); } /** * Removes the view offset from the projection matrix. */ clearViewOffset() { this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); } /** * Updates the camera's projection matrix. Must be called after any change of * camera properties. */ updateProjectionMatrix() { const e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, i = (this.top + this.bottom) / 2; let r = n - e, a = n + e, o = i + t, l = i - t; if (this.view !== null && this.view.enabled) { const c = (this.right - this.left) / this.view.fullWidth / this.zoom, h = (this.top - this.bottom) / this.view.fullHeight / this.zoom; r += c * this.view.offsetX, a = r + c * this.view.width, o -= h * this.view.offsetY, l = o - h * this.view.height; } this.projectionMatrix.makeOrthographic(r, a, o, l, this.near, this.far, this.coordinateSystem, this.reversedDepth), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); } toJSON(e) { const t = super.toJSON(e); return t.object.zoom = this.zoom, t.object.left = this.left, t.object.right = this.right, t.object.top = this.top, t.object.bottom = this.bottom, t.object.near = this.near, t.object.far = this.far, this.view !== null && (t.object.view = Object.assign({}, this.view)), t; } } class s0 extends fc { /** * Constructs a new directional light shadow. */ constructor() { super(new zi(-5, 5, 5, -5, 0.5, 500)), this.isDirectionalLightShadow = !0; } } class os extends Ra { /** * Constructs a new directional light. * * @param {(number|Color|string)} [color=0xffffff] - The light's color. * @param {number} [intensity=1] - The light's strength/intensity. */ constructor(e, t) { super(e, t), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(Mt.DEFAULT_UP), this.updateMatrix(), this.target = new Mt(), this.shadow = new s0(); } dispose() { this.shadow.dispose(); } copy(e) { return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this; } } class Ea extends Ra { /** * Constructs a new ambient light. * * @param {(number|Color|string)} [color=0xffffff] - The light's color. * @param {number} [intensity=1] - The light's strength/intensity. */ constructor(e, t) { super(e, t), this.isAmbientLight = !0, this.type = "AmbientLight"; } } class tr { /** * Extracts the base URL from the given URL. * * @param {string} url -The URL to extract the base URL from. * @return {string} The extracted base URL. */ static extractUrlBase(e) { const t = e.lastIndexOf("/"); return t === -1 ? "./" : e.slice(0, t + 1); } /** * Resolves relative URLs against the given path. Absolute paths, data urls, * and blob URLs will be returned as is. Invalid URLs will return an empty * string. * * @param {string} url -The URL to resolve. * @param {string} path - The base path for relative URLs to be resolved against. * @return {string} The resolved URL. */ 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 Mo = /* @__PURE__ */ new WeakMap(); class r0 extends Fi { /** * Constructs a new image bitmap loader. * * @param {LoadingManager} [manager] - The loading manager. */ constructor(e) { super(e), this.isImageBitmapLoader = !0, typeof createImageBitmap > "u" && ze("ImageBitmapLoader: createImageBitmap() not supported."), typeof fetch > "u" && ze("ImageBitmapLoader: fetch() not supported."), this.options = { premultiplyAlpha: "none" }, this._abortController = new AbortController(); } /** * Sets the given loader options. The structure of the object must match the `options` parameter of * [createImageBitmap](https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap). * * @param {Object} options - The loader options to set. * @return {ImageBitmapLoader} A reference to this image bitmap loader. */ setOptions(e) { return this.options = e, this; } /** * Starts loading from the given URL and pass the loaded image bitmap to the `onLoad()` callback. * * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI. * @param {function(ImageBitmap)} onLoad - Executed when the loading process has been finished. * @param {onProgressCallback} onProgress - Unsupported in this loader. * @param {onErrorCallback} onError - Executed when errors occur. * @return {ImageBitmap|undefined} The image bitmap. */ load(e, t, n, i) { e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); const r = this, a = ni.get(`image-bitmap:${e}`); if (a !== void 0) { if (r.manager.itemStart(e), a.then) { a.then((c) => { if (Mo.has(a) === !0) i && i(Mo.get(a)), r.manager.itemError(e), r.manager.itemEnd(e); else return t && t(c), r.manager.itemEnd(e), c; }); return; } return setTimeout(function() { t && t(a), r.manager.itemEnd(e); }, 0), a; } const o = {}; o.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include", o.headers = this.requestHeader, o.signal = typeof AbortSignal.any == "function" ? AbortSignal.any([this._abortController.signal, this.manager.abortController.signal]) : this._abortController.signal; const l = fetch(e, o).then(function(c) { return c.blob(); }).then(function(c) { return createImageBitmap(c, Object.assign(r.options, { colorSpaceConversion: "none" })); }).then(function(c) { return ni.add(`image-bitmap:${e}`, c), t && t(c), r.manager.itemEnd(e), c; }).catch(function(c) { i && i(c), Mo.set(l, c), ni.remove(`image-bitmap:${e}`), r.manager.itemError(e), r.manager.itemEnd(e); }); ni.add(`image-bitmap:${e}`, l), r.manager.itemStart(e); } /** * Aborts ongoing fetch requests. * * @return {ImageBitmapLoader} A reference to this instance. */ abort() { return this._abortController.abort(), this._abortController = new AbortController(), this; } } class a0 extends jt { /** * Constructs a new array camera. * * @param {Array} [array=[]] - An array of perspective sub cameras. */ constructor(e = []) { super(), this.isArrayCamera = !0, this.isMultiViewCamera = !1, this.cameras = e; } } class o0 { /** * Constructs a new clock. * * @param {boolean} [autoStart=true] - Whether to automatically start the clock when * `getDelta()` is called for the first time. */ constructor(e = !0) { this.autoStart = e, this.startTime = 0, this.oldTime = 0, this.elapsedTime = 0, this.running = !1; } /** * Starts the clock. When `autoStart` is set to `true`, the method is automatically * called by the class. */ start() { this.startTime = performance.now(), this.oldTime = this.startTime, this.elapsedTime = 0, this.running = !0; } /** * Stops the clock. */ stop() { this.getElapsedTime(), this.running = !1, this.autoStart = !1; } /** * Returns the elapsed time in seconds. * * @return {number} The elapsed time. */ getElapsedTime() { return this.getDelta(), this.elapsedTime; } /** * Returns the delta time in seconds. * * @return {number} The delta time. */ 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 pc = "\\[\\]\\.:\\/", l0 = new RegExp("[" + pc + "]", "g"), mc = "[^" + pc + "]", c0 = "[^" + pc.replace("\\.", "") + "]", h0 = /* @__PURE__ */ /((?:WC+[\/:])*)/.source.replace("WC", mc), u0 = /* @__PURE__ */ /(WCOD+)?/.source.replace("WCOD", c0), d0 = /* @__PURE__ */ /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", mc), f0 = /* @__PURE__ */ /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", mc), p0 = new RegExp( "^" + h0 + u0 + d0 + f0 + "$" ), m0 = ["material", "materials", "bones", "map"]; class g0 { constructor(e, t, n) { const i = n || ct.parseTrackName(t); this._targetGroup = e, this._bindings = e.subscribe_(t, i); } getValue(e, t) { this.bind(); const n = this._targetGroup.nCachedObjects_, i = this._bindings[n]; i !== void 0 && i.getValue(e, t); } setValue(e, t) { const n = this._bindings; for (let i = this._targetGroup.nCachedObjects_, r = n.length; i !== r; ++i) n[i].setValue(e, t); } bind() { const e = this._bindings; for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t) e[t].bind(); } unbind() { const e = this._bindings; for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t) e[t].unbind(); } } class ct { /** * Constructs a new property binding. * * @param {Object} rootNode - The root node. * @param {string} path - The path. * @param {?Object} [parsedPath] - The parsed path. */ constructor(e, t, n) { this.path = t, this.parsedPath = n || ct.parseTrackName(t), this.node = ct.findNode(e, this.parsedPath.nodeName), this.rootNode = e, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; } /** * Factory method for creating a property binding from the given parameters. * * @static * @param {Object} root - The root node. * @param {string} path - The path. * @param {?Object} [parsedPath] - The parsed path. * @return {PropertyBinding|Composite} The created property binding or composite. */ static create(e, t, n) { return e && e.isAnimationObjectGroup ? new ct.Composite(e, t, n) : new ct(e, t, n); } /** * Replaces spaces with underscores and removes unsupported characters from * node names, to ensure compatibility with parseTrackName(). * * @param {string} name - Node name to be sanitized. * @return {string} The sanitized node name. */ static sanitizeNodeName(e) { return e.replace(/\s/g, "_").replace(l0, ""); } /** * Parses the given track name (an object path to an animated property) and * returns an object with information about the path. Matches strings in the following forms: * * - nodeName.property * - nodeName.property[accessor] * - nodeName.material.property[accessor] * - uuid.property[accessor] * - uuid.objectName[objectIndex].propertyName[propertyIndex] * - parentName/nodeName.property * - parentName/parentName/nodeName.property[index] * - .bone[Armature.DEF_cog].position * - scene:helium_balloon_model:helium_balloon_model.position * * @static * @param {string} trackName - The track name to parse. * @return {Object} The parsed track name as an object. */ static parseTrackName(e) { const t = p0.exec(e); if (t === null) throw new Error("PropertyBinding: Cannot parse trackName: " + e); const n = { // directoryName: matches[ 1 ], // (tschw) currently unused nodeName: t[2], objectName: t[3], objectIndex: t[4], propertyName: t[5], // required propertyIndex: t[6] }, i = n.nodeName && n.nodeName.lastIndexOf("."); if (i !== void 0 && i !== -1) { const r = n.nodeName.substring(i + 1); m0.indexOf(r) !== -1 && (n.nodeName = n.nodeName.substring(0, i), n.objectName = r); } if (n.propertyName === null || n.propertyName.length === 0) throw new Error("PropertyBinding: can not parse propertyName from trackName: " + e); return n; } /** * Searches for a node in the hierarchy of the given root object by the given * node name. * * @static * @param {Object} root - The root object. * @param {string|number} nodeName - The name of the node. * @return {?Object} The found node. Returns `null` if no object was found. */ static findNode(e, t) { if (t === void 0 || t === "" || t === "." || t === -1 || t === e.name || t === e.uuid) return e; if (e.skeleton) { const n = e.skeleton.getBoneByName(t); if (n !== void 0) return n; } if (e.children) { const n = function(r) { for (let a = 0; a < r.length; a++) { const o = r[a]; if (o.name === t || o.uuid === t) return o; const l = n(o.children); if (l) return l; } return null; }, i = n(e.children); if (i) return i; } return null; } // these are used to "bind" a nonexistent property _getValue_unavailable() { } _setValue_unavailable() { } // Getters _getValue_direct(e, t) { e[t] = this.targetObject[this.propertyName]; } _getValue_array(e, t) { const n = this.resolvedProperty; for (let i = 0, r = n.length; i !== r; ++i) e[t++] = n[i]; } _getValue_arrayElement(e, t) { e[t] = this.resolvedProperty[this.propertyIndex]; } _getValue_toArray(e, t) { this.resolvedProperty.toArray(e, t); } // Direct _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; } // EntireArray _setValue_array(e, t) { const n = this.resolvedProperty; for (let i = 0, r = n.length; i !== r; ++i) n[i] = e[t++]; } _setValue_array_setNeedsUpdate(e, t) { const n = this.resolvedProperty; for (let i = 0, r = n.length; i !== r; ++i) n[i] = e[t++]; this.targetObject.needsUpdate = !0; } _setValue_array_setMatrixWorldNeedsUpdate(e, t) { const n = this.resolvedProperty; for (let i = 0, r = n.length; i !== r; ++i) n[i] = e[t++]; this.targetObject.matrixWorldNeedsUpdate = !0; } // ArrayElement _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; } // HasToFromArray _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); } /** * Creates a getter / setter pair for the property tracked by this binding. */ bind() { let e = this.node; const t = this.parsedPath, n = t.objectName, i = t.propertyName; let r = t.propertyIndex; if (e || (e = ct.findNode(this.rootNode, t.nodeName), this.node = e), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !e) { ze("PropertyBinding: No target node found for track: " + this.path + "."); return; } if (n) { let c = t.objectIndex; switch (n) { case "materials": if (!e.material) { et("PropertyBinding: Can not bind to material as node does not have a material.", this); return; } if (!e.material.materials) { et("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) { et("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) { et("PropertyBinding: Can not bind to material as node does not have a material.", this); return; } if (!e.material.map) { et("PropertyBinding: Can not bind to material.map as node.material does not have a map.", this); return; } e = e.material.map; break; default: if (e[n] === void 0) { et("PropertyBinding: Can not bind to objectName of node undefined.", this); return; } e = e[n]; } if (c !== void 0) { if (e[c] === void 0) { et("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, e); return; } e = e[c]; } } const a = e[i]; if (a === void 0) { const c = t.nodeName; et("PropertyBinding: Trying to update property for track: " + c + "." + i + " but it wasn't found.", e); return; } let o = this.Versioning.None; this.targetObject = e, e.isMaterial === !0 ? o = this.Versioning.NeedsUpdate : e.isObject3D === !0 && (o = this.Versioning.MatrixWorldNeedsUpdate); let l = this.BindingType.Direct; if (r !== void 0) { if (i === "morphTargetInfluences") { if (!e.geometry) { et("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this); return; } if (!e.geometry.morphAttributes) { et("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this); return; } e.morphTargetDictionary[r] !== void 0 && (r = e.morphTargetDictionary[r]); } l = this.BindingType.ArrayElement, this.resolvedProperty = a, this.propertyIndex = r; } else a.fromArray !== void 0 && a.toArray !== void 0 ? (l = this.BindingType.HasFromToArray, this.resolvedProperty = a) : Array.isArray(a) ? (l = this.BindingType.EntireArray, this.resolvedProperty = a) : this.propertyName = i; this.getValue = this.GetterByBindingType[l], this.setValue = this.SetterByBindingTypeAndVersioning[l][o]; } /** * Unbinds the property. */ unbind() { this.node = null, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; } } ct.Composite = g0; ct.prototype.BindingType = { Direct: 0, EntireArray: 1, ArrayElement: 2, HasFromToArray: 3 }; ct.prototype.Versioning = { None: 0, NeedsUpdate: 1, MatrixWorldNeedsUpdate: 2 }; ct.prototype.GetterByBindingType = [ ct.prototype._getValue_direct, ct.prototype._getValue_array, ct.prototype._getValue_arrayElement, ct.prototype._getValue_toArray ]; ct.prototype.SetterByBindingTypeAndVersioning = [ [ // Direct ct.prototype._setValue_direct, ct.prototype._setValue_direct_setNeedsUpdate, ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate ], [ // EntireArray ct.prototype._setValue_array, ct.prototype._setValue_array_setNeedsUpdate, ct.prototype._setValue_array_setMatrixWorldNeedsUpdate ], [ // ArrayElement ct.prototype._setValue_arrayElement, ct.prototype._setValue_arrayElement_setNeedsUpdate, ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate ], [ // HasToFromArray ct.prototype._setValue_fromArray, ct.prototype._setValue_fromArray_setNeedsUpdate, ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate ] ]; const Eh = /* @__PURE__ */ new je(); class Ni { /** * Constructs a new raycaster. * * @param {Vector3} origin - The origin vector where the ray casts from. * @param {Vector3} direction - The (normalized) direction vector that gives direction to the ray. * @param {number} [near=0] - All results returned are further away than near. Near can't be negative. * @param {number} [far=Infinity] - All results returned are closer than far. Far can't be lower than near. */ constructor(e, t, n = 0, i = 1 / 0) { this.ray = new Ts(e, t), this.near = n, this.far = i, this.camera = null, this.layers = new rc(), this.params = { Mesh: {}, Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} }; } /** * Updates the ray with a new origin and direction by copying the values from the arguments. * * @param {Vector3} origin - The origin vector where the ray casts from. * @param {Vector3} direction - The (normalized) direction vector that gives direction to the ray. */ set(e, t) { this.ray.set(e, t); } /** * Uses the given coordinates and camera to compute a new origin and direction for the internal ray. * * @param {Vector2} coords - 2D coordinates of the mouse, in normalized device coordinates (NDC). * X and Y components should be between `-1` and `1`. * @param {Camera} camera - The camera from which the ray should originate. */ setFromCamera(e, t) { t.isPerspectiveCamera ? (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, 0.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) : et("Raycaster: Unsupported camera type: " + t.type); } /** * Uses the given WebXR controller to compute a new origin and direction for the internal ray. * * @param {WebXRController} controller - The controller to copy the position and direction from. * @return {Raycaster} A reference to this raycaster. */ setFromXRController(e) { return Eh.identity().extractRotation(e.matrixWorld), this.ray.origin.setFromMatrixPosition(e.matrixWorld), this.ray.direction.set(0, 0, -1).applyMatrix4(Eh), this; } /** * The intersection point of a raycaster intersection test. * @typedef {Object} Raycaster~Intersection * @property {number} distance - The distance from the ray's origin to the intersection point. * @property {number} distanceToRay - Some 3D objects e.g. {@link Points} provide the distance of the * intersection to the nearest point on the ray. For other objects it will be `undefined`. * @property {Vector3} point - The intersection point, in world coordinates. * @property {Object} face - The face that has been intersected. * @property {number} faceIndex - The face index. * @property {Object3D} object - The 3D object that has been intersected. * @property {Vector2} uv - U,V coordinates at point of intersection. * @property {Vector2} uv1 - Second set of U,V coordinates at point of intersection. * @property {Vector3} uv1 - Interpolated normal vector at point of intersection. * @property {number} instanceId - The index number of the instance where the ray * intersects the {@link InstancedMesh}. */ /** * Checks all intersection between the ray and the object with or without the * descendants. Intersections are returned sorted by distance, closest first. * * `Raycaster` delegates to the `raycast()` method of the passed 3D object, when * evaluating whether the ray intersects the object or not. This allows meshes to respond * differently to ray casting than lines or points. * * Note that for meshes, faces must be pointed towards the origin of the ray in order * to be detected; intersections of the ray passing through the back of a face will not * be detected. To raycast against both faces of an object, you'll want to set {@link Material#side} * to `THREE.DoubleSide`. * * @param {Object3D} object - The 3D object to check for intersection with the ray. * @param {boolean} [recursive=true] - If set to `true`, it also checks all descendants. * Otherwise it only checks intersection with the object. * @param {Array} [intersects=[]] The target array that holds the result of the method. * @return {Array} An array holding the intersection points. */ intersectObject(e, t = !0, n = []) { return kl(e, this, n, t), n.sort(Th), n; } /** * Checks all intersection between the ray and the objects with or without * the descendants. Intersections are returned sorted by distance, closest first. * * @param {Array} objects - The 3D objects to check for intersection with the ray. * @param {boolean} [recursive=true] - If set to `true`, it also checks all descendants. * Otherwise it only checks intersection with the object. * @param {Array} [intersects=[]] The target array that holds the result of the method. * @return {Array} An array holding the intersection points. */ intersectObjects(e, t = !0, n = []) { for (let i = 0, r = e.length; i < r; i++) kl(e[i], this, n, t); return n.sort(Th), n; } } function Th(s, e) { return s.distance - e.distance; } function kl(s, e, t, n) { let i = !0; if (s.layers.test(e.layers) && s.raycast(e, t) === !1 && (i = !1), i === !0 && n === !0) { const r = s.children; for (let a = 0, o = r.length; a < o; a++) kl(r[a], e, t, !0); } } class Ch { /** * Constructs a new spherical. * * @param {number} [radius=1] - The radius, or the Euclidean distance (straight-line distance) from the point to the origin. * @param {number} [phi=0] - The polar angle in radians from the y (up) axis. * @param {number} [theta=0] - The equator/azimuthal angle in radians around the y (up) axis. */ constructor(e = 1, t = 0, n = 0) { this.radius = e, this.phi = t, this.theta = n; } /** * Sets the spherical components by copying the given values. * * @param {number} radius - The radius. * @param {number} phi - The polar angle. * @param {number} theta - The azimuthal angle. * @return {Spherical} A reference to this spherical. */ set(e, t, n) { return this.radius = e, this.phi = t, this.theta = n, this; } /** * Copies the values of the given spherical to this instance. * * @param {Spherical} other - The spherical to copy. * @return {Spherical} A reference to this spherical. */ copy(e) { return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this; } /** * Restricts the polar angle [page:.phi phi] to be between `0.000001` and pi - * `0.000001`. * * @return {Spherical} A reference to this spherical. */ makeSafe() { return this.phi = Je(this.phi, 1e-6, Math.PI - 1e-6), this; } /** * Sets the spherical components from the given vector which is assumed to hold * Cartesian coordinates. * * @param {Vector3} v - The vector to set. * @return {Spherical} A reference to this spherical. */ setFromVector3(e) { return this.setFromCartesianCoords(e.x, e.y, e.z); } /** * Sets the spherical components from the given Cartesian coordinates. * * @param {number} x - The x value. * @param {number} y - The y value. * @param {number} z - The z value. * @return {Spherical} A reference to this spherical. */ setFromCartesianCoords(e, t, n) { return this.radius = Math.sqrt(e * e + t * t + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, n), this.phi = Math.acos(Je(t / this.radius, -1, 1))), this; } /** * Returns a new spherical with copied values from this instance. * * @return {Spherical} A clone of this instance. */ clone() { return new this.constructor().copy(this); } } class x0 extends Ui { /** * Constructs a new controls instance. * * @param {Object3D} object - The object that is managed by the controls. * @param {?HTMLElement} domElement - The HTML element used for event listeners. */ 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 }; } /** * Connects the controls to the DOM. This method has so called "side effects" since * it adds the module's event listeners to the DOM. * * @param {HTMLElement} element - The DOM element to connect to. */ connect(e) { if (e === void 0) { ze("Controls: connect() now requires an element."); return; } this.domElement !== null && this.disconnect(), this.domElement = e; } /** * Disconnects the controls from the DOM. */ disconnect() { } /** * Call this method if you no longer want use to the controls. It frees all internal * resources and removes all event listeners. */ dispose() { } /** * Controls should implement this method if they have to update their internal state * per simulation step. * * @param {number} [delta] - The time delta in seconds. */ update() { } } function Ah(s, e, t, n) { const i = v0(n); switch (t) { // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml case qu: return s * e; case Jl: return s * e / i.components * i.byteLength; case Ql: return s * e / i.components * i.byteLength; case ec: return s * e * 2 / i.components * i.byteLength; case tc: return s * e * 2 / i.components * i.byteLength; case Yu: return s * e * 3 / i.components * i.byteLength; case sn: return s * e * 4 / i.components * i.byteLength; case nc: return s * e * 4 / i.components * i.byteLength; // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/ case ca: case ha: return Math.floor((s + 3) / 4) * Math.floor((e + 3) / 4) * 8; case ua: case da: return Math.floor((s + 3) / 4) * Math.floor((e + 3) / 4) * 16; // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/ case el: case nl: return Math.max(s, 16) * Math.max(e, 8) / 4; case Qo: case tl: return Math.max(s, 8) * Math.max(e, 8) / 2; // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/ case il: case sl: return Math.floor((s + 3) / 4) * Math.floor((e + 3) / 4) * 8; case rl: return Math.floor((s + 3) / 4) * Math.floor((e + 3) / 4) * 16; // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/ case al: return Math.floor((s + 3) / 4) * Math.floor((e + 3) / 4) * 16; case ol: return Math.floor((s + 4) / 5) * Math.floor((e + 3) / 4) * 16; case ll: return Math.floor((s + 4) / 5) * Math.floor((e + 4) / 5) * 16; case cl: return Math.floor((s + 5) / 6) * Math.floor((e + 4) / 5) * 16; case hl: return Math.floor((s + 5) / 6) * Math.floor((e + 5) / 6) * 16; case ul: return Math.floor((s + 7) / 8) * Math.floor((e + 4) / 5) * 16; case dl: return Math.floor((s + 7) / 8) * Math.floor((e + 5) / 6) * 16; case fl: return Math.floor((s + 7) / 8) * Math.floor((e + 7) / 8) * 16; case pl: return Math.floor((s + 9) / 10) * Math.floor((e + 4) / 5) * 16; case ml: return Math.floor((s + 9) / 10) * Math.floor((e + 5) / 6) * 16; case gl: return Math.floor((s + 9) / 10) * Math.floor((e + 7) / 8) * 16; case xl: return Math.floor((s + 9) / 10) * Math.floor((e + 9) / 10) * 16; case vl: return Math.floor((s + 11) / 12) * Math.floor((e + 9) / 10) * 16; case bl: return Math.floor((s + 11) / 12) * Math.floor((e + 11) / 12) * 16; // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/ case _l: case yl: case Ml: return Math.ceil(s / 4) * Math.ceil(e / 4) * 16; // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/ case Sl: case wl: return Math.ceil(s / 4) * Math.ceil(e / 4) * 8; case El: case Tl: return Math.ceil(s / 4) * Math.ceil(e / 4) * 16; } throw new Error( `Unable to determine texture byte length for ${t} format.` ); } function v0(s) { switch (s) { case Ln: case Wu: return { byteLength: 1, components: 1 }; case ir: case Xu: case _n: return { byteLength: 2, components: 1 }; case Kl: case $l: return { byteLength: 2, components: 4 }; case Ri: case Yl: case Pn: return { byteLength: 4, components: 1 }; case ju: case Zu: return { byteLength: 4, components: 3 }; } throw new Error(`Unknown texture type ${s}.`); } typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: { revision: Zl } })); typeof window < "u" && (window.__THREE__ ? ze("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = Zl); function Ed() { let s = null, e = !1, t = null, n = null; function i(r, a) { t(r, a), n = s.requestAnimationFrame(i); } return { start: function() { e !== !0 && t !== null && (n = s.requestAnimationFrame(i), e = !0); }, stop: function() { s.cancelAnimationFrame(n), e = !1; }, setAnimationLoop: function(r) { t = r; }, setContext: function(r) { s = r; } }; } function b0(s) { const e = /* @__PURE__ */ new WeakMap(); function t(o, l) { const c = o.array, h = o.usage, u = c.byteLength, f = s.createBuffer(); s.bindBuffer(l, f), s.bufferData(l, c, h), o.onUploadCallback(); let d; if (c instanceof Float32Array) d = s.FLOAT; else if (typeof Float16Array < "u" && c instanceof Float16Array) d = s.HALF_FLOAT; else if (c instanceof Uint16Array) o.isFloat16BufferAttribute ? d = s.HALF_FLOAT : d = s.UNSIGNED_SHORT; else if (c instanceof Int16Array) d = s.SHORT; else if (c instanceof Uint32Array) d = s.UNSIGNED_INT; else if (c instanceof Int32Array) d = s.INT; else if (c instanceof Int8Array) d = s.BYTE; else if (c instanceof Uint8Array) d = s.UNSIGNED_BYTE; else if (c instanceof Uint8ClampedArray) d = s.UNSIGNED_BYTE; else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + c); return { buffer: f, type: d, bytesPerElement: c.BYTES_PER_ELEMENT, version: o.version, size: u }; } function n(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((d, p) => d.start - p.start); let f = 0; for (let d = 1; d < u.length; d++) { const p = u[f], g = u[d]; g.start <= p.start + p.count + 1 ? p.count = Math.max( p.count, g.start + g.count - p.start ) : (++f, u[f] = g); } u.length = f + 1; for (let d = 0, p = u.length; d < p; d++) { const g = u[d]; s.bufferSubData( c, g.start * h.BYTES_PER_ELEMENT, h, g.start, g.count ); } l.clearUpdateRanges(); } l.onUploadCallback(); } function i(o) { return o.isInterleavedBufferAttribute && (o = o.data), e.get(o); } function r(o) { o.isInterleavedBufferAttribute && (o = o.data); const l = e.get(o); l && (s.deleteBuffer(l.buffer), e.delete(o)); } function a(o, l) { if (o.isInterleavedBufferAttribute && (o = o.data), o.isGLBufferAttribute) { const h = e.get(o); (!h || h.version < o.version) && e.set(o, { buffer: o.buffer, type: o.type, bytesPerElement: o.elementSize, version: o.version }); return; } const c = e.get(o); if (c === void 0) e.set(o, t(o, l)); else if (c.version < o.version) { if (c.size !== o.array.byteLength) throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported."); n(c.buffer, o, l), c.version = o.version; } } return { get: i, remove: r, update: a }; } var _0 = `#ifdef USE_ALPHAHASH if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; #endif`, y0 = `#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`, M0 = `#ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; #endif`, S0 = `#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`, w0 = `#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`, E0 = `#ifdef USE_ALPHATEST uniform float alphaTest; #endif`, T0 = `#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`, C0 = `#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; #endif`, A0 = `#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`, P0 = `#ifdef USE_BATCHING mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); #endif`, R0 = `vec3 transformed = vec3( position ); #ifdef USE_ALPHAHASH vPosition = vec3( position ); #endif`, L0 = `vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); #endif`, D0 = `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`, I0 = `#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`, N0 = `#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`, k0 = `#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`, U0 = `#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`, B0 = `#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`, O0 = `#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`, F0 = `#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`, z0 = `#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`, H0 = `#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`, V0 = `#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`, G0 = `#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`, W0 = `#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`, X0 = `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`, j0 = `#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`, Z0 = `#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`, q0 = `#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`, Y0 = `#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`, K0 = "gl_FragColor = linearToOutputTexel( gl_FragColor );", $0 = `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 ); }`, J0 = `#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`, Q0 = `#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`, eg = `#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`, tg = `#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`, ng = `#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`, ig = `#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`, sg = `#ifdef USE_FOG varying float vFogDepth; #endif`, rg = `#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`, ag = `#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`, og = `#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 }`, lg = `#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`, cg = `LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`, hg = `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`, ug = `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`, dg = `#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`, fg = `ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`, pg = `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`, mg = `BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`, gg = `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`, xg = `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`, vg = `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 ); }`, bg = ` 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`, _g = `#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`, yg = `#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`, Mg = `#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`, Sg = `#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`, wg = `#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`, Eg = `#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`, Tg = `#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`, Cg = `#ifdef USE_MAP uniform sampler2D map; #endif`, Ag = `#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`, Pg = `#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`, Rg = `float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`, Lg = `#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`, Dg = `#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`, Ig = `#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`, Ng = `#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`, kg = `#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`, Ug = `#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`, Bg = `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;`, Og = `#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`, Fg = `#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`, zg = `#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`, Hg = `#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`, Vg = `#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`, Gg = `#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`, Wg = `#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`, Xg = `#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`, jg = `#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`, Zg = `#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, qg = `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 ); }`, Yg = `#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`, Kg = `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;`, $g = `#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`, Jg = `#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`, Qg = `float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`, ex = `#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`, tx = `#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`, nx = `#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`, ix = `#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`, sx = `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; }`, rx = `#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`, ax = `#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`, ox = `#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`, lx = `#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`, cx = `float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`, hx = `#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`, ux = `#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`, dx = `#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; }`, fx = `#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`, px = `#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`, mx = `#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`, gx = `#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`, xx = `#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`, vx = `#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 bx = `varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`, _x = `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 #include }`, yx = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`, Mx = `#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 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 #include }`, Sx = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`, wx = `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 #include }`, Ex = `#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`, Tx = `#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include #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 }`, Cx = `#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`, Ax = `#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`, Px = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`, Rx = `uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`, Lx = `uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`, Dx = `uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`, Ix = `#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`, Nx = `uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include 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 reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`, kx = `#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`, Ux = `#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`, Bx = `#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`, Ox = `#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include 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 #include #include #include #include #include }`, Fx = `#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`, zx = `#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`, Hx = `#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`, Vx = `#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`, Gx = `#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`, Wx = `#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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include 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 #include #include #include #include #include }`, Xx = `#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`, jx = `#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`, Zx = `uniform float size; uniform float scale; #include #include #include #include #include #include #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 #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`, qx = `uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`, Yx = `#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`, Kx = `uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`, $x = `uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include 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 #include #include }`, Jx = `uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`, Qe = { alphahash_fragment: _0, alphahash_pars_fragment: y0, alphamap_fragment: M0, alphamap_pars_fragment: S0, alphatest_fragment: w0, alphatest_pars_fragment: E0, aomap_fragment: T0, aomap_pars_fragment: C0, batching_pars_vertex: A0, batching_vertex: P0, begin_vertex: R0, beginnormal_vertex: L0, bsdfs: D0, iridescence_fragment: I0, bumpmap_pars_fragment: N0, clipping_planes_fragment: k0, clipping_planes_pars_fragment: U0, clipping_planes_pars_vertex: B0, clipping_planes_vertex: O0, color_fragment: F0, color_pars_fragment: z0, color_pars_vertex: H0, color_vertex: V0, common: G0, cube_uv_reflection_fragment: W0, defaultnormal_vertex: X0, displacementmap_pars_vertex: j0, displacementmap_vertex: Z0, emissivemap_fragment: q0, emissivemap_pars_fragment: Y0, colorspace_fragment: K0, colorspace_pars_fragment: $0, envmap_fragment: J0, envmap_common_pars_fragment: Q0, envmap_pars_fragment: eg, envmap_pars_vertex: tg, envmap_physical_pars_fragment: dg, envmap_vertex: ng, fog_vertex: ig, fog_pars_vertex: sg, fog_fragment: rg, fog_pars_fragment: ag, gradientmap_pars_fragment: og, lightmap_pars_fragment: lg, lights_lambert_fragment: cg, lights_lambert_pars_fragment: hg, lights_pars_begin: ug, lights_toon_fragment: fg, lights_toon_pars_fragment: pg, lights_phong_fragment: mg, lights_phong_pars_fragment: gg, lights_physical_fragment: xg, lights_physical_pars_fragment: vg, lights_fragment_begin: bg, lights_fragment_maps: _g, lights_fragment_end: yg, logdepthbuf_fragment: Mg, logdepthbuf_pars_fragment: Sg, logdepthbuf_pars_vertex: wg, logdepthbuf_vertex: Eg, map_fragment: Tg, map_pars_fragment: Cg, map_particle_fragment: Ag, map_particle_pars_fragment: Pg, metalnessmap_fragment: Rg, metalnessmap_pars_fragment: Lg, morphinstance_vertex: Dg, morphcolor_vertex: Ig, morphnormal_vertex: Ng, morphtarget_pars_vertex: kg, morphtarget_vertex: Ug, normal_fragment_begin: Bg, normal_fragment_maps: Og, normal_pars_fragment: Fg, normal_pars_vertex: zg, normal_vertex: Hg, normalmap_pars_fragment: Vg, clearcoat_normal_fragment_begin: Gg, clearcoat_normal_fragment_maps: Wg, clearcoat_pars_fragment: Xg, iridescence_pars_fragment: jg, opaque_fragment: Zg, packing: qg, premultiplied_alpha_fragment: Yg, project_vertex: Kg, dithering_fragment: $g, dithering_pars_fragment: Jg, roughnessmap_fragment: Qg, roughnessmap_pars_fragment: ex, shadowmap_pars_fragment: tx, shadowmap_pars_vertex: nx, shadowmap_vertex: ix, shadowmask_pars_fragment: sx, skinbase_vertex: rx, skinning_pars_vertex: ax, skinning_vertex: ox, skinnormal_vertex: lx, specularmap_fragment: cx, specularmap_pars_fragment: hx, tonemapping_fragment: ux, tonemapping_pars_fragment: dx, transmission_fragment: fx, transmission_pars_fragment: px, uv_pars_fragment: mx, uv_pars_vertex: gx, uv_vertex: xx, worldpos_vertex: vx, background_vert: bx, background_frag: _x, backgroundCube_vert: yx, backgroundCube_frag: Mx, cube_vert: Sx, cube_frag: wx, depth_vert: Ex, depth_frag: Tx, distanceRGBA_vert: Cx, distanceRGBA_frag: Ax, equirect_vert: Px, equirect_frag: Rx, linedashed_vert: Lx, linedashed_frag: Dx, meshbasic_vert: Ix, meshbasic_frag: Nx, meshlambert_vert: kx, meshlambert_frag: Ux, meshmatcap_vert: Bx, meshmatcap_frag: Ox, meshnormal_vert: Fx, meshnormal_frag: zx, meshphong_vert: Hx, meshphong_frag: Vx, meshphysical_vert: Gx, meshphysical_frag: Wx, meshtoon_vert: Xx, meshtoon_frag: jx, points_vert: Zx, points_frag: qx, shadow_vert: Yx, shadow_frag: Kx, sprite_vert: $x, sprite_frag: Jx }, Pe = { common: { diffuse: { value: /* @__PURE__ */ new Fe(16777215) }, opacity: { value: 1 }, map: { value: null }, mapTransform: { value: /* @__PURE__ */ new $e() }, alphaMap: { value: null }, alphaMapTransform: { value: /* @__PURE__ */ new $e() }, alphaTest: { value: 0 } }, specularmap: { specularMap: { value: null }, specularMapTransform: { value: /* @__PURE__ */ new $e() } }, envmap: { envMap: { value: null }, envMapRotation: { value: /* @__PURE__ */ new $e() }, flipEnvMap: { value: -1 }, reflectivity: { value: 1 }, // basic, lambert, phong ior: { value: 1.5 }, // physical refractionRatio: { value: 0.98 }, // basic, lambert, phong dfgLUT: { value: null } // DFG LUT for physically-based rendering }, aomap: { aoMap: { value: null }, aoMapIntensity: { value: 1 }, aoMapTransform: { value: /* @__PURE__ */ new $e() } }, lightmap: { lightMap: { value: null }, lightMapIntensity: { value: 1 }, lightMapTransform: { value: /* @__PURE__ */ new $e() } }, bumpmap: { bumpMap: { value: null }, bumpMapTransform: { value: /* @__PURE__ */ new $e() }, bumpScale: { value: 1 } }, normalmap: { normalMap: { value: null }, normalMapTransform: { value: /* @__PURE__ */ new $e() }, normalScale: { value: /* @__PURE__ */ new ue(1, 1) } }, displacementmap: { displacementMap: { value: null }, displacementMapTransform: { value: /* @__PURE__ */ new $e() }, displacementScale: { value: 1 }, displacementBias: { value: 0 } }, emissivemap: { emissiveMap: { value: null }, emissiveMapTransform: { value: /* @__PURE__ */ new $e() } }, metalnessmap: { metalnessMap: { value: null }, metalnessMapTransform: { value: /* @__PURE__ */ new $e() } }, roughnessmap: { roughnessMap: { value: null }, roughnessMapTransform: { value: /* @__PURE__ */ new $e() } }, gradientmap: { gradientMap: { value: null } }, fog: { fogDensity: { value: 25e-5 }, fogNear: { value: 1 }, fogFar: { value: 2e3 }, fogColor: { value: /* @__PURE__ */ new Fe(16777215) } }, lights: { ambientLightColor: { value: [] }, lightProbe: { value: [] }, directionalLights: { value: [], properties: { direction: {}, color: {} } }, directionalLightShadows: { value: [], properties: { shadowIntensity: 1, shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {} } }, directionalShadowMap: { value: [] }, directionalShadowMatrix: { value: [] }, spotLights: { value: [], properties: { color: {}, position: {}, direction: {}, distance: {}, coneCos: {}, penumbraCos: {}, decay: {} } }, spotLightShadows: { value: [], properties: { shadowIntensity: 1, shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {} } }, spotLightMap: { value: [] }, spotShadowMap: { value: [] }, spotLightMatrix: { value: [] }, pointLights: { value: [], properties: { color: {}, position: {}, decay: {}, distance: {} } }, pointLightShadows: { value: [], properties: { shadowIntensity: 1, shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {}, shadowCameraNear: {}, shadowCameraFar: {} } }, pointShadowMap: { value: [] }, pointShadowMatrix: { value: [] }, hemisphereLights: { value: [], properties: { direction: {}, skyColor: {}, groundColor: {} } }, // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src rectAreaLights: { value: [], properties: { color: {}, position: {}, width: {}, height: {} } }, ltc_1: { value: null }, ltc_2: { value: null } }, points: { diffuse: { value: /* @__PURE__ */ new Fe(16777215) }, opacity: { value: 1 }, size: { value: 1 }, scale: { value: 1 }, map: { value: null }, alphaMap: { value: null }, alphaMapTransform: { value: /* @__PURE__ */ new $e() }, alphaTest: { value: 0 }, uvTransform: { value: /* @__PURE__ */ new $e() } }, sprite: { diffuse: { value: /* @__PURE__ */ new Fe(16777215) }, opacity: { value: 1 }, center: { value: /* @__PURE__ */ new ue(0.5, 0.5) }, rotation: { value: 0 }, map: { value: null }, mapTransform: { value: /* @__PURE__ */ new $e() }, alphaMap: { value: null }, alphaMapTransform: { value: /* @__PURE__ */ new $e() }, alphaTest: { value: 0 } } }, Fn = { basic: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.specularmap, Pe.envmap, Pe.aomap, Pe.lightmap, Pe.fog ]), vertexShader: Qe.meshbasic_vert, fragmentShader: Qe.meshbasic_frag }, lambert: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.specularmap, Pe.envmap, Pe.aomap, Pe.lightmap, Pe.emissivemap, Pe.bumpmap, Pe.normalmap, Pe.displacementmap, Pe.fog, Pe.lights, { emissive: { value: /* @__PURE__ */ new Fe(0) } } ]), vertexShader: Qe.meshlambert_vert, fragmentShader: Qe.meshlambert_frag }, phong: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.specularmap, Pe.envmap, Pe.aomap, Pe.lightmap, Pe.emissivemap, Pe.bumpmap, Pe.normalmap, Pe.displacementmap, Pe.fog, Pe.lights, { emissive: { value: /* @__PURE__ */ new Fe(0) }, specular: { value: /* @__PURE__ */ new Fe(1118481) }, shininess: { value: 30 } } ]), vertexShader: Qe.meshphong_vert, fragmentShader: Qe.meshphong_frag }, standard: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.envmap, Pe.aomap, Pe.lightmap, Pe.emissivemap, Pe.bumpmap, Pe.normalmap, Pe.displacementmap, Pe.roughnessmap, Pe.metalnessmap, Pe.fog, Pe.lights, { emissive: { value: /* @__PURE__ */ new Fe(0) }, roughness: { value: 1 }, metalness: { value: 0 }, envMapIntensity: { value: 1 } } ]), vertexShader: Qe.meshphysical_vert, fragmentShader: Qe.meshphysical_frag }, toon: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.aomap, Pe.lightmap, Pe.emissivemap, Pe.bumpmap, Pe.normalmap, Pe.displacementmap, Pe.gradientmap, Pe.fog, Pe.lights, { emissive: { value: /* @__PURE__ */ new Fe(0) } } ]), vertexShader: Qe.meshtoon_vert, fragmentShader: Qe.meshtoon_frag }, matcap: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.bumpmap, Pe.normalmap, Pe.displacementmap, Pe.fog, { matcap: { value: null } } ]), vertexShader: Qe.meshmatcap_vert, fragmentShader: Qe.meshmatcap_frag }, points: { uniforms: /* @__PURE__ */ Kt([ Pe.points, Pe.fog ]), vertexShader: Qe.points_vert, fragmentShader: Qe.points_frag }, dashed: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.fog, { scale: { value: 1 }, dashSize: { value: 1 }, totalSize: { value: 2 } } ]), vertexShader: Qe.linedashed_vert, fragmentShader: Qe.linedashed_frag }, depth: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.displacementmap ]), vertexShader: Qe.depth_vert, fragmentShader: Qe.depth_frag }, normal: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.bumpmap, Pe.normalmap, Pe.displacementmap, { opacity: { value: 1 } } ]), vertexShader: Qe.meshnormal_vert, fragmentShader: Qe.meshnormal_frag }, sprite: { uniforms: /* @__PURE__ */ Kt([ Pe.sprite, Pe.fog ]), vertexShader: Qe.sprite_vert, fragmentShader: Qe.sprite_frag }, background: { uniforms: { uvTransform: { value: /* @__PURE__ */ new $e() }, t2D: { value: null }, backgroundIntensity: { value: 1 } }, vertexShader: Qe.background_vert, fragmentShader: Qe.background_frag }, backgroundCube: { uniforms: { envMap: { value: null }, flipEnvMap: { value: -1 }, backgroundBlurriness: { value: 0 }, backgroundIntensity: { value: 1 }, backgroundRotation: { value: /* @__PURE__ */ new $e() } }, vertexShader: Qe.backgroundCube_vert, fragmentShader: Qe.backgroundCube_frag }, cube: { uniforms: { tCube: { value: null }, tFlip: { value: -1 }, opacity: { value: 1 } }, vertexShader: Qe.cube_vert, fragmentShader: Qe.cube_frag }, equirect: { uniforms: { tEquirect: { value: null } }, vertexShader: Qe.equirect_vert, fragmentShader: Qe.equirect_frag }, distanceRGBA: { uniforms: /* @__PURE__ */ Kt([ Pe.common, Pe.displacementmap, { referencePosition: { value: /* @__PURE__ */ new R() }, nearDistance: { value: 1 }, farDistance: { value: 1e3 } } ]), vertexShader: Qe.distanceRGBA_vert, fragmentShader: Qe.distanceRGBA_frag }, shadow: { uniforms: /* @__PURE__ */ Kt([ Pe.lights, Pe.fog, { color: { value: /* @__PURE__ */ new Fe(0) }, opacity: { value: 1 } } ]), vertexShader: Qe.shadow_vert, fragmentShader: Qe.shadow_frag } }; Fn.physical = { uniforms: /* @__PURE__ */ Kt([ Fn.standard.uniforms, { clearcoat: { value: 0 }, clearcoatMap: { value: null }, clearcoatMapTransform: { value: /* @__PURE__ */ new $e() }, clearcoatNormalMap: { value: null }, clearcoatNormalMapTransform: { value: /* @__PURE__ */ new $e() }, clearcoatNormalScale: { value: /* @__PURE__ */ new ue(1, 1) }, clearcoatRoughness: { value: 0 }, clearcoatRoughnessMap: { value: null }, clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new $e() }, dispersion: { value: 0 }, iridescence: { value: 0 }, iridescenceMap: { value: null }, iridescenceMapTransform: { value: /* @__PURE__ */ new $e() }, iridescenceIOR: { value: 1.3 }, iridescenceThicknessMinimum: { value: 100 }, iridescenceThicknessMaximum: { value: 400 }, iridescenceThicknessMap: { value: null }, iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new $e() }, sheen: { value: 0 }, sheenColor: { value: /* @__PURE__ */ new Fe(0) }, sheenColorMap: { value: null }, sheenColorMapTransform: { value: /* @__PURE__ */ new $e() }, sheenRoughness: { value: 1 }, sheenRoughnessMap: { value: null }, sheenRoughnessMapTransform: { value: /* @__PURE__ */ new $e() }, transmission: { value: 0 }, transmissionMap: { value: null }, transmissionMapTransform: { value: /* @__PURE__ */ new $e() }, transmissionSamplerSize: { value: /* @__PURE__ */ new ue() }, transmissionSamplerMap: { value: null }, thickness: { value: 0 }, thicknessMap: { value: null }, thicknessMapTransform: { value: /* @__PURE__ */ new $e() }, attenuationDistance: { value: 0 }, attenuationColor: { value: /* @__PURE__ */ new Fe(0) }, specularColor: { value: /* @__PURE__ */ new Fe(1, 1, 1) }, specularColorMap: { value: null }, specularColorMapTransform: { value: /* @__PURE__ */ new $e() }, specularIntensity: { value: 1 }, specularIntensityMap: { value: null }, specularIntensityMapTransform: { value: /* @__PURE__ */ new $e() }, anisotropyVector: { value: /* @__PURE__ */ new ue() }, anisotropyMap: { value: null }, anisotropyMapTransform: { value: /* @__PURE__ */ new $e() } } ]), vertexShader: Qe.meshphysical_vert, fragmentShader: Qe.meshphysical_frag }; const Yr = { r: 0, b: 0, g: 0 }, Si = /* @__PURE__ */ new cn(), Qx = /* @__PURE__ */ new je(); function e1(s, e, t, n, i, r, a) { const o = new Fe(0); let l = r === !0 ? 0 : 1, c, h, u = null, f = 0, d = null; function p(b) { let M = b.isScene === !0 ? b.background : null; return M && M.isTexture && (M = (b.backgroundBlurriness > 0 ? t : e).get(M)), M; } function g(b) { let M = !1; const C = p(b); C === null ? m(o, l) : C && C.isColor && (m(C, 1), M = !0); const T = s.xr.getEnvironmentBlendMode(); T === "additive" ? n.buffers.color.setClear(0, 0, 0, 1, a) : T === "alpha-blend" && n.buffers.color.setClear(0, 0, 0, 0, a), (s.autoClear || M) && (n.buffers.depth.setTest(!0), n.buffers.depth.setMask(!0), n.buffers.color.setMask(!0), s.clear(s.autoClearColor, s.autoClearDepth, s.autoClearStencil)); } function x(b, M) { const C = p(M); C && (C.isCubeTexture || C.mapping === Aa) ? (h === void 0 && (h = new ft( new Li(1, 1, 1), new Pt({ name: "BackgroundCubeMaterial", uniforms: bs(Fn.backgroundCube.uniforms), vertexShader: Fn.backgroundCube.vertexShader, fragmentShader: Fn.backgroundCube.fragmentShader, side: Jt, depthTest: !1, depthWrite: !1, fog: !1, allowOverride: !1 }) ), h.geometry.deleteAttribute("normal"), h.geometry.deleteAttribute("uv"), h.onBeforeRender = function(T, D, U) { this.matrixWorld.copyPosition(U.matrixWorld); }, Object.defineProperty(h.material, "envMap", { get: function() { return this.uniforms.envMap.value; } }), i.update(h)), Si.copy(M.backgroundRotation), Si.x *= -1, Si.y *= -1, Si.z *= -1, C.isCubeTexture && C.isRenderTargetTexture === !1 && (Si.y *= -1, Si.z *= -1), h.material.uniforms.envMap.value = C, h.material.uniforms.flipEnvMap.value = C.isCubeTexture && C.isRenderTargetTexture === !1 ? -1 : 1, h.material.uniforms.backgroundBlurriness.value = M.backgroundBlurriness, h.material.uniforms.backgroundIntensity.value = M.backgroundIntensity, h.material.uniforms.backgroundRotation.value.setFromMatrix4(Qx.makeRotationFromEuler(Si)), h.material.toneMapped = it.getTransfer(C.colorSpace) !== ot, (u !== C || f !== C.version || d !== s.toneMapping) && (h.material.needsUpdate = !0, u = C, f = C.version, d = s.toneMapping), h.layers.enableAll(), b.unshift(h, h.geometry, h.material, 0, 0, null)) : C && C.isTexture && (c === void 0 && (c = new ft( new Ii(2, 2), new Pt({ name: "BackgroundMaterial", uniforms: bs(Fn.background.uniforms), vertexShader: Fn.background.vertexShader, fragmentShader: Fn.background.fragmentShader, side: Rn, depthTest: !1, depthWrite: !1, fog: !1, allowOverride: !1 }) ), c.geometry.deleteAttribute("normal"), Object.defineProperty(c.material, "map", { get: function() { return this.uniforms.t2D.value; } }), i.update(c)), c.material.uniforms.t2D.value = C, c.material.uniforms.backgroundIntensity.value = M.backgroundIntensity, c.material.toneMapped = it.getTransfer(C.colorSpace) !== ot, C.matrixAutoUpdate === !0 && C.updateMatrix(), c.material.uniforms.uvTransform.value.copy(C.matrix), (u !== C || f !== C.version || d !== s.toneMapping) && (c.material.needsUpdate = !0, u = C, f = C.version, d = s.toneMapping), c.layers.enableAll(), b.unshift(c, c.geometry, c.material, 0, 0, null)); } function m(b, M) { b.getRGB(Yr, id(s)), n.buffers.color.setClear(Yr.r, Yr.g, Yr.b, M, a); } function v() { h !== void 0 && (h.geometry.dispose(), h.material.dispose(), h = void 0), c !== void 0 && (c.geometry.dispose(), c.material.dispose(), c = void 0); } return { getClearColor: function() { return o; }, setClearColor: function(b, M = 1) { o.set(b), l = M, m(o, l); }, getClearAlpha: function() { return l; }, setClearAlpha: function(b) { l = b, m(o, l); }, render: g, addToRenderList: x, dispose: v }; } function t1(s, e) { const t = s.getParameter(s.MAX_VERTEX_ATTRIBS), n = {}, i = f(null); let r = i, a = !1; function o(w, B, P, O, y) { let H = !1; const Y = u(O, P, B); r !== Y && (r = Y, c(r.object)), H = d(w, O, P, y), H && p(w, O, P, y), y !== null && e.update(y, s.ELEMENT_ARRAY_BUFFER), (H || a) && (a = !1, M(w, B, P, O), y !== null && s.bindBuffer(s.ELEMENT_ARRAY_BUFFER, e.get(y).buffer)); } function l() { return s.createVertexArray(); } function c(w) { return s.bindVertexArray(w); } function h(w) { return s.deleteVertexArray(w); } function u(w, B, P) { const O = P.wireframe === !0; let y = n[w.id]; y === void 0 && (y = {}, n[w.id] = y); let H = y[B.id]; H === void 0 && (H = {}, y[B.id] = H); let Y = H[O]; return Y === void 0 && (Y = f(l()), H[O] = Y), Y; } function f(w) { const B = [], P = [], O = []; for (let y = 0; y < t; y++) B[y] = 0, P[y] = 0, O[y] = 0; return { // for backward compatibility on non-VAO support browser geometry: null, program: null, wireframe: !1, newAttributes: B, enabledAttributes: P, attributeDivisors: O, object: w, attributes: {}, index: null }; } function d(w, B, P, O) { const y = r.attributes, H = B.attributes; let Y = 0; const j = P.getAttributes(); for (const J in j) if (j[J].location >= 0) { const ae = y[J]; let X = H[J]; if (X === void 0 && (J === "instanceMatrix" && w.instanceMatrix && (X = w.instanceMatrix), J === "instanceColor" && w.instanceColor && (X = w.instanceColor)), ae === void 0 || ae.attribute !== X || X && ae.data !== X.data) return !0; Y++; } return r.attributesNum !== Y || r.index !== O; } function p(w, B, P, O) { const y = {}, H = B.attributes; let Y = 0; const j = P.getAttributes(); for (const J in j) if (j[J].location >= 0) { let ae = H[J]; ae === void 0 && (J === "instanceMatrix" && w.instanceMatrix && (ae = w.instanceMatrix), J === "instanceColor" && w.instanceColor && (ae = w.instanceColor)); const X = {}; X.attribute = ae, ae && ae.data && (X.data = ae.data), y[J] = X, Y++; } r.attributes = y, r.attributesNum = Y, r.index = O; } function g() { const w = r.newAttributes; for (let B = 0, P = w.length; B < P; B++) w[B] = 0; } function x(w) { m(w, 0); } function m(w, B) { const P = r.newAttributes, O = r.enabledAttributes, y = r.attributeDivisors; P[w] = 1, O[w] === 0 && (s.enableVertexAttribArray(w), O[w] = 1), y[w] !== B && (s.vertexAttribDivisor(w, B), y[w] = B); } function v() { const w = r.newAttributes, B = r.enabledAttributes; for (let P = 0, O = B.length; P < O; P++) B[P] !== w[P] && (s.disableVertexAttribArray(P), B[P] = 0); } function b(w, B, P, O, y, H, Y) { Y === !0 ? s.vertexAttribIPointer(w, B, P, y, H) : s.vertexAttribPointer(w, B, P, O, y, H); } function M(w, B, P, O) { g(); const y = O.attributes, H = P.getAttributes(), Y = B.defaultAttributeValues; for (const j in H) { const J = H[j]; if (J.location >= 0) { let Z = y[j]; if (Z === void 0 && (j === "instanceMatrix" && w.instanceMatrix && (Z = w.instanceMatrix), j === "instanceColor" && w.instanceColor && (Z = w.instanceColor)), Z !== void 0) { const ae = Z.normalized, X = Z.itemSize, q = e.get(Z); if (q === void 0) continue; const ge = q.buffer, pe = q.type, de = q.bytesPerElement, ie = pe === s.INT || pe === s.UNSIGNED_INT || Z.gpuType === Yl; if (Z.isInterleavedBufferAttribute) { const ce = Z.data, fe = ce.stride, ve = Z.offset; if (ce.isInstancedInterleavedBuffer) { for (let Ee = 0; Ee < J.locationSize; Ee++) m(J.location + Ee, ce.meshPerAttribute); w.isInstancedMesh !== !0 && O._maxInstanceCount === void 0 && (O._maxInstanceCount = ce.meshPerAttribute * ce.count); } else for (let Ee = 0; Ee < J.locationSize; Ee++) x(J.location + Ee); s.bindBuffer(s.ARRAY_BUFFER, ge); for (let Ee = 0; Ee < J.locationSize; Ee++) b( J.location + Ee, X / J.locationSize, pe, ae, fe * de, (ve + X / J.locationSize * Ee) * de, ie ); } else { if (Z.isInstancedBufferAttribute) { for (let ce = 0; ce < J.locationSize; ce++) m(J.location + ce, Z.meshPerAttribute); w.isInstancedMesh !== !0 && O._maxInstanceCount === void 0 && (O._maxInstanceCount = Z.meshPerAttribute * Z.count); } else for (let ce = 0; ce < J.locationSize; ce++) x(J.location + ce); s.bindBuffer(s.ARRAY_BUFFER, ge); for (let ce = 0; ce < J.locationSize; ce++) b( J.location + ce, X / J.locationSize, pe, ae, X * de, X / J.locationSize * ce * de, ie ); } } else if (Y !== void 0) { const ae = Y[j]; if (ae !== void 0) switch (ae.length) { case 2: s.vertexAttrib2fv(J.location, ae); break; case 3: s.vertexAttrib3fv(J.location, ae); break; case 4: s.vertexAttrib4fv(J.location, ae); break; default: s.vertexAttrib1fv(J.location, ae); } } } } v(); } function C() { U(); for (const w in n) { const B = n[w]; for (const P in B) { const O = B[P]; for (const y in O) h(O[y].object), delete O[y]; delete B[P]; } delete n[w]; } } function T(w) { if (n[w.id] === void 0) return; const B = n[w.id]; for (const P in B) { const O = B[P]; for (const y in O) h(O[y].object), delete O[y]; delete B[P]; } delete n[w.id]; } function D(w) { for (const B in n) { const P = n[B]; if (P[w.id] === void 0) continue; const O = P[w.id]; for (const y in O) h(O[y].object), delete O[y]; delete P[w.id]; } } function U() { S(), a = !0, r !== i && (r = i, c(r.object)); } function S() { i.geometry = null, i.program = null, i.wireframe = !1; } return { setup: o, reset: U, resetDefaultState: S, dispose: C, releaseStatesOfGeometry: T, releaseStatesOfProgram: D, initAttributes: g, enableAttribute: x, disableUnusedAttributes: v }; } function n1(s, e, t) { let n; function i(c) { n = c; } function r(c, h) { s.drawArrays(n, c, h), t.update(h, n, 1); } function a(c, h, u) { u !== 0 && (s.drawArraysInstanced(n, c, h, u), t.update(h, n, u)); } function o(c, h, u) { if (u === 0) return; e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n, c, 0, h, 0, u); let d = 0; for (let p = 0; p < u; p++) d += h[p]; t.update(d, n, 1); } function l(c, h, u, f) { if (u === 0) return; const d = e.get("WEBGL_multi_draw"); if (d === null) for (let p = 0; p < c.length; p++) a(c[p], h[p], f[p]); else { d.multiDrawArraysInstancedWEBGL(n, c, 0, h, 0, f, 0, u); let p = 0; for (let g = 0; g < u; g++) p += h[g] * f[g]; t.update(p, n, 1); } } this.setMode = i, this.render = r, this.renderInstances = a, this.renderMultiDraw = o, this.renderMultiDrawInstances = l; } function i1(s, e, t, n) { let i; function r() { if (i !== void 0) return i; if (e.has("EXT_texture_filter_anisotropic") === !0) { const D = e.get("EXT_texture_filter_anisotropic"); i = s.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT); } else i = 0; return i; } function a(D) { return !(D !== sn && n.convert(D) !== s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT)); } function o(D) { const U = D === _n && (e.has("EXT_color_buffer_half_float") || e.has("EXT_color_buffer_float")); return !(D !== Ln && n.convert(D) !== s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513) D !== Pn && !U); } function l(D) { if (D === "highp") { if (s.getShaderPrecisionFormat(s.VERTEX_SHADER, s.HIGH_FLOAT).precision > 0 && s.getShaderPrecisionFormat(s.FRAGMENT_SHADER, s.HIGH_FLOAT).precision > 0) return "highp"; D = "mediump"; } return D === "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 && (ze("WebGLRenderer:", c, "not supported, using", h, "instead."), c = h); const u = t.logarithmicDepthBuffer === !0, f = t.reversedDepthBuffer === !0 && e.has("EXT_clip_control"), d = s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS), p = s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS), g = s.getParameter(s.MAX_TEXTURE_SIZE), x = s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE), m = s.getParameter(s.MAX_VERTEX_ATTRIBS), v = s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS), b = s.getParameter(s.MAX_VARYING_VECTORS), M = s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS), C = p > 0, T = s.getParameter(s.MAX_SAMPLES); return { isWebGL2: !0, // keeping this for backwards compatibility getMaxAnisotropy: r, getMaxPrecision: l, textureFormatReadable: a, textureTypeReadable: o, precision: c, logarithmicDepthBuffer: u, reversedDepthBuffer: f, maxTextures: d, maxVertexTextures: p, maxTextureSize: g, maxCubemapSize: x, maxAttributes: m, maxVertexUniforms: v, maxVaryings: b, maxFragmentUniforms: M, vertexTextures: C, maxSamples: T }; } function s1(s) { const e = this; let t = null, n = 0, i = !1, r = !1; const a = new Ct(), o = new $e(), l = { value: null, needsUpdate: !1 }; this.uniform = l, this.numPlanes = 0, this.numIntersection = 0, this.init = function(u, f) { const d = u.length !== 0 || f || // enable state of previous frame - the clipping code has to // run another frame in order to reset the state: n !== 0 || i; return i = f, n = u.length, d; }, this.beginShadows = function() { r = !0, h(null); }, this.endShadows = function() { r = !1; }, this.setGlobalState = function(u, f) { t = h(u, f, 0); }, this.setState = function(u, f, d) { const p = u.clippingPlanes, g = u.clipIntersection, x = u.clipShadows, m = s.get(u); if (!i || p === null || p.length === 0 || r && !x) r ? h(null) : c(); else { const v = r ? 0 : n, b = v * 4; let M = m.clippingState || null; l.value = M, M = h(p, f, b, d); for (let C = 0; C !== b; ++C) M[C] = t[C]; m.clippingState = M, this.numIntersection = g ? this.numPlanes : 0, this.numPlanes += v; } }; function c() { l.value !== t && (l.value = t, l.needsUpdate = n > 0), e.numPlanes = n, e.numIntersection = 0; } function h(u, f, d, p) { const g = u !== null ? u.length : 0; let x = null; if (g !== 0) { if (x = l.value, p !== !0 || x === null) { const m = d + g * 4, v = f.matrixWorldInverse; o.getNormalMatrix(v), (x === null || x.length < m) && (x = new Float32Array(m)); for (let b = 0, M = d; b !== g; ++b, M += 4) a.copy(u[b]).applyMatrix4(v, o), a.normal.toArray(x, M), x[M + 3] = a.constant; } l.value = x, l.needsUpdate = !0; } return e.numPlanes = g, e.numIntersection = 0, x; } } function r1(s) { let e = /* @__PURE__ */ new WeakMap(); function t(a, o) { return o === $o ? a.mapping = ps : o === Jo && (a.mapping = ms), a; } function n(a) { if (a && a.isTexture) { const o = a.mapping; if (o === $o || o === Jo) 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 jp(l.height); return c.fromEquirectangularTexture(s, a), e.set(a, c), a.addEventListener("dispose", i), t(c.texture, a.mapping); } else return null; } } return a; } function i(a) { const o = a.target; o.removeEventListener("dispose", i); const l = e.get(o); l !== void 0 && (e.delete(o), l.dispose()); } function r() { e = /* @__PURE__ */ new WeakMap(); } return { get: n, dispose: r }; } const mi = 4, Ph = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], Ti = 20, a1 = 256, Vs = /* @__PURE__ */ new zi(), Rh = /* @__PURE__ */ new Fe(); let So = null, wo = 0, Eo = 0, To = !1; const o1 = /* @__PURE__ */ new R(); class Lh { /** * Constructs a new PMREM generator. * * @param {WebGLRenderer} renderer - The renderer. */ 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; } /** * Generates a PMREM from a supplied Scene, which can be faster than using an * image if networking bandwidth is low. Optional sigma specifies a blur radius * in radians to be applied to the scene before PMREM generation. Optional near * and far planes ensure the scene is rendered in its entirety. * * @param {Scene} scene - The scene to be captured. * @param {number} [sigma=0] - The blur radius in radians. * @param {number} [near=0.1] - The near plane distance. * @param {number} [far=100] - The far plane distance. * @param {Object} [options={}] - The configuration options. * @param {number} [options.size=256] - The texture size of the PMREM. * @param {Vector3} [options.renderTarget=origin] - The position of the internal cube camera that renders the scene. * @return {WebGLRenderTarget} The resulting PMREM. */ fromScene(e, t = 0, n = 0.1, i = 100, r = {}) { const { size: a = 256, position: o = o1 } = r; So = this._renderer.getRenderTarget(), wo = this._renderer.getActiveCubeFace(), Eo = this._renderer.getActiveMipmapLevel(), To = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(a); const l = this._allocateTargets(); return l.depthBuffer = !0, this._sceneToCubeUV(e, n, i, l, o), t > 0 && this._blur(l, 0, 0, t), this._applyPMREM(l), this._cleanup(l), l; } /** * Generates a PMREM from an equirectangular texture, which can be either LDR * or HDR. The ideal input image size is 1k (1024 x 512), * as this matches best with the 256 x 256 cubemap output. * * @param {Texture} equirectangular - The equirectangular texture to be converted. * @param {?WebGLRenderTarget} [renderTarget=null] - The render target to use. * @return {WebGLRenderTarget} The resulting PMREM. */ fromEquirectangular(e, t = null) { return this._fromTexture(e, t); } /** * Generates a PMREM from an cubemap texture, which can be either LDR * or HDR. The ideal input cube size is 256 x 256, * as this matches best with the 256 x 256 cubemap output. * * @param {Texture} cubemap - The cubemap texture to be converted. * @param {?WebGLRenderTarget} [renderTarget=null] - The render target to use. * @return {WebGLRenderTarget} The resulting PMREM. */ fromCubemap(e, t = null) { return this._fromTexture(e, t); } /** * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during * your texture's network fetch for increased concurrency. */ compileCubemapShader() { this._cubemapMaterial === null && (this._cubemapMaterial = Nh(), this._compileMaterial(this._cubemapMaterial)); } /** * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during * your texture's network fetch for increased concurrency. */ compileEquirectangularShader() { this._equirectMaterial === null && (this._equirectMaterial = Ih(), this._compileMaterial(this._equirectMaterial)); } /** * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class, * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on * one of them will cause any others to also become unusable. */ 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()); } // private interface _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(So, wo, Eo), this._renderer.xr.enabled = To, e.scissorTest = !1, ss(e, 0, 0, e.width, e.height); } _fromTexture(e, t) { e.mapping === ps || e.mapping === ms ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), So = this._renderer.getRenderTarget(), wo = this._renderer.getActiveCubeFace(), Eo = this._renderer.getActiveMipmapLevel(), To = this._renderer.xr.enabled, this._renderer.xr.enabled = !1; const n = t || this._allocateTargets(); return this._textureToCubeUV(e, n), this._applyPMREM(n), this._cleanup(n), n; } _allocateTargets() { const e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, n = { magFilter: Ht, minFilter: Ht, generateMipmaps: !1, type: _n, format: sn, colorSpace: Tt, depthBuffer: !1 }, i = Dh(e, t, n); if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) { this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = Dh(e, t, n); const { _lodMax: r } = this; ({ lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas } = l1(r)), this._blurMaterial = h1(r, e, t), this._ggxMaterial = c1(r, e, t); } return i; } _compileMaterial(e) { const t = new ft(new xt(), e); this._renderer.compile(t, Vs); } _sceneToCubeUV(e, t, n, i, r) { const l = new jt(90, 1, t, n), c = [1, -1, 1, 1, 1, 1], h = [1, 1, 1, -1, -1, -1], u = this._renderer, f = u.autoClear, d = u.toneMapping; u.getClearColor(Rh), u.toneMapping = gi, u.autoClear = !1, u.state.buffers.depth.getReversed() && (u.setRenderTarget(i), u.clearDepth(), u.setRenderTarget(null)), this._backgroundBox === null && (this._backgroundBox = new ft( new Li(), new Nt({ name: "PMREM.Background", side: Jt, depthWrite: !1, depthTest: !1 }) )); const g = this._backgroundBox, x = g.material; let m = !1; const v = e.background; v ? v.isColor && (x.color.copy(v), e.background = null, m = !0) : (x.color.copy(Rh), m = !0); for (let b = 0; b < 6; b++) { const M = b % 3; M === 0 ? (l.up.set(0, c[b], 0), l.position.set(r.x, r.y, r.z), l.lookAt(r.x + h[b], r.y, r.z)) : M === 1 ? (l.up.set(0, 0, c[b]), l.position.set(r.x, r.y, r.z), l.lookAt(r.x, r.y + h[b], r.z)) : (l.up.set(0, c[b], 0), l.position.set(r.x, r.y, r.z), l.lookAt(r.x, r.y, r.z + h[b])); const C = this._cubeSize; ss(i, M * C, b > 2 ? C : 0, C, C), u.setRenderTarget(i), m && u.render(g, l), u.render(e, l); } u.toneMapping = d, u.autoClear = f, e.background = v; } _textureToCubeUV(e, t) { const n = this._renderer, i = e.mapping === ps || e.mapping === ms; i ? (this._cubemapMaterial === null && (this._cubemapMaterial = Nh()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = Ih()); const r = i ? this._cubemapMaterial : this._equirectMaterial, a = this._lodMeshes[0]; a.material = r; const o = r.uniforms; o.envMap.value = e; const l = this._cubeSize; ss(t, 0, 0, 3 * l, 2 * l), n.setRenderTarget(t), n.render(a, Vs); } _applyPMREM(e) { const t = this._renderer, n = t.autoClear; t.autoClear = !1; const i = this._lodMeshes.length; for (let r = 1; r < i; r++) this._applyGGXFilter(e, r - 1, r); t.autoClear = n; } /** * Applies GGX VNDF importance sampling filter to generate a prefiltered environment map. * Uses Monte Carlo integration with VNDF importance sampling to accurately represent the * GGX BRDF for physically-based rendering. Reads from the previous LOD level and * applies incremental roughness filtering to avoid over-blurring. * * @private * @param {WebGLRenderTarget} cubeUVRenderTarget * @param {number} lodIn - Source LOD level to read from * @param {number} lodOut - Target LOD level to write to */ _applyGGXFilter(e, t, n) { const i = this._renderer, r = this._pingPongRenderTarget, a = this._ggxMaterial, o = this._lodMeshes[n]; o.material = a; const l = a.uniforms, c = n / (this._lodMeshes.length - 1), h = t / (this._lodMeshes.length - 1), u = Math.sqrt(c * c - h * h), f = 0.05 + c * 0.95, d = u * f, { _lodMax: p } = this, g = this._sizeLods[n], x = 3 * g * (n > p - mi ? n - p + mi : 0), m = 4 * (this._cubeSize - g); l.envMap.value = e.texture, l.roughness.value = d, l.mipInt.value = p - t, ss(r, x, m, 3 * g, 2 * g), i.setRenderTarget(r), i.render(o, Vs), l.envMap.value = r.texture, l.roughness.value = 0, l.mipInt.value = p - n, ss(e, x, m, 3 * g, 2 * g), i.setRenderTarget(e), i.render(o, Vs); } /** * This is a two-pass Gaussian blur for a cubemap. Normally this is done * vertically and horizontally, but this breaks down on a cube. Here we apply * the blur latitudinally (around the poles), and then longitudinally (towards * the poles) to approximate the orthogonally-separable blur. It is least * accurate at the poles, but still does a decent job. * * Used for initial scene blur in fromScene() method when sigma > 0. * * @private * @param {WebGLRenderTarget} cubeUVRenderTarget * @param {number} lodIn * @param {number} lodOut * @param {number} sigma * @param {Vector3} [poleAxis] */ _blur(e, t, n, i, r) { const a = this._pingPongRenderTarget; this._halfBlur( e, a, t, n, i, "latitudinal", r ), this._halfBlur( a, e, n, n, i, "longitudinal", r ); } _halfBlur(e, t, n, i, r, a, o) { const l = this._renderer, c = this._blurMaterial; a !== "latitudinal" && a !== "longitudinal" && et( "blur direction must be either latitudinal or longitudinal!" ); const h = 3, u = this._lodMeshes[i]; u.material = c; const f = c.uniforms, d = this._sizeLods[n] - 1, p = isFinite(r) ? Math.PI / (2 * d) : 2 * Math.PI / (2 * Ti - 1), g = r / p, x = isFinite(r) ? 1 + Math.floor(h * g) : Ti; x > Ti && ze(`sigmaRadians, ${r}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${Ti}`); const m = []; let v = 0; for (let D = 0; D < Ti; ++D) { const U = D / g, S = Math.exp(-U * U / 2); m.push(S), D === 0 ? v += S : D < x && (v += 2 * S); } for (let D = 0; D < m.length; D++) m[D] = m[D] / v; f.envMap.value = e.texture, f.samples.value = x, f.weights.value = m, f.latitudinal.value = a === "latitudinal", o && (f.poleAxis.value = o); const { _lodMax: b } = this; f.dTheta.value = p, f.mipInt.value = b - n; const M = this._sizeLods[i], C = 3 * M * (i > b - mi ? i - b + mi : 0), T = 4 * (this._cubeSize - M); ss(t, C, T, 3 * M, 2 * M), l.setRenderTarget(t), l.render(u, Vs); } } function l1(s) { const e = [], t = [], n = []; let i = s; const r = s - mi + 1 + Ph.length; for (let a = 0; a < r; a++) { const o = Math.pow(2, i); e.push(o); let l = 1 / o; a > s - mi ? l = Ph[a - s + mi - 1] : a === 0 && (l = 0), t.push(l); const c = 1 / (o - 2), h = -c, u = 1 + c, f = [h, h, u, h, u, u, h, h, u, u, h, u], d = 6, p = 6, g = 3, x = 2, m = 1, v = new Float32Array(g * p * d), b = new Float32Array(x * p * d), M = new Float32Array(m * p * d); for (let T = 0; T < d; T++) { const D = T % 3 * 2 / 3 - 1, U = T > 2 ? 0 : -1, S = [ D, U, 0, D + 2 / 3, U, 0, D + 2 / 3, U + 1, 0, D, U, 0, D + 2 / 3, U + 1, 0, D, U + 1, 0 ]; v.set(S, g * p * T), b.set(f, x * p * T); const w = [T, T, T, T, T, T]; M.set(w, m * p * T); } const C = new xt(); C.setAttribute("position", new gt(v, g)), C.setAttribute("uv", new gt(b, x)), C.setAttribute("faceIndex", new gt(M, m)), n.push(new ft(C, null)), i > mi && i--; } return { lodMeshes: n, sizeLods: e, sigmas: t }; } function Dh(s, e, t) { const n = new rn(s, e, t); return n.texture.mapping = Aa, n.texture.name = "PMREM.cubeUv", n.scissorTest = !0, n; } function ss(s, e, t, n, i) { s.viewport.set(e, t, n, i), s.scissor.set(e, t, n, i); } function c1(s, e, t) { return new Pt({ name: "PMREMGGXConvolution", defines: { GGX_SAMPLES: a1, 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: La(), fragmentShader: ( /* glsl */ ` precision highp float; precision highp int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform float roughness; uniform float mipInt; #define ENVMAP_TYPE_CUBE_UV #include #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: Ot, depthTest: !1, depthWrite: !1 }); } function h1(s, e, t) { const n = new Float32Array(Ti), i = new R(0, 1, 0); return new Pt({ name: "SphericalGaussianBlur", defines: { n: Ti, CUBEUV_TEXEL_WIDTH: 1 / e, CUBEUV_TEXEL_HEIGHT: 1 / t, CUBEUV_MAX_MIP: `${s}.0` }, uniforms: { envMap: { value: null }, samples: { value: 1 }, weights: { value: n }, latitudinal: { value: !1 }, dTheta: { value: 0 }, mipInt: { value: 0 }, poleAxis: { value: i } }, vertexShader: La(), fragmentShader: ( /* glsl */ ` 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 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: Ot, depthTest: !1, depthWrite: !1 }); } function Ih() { return new Pt({ name: "EquirectangularToCubeUV", uniforms: { envMap: { value: null } }, vertexShader: La(), fragmentShader: ( /* glsl */ ` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } ` ), blending: Ot, depthTest: !1, depthWrite: !1 }); } function Nh() { return new Pt({ name: "CubemapToCubeUV", uniforms: { envMap: { value: null }, flipEnvMap: { value: -1 } }, vertexShader: La(), fragmentShader: ( /* glsl */ ` 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: Ot, depthTest: !1, depthWrite: !1 }); } function La() { return ( /* glsl */ ` 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 u1(s) { let e = /* @__PURE__ */ new WeakMap(), t = null; function n(o) { if (o && o.isTexture) { const l = o.mapping, c = l === $o || l === Jo, h = l === ps || l === ms; if (c || h) { let u = e.get(o); const f = u !== void 0 ? u.texture.pmremVersion : 0; if (o.isRenderTargetTexture && o.pmremVersion !== f) return t === null && (t = new Lh(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 d = o.image; return c && d && d.height > 0 || h && d && i(d) ? (t === null && (t = new Lh(s)), u = c ? t.fromEquirectangular(o) : t.fromCubemap(o), u.texture.pmremVersion = o.pmremVersion, e.set(o, u), o.addEventListener("dispose", r), u.texture) : null; } } } return o; } function i(o) { let l = 0; const c = 6; for (let h = 0; h < c; h++) o[h] !== void 0 && l++; return l === c; } function r(o) { const l = o.target; l.removeEventListener("dispose", r); const c = e.get(l); c !== void 0 && (e.delete(l), c.dispose()); } function a() { e = /* @__PURE__ */ new WeakMap(), t !== null && (t.dispose(), t = null); } return { get: n, dispose: a }; } function d1(s) { const e = {}; function t(n) { if (e[n] !== void 0) return e[n]; const i = s.getExtension(n); return e[n] = i, i; } return { has: function(n) { return t(n) !== null; }, init: function() { t("EXT_color_buffer_float"), t("WEBGL_clip_cull_distance"), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture"), t("WEBGL_render_shared_exponent"); }, get: function(n) { const i = t(n); return i === null && lr("WebGLRenderer: " + n + " extension not supported."), i; } }; } function f1(s, e, t, n) { const i = {}, r = /* @__PURE__ */ new WeakMap(); function a(u) { const f = u.target; f.index !== null && e.remove(f.index); for (const p in f.attributes) e.remove(f.attributes[p]); f.removeEventListener("dispose", a), delete i[f.id]; const d = r.get(f); d && (e.remove(d), r.delete(f)), n.releaseStatesOfGeometry(f), f.isInstancedBufferGeometry === !0 && delete f._maxInstanceCount, t.memory.geometries--; } function o(u, f) { return i[f.id] === !0 || (f.addEventListener("dispose", a), i[f.id] = !0, t.memory.geometries++), f; } function l(u) { const f = u.attributes; for (const d in f) e.update(f[d], s.ARRAY_BUFFER); } function c(u) { const f = [], d = u.index, p = u.attributes.position; let g = 0; if (d !== null) { const v = d.array; g = d.version; for (let b = 0, M = v.length; b < M; b += 3) { const C = v[b + 0], T = v[b + 1], D = v[b + 2]; f.push(C, T, T, D, D, C); } } else if (p !== void 0) { const v = p.array; g = p.version; for (let b = 0, M = v.length / 3 - 1; b < M; b += 3) { const C = b + 0, T = b + 1, D = b + 2; f.push(C, T, T, D, D, C); } } else return; const x = new (Ju(f) ? nd : td)(f, 1); x.version = g; const m = r.get(u); m && e.remove(m), r.set(u, x); } function h(u) { const f = r.get(u); if (f) { const d = u.index; d !== null && f.version < d.version && c(u); } else c(u); return r.get(u); } return { get: o, update: l, getWireframeAttribute: h }; } function p1(s, e, t) { let n; function i(f) { n = f; } let r, a; function o(f) { r = f.type, a = f.bytesPerElement; } function l(f, d) { s.drawElements(n, d, r, f * a), t.update(d, n, 1); } function c(f, d, p) { p !== 0 && (s.drawElementsInstanced(n, d, r, f * a, p), t.update(d, n, p)); } function h(f, d, p) { if (p === 0) return; e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n, d, 0, r, f, 0, p); let x = 0; for (let m = 0; m < p; m++) x += d[m]; t.update(x, n, 1); } function u(f, d, p, g) { if (p === 0) return; const x = e.get("WEBGL_multi_draw"); if (x === null) for (let m = 0; m < f.length; m++) c(f[m] / a, d[m], g[m]); else { x.multiDrawElementsInstancedWEBGL(n, d, 0, r, f, 0, g, 0, p); let m = 0; for (let v = 0; v < p; v++) m += d[v] * g[v]; t.update(m, n, 1); } } this.setMode = i, this.setIndex = o, this.render = l, this.renderInstances = c, this.renderMultiDraw = h, this.renderMultiDrawInstances = u; } function m1(s) { const e = { geometries: 0, textures: 0 }, t = { frame: 0, calls: 0, triangles: 0, points: 0, lines: 0 }; function n(r, a, o) { switch (t.calls++, a) { case s.TRIANGLES: t.triangles += o * (r / 3); break; case s.LINES: t.lines += o * (r / 2); break; case s.LINE_STRIP: t.lines += o * (r - 1); break; case s.LINE_LOOP: t.lines += o * r; break; case s.POINTS: t.points += o * r; break; default: et("WebGLInfo: Unknown draw mode:", a); break; } } function i() { t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0; } return { memory: e, render: t, programs: null, autoReset: !0, reset: i, update: n }; } function g1(s, e, t) { const n = /* @__PURE__ */ new WeakMap(), i = new at(); function r(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 f = n.get(o); if (f === void 0 || f.count !== u) { let S = function() { D.dispose(), n.delete(o), o.removeEventListener("dispose", S); }; f !== void 0 && f.texture.dispose(); const d = o.morphAttributes.position !== void 0, p = o.morphAttributes.normal !== void 0, g = o.morphAttributes.color !== void 0, x = o.morphAttributes.position || [], m = o.morphAttributes.normal || [], v = o.morphAttributes.color || []; let b = 0; d === !0 && (b = 1), p === !0 && (b = 2), g === !0 && (b = 3); let M = o.attributes.position.count * b, C = 1; M > e.maxTextureSize && (C = Math.ceil(M / e.maxTextureSize), M = e.maxTextureSize); const T = new Float32Array(M * C * 4 * u), D = new Qu(T, M, C, u); D.type = Pn, D.needsUpdate = !0; const U = b * 4; for (let w = 0; w < u; w++) { const B = x[w], P = m[w], O = v[w], y = M * C * 4 * w; for (let H = 0; H < B.count; H++) { const Y = H * U; d === !0 && (i.fromBufferAttribute(B, H), T[y + Y + 0] = i.x, T[y + Y + 1] = i.y, T[y + Y + 2] = i.z, T[y + Y + 3] = 0), p === !0 && (i.fromBufferAttribute(P, H), T[y + Y + 4] = i.x, T[y + Y + 5] = i.y, T[y + Y + 6] = i.z, T[y + Y + 7] = 0), g === !0 && (i.fromBufferAttribute(O, H), T[y + Y + 8] = i.x, T[y + Y + 9] = i.y, T[y + Y + 10] = i.z, T[y + Y + 11] = O.itemSize === 4 ? i.w : 1); } } f = { count: u, texture: D, size: new ue(M, C) }, n.set(o, f), o.addEventListener("dispose", S); } if (a.isInstancedMesh === !0 && a.morphTexture !== null) l.getUniforms().setValue(s, "morphTexture", a.morphTexture, t); else { let d = 0; for (let g = 0; g < c.length; g++) d += c[g]; const p = o.morphTargetsRelative ? 1 : 1 - d; l.getUniforms().setValue(s, "morphTargetBaseInfluence", p), l.getUniforms().setValue(s, "morphTargetInfluences", c); } l.getUniforms().setValue(s, "morphTargetsTexture", f.texture, t), l.getUniforms().setValue(s, "morphTargetsTextureSize", f.size); } return { update: r }; } function x1(s, e, t, n) { let i = /* @__PURE__ */ new WeakMap(); function r(l) { const c = n.render.frame, h = l.geometry, u = e.get(l, h); if (i.get(u) !== c && (e.update(u), i.set(u, c)), l.isInstancedMesh && (l.hasEventListener("dispose", o) === !1 && l.addEventListener("dispose", o), i.get(l) !== c && (t.update(l.instanceMatrix, s.ARRAY_BUFFER), l.instanceColor !== null && t.update(l.instanceColor, s.ARRAY_BUFFER), i.set(l, c))), l.isSkinnedMesh) { const f = l.skeleton; i.get(f) !== c && (f.update(), i.set(f, c)); } return u; } function a() { i = /* @__PURE__ */ new WeakMap(); } function o(l) { const c = l.target; c.removeEventListener("dispose", o), t.remove(c.instanceMatrix), c.instanceColor !== null && t.remove(c.instanceColor); } return { update: r, dispose: a }; } const Td = /* @__PURE__ */ new Ft(), kh = /* @__PURE__ */ new cc(1, 1), Cd = /* @__PURE__ */ new Qu(), Ad = /* @__PURE__ */ new Rp(), Pd = /* @__PURE__ */ new rd(), Uh = [], Bh = [], Oh = new Float32Array(16), Fh = new Float32Array(9), zh = new Float32Array(4); function Rs(s, e, t) { const n = s[0]; if (n <= 0 || n > 0) return s; const i = e * t; let r = Uh[i]; if (r === void 0 && (r = new Float32Array(i), Uh[i] = r), e !== 0) { n.toArray(r, 0); for (let a = 1, o = 0; a !== e; ++a) o += t, s[a].toArray(r, o); } return r; } function kt(s, e) { if (s.length !== e.length) return !1; for (let t = 0, n = s.length; t < n; t++) if (s[t] !== e[t]) return !1; return !0; } function Ut(s, e) { for (let t = 0, n = e.length; t < n; t++) s[t] = e[t]; } function Da(s, e) { let t = Bh[e]; t === void 0 && (t = new Int32Array(e), Bh[e] = t); for (let n = 0; n !== e; ++n) t[n] = s.allocateTextureUnit(); return t; } function v1(s, e) { const t = this.cache; t[0] !== e && (s.uniform1f(this.addr, e), t[0] = e); } function b1(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 (kt(t, e)) return; s.uniform2fv(this.addr, e), Ut(t, e); } } function _1(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 (kt(t, e)) return; s.uniform3fv(this.addr, e), Ut(t, e); } } function y1(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 (kt(t, e)) return; s.uniform4fv(this.addr, e), Ut(t, e); } } function M1(s, e) { const t = this.cache, n = e.elements; if (n === void 0) { if (kt(t, e)) return; s.uniformMatrix2fv(this.addr, !1, e), Ut(t, e); } else { if (kt(t, n)) return; zh.set(n), s.uniformMatrix2fv(this.addr, !1, zh), Ut(t, n); } } function S1(s, e) { const t = this.cache, n = e.elements; if (n === void 0) { if (kt(t, e)) return; s.uniformMatrix3fv(this.addr, !1, e), Ut(t, e); } else { if (kt(t, n)) return; Fh.set(n), s.uniformMatrix3fv(this.addr, !1, Fh), Ut(t, n); } } function w1(s, e) { const t = this.cache, n = e.elements; if (n === void 0) { if (kt(t, e)) return; s.uniformMatrix4fv(this.addr, !1, e), Ut(t, e); } else { if (kt(t, n)) return; Oh.set(n), s.uniformMatrix4fv(this.addr, !1, Oh), Ut(t, n); } } function E1(s, e) { const t = this.cache; t[0] !== e && (s.uniform1i(this.addr, e), t[0] = e); } function T1(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 (kt(t, e)) return; s.uniform2iv(this.addr, e), Ut(t, e); } } function C1(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 (kt(t, e)) return; s.uniform3iv(this.addr, e), Ut(t, e); } } function A1(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 (kt(t, e)) return; s.uniform4iv(this.addr, e), Ut(t, e); } } function P1(s, e) { const t = this.cache; t[0] !== e && (s.uniform1ui(this.addr, e), t[0] = e); } function R1(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 (kt(t, e)) return; s.uniform2uiv(this.addr, e), Ut(t, e); } } function L1(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 (kt(t, e)) return; s.uniform3uiv(this.addr, e), Ut(t, e); } } function D1(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 (kt(t, e)) return; s.uniform4uiv(this.addr, e), Ut(t, e); } } function I1(s, e, t) { const n = this.cache, i = t.allocateTextureUnit(); n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i); let r; this.type === s.SAMPLER_2D_SHADOW ? (kh.compareFunction = $u, r = kh) : r = Td, t.setTexture2D(e || r, i); } function N1(s, e, t) { const n = this.cache, i = t.allocateTextureUnit(); n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTexture3D(e || Ad, i); } function k1(s, e, t) { const n = this.cache, i = t.allocateTextureUnit(); n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTextureCube(e || Pd, i); } function U1(s, e, t) { const n = this.cache, i = t.allocateTextureUnit(); n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTexture2DArray(e || Cd, i); } function B1(s) { switch (s) { case 5126: return v1; // FLOAT case 35664: return b1; // _VEC2 case 35665: return _1; // _VEC3 case 35666: return y1; // _VEC4 case 35674: return M1; // _MAT2 case 35675: return S1; // _MAT3 case 35676: return w1; // _MAT4 case 5124: case 35670: return E1; // INT, BOOL case 35667: case 35671: return T1; // _VEC2 case 35668: case 35672: return C1; // _VEC3 case 35669: case 35673: return A1; // _VEC4 case 5125: return P1; // UINT case 36294: return R1; // _VEC2 case 36295: return L1; // _VEC3 case 36296: return D1; // _VEC4 case 35678: // SAMPLER_2D case 36198: // SAMPLER_EXTERNAL_OES case 36298: // INT_SAMPLER_2D case 36306: // UNSIGNED_INT_SAMPLER_2D case 35682: return I1; case 35679: // SAMPLER_3D case 36299: // INT_SAMPLER_3D case 36307: return N1; case 35680: // SAMPLER_CUBE case 36300: // INT_SAMPLER_CUBE case 36308: // UNSIGNED_INT_SAMPLER_CUBE case 36293: return k1; case 36289: // SAMPLER_2D_ARRAY case 36303: // INT_SAMPLER_2D_ARRAY case 36311: // UNSIGNED_INT_SAMPLER_2D_ARRAY case 36292: return U1; } } function O1(s, e) { s.uniform1fv(this.addr, e); } function F1(s, e) { const t = Rs(e, this.size, 2); s.uniform2fv(this.addr, t); } function z1(s, e) { const t = Rs(e, this.size, 3); s.uniform3fv(this.addr, t); } function H1(s, e) { const t = Rs(e, this.size, 4); s.uniform4fv(this.addr, t); } function V1(s, e) { const t = Rs(e, this.size, 4); s.uniformMatrix2fv(this.addr, !1, t); } function G1(s, e) { const t = Rs(e, this.size, 9); s.uniformMatrix3fv(this.addr, !1, t); } function W1(s, e) { const t = Rs(e, this.size, 16); s.uniformMatrix4fv(this.addr, !1, t); } function X1(s, e) { s.uniform1iv(this.addr, e); } function j1(s, e) { s.uniform2iv(this.addr, e); } function Z1(s, e) { s.uniform3iv(this.addr, e); } function q1(s, e) { s.uniform4iv(this.addr, e); } function Y1(s, e) { s.uniform1uiv(this.addr, e); } function K1(s, e) { s.uniform2uiv(this.addr, e); } function $1(s, e) { s.uniform3uiv(this.addr, e); } function J1(s, e) { s.uniform4uiv(this.addr, e); } function Q1(s, e, t) { const n = this.cache, i = e.length, r = Da(t, i); kt(n, r) || (s.uniform1iv(this.addr, r), Ut(n, r)); for (let a = 0; a !== i; ++a) t.setTexture2D(e[a] || Td, r[a]); } function ev(s, e, t) { const n = this.cache, i = e.length, r = Da(t, i); kt(n, r) || (s.uniform1iv(this.addr, r), Ut(n, r)); for (let a = 0; a !== i; ++a) t.setTexture3D(e[a] || Ad, r[a]); } function tv(s, e, t) { const n = this.cache, i = e.length, r = Da(t, i); kt(n, r) || (s.uniform1iv(this.addr, r), Ut(n, r)); for (let a = 0; a !== i; ++a) t.setTextureCube(e[a] || Pd, r[a]); } function nv(s, e, t) { const n = this.cache, i = e.length, r = Da(t, i); kt(n, r) || (s.uniform1iv(this.addr, r), Ut(n, r)); for (let a = 0; a !== i; ++a) t.setTexture2DArray(e[a] || Cd, r[a]); } function iv(s) { switch (s) { case 5126: return O1; // FLOAT case 35664: return F1; // _VEC2 case 35665: return z1; // _VEC3 case 35666: return H1; // _VEC4 case 35674: return V1; // _MAT2 case 35675: return G1; // _MAT3 case 35676: return W1; // _MAT4 case 5124: case 35670: return X1; // INT, BOOL case 35667: case 35671: return j1; // _VEC2 case 35668: case 35672: return Z1; // _VEC3 case 35669: case 35673: return q1; // _VEC4 case 5125: return Y1; // UINT case 36294: return K1; // _VEC2 case 36295: return $1; // _VEC3 case 36296: return J1; // _VEC4 case 35678: // SAMPLER_2D case 36198: // SAMPLER_EXTERNAL_OES case 36298: // INT_SAMPLER_2D case 36306: // UNSIGNED_INT_SAMPLER_2D case 35682: return Q1; case 35679: // SAMPLER_3D case 36299: // INT_SAMPLER_3D case 36307: return ev; case 35680: // SAMPLER_CUBE case 36300: // INT_SAMPLER_CUBE case 36308: // UNSIGNED_INT_SAMPLER_CUBE case 36293: return tv; case 36289: // SAMPLER_2D_ARRAY case 36303: // INT_SAMPLER_2D_ARRAY case 36311: // UNSIGNED_INT_SAMPLER_2D_ARRAY case 36292: return nv; } } class sv { constructor(e, t, n) { this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = B1(t.type); } } class rv { constructor(e, t, n) { this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = iv(t.type); } } class av { constructor(e) { this.id = e, this.seq = [], this.map = {}; } setValue(e, t, n) { const i = this.seq; for (let r = 0, a = i.length; r !== a; ++r) { const o = i[r]; o.setValue(e, t[o.id], n); } } } const Co = /(\w+)(\])?(\[|\.)?/g; function Hh(s, e) { s.seq.push(e), s.map[e.id] = e; } function ov(s, e, t) { const n = s.name, i = n.length; for (Co.lastIndex = 0; ; ) { const r = Co.exec(n), a = Co.lastIndex; let o = r[1]; const l = r[2] === "]", c = r[3]; if (l && (o = o | 0), c === void 0 || c === "[" && a + 2 === i) { Hh(t, c === void 0 ? new sv(o, s, e) : new rv(o, s, e)); break; } else { let u = t.map[o]; u === void 0 && (u = new av(o), Hh(t, u)), t = u; } } } class fa { constructor(e, t) { this.seq = [], this.map = {}; const n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS); for (let i = 0; i < n; ++i) { const r = e.getActiveUniform(t, i), a = e.getUniformLocation(t, r.name); ov(r, a, this); } } setValue(e, t, n, i) { const r = this.map[t]; r !== void 0 && r.setValue(e, n, i); } setOptional(e, t, n) { const i = t[n]; i !== void 0 && this.setValue(e, n, i); } static upload(e, t, n, i) { for (let r = 0, a = t.length; r !== a; ++r) { const o = t[r], l = n[o.id]; l.needsUpdate !== !1 && o.setValue(e, l.value, i); } } static seqWithValue(e, t) { const n = []; for (let i = 0, r = e.length; i !== r; ++i) { const a = e[i]; a.id in t && n.push(a); } return n; } } function Vh(s, e, t) { const n = s.createShader(e); return s.shaderSource(n, t), s.compileShader(n), n; } const lv = 37297; let cv = 0; function hv(s, e) { const t = s.split(` `), n = [], i = Math.max(e - 6, 0), r = Math.min(e + 6, t.length); for (let a = i; a < r; a++) { const o = a + 1; n.push(`${o === e ? ">" : " "} ${o}: ${t[a]}`); } return n.join(` `); } const Gh = /* @__PURE__ */ new $e(); function uv(s) { it._getMatrix(Gh, it.workingColorSpace, s); const e = `mat3( ${Gh.elements.map((t) => t.toFixed(4))} )`; switch (it.getTransfer(s)) { case ba: return [e, "LinearTransferOETF"]; case ot: return [e, "sRGBTransferOETF"]; default: return ze("WebGLProgram: Unsupported color space: ", s), [e, "LinearTransferOETF"]; } } function Wh(s, e, t) { const n = s.getShaderParameter(e, s.COMPILE_STATUS), r = (s.getShaderInfoLog(e) || "").trim(); if (n && r === "") return ""; const a = /ERROR: 0:(\d+)/.exec(r); if (a) { const o = parseInt(a[1]); return t.toUpperCase() + ` ` + r + ` ` + hv(s.getShaderSource(e), o); } else return r; } function dv(s, e) { const t = uv(e); return [ `vec4 ${s}( vec4 value ) {`, ` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`, "}" ].join(` `); } function fv(s, e) { let t; switch (e) { case Uu: t = "Linear"; break; case Bu: t = "Reinhard"; break; case Ou: t = "Cineon"; break; case ql: t = "ACESFilmic"; break; case zu: t = "AgX"; break; case Hu: t = "Neutral"; break; case Fu: t = "Custom"; break; default: ze("WebGLProgram: Unsupported toneMapping:", e), t = "Linear"; } return "vec3 " + s + "( vec3 color ) { return " + t + "ToneMapping( color ); }"; } const Kr = /* @__PURE__ */ new R(); function pv() { it.getLuminanceCoefficients(Kr); const s = Kr.x.toFixed(4), e = Kr.y.toFixed(4), t = Kr.z.toFixed(4); return [ "float luminance( const in vec3 rgb ) {", ` const vec3 weights = vec3( ${s}, ${e}, ${t} );`, " return dot( weights, rgb );", "}" ].join(` `); } function mv(s) { return [ s.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "", s.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : "" ].filter(qs).join(` `); } function gv(s) { const e = []; for (const t in s) { const n = s[t]; n !== !1 && e.push("#define " + t + " " + n); } return e.join(` `); } function xv(s, e) { const t = {}, n = s.getProgramParameter(e, s.ACTIVE_ATTRIBUTES); for (let i = 0; i < n; i++) { const r = s.getActiveAttrib(e, i), a = r.name; let o = 1; r.type === s.FLOAT_MAT2 && (o = 2), r.type === s.FLOAT_MAT3 && (o = 3), r.type === s.FLOAT_MAT4 && (o = 4), t[a] = { type: r.type, location: s.getAttribLocation(e, a), locationSize: o }; } return t; } function qs(s) { return s !== ""; } function Xh(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 jh(s, e) { return s.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection); } const vv = /^[ \t]*#include +<([\w\d./]+)>/gm; function Ul(s) { return s.replace(vv, _v); } const bv = /* @__PURE__ */ new Map(); function _v(s, e) { let t = Qe[e]; if (t === void 0) { const n = bv.get(e); if (n !== void 0) t = Qe[n], ze('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', e, n); else throw new Error("Can not resolve #include <" + e + ">"); } return Ul(t); } const yv = /#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 Zh(s) { return s.replace(yv, Mv); } function Mv(s, e, t, n) { let i = ""; for (let r = parseInt(e); r < parseInt(t); r++) i += n.replace(/\[\s*i\s*\]/g, "[ " + r + " ]").replace(/UNROLLED_LOOP_INDEX/g, r); return i; } function qh(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 Sv(s) { let e = "SHADOWMAP_TYPE_BASIC"; return s.shadowMapType === Iu ? e = "SHADOWMAP_TYPE_PCF" : s.shadowMapType === Nu ? e = "SHADOWMAP_TYPE_PCF_SOFT" : s.shadowMapType === ei && (e = "SHADOWMAP_TYPE_VSM"), e; } function wv(s) { let e = "ENVMAP_TYPE_CUBE"; if (s.envMap) switch (s.envMapMode) { case ps: case ms: e = "ENVMAP_TYPE_CUBE"; break; case Aa: e = "ENVMAP_TYPE_CUBE_UV"; break; } return e; } function Ev(s) { let e = "ENVMAP_MODE_REFLECTION"; if (s.envMap) switch (s.envMapMode) { case ms: e = "ENVMAP_MODE_REFRACTION"; break; } return e; } function Tv(s) { let e = "ENVMAP_BLENDING_NONE"; if (s.envMap) switch (s.combine) { case Ca: e = "ENVMAP_BLENDING_MULTIPLY"; break; case Xf: e = "ENVMAP_BLENDING_MIX"; break; case jf: e = "ENVMAP_BLENDING_ADD"; break; } return e; } function Cv(s) { const e = s.envMapCubeUVHeight; if (e === null) return null; const t = Math.log2(e) - 2, n = 1 / e; return { texelWidth: 1 / (3 * Math.max(Math.pow(2, t), 112)), texelHeight: n, maxMip: t }; } function Av(s, e, t, n) { const i = s.getContext(), r = t.defines; let a = t.vertexShader, o = t.fragmentShader; const l = Sv(t), c = wv(t), h = Ev(t), u = Tv(t), f = Cv(t), d = mv(t), p = gv(r), g = i.createProgram(); let x, m, v = t.glslVersion ? "#version " + t.glslVersion + ` ` : ""; t.isRawShaderMaterial ? (x = [ "#define SHADER_TYPE " + t.shaderType, "#define SHADER_NAME " + t.shaderName, p ].filter(qs).join(` `), x.length > 0 && (x += ` `), m = [ "#define SHADER_TYPE " + t.shaderType, "#define SHADER_NAME " + t.shaderName, p ].filter(qs).join(` `), m.length > 0 && (m += ` `)) : (x = [ qh(t), "#define SHADER_TYPE " + t.shaderType, "#define SHADER_NAME " + t.shaderName, p, 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(qs).join(` `), m = [ qh(t), "#define SHADER_TYPE " + t.shaderType, "#define SHADER_NAME " + t.shaderName, p, 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 : "", f ? "#define CUBEUV_TEXEL_WIDTH " + f.texelWidth : "", f ? "#define CUBEUV_TEXEL_HEIGHT " + f.texelHeight : "", f ? "#define CUBEUV_MAX_MIP " + f.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 !== gi ? "#define TONE_MAPPING" : "", t.toneMapping !== gi ? Qe.tonemapping_pars_fragment : "", // this code is required here because it is used by the toneMapping() function defined below t.toneMapping !== gi ? fv("toneMapping", t.toneMapping) : "", t.dithering ? "#define DITHERING" : "", t.opaque ? "#define OPAQUE" : "", Qe.colorspace_pars_fragment, // this code is required here because it is used by the various encoding/decoding function defined below dv("linearToOutputTexel", t.outputColorSpace), pv(), t.useDepthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "", ` ` ].filter(qs).join(` `)), a = Ul(a), a = Xh(a, t), a = jh(a, t), o = Ul(o), o = Xh(o, t), o = jh(o, t), a = Zh(a), o = Zh(o), t.isRawShaderMaterial !== !0 && (v = `#version 300 es `, x = [ d, "#define attribute in", "#define varying out", "#define texture2D texture" ].join(` `) + ` ` + x, m = [ "#define varying in", t.glslVersion === Bc ? "" : "layout(location = 0) out highp vec4 pc_fragColor;", t.glslVersion === Bc ? "" : "#define gl_FragColor pc_fragColor", "#define gl_FragDepthEXT gl_FragDepth", "#define texture2D texture", "#define textureCube texture", "#define texture2DProj textureProj", "#define texture2DLodEXT textureLod", "#define texture2DProjLodEXT textureProjLod", "#define textureCubeLodEXT textureLod", "#define texture2DGradEXT textureGrad", "#define texture2DProjGradEXT textureProjGrad", "#define textureCubeGradEXT textureGrad" ].join(` `) + ` ` + m); const b = v + x + a, M = v + m + o, C = Vh(i, i.VERTEX_SHADER, b), T = Vh(i, i.FRAGMENT_SHADER, M); i.attachShader(g, C), i.attachShader(g, T), t.index0AttributeName !== void 0 ? i.bindAttribLocation(g, 0, t.index0AttributeName) : t.morphTargets === !0 && i.bindAttribLocation(g, 0, "position"), i.linkProgram(g); function D(B) { if (s.debug.checkShaderErrors) { const P = i.getProgramInfoLog(g) || "", O = i.getShaderInfoLog(C) || "", y = i.getShaderInfoLog(T) || "", H = P.trim(), Y = O.trim(), j = y.trim(); let J = !0, Z = !0; if (i.getProgramParameter(g, i.LINK_STATUS) === !1) if (J = !1, typeof s.debug.onShaderError == "function") s.debug.onShaderError(i, g, C, T); else { const ae = Wh(i, C, "vertex"), X = Wh(i, T, "fragment"); et( "THREE.WebGLProgram: Shader Error " + i.getError() + " - VALIDATE_STATUS " + i.getProgramParameter(g, i.VALIDATE_STATUS) + ` Material Name: ` + B.name + ` Material Type: ` + B.type + ` Program Info Log: ` + H + ` ` + ae + ` ` + X ); } else H !== "" ? ze("WebGLProgram: Program Info Log:", H) : (Y === "" || j === "") && (Z = !1); Z && (B.diagnostics = { runnable: J, programLog: H, vertexShader: { log: Y, prefix: x }, fragmentShader: { log: j, prefix: m } }); } i.deleteShader(C), i.deleteShader(T), U = new fa(i, g), S = xv(i, g); } let U; this.getUniforms = function() { return U === void 0 && D(this), U; }; let S; this.getAttributes = function() { return S === void 0 && D(this), S; }; let w = t.rendererExtensionParallelShaderCompile === !1; return this.isReady = function() { return w === !1 && (w = i.getProgramParameter(g, lv)), w; }, this.destroy = function() { n.releaseStatesOfProgram(this), i.deleteProgram(g), this.program = void 0; }, this.type = t.shaderType, this.name = t.shaderName, this.id = cv++, this.cacheKey = e, this.usedTimes = 1, this.program = g, this.vertexShader = C, this.fragmentShader = T, this; } let Pv = 0; class Rv { constructor() { this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map(); } update(e) { const t = e.vertexShader, n = e.fragmentShader, i = this._getShaderStage(t), r = this._getShaderStage(n), a = this._getShaderCacheForMaterial(e); return a.has(i) === !1 && (a.add(i), i.usedTimes++), a.has(r) === !1 && (a.add(r), r.usedTimes++), this; } remove(e) { const t = this.materialCache.get(e); for (const n of t) n.usedTimes--, n.usedTimes === 0 && this.shaderCache.delete(n.code); return this.materialCache.delete(e), this; } getVertexShaderID(e) { return this._getShaderStage(e.vertexShader).id; } getFragmentShaderID(e) { return this._getShaderStage(e.fragmentShader).id; } dispose() { this.shaderCache.clear(), this.materialCache.clear(); } _getShaderCacheForMaterial(e) { const t = this.materialCache; let n = t.get(e); return n === void 0 && (n = /* @__PURE__ */ new Set(), t.set(e, n)), n; } _getShaderStage(e) { const t = this.shaderCache; let n = t.get(e); return n === void 0 && (n = new Lv(e), t.set(e, n)), n; } } class Lv { constructor(e) { this.id = Pv++, this.code = e, this.usedTimes = 0; } } function Dv(s, e, t, n, i, r, a) { const o = new rc(), l = new Rv(), c = /* @__PURE__ */ new Set(), h = [], u = i.logarithmicDepthBuffer, f = i.vertexTextures; let d = i.precision; const p = { 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 g(S) { return c.add(S), S === 0 ? "uv" : `uv${S}`; } function x(S, w, B, P, O) { const y = P.fog, H = O.geometry, Y = S.isMeshStandardMaterial ? P.environment : null, j = (S.isMeshStandardMaterial ? t : e).get(S.envMap || Y), J = j && j.mapping === Aa ? j.image.height : null, Z = p[S.type]; S.precision !== null && (d = i.getMaxPrecision(S.precision), d !== S.precision && ze("WebGLProgram.getParameters:", S.precision, "not supported, using", d, "instead.")); const ae = H.morphAttributes.position || H.morphAttributes.normal || H.morphAttributes.color, X = ae !== void 0 ? ae.length : 0; let q = 0; H.morphAttributes.position !== void 0 && (q = 1), H.morphAttributes.normal !== void 0 && (q = 2), H.morphAttributes.color !== void 0 && (q = 3); let ge, pe, de, ie; if (Z) { const ht = Fn[Z]; ge = ht.vertexShader, pe = ht.fragmentShader; } else ge = S.vertexShader, pe = S.fragmentShader, l.update(S), de = l.getVertexShaderID(S), ie = l.getFragmentShaderID(S); const ce = s.getRenderTarget(), fe = s.state.buffers.depth.getReversed(), ve = O.isInstancedMesh === !0, Ee = O.isBatchedMesh === !0, Ne = !!S.map, Ye = !!S.matcap, ke = !!j, _ = !!S.aoMap, A = !!S.lightMap, V = !!S.bumpMap, N = !!S.normalMap, I = !!S.displacementMap, F = !!S.emissiveMap, ee = !!S.metalnessMap, $ = !!S.roughnessMap, G = S.anisotropy > 0, L = S.clearcoat > 0, E = S.dispersion > 0, z = S.iridescence > 0, K = S.sheen > 0, le = S.transmission > 0, te = G && !!S.anisotropyMap, Te = L && !!S.clearcoatMap, be = L && !!S.clearcoatNormalMap, Re = L && !!S.clearcoatRoughnessMap, De = z && !!S.iridescenceMap, he = z && !!S.iridescenceThicknessMap, _e = K && !!S.sheenColorMap, He = K && !!S.sheenRoughnessMap, Ue = !!S.specularMap, Ce = !!S.specularColorMap, Ve = !!S.specularIntensityMap, W = le && !!S.transmissionMap, we = le && !!S.thicknessMap, ye = !!S.gradientMap, Me = !!S.alphaMap, xe = S.alphaTest > 0, me = !!S.alphaHash, Be = !!S.extensions; let qe = gi; S.toneMapped && (ce === null || ce.isXRRenderTarget === !0) && (qe = s.toneMapping); const vt = { shaderID: Z, shaderType: S.type, shaderName: S.name, vertexShader: ge, fragmentShader: pe, defines: S.defines, customVertexShaderID: de, customFragmentShaderID: ie, isRawShaderMaterial: S.isRawShaderMaterial === !0, glslVersion: S.glslVersion, precision: d, batching: Ee, batchingColor: Ee && O._colorsTexture !== null, instancing: ve, instancingColor: ve && O.instanceColor !== null, instancingMorph: ve && O.morphTexture !== null, supportsVertexTextures: f, outputColorSpace: ce === null ? s.outputColorSpace : ce.isXRRenderTarget === !0 ? ce.texture.colorSpace : Tt, alphaToCoverage: !!S.alphaToCoverage, map: Ne, matcap: Ye, envMap: ke, envMapMode: ke && j.mapping, envMapCubeUVHeight: J, aoMap: _, lightMap: A, bumpMap: V, normalMap: N, displacementMap: f && I, emissiveMap: F, normalMapObjectSpace: N && S.normalMapType === Jf, normalMapTangentSpace: N && S.normalMapType === fr, metalnessMap: ee, roughnessMap: $, anisotropy: G, anisotropyMap: te, clearcoat: L, clearcoatMap: Te, clearcoatNormalMap: be, clearcoatRoughnessMap: Re, dispersion: E, iridescence: z, iridescenceMap: De, iridescenceThicknessMap: he, sheen: K, sheenColorMap: _e, sheenRoughnessMap: He, specularMap: Ue, specularColorMap: Ce, specularIntensityMap: Ve, transmission: le, transmissionMap: W, thicknessMap: we, gradientMap: ye, opaque: S.transparent === !1 && S.blending === cs && S.alphaToCoverage === !1, alphaMap: Me, alphaTest: xe, alphaHash: me, combine: S.combine, // mapUv: Ne && g(S.map.channel), aoMapUv: _ && g(S.aoMap.channel), lightMapUv: A && g(S.lightMap.channel), bumpMapUv: V && g(S.bumpMap.channel), normalMapUv: N && g(S.normalMap.channel), displacementMapUv: I && g(S.displacementMap.channel), emissiveMapUv: F && g(S.emissiveMap.channel), metalnessMapUv: ee && g(S.metalnessMap.channel), roughnessMapUv: $ && g(S.roughnessMap.channel), anisotropyMapUv: te && g(S.anisotropyMap.channel), clearcoatMapUv: Te && g(S.clearcoatMap.channel), clearcoatNormalMapUv: be && g(S.clearcoatNormalMap.channel), clearcoatRoughnessMapUv: Re && g(S.clearcoatRoughnessMap.channel), iridescenceMapUv: De && g(S.iridescenceMap.channel), iridescenceThicknessMapUv: he && g(S.iridescenceThicknessMap.channel), sheenColorMapUv: _e && g(S.sheenColorMap.channel), sheenRoughnessMapUv: He && g(S.sheenRoughnessMap.channel), specularMapUv: Ue && g(S.specularMap.channel), specularColorMapUv: Ce && g(S.specularColorMap.channel), specularIntensityMapUv: Ve && g(S.specularIntensityMap.channel), transmissionMapUv: W && g(S.transmissionMap.channel), thicknessMapUv: we && g(S.thicknessMap.channel), alphaMapUv: Me && g(S.alphaMap.channel), // vertexTangents: !!H.attributes.tangent && (N || G), vertexColors: S.vertexColors, vertexAlphas: S.vertexColors === !0 && !!H.attributes.color && H.attributes.color.itemSize === 4, pointsUvs: O.isPoints === !0 && !!H.attributes.uv && (Ne || Me), fog: !!y, useFog: S.fog === !0, fogExp2: !!y && y.isFogExp2, flatShading: S.flatShading === !0 && S.wireframe === !1, sizeAttenuation: S.sizeAttenuation === !0, logarithmicDepthBuffer: u, reversedDepthBuffer: fe, skinning: O.isSkinnedMesh === !0, morphTargets: H.morphAttributes.position !== void 0, morphNormals: H.morphAttributes.normal !== void 0, morphColors: H.morphAttributes.color !== void 0, morphTargetsCount: X, morphTextureStride: q, numDirLights: w.directional.length, numPointLights: w.point.length, numSpotLights: w.spot.length, numSpotLightMaps: w.spotLightMap.length, numRectAreaLights: w.rectArea.length, numHemiLights: w.hemi.length, numDirLightShadows: w.directionalShadowMap.length, numPointLightShadows: w.pointShadowMap.length, numSpotLightShadows: w.spotShadowMap.length, numSpotLightShadowsWithMaps: w.numSpotLightShadowsWithMaps, numLightProbes: w.numLightProbes, numClippingPlanes: a.numPlanes, numClipIntersection: a.numIntersection, dithering: S.dithering, shadowMapEnabled: s.shadowMap.enabled && B.length > 0, shadowMapType: s.shadowMap.type, toneMapping: qe, decodeVideoTexture: Ne && S.map.isVideoTexture === !0 && it.getTransfer(S.map.colorSpace) === ot, decodeVideoTextureEmissive: F && S.emissiveMap.isVideoTexture === !0 && it.getTransfer(S.emissiveMap.colorSpace) === ot, premultipliedAlpha: S.premultipliedAlpha, doubleSided: S.side === Dt, flipSided: S.side === Jt, useDepthPacking: S.depthPacking >= 0, depthPacking: S.depthPacking || 0, index0AttributeName: S.index0AttributeName, extensionClipCullDistance: Be && S.extensions.clipCullDistance === !0 && n.has("WEBGL_clip_cull_distance"), extensionMultiDraw: (Be && S.extensions.multiDraw === !0 || Ee) && n.has("WEBGL_multi_draw"), rendererExtensionParallelShaderCompile: n.has("KHR_parallel_shader_compile"), customProgramCacheKey: S.customProgramCacheKey() }; return vt.vertexUv1s = c.has(1), vt.vertexUv2s = c.has(2), vt.vertexUv3s = c.has(3), c.clear(), vt; } function m(S) { const w = []; if (S.shaderID ? w.push(S.shaderID) : (w.push(S.customVertexShaderID), w.push(S.customFragmentShaderID)), S.defines !== void 0) for (const B in S.defines) w.push(B), w.push(S.defines[B]); return S.isRawShaderMaterial === !1 && (v(w, S), b(w, S), w.push(s.outputColorSpace)), w.push(S.customProgramCacheKey), w.join(); } function v(S, w) { S.push(w.precision), S.push(w.outputColorSpace), S.push(w.envMapMode), S.push(w.envMapCubeUVHeight), S.push(w.mapUv), S.push(w.alphaMapUv), S.push(w.lightMapUv), S.push(w.aoMapUv), S.push(w.bumpMapUv), S.push(w.normalMapUv), S.push(w.displacementMapUv), S.push(w.emissiveMapUv), S.push(w.metalnessMapUv), S.push(w.roughnessMapUv), S.push(w.anisotropyMapUv), S.push(w.clearcoatMapUv), S.push(w.clearcoatNormalMapUv), S.push(w.clearcoatRoughnessMapUv), S.push(w.iridescenceMapUv), S.push(w.iridescenceThicknessMapUv), S.push(w.sheenColorMapUv), S.push(w.sheenRoughnessMapUv), S.push(w.specularMapUv), S.push(w.specularColorMapUv), S.push(w.specularIntensityMapUv), S.push(w.transmissionMapUv), S.push(w.thicknessMapUv), S.push(w.combine), S.push(w.fogExp2), S.push(w.sizeAttenuation), S.push(w.morphTargetsCount), S.push(w.morphAttributeCount), S.push(w.numDirLights), S.push(w.numPointLights), S.push(w.numSpotLights), S.push(w.numSpotLightMaps), S.push(w.numHemiLights), S.push(w.numRectAreaLights), S.push(w.numDirLightShadows), S.push(w.numPointLightShadows), S.push(w.numSpotLightShadows), S.push(w.numSpotLightShadowsWithMaps), S.push(w.numLightProbes), S.push(w.shadowMapType), S.push(w.toneMapping), S.push(w.numClippingPlanes), S.push(w.numClipIntersection), S.push(w.depthPacking); } function b(S, w) { o.disableAll(), w.supportsVertexTextures && o.enable(0), w.instancing && o.enable(1), w.instancingColor && o.enable(2), w.instancingMorph && o.enable(3), w.matcap && o.enable(4), w.envMap && o.enable(5), w.normalMapObjectSpace && o.enable(6), w.normalMapTangentSpace && o.enable(7), w.clearcoat && o.enable(8), w.iridescence && o.enable(9), w.alphaTest && o.enable(10), w.vertexColors && o.enable(11), w.vertexAlphas && o.enable(12), w.vertexUv1s && o.enable(13), w.vertexUv2s && o.enable(14), w.vertexUv3s && o.enable(15), w.vertexTangents && o.enable(16), w.anisotropy && o.enable(17), w.alphaHash && o.enable(18), w.batching && o.enable(19), w.dispersion && o.enable(20), w.batchingColor && o.enable(21), w.gradientMap && o.enable(22), S.push(o.mask), o.disableAll(), w.fog && o.enable(0), w.useFog && o.enable(1), w.flatShading && o.enable(2), w.logarithmicDepthBuffer && o.enable(3), w.reversedDepthBuffer && o.enable(4), w.skinning && o.enable(5), w.morphTargets && o.enable(6), w.morphNormals && o.enable(7), w.morphColors && o.enable(8), w.premultipliedAlpha && o.enable(9), w.shadowMapEnabled && o.enable(10), w.doubleSided && o.enable(11), w.flipSided && o.enable(12), w.useDepthPacking && o.enable(13), w.dithering && o.enable(14), w.transmission && o.enable(15), w.sheen && o.enable(16), w.opaque && o.enable(17), w.pointsUvs && o.enable(18), w.decodeVideoTexture && o.enable(19), w.decodeVideoTextureEmissive && o.enable(20), w.alphaToCoverage && o.enable(21), S.push(o.mask); } function M(S) { const w = p[S.type]; let B; if (w) { const P = Fn[w]; B = zn.clone(P.uniforms); } else B = S.uniforms; return B; } function C(S, w) { let B; for (let P = 0, O = h.length; P < O; P++) { const y = h[P]; if (y.cacheKey === w) { B = y, ++B.usedTimes; break; } } return B === void 0 && (B = new Av(s, w, S, r), h.push(B)), B; } function T(S) { if (--S.usedTimes === 0) { const w = h.indexOf(S); h[w] = h[h.length - 1], h.pop(), S.destroy(); } } function D(S) { l.remove(S); } function U() { l.dispose(); } return { getParameters: x, getProgramCacheKey: m, getUniforms: M, acquireProgram: C, releaseProgram: T, releaseShaderCache: D, // Exposed for resource monitoring & error feedback via renderer.info: programs: h, dispose: U }; } function Iv() { let s = /* @__PURE__ */ new WeakMap(); function e(a) { return s.has(a); } function t(a) { let o = s.get(a); return o === void 0 && (o = {}, s.set(a, o)), o; } function n(a) { s.delete(a); } function i(a, o, l) { s.get(a)[o] = l; } function r() { s = /* @__PURE__ */ new WeakMap(); } return { has: e, get: t, remove: n, update: i, dispose: r }; } function Nv(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 Yh(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 Kh() { const s = []; let e = 0; const t = [], n = [], i = []; function r() { e = 0, t.length = 0, n.length = 0, i.length = 0; } function a(u, f, d, p, g, x) { let m = s[e]; return m === void 0 ? (m = { id: u.id, object: u, geometry: f, material: d, groupOrder: p, renderOrder: u.renderOrder, z: g, group: x }, s[e] = m) : (m.id = u.id, m.object = u, m.geometry = f, m.material = d, m.groupOrder = p, m.renderOrder = u.renderOrder, m.z = g, m.group = x), e++, m; } function o(u, f, d, p, g, x) { const m = a(u, f, d, p, g, x); d.transmission > 0 ? n.push(m) : d.transparent === !0 ? i.push(m) : t.push(m); } function l(u, f, d, p, g, x) { const m = a(u, f, d, p, g, x); d.transmission > 0 ? n.unshift(m) : d.transparent === !0 ? i.unshift(m) : t.unshift(m); } function c(u, f) { t.length > 1 && t.sort(u || Nv), n.length > 1 && n.sort(f || Yh), i.length > 1 && i.sort(f || Yh); } function h() { for (let u = e, f = s.length; u < f; u++) { const d = s[u]; if (d.id === null) break; d.id = null, d.object = null, d.geometry = null, d.material = null, d.group = null; } } return { opaque: t, transmissive: n, transparent: i, init: r, push: o, unshift: l, finish: h, sort: c }; } function kv() { let s = /* @__PURE__ */ new WeakMap(); function e(n, i) { const r = s.get(n); let a; return r === void 0 ? (a = new Kh(), s.set(n, [a])) : i >= r.length ? (a = new Kh(), r.push(a)) : a = r[i], a; } function t() { s = /* @__PURE__ */ new WeakMap(); } return { get: e, dispose: t }; } function Uv() { 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 R(), color: new Fe() }; break; case "SpotLight": t = { position: new R(), direction: new R(), color: new Fe(), distance: 0, coneCos: 0, penumbraCos: 0, decay: 0 }; break; case "PointLight": t = { position: new R(), color: new Fe(), distance: 0, decay: 0 }; break; case "HemisphereLight": t = { direction: new R(), skyColor: new Fe(), groundColor: new Fe() }; break; case "RectAreaLight": t = { color: new Fe(), position: new R(), halfWidth: new R(), halfHeight: new R() }; break; } return s[e.id] = t, t; } }; } function Bv() { 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 ue() }; break; case "SpotLight": t = { shadowIntensity: 1, shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new ue() }; break; case "PointLight": t = { shadowIntensity: 1, shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new ue(), shadowCameraNear: 1, shadowCameraFar: 1e3 }; break; } return s[e.id] = t, t; } }; } let Ov = 0; function Fv(s, e) { return (e.castShadow ? 2 : 0) - (s.castShadow ? 2 : 0) + (e.map ? 1 : 0) - (s.map ? 1 : 0); } function zv(s) { const e = new Uv(), t = Bv(), n = { version: 0, hash: { directionalLength: -1, pointLength: -1, spotLength: -1, rectAreaLength: -1, hemiLength: -1, numDirectionalShadows: -1, numPointShadows: -1, numSpotShadows: -1, numSpotMaps: -1, numLightProbes: -1 }, ambient: [0, 0, 0], probe: [], directional: [], directionalShadow: [], directionalShadowMap: [], directionalShadowMatrix: [], spot: [], spotLightMap: [], spotShadow: [], spotShadowMap: [], spotLightMatrix: [], rectArea: [], rectAreaLTC1: null, rectAreaLTC2: null, point: [], pointShadow: [], pointShadowMap: [], pointShadowMatrix: [], hemi: [], numSpotLightShadowsWithMaps: 0, numLightProbes: 0 }; for (let c = 0; c < 9; c++) n.probe.push(new R()); const i = new R(), r = new je(), a = new je(); function o(c) { let h = 0, u = 0, f = 0; for (let S = 0; S < 9; S++) n.probe[S].set(0, 0, 0); let d = 0, p = 0, g = 0, x = 0, m = 0, v = 0, b = 0, M = 0, C = 0, T = 0, D = 0; c.sort(Fv); for (let S = 0, w = c.length; S < w; S++) { const B = c[S], P = B.color, O = B.intensity, y = B.distance, H = B.shadow && B.shadow.map ? B.shadow.map.texture : null; if (B.isAmbientLight) h += P.r * O, u += P.g * O, f += P.b * O; else if (B.isLightProbe) { for (let Y = 0; Y < 9; Y++) n.probe[Y].addScaledVector(B.sh.coefficients[Y], O); D++; } else if (B.isDirectionalLight) { const Y = e.get(B); if (Y.color.copy(B.color).multiplyScalar(B.intensity), B.castShadow) { const j = B.shadow, J = t.get(B); J.shadowIntensity = j.intensity, J.shadowBias = j.bias, J.shadowNormalBias = j.normalBias, J.shadowRadius = j.radius, J.shadowMapSize = j.mapSize, n.directionalShadow[d] = J, n.directionalShadowMap[d] = H, n.directionalShadowMatrix[d] = B.shadow.matrix, v++; } n.directional[d] = Y, d++; } else if (B.isSpotLight) { const Y = e.get(B); Y.position.setFromMatrixPosition(B.matrixWorld), Y.color.copy(P).multiplyScalar(O), Y.distance = y, Y.coneCos = Math.cos(B.angle), Y.penumbraCos = Math.cos(B.angle * (1 - B.penumbra)), Y.decay = B.decay, n.spot[g] = Y; const j = B.shadow; if (B.map && (n.spotLightMap[C] = B.map, C++, j.updateMatrices(B), B.castShadow && T++), n.spotLightMatrix[g] = j.matrix, B.castShadow) { const J = t.get(B); J.shadowIntensity = j.intensity, J.shadowBias = j.bias, J.shadowNormalBias = j.normalBias, J.shadowRadius = j.radius, J.shadowMapSize = j.mapSize, n.spotShadow[g] = J, n.spotShadowMap[g] = H, M++; } g++; } else if (B.isRectAreaLight) { const Y = e.get(B); Y.color.copy(P).multiplyScalar(O), Y.halfWidth.set(B.width * 0.5, 0, 0), Y.halfHeight.set(0, B.height * 0.5, 0), n.rectArea[x] = Y, x++; } else if (B.isPointLight) { const Y = e.get(B); if (Y.color.copy(B.color).multiplyScalar(B.intensity), Y.distance = B.distance, Y.decay = B.decay, B.castShadow) { const j = B.shadow, J = t.get(B); J.shadowIntensity = j.intensity, J.shadowBias = j.bias, J.shadowNormalBias = j.normalBias, J.shadowRadius = j.radius, J.shadowMapSize = j.mapSize, J.shadowCameraNear = j.camera.near, J.shadowCameraFar = j.camera.far, n.pointShadow[p] = J, n.pointShadowMap[p] = H, n.pointShadowMatrix[p] = B.shadow.matrix, b++; } n.point[p] = Y, p++; } else if (B.isHemisphereLight) { const Y = e.get(B); Y.skyColor.copy(B.color).multiplyScalar(O), Y.groundColor.copy(B.groundColor).multiplyScalar(O), n.hemi[m] = Y, m++; } } x > 0 && (s.has("OES_texture_float_linear") === !0 ? (n.rectAreaLTC1 = Pe.LTC_FLOAT_1, n.rectAreaLTC2 = Pe.LTC_FLOAT_2) : (n.rectAreaLTC1 = Pe.LTC_HALF_1, n.rectAreaLTC2 = Pe.LTC_HALF_2)), n.ambient[0] = h, n.ambient[1] = u, n.ambient[2] = f; const U = n.hash; (U.directionalLength !== d || U.pointLength !== p || U.spotLength !== g || U.rectAreaLength !== x || U.hemiLength !== m || U.numDirectionalShadows !== v || U.numPointShadows !== b || U.numSpotShadows !== M || U.numSpotMaps !== C || U.numLightProbes !== D) && (n.directional.length = d, n.spot.length = g, n.rectArea.length = x, n.point.length = p, n.hemi.length = m, n.directionalShadow.length = v, n.directionalShadowMap.length = v, n.pointShadow.length = b, n.pointShadowMap.length = b, n.spotShadow.length = M, n.spotShadowMap.length = M, n.directionalShadowMatrix.length = v, n.pointShadowMatrix.length = b, n.spotLightMatrix.length = M + C - T, n.spotLightMap.length = C, n.numSpotLightShadowsWithMaps = T, n.numLightProbes = D, U.directionalLength = d, U.pointLength = p, U.spotLength = g, U.rectAreaLength = x, U.hemiLength = m, U.numDirectionalShadows = v, U.numPointShadows = b, U.numSpotShadows = M, U.numSpotMaps = C, U.numLightProbes = D, n.version = Ov++); } function l(c, h) { let u = 0, f = 0, d = 0, p = 0, g = 0; const x = h.matrixWorldInverse; for (let m = 0, v = c.length; m < v; m++) { const b = c[m]; if (b.isDirectionalLight) { const M = n.directional[u]; M.direction.setFromMatrixPosition(b.matrixWorld), i.setFromMatrixPosition(b.target.matrixWorld), M.direction.sub(i), M.direction.transformDirection(x), u++; } else if (b.isSpotLight) { const M = n.spot[d]; M.position.setFromMatrixPosition(b.matrixWorld), M.position.applyMatrix4(x), M.direction.setFromMatrixPosition(b.matrixWorld), i.setFromMatrixPosition(b.target.matrixWorld), M.direction.sub(i), M.direction.transformDirection(x), d++; } else if (b.isRectAreaLight) { const M = n.rectArea[p]; M.position.setFromMatrixPosition(b.matrixWorld), M.position.applyMatrix4(x), a.identity(), r.copy(b.matrixWorld), r.premultiply(x), a.extractRotation(r), M.halfWidth.set(b.width * 0.5, 0, 0), M.halfHeight.set(0, b.height * 0.5, 0), M.halfWidth.applyMatrix4(a), M.halfHeight.applyMatrix4(a), p++; } else if (b.isPointLight) { const M = n.point[f]; M.position.setFromMatrixPosition(b.matrixWorld), M.position.applyMatrix4(x), f++; } else if (b.isHemisphereLight) { const M = n.hemi[g]; M.direction.setFromMatrixPosition(b.matrixWorld), M.direction.transformDirection(x), g++; } } } return { setup: o, setupView: l, state: n }; } function $h(s) { const e = new zv(s), t = [], n = []; function i(h) { c.camera = h, t.length = 0, n.length = 0; } function r(h) { t.push(h); } function a(h) { n.push(h); } function o() { e.setup(t); } function l(h) { e.setupView(t, h); } const c = { lightsArray: t, shadowsArray: n, camera: null, lights: e, transmissionRenderTarget: {} }; return { init: i, state: c, setupLights: o, setupLightsView: l, pushLight: r, pushShadow: a }; } function Hv(s) { let e = /* @__PURE__ */ new WeakMap(); function t(i, r = 0) { const a = e.get(i); let o; return a === void 0 ? (o = new $h(s), e.set(i, [o])) : r >= a.length ? (o = new $h(s), a.push(o)) : o = a[r], o; } function n() { e = /* @__PURE__ */ new WeakMap(); } return { get: t, dispose: n }; } const Vv = `void main() { gl_Position = vec4( position, 1.0 ); }`, Gv = `uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include 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 Wv(s, e, t) { let n = new lc(); const i = new ue(), r = new ue(), a = new at(), o = new Fm({ depthPacking: $f }), l = new zm(), c = {}, h = t.maxTextureSize, u = { [Rn]: Jt, [Jt]: Rn, [Dt]: Dt }, f = new Pt({ defines: { VSM_SAMPLES: 8 }, uniforms: { shadow_pass: { value: null }, resolution: { value: new ue() }, radius: { value: 4 } }, vertexShader: Vv, fragmentShader: Gv }), d = f.clone(); d.defines.HORIZONTAL_PASS = 1; const p = new xt(); p.setAttribute( "position", new gt( new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]), 3 ) ); const g = new ft(p, f), x = this; this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = Iu; let m = this.type; this.render = function(T, D, U) { if (x.enabled === !1 || x.autoUpdate === !1 && x.needsUpdate === !1 || T.length === 0) return; const S = s.getRenderTarget(), w = s.getActiveCubeFace(), B = s.getActiveMipmapLevel(), P = s.state; P.setBlending(Ot), P.buffers.depth.getReversed() === !0 ? P.buffers.color.setClear(0, 0, 0, 0) : P.buffers.color.setClear(1, 1, 1, 1), P.buffers.depth.setTest(!0), P.setScissorTest(!1); const O = m !== ei && this.type === ei, y = m === ei && this.type !== ei; for (let H = 0, Y = T.length; H < Y; H++) { const j = T[H], J = j.shadow; if (J === void 0) { ze("WebGLShadowMap:", j, "has no shadow."); continue; } if (J.autoUpdate === !1 && J.needsUpdate === !1) continue; i.copy(J.mapSize); const Z = J.getFrameExtents(); if (i.multiply(Z), r.copy(J.mapSize), (i.x > h || i.y > h) && (i.x > h && (r.x = Math.floor(h / Z.x), i.x = r.x * Z.x, J.mapSize.x = r.x), i.y > h && (r.y = Math.floor(h / Z.y), i.y = r.y * Z.y, J.mapSize.y = r.y)), J.map === null || O === !0 || y === !0) { const X = this.type !== ei ? { minFilter: Gt, magFilter: Gt } : {}; J.map !== null && J.map.dispose(), J.map = new rn(i.x, i.y, X), J.map.texture.name = j.name + ".shadowMap", J.camera.updateProjectionMatrix(); } s.setRenderTarget(J.map), s.clear(); const ae = J.getViewportCount(); for (let X = 0; X < ae; X++) { const q = J.getViewport(X); a.set( r.x * q.x, r.y * q.y, r.x * q.z, r.y * q.w ), P.viewport(a), J.updateMatrices(j, X), n = J.getFrustum(), M(D, U, J.camera, j, this.type); } J.isPointLightShadow !== !0 && this.type === ei && v(J, U), J.needsUpdate = !1; } m = this.type, x.needsUpdate = !1, s.setRenderTarget(S, w, B); }; function v(T, D) { const U = e.update(g); f.defines.VSM_SAMPLES !== T.blurSamples && (f.defines.VSM_SAMPLES = T.blurSamples, d.defines.VSM_SAMPLES = T.blurSamples, f.needsUpdate = !0, d.needsUpdate = !0), T.mapPass === null && (T.mapPass = new rn(i.x, i.y)), f.uniforms.shadow_pass.value = T.map.texture, f.uniforms.resolution.value = T.mapSize, f.uniforms.radius.value = T.radius, s.setRenderTarget(T.mapPass), s.clear(), s.renderBufferDirect(D, null, U, f, g, null), d.uniforms.shadow_pass.value = T.mapPass.texture, d.uniforms.resolution.value = T.mapSize, d.uniforms.radius.value = T.radius, s.setRenderTarget(T.map), s.clear(), s.renderBufferDirect(D, null, U, d, g, null); } function b(T, D, U, S) { let w = null; const B = U.isPointLight === !0 ? T.customDistanceMaterial : T.customDepthMaterial; if (B !== void 0) w = B; else if (w = U.isPointLight === !0 ? l : o, s.localClippingEnabled && D.clipShadows === !0 && Array.isArray(D.clippingPlanes) && D.clippingPlanes.length !== 0 || D.displacementMap && D.displacementScale !== 0 || D.alphaMap && D.alphaTest > 0 || D.map && D.alphaTest > 0 || D.alphaToCoverage === !0) { const P = w.uuid, O = D.uuid; let y = c[P]; y === void 0 && (y = {}, c[P] = y); let H = y[O]; H === void 0 && (H = w.clone(), y[O] = H, D.addEventListener("dispose", C)), w = H; } if (w.visible = D.visible, w.wireframe = D.wireframe, S === ei ? w.side = D.shadowSide !== null ? D.shadowSide : D.side : w.side = D.shadowSide !== null ? D.shadowSide : u[D.side], w.alphaMap = D.alphaMap, w.alphaTest = D.alphaToCoverage === !0 ? 0.5 : D.alphaTest, w.map = D.map, w.clipShadows = D.clipShadows, w.clippingPlanes = D.clippingPlanes, w.clipIntersection = D.clipIntersection, w.displacementMap = D.displacementMap, w.displacementScale = D.displacementScale, w.displacementBias = D.displacementBias, w.wireframeLinewidth = D.wireframeLinewidth, w.linewidth = D.linewidth, U.isPointLight === !0 && w.isMeshDistanceMaterial === !0) { const P = s.properties.get(w); P.light = U; } return w; } function M(T, D, U, S, w) { if (T.visible === !1) return; if (T.layers.test(D.layers) && (T.isMesh || T.isLine || T.isPoints) && (T.castShadow || T.receiveShadow && w === ei) && (!T.frustumCulled || n.intersectsObject(T))) { T.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse, T.matrixWorld); const O = e.update(T), y = T.material; if (Array.isArray(y)) { const H = O.groups; for (let Y = 0, j = H.length; Y < j; Y++) { const J = H[Y], Z = y[J.materialIndex]; if (Z && Z.visible) { const ae = b(T, Z, S, w); T.onBeforeShadow(s, T, D, U, O, ae, J), s.renderBufferDirect(U, null, O, ae, T, J), T.onAfterShadow(s, T, D, U, O, ae, J); } } } else if (y.visible) { const H = b(T, y, S, w); T.onBeforeShadow(s, T, D, U, O, H, null), s.renderBufferDirect(U, null, O, H, T, null), T.onAfterShadow(s, T, D, U, O, H, null); } } const P = T.children; for (let O = 0, y = P.length; O < y; O++) M(P[O], D, U, S, w); } function C(T) { T.target.removeEventListener("dispose", C); for (const U in c) { const S = c[U], w = T.target.uuid; w in S && (S[w].dispose(), delete S[w]); } } } const Xv = { [Wo]: Xo, [jo]: Yo, [Zo]: Ko, [fs]: qo, [Xo]: Wo, [Yo]: jo, [Ko]: Zo, [qo]: fs }; function jv(s, e) { function t() { let W = !1; const we = new at(); let ye = null; const Me = new at(0, 0, 0, 0); return { setMask: function(xe) { ye !== xe && !W && (s.colorMask(xe, xe, xe, xe), ye = xe); }, setLocked: function(xe) { W = xe; }, setClear: function(xe, me, Be, qe, vt) { vt === !0 && (xe *= qe, me *= qe, Be *= qe), we.set(xe, me, Be, qe), Me.equals(we) === !1 && (s.clearColor(xe, me, Be, qe), Me.copy(we)); }, reset: function() { W = !1, ye = null, Me.set(-1, 0, 0, 0); } }; } function n() { let W = !1, we = !1, ye = null, Me = null, xe = null; return { setReversed: function(me) { if (we !== me) { const Be = e.get("EXT_clip_control"); me ? Be.clipControlEXT(Be.LOWER_LEFT_EXT, Be.ZERO_TO_ONE_EXT) : Be.clipControlEXT(Be.LOWER_LEFT_EXT, Be.NEGATIVE_ONE_TO_ONE_EXT), we = me; const qe = xe; xe = null, this.setClear(qe); } }, getReversed: function() { return we; }, setTest: function(me) { me ? ce(s.DEPTH_TEST) : fe(s.DEPTH_TEST); }, setMask: function(me) { ye !== me && !W && (s.depthMask(me), ye = me); }, setFunc: function(me) { if (we && (me = Xv[me]), Me !== me) { switch (me) { case Wo: s.depthFunc(s.NEVER); break; case Xo: s.depthFunc(s.ALWAYS); break; case jo: s.depthFunc(s.LESS); break; case fs: s.depthFunc(s.LEQUAL); break; case Zo: s.depthFunc(s.EQUAL); break; case qo: s.depthFunc(s.GEQUAL); break; case Yo: s.depthFunc(s.GREATER); break; case Ko: s.depthFunc(s.NOTEQUAL); break; default: s.depthFunc(s.LEQUAL); } Me = me; } }, setLocked: function(me) { W = me; }, setClear: function(me) { xe !== me && (we && (me = 1 - me), s.clearDepth(me), xe = me); }, reset: function() { W = !1, ye = null, Me = null, xe = null, we = !1; } }; } function i() { let W = !1, we = null, ye = null, Me = null, xe = null, me = null, Be = null, qe = null, vt = null; return { setTest: function(ht) { W || (ht ? ce(s.STENCIL_TEST) : fe(s.STENCIL_TEST)); }, setMask: function(ht) { we !== ht && !W && (s.stencilMask(ht), we = ht); }, setFunc: function(ht, Un, Mn) { (ye !== ht || Me !== Un || xe !== Mn) && (s.stencilFunc(ht, Un, Mn), ye = ht, Me = Un, xe = Mn); }, setOp: function(ht, Un, Mn) { (me !== ht || Be !== Un || qe !== Mn) && (s.stencilOp(ht, Un, Mn), me = ht, Be = Un, qe = Mn); }, setLocked: function(ht) { W = ht; }, setClear: function(ht) { vt !== ht && (s.clearStencil(ht), vt = ht); }, reset: function() { W = !1, we = null, ye = null, Me = null, xe = null, me = null, Be = null, qe = null, vt = null; } }; } const r = new t(), a = new n(), o = new i(), l = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(); let h = {}, u = {}, f = /* @__PURE__ */ new WeakMap(), d = [], p = null, g = !1, x = null, m = null, v = null, b = null, M = null, C = null, T = null, D = new Fe(0, 0, 0), U = 0, S = !1, w = null, B = null, P = null, O = null, y = null; const H = s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS); let Y = !1, j = 0; const J = s.getParameter(s.VERSION); J.indexOf("WebGL") !== -1 ? (j = parseFloat(/^WebGL (\d)/.exec(J)[1]), Y = j >= 1) : J.indexOf("OpenGL ES") !== -1 && (j = parseFloat(/^OpenGL ES (\d)/.exec(J)[1]), Y = j >= 2); let Z = null, ae = {}; const X = s.getParameter(s.SCISSOR_BOX), q = s.getParameter(s.VIEWPORT), ge = new at().fromArray(X), pe = new at().fromArray(q); function de(W, we, ye, Me) { const xe = new Uint8Array(4), me = s.createTexture(); s.bindTexture(W, me), s.texParameteri(W, s.TEXTURE_MIN_FILTER, s.NEAREST), s.texParameteri(W, s.TEXTURE_MAG_FILTER, s.NEAREST); for (let Be = 0; Be < ye; Be++) W === s.TEXTURE_3D || W === s.TEXTURE_2D_ARRAY ? s.texImage3D(we, 0, s.RGBA, 1, 1, Me, 0, s.RGBA, s.UNSIGNED_BYTE, xe) : s.texImage2D(we + Be, 0, s.RGBA, 1, 1, 0, s.RGBA, s.UNSIGNED_BYTE, xe); return me; } const ie = {}; ie[s.TEXTURE_2D] = de(s.TEXTURE_2D, s.TEXTURE_2D, 1), ie[s.TEXTURE_CUBE_MAP] = de(s.TEXTURE_CUBE_MAP, s.TEXTURE_CUBE_MAP_POSITIVE_X, 6), ie[s.TEXTURE_2D_ARRAY] = de(s.TEXTURE_2D_ARRAY, s.TEXTURE_2D_ARRAY, 1, 1), ie[s.TEXTURE_3D] = de(s.TEXTURE_3D, s.TEXTURE_3D, 1, 1), r.setClear(0, 0, 0, 1), a.setClear(1), o.setClear(0), ce(s.DEPTH_TEST), a.setFunc(fs), V(!1), N(Rc), ce(s.CULL_FACE), _(Ot); function ce(W) { h[W] !== !0 && (s.enable(W), h[W] = !0); } function fe(W) { h[W] !== !1 && (s.disable(W), h[W] = !1); } function ve(W, we) { return u[W] !== we ? (s.bindFramebuffer(W, we), u[W] = we, W === s.DRAW_FRAMEBUFFER && (u[s.FRAMEBUFFER] = we), W === s.FRAMEBUFFER && (u[s.DRAW_FRAMEBUFFER] = we), !0) : !1; } function Ee(W, we) { let ye = d, Me = !1; if (W) { ye = f.get(we), ye === void 0 && (ye = [], f.set(we, ye)); const xe = W.textures; if (ye.length !== xe.length || ye[0] !== s.COLOR_ATTACHMENT0) { for (let me = 0, Be = xe.length; me < Be; me++) ye[me] = s.COLOR_ATTACHMENT0 + me; ye.length = xe.length, Me = !0; } } else ye[0] !== s.BACK && (ye[0] = s.BACK, Me = !0); Me && s.drawBuffers(ye); } function Ne(W) { return p !== W ? (s.useProgram(W), p = W, !0) : !1; } const Ye = { [Tn]: s.FUNC_ADD, [Lf]: s.FUNC_SUBTRACT, [Df]: s.FUNC_REVERSE_SUBTRACT }; Ye[If] = s.MIN, Ye[Nf] = s.MAX; const ke = { [Xs]: s.ZERO, [kf]: s.ONE, [Uf]: s.SRC_COLOR, [zo]: s.SRC_ALPHA, [zf]: s.SRC_ALPHA_SATURATE, [Go]: s.DST_COLOR, [Vo]: s.DST_ALPHA, [Bf]: s.ONE_MINUS_SRC_COLOR, [Ho]: s.ONE_MINUS_SRC_ALPHA, [Ff]: s.ONE_MINUS_DST_COLOR, [Of]: s.ONE_MINUS_DST_ALPHA, [Hf]: s.CONSTANT_COLOR, [Vf]: s.ONE_MINUS_CONSTANT_COLOR, [Gf]: s.CONSTANT_ALPHA, [Wf]: s.ONE_MINUS_CONSTANT_ALPHA }; function _(W, we, ye, Me, xe, me, Be, qe, vt, ht) { if (W === Ot) { g === !0 && (fe(s.BLEND), g = !1); return; } if (g === !1 && (ce(s.BLEND), g = !0), W !== ku) { if (W !== x || ht !== S) { if ((m !== Tn || M !== Tn) && (s.blendEquation(s.FUNC_ADD), m = Tn, M = Tn), ht) switch (W) { case cs: s.blendFuncSeparate(s.ONE, s.ONE_MINUS_SRC_ALPHA, s.ONE, s.ONE_MINUS_SRC_ALPHA); break; case Fo: s.blendFunc(s.ONE, s.ONE); break; case Lc: s.blendFuncSeparate(s.ZERO, s.ONE_MINUS_SRC_COLOR, s.ZERO, s.ONE); break; case Dc: s.blendFuncSeparate(s.DST_COLOR, s.ONE_MINUS_SRC_ALPHA, s.ZERO, s.ONE); break; default: et("WebGLState: Invalid blending: ", W); break; } else switch (W) { case cs: s.blendFuncSeparate(s.SRC_ALPHA, s.ONE_MINUS_SRC_ALPHA, s.ONE, s.ONE_MINUS_SRC_ALPHA); break; case Fo: s.blendFuncSeparate(s.SRC_ALPHA, s.ONE, s.ONE, s.ONE); break; case Lc: et("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true"); break; case Dc: et("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true"); break; default: et("WebGLState: Invalid blending: ", W); break; } v = null, b = null, C = null, T = null, D.set(0, 0, 0), U = 0, x = W, S = ht; } return; } xe = xe || we, me = me || ye, Be = Be || Me, (we !== m || xe !== M) && (s.blendEquationSeparate(Ye[we], Ye[xe]), m = we, M = xe), (ye !== v || Me !== b || me !== C || Be !== T) && (s.blendFuncSeparate(ke[ye], ke[Me], ke[me], ke[Be]), v = ye, b = Me, C = me, T = Be), (qe.equals(D) === !1 || vt !== U) && (s.blendColor(qe.r, qe.g, qe.b, vt), D.copy(qe), U = vt), x = W, S = !1; } function A(W, we) { W.side === Dt ? fe(s.CULL_FACE) : ce(s.CULL_FACE); let ye = W.side === Jt; we && (ye = !ye), V(ye), W.blending === cs && W.transparent === !1 ? _(Ot) : _(W.blending, W.blendEquation, W.blendSrc, W.blendDst, W.blendEquationAlpha, W.blendSrcAlpha, W.blendDstAlpha, W.blendColor, W.blendAlpha, W.premultipliedAlpha), a.setFunc(W.depthFunc), a.setTest(W.depthTest), a.setMask(W.depthWrite), r.setMask(W.colorWrite); const Me = W.stencilWrite; o.setTest(Me), Me && (o.setMask(W.stencilWriteMask), o.setFunc(W.stencilFunc, W.stencilRef, W.stencilFuncMask), o.setOp(W.stencilFail, W.stencilZFail, W.stencilZPass)), F(W.polygonOffset, W.polygonOffsetFactor, W.polygonOffsetUnits), W.alphaToCoverage === !0 ? ce(s.SAMPLE_ALPHA_TO_COVERAGE) : fe(s.SAMPLE_ALPHA_TO_COVERAGE); } function V(W) { w !== W && (W ? s.frontFace(s.CW) : s.frontFace(s.CCW), w = W); } function N(W) { W !== Pf ? (ce(s.CULL_FACE), W !== B && (W === Rc ? s.cullFace(s.BACK) : W === Rf ? s.cullFace(s.FRONT) : s.cullFace(s.FRONT_AND_BACK))) : fe(s.CULL_FACE), B = W; } function I(W) { W !== P && (Y && s.lineWidth(W), P = W); } function F(W, we, ye) { W ? (ce(s.POLYGON_OFFSET_FILL), (O !== we || y !== ye) && (s.polygonOffset(we, ye), O = we, y = ye)) : fe(s.POLYGON_OFFSET_FILL); } function ee(W) { W ? ce(s.SCISSOR_TEST) : fe(s.SCISSOR_TEST); } function $(W) { W === void 0 && (W = s.TEXTURE0 + H - 1), Z !== W && (s.activeTexture(W), Z = W); } function G(W, we, ye) { ye === void 0 && (Z === null ? ye = s.TEXTURE0 + H - 1 : ye = Z); let Me = ae[ye]; Me === void 0 && (Me = { type: void 0, texture: void 0 }, ae[ye] = Me), (Me.type !== W || Me.texture !== we) && (Z !== ye && (s.activeTexture(ye), Z = ye), s.bindTexture(W, we || ie[W]), Me.type = W, Me.texture = we); } function L() { const W = ae[Z]; W !== void 0 && W.type !== void 0 && (s.bindTexture(W.type, null), W.type = void 0, W.texture = void 0); } function E() { try { s.compressedTexImage2D(...arguments); } catch (W) { W("WebGLState:", W); } } function z() { try { s.compressedTexImage3D(...arguments); } catch (W) { W("WebGLState:", W); } } function K() { try { s.texSubImage2D(...arguments); } catch (W) { W("WebGLState:", W); } } function le() { try { s.texSubImage3D(...arguments); } catch (W) { W("WebGLState:", W); } } function te() { try { s.compressedTexSubImage2D(...arguments); } catch (W) { W("WebGLState:", W); } } function Te() { try { s.compressedTexSubImage3D(...arguments); } catch (W) { W("WebGLState:", W); } } function be() { try { s.texStorage2D(...arguments); } catch (W) { W("WebGLState:", W); } } function Re() { try { s.texStorage3D(...arguments); } catch (W) { W("WebGLState:", W); } } function De() { try { s.texImage2D(...arguments); } catch (W) { W("WebGLState:", W); } } function he() { try { s.texImage3D(...arguments); } catch (W) { W("WebGLState:", W); } } function _e(W) { ge.equals(W) === !1 && (s.scissor(W.x, W.y, W.z, W.w), ge.copy(W)); } function He(W) { pe.equals(W) === !1 && (s.viewport(W.x, W.y, W.z, W.w), pe.copy(W)); } function Ue(W, we) { let ye = c.get(we); ye === void 0 && (ye = /* @__PURE__ */ new WeakMap(), c.set(we, ye)); let Me = ye.get(W); Me === void 0 && (Me = s.getUniformBlockIndex(we, W.name), ye.set(W, Me)); } function Ce(W, we) { const Me = c.get(we).get(W); l.get(we) !== Me && (s.uniformBlockBinding(we, Me, W.__bindingPointIndex), l.set(we, Me)); } function Ve() { 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, ae = {}, u = {}, f = /* @__PURE__ */ new WeakMap(), d = [], p = null, g = !1, x = null, m = null, v = null, b = null, M = null, C = null, T = null, D = new Fe(0, 0, 0), U = 0, S = !1, w = null, B = null, P = null, O = null, y = null, ge.set(0, 0, s.canvas.width, s.canvas.height), pe.set(0, 0, s.canvas.width, s.canvas.height), r.reset(), a.reset(), o.reset(); } return { buffers: { color: r, depth: a, stencil: o }, enable: ce, disable: fe, bindFramebuffer: ve, drawBuffers: Ee, useProgram: Ne, setBlending: _, setMaterial: A, setFlipSided: V, setCullFace: N, setLineWidth: I, setPolygonOffset: F, setScissorTest: ee, activeTexture: $, bindTexture: G, unbindTexture: L, compressedTexImage2D: E, compressedTexImage3D: z, texImage2D: De, texImage3D: he, updateUBOMapping: Ue, uniformBlockBinding: Ce, texStorage2D: be, texStorage3D: Re, texSubImage2D: K, texSubImage3D: le, compressedTexSubImage2D: te, compressedTexSubImage3D: Te, scissor: _e, viewport: He, reset: Ve }; } function Zv(s, e, t, n, i, r, a) { const o = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : null, l = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), c = new ue(), h = /* @__PURE__ */ new WeakMap(); let u; const f = /* @__PURE__ */ new WeakMap(); let d = !1; try { d = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null; } catch { } function p(L, E) { return d ? ( // eslint-disable-next-line compat/compat new OffscreenCanvas(L, E) ) : or("canvas"); } function g(L, E, z) { let K = 1; const le = G(L); if ((le.width > z || le.height > z) && (K = z / Math.max(le.width, le.height)), K < 1) if (typeof HTMLImageElement < "u" && L instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && L instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && L instanceof ImageBitmap || typeof VideoFrame < "u" && L instanceof VideoFrame) { const te = Math.floor(K * le.width), Te = Math.floor(K * le.height); u === void 0 && (u = p(te, Te)); const be = E ? p(te, Te) : u; return be.width = te, be.height = Te, be.getContext("2d").drawImage(L, 0, 0, te, Te), ze("WebGLRenderer: Texture has been resized from (" + le.width + "x" + le.height + ") to (" + te + "x" + Te + ")."), be; } else return "data" in L && ze("WebGLRenderer: Image in DataTexture is too big (" + le.width + "x" + le.height + ")."), L; return L; } function x(L) { return L.generateMipmaps; } function m(L) { s.generateMipmap(L); } function v(L) { return L.isWebGLCubeRenderTarget ? s.TEXTURE_CUBE_MAP : L.isWebGL3DRenderTarget ? s.TEXTURE_3D : L.isWebGLArrayRenderTarget || L.isCompressedArrayTexture ? s.TEXTURE_2D_ARRAY : s.TEXTURE_2D; } function b(L, E, z, K, le = !1) { if (L !== null) { if (s[L] !== void 0) return s[L]; ze("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + L + "'"); } let te = E; if (E === s.RED && (z === s.FLOAT && (te = s.R32F), z === s.HALF_FLOAT && (te = s.R16F), z === s.UNSIGNED_BYTE && (te = s.R8)), E === s.RED_INTEGER && (z === s.UNSIGNED_BYTE && (te = s.R8UI), z === s.UNSIGNED_SHORT && (te = s.R16UI), z === s.UNSIGNED_INT && (te = s.R32UI), z === s.BYTE && (te = s.R8I), z === s.SHORT && (te = s.R16I), z === s.INT && (te = s.R32I)), E === s.RG && (z === s.FLOAT && (te = s.RG32F), z === s.HALF_FLOAT && (te = s.RG16F), z === s.UNSIGNED_BYTE && (te = s.RG8)), E === s.RG_INTEGER && (z === s.UNSIGNED_BYTE && (te = s.RG8UI), z === s.UNSIGNED_SHORT && (te = s.RG16UI), z === s.UNSIGNED_INT && (te = s.RG32UI), z === s.BYTE && (te = s.RG8I), z === s.SHORT && (te = s.RG16I), z === s.INT && (te = s.RG32I)), E === s.RGB_INTEGER && (z === s.UNSIGNED_BYTE && (te = s.RGB8UI), z === s.UNSIGNED_SHORT && (te = s.RGB16UI), z === s.UNSIGNED_INT && (te = s.RGB32UI), z === s.BYTE && (te = s.RGB8I), z === s.SHORT && (te = s.RGB16I), z === s.INT && (te = s.RGB32I)), E === s.RGBA_INTEGER && (z === s.UNSIGNED_BYTE && (te = s.RGBA8UI), z === s.UNSIGNED_SHORT && (te = s.RGBA16UI), z === s.UNSIGNED_INT && (te = s.RGBA32UI), z === s.BYTE && (te = s.RGBA8I), z === s.SHORT && (te = s.RGBA16I), z === s.INT && (te = s.RGBA32I)), E === s.RGB && (z === s.UNSIGNED_INT_5_9_9_9_REV && (te = s.RGB9_E5), z === s.UNSIGNED_INT_10F_11F_11F_REV && (te = s.R11F_G11F_B10F)), E === s.RGBA) { const Te = le ? ba : it.getTransfer(K); z === s.FLOAT && (te = s.RGBA32F), z === s.HALF_FLOAT && (te = s.RGBA16F), z === s.UNSIGNED_BYTE && (te = Te === ot ? s.SRGB8_ALPHA8 : s.RGBA8), z === s.UNSIGNED_SHORT_4_4_4_4 && (te = s.RGBA4), z === s.UNSIGNED_SHORT_5_5_5_1 && (te = s.RGB5_A1); } return (te === s.R16F || te === s.R32F || te === s.RG16F || te === s.RG32F || te === s.RGBA16F || te === s.RGBA32F) && e.get("EXT_color_buffer_float"), te; } function M(L, E) { let z; return L ? E === null || E === Ri || E === gs ? z = s.DEPTH24_STENCIL8 : E === Pn ? z = s.DEPTH32F_STENCIL8 : E === ir && (z = s.DEPTH24_STENCIL8, ze("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : E === null || E === Ri || E === gs ? z = s.DEPTH_COMPONENT24 : E === Pn ? z = s.DEPTH_COMPONENT32F : E === ir && (z = s.DEPTH_COMPONENT16), z; } function C(L, E) { return x(L) === !0 || L.isFramebufferTexture && L.minFilter !== Gt && L.minFilter !== Ht ? Math.log2(Math.max(E.width, E.height)) + 1 : L.mipmaps !== void 0 && L.mipmaps.length > 0 ? L.mipmaps.length : L.isCompressedTexture && Array.isArray(L.image) ? E.mipmaps.length : 1; } function T(L) { const E = L.target; E.removeEventListener("dispose", T), U(E), E.isVideoTexture && h.delete(E); } function D(L) { const E = L.target; E.removeEventListener("dispose", D), w(E); } function U(L) { const E = n.get(L); if (E.__webglInit === void 0) return; const z = L.source, K = f.get(z); if (K) { const le = K[E.__cacheKey]; le.usedTimes--, le.usedTimes === 0 && S(L), Object.keys(K).length === 0 && f.delete(z); } n.remove(L); } function S(L) { const E = n.get(L); s.deleteTexture(E.__webglTexture); const z = L.source, K = f.get(z); delete K[E.__cacheKey], a.memory.textures--; } function w(L) { const E = n.get(L); if (L.depthTexture && (L.depthTexture.dispose(), n.remove(L.depthTexture)), L.isWebGLCubeRenderTarget) for (let K = 0; K < 6; K++) { if (Array.isArray(E.__webglFramebuffer[K])) for (let le = 0; le < E.__webglFramebuffer[K].length; le++) s.deleteFramebuffer(E.__webglFramebuffer[K][le]); else s.deleteFramebuffer(E.__webglFramebuffer[K]); E.__webglDepthbuffer && s.deleteRenderbuffer(E.__webglDepthbuffer[K]); } else { if (Array.isArray(E.__webglFramebuffer)) for (let K = 0; K < E.__webglFramebuffer.length; K++) s.deleteFramebuffer(E.__webglFramebuffer[K]); else s.deleteFramebuffer(E.__webglFramebuffer); if (E.__webglDepthbuffer && s.deleteRenderbuffer(E.__webglDepthbuffer), E.__webglMultisampledFramebuffer && s.deleteFramebuffer(E.__webglMultisampledFramebuffer), E.__webglColorRenderbuffer) for (let K = 0; K < E.__webglColorRenderbuffer.length; K++) E.__webglColorRenderbuffer[K] && s.deleteRenderbuffer(E.__webglColorRenderbuffer[K]); E.__webglDepthRenderbuffer && s.deleteRenderbuffer(E.__webglDepthRenderbuffer); } const z = L.textures; for (let K = 0, le = z.length; K < le; K++) { const te = n.get(z[K]); te.__webglTexture && (s.deleteTexture(te.__webglTexture), a.memory.textures--), n.remove(z[K]); } n.remove(L); } let B = 0; function P() { B = 0; } function O() { const L = B; return L >= i.maxTextures && ze("WebGLTextures: Trying to use " + L + " texture units while this GPU supports only " + i.maxTextures), B += 1, L; } function y(L) { const E = []; return E.push(L.wrapS), E.push(L.wrapT), E.push(L.wrapR || 0), E.push(L.magFilter), E.push(L.minFilter), E.push(L.anisotropy), E.push(L.internalFormat), E.push(L.format), E.push(L.type), E.push(L.generateMipmaps), E.push(L.premultiplyAlpha), E.push(L.flipY), E.push(L.unpackAlignment), E.push(L.colorSpace), E.join(); } function H(L, E) { const z = n.get(L); if (L.isVideoTexture && ee(L), L.isRenderTargetTexture === !1 && L.isExternalTexture !== !0 && L.version > 0 && z.__version !== L.version) { const K = L.image; if (K === null) ze("WebGLRenderer: Texture marked for update but no image data found."); else if (K.complete === !1) ze("WebGLRenderer: Texture marked for update but image is incomplete"); else { ie(z, L, E); return; } } else L.isExternalTexture && (z.__webglTexture = L.sourceTexture ? L.sourceTexture : null); t.bindTexture(s.TEXTURE_2D, z.__webglTexture, s.TEXTURE0 + E); } function Y(L, E) { const z = n.get(L); if (L.isRenderTargetTexture === !1 && L.version > 0 && z.__version !== L.version) { ie(z, L, E); return; } else L.isExternalTexture && (z.__webglTexture = L.sourceTexture ? L.sourceTexture : null); t.bindTexture(s.TEXTURE_2D_ARRAY, z.__webglTexture, s.TEXTURE0 + E); } function j(L, E) { const z = n.get(L); if (L.isRenderTargetTexture === !1 && L.version > 0 && z.__version !== L.version) { ie(z, L, E); return; } t.bindTexture(s.TEXTURE_3D, z.__webglTexture, s.TEXTURE0 + E); } function J(L, E) { const z = n.get(L); if (L.version > 0 && z.__version !== L.version) { ce(z, L, E); return; } t.bindTexture(s.TEXTURE_CUBE_MAP, z.__webglTexture, s.TEXTURE0 + E); } const Z = { [Gn]: s.REPEAT, [Hn]: s.CLAMP_TO_EDGE, [va]: s.MIRRORED_REPEAT }, ae = { [Gt]: s.NEAREST, [Gu]: s.NEAREST_MIPMAP_NEAREST, [js]: s.NEAREST_MIPMAP_LINEAR, [Ht]: s.LINEAR, [la]: s.LINEAR_MIPMAP_NEAREST, [ti]: s.LINEAR_MIPMAP_LINEAR }, X = { [ep]: s.NEVER, [ap]: s.ALWAYS, [tp]: s.LESS, [$u]: s.LEQUAL, [np]: s.EQUAL, [rp]: s.GEQUAL, [ip]: s.GREATER, [sp]: s.NOTEQUAL }; function q(L, E) { if (E.type === Pn && e.has("OES_texture_float_linear") === !1 && (E.magFilter === Ht || E.magFilter === la || E.magFilter === js || E.magFilter === ti || E.minFilter === Ht || E.minFilter === la || E.minFilter === js || E.minFilter === ti) && ze("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), s.texParameteri(L, s.TEXTURE_WRAP_S, Z[E.wrapS]), s.texParameteri(L, s.TEXTURE_WRAP_T, Z[E.wrapT]), (L === s.TEXTURE_3D || L === s.TEXTURE_2D_ARRAY) && s.texParameteri(L, s.TEXTURE_WRAP_R, Z[E.wrapR]), s.texParameteri(L, s.TEXTURE_MAG_FILTER, ae[E.magFilter]), s.texParameteri(L, s.TEXTURE_MIN_FILTER, ae[E.minFilter]), E.compareFunction && (s.texParameteri(L, s.TEXTURE_COMPARE_MODE, s.COMPARE_REF_TO_TEXTURE), s.texParameteri(L, s.TEXTURE_COMPARE_FUNC, X[E.compareFunction])), e.has("EXT_texture_filter_anisotropic") === !0) { if (E.magFilter === Gt || E.minFilter !== js && E.minFilter !== ti || E.type === Pn && e.has("OES_texture_float_linear") === !1) return; if (E.anisotropy > 1 || n.get(E).__currentAnisotropy) { const z = e.get("EXT_texture_filter_anisotropic"); s.texParameterf(L, z.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(E.anisotropy, i.getMaxAnisotropy())), n.get(E).__currentAnisotropy = E.anisotropy; } } } function ge(L, E) { let z = !1; L.__webglInit === void 0 && (L.__webglInit = !0, E.addEventListener("dispose", T)); const K = E.source; let le = f.get(K); le === void 0 && (le = {}, f.set(K, le)); const te = y(E); if (te !== L.__cacheKey) { le[te] === void 0 && (le[te] = { texture: s.createTexture(), usedTimes: 0 }, a.memory.textures++, z = !0), le[te].usedTimes++; const Te = le[L.__cacheKey]; Te !== void 0 && (le[L.__cacheKey].usedTimes--, Te.usedTimes === 0 && S(E)), L.__cacheKey = te, L.__webglTexture = le[te].texture; } return z; } function pe(L, E, z) { return Math.floor(Math.floor(L / z) / E); } function de(L, E, z, K) { const te = L.updateRanges; if (te.length === 0) t.texSubImage2D(s.TEXTURE_2D, 0, 0, 0, E.width, E.height, z, K, E.data); else { te.sort((he, _e) => he.start - _e.start); let Te = 0; for (let he = 1; he < te.length; he++) { const _e = te[Te], He = te[he], Ue = _e.start + _e.count, Ce = pe(He.start, E.width, 4), Ve = pe(_e.start, E.width, 4); He.start <= Ue + 1 && Ce === Ve && pe(He.start + He.count - 1, E.width, 4) === Ce ? _e.count = Math.max( _e.count, He.start + He.count - _e.start ) : (++Te, te[Te] = He); } te.length = Te + 1; const be = s.getParameter(s.UNPACK_ROW_LENGTH), Re = s.getParameter(s.UNPACK_SKIP_PIXELS), De = s.getParameter(s.UNPACK_SKIP_ROWS); s.pixelStorei(s.UNPACK_ROW_LENGTH, E.width); for (let he = 0, _e = te.length; he < _e; he++) { const He = te[he], Ue = Math.floor(He.start / 4), Ce = Math.ceil(He.count / 4), Ve = Ue % E.width, W = Math.floor(Ue / E.width), we = Ce, ye = 1; s.pixelStorei(s.UNPACK_SKIP_PIXELS, Ve), s.pixelStorei(s.UNPACK_SKIP_ROWS, W), t.texSubImage2D(s.TEXTURE_2D, 0, Ve, W, we, ye, z, K, E.data); } L.clearUpdateRanges(), s.pixelStorei(s.UNPACK_ROW_LENGTH, be), s.pixelStorei(s.UNPACK_SKIP_PIXELS, Re), s.pixelStorei(s.UNPACK_SKIP_ROWS, De); } } function ie(L, E, z) { let K = s.TEXTURE_2D; (E.isDataArrayTexture || E.isCompressedArrayTexture) && (K = s.TEXTURE_2D_ARRAY), E.isData3DTexture && (K = s.TEXTURE_3D); const le = ge(L, E), te = E.source; t.bindTexture(K, L.__webglTexture, s.TEXTURE0 + z); const Te = n.get(te); if (te.version !== Te.__version || le === !0) { t.activeTexture(s.TEXTURE0 + z); const be = it.getPrimaries(it.workingColorSpace), Re = E.colorSpace === pi ? null : it.getPrimaries(E.colorSpace), De = E.colorSpace === pi || be === Re ? s.NONE : s.BROWSER_DEFAULT_WEBGL; s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, E.flipY), s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, E.premultiplyAlpha), s.pixelStorei(s.UNPACK_ALIGNMENT, E.unpackAlignment), s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL, De); let he = g(E.image, !1, i.maxTextureSize); he = $(E, he); const _e = r.convert(E.format, E.colorSpace), He = r.convert(E.type); let Ue = b(E.internalFormat, _e, He, E.colorSpace, E.isVideoTexture); q(K, E); let Ce; const Ve = E.mipmaps, W = E.isVideoTexture !== !0, we = Te.__version === void 0 || le === !0, ye = te.dataReady, Me = C(E, he); if (E.isDepthTexture) Ue = M(E.format === xs, E.type), we && (W ? t.texStorage2D(s.TEXTURE_2D, 1, Ue, he.width, he.height) : t.texImage2D(s.TEXTURE_2D, 0, Ue, he.width, he.height, 0, _e, He, null)); else if (E.isDataTexture) if (Ve.length > 0) { W && we && t.texStorage2D(s.TEXTURE_2D, Me, Ue, Ve[0].width, Ve[0].height); for (let xe = 0, me = Ve.length; xe < me; xe++) Ce = Ve[xe], W ? ye && t.texSubImage2D(s.TEXTURE_2D, xe, 0, 0, Ce.width, Ce.height, _e, He, Ce.data) : t.texImage2D(s.TEXTURE_2D, xe, Ue, Ce.width, Ce.height, 0, _e, He, Ce.data); E.generateMipmaps = !1; } else W ? (we && t.texStorage2D(s.TEXTURE_2D, Me, Ue, he.width, he.height), ye && de(E, he, _e, He)) : t.texImage2D(s.TEXTURE_2D, 0, Ue, he.width, he.height, 0, _e, He, he.data); else if (E.isCompressedTexture) if (E.isCompressedArrayTexture) { W && we && t.texStorage3D(s.TEXTURE_2D_ARRAY, Me, Ue, Ve[0].width, Ve[0].height, he.depth); for (let xe = 0, me = Ve.length; xe < me; xe++) if (Ce = Ve[xe], E.format !== sn) if (_e !== null) if (W) { if (ye) if (E.layerUpdates.size > 0) { const Be = Ah(Ce.width, Ce.height, E.format, E.type); for (const qe of E.layerUpdates) { const vt = Ce.data.subarray( qe * Be / Ce.data.BYTES_PER_ELEMENT, (qe + 1) * Be / Ce.data.BYTES_PER_ELEMENT ); t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY, xe, 0, 0, qe, Ce.width, Ce.height, 1, _e, vt); } E.clearLayerUpdates(); } else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY, xe, 0, 0, 0, Ce.width, Ce.height, he.depth, _e, Ce.data); } else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY, xe, Ue, Ce.width, Ce.height, he.depth, 0, Ce.data, 0, 0); else ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"); else W ? ye && t.texSubImage3D(s.TEXTURE_2D_ARRAY, xe, 0, 0, 0, Ce.width, Ce.height, he.depth, _e, He, Ce.data) : t.texImage3D(s.TEXTURE_2D_ARRAY, xe, Ue, Ce.width, Ce.height, he.depth, 0, _e, He, Ce.data); } else { W && we && t.texStorage2D(s.TEXTURE_2D, Me, Ue, Ve[0].width, Ve[0].height); for (let xe = 0, me = Ve.length; xe < me; xe++) Ce = Ve[xe], E.format !== sn ? _e !== null ? W ? ye && t.compressedTexSubImage2D(s.TEXTURE_2D, xe, 0, 0, Ce.width, Ce.height, _e, Ce.data) : t.compressedTexImage2D(s.TEXTURE_2D, xe, Ue, Ce.width, Ce.height, 0, Ce.data) : ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : W ? ye && t.texSubImage2D(s.TEXTURE_2D, xe, 0, 0, Ce.width, Ce.height, _e, He, Ce.data) : t.texImage2D(s.TEXTURE_2D, xe, Ue, Ce.width, Ce.height, 0, _e, He, Ce.data); } else if (E.isDataArrayTexture) if (W) { if (we && t.texStorage3D(s.TEXTURE_2D_ARRAY, Me, Ue, he.width, he.height, he.depth), ye) if (E.layerUpdates.size > 0) { const xe = Ah(he.width, he.height, E.format, E.type); for (const me of E.layerUpdates) { const Be = he.data.subarray( me * xe / he.data.BYTES_PER_ELEMENT, (me + 1) * xe / he.data.BYTES_PER_ELEMENT ); t.texSubImage3D(s.TEXTURE_2D_ARRAY, 0, 0, 0, me, he.width, he.height, 1, _e, He, Be); } E.clearLayerUpdates(); } else t.texSubImage3D(s.TEXTURE_2D_ARRAY, 0, 0, 0, 0, he.width, he.height, he.depth, _e, He, he.data); } else t.texImage3D(s.TEXTURE_2D_ARRAY, 0, Ue, he.width, he.height, he.depth, 0, _e, He, he.data); else if (E.isData3DTexture) W ? (we && t.texStorage3D(s.TEXTURE_3D, Me, Ue, he.width, he.height, he.depth), ye && t.texSubImage3D(s.TEXTURE_3D, 0, 0, 0, 0, he.width, he.height, he.depth, _e, He, he.data)) : t.texImage3D(s.TEXTURE_3D, 0, Ue, he.width, he.height, he.depth, 0, _e, He, he.data); else if (E.isFramebufferTexture) { if (we) if (W) t.texStorage2D(s.TEXTURE_2D, Me, Ue, he.width, he.height); else { let xe = he.width, me = he.height; for (let Be = 0; Be < Me; Be++) t.texImage2D(s.TEXTURE_2D, Be, Ue, xe, me, 0, _e, He, null), xe >>= 1, me >>= 1; } } else if (Ve.length > 0) { if (W && we) { const xe = G(Ve[0]); t.texStorage2D(s.TEXTURE_2D, Me, Ue, xe.width, xe.height); } for (let xe = 0, me = Ve.length; xe < me; xe++) Ce = Ve[xe], W ? ye && t.texSubImage2D(s.TEXTURE_2D, xe, 0, 0, _e, He, Ce) : t.texImage2D(s.TEXTURE_2D, xe, Ue, _e, He, Ce); E.generateMipmaps = !1; } else if (W) { if (we) { const xe = G(he); t.texStorage2D(s.TEXTURE_2D, Me, Ue, xe.width, xe.height); } ye && t.texSubImage2D(s.TEXTURE_2D, 0, 0, 0, _e, He, he); } else t.texImage2D(s.TEXTURE_2D, 0, Ue, _e, He, he); x(E) && m(K), Te.__version = te.version, E.onUpdate && E.onUpdate(E); } L.__version = E.version; } function ce(L, E, z) { if (E.image.length !== 6) return; const K = ge(L, E), le = E.source; t.bindTexture(s.TEXTURE_CUBE_MAP, L.__webglTexture, s.TEXTURE0 + z); const te = n.get(le); if (le.version !== te.__version || K === !0) { t.activeTexture(s.TEXTURE0 + z); const Te = it.getPrimaries(it.workingColorSpace), be = E.colorSpace === pi ? null : it.getPrimaries(E.colorSpace), Re = E.colorSpace === pi || Te === be ? s.NONE : s.BROWSER_DEFAULT_WEBGL; s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, E.flipY), s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, E.premultiplyAlpha), s.pixelStorei(s.UNPACK_ALIGNMENT, E.unpackAlignment), s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL, Re); const De = E.isCompressedTexture || E.image[0].isCompressedTexture, he = E.image[0] && E.image[0].isDataTexture, _e = []; for (let me = 0; me < 6; me++) !De && !he ? _e[me] = g(E.image[me], !0, i.maxCubemapSize) : _e[me] = he ? E.image[me].image : E.image[me], _e[me] = $(E, _e[me]); const He = _e[0], Ue = r.convert(E.format, E.colorSpace), Ce = r.convert(E.type), Ve = b(E.internalFormat, Ue, Ce, E.colorSpace), W = E.isVideoTexture !== !0, we = te.__version === void 0 || K === !0, ye = le.dataReady; let Me = C(E, He); q(s.TEXTURE_CUBE_MAP, E); let xe; if (De) { W && we && t.texStorage2D(s.TEXTURE_CUBE_MAP, Me, Ve, He.width, He.height); for (let me = 0; me < 6; me++) { xe = _e[me].mipmaps; for (let Be = 0; Be < xe.length; Be++) { const qe = xe[Be]; E.format !== sn ? Ue !== null ? W ? ye && t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, Be, 0, 0, qe.width, qe.height, Ue, qe.data) : t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, Be, Ve, qe.width, qe.height, 0, qe.data) : ze("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : W ? ye && t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, Be, 0, 0, qe.width, qe.height, Ue, Ce, qe.data) : t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, Be, Ve, qe.width, qe.height, 0, Ue, Ce, qe.data); } } } else { if (xe = E.mipmaps, W && we) { xe.length > 0 && Me++; const me = G(_e[0]); t.texStorage2D(s.TEXTURE_CUBE_MAP, Me, Ve, me.width, me.height); } for (let me = 0; me < 6; me++) if (he) { W ? ye && t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, 0, 0, 0, _e[me].width, _e[me].height, Ue, Ce, _e[me].data) : t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, 0, Ve, _e[me].width, _e[me].height, 0, Ue, Ce, _e[me].data); for (let Be = 0; Be < xe.length; Be++) { const vt = xe[Be].image[me].image; W ? ye && t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, Be + 1, 0, 0, vt.width, vt.height, Ue, Ce, vt.data) : t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, Be + 1, Ve, vt.width, vt.height, 0, Ue, Ce, vt.data); } } else { W ? ye && t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, 0, 0, 0, Ue, Ce, _e[me]) : t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, 0, Ve, Ue, Ce, _e[me]); for (let Be = 0; Be < xe.length; Be++) { const qe = xe[Be]; W ? ye && t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, Be + 1, 0, 0, Ue, Ce, qe.image[me]) : t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + me, Be + 1, Ve, Ue, Ce, qe.image[me]); } } } x(E) && m(s.TEXTURE_CUBE_MAP), te.__version = le.version, E.onUpdate && E.onUpdate(E); } L.__version = E.version; } function fe(L, E, z, K, le, te) { const Te = r.convert(z.format, z.colorSpace), be = r.convert(z.type), Re = b(z.internalFormat, Te, be, z.colorSpace), De = n.get(E), he = n.get(z); if (he.__renderTarget = E, !De.__hasExternalTextures) { const _e = Math.max(1, E.width >> te), He = Math.max(1, E.height >> te); le === s.TEXTURE_3D || le === s.TEXTURE_2D_ARRAY ? t.texImage3D(le, te, Re, _e, He, E.depth, 0, Te, be, null) : t.texImage2D(le, te, Re, _e, He, 0, Te, be, null); } t.bindFramebuffer(s.FRAMEBUFFER, L), F(E) ? o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER, K, le, he.__webglTexture, 0, I(E)) : (le === s.TEXTURE_2D || le >= s.TEXTURE_CUBE_MAP_POSITIVE_X && le <= s.TEXTURE_CUBE_MAP_NEGATIVE_Z) && s.framebufferTexture2D(s.FRAMEBUFFER, K, le, he.__webglTexture, te), t.bindFramebuffer(s.FRAMEBUFFER, null); } function ve(L, E, z) { if (s.bindRenderbuffer(s.RENDERBUFFER, L), E.depthBuffer) { const K = E.depthTexture, le = K && K.isDepthTexture ? K.type : null, te = M(E.stencilBuffer, le), Te = E.stencilBuffer ? s.DEPTH_STENCIL_ATTACHMENT : s.DEPTH_ATTACHMENT, be = I(E); F(E) ? o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER, be, te, E.width, E.height) : z ? s.renderbufferStorageMultisample(s.RENDERBUFFER, be, te, E.width, E.height) : s.renderbufferStorage(s.RENDERBUFFER, te, E.width, E.height), s.framebufferRenderbuffer(s.FRAMEBUFFER, Te, s.RENDERBUFFER, L); } else { const K = E.textures; for (let le = 0; le < K.length; le++) { const te = K[le], Te = r.convert(te.format, te.colorSpace), be = r.convert(te.type), Re = b(te.internalFormat, Te, be, te.colorSpace), De = I(E); z && F(E) === !1 ? s.renderbufferStorageMultisample(s.RENDERBUFFER, De, Re, E.width, E.height) : F(E) ? o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER, De, Re, E.width, E.height) : s.renderbufferStorage(s.RENDERBUFFER, Re, E.width, E.height); } } s.bindRenderbuffer(s.RENDERBUFFER, null); } function Ee(L, E) { if (E && E.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported"); if (t.bindFramebuffer(s.FRAMEBUFFER, L), !(E.depthTexture && E.depthTexture.isDepthTexture)) throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture"); const K = n.get(E.depthTexture); K.__renderTarget = E, (!K.__webglTexture || E.depthTexture.image.width !== E.width || E.depthTexture.image.height !== E.height) && (E.depthTexture.image.width = E.width, E.depthTexture.image.height = E.height, E.depthTexture.needsUpdate = !0), H(E.depthTexture, 0); const le = K.__webglTexture, te = I(E); if (E.depthTexture.format === sr) F(E) ? o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER, s.DEPTH_ATTACHMENT, s.TEXTURE_2D, le, 0, te) : s.framebufferTexture2D(s.FRAMEBUFFER, s.DEPTH_ATTACHMENT, s.TEXTURE_2D, le, 0); else if (E.depthTexture.format === xs) F(E) ? o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER, s.DEPTH_STENCIL_ATTACHMENT, s.TEXTURE_2D, le, 0, te) : s.framebufferTexture2D(s.FRAMEBUFFER, s.DEPTH_STENCIL_ATTACHMENT, s.TEXTURE_2D, le, 0); else throw new Error("Unknown depthTexture format"); } function Ne(L) { const E = n.get(L), z = L.isWebGLCubeRenderTarget === !0; if (E.__boundDepthTexture !== L.depthTexture) { const K = L.depthTexture; if (E.__depthDisposeCallback && E.__depthDisposeCallback(), K) { const le = () => { delete E.__boundDepthTexture, delete E.__depthDisposeCallback, K.removeEventListener("dispose", le); }; K.addEventListener("dispose", le), E.__depthDisposeCallback = le; } E.__boundDepthTexture = K; } if (L.depthTexture && !E.__autoAllocateDepthBuffer) { if (z) throw new Error("target.depthTexture not supported in Cube render targets"); const K = L.texture.mipmaps; K && K.length > 0 ? Ee(E.__webglFramebuffer[0], L) : Ee(E.__webglFramebuffer, L); } else if (z) { E.__webglDepthbuffer = []; for (let K = 0; K < 6; K++) if (t.bindFramebuffer(s.FRAMEBUFFER, E.__webglFramebuffer[K]), E.__webglDepthbuffer[K] === void 0) E.__webglDepthbuffer[K] = s.createRenderbuffer(), ve(E.__webglDepthbuffer[K], L, !1); else { const le = L.stencilBuffer ? s.DEPTH_STENCIL_ATTACHMENT : s.DEPTH_ATTACHMENT, te = E.__webglDepthbuffer[K]; s.bindRenderbuffer(s.RENDERBUFFER, te), s.framebufferRenderbuffer(s.FRAMEBUFFER, le, s.RENDERBUFFER, te); } } else { const K = L.texture.mipmaps; if (K && K.length > 0 ? t.bindFramebuffer(s.FRAMEBUFFER, E.__webglFramebuffer[0]) : t.bindFramebuffer(s.FRAMEBUFFER, E.__webglFramebuffer), E.__webglDepthbuffer === void 0) E.__webglDepthbuffer = s.createRenderbuffer(), ve(E.__webglDepthbuffer, L, !1); else { const le = L.stencilBuffer ? s.DEPTH_STENCIL_ATTACHMENT : s.DEPTH_ATTACHMENT, te = E.__webglDepthbuffer; s.bindRenderbuffer(s.RENDERBUFFER, te), s.framebufferRenderbuffer(s.FRAMEBUFFER, le, s.RENDERBUFFER, te); } } t.bindFramebuffer(s.FRAMEBUFFER, null); } function Ye(L, E, z) { const K = n.get(L); E !== void 0 && fe(K.__webglFramebuffer, L, L.texture, s.COLOR_ATTACHMENT0, s.TEXTURE_2D, 0), z !== void 0 && Ne(L); } function ke(L) { const E = L.texture, z = n.get(L), K = n.get(E); L.addEventListener("dispose", D); const le = L.textures, te = L.isWebGLCubeRenderTarget === !0, Te = le.length > 1; if (Te || (K.__webglTexture === void 0 && (K.__webglTexture = s.createTexture()), K.__version = E.version, a.memory.textures++), te) { z.__webglFramebuffer = []; for (let be = 0; be < 6; be++) if (E.mipmaps && E.mipmaps.length > 0) { z.__webglFramebuffer[be] = []; for (let Re = 0; Re < E.mipmaps.length; Re++) z.__webglFramebuffer[be][Re] = s.createFramebuffer(); } else z.__webglFramebuffer[be] = s.createFramebuffer(); } else { if (E.mipmaps && E.mipmaps.length > 0) { z.__webglFramebuffer = []; for (let be = 0; be < E.mipmaps.length; be++) z.__webglFramebuffer[be] = s.createFramebuffer(); } else z.__webglFramebuffer = s.createFramebuffer(); if (Te) for (let be = 0, Re = le.length; be < Re; be++) { const De = n.get(le[be]); De.__webglTexture === void 0 && (De.__webglTexture = s.createTexture(), a.memory.textures++); } if (L.samples > 0 && F(L) === !1) { z.__webglMultisampledFramebuffer = s.createFramebuffer(), z.__webglColorRenderbuffer = [], t.bindFramebuffer(s.FRAMEBUFFER, z.__webglMultisampledFramebuffer); for (let be = 0; be < le.length; be++) { const Re = le[be]; z.__webglColorRenderbuffer[be] = s.createRenderbuffer(), s.bindRenderbuffer(s.RENDERBUFFER, z.__webglColorRenderbuffer[be]); const De = r.convert(Re.format, Re.colorSpace), he = r.convert(Re.type), _e = b(Re.internalFormat, De, he, Re.colorSpace, L.isXRRenderTarget === !0), He = I(L); s.renderbufferStorageMultisample(s.RENDERBUFFER, He, _e, L.width, L.height), s.framebufferRenderbuffer(s.FRAMEBUFFER, s.COLOR_ATTACHMENT0 + be, s.RENDERBUFFER, z.__webglColorRenderbuffer[be]); } s.bindRenderbuffer(s.RENDERBUFFER, null), L.depthBuffer && (z.__webglDepthRenderbuffer = s.createRenderbuffer(), ve(z.__webglDepthRenderbuffer, L, !0)), t.bindFramebuffer(s.FRAMEBUFFER, null); } } if (te) { t.bindTexture(s.TEXTURE_CUBE_MAP, K.__webglTexture), q(s.TEXTURE_CUBE_MAP, E); for (let be = 0; be < 6; be++) if (E.mipmaps && E.mipmaps.length > 0) for (let Re = 0; Re < E.mipmaps.length; Re++) fe(z.__webglFramebuffer[be][Re], L, E, s.COLOR_ATTACHMENT0, s.TEXTURE_CUBE_MAP_POSITIVE_X + be, Re); else fe(z.__webglFramebuffer[be], L, E, s.COLOR_ATTACHMENT0, s.TEXTURE_CUBE_MAP_POSITIVE_X + be, 0); x(E) && m(s.TEXTURE_CUBE_MAP), t.unbindTexture(); } else if (Te) { for (let be = 0, Re = le.length; be < Re; be++) { const De = le[be], he = n.get(De); let _e = s.TEXTURE_2D; (L.isWebGL3DRenderTarget || L.isWebGLArrayRenderTarget) && (_e = L.isWebGL3DRenderTarget ? s.TEXTURE_3D : s.TEXTURE_2D_ARRAY), t.bindTexture(_e, he.__webglTexture), q(_e, De), fe(z.__webglFramebuffer, L, De, s.COLOR_ATTACHMENT0 + be, _e, 0), x(De) && m(_e); } t.unbindTexture(); } else { let be = s.TEXTURE_2D; if ((L.isWebGL3DRenderTarget || L.isWebGLArrayRenderTarget) && (be = L.isWebGL3DRenderTarget ? s.TEXTURE_3D : s.TEXTURE_2D_ARRAY), t.bindTexture(be, K.__webglTexture), q(be, E), E.mipmaps && E.mipmaps.length > 0) for (let Re = 0; Re < E.mipmaps.length; Re++) fe(z.__webglFramebuffer[Re], L, E, s.COLOR_ATTACHMENT0, be, Re); else fe(z.__webglFramebuffer, L, E, s.COLOR_ATTACHMENT0, be, 0); x(E) && m(be), t.unbindTexture(); } L.depthBuffer && Ne(L); } function _(L) { const E = L.textures; for (let z = 0, K = E.length; z < K; z++) { const le = E[z]; if (x(le)) { const te = v(L), Te = n.get(le).__webglTexture; t.bindTexture(te, Te), m(te), t.unbindTexture(); } } } const A = [], V = []; function N(L) { if (L.samples > 0) { if (F(L) === !1) { const E = L.textures, z = L.width, K = L.height; let le = s.COLOR_BUFFER_BIT; const te = L.stencilBuffer ? s.DEPTH_STENCIL_ATTACHMENT : s.DEPTH_ATTACHMENT, Te = n.get(L), be = E.length > 1; if (be) for (let De = 0; De < E.length; De++) t.bindFramebuffer(s.FRAMEBUFFER, Te.__webglMultisampledFramebuffer), s.framebufferRenderbuffer(s.FRAMEBUFFER, s.COLOR_ATTACHMENT0 + De, s.RENDERBUFFER, null), t.bindFramebuffer(s.FRAMEBUFFER, Te.__webglFramebuffer), s.framebufferTexture2D(s.DRAW_FRAMEBUFFER, s.COLOR_ATTACHMENT0 + De, s.TEXTURE_2D, null, 0); t.bindFramebuffer(s.READ_FRAMEBUFFER, Te.__webglMultisampledFramebuffer); const Re = L.texture.mipmaps; Re && Re.length > 0 ? t.bindFramebuffer(s.DRAW_FRAMEBUFFER, Te.__webglFramebuffer[0]) : t.bindFramebuffer(s.DRAW_FRAMEBUFFER, Te.__webglFramebuffer); for (let De = 0; De < E.length; De++) { if (L.resolveDepthBuffer && (L.depthBuffer && (le |= s.DEPTH_BUFFER_BIT), L.stencilBuffer && L.resolveStencilBuffer && (le |= s.STENCIL_BUFFER_BIT)), be) { s.framebufferRenderbuffer(s.READ_FRAMEBUFFER, s.COLOR_ATTACHMENT0, s.RENDERBUFFER, Te.__webglColorRenderbuffer[De]); const he = n.get(E[De]).__webglTexture; s.framebufferTexture2D(s.DRAW_FRAMEBUFFER, s.COLOR_ATTACHMENT0, s.TEXTURE_2D, he, 0); } s.blitFramebuffer(0, 0, z, K, 0, 0, z, K, le, s.NEAREST), l === !0 && (A.length = 0, V.length = 0, A.push(s.COLOR_ATTACHMENT0 + De), L.depthBuffer && L.resolveDepthBuffer === !1 && (A.push(te), V.push(te), s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER, V)), s.invalidateFramebuffer(s.READ_FRAMEBUFFER, A)); } if (t.bindFramebuffer(s.READ_FRAMEBUFFER, null), t.bindFramebuffer(s.DRAW_FRAMEBUFFER, null), be) for (let De = 0; De < E.length; De++) { t.bindFramebuffer(s.FRAMEBUFFER, Te.__webglMultisampledFramebuffer), s.framebufferRenderbuffer(s.FRAMEBUFFER, s.COLOR_ATTACHMENT0 + De, s.RENDERBUFFER, Te.__webglColorRenderbuffer[De]); const he = n.get(E[De]).__webglTexture; t.bindFramebuffer(s.FRAMEBUFFER, Te.__webglFramebuffer), s.framebufferTexture2D(s.DRAW_FRAMEBUFFER, s.COLOR_ATTACHMENT0 + De, s.TEXTURE_2D, he, 0); } t.bindFramebuffer(s.DRAW_FRAMEBUFFER, Te.__webglMultisampledFramebuffer); } else if (L.depthBuffer && L.resolveDepthBuffer === !1 && l) { const E = L.stencilBuffer ? s.DEPTH_STENCIL_ATTACHMENT : s.DEPTH_ATTACHMENT; s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER, [E]); } } } function I(L) { return Math.min(i.maxSamples, L.samples); } function F(L) { const E = n.get(L); return L.samples > 0 && e.has("WEBGL_multisampled_render_to_texture") === !0 && E.__useRenderToTexture !== !1; } function ee(L) { const E = a.render.frame; h.get(L) !== E && (h.set(L, E), L.update()); } function $(L, E) { const z = L.colorSpace, K = L.format, le = L.type; return L.isCompressedTexture === !0 || L.isVideoTexture === !0 || z !== Tt && z !== pi && (it.getTransfer(z) === ot ? (K !== sn || le !== Ln) && ze("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : et("WebGLTextures: Unsupported texture color space:", z)), E; } function G(L) { return typeof HTMLImageElement < "u" && L instanceof HTMLImageElement ? (c.width = L.naturalWidth || L.width, c.height = L.naturalHeight || L.height) : typeof VideoFrame < "u" && L instanceof VideoFrame ? (c.width = L.displayWidth, c.height = L.displayHeight) : (c.width = L.width, c.height = L.height), c; } this.allocateTextureUnit = O, this.resetTextureUnits = P, this.setTexture2D = H, this.setTexture2DArray = Y, this.setTexture3D = j, this.setTextureCube = J, this.rebindTextures = Ye, this.setupRenderTarget = ke, this.updateRenderTargetMipmap = _, this.updateMultisampleRenderTarget = N, this.setupDepthRenderbuffer = Ne, this.setupFrameBufferTexture = fe, this.useMultisampledRTT = F; } function qv(s, e) { function t(n, i = pi) { let r; const a = it.getTransfer(i); if (n === Ln) return s.UNSIGNED_BYTE; if (n === Kl) return s.UNSIGNED_SHORT_4_4_4_4; if (n === $l) return s.UNSIGNED_SHORT_5_5_5_1; if (n === ju) return s.UNSIGNED_INT_5_9_9_9_REV; if (n === Zu) return s.UNSIGNED_INT_10F_11F_11F_REV; if (n === Wu) return s.BYTE; if (n === Xu) return s.SHORT; if (n === ir) return s.UNSIGNED_SHORT; if (n === Yl) return s.INT; if (n === Ri) return s.UNSIGNED_INT; if (n === Pn) return s.FLOAT; if (n === _n) return s.HALF_FLOAT; if (n === qu) return s.ALPHA; if (n === Yu) return s.RGB; if (n === sn) return s.RGBA; if (n === sr) return s.DEPTH_COMPONENT; if (n === xs) return s.DEPTH_STENCIL; if (n === Jl) return s.RED; if (n === Ql) return s.RED_INTEGER; if (n === ec) return s.RG; if (n === tc) return s.RG_INTEGER; if (n === nc) return s.RGBA_INTEGER; if (n === ca || n === ha || n === ua || n === da) if (a === ot) if (r = e.get("WEBGL_compressed_texture_s3tc_srgb"), r !== null) { if (n === ca) return r.COMPRESSED_SRGB_S3TC_DXT1_EXT; if (n === ha) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; if (n === ua) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; if (n === da) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; } else return null; else if (r = e.get("WEBGL_compressed_texture_s3tc"), r !== null) { if (n === ca) return r.COMPRESSED_RGB_S3TC_DXT1_EXT; if (n === ha) return r.COMPRESSED_RGBA_S3TC_DXT1_EXT; if (n === ua) return r.COMPRESSED_RGBA_S3TC_DXT3_EXT; if (n === da) return r.COMPRESSED_RGBA_S3TC_DXT5_EXT; } else return null; if (n === Qo || n === el || n === tl || n === nl) if (r = e.get("WEBGL_compressed_texture_pvrtc"), r !== null) { if (n === Qo) return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; if (n === el) return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; if (n === tl) return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; if (n === nl) return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; } else return null; if (n === il || n === sl || n === rl) if (r = e.get("WEBGL_compressed_texture_etc"), r !== null) { if (n === il || n === sl) return a === ot ? r.COMPRESSED_SRGB8_ETC2 : r.COMPRESSED_RGB8_ETC2; if (n === rl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : r.COMPRESSED_RGBA8_ETC2_EAC; } else return null; if (n === al || n === ol || n === ll || n === cl || n === hl || n === ul || n === dl || n === fl || n === pl || n === ml || n === gl || n === xl || n === vl || n === bl) if (r = e.get("WEBGL_compressed_texture_astc"), r !== null) { if (n === al) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : r.COMPRESSED_RGBA_ASTC_4x4_KHR; if (n === ol) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : r.COMPRESSED_RGBA_ASTC_5x4_KHR; if (n === ll) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : r.COMPRESSED_RGBA_ASTC_5x5_KHR; if (n === cl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : r.COMPRESSED_RGBA_ASTC_6x5_KHR; if (n === hl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : r.COMPRESSED_RGBA_ASTC_6x6_KHR; if (n === ul) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : r.COMPRESSED_RGBA_ASTC_8x5_KHR; if (n === dl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : r.COMPRESSED_RGBA_ASTC_8x6_KHR; if (n === fl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : r.COMPRESSED_RGBA_ASTC_8x8_KHR; if (n === pl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : r.COMPRESSED_RGBA_ASTC_10x5_KHR; if (n === ml) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : r.COMPRESSED_RGBA_ASTC_10x6_KHR; if (n === gl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : r.COMPRESSED_RGBA_ASTC_10x8_KHR; if (n === xl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : r.COMPRESSED_RGBA_ASTC_10x10_KHR; if (n === vl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : r.COMPRESSED_RGBA_ASTC_12x10_KHR; if (n === bl) return a === ot ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : r.COMPRESSED_RGBA_ASTC_12x12_KHR; } else return null; if (n === _l || n === yl || n === Ml) if (r = e.get("EXT_texture_compression_bptc"), r !== null) { if (n === _l) return a === ot ? r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : r.COMPRESSED_RGBA_BPTC_UNORM_EXT; if (n === yl) return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT; if (n === Ml) return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT; } else return null; if (n === Sl || n === wl || n === El || n === Tl) if (r = e.get("EXT_texture_compression_rgtc"), r !== null) { if (n === Sl) return r.COMPRESSED_RED_RGTC1_EXT; if (n === wl) return r.COMPRESSED_SIGNED_RED_RGTC1_EXT; if (n === El) return r.COMPRESSED_RED_GREEN_RGTC2_EXT; if (n === Tl) return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT; } else return null; return n === gs ? s.UNSIGNED_INT_24_8 : s[n] !== void 0 ? s[n] : null; } return { convert: t }; } const Yv = ` void main() { gl_Position = vec4( position, 1.0 ); }`, Kv = ` 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 $v { /** * Constructs a new depth sensing module. */ constructor() { this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0; } /** * Inits the depth sensing module * * @param {XRWebGLDepthInformation} depthData - The XR depth data. * @param {XRRenderState} renderState - The XR render state. */ init(e, t) { if (this.texture === null) { const n = new ud(e.texture); (e.depthNear !== t.depthNear || e.depthFar !== t.depthFar) && (this.depthNear = e.depthNear, this.depthFar = e.depthFar), this.texture = n; } } /** * Returns a plane mesh that visualizes the depth texture. * * @param {ArrayCamera} cameraXR - The XR camera. * @return {?Mesh} The plane mesh. */ getMesh(e) { if (this.texture !== null && this.mesh === null) { const t = e.cameras[0].viewport, n = new Pt({ vertexShader: Yv, fragmentShader: Kv, uniforms: { depthColor: { value: this.texture }, depthWidth: { value: t.z }, depthHeight: { value: t.w } } }); this.mesh = new ft(new Ii(20, 20), n); } return this.mesh; } /** * Resets the module */ reset() { this.texture = null, this.mesh = null; } /** * Returns a texture representing the depth of the user's environment. * * @return {?ExternalTexture} The depth texture. */ getDepthTexture() { return this.texture; } } class Jv extends Ui { /** * Constructs a new WebGL renderer. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGL2RenderingContext} gl - The rendering context. */ constructor(e, t) { super(); const n = this; let i = null, r = 1, a = null, o = "local-floor", l = 1, c = null, h = null, u = null, f = null, d = null, p = null; const g = typeof XRWebGLBinding < "u", x = new $v(), m = {}, v = t.getContextAttributes(); let b = null, M = null; const C = [], T = [], D = new ue(); let U = null; const S = new jt(); S.viewport = new at(); const w = new jt(); w.viewport = new at(); const B = [S, w], P = new a0(); let O = null, y = null; this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(ie) { let ce = C[ie]; return ce === void 0 && (ce = new uo(), C[ie] = ce), ce.getTargetRaySpace(); }, this.getControllerGrip = function(ie) { let ce = C[ie]; return ce === void 0 && (ce = new uo(), C[ie] = ce), ce.getGripSpace(); }, this.getHand = function(ie) { let ce = C[ie]; return ce === void 0 && (ce = new uo(), C[ie] = ce), ce.getHandSpace(); }; function H(ie) { const ce = T.indexOf(ie.inputSource); if (ce === -1) return; const fe = C[ce]; fe !== void 0 && (fe.update(ie.inputSource, ie.frame, c || a), fe.dispatchEvent({ type: ie.type, data: ie.inputSource })); } function Y() { i.removeEventListener("select", H), i.removeEventListener("selectstart", H), i.removeEventListener("selectend", H), i.removeEventListener("squeeze", H), i.removeEventListener("squeezestart", H), i.removeEventListener("squeezeend", H), i.removeEventListener("end", Y), i.removeEventListener("inputsourceschange", j); for (let ie = 0; ie < C.length; ie++) { const ce = T[ie]; ce !== null && (T[ie] = null, C[ie].disconnect(ce)); } O = null, y = null, x.reset(); for (const ie in m) delete m[ie]; e.setRenderTarget(b), d = null, f = null, u = null, i = null, M = null, de.stop(), n.isPresenting = !1, e.setPixelRatio(U), e.setSize(D.width, D.height, !1), n.dispatchEvent({ type: "sessionend" }); } this.setFramebufferScaleFactor = function(ie) { r = ie, n.isPresenting === !0 && ze("WebXRManager: Cannot change framebuffer scale while presenting."); }, this.setReferenceSpaceType = function(ie) { o = ie, n.isPresenting === !0 && ze("WebXRManager: Cannot change reference space type while presenting."); }, this.getReferenceSpace = function() { return c || a; }, this.setReferenceSpace = function(ie) { c = ie; }, this.getBaseLayer = function() { return f !== null ? f : d; }, this.getBinding = function() { return u === null && g && (u = new XRWebGLBinding(i, t)), u; }, this.getFrame = function() { return p; }, this.getSession = function() { return i; }, this.setSession = async function(ie) { if (i = ie, i !== null) { if (b = e.getRenderTarget(), i.addEventListener("select", H), i.addEventListener("selectstart", H), i.addEventListener("selectend", H), i.addEventListener("squeeze", H), i.addEventListener("squeezestart", H), i.addEventListener("squeezeend", H), i.addEventListener("end", Y), i.addEventListener("inputsourceschange", j), v.xrCompatible !== !0 && await t.makeXRCompatible(), U = e.getPixelRatio(), e.getSize(D), g && "createProjectionLayer" in XRWebGLBinding.prototype) { let fe = null, ve = null, Ee = null; v.depth && (Ee = v.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, fe = v.stencil ? xs : sr, ve = v.stencil ? gs : Ri); const Ne = { colorFormat: t.RGBA8, depthFormat: Ee, scaleFactor: r }; u = this.getBinding(), f = u.createProjectionLayer(Ne), i.updateRenderState({ layers: [f] }), e.setPixelRatio(1), e.setSize(f.textureWidth, f.textureHeight, !1), M = new rn( f.textureWidth, f.textureHeight, { format: sn, type: Ln, depthTexture: new cc(f.textureWidth, f.textureHeight, ve, void 0, void 0, void 0, void 0, void 0, void 0, fe), stencilBuffer: v.stencil, colorSpace: e.outputColorSpace, samples: v.antialias ? 4 : 0, resolveDepthBuffer: f.ignoreDepthValues === !1, resolveStencilBuffer: f.ignoreDepthValues === !1 } ); } else { const fe = { antialias: v.antialias, alpha: !0, depth: v.depth, stencil: v.stencil, framebufferScaleFactor: r }; d = new XRWebGLLayer(i, t, fe), i.updateRenderState({ baseLayer: d }), e.setPixelRatio(1), e.setSize(d.framebufferWidth, d.framebufferHeight, !1), M = new rn( d.framebufferWidth, d.framebufferHeight, { format: sn, type: Ln, colorSpace: e.outputColorSpace, stencilBuffer: v.stencil, resolveDepthBuffer: d.ignoreDepthValues === !1, resolveStencilBuffer: d.ignoreDepthValues === !1 } ); } M.isXRRenderTarget = !0, this.setFoveation(l), c = null, a = await i.requestReferenceSpace(o), de.setContext(i), de.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" }); } }, this.getEnvironmentBlendMode = function() { if (i !== null) return i.environmentBlendMode; }, this.getDepthTexture = function() { return x.getDepthTexture(); }; function j(ie) { for (let ce = 0; ce < ie.removed.length; ce++) { const fe = ie.removed[ce], ve = T.indexOf(fe); ve >= 0 && (T[ve] = null, C[ve].disconnect(fe)); } for (let ce = 0; ce < ie.added.length; ce++) { const fe = ie.added[ce]; let ve = T.indexOf(fe); if (ve === -1) { for (let Ne = 0; Ne < C.length; Ne++) if (Ne >= T.length) { T.push(fe), ve = Ne; break; } else if (T[Ne] === null) { T[Ne] = fe, ve = Ne; break; } if (ve === -1) break; } const Ee = C[ve]; Ee && Ee.connect(fe); } } const J = new R(), Z = new R(); function ae(ie, ce, fe) { J.setFromMatrixPosition(ce.matrixWorld), Z.setFromMatrixPosition(fe.matrixWorld); const ve = J.distanceTo(Z), Ee = ce.projectionMatrix.elements, Ne = fe.projectionMatrix.elements, Ye = Ee[14] / (Ee[10] - 1), ke = Ee[14] / (Ee[10] + 1), _ = (Ee[9] + 1) / Ee[5], A = (Ee[9] - 1) / Ee[5], V = (Ee[8] - 1) / Ee[0], N = (Ne[8] + 1) / Ne[0], I = Ye * V, F = Ye * N, ee = ve / (-V + N), $ = ee * -V; if (ce.matrixWorld.decompose(ie.position, ie.quaternion, ie.scale), ie.translateX($), ie.translateZ(ee), ie.matrixWorld.compose(ie.position, ie.quaternion, ie.scale), ie.matrixWorldInverse.copy(ie.matrixWorld).invert(), Ee[10] === -1) ie.projectionMatrix.copy(ce.projectionMatrix), ie.projectionMatrixInverse.copy(ce.projectionMatrixInverse); else { const G = Ye + ee, L = ke + ee, E = I - $, z = F + (ve - $), K = _ * ke / L * G, le = A * ke / L * G; ie.projectionMatrix.makePerspective(E, z, K, le, G, L), ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(); } } function X(ie, ce) { ce === null ? ie.matrixWorld.copy(ie.matrix) : ie.matrixWorld.multiplyMatrices(ce.matrixWorld, ie.matrix), ie.matrixWorldInverse.copy(ie.matrixWorld).invert(); } this.updateCamera = function(ie) { if (i === null) return; let ce = ie.near, fe = ie.far; x.texture !== null && (x.depthNear > 0 && (ce = x.depthNear), x.depthFar > 0 && (fe = x.depthFar)), P.near = w.near = S.near = ce, P.far = w.far = S.far = fe, (O !== P.near || y !== P.far) && (i.updateRenderState({ depthNear: P.near, depthFar: P.far }), O = P.near, y = P.far), P.layers.mask = ie.layers.mask | 6, S.layers.mask = P.layers.mask & 3, w.layers.mask = P.layers.mask & 5; const ve = ie.parent, Ee = P.cameras; X(P, ve); for (let Ne = 0; Ne < Ee.length; Ne++) X(Ee[Ne], ve); Ee.length === 2 ? ae(P, S, w) : P.projectionMatrix.copy(S.projectionMatrix), q(ie, P, ve); }; function q(ie, ce, fe) { fe === null ? ie.matrix.copy(ce.matrixWorld) : (ie.matrix.copy(fe.matrixWorld), ie.matrix.invert(), ie.matrix.multiply(ce.matrixWorld)), ie.matrix.decompose(ie.position, ie.quaternion, ie.scale), ie.updateMatrixWorld(!0), ie.projectionMatrix.copy(ce.projectionMatrix), ie.projectionMatrixInverse.copy(ce.projectionMatrixInverse), ie.isPerspectiveCamera && (ie.fov = vs * 2 * Math.atan(1 / ie.projectionMatrix.elements[5]), ie.zoom = 1); } this.getCamera = function() { return P; }, this.getFoveation = function() { if (!(f === null && d === null)) return l; }, this.setFoveation = function(ie) { l = ie, f !== null && (f.fixedFoveation = ie), d !== null && d.fixedFoveation !== void 0 && (d.fixedFoveation = ie); }, this.hasDepthSensing = function() { return x.texture !== null; }, this.getDepthSensingMesh = function() { return x.getMesh(P); }, this.getCameraTexture = function(ie) { return m[ie]; }; let ge = null; function pe(ie, ce) { if (h = ce.getViewerPose(c || a), p = ce, h !== null) { const fe = h.views; d !== null && (e.setRenderTargetFramebuffer(M, d.framebuffer), e.setRenderTarget(M)); let ve = !1; fe.length !== P.cameras.length && (P.cameras.length = 0, ve = !0); for (let ke = 0; ke < fe.length; ke++) { const _ = fe[ke]; let A = null; if (d !== null) A = d.getViewport(_); else { const N = u.getViewSubImage(f, _); A = N.viewport, ke === 0 && (e.setRenderTargetTextures( M, N.colorTexture, N.depthStencilTexture ), e.setRenderTarget(M)); } let V = B[ke]; V === void 0 && (V = new jt(), V.layers.enable(ke), V.viewport = new at(), B[ke] = V), V.matrix.fromArray(_.transform.matrix), V.matrix.decompose(V.position, V.quaternion, V.scale), V.projectionMatrix.fromArray(_.projectionMatrix), V.projectionMatrixInverse.copy(V.projectionMatrix).invert(), V.viewport.set(A.x, A.y, A.width, A.height), ke === 0 && (P.matrix.copy(V.matrix), P.matrix.decompose(P.position, P.quaternion, P.scale)), ve === !0 && P.cameras.push(V); } const Ee = i.enabledFeatures; if (Ee && Ee.includes("depth-sensing") && i.depthUsage == "gpu-optimized" && g) { u = n.getBinding(); const ke = u.getDepthInformation(fe[0]); ke && ke.isValid && ke.texture && x.init(ke, i.renderState); } if (Ee && Ee.includes("camera-access") && g) { e.state.unbindTexture(), u = n.getBinding(); for (let ke = 0; ke < fe.length; ke++) { const _ = fe[ke].camera; if (_) { let A = m[_]; A || (A = new ud(), m[_] = A); const V = u.getCameraImage(_); A.sourceTexture = V; } } } } for (let fe = 0; fe < C.length; fe++) { const ve = T[fe], Ee = C[fe]; ve !== null && Ee !== void 0 && Ee.update(ve, ce, c || a); } ge && ge(ie, ce), ce.detectedPlanes && n.dispatchEvent({ type: "planesdetected", data: ce }), p = null; } const de = new Ed(); de.setAnimationLoop(pe), this.setAnimationLoop = function(ie) { ge = ie; }, this.dispose = function() { }; } } const wi = /* @__PURE__ */ new cn(), Qv = /* @__PURE__ */ new je(); function eb(s, e) { function t(x, m) { x.matrixAutoUpdate === !0 && x.updateMatrix(), m.value.copy(x.matrix); } function n(x, m) { m.color.getRGB(x.fogColor.value, id(s)), m.isFog ? (x.fogNear.value = m.near, x.fogFar.value = m.far) : m.isFogExp2 && (x.fogDensity.value = m.density); } function i(x, m, v, b, M) { m.isMeshBasicMaterial || m.isMeshLambertMaterial ? r(x, m) : m.isMeshToonMaterial ? (r(x, m), u(x, m)) : m.isMeshPhongMaterial ? (r(x, m), h(x, m)) : m.isMeshStandardMaterial ? (r(x, m), f(x, m), m.isMeshPhysicalMaterial && d(x, m, M)) : m.isMeshMatcapMaterial ? (r(x, m), p(x, m)) : m.isMeshDepthMaterial ? r(x, m) : m.isMeshDistanceMaterial ? (r(x, m), g(x, m)) : m.isMeshNormalMaterial ? r(x, m) : m.isLineBasicMaterial ? (a(x, m), m.isLineDashedMaterial && o(x, m)) : m.isPointsMaterial ? l(x, m, v, b) : m.isSpriteMaterial ? c(x, m) : m.isShadowMaterial ? (x.color.value.copy(m.color), x.opacity.value = m.opacity) : m.isShaderMaterial && (m.uniformsNeedUpdate = !1); } function r(x, m) { x.opacity.value = m.opacity, m.color && x.diffuse.value.copy(m.color), m.emissive && x.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity), m.map && (x.map.value = m.map, t(m.map, x.mapTransform)), m.alphaMap && (x.alphaMap.value = m.alphaMap, t(m.alphaMap, x.alphaMapTransform)), m.bumpMap && (x.bumpMap.value = m.bumpMap, t(m.bumpMap, x.bumpMapTransform), x.bumpScale.value = m.bumpScale, m.side === Jt && (x.bumpScale.value *= -1)), m.normalMap && (x.normalMap.value = m.normalMap, t(m.normalMap, x.normalMapTransform), x.normalScale.value.copy(m.normalScale), m.side === Jt && x.normalScale.value.negate()), m.displacementMap && (x.displacementMap.value = m.displacementMap, t(m.displacementMap, x.displacementMapTransform), x.displacementScale.value = m.displacementScale, x.displacementBias.value = m.displacementBias), m.emissiveMap && (x.emissiveMap.value = m.emissiveMap, t(m.emissiveMap, x.emissiveMapTransform)), m.specularMap && (x.specularMap.value = m.specularMap, t(m.specularMap, x.specularMapTransform)), m.alphaTest > 0 && (x.alphaTest.value = m.alphaTest); const v = e.get(m), b = v.envMap, M = v.envMapRotation; b && (x.envMap.value = b, wi.copy(M), wi.x *= -1, wi.y *= -1, wi.z *= -1, b.isCubeTexture && b.isRenderTargetTexture === !1 && (wi.y *= -1, wi.z *= -1), x.envMapRotation.value.setFromMatrix4(Qv.makeRotationFromEuler(wi)), x.flipEnvMap.value = b.isCubeTexture && b.isRenderTargetTexture === !1 ? -1 : 1, x.reflectivity.value = m.reflectivity, x.ior.value = m.ior, x.refractionRatio.value = m.refractionRatio), m.lightMap && (x.lightMap.value = m.lightMap, x.lightMapIntensity.value = m.lightMapIntensity, t(m.lightMap, x.lightMapTransform)), m.aoMap && (x.aoMap.value = m.aoMap, x.aoMapIntensity.value = m.aoMapIntensity, t(m.aoMap, x.aoMapTransform)); } function a(x, m) { x.diffuse.value.copy(m.color), x.opacity.value = m.opacity, m.map && (x.map.value = m.map, t(m.map, x.mapTransform)); } function o(x, m) { x.dashSize.value = m.dashSize, x.totalSize.value = m.dashSize + m.gapSize, x.scale.value = m.scale; } function l(x, m, v, b) { x.diffuse.value.copy(m.color), x.opacity.value = m.opacity, x.size.value = m.size * v, x.scale.value = b * 0.5, m.map && (x.map.value = m.map, t(m.map, x.uvTransform)), m.alphaMap && (x.alphaMap.value = m.alphaMap, t(m.alphaMap, x.alphaMapTransform)), m.alphaTest > 0 && (x.alphaTest.value = m.alphaTest); } function c(x, m) { x.diffuse.value.copy(m.color), x.opacity.value = m.opacity, x.rotation.value = m.rotation, m.map && (x.map.value = m.map, t(m.map, x.mapTransform)), m.alphaMap && (x.alphaMap.value = m.alphaMap, t(m.alphaMap, x.alphaMapTransform)), m.alphaTest > 0 && (x.alphaTest.value = m.alphaTest); } function h(x, m) { x.specular.value.copy(m.specular), x.shininess.value = Math.max(m.shininess, 1e-4); } function u(x, m) { m.gradientMap && (x.gradientMap.value = m.gradientMap); } function f(x, m) { x.metalness.value = m.metalness, m.metalnessMap && (x.metalnessMap.value = m.metalnessMap, t(m.metalnessMap, x.metalnessMapTransform)), x.roughness.value = m.roughness, m.roughnessMap && (x.roughnessMap.value = m.roughnessMap, t(m.roughnessMap, x.roughnessMapTransform)), m.envMap && (x.envMapIntensity.value = m.envMapIntensity); } function d(x, m, v) { x.ior.value = m.ior, m.sheen > 0 && (x.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen), x.sheenRoughness.value = m.sheenRoughness, m.sheenColorMap && (x.sheenColorMap.value = m.sheenColorMap, t(m.sheenColorMap, x.sheenColorMapTransform)), m.sheenRoughnessMap && (x.sheenRoughnessMap.value = m.sheenRoughnessMap, t(m.sheenRoughnessMap, x.sheenRoughnessMapTransform))), m.clearcoat > 0 && (x.clearcoat.value = m.clearcoat, x.clearcoatRoughness.value = m.clearcoatRoughness, m.clearcoatMap && (x.clearcoatMap.value = m.clearcoatMap, t(m.clearcoatMap, x.clearcoatMapTransform)), m.clearcoatRoughnessMap && (x.clearcoatRoughnessMap.value = m.clearcoatRoughnessMap, t(m.clearcoatRoughnessMap, x.clearcoatRoughnessMapTransform)), m.clearcoatNormalMap && (x.clearcoatNormalMap.value = m.clearcoatNormalMap, t(m.clearcoatNormalMap, x.clearcoatNormalMapTransform), x.clearcoatNormalScale.value.copy(m.clearcoatNormalScale), m.side === Jt && x.clearcoatNormalScale.value.negate())), m.dispersion > 0 && (x.dispersion.value = m.dispersion), m.iridescence > 0 && (x.iridescence.value = m.iridescence, x.iridescenceIOR.value = m.iridescenceIOR, x.iridescenceThicknessMinimum.value = m.iridescenceThicknessRange[0], x.iridescenceThicknessMaximum.value = m.iridescenceThicknessRange[1], m.iridescenceMap && (x.iridescenceMap.value = m.iridescenceMap, t(m.iridescenceMap, x.iridescenceMapTransform)), m.iridescenceThicknessMap && (x.iridescenceThicknessMap.value = m.iridescenceThicknessMap, t(m.iridescenceThicknessMap, x.iridescenceThicknessMapTransform))), m.transmission > 0 && (x.transmission.value = m.transmission, x.transmissionSamplerMap.value = v.texture, x.transmissionSamplerSize.value.set(v.width, v.height), m.transmissionMap && (x.transmissionMap.value = m.transmissionMap, t(m.transmissionMap, x.transmissionMapTransform)), x.thickness.value = m.thickness, m.thicknessMap && (x.thicknessMap.value = m.thicknessMap, t(m.thicknessMap, x.thicknessMapTransform)), x.attenuationDistance.value = m.attenuationDistance, x.attenuationColor.value.copy(m.attenuationColor)), m.anisotropy > 0 && (x.anisotropyVector.value.set(m.anisotropy * Math.cos(m.anisotropyRotation), m.anisotropy * Math.sin(m.anisotropyRotation)), m.anisotropyMap && (x.anisotropyMap.value = m.anisotropyMap, t(m.anisotropyMap, x.anisotropyMapTransform))), x.specularIntensity.value = m.specularIntensity, x.specularColor.value.copy(m.specularColor), m.specularColorMap && (x.specularColorMap.value = m.specularColorMap, t(m.specularColorMap, x.specularColorMapTransform)), m.specularIntensityMap && (x.specularIntensityMap.value = m.specularIntensityMap, t(m.specularIntensityMap, x.specularIntensityMapTransform)); } function p(x, m) { m.matcap && (x.matcap.value = m.matcap); } function g(x, m) { const v = e.get(m).light; x.referencePosition.value.setFromMatrixPosition(v.matrixWorld), x.nearDistance.value = v.shadow.camera.near, x.farDistance.value = v.shadow.camera.far; } return { refreshFogUniforms: n, refreshMaterialUniforms: i }; } function tb(s, e, t, n) { let i = {}, r = {}, a = []; const o = s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS); function l(v, b) { const M = b.program; n.uniformBlockBinding(v, M); } function c(v, b) { let M = i[v.id]; M === void 0 && (p(v), M = h(v), i[v.id] = M, v.addEventListener("dispose", x)); const C = b.program; n.updateUBOMapping(v, C); const T = e.render.frame; r[v.id] !== T && (f(v), r[v.id] = T); } function h(v) { const b = u(); v.__bindingPointIndex = b; const M = s.createBuffer(), C = v.__size, T = v.usage; return s.bindBuffer(s.UNIFORM_BUFFER, M), s.bufferData(s.UNIFORM_BUFFER, C, T), s.bindBuffer(s.UNIFORM_BUFFER, null), s.bindBufferBase(s.UNIFORM_BUFFER, b, M), M; } function u() { for (let v = 0; v < o; v++) if (a.indexOf(v) === -1) return a.push(v), v; return et("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0; } function f(v) { const b = i[v.id], M = v.uniforms, C = v.__cache; s.bindBuffer(s.UNIFORM_BUFFER, b); for (let T = 0, D = M.length; T < D; T++) { const U = Array.isArray(M[T]) ? M[T] : [M[T]]; for (let S = 0, w = U.length; S < w; S++) { const B = U[S]; if (d(B, T, S, C) === !0) { const P = B.__offset, O = Array.isArray(B.value) ? B.value : [B.value]; let y = 0; for (let H = 0; H < O.length; H++) { const Y = O[H], j = g(Y); typeof Y == "number" || typeof Y == "boolean" ? (B.__data[0] = Y, s.bufferSubData(s.UNIFORM_BUFFER, P + y, B.__data)) : Y.isMatrix3 ? (B.__data[0] = Y.elements[0], B.__data[1] = Y.elements[1], B.__data[2] = Y.elements[2], B.__data[3] = 0, B.__data[4] = Y.elements[3], B.__data[5] = Y.elements[4], B.__data[6] = Y.elements[5], B.__data[7] = 0, B.__data[8] = Y.elements[6], B.__data[9] = Y.elements[7], B.__data[10] = Y.elements[8], B.__data[11] = 0) : (Y.toArray(B.__data, y), y += j.storage / Float32Array.BYTES_PER_ELEMENT); } s.bufferSubData(s.UNIFORM_BUFFER, P, B.__data); } } } s.bindBuffer(s.UNIFORM_BUFFER, null); } function d(v, b, M, C) { const T = v.value, D = b + "_" + M; if (C[D] === void 0) return typeof T == "number" || typeof T == "boolean" ? C[D] = T : C[D] = T.clone(), !0; { const U = C[D]; if (typeof T == "number" || typeof T == "boolean") { if (U !== T) return C[D] = T, !0; } else if (U.equals(T) === !1) return U.copy(T), !0; } return !1; } function p(v) { const b = v.uniforms; let M = 0; const C = 16; for (let D = 0, U = b.length; D < U; D++) { const S = Array.isArray(b[D]) ? b[D] : [b[D]]; for (let w = 0, B = S.length; w < B; w++) { const P = S[w], O = Array.isArray(P.value) ? P.value : [P.value]; for (let y = 0, H = O.length; y < H; y++) { const Y = O[y], j = g(Y), J = M % C, Z = J % j.boundary, ae = J + Z; M += Z, ae !== 0 && C - ae < j.storage && (M += C - ae), P.__data = new Float32Array(j.storage / Float32Array.BYTES_PER_ELEMENT), P.__offset = M, M += j.storage; } } } const T = M % C; return T > 0 && (M += C - T), v.__size = M, v.__cache = {}, this; } function g(v) { const b = { boundary: 0, // bytes storage: 0 // bytes }; return typeof v == "number" || typeof v == "boolean" ? (b.boundary = 4, b.storage = 4) : v.isVector2 ? (b.boundary = 8, b.storage = 8) : v.isVector3 || v.isColor ? (b.boundary = 16, b.storage = 12) : v.isVector4 ? (b.boundary = 16, b.storage = 16) : v.isMatrix3 ? (b.boundary = 48, b.storage = 48) : v.isMatrix4 ? (b.boundary = 64, b.storage = 64) : v.isTexture ? ze("WebGLRenderer: Texture samplers can not be part of an uniforms group.") : ze("WebGLRenderer: Unsupported uniform value type.", v), b; } function x(v) { const b = v.target; b.removeEventListener("dispose", x); const M = a.indexOf(b.__bindingPointIndex); a.splice(M, 1), s.deleteBuffer(i[b.id]), delete i[b.id], delete r[b.id]; } function m() { for (const v in i) s.deleteBuffer(i[v]); a = [], i = {}, r = {}; } return { bind: l, update: c, dispose: m }; } const nb = 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 Qn = null; function ib() { return Qn === null && (Qn = new pr(nb, 32, 32, ec, _n), Qn.minFilter = Ht, Qn.magFilter = Ht, Qn.wrapS = Hn, Qn.wrapT = Hn, Qn.generateMipmaps = !1, Qn.needsUpdate = !0), Qn; } class Rd { /** * Constructs a new WebGL renderer. * * @param {WebGLRenderer~Options} [parameters] - The configuration parameter. */ constructor(e = {}) { const { canvas: t = op(), context: n = null, depth: i = !0, stencil: r = !1, alpha: a = !1, antialias: o = !1, premultipliedAlpha: l = !0, preserveDrawingBuffer: c = !1, powerPreference: h = "default", failIfMajorPerformanceCaveat: u = !1, reversedDepthBuffer: f = !1 } = e; this.isWebGLRenderer = !0; let d; if (n !== null) { if (typeof WebGLRenderingContext < "u" && n instanceof WebGLRenderingContext) throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163."); d = n.getContextAttributes().alpha; } else d = a; const p = /* @__PURE__ */ new Set([ nc, tc, Ql ]), g = /* @__PURE__ */ new Set([ Ln, Ri, ir, gs, Kl, $l ]), x = new Uint32Array(4), m = new Int32Array(4); let v = null, b = null; const M = [], C = []; this.domElement = t, this.debug = { /** * Enables error checking and reporting when shader programs are being compiled. * @type {boolean} */ checkShaderErrors: !0, /** * Callback for custom error reporting. * @type {?Function} */ onShaderError: null }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this.toneMapping = gi, this.toneMappingExposure = 1, this.transmissionResolutionScale = 1; const T = this; let D = !1; this._outputColorSpace = mt; let U = 0, S = 0, w = null, B = -1, P = null; const O = new at(), y = new at(); let H = null; const Y = new Fe(0); let j = 0, J = t.width, Z = t.height, ae = 1, X = null, q = null; const ge = new at(0, 0, J, Z), pe = new at(0, 0, J, Z); let de = !1; const ie = new lc(); let ce = !1, fe = !1; const ve = new je(), Ee = new R(), Ne = new at(), Ye = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 }; let ke = !1; function _() { return w === null ? ae : 1; } let A = n; function V(k, Q) { return t.getContext(k, Q); } try { const k = { alpha: !0, depth: i, stencil: r, antialias: o, premultipliedAlpha: l, preserveDrawingBuffer: c, powerPreference: h, failIfMajorPerformanceCaveat: u }; if ("setAttribute" in t && t.setAttribute("data-engine", `three.js r${Zl}`), t.addEventListener("webglcontextlost", xe, !1), t.addEventListener("webglcontextrestored", me, !1), t.addEventListener("webglcontextcreationerror", Be, !1), A === null) { const Q = "webgl2"; if (A = V(Q, k), A === null) throw V(Q) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context."); } } catch (k) { throw k("WebGLRenderer: " + k.message), k; } let N, I, F, ee, $, G, L, E, z, K, le, te, Te, be, Re, De, he, _e, He, Ue, Ce, Ve, W, we; function ye() { N = new d1(A), N.init(), Ve = new qv(A, N), I = new i1(A, N, e, Ve), F = new jv(A, N), I.reversedDepthBuffer && f && F.buffers.depth.setReversed(!0), ee = new m1(A), $ = new Iv(), G = new Zv(A, N, F, $, I, Ve, ee), L = new r1(T), E = new u1(T), z = new b0(A), W = new t1(A, z), K = new f1(A, z, ee, W), le = new x1(A, K, z, ee), He = new g1(A, I, G), De = new s1($), te = new Dv(T, L, E, N, I, W, De), Te = new eb(T, $), be = new kv(), Re = new Hv(N), _e = new e1(T, L, E, F, le, d, l), he = new Wv(T, le, I), we = new tb(A, ee, I, F), Ue = new n1(A, N, ee), Ce = new p1(A, N, ee), ee.programs = te.programs, T.capabilities = I, T.extensions = N, T.properties = $, T.renderLists = be, T.shadowMap = he, T.state = F, T.info = ee; } ye(); const Me = new Jv(T, A); this.xr = Me, this.getContext = function() { return A; }, this.getContextAttributes = function() { return A.getContextAttributes(); }, this.forceContextLoss = function() { const k = N.get("WEBGL_lose_context"); k && k.loseContext(); }, this.forceContextRestore = function() { const k = N.get("WEBGL_lose_context"); k && k.restoreContext(); }, this.getPixelRatio = function() { return ae; }, this.setPixelRatio = function(k) { k !== void 0 && (ae = k, this.setSize(J, Z, !1)); }, this.getSize = function(k) { return k.set(J, Z); }, this.setSize = function(k, Q, re = !0) { if (Me.isPresenting) { ze("WebGLRenderer: Can't change size while VR device is presenting."); return; } J = k, Z = Q, t.width = Math.floor(k * ae), t.height = Math.floor(Q * ae), re === !0 && (t.style.width = k + "px", t.style.height = Q + "px"), this.setViewport(0, 0, k, Q); }, this.getDrawingBufferSize = function(k) { return k.set(J * ae, Z * ae).floor(); }, this.setDrawingBufferSize = function(k, Q, re) { J = k, Z = Q, ae = re, t.width = Math.floor(k * re), t.height = Math.floor(Q * re), this.setViewport(0, 0, k, Q); }, this.getCurrentViewport = function(k) { return k.copy(O); }, this.getViewport = function(k) { return k.copy(ge); }, this.setViewport = function(k, Q, re, oe) { k.isVector4 ? ge.set(k.x, k.y, k.z, k.w) : ge.set(k, Q, re, oe), F.viewport(O.copy(ge).multiplyScalar(ae).round()); }, this.getScissor = function(k) { return k.copy(pe); }, this.setScissor = function(k, Q, re, oe) { k.isVector4 ? pe.set(k.x, k.y, k.z, k.w) : pe.set(k, Q, re, oe), F.scissor(y.copy(pe).multiplyScalar(ae).round()); }, this.getScissorTest = function() { return de; }, this.setScissorTest = function(k) { F.setScissorTest(de = k); }, this.setOpaqueSort = function(k) { X = k; }, this.setTransparentSort = function(k) { q = k; }, this.getClearColor = function(k) { return k.copy(_e.getClearColor()); }, this.setClearColor = function() { _e.setClearColor(...arguments); }, this.getClearAlpha = function() { return _e.getClearAlpha(); }, this.setClearAlpha = function() { _e.setClearAlpha(...arguments); }, this.clear = function(k = !0, Q = !0, re = !0) { let oe = 0; if (k) { let ne = !1; if (w !== null) { const Se = w.texture.format; ne = p.has(Se); } if (ne) { const Se = w.texture.type, Le = g.has(Se), Oe = _e.getClearColor(), Ie = _e.getClearAlpha(), Xe = Oe.r, Ze = Oe.g, Ge = Oe.b; Le ? (x[0] = Xe, x[1] = Ze, x[2] = Ge, x[3] = Ie, A.clearBufferuiv(A.COLOR, 0, x)) : (m[0] = Xe, m[1] = Ze, m[2] = Ge, m[3] = Ie, A.clearBufferiv(A.COLOR, 0, m)); } else oe |= A.COLOR_BUFFER_BIT; } Q && (oe |= A.DEPTH_BUFFER_BIT), re && (oe |= A.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), A.clear(oe); }, this.clearColor = function() { this.clear(!0, !1, !1); }, this.clearDepth = function() { this.clear(!1, !0, !1); }, this.clearStencil = function() { this.clear(!1, !1, !0); }, this.dispose = function() { t.removeEventListener("webglcontextlost", xe, !1), t.removeEventListener("webglcontextrestored", me, !1), t.removeEventListener("webglcontextcreationerror", Be, !1), _e.dispose(), be.dispose(), Re.dispose(), $.dispose(), L.dispose(), E.dispose(), le.dispose(), W.dispose(), we.dispose(), te.dispose(), Me.dispose(), Me.removeEventListener("sessionstart", Mc), Me.removeEventListener("sessionend", Sc), xi.stop(); }; function xe(k) { k.preventDefault(), ya("WebGLRenderer: Context Lost."), D = !0; } function me() { ya("WebGLRenderer: Context Restored."), D = !1; const k = ee.autoReset, Q = he.enabled, re = he.autoUpdate, oe = he.needsUpdate, ne = he.type; ye(), ee.autoReset = k, he.enabled = Q, he.autoUpdate = re, he.needsUpdate = oe, he.type = ne; } function Be(k) { et("WebGLRenderer: A WebGL context could not be created. Reason: ", k.statusMessage); } function qe(k) { const Q = k.target; Q.removeEventListener("dispose", qe), vt(Q); } function vt(k) { ht(k), $.remove(k); } function ht(k) { const Q = $.get(k).programs; Q !== void 0 && (Q.forEach(function(re) { te.releaseProgram(re); }), k.isShaderMaterial && te.releaseShaderCache(k)); } this.renderBufferDirect = function(k, Q, re, oe, ne, Se) { Q === null && (Q = Ye); const Le = ne.isMesh && ne.matrixWorld.determinant() < 0, Oe = ff(k, Q, re, oe, ne); F.setMaterial(oe, Le); let Ie = re.index, Xe = 1; if (oe.wireframe === !0) { if (Ie = K.getWireframeAttribute(re), Ie === void 0) return; Xe = 2; } const Ze = re.drawRange, Ge = re.attributes.position; let nt = Ze.start * Xe, ut = (Ze.start + Ze.count) * Xe; Se !== null && (nt = Math.max(nt, Se.start * Xe), ut = Math.min(ut, (Se.start + Se.count) * Xe)), Ie !== null ? (nt = Math.max(nt, 0), ut = Math.min(ut, Ie.count)) : Ge != null && (nt = Math.max(nt, 0), ut = Math.min(ut, Ge.count)); const St = ut - nt; if (St < 0 || St === 1 / 0) return; W.setup(ne, oe, Oe, re, Ie); let wt, pt = Ue; if (Ie !== null && (wt = z.get(Ie), pt = Ce, pt.setIndex(wt)), ne.isMesh) oe.wireframe === !0 ? (F.setLineWidth(oe.wireframeLinewidth * _()), pt.setMode(A.LINES)) : pt.setMode(A.TRIANGLES); else if (ne.isLine) { let We = oe.linewidth; We === void 0 && (We = 1), F.setLineWidth(We * _()), ne.isLineSegments ? pt.setMode(A.LINES) : ne.isLineLoop ? pt.setMode(A.LINE_LOOP) : pt.setMode(A.LINE_STRIP); } else ne.isPoints ? pt.setMode(A.POINTS) : ne.isSprite && pt.setMode(A.TRIANGLES); if (ne.isBatchedMesh) if (ne._multiDrawInstances !== null) lr("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."), pt.renderMultiDrawInstances(ne._multiDrawStarts, ne._multiDrawCounts, ne._multiDrawCount, ne._multiDrawInstances); else if (N.get("WEBGL_multi_draw")) pt.renderMultiDraw(ne._multiDrawStarts, ne._multiDrawCounts, ne._multiDrawCount); else { const We = ne._multiDrawStarts, bt = ne._multiDrawCounts, rt = ne._multiDrawCount, un = Ie ? z.get(Ie).bytesPerElement : 1, Vi = $.get(oe).currentProgram.getUniforms(); for (let dn = 0; dn < rt; dn++) Vi.setValue(A, "_gl_DrawID", dn), pt.render(We[dn] / un, bt[dn]); } else if (ne.isInstancedMesh) pt.renderInstances(nt, St, ne.count); else if (re.isInstancedBufferGeometry) { const We = re._maxInstanceCount !== void 0 ? re._maxInstanceCount : 1 / 0, bt = Math.min(re.instanceCount, We); pt.renderInstances(nt, St, bt); } else pt.render(nt, St); }; function Un(k, Q, re) { k.transparent === !0 && k.side === Dt && k.forceSinglePass === !1 ? (k.side = Jt, k.needsUpdate = !0, yr(k, Q, re), k.side = Rn, k.needsUpdate = !0, yr(k, Q, re), k.side = Dt) : yr(k, Q, re); } this.compile = function(k, Q, re = null) { re === null && (re = k), b = Re.get(re), b.init(Q), C.push(b), re.traverseVisible(function(ne) { ne.isLight && ne.layers.test(Q.layers) && (b.pushLight(ne), ne.castShadow && b.pushShadow(ne)); }), k !== re && k.traverseVisible(function(ne) { ne.isLight && ne.layers.test(Q.layers) && (b.pushLight(ne), ne.castShadow && b.pushShadow(ne)); }), b.setupLights(); const oe = /* @__PURE__ */ new Set(); return k.traverse(function(ne) { if (!(ne.isMesh || ne.isPoints || ne.isLine || ne.isSprite)) return; const Se = ne.material; if (Se) if (Array.isArray(Se)) for (let Le = 0; Le < Se.length; Le++) { const Oe = Se[Le]; Un(Oe, re, ne), oe.add(Oe); } else Un(Se, re, ne), oe.add(Se); }), b = C.pop(), oe; }, this.compileAsync = function(k, Q, re = null) { const oe = this.compile(k, Q, re); return new Promise((ne) => { function Se() { if (oe.forEach(function(Le) { $.get(Le).currentProgram.isReady() && oe.delete(Le); }), oe.size === 0) { ne(k); return; } setTimeout(Se, 10); } N.get("KHR_parallel_shader_compile") !== null ? Se() : setTimeout(Se, 10); }); }; let Mn = null; function df(k) { Mn && Mn(k); } function Mc() { xi.stop(); } function Sc() { xi.start(); } const xi = new Ed(); xi.setAnimationLoop(df), typeof self < "u" && xi.setContext(self), this.setAnimationLoop = function(k) { Mn = k, Me.setAnimationLoop(k), k === null ? xi.stop() : xi.start(); }, Me.addEventListener("sessionstart", Mc), Me.addEventListener("sessionend", Sc), this.render = function(k, Q) { if (Q !== void 0 && Q.isCamera !== !0) { et("WebGLRenderer.render: camera is not an instance of THREE.Camera."); return; } if (D === !0) return; if (k.matrixWorldAutoUpdate === !0 && k.updateMatrixWorld(), Q.parent === null && Q.matrixWorldAutoUpdate === !0 && Q.updateMatrixWorld(), Me.enabled === !0 && Me.isPresenting === !0 && (Me.cameraAutoUpdate === !0 && Me.updateCamera(Q), Q = Me.getCamera()), k.isScene === !0 && k.onBeforeRender(T, k, Q, w), b = Re.get(k, C.length), b.init(Q), C.push(b), ve.multiplyMatrices(Q.projectionMatrix, Q.matrixWorldInverse), ie.setFromProjectionMatrix(ve, Vn, Q.reversedDepth), fe = this.localClippingEnabled, ce = De.init(this.clippingPlanes, fe), v = be.get(k, M.length), v.init(), M.push(v), Me.enabled === !0 && Me.isPresenting === !0) { const Se = T.xr.getDepthSensingMesh(); Se !== null && Fa(Se, Q, -1 / 0, T.sortObjects); } Fa(k, Q, 0, T.sortObjects), v.finish(), T.sortObjects === !0 && v.sort(X, q), ke = Me.enabled === !1 || Me.isPresenting === !1 || Me.hasDepthSensing() === !1, ke && _e.addToRenderList(v, k), this.info.render.frame++, ce === !0 && De.beginShadows(); const re = b.state.shadowsArray; he.render(re, k, Q), ce === !0 && De.endShadows(), this.info.autoReset === !0 && this.info.reset(); const oe = v.opaque, ne = v.transmissive; if (b.setupLights(), Q.isArrayCamera) { const Se = Q.cameras; if (ne.length > 0) for (let Le = 0, Oe = Se.length; Le < Oe; Le++) { const Ie = Se[Le]; Ec(oe, ne, k, Ie); } ke && _e.render(k); for (let Le = 0, Oe = Se.length; Le < Oe; Le++) { const Ie = Se[Le]; wc(v, k, Ie, Ie.viewport); } } else ne.length > 0 && Ec(oe, ne, k, Q), ke && _e.render(k), wc(v, k, Q); w !== null && S === 0 && (G.updateMultisampleRenderTarget(w), G.updateRenderTargetMipmap(w)), k.isScene === !0 && k.onAfterRender(T, k, Q), W.resetDefaultState(), B = -1, P = null, C.pop(), C.length > 0 ? (b = C[C.length - 1], ce === !0 && De.setGlobalState(T.clippingPlanes, b.state.camera)) : b = null, M.pop(), M.length > 0 ? v = M[M.length - 1] : v = null; }; function Fa(k, Q, re, oe) { if (k.visible === !1) return; if (k.layers.test(Q.layers)) { if (k.isGroup) re = k.renderOrder; else if (k.isLOD) k.autoUpdate === !0 && k.update(Q); else if (k.isLight) b.pushLight(k), k.castShadow && b.pushShadow(k); else if (k.isSprite) { if (!k.frustumCulled || ie.intersectsSprite(k)) { oe && Ne.setFromMatrixPosition(k.matrixWorld).applyMatrix4(ve); const Le = le.update(k), Oe = k.material; Oe.visible && v.push(k, Le, Oe, re, Ne.z, null); } } else if ((k.isMesh || k.isLine || k.isPoints) && (!k.frustumCulled || ie.intersectsObject(k))) { const Le = le.update(k), Oe = k.material; if (oe && (k.boundingSphere !== void 0 ? (k.boundingSphere === null && k.computeBoundingSphere(), Ne.copy(k.boundingSphere.center)) : (Le.boundingSphere === null && Le.computeBoundingSphere(), Ne.copy(Le.boundingSphere.center)), Ne.applyMatrix4(k.matrixWorld).applyMatrix4(ve)), Array.isArray(Oe)) { const Ie = Le.groups; for (let Xe = 0, Ze = Ie.length; Xe < Ze; Xe++) { const Ge = Ie[Xe], nt = Oe[Ge.materialIndex]; nt && nt.visible && v.push(k, Le, nt, re, Ne.z, Ge); } } else Oe.visible && v.push(k, Le, Oe, re, Ne.z, null); } } const Se = k.children; for (let Le = 0, Oe = Se.length; Le < Oe; Le++) Fa(Se[Le], Q, re, oe); } function wc(k, Q, re, oe) { const { opaque: ne, transmissive: Se, transparent: Le } = k; b.setupLightsView(re), ce === !0 && De.setGlobalState(T.clippingPlanes, re), oe && F.viewport(O.copy(oe)), ne.length > 0 && _r(ne, Q, re), Se.length > 0 && _r(Se, Q, re), Le.length > 0 && _r(Le, Q, re), F.buffers.depth.setTest(!0), F.buffers.depth.setMask(!0), F.buffers.color.setMask(!0), F.setPolygonOffset(!1); } function Ec(k, Q, re, oe) { if ((re.isScene === !0 ? re.overrideMaterial : null) !== null) return; b.state.transmissionRenderTarget[oe.id] === void 0 && (b.state.transmissionRenderTarget[oe.id] = new rn(1, 1, { generateMipmaps: !0, type: N.has("EXT_color_buffer_half_float") || N.has("EXT_color_buffer_float") ? _n : Ln, minFilter: ti, samples: 4, stencilBuffer: r, resolveDepthBuffer: !1, resolveStencilBuffer: !1, colorSpace: it.workingColorSpace })); const Se = b.state.transmissionRenderTarget[oe.id], Le = oe.viewport || O; Se.setSize(Le.z * T.transmissionResolutionScale, Le.w * T.transmissionResolutionScale); const Oe = T.getRenderTarget(), Ie = T.getActiveCubeFace(), Xe = T.getActiveMipmapLevel(); T.setRenderTarget(Se), T.getClearColor(Y), j = T.getClearAlpha(), j < 1 && T.setClearColor(16777215, 0.5), T.clear(), ke && _e.render(re); const Ze = T.toneMapping; T.toneMapping = gi; const Ge = oe.viewport; if (oe.viewport !== void 0 && (oe.viewport = void 0), b.setupLightsView(oe), ce === !0 && De.setGlobalState(T.clippingPlanes, oe), _r(k, re, oe), G.updateMultisampleRenderTarget(Se), G.updateRenderTargetMipmap(Se), N.has("WEBGL_multisampled_render_to_texture") === !1) { let nt = !1; for (let ut = 0, St = Q.length; ut < St; ut++) { const wt = Q[ut], { object: pt, geometry: We, material: bt, group: rt } = wt; if (bt.side === Dt && pt.layers.test(oe.layers)) { const un = bt.side; bt.side = Jt, bt.needsUpdate = !0, Tc(pt, re, oe, We, bt, rt), bt.side = un, bt.needsUpdate = !0, nt = !0; } } nt === !0 && (G.updateMultisampleRenderTarget(Se), G.updateRenderTargetMipmap(Se)); } T.setRenderTarget(Oe, Ie, Xe), T.setClearColor(Y, j), Ge !== void 0 && (oe.viewport = Ge), T.toneMapping = Ze; } function _r(k, Q, re) { const oe = Q.isScene === !0 ? Q.overrideMaterial : null; for (let ne = 0, Se = k.length; ne < Se; ne++) { const Le = k[ne], { object: Oe, geometry: Ie, group: Xe } = Le; let Ze = Le.material; Ze.allowOverride === !0 && oe !== null && (Ze = oe), Oe.layers.test(re.layers) && Tc(Oe, Q, re, Ie, Ze, Xe); } } function Tc(k, Q, re, oe, ne, Se) { k.onBeforeRender(T, Q, re, oe, ne, Se), k.modelViewMatrix.multiplyMatrices(re.matrixWorldInverse, k.matrixWorld), k.normalMatrix.getNormalMatrix(k.modelViewMatrix), ne.onBeforeRender(T, Q, re, oe, k, Se), ne.transparent === !0 && ne.side === Dt && ne.forceSinglePass === !1 ? (ne.side = Jt, ne.needsUpdate = !0, T.renderBufferDirect(re, Q, oe, ne, k, Se), ne.side = Rn, ne.needsUpdate = !0, T.renderBufferDirect(re, Q, oe, ne, k, Se), ne.side = Dt) : T.renderBufferDirect(re, Q, oe, ne, k, Se), k.onAfterRender(T, Q, re, oe, ne, Se); } function yr(k, Q, re) { Q.isScene !== !0 && (Q = Ye); const oe = $.get(k), ne = b.state.lights, Se = b.state.shadowsArray, Le = ne.state.version, Oe = te.getParameters(k, ne.state, Se, Q, re), Ie = te.getProgramCacheKey(Oe); let Xe = oe.programs; oe.environment = k.isMeshStandardMaterial ? Q.environment : null, oe.fog = Q.fog, oe.envMap = (k.isMeshStandardMaterial ? E : L).get(k.envMap || oe.environment), oe.envMapRotation = oe.environment !== null && k.envMap === null ? Q.environmentRotation : k.envMapRotation, Xe === void 0 && (k.addEventListener("dispose", qe), Xe = /* @__PURE__ */ new Map(), oe.programs = Xe); let Ze = Xe.get(Ie); if (Ze !== void 0) { if (oe.currentProgram === Ze && oe.lightsStateVersion === Le) return Ac(k, Oe), Ze; } else Oe.uniforms = te.getUniforms(k), k.onBeforeCompile(Oe, T), Ze = te.acquireProgram(Oe, Ie), Xe.set(Ie, Ze), oe.uniforms = Oe.uniforms; const Ge = oe.uniforms; return (!k.isShaderMaterial && !k.isRawShaderMaterial || k.clipping === !0) && (Ge.clippingPlanes = De.uniform), Ac(k, Oe), oe.needsLights = mf(k), oe.lightsStateVersion = Le, oe.needsLights && (Ge.ambientLightColor.value = ne.state.ambient, Ge.lightProbe.value = ne.state.probe, Ge.directionalLights.value = ne.state.directional, Ge.directionalLightShadows.value = ne.state.directionalShadow, Ge.spotLights.value = ne.state.spot, Ge.spotLightShadows.value = ne.state.spotShadow, Ge.rectAreaLights.value = ne.state.rectArea, Ge.ltc_1.value = ne.state.rectAreaLTC1, Ge.ltc_2.value = ne.state.rectAreaLTC2, Ge.pointLights.value = ne.state.point, Ge.pointLightShadows.value = ne.state.pointShadow, Ge.hemisphereLights.value = ne.state.hemi, Ge.directionalShadowMap.value = ne.state.directionalShadowMap, Ge.directionalShadowMatrix.value = ne.state.directionalShadowMatrix, Ge.spotShadowMap.value = ne.state.spotShadowMap, Ge.spotLightMatrix.value = ne.state.spotLightMatrix, Ge.spotLightMap.value = ne.state.spotLightMap, Ge.pointShadowMap.value = ne.state.pointShadowMap, Ge.pointShadowMatrix.value = ne.state.pointShadowMatrix), oe.currentProgram = Ze, oe.uniformsList = null, Ze; } function Cc(k) { if (k.uniformsList === null) { const Q = k.currentProgram.getUniforms(); k.uniformsList = fa.seqWithValue(Q.seq, k.uniforms); } return k.uniformsList; } function Ac(k, Q) { const re = $.get(k); re.outputColorSpace = Q.outputColorSpace, re.batching = Q.batching, re.batchingColor = Q.batchingColor, re.instancing = Q.instancing, re.instancingColor = Q.instancingColor, re.instancingMorph = Q.instancingMorph, re.skinning = Q.skinning, re.morphTargets = Q.morphTargets, re.morphNormals = Q.morphNormals, re.morphColors = Q.morphColors, re.morphTargetsCount = Q.morphTargetsCount, re.numClippingPlanes = Q.numClippingPlanes, re.numIntersection = Q.numClipIntersection, re.vertexAlphas = Q.vertexAlphas, re.vertexTangents = Q.vertexTangents, re.toneMapping = Q.toneMapping; } function ff(k, Q, re, oe, ne) { Q.isScene !== !0 && (Q = Ye), G.resetTextureUnits(); const Se = Q.fog, Le = oe.isMeshStandardMaterial ? Q.environment : null, Oe = w === null ? T.outputColorSpace : w.isXRRenderTarget === !0 ? w.texture.colorSpace : Tt, Ie = (oe.isMeshStandardMaterial ? E : L).get(oe.envMap || Le), Xe = oe.vertexColors === !0 && !!re.attributes.color && re.attributes.color.itemSize === 4, Ze = !!re.attributes.tangent && (!!oe.normalMap || oe.anisotropy > 0), Ge = !!re.morphAttributes.position, nt = !!re.morphAttributes.normal, ut = !!re.morphAttributes.color; let St = gi; oe.toneMapped && (w === null || w.isXRRenderTarget === !0) && (St = T.toneMapping); const wt = re.morphAttributes.position || re.morphAttributes.normal || re.morphAttributes.color, pt = wt !== void 0 ? wt.length : 0, We = $.get(oe), bt = b.state.lights; if (ce === !0 && (fe === !0 || k !== P)) { const qt = k === P && oe.id === B; De.setState(oe, k, qt); } let rt = !1; oe.version === We.__version ? (We.needsLights && We.lightsStateVersion !== bt.state.version || We.outputColorSpace !== Oe || ne.isBatchedMesh && We.batching === !1 || !ne.isBatchedMesh && We.batching === !0 || ne.isBatchedMesh && We.batchingColor === !0 && ne.colorTexture === null || ne.isBatchedMesh && We.batchingColor === !1 && ne.colorTexture !== null || ne.isInstancedMesh && We.instancing === !1 || !ne.isInstancedMesh && We.instancing === !0 || ne.isSkinnedMesh && We.skinning === !1 || !ne.isSkinnedMesh && We.skinning === !0 || ne.isInstancedMesh && We.instancingColor === !0 && ne.instanceColor === null || ne.isInstancedMesh && We.instancingColor === !1 && ne.instanceColor !== null || ne.isInstancedMesh && We.instancingMorph === !0 && ne.morphTexture === null || ne.isInstancedMesh && We.instancingMorph === !1 && ne.morphTexture !== null || We.envMap !== Ie || oe.fog === !0 && We.fog !== Se || We.numClippingPlanes !== void 0 && (We.numClippingPlanes !== De.numPlanes || We.numIntersection !== De.numIntersection) || We.vertexAlphas !== Xe || We.vertexTangents !== Ze || We.morphTargets !== Ge || We.morphNormals !== nt || We.morphColors !== ut || We.toneMapping !== St || We.morphTargetsCount !== pt) && (rt = !0) : (rt = !0, We.__version = oe.version); let un = We.currentProgram; rt === !0 && (un = yr(oe, Q, ne)); let Vi = !1, dn = !1, Is = !1; const _t = un.getUniforms(), Qt = We.uniforms; if (F.useProgram(un.program) && (Vi = !0, dn = !0, Is = !0), oe.id !== B && (B = oe.id, dn = !0), Vi || P !== k) { F.buffers.depth.getReversed() && k.reversedDepth !== !0 && (k._reversedDepth = !0, k.updateProjectionMatrix()), _t.setValue(A, "projectionMatrix", k.projectionMatrix), _t.setValue(A, "viewMatrix", k.matrixWorldInverse); const en = _t.map.cameraPosition; en !== void 0 && en.setValue(A, Ee.setFromMatrixPosition(k.matrixWorld)), I.logarithmicDepthBuffer && _t.setValue( A, "logDepthBufFC", 2 / (Math.log(k.far + 1) / Math.LN2) ), (oe.isMeshPhongMaterial || oe.isMeshToonMaterial || oe.isMeshLambertMaterial || oe.isMeshBasicMaterial || oe.isMeshStandardMaterial || oe.isShaderMaterial) && _t.setValue(A, "isOrthographic", k.isOrthographicCamera === !0), P !== k && (P = k, dn = !0, Is = !0); } if (ne.isSkinnedMesh) { _t.setOptional(A, ne, "bindMatrix"), _t.setOptional(A, ne, "bindMatrixInverse"); const qt = ne.skeleton; qt && (qt.boneTexture === null && qt.computeBoneTexture(), _t.setValue(A, "boneTexture", qt.boneTexture, G)); } ne.isBatchedMesh && (_t.setOptional(A, ne, "batchingTexture"), _t.setValue(A, "batchingTexture", ne._matricesTexture, G), _t.setOptional(A, ne, "batchingIdTexture"), _t.setValue(A, "batchingIdTexture", ne._indirectTexture, G), _t.setOptional(A, ne, "batchingColorTexture"), ne._colorsTexture !== null && _t.setValue(A, "batchingColorTexture", ne._colorsTexture, G)); const gn = re.morphAttributes; if ((gn.position !== void 0 || gn.normal !== void 0 || gn.color !== void 0) && He.update(ne, re, un), (dn || We.receiveShadow !== ne.receiveShadow) && (We.receiveShadow = ne.receiveShadow, _t.setValue(A, "receiveShadow", ne.receiveShadow)), oe.isMeshGouraudMaterial && oe.envMap !== null && (Qt.envMap.value = Ie, Qt.flipEnvMap.value = Ie.isCubeTexture && Ie.isRenderTargetTexture === !1 ? -1 : 1), oe.isMeshStandardMaterial && oe.envMap === null && Q.environment !== null && (Qt.envMapIntensity.value = Q.environmentIntensity), Qt.dfgLUT !== void 0 && (Qt.dfgLUT.value = ib()), dn && (_t.setValue(A, "toneMappingExposure", T.toneMappingExposure), We.needsLights && pf(Qt, Is), Se && oe.fog === !0 && Te.refreshFogUniforms(Qt, Se), Te.refreshMaterialUniforms(Qt, oe, ae, Z, b.state.transmissionRenderTarget[k.id]), fa.upload(A, Cc(We), Qt, G)), oe.isShaderMaterial && oe.uniformsNeedUpdate === !0 && (fa.upload(A, Cc(We), Qt, G), oe.uniformsNeedUpdate = !1), oe.isSpriteMaterial && _t.setValue(A, "center", ne.center), _t.setValue(A, "modelViewMatrix", ne.modelViewMatrix), _t.setValue(A, "normalMatrix", ne.normalMatrix), _t.setValue(A, "modelMatrix", ne.matrixWorld), oe.isShaderMaterial || oe.isRawShaderMaterial) { const qt = oe.uniformsGroups; for (let en = 0, za = qt.length; en < za; en++) { const vi = qt[en]; we.update(vi, un), we.bind(vi, un); } } return un; } function pf(k, Q) { k.ambientLightColor.needsUpdate = Q, k.lightProbe.needsUpdate = Q, k.directionalLights.needsUpdate = Q, k.directionalLightShadows.needsUpdate = Q, k.pointLights.needsUpdate = Q, k.pointLightShadows.needsUpdate = Q, k.spotLights.needsUpdate = Q, k.spotLightShadows.needsUpdate = Q, k.rectAreaLights.needsUpdate = Q, k.hemisphereLights.needsUpdate = Q; } function mf(k) { return k.isMeshLambertMaterial || k.isMeshToonMaterial || k.isMeshPhongMaterial || k.isMeshStandardMaterial || k.isShadowMaterial || k.isShaderMaterial && k.lights === !0; } this.getActiveCubeFace = function() { return U; }, this.getActiveMipmapLevel = function() { return S; }, this.getRenderTarget = function() { return w; }, this.setRenderTargetTextures = function(k, Q, re) { const oe = $.get(k); oe.__autoAllocateDepthBuffer = k.resolveDepthBuffer === !1, oe.__autoAllocateDepthBuffer === !1 && (oe.__useRenderToTexture = !1), $.get(k.texture).__webglTexture = Q, $.get(k.depthTexture).__webglTexture = oe.__autoAllocateDepthBuffer ? void 0 : re, oe.__hasExternalTextures = !0; }, this.setRenderTargetFramebuffer = function(k, Q) { const re = $.get(k); re.__webglFramebuffer = Q, re.__useDefaultFramebuffer = Q === void 0; }; const gf = A.createFramebuffer(); this.setRenderTarget = function(k, Q = 0, re = 0) { w = k, U = Q, S = re; let oe = !0, ne = null, Se = !1, Le = !1; if (k) { const Ie = $.get(k); if (Ie.__useDefaultFramebuffer !== void 0) F.bindFramebuffer(A.FRAMEBUFFER, null), oe = !1; else if (Ie.__webglFramebuffer === void 0) G.setupRenderTarget(k); else if (Ie.__hasExternalTextures) G.rebindTextures(k, $.get(k.texture).__webglTexture, $.get(k.depthTexture).__webglTexture); else if (k.depthBuffer) { const Ge = k.depthTexture; if (Ie.__boundDepthTexture !== Ge) { if (Ge !== null && $.has(Ge) && (k.width !== Ge.image.width || k.height !== Ge.image.height)) throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size."); G.setupDepthRenderbuffer(k); } } const Xe = k.texture; (Xe.isData3DTexture || Xe.isDataArrayTexture || Xe.isCompressedArrayTexture) && (Le = !0); const Ze = $.get(k).__webglFramebuffer; k.isWebGLCubeRenderTarget ? (Array.isArray(Ze[Q]) ? ne = Ze[Q][re] : ne = Ze[Q], Se = !0) : k.samples > 0 && G.useMultisampledRTT(k) === !1 ? ne = $.get(k).__webglMultisampledFramebuffer : Array.isArray(Ze) ? ne = Ze[re] : ne = Ze, O.copy(k.viewport), y.copy(k.scissor), H = k.scissorTest; } else O.copy(ge).multiplyScalar(ae).floor(), y.copy(pe).multiplyScalar(ae).floor(), H = de; if (re !== 0 && (ne = gf), F.bindFramebuffer(A.FRAMEBUFFER, ne) && oe && F.drawBuffers(k, ne), F.viewport(O), F.scissor(y), F.setScissorTest(H), Se) { const Ie = $.get(k.texture); A.framebufferTexture2D(A.FRAMEBUFFER, A.COLOR_ATTACHMENT0, A.TEXTURE_CUBE_MAP_POSITIVE_X + Q, Ie.__webglTexture, re); } else if (Le) { const Ie = Q; for (let Xe = 0; Xe < k.textures.length; Xe++) { const Ze = $.get(k.textures[Xe]); A.framebufferTextureLayer(A.FRAMEBUFFER, A.COLOR_ATTACHMENT0 + Xe, Ze.__webglTexture, re, Ie); } } else if (k !== null && re !== 0) { const Ie = $.get(k.texture); A.framebufferTexture2D(A.FRAMEBUFFER, A.COLOR_ATTACHMENT0, A.TEXTURE_2D, Ie.__webglTexture, re); } B = -1; }, this.readRenderTargetPixels = function(k, Q, re, oe, ne, Se, Le, Oe = 0) { if (!(k && k.isWebGLRenderTarget)) { et("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); return; } let Ie = $.get(k).__webglFramebuffer; if (k.isWebGLCubeRenderTarget && Le !== void 0 && (Ie = Ie[Le]), Ie) { F.bindFramebuffer(A.FRAMEBUFFER, Ie); try { const Xe = k.textures[Oe], Ze = Xe.format, Ge = Xe.type; if (!I.textureFormatReadable(Ze)) { et("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."); return; } if (!I.textureTypeReadable(Ge)) { et("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."); return; } Q >= 0 && Q <= k.width - oe && re >= 0 && re <= k.height - ne && (k.textures.length > 1 && A.readBuffer(A.COLOR_ATTACHMENT0 + Oe), A.readPixels(Q, re, oe, ne, Ve.convert(Ze), Ve.convert(Ge), Se)); } finally { const Xe = w !== null ? $.get(w).__webglFramebuffer : null; F.bindFramebuffer(A.FRAMEBUFFER, Xe); } } }, this.readRenderTargetPixelsAsync = async function(k, Q, re, oe, ne, Se, Le, Oe = 0) { if (!(k && k.isWebGLRenderTarget)) throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); let Ie = $.get(k).__webglFramebuffer; if (k.isWebGLCubeRenderTarget && Le !== void 0 && (Ie = Ie[Le]), Ie) if (Q >= 0 && Q <= k.width - oe && re >= 0 && re <= k.height - ne) { F.bindFramebuffer(A.FRAMEBUFFER, Ie); const Xe = k.textures[Oe], Ze = Xe.format, Ge = Xe.type; if (!I.textureFormatReadable(Ze)) throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format."); if (!I.textureTypeReadable(Ge)) throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type."); const nt = A.createBuffer(); A.bindBuffer(A.PIXEL_PACK_BUFFER, nt), A.bufferData(A.PIXEL_PACK_BUFFER, Se.byteLength, A.STREAM_READ), k.textures.length > 1 && A.readBuffer(A.COLOR_ATTACHMENT0 + Oe), A.readPixels(Q, re, oe, ne, Ve.convert(Ze), Ve.convert(Ge), 0); const ut = w !== null ? $.get(w).__webglFramebuffer : null; F.bindFramebuffer(A.FRAMEBUFFER, ut); const St = A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE, 0); return A.flush(), await lp(A, St, 4), A.bindBuffer(A.PIXEL_PACK_BUFFER, nt), A.getBufferSubData(A.PIXEL_PACK_BUFFER, 0, Se), A.deleteBuffer(nt), A.deleteSync(St), Se; } else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range."); }, this.copyFramebufferToTexture = function(k, Q = null, re = 0) { const oe = Math.pow(2, -re), ne = Math.floor(k.image.width * oe), Se = Math.floor(k.image.height * oe), Le = Q !== null ? Q.x : 0, Oe = Q !== null ? Q.y : 0; G.setTexture2D(k, 0), A.copyTexSubImage2D(A.TEXTURE_2D, re, 0, 0, Le, Oe, ne, Se), F.unbindTexture(); }; const xf = A.createFramebuffer(), vf = A.createFramebuffer(); this.copyTextureToTexture = function(k, Q, re = null, oe = null, ne = 0, Se = null) { Se === null && (ne !== 0 ? (lr("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."), Se = ne, ne = 0) : Se = 0); let Le, Oe, Ie, Xe, Ze, Ge, nt, ut, St; const wt = k.isCompressedTexture ? k.mipmaps[Se] : k.image; if (re !== null) Le = re.max.x - re.min.x, Oe = re.max.y - re.min.y, Ie = re.isBox3 ? re.max.z - re.min.z : 1, Xe = re.min.x, Ze = re.min.y, Ge = re.isBox3 ? re.min.z : 0; else { const gn = Math.pow(2, -ne); Le = Math.floor(wt.width * gn), Oe = Math.floor(wt.height * gn), k.isDataArrayTexture ? Ie = wt.depth : k.isData3DTexture ? Ie = Math.floor(wt.depth * gn) : Ie = 1, Xe = 0, Ze = 0, Ge = 0; } oe !== null ? (nt = oe.x, ut = oe.y, St = oe.z) : (nt = 0, ut = 0, St = 0); const pt = Ve.convert(Q.format), We = Ve.convert(Q.type); let bt; Q.isData3DTexture ? (G.setTexture3D(Q, 0), bt = A.TEXTURE_3D) : Q.isDataArrayTexture || Q.isCompressedArrayTexture ? (G.setTexture2DArray(Q, 0), bt = A.TEXTURE_2D_ARRAY) : (G.setTexture2D(Q, 0), bt = A.TEXTURE_2D), A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL, Q.flipY), A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL, Q.premultiplyAlpha), A.pixelStorei(A.UNPACK_ALIGNMENT, Q.unpackAlignment); const rt = A.getParameter(A.UNPACK_ROW_LENGTH), un = A.getParameter(A.UNPACK_IMAGE_HEIGHT), Vi = A.getParameter(A.UNPACK_SKIP_PIXELS), dn = A.getParameter(A.UNPACK_SKIP_ROWS), Is = A.getParameter(A.UNPACK_SKIP_IMAGES); A.pixelStorei(A.UNPACK_ROW_LENGTH, wt.width), A.pixelStorei(A.UNPACK_IMAGE_HEIGHT, wt.height), A.pixelStorei(A.UNPACK_SKIP_PIXELS, Xe), A.pixelStorei(A.UNPACK_SKIP_ROWS, Ze), A.pixelStorei(A.UNPACK_SKIP_IMAGES, Ge); const _t = k.isDataArrayTexture || k.isData3DTexture, Qt = Q.isDataArrayTexture || Q.isData3DTexture; if (k.isDepthTexture) { const gn = $.get(k), qt = $.get(Q), en = $.get(gn.__renderTarget), za = $.get(qt.__renderTarget); F.bindFramebuffer(A.READ_FRAMEBUFFER, en.__webglFramebuffer), F.bindFramebuffer(A.DRAW_FRAMEBUFFER, za.__webglFramebuffer); for (let vi = 0; vi < Ie; vi++) _t && (A.framebufferTextureLayer(A.READ_FRAMEBUFFER, A.COLOR_ATTACHMENT0, $.get(k).__webglTexture, ne, Ge + vi), A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER, A.COLOR_ATTACHMENT0, $.get(Q).__webglTexture, Se, St + vi)), A.blitFramebuffer(Xe, Ze, Le, Oe, nt, ut, Le, Oe, A.DEPTH_BUFFER_BIT, A.NEAREST); F.bindFramebuffer(A.READ_FRAMEBUFFER, null), F.bindFramebuffer(A.DRAW_FRAMEBUFFER, null); } else if (ne !== 0 || k.isRenderTargetTexture || $.has(k)) { const gn = $.get(k), qt = $.get(Q); F.bindFramebuffer(A.READ_FRAMEBUFFER, xf), F.bindFramebuffer(A.DRAW_FRAMEBUFFER, vf); for (let en = 0; en < Ie; en++) _t ? A.framebufferTextureLayer(A.READ_FRAMEBUFFER, A.COLOR_ATTACHMENT0, gn.__webglTexture, ne, Ge + en) : A.framebufferTexture2D(A.READ_FRAMEBUFFER, A.COLOR_ATTACHMENT0, A.TEXTURE_2D, gn.__webglTexture, ne), Qt ? A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER, A.COLOR_ATTACHMENT0, qt.__webglTexture, Se, St + en) : A.framebufferTexture2D(A.DRAW_FRAMEBUFFER, A.COLOR_ATTACHMENT0, A.TEXTURE_2D, qt.__webglTexture, Se), ne !== 0 ? A.blitFramebuffer(Xe, Ze, Le, Oe, nt, ut, Le, Oe, A.COLOR_BUFFER_BIT, A.NEAREST) : Qt ? A.copyTexSubImage3D(bt, Se, nt, ut, St + en, Xe, Ze, Le, Oe) : A.copyTexSubImage2D(bt, Se, nt, ut, Xe, Ze, Le, Oe); F.bindFramebuffer(A.READ_FRAMEBUFFER, null), F.bindFramebuffer(A.DRAW_FRAMEBUFFER, null); } else Qt ? k.isDataTexture || k.isData3DTexture ? A.texSubImage3D(bt, Se, nt, ut, St, Le, Oe, Ie, pt, We, wt.data) : Q.isCompressedArrayTexture ? A.compressedTexSubImage3D(bt, Se, nt, ut, St, Le, Oe, Ie, pt, wt.data) : A.texSubImage3D(bt, Se, nt, ut, St, Le, Oe, Ie, pt, We, wt) : k.isDataTexture ? A.texSubImage2D(A.TEXTURE_2D, Se, nt, ut, Le, Oe, pt, We, wt.data) : k.isCompressedTexture ? A.compressedTexSubImage2D(A.TEXTURE_2D, Se, nt, ut, wt.width, wt.height, pt, wt.data) : A.texSubImage2D(A.TEXTURE_2D, Se, nt, ut, Le, Oe, pt, We, wt); A.pixelStorei(A.UNPACK_ROW_LENGTH, rt), A.pixelStorei(A.UNPACK_IMAGE_HEIGHT, un), A.pixelStorei(A.UNPACK_SKIP_PIXELS, Vi), A.pixelStorei(A.UNPACK_SKIP_ROWS, dn), A.pixelStorei(A.UNPACK_SKIP_IMAGES, Is), Se === 0 && Q.generateMipmaps && A.generateMipmap(bt), F.unbindTexture(); }, this.initRenderTarget = function(k) { $.get(k).__webglFramebuffer === void 0 && G.setupRenderTarget(k); }, this.initTexture = function(k) { k.isCubeTexture ? G.setTextureCube(k, 0) : k.isData3DTexture ? G.setTexture3D(k, 0) : k.isDataArrayTexture || k.isCompressedArrayTexture ? G.setTexture2DArray(k, 0) : G.setTexture2D(k, 0), F.unbindTexture(); }, this.resetState = function() { U = 0, S = 0, w = null, F.reset(), W.reset(); }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); } /** * Defines the coordinate system of the renderer. * * In `WebGLRenderer`, the value is always `WebGLCoordinateSystem`. * * @type {WebGLCoordinateSystem|WebGPUCoordinateSystem} * @default WebGLCoordinateSystem * @readonly */ get coordinateSystem() { return Vn; } /** * Defines the output color space of the renderer. * * @type {SRGBColorSpace|LinearSRGBColorSpace} * @default SRGBColorSpace */ get outputColorSpace() { return this._outputColorSpace; } set outputColorSpace(e) { this._outputColorSpace = e; const t = this.getContext(); t.drawingBufferColorSpace = it._getDrawingBufferColorSpace(e), t.unpackColorSpace = it._getUnpackColorSpace(); } } class sb { engine; scene; constructor(e) { this.engine = e, this.scene = new ad(); let t = new $t(); t.name = "groupEdge", this.scene.add(t); } } class rb { engine; // 透视相机 perspectiveCamera; // 正交相机 orthographicCamera; constructor(e) { this.engine = e, this.perspectiveCamera = new jt( 60, this.engine.container.clientWidth / this.engine.container.clientHeight, 0.1, 1e3 ), this.perspectiveCamera.position.set(2, 2, 2), this.perspectiveCamera.lookAt(0, 0, 0); const t = 50, n = this.engine.container.clientWidth / this.engine.container.clientHeight; this.orthographicCamera = new zi(t * n / -2, t * n / 2, t / 2, t / -2, 0.1, 1e3); } // 切换当前相机 switchCurrentCamera() { this.engine.camera === this.perspectiveCamera ? this.switchToOrthographicCamera() : this.switchToPerspectiveCamera(); } // 透视相机 switchToPerspectiveCamera() { const e = this.engine.camera.position.clone(), t = this.engine.controls.target.clone(); this.engine.camera = this.perspectiveCamera, this.engine.scene.camera = this.perspectiveCamera, this.perspectiveCamera.position.copy(e), this.perspectiveCamera.lookAt(t), this.engine.controlModule.orbitControls.object = this.perspectiveCamera, this.engine.controlModule.firstPersonControls.camera = this.perspectiveCamera, this.engine.composerModule.init(); } // 正交相机 switchToOrthographicCamera() { const e = this.engine.camera.position.clone(), t = this.engine.controls.target.clone(); this.engine.camera = this.orthographicCamera, this.engine.scene.camera = this.orthographicCamera, this.orthographicCamera.position.copy(e), this.orthographicCamera.lookAt(t), this.engine.controlModule.orbitControls.object = this.orthographicCamera, this.engine.controlModule.firstPersonControls.camera = this.orthographicCamera, this.engine.composerModule.init(); } // 获取当前相机类型 getCameraType() { return this.engine.camera === this.perspectiveCamera ? "perspective" : this.engine.camera === this.orthographicCamera ? "orthographic" : "perspective"; } // 获取当前相机姿态 getCameraPose() { const e = this.engine.camera, t = this.getCameraType(), n = { type: t, position: { x: e.position.x, y: e.position.y, z: e.position.z }, rotation: { x: e.rotation.x, y: e.rotation.y, z: e.rotation.z }, quaternion: { x: e.quaternion.x, y: e.quaternion.y, z: e.quaternion.z, w: e.quaternion.w } }; return this.engine.controls && this.engine.controls.target && (n.target = { x: this.engine.controls.target.x, y: this.engine.controls.target.y, z: this.engine.controls.target.z }), t === "orthographic" && (n.zoom = e.zoom), n; } // 通过相机姿态还原相机位置 restoreCameraPose(e) { this.getCameraType() !== e.type && (e.type === "perspective" ? this.switchToPerspectiveCamera() : this.switchToOrthographicCamera()); const t = this.engine.camera; t.position.set(e.position.x, e.position.y, e.position.z), e.quaternion ? t.quaternion.set( e.quaternion.x, e.quaternion.y, e.quaternion.z, e.quaternion.w ) : e.rotation && t.rotation.set(e.rotation.x, e.rotation.y, e.rotation.z), e.target && this.engine.controls && this.engine.controls.target && this.engine.controls.target.set( e.target.x, e.target.y, e.target.z ), e.type === "orthographic" && e.zoom !== void 0 && (t.zoom = e.zoom, t.updateProjectionMatrix()), t.updateMatrix(), t.updateMatrixWorld(!0), this.engine.controls && this.engine.controls.update && this.engine.controls.update(); } } class ab { engine; deviceType; constructor(e) { this.engine = e, this.deviceType = "PC"; } // 获取设备类型 getDeviceType() { return this.deviceType; } // 获取容器尺寸 getContainerSize() { return { width: this.engine.container.clientWidth, height: this.engine.container.clientHeight }; } } class ob { engine; renderer; constructor(e) { this.engine = e, this.renderer = null; } createRenderer() { const { width: e, height: t } = this.engine.deviceModule.getContainerSize(); return this.renderer = new Rd({ antialias: this.engine.options.antialias ?? !0, alpha: !0, premultipliedAlpha: !1, stencil: !0 }), this.renderer.setClearColor(0, 0), this.renderer.setSize(e, t), this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.shadowMap.enabled = !0, this.renderer.shadowMap.type = Nu, this.renderer.localClippingEnabled = !0, this.renderer.outputColorSpace = mt, this.renderer.toneMapping = ql, this.renderer.toneMappingExposure = 1.5, this.engine.container.appendChild(this.renderer.domElement), this.renderer; } disposeRenderer() { this.renderer?.dispose(); } } const Jh = { type: "change" }, gc = { type: "start" }, Ld = { type: "end" }, $r = new Ts(), Qh = new Ct(), lb = Math.cos(70 * Js.DEG2RAD), It = new R(), tn = 2 * Math.PI, dt = { NONE: -1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_PAN: 4, TOUCH_DOLLY_PAN: 5, TOUCH_DOLLY_ROTATE: 6 }, Ao = 1e-6; class cb extends x0 { /** * Constructs a new controls instance. * * @param {Object3D} object - The object that is managed by the controls. * @param {?HTMLElement} domElement - The HTML element used for event listeners. */ constructor(e, t, n = null) { super(t, n), this.engine = e, this.state = dt.NONE, this.target = new R(), this.cursor = new R(), 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 = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: ls.ROTATE, MIDDLE: ls.DOLLY, RIGHT: ls.PAN }, this.touches = { ONE: rs.ROTATE, TWO: rs.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new R(), this._lastQuaternion = new Dn(), this._lastTargetPosition = new R(), this._quat = new Dn().setFromUnitVectors(t.up, new R(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new Ch(), this._sphericalDelta = new Ch(), this._scale = 1, this._panOffset = new R(), this._rotateStart = new ue(), this._rotateEnd = new ue(), this._rotateDelta = new ue(), this._panStart = new ue(), this._panEnd = new ue(), this._panDelta = new ue(), this._dollyStart = new ue(), this._dollyEnd = new ue(), this._dollyDelta = new ue(), this._dollyDirection = new R(), this._mouse = new ue(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = ub.bind(this), this._onPointerDown = hb.bind(this), this._onPointerUp = db.bind(this), this._onContextMenu = bb.bind(this), this._onMouseWheel = mb.bind(this), this._onKeyDown = gb.bind(this), this._onTouchStart = xb.bind(this), this._onTouchMove = vb.bind(this), this._onMouseDown = fb.bind(this), this._onMouseMove = pb.bind(this), this._interceptControlDown = _b.bind(this), this._interceptControlUp = yb.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(); } /** * Get the current vertical rotation, in radians. * * @return {number} The current vertical rotation, in radians. */ getPolarAngle() { return this._spherical.phi; } /** * Get the current horizontal rotation, in radians. * * @return {number} The current horizontal rotation, in radians. */ getAzimuthalAngle() { return this._spherical.theta; } /** * Returns the distance from the camera to the target. * * @return {number} The distance from the camera to the target. */ getDistance() { return this.object.position.distanceTo(this.target); } /** * Adds key event listeners to the given DOM element. * `window` is a recommended argument for using this method. * * @param {HTMLElement} domElement - The DOM element */ listenToKeyEvents(e) { e.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = e; } /** * Removes the key event listener previously defined with `listenToKeyEvents()`. */ stopListenToKeyEvents() { this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null); } /** * Save the current state of the controls. This can later be recovered with `reset()`. */ saveState() { this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom; } /** * Reset the controls to their state from either the last time the `saveState()` * was called, or the initial state. */ reset() { this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(Jh), this.update(), this.state = dt.NONE; } update(e = null) { const t = this.object.position; It.copy(t).sub(this.target), It.applyQuaternion(this._quat), this._spherical.setFromVector3(It), this.autoRotate && this.state === dt.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi); let n = this.minAzimuthAngle, i = this.maxAzimuthAngle; isFinite(n) && isFinite(i) && (n < -Math.PI ? n += tn : n > Math.PI && (n -= tn), i < -Math.PI ? i += tn : i > Math.PI && (i -= tn), n <= i ? this._spherical.theta = Math.max(n, Math.min(i, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (n + i) / 2 ? Math.max(n, this._spherical.theta) : Math.min(i, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor); let r = !1; if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera) this._spherical.radius = this._clampDistance(this._spherical.radius); else { const a = this._spherical.radius; this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), r = a != this._spherical.radius; } if (It.setFromSpherical(this._spherical), It.applyQuaternion(this._quatInverse), t.copy(this.target).add(It), 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 = It.length(); a = this._clampDistance(o * this._scale); const l = o - a; this.object.position.addScaledVector(this._dollyDirection, l), this.object.updateMatrixWorld(), r = !!l; } else if (this.object.isOrthographicCamera) { const o = new R(this._mouse.x, this._mouse.y, 0); o.unproject(this.object); const l = this.object.zoom; this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), r = l !== this.object.zoom; const c = new R(this._mouse.x, this._mouse.y, 0); c.unproject(this.object), this.object.position.sub(c).add(o), this.object.updateMatrixWorld(), a = It.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) : ($r.origin.copy(this.object.position), $r.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot($r.direction)) < lb ? this.object.lookAt(this.target) : (Qh.setFromNormalAndCoplanarPoint(this.object.up, this.target), $r.intersectPlane(Qh, this.target)))); } else if (this.object.isOrthographicCamera) { const a = this.object.zoom; this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), a !== this.object.zoom && (this.object.updateProjectionMatrix(), r = !0); } return this._scale = 1, this._performCursorZoom = !1, r || this._lastPosition.distanceToSquared(this.object.position) > Ao || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > Ao || this._lastTargetPosition.distanceToSquared(this.target) > Ao ? (this.dispatchEvent(Jh), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1; } _getAutoRotationAngle(e) { return e !== null ? tn / 60 * this.autoRotateSpeed * e : tn / 60 / 60 * this.autoRotateSpeed; } _getZoomScale(e) { const t = Math.abs(e * 0.01); return Math.pow(0.95, this.zoomSpeed * t); } _rotateLeft(e) { this._sphericalDelta.theta -= e; } _rotateUp(e) { this._sphericalDelta.phi -= e; } _panLeft(e, t) { It.setFromMatrixColumn(t, 0), It.multiplyScalar(-e), this._panOffset.add(It); } _panUp(e, t) { this.screenSpacePanning === !0 ? It.setFromMatrixColumn(t, 1) : (It.setFromMatrixColumn(t, 0), It.crossVectors(this.object.up, It)), It.multiplyScalar(e), this._panOffset.add(It); } // deltaX and deltaY are in pixels; right and down are positive _pan(e, t) { const n = this.domElement; if (this.object.isPerspectiveCamera) { const i = this.object.position; It.copy(i).sub(this.target); let r = It.length(); r *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * r / n.clientHeight, this.object.matrix), this._panUp(2 * t * r / n.clientHeight, this.object.matrix); } else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / n.clientWidth, this.object.matrix), this._panUp(t * (this.object.top - this.object.bottom) / this.object.zoom / n.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1); } _dollyOut(e) { this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1); } _dollyIn(e) { this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1); } _updateZoomParameters(e, t) { if (!this.zoomToCursor) return; this._performCursorZoom = !0; const n = this.domElement.getBoundingClientRect(), i = e - n.left, r = t - n.top, a = n.width, o = n.height; this._mouse.x = i / a * 2 - 1, this._mouse.y = -(r / o) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize(); } _clampDistance(e) { return Math.max(this.minDistance, Math.min(this.maxDistance, e)); } // // event callbacks - update the object state // _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(tn * this._rotateDelta.x / t.clientHeight), this._rotateUp(tn * 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(tn * 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(-tn * 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(tn * 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(-tn * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), t = !0; break; } t && (e.preventDefault(), this.update()); } _handleTouchStartRotate(e) { if (this._pointers.length === 1) this._rotateStart.set(e.pageX, e.pageY); else { const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y); this._rotateStart.set(n, i); } } _handleTouchStartPan(e) { if (this._pointers.length === 1) this._panStart.set(e.pageX, e.pageY); else { const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y); this._panStart.set(n, i); } } _handleTouchStartDolly(e) { const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, i = e.pageY - t.y, r = Math.sqrt(n * n + i * i); this._dollyStart.set(0, r); } _handleTouchStartDollyPan(e) { this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e); } _handleTouchStartDollyRotate(e) { this.enableZoom && this._handleTouchStartDolly(e), this.enableRotate && this._handleTouchStartRotate(e); } _handleTouchMoveRotate(e) { if (this._pointers.length == 1) this._rotateEnd.set(e.pageX, e.pageY); else { const n = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + n.x), r = 0.5 * (e.pageY + n.y); this._rotateEnd.set(i, r); } this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed); const t = this.domElement; this._rotateLeft(tn * this._rotateDelta.x / t.clientHeight), this._rotateUp(tn * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd); } _handleTouchMovePan(e) { if (this._pointers.length === 1) this._panEnd.set(e.pageX, e.pageY); else { const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y); this._panEnd.set(n, i); } this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd); } _handleTouchMoveDolly(e) { const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, i = e.pageY - t.y, r = Math.sqrt(n * n + i * i); this._dollyEnd.set(0, r), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd); const a = (e.pageX + t.x) * 0.5, o = (e.pageY + t.y) * 0.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); } // pointers _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 ue(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY); } _getSecondPointerPosition(e) { const t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0]; return this._pointerPositions[t]; } // _customWheelEvent(e) { const t = e.deltaMode, n = { clientX: e.clientX, clientY: e.clientY, deltaY: e.deltaY }; switch (t) { case 1: n.deltaY *= 16; break; case 2: n.deltaY *= 100; break; } return e.ctrlKey && !this._controlActive && (n.deltaY *= 10), n; } } function hb(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 ub(s) { this.enabled !== !1 && (s.pointerType === "touch" ? this._onTouchMove(s) : this._onMouseMove(s)); } function db(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(Ld), this.state = dt.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 fb(s) { let e; switch (s.button) { case 0: e = this.mouseButtons.LEFT; break; case 1: e = this.mouseButtons.MIDDLE; break; case 2: e = this.mouseButtons.RIGHT; break; default: e = -1; } switch (e) { case ls.DOLLY: if (this.enableZoom === !1) return; this._handleMouseDownDolly(s), this.state = dt.DOLLY; break; case ls.ROTATE: if (s.ctrlKey || s.metaKey || s.shiftKey) { if (this.enablePan === !1) return; this._handleMouseDownPan(s), this.state = dt.PAN; } else { if (this.enableRotate === !1) return; this._handleMouseDownRotate(s), this.state = dt.ROTATE; } break; case ls.PAN: if (s.ctrlKey || s.metaKey || s.shiftKey) { if (this.enableRotate === !1) return; this._handleMouseDownRotate(s), this.state = dt.ROTATE; } else { if (this.enablePan === !1) return; this._handleMouseDownPan(s), this.state = dt.PAN; } break; default: this.state = dt.NONE; } this.state !== dt.NONE && this.dispatchEvent(gc); } function pb(s) { switch (this.state) { case dt.ROTATE: if (this.enableRotate === !1) return; this._handleMouseMoveRotate(s); break; case dt.DOLLY: if (this.enableZoom === !1) return; this._handleMouseMoveDolly(s); break; case dt.PAN: if (this.enablePan === !1) return; this._handleMouseMovePan(s); break; } } function mb(s) { this.enabled === !1 || this.enableZoom === !1 || this.state !== dt.NONE || (s.preventDefault(), this.dispatchEvent(gc), this._handleMouseWheel(this._customWheelEvent(s)), this.dispatchEvent(Ld)); } function gb(s) { this.enabled !== !1 && this._handleKeyDown(s); } function xb(s) { switch (this._trackPointer(s), this._pointers.length) { case 1: switch (this.touches.ONE) { case rs.ROTATE: if (this.enableRotate === !1) return; this._handleTouchStartRotate(s), this.state = dt.TOUCH_ROTATE; break; case rs.PAN: if (this.enablePan === !1) return; this._handleTouchStartPan(s), this.state = dt.TOUCH_PAN; break; default: this.state = dt.NONE; } break; case 2: switch (this.touches.TWO) { case rs.DOLLY_PAN: if (this.enableZoom === !1 && this.enablePan === !1) return; this._handleTouchStartDollyPan(s), this.state = dt.TOUCH_DOLLY_PAN; break; case rs.DOLLY_ROTATE: if (this.enableZoom === !1 && this.enableRotate === !1) return; this._handleTouchStartDollyRotate(s), this.state = dt.TOUCH_DOLLY_ROTATE; break; default: this.state = dt.NONE; } break; default: this.state = dt.NONE; } this.state !== dt.NONE && this.dispatchEvent(gc); } function vb(s) { switch (this._trackPointer(s), this.state) { case dt.TOUCH_ROTATE: if (this.enableRotate === !1) return; this._handleTouchMoveRotate(s), this.update(); break; case dt.TOUCH_PAN: if (this.enablePan === !1) return; this._handleTouchMovePan(s), this.update(); break; case dt.TOUCH_DOLLY_PAN: if (this.enableZoom === !1 && this.enablePan === !1) return; this._handleTouchMoveDollyPan(s), this.update(); break; case dt.TOUCH_DOLLY_ROTATE: if (this.enableZoom === !1 && this.enableRotate === !1) return; this._handleTouchMoveDollyRotate(s), this.update(); break; default: this.state = dt.NONE; } } function bb(s) { this.enabled !== !1 && s.preventDefault(); } function _b(s) { s.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 })); } function yb(s) { s.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 })); } class eu { constructor(e, t, n, i) { this._Engine = e, this.camera = t, this.domElement = n, this._isEnabled = !1, this._rayOriginOffset = new R(0, -1, 0), this._camerLocalDirection = new R(), this._tmpVector = new R(), this._rayCaster = new Ni(), this._fallingTime = 0, this._euler = new cn(0, 0, 0, "YZX"), this._prevMouseX = 0, this._prevMouseY = 0, this.applyGravity = !1, this.gravityMinHeight = !0, this.applyCollision = !0, this.positionEasing = !0, this.lookflag = 1, this.lookSpeed = 8e-3, this.moveSpeed = 0.02, this.playerHeight = 1.4, this.maxRotateX = 0.8, this.g = 9.8, this.bindmousedown = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchStart.bind(this) : this.onMouseDown.bind(this), this.bindmouseup = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchEnd.bind(this) : this.onMouseUp.bind(this), this.bindmousemove = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchMove.bind(this) : this.onMouseMove.bind(this), this.bindonKeyDown = this.onKeyDown.bind(this), this.bindonKeyUp = this.onKeyUp.bind(this), this.bindMousewheel = this.onMousewheel.bind(this), this.needMousewheel = !1, this.moveWheelRun = !0, this.moveWheelStop = !1, this.wheelClock, this.keydown = !1, this.GetEngine = () => e; } /** * @param {Object} colliders set objects for collision detection */ set colliders(e) { this._rayCastObjects = e; } /** * @param {boolean} isEnabled set if this camera control is enabled */ set enabled(e) { this._isEnabled !== e && (this._isEnabled = e, this._euler.setFromQuaternion(this.camera.quaternion), e ? this.addEvents() : this.removeEvents()); } /** * @description: getter if current camera control is enabled. */ get enabled() { return this._isEnabled; } addEvents() { const e = this._Engine?.DeviceType, t = e === "PC" || !e; console.log("[FirstPersonCameraControl] addEvents - DeviceType:", e, "isPC:", t), t ? (console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"), this.domElement.addEventListener("mousedown", this.bindmousedown, !1), this.domElement.addEventListener("mouseup", this.bindmouseup, !1)) : (console.log("[FirstPersonCameraControl] 添加触摸事件监听器"), this.domElement.addEventListener("touchstart", this.bindmousedown, !1), this.domElement.addEventListener("touchend", this.bindmouseup, !1)), window.addEventListener("keydown", this.bindonKeyDown, !1), window.addEventListener("keyup", this.bindonKeyUp, !1), this.needMousewheel && (document.addEventListener && document.addEventListener("DOMMouseScroll", this.bindMousewheel, !1), window.addEventListener("mousewheel", this.bindMousewheel, !1)); } removeEvents() { this._Engine && this._Engine.DeviceType !== "PC" ? (this.domElement.removeEventListener("touchstart", this.bindmousedown), this.domElement.removeEventListener("touchend", this.bindmouseup), this.domElement.removeEventListener("touchmove", this.bindmousemove)) : (this.domElement.removeEventListener("mousedown", this.bindmousedown), this.domElement.removeEventListener("mouseup", this.bindmouseup), this.domElement.removeEventListener("mousemove", this.bindmousemove)), window.removeEventListener("keydown", this.bindonKeyDown), window.removeEventListener("keyup", this.bindonKeyUp), this.needMousewheel && (document.addEventListener && document.removeEventListener("DOMMouseScroll", this.bindMousewheel), window.removeEventListener("mousewheel", this.bindMousewheel)); } onMousewheel(e) { debugger; let t; switch (e.wheelDelta ? (e.wheelDelta > 0 && (t = "up"), e.wheelDelta < 0 && (t = "down")) : e.detail && (e.detail < 0 && (t = "up"), e.detail > 0 && (t = "down")), t) { case "up": this._camerLocalDirection.z = 1; break; case "down": this._camerLocalDirection.z = -1; break; } this.moveWheelRun == !0 ? (this.moveWheelRun = !1, this.moveWheelStop = !0, this.wheelClock = setTimeout(() => { this.moveWheelStop == !0 && (this.moveWheelStop = !1, this.moveWheelRun = !0, this._camerLocalDirection.z = 0); }, 200)) : (clearTimeout(this.wheelClock), this.wheelClock = setTimeout(() => { this.moveWheelStop == !0 && (this.moveWheelStop = !1, this.moveWheelRun = !0, this._camerLocalDirection.z = 0); }, 150)); } onMouseDown(e) { console.log("[FirstPersonCameraControl] onMouseDown 被调用", e), this.domElement.addEventListener("mousemove", this.bindmousemove, !1), this._prevMouseX = e.screenX, this._prevMouseY = e.screenY; } onMouseMove(e) { if (this._isEnabled == !1) return; let t = this._prevMouseX ? e.screenX - this._prevMouseX : 0, n = this._prevMouseY ? e.screenY - this._prevMouseY : 0, i = this._euler.x - n * this.lookflag * this.lookSpeed; i >= 0 ? i < this.maxRotateX ? this._euler.x = i : this._euler.x = this.maxRotateX : i > -this.maxRotateX ? this._euler.x = i : this._euler.x = -this.maxRotateX, this._euler.y -= t * this.lookSpeed, this.camera.quaternion.setFromEuler(this._euler), this._prevMouseX = e.screenX, this._prevMouseY = e.screenY; let r = this.GetEngine(); r.movefirst = !0; var a = new CustomEvent("bimengine:camerachange", { detail: "" }); window.dispatchEvent(a); } onMouseUp(e) { let t = this.GetEngine(); t.movefirst = !1, this.domElement.removeEventListener("mousemove", this.bindmousemove); } onTouchStart(e) { this.domElement.addEventListener("touchmove", this.bindmousemove, !1), this._prevMouseX = e.targetTouches[0].clientX, this._prevMouseY = e.targetTouches[0].clientY; } onTouchMove(e) { if (this._isEnabled == !1) return; let t = this._prevMouseX ? e.targetTouches[0].clientX - this._prevMouseX : 0, n = this._prevMouseY ? e.targetTouches[0].clientY - this._prevMouseY : 0, i = this._euler.x - n * this.lookflag * this.lookSpeed; i >= 0 ? i < this.maxRotateX ? this._euler.x = i : this._euler.x = this.maxRotateX : i > -this.maxRotateX ? this._euler.x = i : this._euler.x = -this.maxRotateX, this._euler.y -= t * this.lookSpeed, this.camera.quaternion.setFromEuler(this._euler), this._prevMouseX = e.targetTouches[0].clientX, this._prevMouseY = e.targetTouches[0].clientY; let r = this.GetEngine(); r.movefirst = !0; var a = new CustomEvent("bimengine:camerachange", { detail: "" }); window.dispatchEvent(a); } onTouchEnd(e) { let t = this.GetEngine(); t.movefirst = !1, this.domElement.removeEventListener("touchmove", this.bindmousemove); } onKeyDown(e) { var t = new CustomEvent("bimengine:camerachange", { detail: "" }); let n = this.GetEngine(); switch (n.movefirst = !0, window.dispatchEvent(t), e.keyCode) { case 38: this.rotateY(-1); break; case 81: this.keydown = !0, this._camerLocalDirection.y = 1; break; case 69: this._camerLocalDirection.y = -1; break; case 87: this._camerLocalDirection.z = 1; break; case 37: this.rotateX(-1); break; case 65: this._camerLocalDirection.x = -1; break; case 40: this.rotateY(1); break; case 83: this._camerLocalDirection.z = -1; break; case 39: this.rotateX(1); break; case 68: this._camerLocalDirection.x = 1; break; } } onKeyUp(e) { let t = this.GetEngine(); switch (t.movefirst = !1, e.keyCode) { case 38: // up case 87: this._camerLocalDirection.z = 0; break; case 37: // left case 65: this._camerLocalDirection.x = 0; break; case 40: // down case 83: this._camerLocalDirection.z = 0; break; case 39: // right case 68: this._camerLocalDirection.x = 0; break; case 81: case 69: this.keydown = !1, this._camerLocalDirection.y = 0; break; } } /** * @description: rotate camera by left/right * @param {Number} value * @return: null */ rotateX(e) { this._euler.y -= e * this.lookSpeed, this.camera.quaternion.setFromEuler(this._euler); } /** * @description: rotate camera by up/down * @param {Number} value * @return: null */ rotateY(e) { let t = this._euler.x - e * this.lookflag * 0.5 * this.lookSpeed; t >= 0 ? t < this.maxRotateX ? this._euler.x = t : this._euler.x = this.maxRotateX : t > -this.maxRotateX ? this._euler.x = t : this._euler.x = -this.maxRotateX, this.camera.quaternion.setFromEuler(this._euler); } /** * @description: update current calcuate each frame. */ update() { this.keydown || this.gravityTest(), this.collisionTest(); } gravityTest() { if (this.applyGravity) { let e = !0; this._fallingTime += 0.01, this._tmpVector.set(0, -1, 0); const t = this.hitTest(); if (t) { const n = t.point.add(new R(0, this.playerHeight, 0)); if (this.positionEasing) { if (n.y >= this.camera.position.y || n.y - this.camera.position.y < 0.2) { this.setCameraHeight(this.camera.position.y + (n.y - this.camera.position.y) * 0.08), this._fallingTime = 0, e = !1; return; } } else t.distance < this.playerHeight && (this.setCameraHeight(n.y), this._fallingTime = 0, e = !1); } e && this.setCameraHeight(this.camera.position.y - this.g * Math.pow(this._fallingTime, 2)); } else this.setCameraHeight(this.camera.position.y); } collisionTest() { this._camerLocalDirection.x !== 0 && this.collisionTestX(), this._camerLocalDirection.z !== 0 && this.collisionTestZ(), this._camerLocalDirection.y !== 0 && this.collisionTestY(); } collisionTestX() { let e = this.GetEngine(); if (e.movefirst = !0, this._tmpVector.setFromMatrixColumn(this.camera.matrix, 0), this._tmpVector.multiplyScalar(this._camerLocalDirection.x), this.applyCollision) { const t = this.hitTest(); if (t && t.distance < 0.3) return; } this.camera.position.addScaledVector(this._tmpVector, this.moveSpeed); } collisionTestZ() { let e = this.GetEngine(); if (e.movefirst = !0, this._tmpVector.setFromMatrixColumn(this.camera.matrix, 0), this._tmpVector.crossVectors(this.camera.up, this._tmpVector), this._tmpVector.multiplyScalar(this._camerLocalDirection.z), this.applyCollision) { const t = this.hitTest(); if (t && t.distance < 0.3) return; } this.camera.position.addScaledVector(this._tmpVector, this.moveSpeed); } collisionTestY() { let e = this.GetEngine(); if (e.movefirst = !0, this._tmpVector.setFromMatrixColumn(this.camera.matrix, 0), this._tmpVector = new R(0, 1, 0), this._tmpVector.multiplyScalar(this._camerLocalDirection.y), this.applyCollision) { const n = this.hitTest(); if (n && n.distance < 0.3) return; } let t = this.camera.position.clone().addScaledVector(this._tmpVector, this.moveSpeed); this.setCameraHeight(t.y); } // 设置相机Y方向位置 setCameraHeight(e) { let t = this.getMinHeight(); this.gravityMinHeight && t !== void 0 && e < t ? this.camera.position.y = t : this.camera.position.y = e; } // 获得所有模型最低点 getMinHeight() { let e, t = this.GetEngine(), n = t.ToolUntils ? t.ToolUntils.GetBoundingBox(t) : null; return t && n && (e = n.min.y), e; } hitTest() { const e = this.camera.position.clone().add(this._rayOriginOffset); this._rayCaster.ray.origin = e, this._rayCaster.ray.direction = this._tmpVector; var t = this.GetEngine().scene.ground; return t && t.material.type, null; } } class Mb { engine; orbitControls; firstPersonControls; isActive = !0; constructor(e) { this.engine = e, this.init(); } init() { this.orbitControls = new cb(this.engine, this.engine.camera, this.engine.renderer.domElement), this.firstPersonControls = new eu(this.engine, this.engine.camera, this.engine.renderer.domElement); } active() { this.isActive = !0, this.orbitControls.enabled = !0; } disActive() { this.isActive = !1, this.orbitControls.enabled = !1; } // 切换第一人称漫游模式 switchFirstPersonMode() { this.firstPersonControls = new eu( this.engine, this.engine.camera, this.engine.renderer.domElement, [] ), this.orbitControls.enabled = !1, this.firstPersonControls.enabled = !0, this.firstPersonControls.isActive = !0; } // 切换默认模式 switchDefaultMode() { this.firstPersonControls && (this.firstPersonControls.enabled = !1), this.orbitControls.enabled = !0; } update() { this.firstPersonControls.enabled && this.firstPersonControls.update(); } } const Ai = { name: "CopyShader", uniforms: { tDiffuse: { value: null }, opacity: { value: 1 } }, vertexShader: ( /* glsl */ ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }` ), fragmentShader: ( /* glsl */ ` uniform float opacity; uniform sampler2D tDiffuse; varying vec2 vUv; void main() { vec4 texel = texture2D( tDiffuse, vUv ); gl_FragColor = opacity * texel; }` ) }; class Hi { /** * Constructs a new pass. */ constructor() { this.isPass = !0, this.enabled = !0, this.needsSwap = !0, this.clear = !1, this.renderToScreen = !1; } /** * Sets the size of the pass. * * @abstract * @param {number} width - The width to set. * @param {number} height - The height to set. */ setSize() { } /** * This method holds the render logic of a pass. It must be implemented in all derived classes. * * @abstract * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render() { console.error("THREE.Pass: .render() must be implemented in derived pass."); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever the pass is no longer used in your app. * * @abstract */ dispose() { } } const Sb = new zi(-1, 1, 1, -1, 0, 1); class wb extends xt { constructor() { super(), this.setAttribute("position", new an([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3)), this.setAttribute("uv", new an([0, 2, 0, 0, 2, 0], 2)); } } const Eb = new wb(); class Ia { /** * Constructs a new full screen quad. * * @param {?Material} material - The material to render te full screen quad with. */ constructor(e) { this._mesh = new ft(Eb, e); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever the instance is no longer used in your app. */ dispose() { this._mesh.geometry.dispose(); } /** * Renders the full screen quad. * * @param {WebGLRenderer} renderer - The renderer. */ render(e) { e.render(this._mesh, Sb); } /** * The quad's material. * * @type {?Material} */ get material() { return this._mesh.material; } set material(e) { this._mesh.material = e; } } class pa extends Hi { /** * Constructs a new shader pass. * * @param {Object|ShaderMaterial} [shader] - A shader object holding vertex and fragment shader as well as * defines and uniforms. It's also valid to pass a custom shader material. * @param {string} [textureID='tDiffuse'] - The name of the texture uniform that should sample * the read buffer. */ constructor(e, t = "tDiffuse") { super(), this.textureID = t, this.uniforms = null, this.material = null, e instanceof Pt ? (this.uniforms = e.uniforms, this.material = e) : e && (this.uniforms = zn.clone(e.uniforms), this.material = new Pt({ 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 Ia(this.material); } /** * Performs the shader pass. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render(e, t, n) { this.uniforms[this.textureID] && (this.uniforms[this.textureID].value = n.texture), this._fsQuad.material = this.material, this.renderToScreen ? (e.setRenderTarget(null), this._fsQuad.render(e)) : (e.setRenderTarget(t), this.clear && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), this._fsQuad.render(e)); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever the pass is no longer used in your app. */ dispose() { this.material.dispose(), this._fsQuad.dispose(); } } class tu extends Hi { /** * Constructs a new mask pass. * * @param {Scene} scene - The 3D objects in this scene will define the mask. * @param {Camera} camera - The camera. */ constructor(e, t) { super(), this.scene = e, this.camera = t, this.clear = !0, this.needsSwap = !1, this.inverse = !1; } /** * Performs a mask pass with the configured scene and camera. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render(e, t, n) { const i = e.getContext(), r = e.state; r.buffers.color.setMask(!1), r.buffers.depth.setMask(!1), r.buffers.color.setLocked(!0), r.buffers.depth.setLocked(!0); let a, o; this.inverse ? (a = 0, o = 1) : (a = 1, o = 0), r.buffers.stencil.setTest(!0), r.buffers.stencil.setOp(i.REPLACE, i.REPLACE, i.REPLACE), r.buffers.stencil.setFunc(i.ALWAYS, a, 4294967295), r.buffers.stencil.setClear(o), r.buffers.stencil.setLocked(!0), e.setRenderTarget(n), this.clear && e.clear(), e.render(this.scene, this.camera), e.setRenderTarget(t), this.clear && e.clear(), e.render(this.scene, this.camera), r.buffers.color.setLocked(!1), r.buffers.depth.setLocked(!1), r.buffers.color.setMask(!0), r.buffers.depth.setMask(!0), r.buffers.stencil.setLocked(!1), r.buffers.stencil.setFunc(i.EQUAL, 1, 4294967295), r.buffers.stencil.setOp(i.KEEP, i.KEEP, i.KEEP), r.buffers.stencil.setLocked(!0); } } class Tb extends Hi { /** * Constructs a new clear mask pass. */ constructor() { super(), this.needsSwap = !1; } /** * Performs the clear of the currently defined mask. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render(e) { e.state.buffers.stencil.setLocked(!1), e.state.buffers.stencil.setTest(!1); } } class Cb { /** * Constructs a new effect composer. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} [renderTarget] - This render target and a clone will * be used as the internal read and write buffers. If not given, the composer creates * the buffers automatically. */ constructor(e, t) { if (this.renderer = e, this._pixelRatio = e.getPixelRatio(), t === void 0) { const n = e.getSize(new ue()); this._width = n.width, this._height = n.height, t = new rn(this._width * this._pixelRatio, this._height * this._pixelRatio, { type: _n }), 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 pa(Ai), this.copyPass.material.blending = Ot, this.clock = new o0(); } /** * Swaps the internal read/write buffers. */ swapBuffers() { const e = this.readBuffer; this.readBuffer = this.writeBuffer, this.writeBuffer = e; } /** * Adds the given pass to the pass chain. * * @param {Pass} pass - The pass to add. */ addPass(e) { this.passes.push(e), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio); } /** * Inserts the given pass at a given index. * * @param {Pass} pass - The pass to insert. * @param {number} index - The index into the pass chain. */ insertPass(e, t) { this.passes.splice(t, 0, e), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio); } /** * Removes the given pass from the pass chain. * * @param {Pass} pass - The pass to remove. */ removePass(e) { const t = this.passes.indexOf(e); t !== -1 && this.passes.splice(t, 1); } /** * Returns `true` if the pass for the given index is the last enabled pass in the pass chain. * * @param {number} passIndex - The pass index. * @return {boolean} Whether the pass for the given index is the last pass in the pass chain. */ isLastEnabledPass(e) { for (let t = e + 1; t < this.passes.length; t++) if (this.passes[t].enabled) return !1; return !0; } /** * Executes all enabled post-processing passes in order to produce the final frame. * * @param {number} deltaTime - The delta time in seconds. If not given, the composer computes * its own time delta value. */ render(e) { e === void 0 && (e = this.clock.getDelta()); const t = this.renderer.getRenderTarget(); let n = !1; for (let i = 0, r = this.passes.length; i < r; i++) { const a = this.passes[i]; if (a.enabled !== !1) { if (a.renderToScreen = this.renderToScreen && this.isLastEnabledPass(i), a.render(this.renderer, this.writeBuffer, this.readBuffer, e, n), a.needsSwap) { if (n) { const o = this.renderer.getContext(), l = this.renderer.state.buffers.stencil; l.setFunc(o.NOTEQUAL, 1, 4294967295), this.copyPass.render(this.renderer, this.writeBuffer, this.readBuffer, e), l.setFunc(o.EQUAL, 1, 4294967295); } this.swapBuffers(); } tu !== void 0 && (a instanceof tu ? n = !0 : a instanceof Tb && (n = !1)); } } this.renderer.setRenderTarget(t); } /** * Resets the internal state of the EffectComposer. * * @param {WebGLRenderTarget} [renderTarget] - This render target has the same purpose like * the one from the constructor. If set, it is used to setup the read and write buffers. */ reset(e) { if (e === void 0) { const t = this.renderer.getSize(new ue()); 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; } /** * Resizes the internal read and write buffers as well as all passes. Similar to {@link WebGLRenderer#setSize}, * this method honors the current pixel ration. * * @param {number} width - The width in logical pixels. * @param {number} height - The height in logical pixels. */ setSize(e, t) { this._width = e, this._height = t; const n = this._width * this._pixelRatio, i = this._height * this._pixelRatio; this.renderTarget1.setSize(n, i), this.renderTarget2.setSize(n, i); for (let r = 0; r < this.passes.length; r++) this.passes[r].setSize(n, i); } /** * Sets device pixel ratio. This is usually used for HiDPI device to prevent blurring output. * Setting the pixel ratio will automatically resize the composer. * * @param {number} pixelRatio - The pixel ratio to set. */ setPixelRatio(e) { this._pixelRatio = e, this.setSize(this._width, this._height); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever the composer is no longer used in your app. */ dispose() { this.renderTarget1.dispose(), this.renderTarget2.dispose(), this.copyPass.dispose(); } } class Ab extends Hi { /** * Constructs a new render pass. * * @param {Scene} scene - The scene to render. * @param {Camera} camera - The camera. * @param {?Material} [overrideMaterial=null] - The override material. If set, this material is used * for all objects in the scene. * @param {?(number|Color|string)} [clearColor=null] - The clear color of the render pass. * @param {?number} [clearAlpha=null] - The clear alpha of the render pass. */ constructor(e, t, n = null, i = null, r = null) { super(), this.scene = e, this.camera = t, this.overrideMaterial = n, this.clearColor = i, this.clearAlpha = r, this.clear = !0, this.clearDepth = !1, this.needsSwap = !1, this._oldClearColor = new Fe(); } /** * Performs a beauty pass with the configured scene and camera. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render(e, t, n) { const i = e.autoClear; e.autoClear = !1; let r, a; this.overrideMaterial !== null && (a = this.scene.overrideMaterial, this.scene.overrideMaterial = this.overrideMaterial), this.clearColor !== null && (e.getClearColor(this._oldClearColor), e.setClearColor(this.clearColor, e.getClearAlpha())), this.clearAlpha !== null && (r = e.getClearAlpha(), e.setClearAlpha(this.clearAlpha)), this.clearDepth == !0 && e.clearDepth(), e.setRenderTarget(this.renderToScreen ? null : n), this.clear === !0 && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), e.render(this.scene, this.camera), this.clearColor !== null && e.setClearColor(this._oldClearColor), this.clearAlpha !== null && e.setClearAlpha(r), this.overrideMaterial !== null && (this.scene.overrideMaterial = a), e.autoClear = i; } } const Jr = { 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 ue() }, cameraNear: { value: null }, cameraFar: { value: null }, cameraProjectionMatrix: { value: new je() }, cameraProjectionMatrixInverse: { value: new je() }, cameraWorldMatrix: { value: new je() }, radius: { value: 0.25 }, distanceExponent: { value: 1 }, thickness: { value: 1 }, distanceFallOff: { value: 1 }, scale: { value: 1 }, sceneBoxMin: { value: new R(-1, -1, -1) }, sceneBoxMax: { value: new R(1, 1, 1) } }, vertexShader: ( /* glsl */ ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }` ), fragmentShader: ( /* glsl */ ` 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 #include #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; }` ) }, Qr = { defines: { PERSPECTIVE_CAMERA: 1 }, uniforms: { tDepth: { value: null }, cameraNear: { value: null }, cameraFar: { value: null } }, vertexShader: ( /* glsl */ ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }` ), fragmentShader: ( /* glsl */ ` uniform sampler2D tDepth; uniform float cameraNear; uniform float cameraFar; varying vec2 vUv; #include 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 ); }` ) }, Po = { uniforms: { tDiffuse: { value: null }, intensity: { value: 1 } }, vertexShader: ( /* glsl */ ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }` ), fragmentShader: ( /* glsl */ ` 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 Pb(s = 5) { const e = Math.floor(s) % 2 === 0 ? Math.floor(s) + 1 : Math.floor(s), t = Rb(e), n = t.length, i = new Uint8Array(n * 4); for (let a = 0; a < n; ++a) { const o = t[a], l = 2 * Math.PI * o / n, c = new R( Math.cos(l), Math.sin(l), 0 ).normalize(); i[a * 4] = (c.x * 0.5 + 0.5) * 255, i[a * 4 + 1] = (c.y * 0.5 + 0.5) * 255, i[a * 4 + 2] = 127, i[a * 4 + 3] = 255; } const r = new pr(i, e, e); return r.wrapS = Gn, r.wrapT = Gn, r.needsUpdate = !0, r; } function Rb(s) { const e = Math.floor(s) % 2 === 0 ? Math.floor(s) + 1 : Math.floor(s), t = e * e, n = Array(t).fill(0); let i = Math.floor(e / 2), r = e - 1; for (let a = 1; a <= t; ) { if (i === -1 && r === e ? (r = e - 2, i = 0) : (r === e && (r = 0), i < 0 && (i = e - 1)), n[i * e + r] !== 0) { r -= 2, i++; continue; } else n[i * e + r] = a++; r++, i--; } return n; } const ea = { defines: { SAMPLES: 16, SAMPLE_VECTORS: Dd(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 ue() }, cameraProjectionMatrixInverse: { value: new je() }, lumaPhi: { value: 5 }, depthPhi: { value: 5 }, normalPhi: { value: 5 }, radius: { value: 4 }, index: { value: 0 } }, vertexShader: ( /* glsl */ ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }` ), fragmentShader: ( /* glsl */ ` 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 #include #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 Dd(s, e, t) { const n = Lb( s, e, t ); let i = "vec3[SAMPLES]("; for (let r = 0; r < s; r++) { const a = n[r]; i += `vec3(${a.x}, ${a.y}, ${a.z})${r < s - 1 ? "," : ")"}`; } return i; } function Lb(s, e, t) { const n = []; for (let i = 0; i < s; i++) { const r = 2 * Math.PI * e * i / s, a = Math.pow(i / (s - 1), t); n.push(new R(Math.cos(r), Math.sin(r), a)); } return n; } class Db { /** * Constructs a new simplex noise object. * * @param {Object} [r=Math] - A math utility class that holds a `random()` method. This makes it * possible to pass in custom random number generator. */ 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] ]; } /** * A 2D simplex noise method. * * @param {number} xin - The x coordinate. * @param {number} yin - The y coordinate. * @return {number} The noise value. */ noise(e, t) { let n, i, r; const a = 0.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, f = l - u, d = c - u, p = e - f, g = t - d; let x, m; p > g ? (x = 1, m = 0) : (x = 0, m = 1); const v = p - x + h, b = g - m + h, M = p - 1 + 2 * h, C = g - 1 + 2 * h, T = l & 255, D = c & 255, U = this.perm[T + this.perm[D]] % 12, S = this.perm[T + x + this.perm[D + m]] % 12, w = this.perm[T + 1 + this.perm[D + 1]] % 12; let B = 0.5 - p * p - g * g; B < 0 ? n = 0 : (B *= B, n = B * B * this._dot(this.grad3[U], p, g)); let P = 0.5 - v * v - b * b; P < 0 ? i = 0 : (P *= P, i = P * P * this._dot(this.grad3[S], v, b)); let O = 0.5 - M * M - C * C; return O < 0 ? r = 0 : (O *= O, r = O * O * this._dot(this.grad3[w], M, C)), 70 * (n + i + r); } /** * A 3D simplex noise method. * * @param {number} xin - The x coordinate. * @param {number} yin - The y coordinate. * @param {number} zin - The z coordinate. * @return {number} The noise value. */ noise3d(e, t, n) { let i, r, a, o; const l = (e + t + n) * 0.3333333333333333, c = Math.floor(e + l), h = Math.floor(t + l), u = Math.floor(n + l), f = 1 / 6, d = (c + h + u) * f, p = c - d, g = h - d, x = u - d, m = e - p, v = t - g, b = n - x; let M, C, T, D, U, S; m >= v ? v >= b ? (M = 1, C = 0, T = 0, D = 1, U = 1, S = 0) : m >= b ? (M = 1, C = 0, T = 0, D = 1, U = 0, S = 1) : (M = 0, C = 0, T = 1, D = 1, U = 0, S = 1) : v < b ? (M = 0, C = 0, T = 1, D = 0, U = 1, S = 1) : m < b ? (M = 0, C = 1, T = 0, D = 0, U = 1, S = 1) : (M = 0, C = 1, T = 0, D = 1, U = 1, S = 0); const w = m - M + f, B = v - C + f, P = b - T + f, O = m - D + 2 * f, y = v - U + 2 * f, H = b - S + 2 * f, Y = m - 1 + 3 * f, j = v - 1 + 3 * f, J = b - 1 + 3 * f, Z = c & 255, ae = h & 255, X = u & 255, q = this.perm[Z + this.perm[ae + this.perm[X]]] % 12, ge = this.perm[Z + M + this.perm[ae + C + this.perm[X + T]]] % 12, pe = this.perm[Z + D + this.perm[ae + U + this.perm[X + S]]] % 12, de = this.perm[Z + 1 + this.perm[ae + 1 + this.perm[X + 1]]] % 12; let ie = 0.6 - m * m - v * v - b * b; ie < 0 ? i = 0 : (ie *= ie, i = ie * ie * this._dot3(this.grad3[q], m, v, b)); let ce = 0.6 - w * w - B * B - P * P; ce < 0 ? r = 0 : (ce *= ce, r = ce * ce * this._dot3(this.grad3[ge], w, B, P)); let fe = 0.6 - O * O - y * y - H * H; fe < 0 ? a = 0 : (fe *= fe, a = fe * fe * this._dot3(this.grad3[pe], O, y, H)); let ve = 0.6 - Y * Y - j * j - J * J; return ve < 0 ? o = 0 : (ve *= ve, o = ve * ve * this._dot3(this.grad3[de], Y, j, J)), 32 * (i + r + a + o); } /** * A 4D simplex noise method. * * @param {number} x - The x coordinate. * @param {number} y - The y coordinate. * @param {number} z - The z coordinate. * @param {number} w - The w coordinate. * @return {number} The noise value. */ noise4d(e, t, n, i) { const r = this.grad4, a = this.simplex, o = this.perm, l = (Math.sqrt(5) - 1) / 4, c = (5 - Math.sqrt(5)) / 20; let h, u, f, d, p; const g = (e + t + n + i) * l, x = Math.floor(e + g), m = Math.floor(t + g), v = Math.floor(n + g), b = Math.floor(i + g), M = (x + m + v + b) * c, C = x - M, T = m - M, D = v - M, U = b - M, S = e - C, w = t - T, B = n - D, P = i - U, O = S > w ? 32 : 0, y = S > B ? 16 : 0, H = w > B ? 8 : 0, Y = S > P ? 4 : 0, j = w > P ? 2 : 0, J = B > P ? 1 : 0, Z = O + y + H + Y + j + J, ae = a[Z][0] >= 3 ? 1 : 0, X = a[Z][1] >= 3 ? 1 : 0, q = a[Z][2] >= 3 ? 1 : 0, ge = a[Z][3] >= 3 ? 1 : 0, pe = a[Z][0] >= 2 ? 1 : 0, de = a[Z][1] >= 2 ? 1 : 0, ie = a[Z][2] >= 2 ? 1 : 0, ce = a[Z][3] >= 2 ? 1 : 0, fe = a[Z][0] >= 1 ? 1 : 0, ve = a[Z][1] >= 1 ? 1 : 0, Ee = a[Z][2] >= 1 ? 1 : 0, Ne = a[Z][3] >= 1 ? 1 : 0, Ye = S - ae + c, ke = w - X + c, _ = B - q + c, A = P - ge + c, V = S - pe + 2 * c, N = w - de + 2 * c, I = B - ie + 2 * c, F = P - ce + 2 * c, ee = S - fe + 3 * c, $ = w - ve + 3 * c, G = B - Ee + 3 * c, L = P - Ne + 3 * c, E = S - 1 + 4 * c, z = w - 1 + 4 * c, K = B - 1 + 4 * c, le = P - 1 + 4 * c, te = x & 255, Te = m & 255, be = v & 255, Re = b & 255, De = o[te + o[Te + o[be + o[Re]]]] % 32, he = o[te + ae + o[Te + X + o[be + q + o[Re + ge]]]] % 32, _e = o[te + pe + o[Te + de + o[be + ie + o[Re + ce]]]] % 32, He = o[te + fe + o[Te + ve + o[be + Ee + o[Re + Ne]]]] % 32, Ue = o[te + 1 + o[Te + 1 + o[be + 1 + o[Re + 1]]]] % 32; let Ce = 0.6 - S * S - w * w - B * B - P * P; Ce < 0 ? h = 0 : (Ce *= Ce, h = Ce * Ce * this._dot4(r[De], S, w, B, P)); let Ve = 0.6 - Ye * Ye - ke * ke - _ * _ - A * A; Ve < 0 ? u = 0 : (Ve *= Ve, u = Ve * Ve * this._dot4(r[he], Ye, ke, _, A)); let W = 0.6 - V * V - N * N - I * I - F * F; W < 0 ? f = 0 : (W *= W, f = W * W * this._dot4(r[_e], V, N, I, F)); let we = 0.6 - ee * ee - $ * $ - G * G - L * L; we < 0 ? d = 0 : (we *= we, d = we * we * this._dot4(r[He], ee, $, G, L)); let ye = 0.6 - E * E - z * z - K * K - le * le; return ye < 0 ? p = 0 : (ye *= ye, p = ye * ye * this._dot4(r[Ue], E, z, K, le)), 27 * (h + u + f + d + p); } // private _dot(e, t, n) { return e[0] * t + e[1] * n; } _dot3(e, t, n, i) { return e[0] * t + e[1] * n + e[2] * i; } _dot4(e, t, n, i, r) { return e[0] * t + e[1] * n + e[2] * i + e[3] * r; } } class nn extends Hi { /** * Constructs a new GTAO pass. * * @param {Scene} scene - The scene to compute the AO for. * @param {Camera} camera - The camera. * @param {number} [width=512] - The width of the effect. * @param {number} [height=512] - The height of the effect. * @param {Object} [parameters] - The pass parameters. * @param {Object} [aoParameters] - The AO parameters. * @param {Object} [pdParameters] - The denoise parameters. */ constructor(e, t, n = 512, i = 512, r, a, o) { super(), this.width = n, this.height = i, this.clear = !0, this.camera = t, this.scene = e, this.output = 0, this._renderGBuffer = !0, this._visibilityCache = [], this.blendIntensity = 1, this.pdRings = 2, this.pdRadiusExponent = 2, this.pdSamples = 16, this.gtaoNoiseTexture = Pb(), this.pdNoiseTexture = this._generateNoise(), this.gtaoRenderTarget = new rn(this.width, this.height, { type: _n }), this.pdRenderTarget = this.gtaoRenderTarget.clone(), this.gtaoMaterial = new Pt({ defines: Object.assign({}, Jr.defines), uniforms: zn.clone(Jr.uniforms), vertexShader: Jr.vertexShader, fragmentShader: Jr.fragmentShader, blending: Ot, 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 Om(), this.normalMaterial.blending = Ot, this.pdMaterial = new Pt({ defines: Object.assign({}, ea.defines), uniforms: zn.clone(ea.uniforms), vertexShader: ea.vertexShader, fragmentShader: ea.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 Pt({ defines: Object.assign({}, Qr.defines), uniforms: zn.clone(Qr.uniforms), vertexShader: Qr.vertexShader, fragmentShader: Qr.fragmentShader, blending: Ot }), this.depthRenderMaterial.uniforms.cameraNear.value = this.camera.near, this.depthRenderMaterial.uniforms.cameraFar.value = this.camera.far, this.copyMaterial = new Pt({ uniforms: zn.clone(Ai.uniforms), vertexShader: Ai.vertexShader, fragmentShader: Ai.fragmentShader, transparent: !0, depthTest: !1, depthWrite: !1, blendSrc: Go, blendDst: Xs, blendEquation: Tn, blendSrcAlpha: Vo, blendDstAlpha: Xs, blendEquationAlpha: Tn }), this.blendMaterial = new Pt({ uniforms: zn.clone(Po.uniforms), vertexShader: Po.vertexShader, fragmentShader: Po.fragmentShader, transparent: !0, depthTest: !1, depthWrite: !1, blending: ku, blendSrc: Go, blendDst: Xs, blendEquation: Tn, blendSrcAlpha: Vo, blendDstAlpha: Xs, blendEquationAlpha: Tn }), this._fsQuad = new Ia(null), this._originalClearColor = new Fe(), this.setGBuffer(r ? r.depthTexture : void 0, r ? r.normalTexture : void 0), a !== void 0 && this.updateGtaoMaterial(a), o !== void 0 && this.updatePdMaterial(o); } /** * Sets the size of the pass. * * @param {number} width - The width to set. * @param {number} height - The height to set. */ 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); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever the pass is no longer used in your app. */ 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(); } /** * A texture holding the computed AO. * * @type {Texture} * @readonly */ get gtaoMap() { return this.pdRenderTarget.texture; } /** * Configures the GBuffer of this pass. If no arguments are passed, * the pass creates an internal render target for holding depth * and normal data. * * @param {DepthTexture} [depthTexture] - The depth texture. * @param {DepthTexture} [normalTexture] - The normal texture. */ setGBuffer(e, t) { e !== void 0 ? (this.depthTexture = e, this.normalTexture = t, this._renderGBuffer = !1) : (this.depthTexture = new cc(), this.depthTexture.format = xs, this.depthTexture.type = gs, this.normalRenderTarget = new rn(this.width, this.height, { minFilter: Gt, magFilter: Gt, type: _n, depthTexture: this.depthTexture }), this.normalTexture = this.normalRenderTarget.texture, this._renderGBuffer = !0); const n = this.normalTexture ? 1 : 0, i = this.depthTexture === this.normalTexture ? "w" : "x"; this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE = n, this.gtaoMaterial.defines.DEPTH_SWIZZLING = i, this.gtaoMaterial.uniforms.tNormal.value = this.normalTexture, this.gtaoMaterial.uniforms.tDepth.value = this.depthTexture, this.pdMaterial.defines.NORMAL_VECTOR_TYPE = n, this.pdMaterial.defines.DEPTH_SWIZZLING = i, this.pdMaterial.uniforms.tNormal.value = this.normalTexture, this.pdMaterial.uniforms.tDepth.value = this.depthTexture, this.depthRenderMaterial.uniforms.tDepth.value = this.normalRenderTarget.depthTexture; } /** * Configures the clip box of the GTAO shader with the given AABB. * * @param {?Box3} box - The AABB enclosing the scene that should receive AO. When passing * `null`, to clip box is used. */ 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); } /** * Updates the GTAO material from the given parameter object. * * @param {Object} parameters - The GTAO material parameters. */ 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); } /** * Updates the Denoise material from the given parameter object. * * @param {Object} parameters - The denoise parameters. */ 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 = Dd(this.pdSamples, this.pdRings, this.pdRadiusExponent), this.pdMaterial.needsUpdate = !0); } /** * Performs the GTAO pass. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render(e, t, n) { switch (this._renderGBuffer && (this._overrideVisibility(), this._renderOverride(e, this.normalMaterial, this.normalRenderTarget, 7829503, 1), this._restoreVisibility()), this.gtaoMaterial.uniforms.cameraNear.value = this.camera.near, this.gtaoMaterial.uniforms.cameraFar.value = this.camera.far, this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix), this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse), this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld), this._renderPass(e, this.gtaoMaterial, this.gtaoRenderTarget, 16777215, 1), this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse), this._renderPass(e, this.pdMaterial, this.pdRenderTarget, 16777215, 1), this.output) { case nn.OUTPUT.Off: break; case nn.OUTPUT.Diffuse: this.copyMaterial.uniforms.tDiffuse.value = n.texture, this.copyMaterial.blending = Ot, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t); break; case nn.OUTPUT.AO: this.copyMaterial.uniforms.tDiffuse.value = this.gtaoRenderTarget.texture, this.copyMaterial.blending = Ot, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t); break; case nn.OUTPUT.Denoise: this.copyMaterial.uniforms.tDiffuse.value = this.pdRenderTarget.texture, this.copyMaterial.blending = Ot, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t); break; case nn.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 nn.OUTPUT.Normal: this.copyMaterial.uniforms.tDiffuse.value = this.normalRenderTarget.texture, this.copyMaterial.blending = Ot, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t); break; case nn.OUTPUT.Default: this.copyMaterial.uniforms.tDiffuse.value = n.texture, this.copyMaterial.blending = Ot, 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."); } } // internals _renderPass(e, t, n, i, r) { e.getClearColor(this._originalClearColor); const a = e.getClearAlpha(), o = e.autoClear; e.setRenderTarget(n), e.autoClear = !1, i != null && (e.setClearColor(i), e.setClearAlpha(r || 0), e.clear()), this._fsQuad.material = t, this._fsQuad.render(e), e.autoClear = o, e.setClearColor(this._originalClearColor), e.setClearAlpha(a); } _renderOverride(e, t, n, i, r) { e.getClearColor(this._originalClearColor); const a = e.getClearAlpha(), o = e.autoClear; e.setRenderTarget(n), e.autoClear = !1, i = t.clearColor || i, r = t.clearAlpha || r, i != null && (e.setClearColor(i), e.setClearAlpha(r || 0), e.clear()), this.scene.overrideMaterial = t, e.render(this.scene, this.camera), this.scene.overrideMaterial = null, e.autoClear = o, e.setClearColor(this._originalClearColor), e.setClearAlpha(a); } _overrideVisibility() { const e = this.scene, t = this._visibilityCache; e.traverse(function(n) { (n.isPoints || n.isLine || n.isLine2) && n.visible && (n.visible = !1, t.push(n)); }); } _restoreVisibility() { const e = this._visibilityCache; for (let t = 0; t < e.length; t++) e[t].visible = !0; e.length = 0; } _generateNoise(e = 64) { const t = new Db(), n = e * e * 4, i = new Uint8Array(n); for (let a = 0; a < e; a++) for (let o = 0; o < e; o++) { const l = a, c = o; i[(a * e + o) * 4] = (t.noise(l, c) * 0.5 + 0.5) * 255, i[(a * e + o) * 4 + 1] = (t.noise(l + e, c) * 0.5 + 0.5) * 255, i[(a * e + o) * 4 + 2] = (t.noise(l, c + e) * 0.5 + 0.5) * 255, i[(a * e + o) * 4 + 3] = (t.noise(l + e, c + e) * 0.5 + 0.5) * 255; } const r = new pr(i, e, e, sn, Ln); return r.wrapS = Gn, r.wrapT = Gn, r.needsUpdate = !0, r; } } nn.OUTPUT = { Off: -1, Default: 0, Diffuse: 1, Depth: 2, Normal: 3, AO: 4, Denoise: 5 }; const Ib = { uniforms: { tDiffuse: { value: null }, luminosityThreshold: { value: 1 }, smoothWidth: { value: 1 }, defaultColor: { value: new Fe(0) }, defaultOpacity: { value: 0 } }, vertexShader: ( /* glsl */ ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }` ), fragmentShader: ( /* glsl */ ` 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 ws extends Hi { /** * Constructs a new Unreal Bloom pass. * * @param {Vector2} [resolution] - The effect's resolution. * @param {number} [strength=1] - The Bloom strength. * @param {number} radius - The Bloom radius. * @param {number} threshold - The luminance threshold limits which bright areas contribute to the Bloom effect. */ constructor(e, t = 1, n, i) { super(), this.strength = t, this.radius = n, this.threshold = i, this.resolution = e !== void 0 ? new ue(e.x, e.y) : new ue(256, 256), this.clearColor = new Fe(0, 0, 0), this.needsSwap = !1, this.renderTargetsHorizontal = [], this.renderTargetsVertical = [], this.nMips = 5; let r = Math.round(this.resolution.x / 2), a = Math.round(this.resolution.y / 2); this.renderTargetBright = new rn(r, a, { type: _n }), this.renderTargetBright.texture.name = "UnrealBloomPass.bright", this.renderTargetBright.texture.generateMipmaps = !1; for (let h = 0; h < this.nMips; h++) { const u = new rn(r, a, { type: _n }); u.texture.name = "UnrealBloomPass.h" + h, u.texture.generateMipmaps = !1, this.renderTargetsHorizontal.push(u); const f = new rn(r, a, { type: _n }); f.texture.name = "UnrealBloomPass.v" + h, f.texture.generateMipmaps = !1, this.renderTargetsVertical.push(f), r = Math.round(r / 2), a = Math.round(a / 2); } const o = Ib; this.highPassUniforms = zn.clone(o.uniforms), this.highPassUniforms.luminosityThreshold.value = i, this.highPassUniforms.smoothWidth.value = 0.01, this.materialHighPassFilter = new Pt({ uniforms: this.highPassUniforms, vertexShader: o.vertexShader, fragmentShader: o.fragmentShader }), this.separableBlurMaterials = []; const l = [6, 10, 14, 18, 22]; r = 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 ue(1 / r, 1 / a), r = Math.round(r / 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 = 0.1; const c = [1, 0.8, 0.6, 0.4, 0.2]; this.compositeMaterial.uniforms.bloomFactors.value = c, this.bloomTintColors = [new R(1, 1, 1), new R(1, 1, 1), new R(1, 1, 1), new R(1, 1, 1), new R(1, 1, 1)], this.compositeMaterial.uniforms.bloomTintColors.value = this.bloomTintColors, this.copyUniforms = zn.clone(Ai.uniforms), this.blendMaterial = new Pt({ uniforms: this.copyUniforms, vertexShader: Ai.vertexShader, fragmentShader: Ai.fragmentShader, blending: Fo, depthTest: !1, depthWrite: !1, transparent: !0 }), this._oldClearColor = new Fe(), this._oldClearAlpha = 1, this._basic = new Nt(), this._fsQuad = new Ia(null); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever the pass is no longer used in your app. */ 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(); } /** * Sets the size of the pass. * * @param {number} width - The width to set. * @param {number} height - The height to set. */ setSize(e, t) { let n = Math.round(e / 2), i = Math.round(t / 2); this.renderTargetBright.setSize(n, i); for (let r = 0; r < this.nMips; r++) this.renderTargetsHorizontal[r].setSize(n, i), this.renderTargetsVertical[r].setSize(n, i), this.separableBlurMaterials[r].uniforms.invSize.value = new ue(1 / n, 1 / i), n = Math.round(n / 2), i = Math.round(i / 2); } /** * Performs the Bloom pass. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render(e, t, n, i, r) { e.getClearColor(this._oldClearColor), this._oldClearAlpha = e.getClearAlpha(); const a = e.autoClear; e.autoClear = !1, e.setClearColor(this.clearColor, 0), r && e.state.buffers.stencil.setTest(!1), this.renderToScreen && (this._fsQuad.material = this._basic, this._basic.map = n.texture, e.setRenderTarget(null), e.clear(), this._fsQuad.render(e)), this.highPassUniforms.tDiffuse.value = n.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 = ws.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 = ws.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, r && e.state.buffers.stencil.setTest(!0), this.renderToScreen ? (e.setRenderTarget(null), this._fsQuad.render(e)) : (e.setRenderTarget(n), this._fsQuad.render(e)), e.setClearColor(this._oldClearColor, this._oldClearAlpha), e.autoClear = a; } // internals _getSeparableBlurMaterial(e) { const t = [], n = e / 3; for (let i = 0; i < e; i++) t.push(0.39894 * Math.exp(-0.5 * i * i / (n * n)) / n); return new Pt({ defines: { KERNEL_RADIUS: e }, uniforms: { colorTexture: { value: null }, invSize: { value: new ue(0.5, 0.5) }, // inverse texture size direction: { value: new ue(0.5, 0.5) }, gaussianCoefficients: { value: t } // precomputed Gaussian coefficients }, vertexShader: `varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`, fragmentShader: `#include 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 Pt({ 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) ); }` }); } } ws.BlurDirectionX = new ue(1, 0); ws.BlurDirectionY = new ue(0, 1); const ta = { name: "OutputShader", uniforms: { tDiffuse: { value: null }, toneMappingExposure: { value: 1 } }, vertexShader: ( /* glsl */ ` 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: ( /* glsl */ ` precision highp float; uniform sampler2D tDiffuse; #include #include 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 Nb extends Hi { /** * Constructs a new output pass. */ constructor() { super(), this.uniforms = zn.clone(ta.uniforms), this.material = new Um({ name: ta.name, uniforms: this.uniforms, vertexShader: ta.vertexShader, fragmentShader: ta.fragmentShader }), this._fsQuad = new Ia(this.material), this._outputColorSpace = null, this._toneMapping = null; } /** * Performs the output pass. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render(e, t, n) { this.uniforms.tDiffuse.value = n.texture, this.uniforms.toneMappingExposure.value = e.toneMappingExposure, (this._outputColorSpace !== e.outputColorSpace || this._toneMapping !== e.toneMapping) && (this._outputColorSpace = e.outputColorSpace, this._toneMapping = e.toneMapping, this.material.defines = {}, it.getTransfer(this._outputColorSpace) === ot && (this.material.defines.SRGB_TRANSFER = ""), this._toneMapping === Uu ? this.material.defines.LINEAR_TONE_MAPPING = "" : this._toneMapping === Bu ? this.material.defines.REINHARD_TONE_MAPPING = "" : this._toneMapping === Ou ? this.material.defines.CINEON_TONE_MAPPING = "" : this._toneMapping === ql ? this.material.defines.ACES_FILMIC_TONE_MAPPING = "" : this._toneMapping === zu ? this.material.defines.AGX_TONE_MAPPING = "" : this._toneMapping === Hu ? this.material.defines.NEUTRAL_TONE_MAPPING = "" : this._toneMapping === Fu && (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)); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever the pass is no longer used in your app. */ dispose() { this.material.dispose(), this._fsQuad.dispose(); } } const kb = { name: "FXAAShader", uniforms: { tDiffuse: { value: null }, resolution: { value: new ue(1 / 1024, 1 / 512) } }, vertexShader: ( /* glsl */ ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }` ), fragmentShader: ( /* glsl */ ` 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 ); }` ) }, Ub = { uniforms: { tDiffuse: { value: null }, saturation: { value: 1.2 }, // 饱和度值,1.0为原始,大于1.0增加饱和度 contrast: { value: 1.2 } // 对比度值,1.0为原始,大于1.0增加对比度 }, vertexShader: ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `, fragmentShader: ` uniform sampler2D tDiffuse; uniform float saturation; uniform float contrast; varying vec2 vUv; void main() { vec4 color = texture2D(tDiffuse, vUv); // 转换为灰度值用于饱和度调整 float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114)); // 混合原始颜色和灰度值来调整饱和度 color.rgb = mix(vec3(gray), color.rgb, saturation); // 调整对比度 color.rgb = (color.rgb - 0.5) * contrast + 0.5; gl_FragColor = color; } ` }; class Bb { engine; composer; saturationPass; constructor(e) { this.engine = e; } resize() { const { width: e, height: t } = this.engine.deviceModule.getContainerSize(), n = e / t; if (this.composer) { this.composer.setPixelRatio(n), this.composer.setSize(e, t); const i = this.composer.passes.find((r) => r instanceof pa && r.material.uniforms.resolution); i && (i.material.uniforms.resolution.value.x = 1 / (e * n), i.material.uniforms.resolution.value.y = 1 / (t * n)); } } init() { const { width: e, height: t } = this.engine.deviceModule.getContainerSize(), n = this.engine.scene, i = this.engine.camera, r = this.engine.renderer, a = e / t, o = new rn(e, t, { minFilter: Ht, magFilter: Ht, format: sn, samples: 4 // 启用多重采样抗锯齿 }); this.composer = new Cb(r, o), this.composer.setPixelRatio(a), this.composer.setSize(e, t); const l = new Ab(n, i); this.composer.addPass(l); const c = new nn(n, i, e, t); c.output = nn.OUTPUT.Default, c.blendIntensity = 0.5, c.updateGtaoMaterial && c.updateGtaoMaterial({ radius: 1, // 减小半径以获得更紧密、更逼真的接触阴影 (原为 10) distanceExponent: 1, // 衰减 thickness: 1, // 厚度 scale: 1, // 缩放 distanceFallOff: 1, // 距离衰减 screenSpaceRadius: !0 }), new ws( new ue(e, t), 0.1, // 强度 0.1, // 半径 0.5 // 阈值 ), this.saturationPass = new pa(Ub), this.saturationPass.uniforms.saturation.value = 1.3, this.saturationPass.uniforms.contrast.value = 1.1, this.composer.addPass(this.saturationPass); const h = new Nb(); this.composer.addPass(h); const u = new pa(kb); u.material.uniforms.resolution.value.x = 1 / (e * a), u.material.uniforms.resolution.value.y = 1 / (t * a), this.composer.addPass(u); } } var na = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Id(s) { return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s; } function ia(s) { throw new Error('Could not dynamically require "' + s + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var nu = { exports: {} }, iu; function Ob() { return iu || (iu = 1, (function(s, e) { (function(t) { s.exports = t(); })(function() { return (function t(n, i, r) { function a(c, h) { if (!i[c]) { if (!n[c]) { var u = typeof ia == "function" && ia; if (!h && u) return u(c, !0); if (o) return o(c, !0); var f = new Error("Cannot find module '" + c + "'"); throw f.code = "MODULE_NOT_FOUND", f; } var d = i[c] = { exports: {} }; n[c][0].call(d.exports, function(p) { var g = n[c][1][p]; return a(g || p); }, d, d.exports, t, n, i, r); } return i[c].exports; } for (var o = typeof ia == "function" && ia, l = 0; l < r.length; l++) a(r[l]); return a; })({ 1: [function(t, n, i) { var r = t("./utils"), a = t("./support"), o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; i.encode = function(l) { for (var c, h, u, f, d, p, g, x = [], m = 0, v = l.length, b = v, M = r.getTypeOf(l) !== "string"; m < l.length; ) b = v - m, u = M ? (c = l[m++], h = m < v ? l[m++] : 0, m < v ? l[m++] : 0) : (c = l.charCodeAt(m++), h = m < v ? l.charCodeAt(m++) : 0, m < v ? l.charCodeAt(m++) : 0), f = c >> 2, d = (3 & c) << 4 | h >> 4, p = 1 < b ? (15 & h) << 2 | u >> 6 : 64, g = 2 < b ? 63 & u : 64, x.push(o.charAt(f) + o.charAt(d) + o.charAt(p) + o.charAt(g)); return x.join(""); }, i.decode = function(l) { var c, h, u, f, d, p, g = 0, x = 0, m = "data:"; if (l.substr(0, m.length) === m) throw new Error("Invalid base64 input, it looks like a data url."); var v, b = 3 * (l = l.replace(/[^A-Za-z0-9+/=]/g, "")).length / 4; if (l.charAt(l.length - 1) === o.charAt(64) && b--, l.charAt(l.length - 2) === o.charAt(64) && b--, b % 1 != 0) throw new Error("Invalid base64 input, bad content length."); for (v = a.uint8array ? new Uint8Array(0 | b) : new Array(0 | b); g < l.length; ) c = o.indexOf(l.charAt(g++)) << 2 | (f = o.indexOf(l.charAt(g++))) >> 4, h = (15 & f) << 4 | (d = o.indexOf(l.charAt(g++))) >> 2, u = (3 & d) << 6 | (p = o.indexOf(l.charAt(g++))), v[x++] = c, d !== 64 && (v[x++] = h), p !== 64 && (v[x++] = u); return v; }; }, { "./support": 30, "./utils": 32 }], 2: [function(t, n, i) { var r = t("./external"), a = t("./stream/DataWorker"), o = t("./stream/Crc32Probe"), l = t("./stream/DataLengthProbe"); function c(h, u, f, d, p) { this.compressedSize = h, this.uncompressedSize = u, this.crc32 = f, this.compression = d, this.compressedContent = p; } c.prototype = { getContentWorker: function() { var h = new a(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")), u = this; return h.on("end", function() { if (this.streamInfo.data_length !== u.uncompressedSize) throw new Error("Bug : uncompressed data size mismatch"); }), h; }, getCompressedWorker: function() { return new a(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression); } }, c.createWorkerFrom = function(h, u, f) { return h.pipe(new o()).pipe(new l("uncompressedSize")).pipe(u.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression", u); }, n.exports = c; }, { "./external": 6, "./stream/Crc32Probe": 25, "./stream/DataLengthProbe": 26, "./stream/DataWorker": 27 }], 3: [function(t, n, i) { var r = t("./stream/GenericWorker"); i.STORE = { magic: "\0\0", compressWorker: function() { return new r("STORE compression"); }, uncompressWorker: function() { return new r("STORE decompression"); } }, i.DEFLATE = t("./flate"); }, { "./flate": 7, "./stream/GenericWorker": 28 }], 4: [function(t, n, i) { var r = t("./utils"), a = (function() { for (var o, l = [], c = 0; c < 256; c++) { o = c; for (var h = 0; h < 8; h++) o = 1 & o ? 3988292384 ^ o >>> 1 : o >>> 1; l[c] = o; } return l; })(); n.exports = function(o, l) { return o !== void 0 && o.length ? r.getTypeOf(o) !== "string" ? (function(c, h, u, f) { var d = a, p = f + u; c ^= -1; for (var g = f; g < p; g++) c = c >>> 8 ^ d[255 & (c ^ h[g])]; return -1 ^ c; })(0 | l, o, o.length, 0) : (function(c, h, u, f) { var d = a, p = f + u; c ^= -1; for (var g = f; g < p; g++) c = c >>> 8 ^ d[255 & (c ^ h.charCodeAt(g))]; return -1 ^ c; })(0 | l, o, o.length, 0) : 0; }; }, { "./utils": 32 }], 5: [function(t, n, i) { i.base64 = !1, i.binary = !1, i.dir = !1, i.createFolders = !0, i.date = null, i.compression = null, i.compressionOptions = null, i.comment = null, i.unixPermissions = null, i.dosPermissions = null; }, {}], 6: [function(t, n, i) { var r = null; r = typeof Promise < "u" ? Promise : t("lie"), n.exports = { Promise: r }; }, { lie: 37 }], 7: [function(t, n, i) { var r = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Uint32Array < "u", a = t("pako"), o = t("./utils"), l = t("./stream/GenericWorker"), c = r ? "uint8array" : "array"; function h(u, f) { l.call(this, "FlateWorker/" + u), this._pako = null, this._pakoAction = u, this._pakoOptions = f, this.meta = {}; } i.magic = "\b\0", o.inherits(h, l), h.prototype.processChunk = function(u) { this.meta = u.meta, this._pako === null && this._createPako(), this._pako.push(o.transformTo(c, u.data), !1); }, h.prototype.flush = function() { l.prototype.flush.call(this), this._pako === null && this._createPako(), this._pako.push([], !0); }, h.prototype.cleanUp = function() { l.prototype.cleanUp.call(this), this._pako = null; }, h.prototype._createPako = function() { this._pako = new a[this._pakoAction]({ raw: !0, level: this._pakoOptions.level || -1 }); var u = this; this._pako.onData = function(f) { u.push({ data: f, meta: u.meta }); }; }, i.compressWorker = function(u) { return new h("Deflate", u); }, i.uncompressWorker = function() { return new h("Inflate", {}); }; }, { "./stream/GenericWorker": 28, "./utils": 32, pako: 38 }], 8: [function(t, n, i) { function r(d, p) { var g, x = ""; for (g = 0; g < p; g++) x += String.fromCharCode(255 & d), d >>>= 8; return x; } function a(d, p, g, x, m, v) { var b, M, C = d.file, T = d.compression, D = v !== c.utf8encode, U = o.transformTo("string", v(C.name)), S = o.transformTo("string", c.utf8encode(C.name)), w = C.comment, B = o.transformTo("string", v(w)), P = o.transformTo("string", c.utf8encode(w)), O = S.length !== C.name.length, y = P.length !== w.length, H = "", Y = "", j = "", J = C.dir, Z = C.date, ae = { crc32: 0, compressedSize: 0, uncompressedSize: 0 }; p && !g || (ae.crc32 = d.crc32, ae.compressedSize = d.compressedSize, ae.uncompressedSize = d.uncompressedSize); var X = 0; p && (X |= 8), D || !O && !y || (X |= 2048); var q = 0, ge = 0; J && (q |= 16), m === "UNIX" ? (ge = 798, q |= (function(de, ie) { var ce = de; return de || (ce = ie ? 16893 : 33204), (65535 & ce) << 16; })(C.unixPermissions, J)) : (ge = 20, q |= (function(de) { return 63 & (de || 0); })(C.dosPermissions)), b = Z.getUTCHours(), b <<= 6, b |= Z.getUTCMinutes(), b <<= 5, b |= Z.getUTCSeconds() / 2, M = Z.getUTCFullYear() - 1980, M <<= 4, M |= Z.getUTCMonth() + 1, M <<= 5, M |= Z.getUTCDate(), O && (Y = r(1, 1) + r(h(U), 4) + S, H += "up" + r(Y.length, 2) + Y), y && (j = r(1, 1) + r(h(B), 4) + P, H += "uc" + r(j.length, 2) + j); var pe = ""; return pe += ` \0`, pe += r(X, 2), pe += T.magic, pe += r(b, 2), pe += r(M, 2), pe += r(ae.crc32, 4), pe += r(ae.compressedSize, 4), pe += r(ae.uncompressedSize, 4), pe += r(U.length, 2), pe += r(H.length, 2), { fileRecord: u.LOCAL_FILE_HEADER + pe + U + H, dirRecord: u.CENTRAL_FILE_HEADER + r(ge, 2) + pe + r(B.length, 2) + "\0\0\0\0" + r(q, 4) + r(x, 4) + U + H + B }; } var o = t("../utils"), l = t("../stream/GenericWorker"), c = t("../utf8"), h = t("../crc32"), u = t("../signature"); function f(d, p, g, x) { l.call(this, "ZipFileWorker"), this.bytesWritten = 0, this.zipComment = p, this.zipPlatform = g, this.encodeFileName = x, this.streamFiles = d, this.accumulate = !1, this.contentBuffer = [], this.dirRecords = [], this.currentSourceOffset = 0, this.entriesCount = 0, this.currentFile = null, this._sources = []; } o.inherits(f, l), f.prototype.push = function(d) { var p = d.meta.percent || 0, g = this.entriesCount, x = this._sources.length; this.accumulate ? this.contentBuffer.push(d) : (this.bytesWritten += d.data.length, l.prototype.push.call(this, { data: d.data, meta: { currentFile: this.currentFile, percent: g ? (p + 100 * (g - x - 1)) / g : 100 } })); }, f.prototype.openedSource = function(d) { this.currentSourceOffset = this.bytesWritten, this.currentFile = d.file.name; var p = this.streamFiles && !d.file.dir; if (p) { var g = a(d, p, !1, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); this.push({ data: g.fileRecord, meta: { percent: 0 } }); } else this.accumulate = !0; }, f.prototype.closedSource = function(d) { this.accumulate = !1; var p = this.streamFiles && !d.file.dir, g = a(d, p, !0, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); if (this.dirRecords.push(g.dirRecord), p) this.push({ data: (function(x) { return u.DATA_DESCRIPTOR + r(x.crc32, 4) + r(x.compressedSize, 4) + r(x.uncompressedSize, 4); })(d), meta: { percent: 100 } }); else for (this.push({ data: g.fileRecord, meta: { percent: 0 } }); this.contentBuffer.length; ) this.push(this.contentBuffer.shift()); this.currentFile = null; }, f.prototype.flush = function() { for (var d = this.bytesWritten, p = 0; p < this.dirRecords.length; p++) this.push({ data: this.dirRecords[p], meta: { percent: 100 } }); var g = this.bytesWritten - d, x = (function(m, v, b, M, C) { var T = o.transformTo("string", C(M)); return u.CENTRAL_DIRECTORY_END + "\0\0\0\0" + r(m, 2) + r(m, 2) + r(v, 4) + r(b, 4) + r(T.length, 2) + T; })(this.dirRecords.length, g, d, this.zipComment, this.encodeFileName); this.push({ data: x, meta: { percent: 100 } }); }, f.prototype.prepareNextSource = function() { this.previous = this._sources.shift(), this.openedSource(this.previous.streamInfo), this.isPaused ? this.previous.pause() : this.previous.resume(); }, f.prototype.registerPrevious = function(d) { this._sources.push(d); var p = this; return d.on("data", function(g) { p.processChunk(g); }), d.on("end", function() { p.closedSource(p.previous.streamInfo), p._sources.length ? p.prepareNextSource() : p.end(); }), d.on("error", function(g) { p.error(g); }), this; }, f.prototype.resume = function() { return !!l.prototype.resume.call(this) && (!this.previous && this._sources.length ? (this.prepareNextSource(), !0) : this.previous || this._sources.length || this.generatedError ? void 0 : (this.end(), !0)); }, f.prototype.error = function(d) { var p = this._sources; if (!l.prototype.error.call(this, d)) return !1; for (var g = 0; g < p.length; g++) try { p[g].error(d); } catch { } return !0; }, f.prototype.lock = function() { l.prototype.lock.call(this); for (var d = this._sources, p = 0; p < d.length; p++) d[p].lock(); }, n.exports = f; }, { "../crc32": 4, "../signature": 23, "../stream/GenericWorker": 28, "../utf8": 31, "../utils": 32 }], 9: [function(t, n, i) { var r = t("../compressions"), a = t("./ZipFileWorker"); i.generateWorker = function(o, l, c) { var h = new a(l.streamFiles, c, l.platform, l.encodeFileName), u = 0; try { o.forEach(function(f, d) { u++; var p = (function(v, b) { var M = v || b, C = r[M]; if (!C) throw new Error(M + " is not a valid compression method !"); return C; })(d.options.compression, l.compression), g = d.options.compressionOptions || l.compressionOptions || {}, x = d.dir, m = d.date; d._compressWorker(p, g).withStreamInfo("file", { name: f, dir: x, date: m, comment: d.comment || "", unixPermissions: d.unixPermissions, dosPermissions: d.dosPermissions }).pipe(h); }), h.entriesCount = u; } catch (f) { h.error(f); } return h; }; }, { "../compressions": 3, "./ZipFileWorker": 8 }], 10: [function(t, n, i) { function r() { if (!(this instanceof r)) return new r(); if (arguments.length) throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide."); this.files = /* @__PURE__ */ Object.create(null), this.comment = null, this.root = "", this.clone = function() { var a = new r(); for (var o in this) typeof this[o] != "function" && (a[o] = this[o]); return a; }; } (r.prototype = t("./object")).loadAsync = t("./load"), r.support = t("./support"), r.defaults = t("./defaults"), r.version = "3.10.1", r.loadAsync = function(a, o) { return new r().loadAsync(a, o); }, r.external = t("./external"), n.exports = r; }, { "./defaults": 5, "./external": 6, "./load": 11, "./object": 15, "./support": 30 }], 11: [function(t, n, i) { var r = t("./utils"), a = t("./external"), o = t("./utf8"), l = t("./zipEntries"), c = t("./stream/Crc32Probe"), h = t("./nodejsUtils"); function u(f) { return new a.Promise(function(d, p) { var g = f.decompressed.getContentWorker().pipe(new c()); g.on("error", function(x) { p(x); }).on("end", function() { g.streamInfo.crc32 !== f.decompressed.crc32 ? p(new Error("Corrupted zip : CRC32 mismatch")) : d(); }).resume(); }); } n.exports = function(f, d) { var p = this; return d = r.extend(d || {}, { base64: !1, checkCRC32: !1, optimizedBinaryString: !1, createFolders: !1, decodeFileName: o.utf8decode }), h.isNode && h.isStream(f) ? a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")) : r.prepareContent("the loaded zip file", f, !0, d.optimizedBinaryString, d.base64).then(function(g) { var x = new l(d); return x.load(g), x; }).then(function(g) { var x = [a.Promise.resolve(g)], m = g.files; if (d.checkCRC32) for (var v = 0; v < m.length; v++) x.push(u(m[v])); return a.Promise.all(x); }).then(function(g) { for (var x = g.shift(), m = x.files, v = 0; v < m.length; v++) { var b = m[v], M = b.fileNameStr, C = r.resolve(b.fileNameStr); p.file(C, b.decompressed, { binary: !0, optimizedBinaryString: !0, date: b.date, dir: b.dir, comment: b.fileCommentStr.length ? b.fileCommentStr : null, unixPermissions: b.unixPermissions, dosPermissions: b.dosPermissions, createFolders: d.createFolders }), b.dir || (p.file(C).unsafeOriginalName = M); } return x.zipComment.length && (p.comment = x.zipComment), p; }); }; }, { "./external": 6, "./nodejsUtils": 14, "./stream/Crc32Probe": 25, "./utf8": 31, "./utils": 32, "./zipEntries": 33 }], 12: [function(t, n, i) { var r = t("../utils"), a = t("../stream/GenericWorker"); function o(l, c) { a.call(this, "Nodejs stream input adapter for " + l), this._upstreamEnded = !1, this._bindStream(c); } r.inherits(o, a), o.prototype._bindStream = function(l) { var c = this; (this._stream = l).pause(), l.on("data", function(h) { c.push({ data: h, meta: { percent: 0 } }); }).on("error", function(h) { c.isPaused ? this.generatedError = h : c.error(h); }).on("end", function() { c.isPaused ? c._upstreamEnded = !0 : c.end(); }); }, o.prototype.pause = function() { return !!a.prototype.pause.call(this) && (this._stream.pause(), !0); }, o.prototype.resume = function() { return !!a.prototype.resume.call(this) && (this._upstreamEnded ? this.end() : this._stream.resume(), !0); }, n.exports = o; }, { "../stream/GenericWorker": 28, "../utils": 32 }], 13: [function(t, n, i) { var r = t("readable-stream").Readable; function a(o, l, c) { r.call(this, l), this._helper = o; var h = this; o.on("data", function(u, f) { h.push(u) || h._helper.pause(), c && c(f); }).on("error", function(u) { h.emit("error", u); }).on("end", function() { h.push(null); }); } t("../utils").inherits(a, r), a.prototype._read = function() { this._helper.resume(); }, n.exports = a; }, { "../utils": 32, "readable-stream": 16 }], 14: [function(t, n, i) { n.exports = { isNode: typeof Buffer < "u", newBufferFrom: function(r, a) { if (Buffer.from && Buffer.from !== Uint8Array.from) return Buffer.from(r, a); if (typeof r == "number") throw new Error('The "data" argument must not be a number'); return new Buffer(r, a); }, allocBuffer: function(r) { if (Buffer.alloc) return Buffer.alloc(r); var a = new Buffer(r); return a.fill(0), a; }, isBuffer: function(r) { return Buffer.isBuffer(r); }, isStream: function(r) { return r && typeof r.on == "function" && typeof r.pause == "function" && typeof r.resume == "function"; } }; }, {}], 15: [function(t, n, i) { function r(C, T, D) { var U, S = o.getTypeOf(T), w = o.extend(D || {}, h); w.date = w.date || /* @__PURE__ */ new Date(), w.compression !== null && (w.compression = w.compression.toUpperCase()), typeof w.unixPermissions == "string" && (w.unixPermissions = parseInt(w.unixPermissions, 8)), w.unixPermissions && 16384 & w.unixPermissions && (w.dir = !0), w.dosPermissions && 16 & w.dosPermissions && (w.dir = !0), w.dir && (C = m(C)), w.createFolders && (U = x(C)) && v.call(this, U, !0); var B = S === "string" && w.binary === !1 && w.base64 === !1; D && D.binary !== void 0 || (w.binary = !B), (T instanceof u && T.uncompressedSize === 0 || w.dir || !T || T.length === 0) && (w.base64 = !1, w.binary = !0, T = "", w.compression = "STORE", S = "string"); var P = null; P = T instanceof u || T instanceof l ? T : p.isNode && p.isStream(T) ? new g(C, T) : o.prepareContent(C, T, w.binary, w.optimizedBinaryString, w.base64); var O = new f(C, P, w); this.files[C] = O; } var a = t("./utf8"), o = t("./utils"), l = t("./stream/GenericWorker"), c = t("./stream/StreamHelper"), h = t("./defaults"), u = t("./compressedObject"), f = t("./zipObject"), d = t("./generate"), p = t("./nodejsUtils"), g = t("./nodejs/NodejsStreamInputAdapter"), x = function(C) { C.slice(-1) === "/" && (C = C.substring(0, C.length - 1)); var T = C.lastIndexOf("/"); return 0 < T ? C.substring(0, T) : ""; }, m = function(C) { return C.slice(-1) !== "/" && (C += "/"), C; }, v = function(C, T) { return T = T !== void 0 ? T : h.createFolders, C = m(C), this.files[C] || r.call(this, C, null, { dir: !0, createFolders: T }), this.files[C]; }; function b(C) { return Object.prototype.toString.call(C) === "[object RegExp]"; } var M = { load: function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, forEach: function(C) { var T, D, U; for (T in this.files) U = this.files[T], (D = T.slice(this.root.length, T.length)) && T.slice(0, this.root.length) === this.root && C(D, U); }, filter: function(C) { var T = []; return this.forEach(function(D, U) { C(D, U) && T.push(U); }), T; }, file: function(C, T, D) { if (arguments.length !== 1) return C = this.root + C, r.call(this, C, T, D), this; if (b(C)) { var U = C; return this.filter(function(w, B) { return !B.dir && U.test(w); }); } var S = this.files[this.root + C]; return S && !S.dir ? S : null; }, folder: function(C) { if (!C) return this; if (b(C)) return this.filter(function(S, w) { return w.dir && C.test(S); }); var T = this.root + C, D = v.call(this, T), U = this.clone(); return U.root = D.name, U; }, remove: function(C) { C = this.root + C; var T = this.files[C]; if (T || (C.slice(-1) !== "/" && (C += "/"), T = this.files[C]), T && !T.dir) delete this.files[C]; else for (var D = this.filter(function(S, w) { return w.name.slice(0, C.length) === C; }), U = 0; U < D.length; U++) delete this.files[D[U].name]; return this; }, generate: function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, generateInternalStream: function(C) { var T, D = {}; try { if ((D = o.extend(C || {}, { streamFiles: !1, compression: "STORE", compressionOptions: null, type: "", platform: "DOS", comment: null, mimeType: "application/zip", encodeFileName: a.utf8encode })).type = D.type.toLowerCase(), D.compression = D.compression.toUpperCase(), D.type === "binarystring" && (D.type = "string"), !D.type) throw new Error("No output type specified."); o.checkSupport(D.type), D.platform !== "darwin" && D.platform !== "freebsd" && D.platform !== "linux" && D.platform !== "sunos" || (D.platform = "UNIX"), D.platform === "win32" && (D.platform = "DOS"); var U = D.comment || this.comment || ""; T = d.generateWorker(this, D, U); } catch (S) { (T = new l("error")).error(S); } return new c(T, D.type || "string", D.mimeType); }, generateAsync: function(C, T) { return this.generateInternalStream(C).accumulate(T); }, generateNodeStream: function(C, T) { return (C = C || {}).type || (C.type = "nodebuffer"), this.generateInternalStream(C).toNodejsStream(T); } }; n.exports = M; }, { "./compressedObject": 2, "./defaults": 5, "./generate": 9, "./nodejs/NodejsStreamInputAdapter": 12, "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31, "./utils": 32, "./zipObject": 35 }], 16: [function(t, n, i) { n.exports = t("stream"); }, { stream: void 0 }], 17: [function(t, n, i) { var r = t("./DataReader"); function a(o) { r.call(this, o); for (var l = 0; l < this.data.length; l++) o[l] = 255 & o[l]; } t("../utils").inherits(a, r), a.prototype.byteAt = function(o) { return this.data[this.zero + o]; }, a.prototype.lastIndexOfSignature = function(o) { for (var l = o.charCodeAt(0), c = o.charCodeAt(1), h = o.charCodeAt(2), u = o.charCodeAt(3), f = this.length - 4; 0 <= f; --f) if (this.data[f] === l && this.data[f + 1] === c && this.data[f + 2] === h && this.data[f + 3] === u) return f - this.zero; return -1; }, a.prototype.readAndCheckSignature = function(o) { var l = o.charCodeAt(0), c = o.charCodeAt(1), h = o.charCodeAt(2), u = o.charCodeAt(3), f = this.readData(4); return l === f[0] && c === f[1] && h === f[2] && u === f[3]; }, a.prototype.readData = function(o) { if (this.checkOffset(o), o === 0) return []; var l = this.data.slice(this.zero + this.index, this.zero + this.index + o); return this.index += o, l; }, n.exports = a; }, { "../utils": 32, "./DataReader": 18 }], 18: [function(t, n, i) { var r = t("../utils"); function a(o) { this.data = o, this.length = o.length, this.index = 0, this.zero = 0; } a.prototype = { checkOffset: function(o) { this.checkIndex(this.index + o); }, checkIndex: function(o) { if (this.length < this.zero + o || o < 0) throw new Error("End of data reached (data length = " + this.length + ", asked index = " + o + "). Corrupted zip ?"); }, setIndex: function(o) { this.checkIndex(o), this.index = o; }, skip: function(o) { this.setIndex(this.index + o); }, byteAt: function() { }, readInt: function(o) { var l, c = 0; for (this.checkOffset(o), l = this.index + o - 1; l >= this.index; l--) c = (c << 8) + this.byteAt(l); return this.index += o, c; }, readString: function(o) { return r.transformTo("string", this.readData(o)); }, readData: function() { }, lastIndexOfSignature: function() { }, readAndCheckSignature: function() { }, readDate: function() { var o = this.readInt(4); return new Date(Date.UTC(1980 + (o >> 25 & 127), (o >> 21 & 15) - 1, o >> 16 & 31, o >> 11 & 31, o >> 5 & 63, (31 & o) << 1)); } }, n.exports = a; }, { "../utils": 32 }], 19: [function(t, n, i) { var r = t("./Uint8ArrayReader"); function a(o) { r.call(this, o); } t("../utils").inherits(a, r), a.prototype.readData = function(o) { this.checkOffset(o); var l = this.data.slice(this.zero + this.index, this.zero + this.index + o); return this.index += o, l; }, n.exports = a; }, { "../utils": 32, "./Uint8ArrayReader": 21 }], 20: [function(t, n, i) { var r = t("./DataReader"); function a(o) { r.call(this, o); } t("../utils").inherits(a, r), a.prototype.byteAt = function(o) { return this.data.charCodeAt(this.zero + o); }, a.prototype.lastIndexOfSignature = function(o) { return this.data.lastIndexOf(o) - this.zero; }, a.prototype.readAndCheckSignature = function(o) { return o === this.readData(4); }, a.prototype.readData = function(o) { this.checkOffset(o); var l = this.data.slice(this.zero + this.index, this.zero + this.index + o); return this.index += o, l; }, n.exports = a; }, { "../utils": 32, "./DataReader": 18 }], 21: [function(t, n, i) { var r = t("./ArrayReader"); function a(o) { r.call(this, o); } t("../utils").inherits(a, r), a.prototype.readData = function(o) { if (this.checkOffset(o), o === 0) return new Uint8Array(0); var l = this.data.subarray(this.zero + this.index, this.zero + this.index + o); return this.index += o, l; }, n.exports = a; }, { "../utils": 32, "./ArrayReader": 17 }], 22: [function(t, n, i) { var r = t("../utils"), a = t("../support"), o = t("./ArrayReader"), l = t("./StringReader"), c = t("./NodeBufferReader"), h = t("./Uint8ArrayReader"); n.exports = function(u) { var f = r.getTypeOf(u); return r.checkSupport(f), f !== "string" || a.uint8array ? f === "nodebuffer" ? new c(u) : a.uint8array ? new h(r.transformTo("uint8array", u)) : new o(r.transformTo("array", u)) : new l(u); }; }, { "../support": 30, "../utils": 32, "./ArrayReader": 17, "./NodeBufferReader": 19, "./StringReader": 20, "./Uint8ArrayReader": 21 }], 23: [function(t, n, i) { i.LOCAL_FILE_HEADER = "PK", i.CENTRAL_FILE_HEADER = "PK", i.CENTRAL_DIRECTORY_END = "PK", i.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x07", i.ZIP64_CENTRAL_DIRECTORY_END = "PK", i.DATA_DESCRIPTOR = "PK\x07\b"; }, {}], 24: [function(t, n, i) { var r = t("./GenericWorker"), a = t("../utils"); function o(l) { r.call(this, "ConvertWorker to " + l), this.destType = l; } a.inherits(o, r), o.prototype.processChunk = function(l) { this.push({ data: a.transformTo(this.destType, l.data), meta: l.meta }); }, n.exports = o; }, { "../utils": 32, "./GenericWorker": 28 }], 25: [function(t, n, i) { var r = t("./GenericWorker"), a = t("../crc32"); function o() { r.call(this, "Crc32Probe"), this.withStreamInfo("crc32", 0); } t("../utils").inherits(o, r), o.prototype.processChunk = function(l) { this.streamInfo.crc32 = a(l.data, this.streamInfo.crc32 || 0), this.push(l); }, n.exports = o; }, { "../crc32": 4, "../utils": 32, "./GenericWorker": 28 }], 26: [function(t, n, i) { var r = t("../utils"), a = t("./GenericWorker"); function o(l) { a.call(this, "DataLengthProbe for " + l), this.propName = l, this.withStreamInfo(l, 0); } r.inherits(o, a), o.prototype.processChunk = function(l) { if (l) { var c = this.streamInfo[this.propName] || 0; this.streamInfo[this.propName] = c + l.data.length; } a.prototype.processChunk.call(this, l); }, n.exports = o; }, { "../utils": 32, "./GenericWorker": 28 }], 27: [function(t, n, i) { var r = t("../utils"), a = t("./GenericWorker"); function o(l) { a.call(this, "DataWorker"); var c = this; this.dataIsReady = !1, this.index = 0, this.max = 0, this.data = null, this.type = "", this._tickScheduled = !1, l.then(function(h) { c.dataIsReady = !0, c.data = h, c.max = h && h.length || 0, c.type = r.getTypeOf(h), c.isPaused || c._tickAndRepeat(); }, function(h) { c.error(h); }); } r.inherits(o, a), o.prototype.cleanUp = function() { a.prototype.cleanUp.call(this), this.data = null; }, o.prototype.resume = function() { return !!a.prototype.resume.call(this) && (!this._tickScheduled && this.dataIsReady && (this._tickScheduled = !0, r.delay(this._tickAndRepeat, [], this)), !0); }, o.prototype._tickAndRepeat = function() { this._tickScheduled = !1, this.isPaused || this.isFinished || (this._tick(), this.isFinished || (r.delay(this._tickAndRepeat, [], this), this._tickScheduled = !0)); }, o.prototype._tick = function() { if (this.isPaused || this.isFinished) return !1; var l = null, c = Math.min(this.max, this.index + 16384); if (this.index >= this.max) return this.end(); switch (this.type) { case "string": l = this.data.substring(this.index, c); break; case "uint8array": l = this.data.subarray(this.index, c); break; case "array": case "nodebuffer": l = this.data.slice(this.index, c); } return this.index = c, this.push({ data: l, meta: { percent: this.max ? this.index / this.max * 100 : 0 } }); }, n.exports = o; }, { "../utils": 32, "./GenericWorker": 28 }], 28: [function(t, n, i) { function r(a) { this.name = a || "default", this.streamInfo = {}, this.generatedError = null, this.extraStreamInfo = {}, this.isPaused = !0, this.isFinished = !1, this.isLocked = !1, this._listeners = { data: [], end: [], error: [] }, this.previous = null; } r.prototype = { push: function(a) { this.emit("data", a); }, end: function() { if (this.isFinished) return !1; this.flush(); try { this.emit("end"), this.cleanUp(), this.isFinished = !0; } catch (a) { this.emit("error", a); } return !0; }, error: function(a) { return !this.isFinished && (this.isPaused ? this.generatedError = a : (this.isFinished = !0, this.emit("error", a), this.previous && this.previous.error(a), this.cleanUp()), !0); }, on: function(a, o) { return this._listeners[a].push(o), this; }, cleanUp: function() { this.streamInfo = this.generatedError = this.extraStreamInfo = null, this._listeners = []; }, emit: function(a, o) { if (this._listeners[a]) for (var l = 0; l < this._listeners[a].length; l++) this._listeners[a][l].call(this, o); }, pipe: function(a) { return a.registerPrevious(this); }, registerPrevious: function(a) { if (this.isLocked) throw new Error("The stream '" + this + "' has already been used."); this.streamInfo = a.streamInfo, this.mergeStreamInfo(), this.previous = a; var o = this; return a.on("data", function(l) { o.processChunk(l); }), a.on("end", function() { o.end(); }), a.on("error", function(l) { o.error(l); }), this; }, pause: function() { return !this.isPaused && !this.isFinished && (this.isPaused = !0, this.previous && this.previous.pause(), !0); }, resume: function() { if (!this.isPaused || this.isFinished) return !1; var a = this.isPaused = !1; return this.generatedError && (this.error(this.generatedError), a = !0), this.previous && this.previous.resume(), !a; }, flush: function() { }, processChunk: function(a) { this.push(a); }, withStreamInfo: function(a, o) { return this.extraStreamInfo[a] = o, this.mergeStreamInfo(), this; }, mergeStreamInfo: function() { for (var a in this.extraStreamInfo) Object.prototype.hasOwnProperty.call(this.extraStreamInfo, a) && (this.streamInfo[a] = this.extraStreamInfo[a]); }, lock: function() { if (this.isLocked) throw new Error("The stream '" + this + "' has already been used."); this.isLocked = !0, this.previous && this.previous.lock(); }, toString: function() { var a = "Worker " + this.name; return this.previous ? this.previous + " -> " + a : a; } }, n.exports = r; }, {}], 29: [function(t, n, i) { var r = t("../utils"), a = t("./ConvertWorker"), o = t("./GenericWorker"), l = t("../base64"), c = t("../support"), h = t("../external"), u = null; if (c.nodestream) try { u = t("../nodejs/NodejsStreamOutputAdapter"); } catch { } function f(p, g) { return new h.Promise(function(x, m) { var v = [], b = p._internalType, M = p._outputType, C = p._mimeType; p.on("data", function(T, D) { v.push(T), g && g(D); }).on("error", function(T) { v = [], m(T); }).on("end", function() { try { var T = (function(D, U, S) { switch (D) { case "blob": return r.newBlob(r.transformTo("arraybuffer", U), S); case "base64": return l.encode(U); default: return r.transformTo(D, U); } })(M, (function(D, U) { var S, w = 0, B = null, P = 0; for (S = 0; S < U.length; S++) P += U[S].length; switch (D) { case "string": return U.join(""); case "array": return Array.prototype.concat.apply([], U); case "uint8array": for (B = new Uint8Array(P), S = 0; S < U.length; S++) B.set(U[S], w), w += U[S].length; return B; case "nodebuffer": return Buffer.concat(U); default: throw new Error("concat : unsupported type '" + D + "'"); } })(b, v), C); x(T); } catch (D) { m(D); } v = []; }).resume(); }); } function d(p, g, x) { var m = g; switch (g) { case "blob": case "arraybuffer": m = "uint8array"; break; case "base64": m = "string"; } try { this._internalType = m, this._outputType = g, this._mimeType = x, r.checkSupport(m), this._worker = p.pipe(new a(m)), p.lock(); } catch (v) { this._worker = new o("error"), this._worker.error(v); } } d.prototype = { accumulate: function(p) { return f(this, p); }, on: function(p, g) { var x = this; return p === "data" ? this._worker.on(p, function(m) { g.call(x, m.data, m.meta); }) : this._worker.on(p, function() { r.delay(g, arguments, x); }), this; }, resume: function() { return r.delay(this._worker.resume, [], this._worker), this; }, pause: function() { return this._worker.pause(), this; }, toNodejsStream: function(p) { if (r.checkSupport("nodestream"), this._outputType !== "nodebuffer") throw new Error(this._outputType + " is not supported by this method"); return new u(this, { objectMode: this._outputType !== "nodebuffer" }, p); } }, n.exports = d; }, { "../base64": 1, "../external": 6, "../nodejs/NodejsStreamOutputAdapter": 13, "../support": 30, "../utils": 32, "./ConvertWorker": 24, "./GenericWorker": 28 }], 30: [function(t, n, i) { if (i.base64 = !0, i.array = !0, i.string = !0, i.arraybuffer = typeof ArrayBuffer < "u" && typeof Uint8Array < "u", i.nodebuffer = typeof Buffer < "u", i.uint8array = typeof Uint8Array < "u", typeof ArrayBuffer > "u") i.blob = !1; else { var r = new ArrayBuffer(0); try { i.blob = new Blob([r], { type: "application/zip" }).size === 0; } catch { try { var a = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)(); a.append(r), i.blob = a.getBlob("application/zip").size === 0; } catch { i.blob = !1; } } } try { i.nodestream = !!t("readable-stream").Readable; } catch { i.nodestream = !1; } }, { "readable-stream": 16 }], 31: [function(t, n, i) { for (var r = t("./utils"), a = t("./support"), o = t("./nodejsUtils"), l = t("./stream/GenericWorker"), c = new Array(256), h = 0; h < 256; h++) c[h] = 252 <= h ? 6 : 248 <= h ? 5 : 240 <= h ? 4 : 224 <= h ? 3 : 192 <= h ? 2 : 1; c[254] = c[254] = 1; function u() { l.call(this, "utf-8 decode"), this.leftOver = null; } function f() { l.call(this, "utf-8 encode"); } i.utf8encode = function(d) { return a.nodebuffer ? o.newBufferFrom(d, "utf-8") : (function(p) { var g, x, m, v, b, M = p.length, C = 0; for (v = 0; v < M; v++) (64512 & (x = p.charCodeAt(v))) == 55296 && v + 1 < M && (64512 & (m = p.charCodeAt(v + 1))) == 56320 && (x = 65536 + (x - 55296 << 10) + (m - 56320), v++), C += x < 128 ? 1 : x < 2048 ? 2 : x < 65536 ? 3 : 4; for (g = a.uint8array ? new Uint8Array(C) : new Array(C), v = b = 0; b < C; v++) (64512 & (x = p.charCodeAt(v))) == 55296 && v + 1 < M && (64512 & (m = p.charCodeAt(v + 1))) == 56320 && (x = 65536 + (x - 55296 << 10) + (m - 56320), v++), x < 128 ? g[b++] = x : (x < 2048 ? g[b++] = 192 | x >>> 6 : (x < 65536 ? g[b++] = 224 | x >>> 12 : (g[b++] = 240 | x >>> 18, g[b++] = 128 | x >>> 12 & 63), g[b++] = 128 | x >>> 6 & 63), g[b++] = 128 | 63 & x); return g; })(d); }, i.utf8decode = function(d) { return a.nodebuffer ? r.transformTo("nodebuffer", d).toString("utf-8") : (function(p) { var g, x, m, v, b = p.length, M = new Array(2 * b); for (g = x = 0; g < b; ) if ((m = p[g++]) < 128) M[x++] = m; else if (4 < (v = c[m])) M[x++] = 65533, g += v - 1; else { for (m &= v === 2 ? 31 : v === 3 ? 15 : 7; 1 < v && g < b; ) m = m << 6 | 63 & p[g++], v--; 1 < v ? M[x++] = 65533 : m < 65536 ? M[x++] = m : (m -= 65536, M[x++] = 55296 | m >> 10 & 1023, M[x++] = 56320 | 1023 & m); } return M.length !== x && (M.subarray ? M = M.subarray(0, x) : M.length = x), r.applyFromCharCode(M); })(d = r.transformTo(a.uint8array ? "uint8array" : "array", d)); }, r.inherits(u, l), u.prototype.processChunk = function(d) { var p = r.transformTo(a.uint8array ? "uint8array" : "array", d.data); if (this.leftOver && this.leftOver.length) { if (a.uint8array) { var g = p; (p = new Uint8Array(g.length + this.leftOver.length)).set(this.leftOver, 0), p.set(g, this.leftOver.length); } else p = this.leftOver.concat(p); this.leftOver = null; } var x = (function(v, b) { var M; for ((b = b || v.length) > v.length && (b = v.length), M = b - 1; 0 <= M && (192 & v[M]) == 128; ) M--; return M < 0 || M === 0 ? b : M + c[v[M]] > b ? M : b; })(p), m = p; x !== p.length && (a.uint8array ? (m = p.subarray(0, x), this.leftOver = p.subarray(x, p.length)) : (m = p.slice(0, x), this.leftOver = p.slice(x, p.length))), this.push({ data: i.utf8decode(m), meta: d.meta }); }, u.prototype.flush = function() { this.leftOver && this.leftOver.length && (this.push({ data: i.utf8decode(this.leftOver), meta: {} }), this.leftOver = null); }, i.Utf8DecodeWorker = u, r.inherits(f, l), f.prototype.processChunk = function(d) { this.push({ data: i.utf8encode(d.data), meta: d.meta }); }, i.Utf8EncodeWorker = f; }, { "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./support": 30, "./utils": 32 }], 32: [function(t, n, i) { var r = t("./support"), a = t("./base64"), o = t("./nodejsUtils"), l = t("./external"); function c(g) { return g; } function h(g, x) { for (var m = 0; m < g.length; ++m) x[m] = 255 & g.charCodeAt(m); return x; } t("setimmediate"), i.newBlob = function(g, x) { i.checkSupport("blob"); try { return new Blob([g], { type: x }); } catch { try { var m = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)(); return m.append(g), m.getBlob(x); } catch { throw new Error("Bug : can't construct the Blob."); } } }; var u = { stringifyByChunk: function(g, x, m) { var v = [], b = 0, M = g.length; if (M <= m) return String.fromCharCode.apply(null, g); for (; b < M; ) x === "array" || x === "nodebuffer" ? v.push(String.fromCharCode.apply(null, g.slice(b, Math.min(b + m, M)))) : v.push(String.fromCharCode.apply(null, g.subarray(b, Math.min(b + m, M)))), b += m; return v.join(""); }, stringifyByChar: function(g) { for (var x = "", m = 0; m < g.length; m++) x += String.fromCharCode(g[m]); return x; }, applyCanBeUsed: { uint8array: (function() { try { return r.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1; } catch { return !1; } })(), nodebuffer: (function() { try { return r.nodebuffer && String.fromCharCode.apply(null, o.allocBuffer(1)).length === 1; } catch { return !1; } })() } }; function f(g) { var x = 65536, m = i.getTypeOf(g), v = !0; if (m === "uint8array" ? v = u.applyCanBeUsed.uint8array : m === "nodebuffer" && (v = u.applyCanBeUsed.nodebuffer), v) for (; 1 < x; ) try { return u.stringifyByChunk(g, m, x); } catch { x = Math.floor(x / 2); } return u.stringifyByChar(g); } function d(g, x) { for (var m = 0; m < g.length; m++) x[m] = g[m]; return x; } i.applyFromCharCode = f; var p = {}; p.string = { string: c, array: function(g) { return h(g, new Array(g.length)); }, arraybuffer: function(g) { return p.string.uint8array(g).buffer; }, uint8array: function(g) { return h(g, new Uint8Array(g.length)); }, nodebuffer: function(g) { return h(g, o.allocBuffer(g.length)); } }, p.array = { string: f, array: c, arraybuffer: function(g) { return new Uint8Array(g).buffer; }, uint8array: function(g) { return new Uint8Array(g); }, nodebuffer: function(g) { return o.newBufferFrom(g); } }, p.arraybuffer = { string: function(g) { return f(new Uint8Array(g)); }, array: function(g) { return d(new Uint8Array(g), new Array(g.byteLength)); }, arraybuffer: c, uint8array: function(g) { return new Uint8Array(g); }, nodebuffer: function(g) { return o.newBufferFrom(new Uint8Array(g)); } }, p.uint8array = { string: f, array: function(g) { return d(g, new Array(g.length)); }, arraybuffer: function(g) { return g.buffer; }, uint8array: c, nodebuffer: function(g) { return o.newBufferFrom(g); } }, p.nodebuffer = { string: f, array: function(g) { return d(g, new Array(g.length)); }, arraybuffer: function(g) { return p.nodebuffer.uint8array(g).buffer; }, uint8array: function(g) { return d(g, new Uint8Array(g.length)); }, nodebuffer: c }, i.transformTo = function(g, x) { if (x = x || "", !g) return x; i.checkSupport(g); var m = i.getTypeOf(x); return p[m][g](x); }, i.resolve = function(g) { for (var x = g.split("/"), m = [], v = 0; v < x.length; v++) { var b = x[v]; b === "." || b === "" && v !== 0 && v !== x.length - 1 || (b === ".." ? m.pop() : m.push(b)); } return m.join("/"); }, i.getTypeOf = function(g) { return typeof g == "string" ? "string" : Object.prototype.toString.call(g) === "[object Array]" ? "array" : r.nodebuffer && o.isBuffer(g) ? "nodebuffer" : r.uint8array && g instanceof Uint8Array ? "uint8array" : r.arraybuffer && g instanceof ArrayBuffer ? "arraybuffer" : void 0; }, i.checkSupport = function(g) { if (!r[g.toLowerCase()]) throw new Error(g + " is not supported by this platform"); }, i.MAX_VALUE_16BITS = 65535, i.MAX_VALUE_32BITS = -1, i.pretty = function(g) { var x, m, v = ""; for (m = 0; m < (g || "").length; m++) v += "\\x" + ((x = g.charCodeAt(m)) < 16 ? "0" : "") + x.toString(16).toUpperCase(); return v; }, i.delay = function(g, x, m) { setImmediate(function() { g.apply(m || null, x || []); }); }, i.inherits = function(g, x) { function m() { } m.prototype = x.prototype, g.prototype = new m(); }, i.extend = function() { var g, x, m = {}; for (g = 0; g < arguments.length; g++) for (x in arguments[g]) Object.prototype.hasOwnProperty.call(arguments[g], x) && m[x] === void 0 && (m[x] = arguments[g][x]); return m; }, i.prepareContent = function(g, x, m, v, b) { return l.Promise.resolve(x).then(function(M) { return r.blob && (M instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(M)) !== -1) && typeof FileReader < "u" ? new l.Promise(function(C, T) { var D = new FileReader(); D.onload = function(U) { C(U.target.result); }, D.onerror = function(U) { T(U.target.error); }, D.readAsArrayBuffer(M); }) : M; }).then(function(M) { var C = i.getTypeOf(M); return C ? (C === "arraybuffer" ? M = i.transformTo("uint8array", M) : C === "string" && (b ? M = a.decode(M) : m && v !== !0 && (M = (function(T) { return h(T, r.uint8array ? new Uint8Array(T.length) : new Array(T.length)); })(M))), M) : l.Promise.reject(new Error("Can't read the data of '" + g + "'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?")); }); }; }, { "./base64": 1, "./external": 6, "./nodejsUtils": 14, "./support": 30, setimmediate: 54 }], 33: [function(t, n, i) { var r = t("./reader/readerFor"), a = t("./utils"), o = t("./signature"), l = t("./zipEntry"), c = t("./support"); function h(u) { this.files = [], this.loadOptions = u; } h.prototype = { checkSignature: function(u) { if (!this.reader.readAndCheckSignature(u)) { this.reader.index -= 4; var f = this.reader.readString(4); throw new Error("Corrupted zip or bug: unexpected signature (" + a.pretty(f) + ", expected " + a.pretty(u) + ")"); } }, isSignature: function(u, f) { var d = this.reader.index; this.reader.setIndex(u); var p = this.reader.readString(4) === f; return this.reader.setIndex(d), p; }, readBlockEndOfCentral: function() { this.diskNumber = this.reader.readInt(2), this.diskWithCentralDirStart = this.reader.readInt(2), this.centralDirRecordsOnThisDisk = this.reader.readInt(2), this.centralDirRecords = this.reader.readInt(2), this.centralDirSize = this.reader.readInt(4), this.centralDirOffset = this.reader.readInt(4), this.zipCommentLength = this.reader.readInt(2); var u = this.reader.readData(this.zipCommentLength), f = c.uint8array ? "uint8array" : "array", d = a.transformTo(f, u); this.zipComment = this.loadOptions.decodeFileName(d); }, readBlockZip64EndOfCentral: function() { this.zip64EndOfCentralSize = this.reader.readInt(8), this.reader.skip(4), this.diskNumber = this.reader.readInt(4), this.diskWithCentralDirStart = this.reader.readInt(4), this.centralDirRecordsOnThisDisk = this.reader.readInt(8), this.centralDirRecords = this.reader.readInt(8), this.centralDirSize = this.reader.readInt(8), this.centralDirOffset = this.reader.readInt(8), this.zip64ExtensibleData = {}; for (var u, f, d, p = this.zip64EndOfCentralSize - 44; 0 < p; ) u = this.reader.readInt(2), f = this.reader.readInt(4), d = this.reader.readData(f), this.zip64ExtensibleData[u] = { id: u, length: f, value: d }; }, readBlockZip64EndOfCentralLocator: function() { if (this.diskWithZip64CentralDirStart = this.reader.readInt(4), this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8), this.disksCount = this.reader.readInt(4), 1 < this.disksCount) throw new Error("Multi-volumes zip are not supported"); }, readLocalFiles: function() { var u, f; for (u = 0; u < this.files.length; u++) f = this.files[u], this.reader.setIndex(f.localHeaderOffset), this.checkSignature(o.LOCAL_FILE_HEADER), f.readLocalPart(this.reader), f.handleUTF8(), f.processAttributes(); }, readCentralDir: function() { var u; for (this.reader.setIndex(this.centralDirOffset); this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER); ) (u = new l({ zip64: this.zip64 }, this.loadOptions)).readCentralPart(this.reader), this.files.push(u); if (this.centralDirRecords !== this.files.length && this.centralDirRecords !== 0 && this.files.length === 0) throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length); }, readEndOfCentral: function() { var u = this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END); if (u < 0) throw this.isSignature(0, o.LOCAL_FILE_HEADER) ? new Error("Corrupted zip: can't find end of central directory") : new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"); this.reader.setIndex(u); var f = u; if (this.checkSignature(o.CENTRAL_DIRECTORY_END), this.readBlockEndOfCentral(), this.diskNumber === a.MAX_VALUE_16BITS || this.diskWithCentralDirStart === a.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === a.MAX_VALUE_16BITS || this.centralDirRecords === a.MAX_VALUE_16BITS || this.centralDirSize === a.MAX_VALUE_32BITS || this.centralDirOffset === a.MAX_VALUE_32BITS) { if (this.zip64 = !0, (u = this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR)) < 0) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator"); if (this.reader.setIndex(u), this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR), this.readBlockZip64EndOfCentralLocator(), !this.isSignature(this.relativeOffsetEndOfZip64CentralDir, o.ZIP64_CENTRAL_DIRECTORY_END) && (this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END), this.relativeOffsetEndOfZip64CentralDir < 0)) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory"); this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir), this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END), this.readBlockZip64EndOfCentral(); } var d = this.centralDirOffset + this.centralDirSize; this.zip64 && (d += 20, d += 12 + this.zip64EndOfCentralSize); var p = f - d; if (0 < p) this.isSignature(f, o.CENTRAL_FILE_HEADER) || (this.reader.zero = p); else if (p < 0) throw new Error("Corrupted zip: missing " + Math.abs(p) + " bytes."); }, prepareReader: function(u) { this.reader = r(u); }, load: function(u) { this.prepareReader(u), this.readEndOfCentral(), this.readCentralDir(), this.readLocalFiles(); } }, n.exports = h; }, { "./reader/readerFor": 22, "./signature": 23, "./support": 30, "./utils": 32, "./zipEntry": 34 }], 34: [function(t, n, i) { var r = t("./reader/readerFor"), a = t("./utils"), o = t("./compressedObject"), l = t("./crc32"), c = t("./utf8"), h = t("./compressions"), u = t("./support"); function f(d, p) { this.options = d, this.loadOptions = p; } f.prototype = { isEncrypted: function() { return (1 & this.bitFlag) == 1; }, useUTF8: function() { return (2048 & this.bitFlag) == 2048; }, readLocalPart: function(d) { var p, g; if (d.skip(22), this.fileNameLength = d.readInt(2), g = d.readInt(2), this.fileName = d.readData(this.fileNameLength), d.skip(g), this.compressedSize === -1 || this.uncompressedSize === -1) throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)"); if ((p = (function(x) { for (var m in h) if (Object.prototype.hasOwnProperty.call(h, m) && h[m].magic === x) return h[m]; return null; })(this.compressionMethod)) === null) throw new Error("Corrupted zip : compression " + a.pretty(this.compressionMethod) + " unknown (inner file : " + a.transformTo("string", this.fileName) + ")"); this.decompressed = new o(this.compressedSize, this.uncompressedSize, this.crc32, p, d.readData(this.compressedSize)); }, readCentralPart: function(d) { this.versionMadeBy = d.readInt(2), d.skip(2), this.bitFlag = d.readInt(2), this.compressionMethod = d.readString(2), this.date = d.readDate(), this.crc32 = d.readInt(4), this.compressedSize = d.readInt(4), this.uncompressedSize = d.readInt(4); var p = d.readInt(2); if (this.extraFieldsLength = d.readInt(2), this.fileCommentLength = d.readInt(2), this.diskNumberStart = d.readInt(2), this.internalFileAttributes = d.readInt(2), this.externalFileAttributes = d.readInt(4), this.localHeaderOffset = d.readInt(4), this.isEncrypted()) throw new Error("Encrypted zip are not supported"); d.skip(p), this.readExtraFields(d), this.parseZIP64ExtraField(d), this.fileComment = d.readData(this.fileCommentLength); }, processAttributes: function() { this.unixPermissions = null, this.dosPermissions = null; var d = this.versionMadeBy >> 8; this.dir = !!(16 & this.externalFileAttributes), d == 0 && (this.dosPermissions = 63 & this.externalFileAttributes), d == 3 && (this.unixPermissions = this.externalFileAttributes >> 16 & 65535), this.dir || this.fileNameStr.slice(-1) !== "/" || (this.dir = !0); }, parseZIP64ExtraField: function() { if (this.extraFields[1]) { var d = r(this.extraFields[1].value); this.uncompressedSize === a.MAX_VALUE_32BITS && (this.uncompressedSize = d.readInt(8)), this.compressedSize === a.MAX_VALUE_32BITS && (this.compressedSize = d.readInt(8)), this.localHeaderOffset === a.MAX_VALUE_32BITS && (this.localHeaderOffset = d.readInt(8)), this.diskNumberStart === a.MAX_VALUE_32BITS && (this.diskNumberStart = d.readInt(4)); } }, readExtraFields: function(d) { var p, g, x, m = d.index + this.extraFieldsLength; for (this.extraFields || (this.extraFields = {}); d.index + 4 < m; ) p = d.readInt(2), g = d.readInt(2), x = d.readData(g), this.extraFields[p] = { id: p, length: g, value: x }; d.setIndex(m); }, handleUTF8: function() { var d = u.uint8array ? "uint8array" : "array"; if (this.useUTF8()) this.fileNameStr = c.utf8decode(this.fileName), this.fileCommentStr = c.utf8decode(this.fileComment); else { var p = this.findExtraFieldUnicodePath(); if (p !== null) this.fileNameStr = p; else { var g = a.transformTo(d, this.fileName); this.fileNameStr = this.loadOptions.decodeFileName(g); } var x = this.findExtraFieldUnicodeComment(); if (x !== null) this.fileCommentStr = x; else { var m = a.transformTo(d, this.fileComment); this.fileCommentStr = this.loadOptions.decodeFileName(m); } } }, findExtraFieldUnicodePath: function() { var d = this.extraFields[28789]; if (d) { var p = r(d.value); return p.readInt(1) !== 1 || l(this.fileName) !== p.readInt(4) ? null : c.utf8decode(p.readData(d.length - 5)); } return null; }, findExtraFieldUnicodeComment: function() { var d = this.extraFields[25461]; if (d) { var p = r(d.value); return p.readInt(1) !== 1 || l(this.fileComment) !== p.readInt(4) ? null : c.utf8decode(p.readData(d.length - 5)); } return null; } }, n.exports = f; }, { "./compressedObject": 2, "./compressions": 3, "./crc32": 4, "./reader/readerFor": 22, "./support": 30, "./utf8": 31, "./utils": 32 }], 35: [function(t, n, i) { function r(p, g, x) { this.name = p, this.dir = x.dir, this.date = x.date, this.comment = x.comment, this.unixPermissions = x.unixPermissions, this.dosPermissions = x.dosPermissions, this._data = g, this._dataBinary = x.binary, this.options = { compression: x.compression, compressionOptions: x.compressionOptions }; } var a = t("./stream/StreamHelper"), o = t("./stream/DataWorker"), l = t("./utf8"), c = t("./compressedObject"), h = t("./stream/GenericWorker"); r.prototype = { internalStream: function(p) { var g = null, x = "string"; try { if (!p) throw new Error("No output type specified."); var m = (x = p.toLowerCase()) === "string" || x === "text"; x !== "binarystring" && x !== "text" || (x = "string"), g = this._decompressWorker(); var v = !this._dataBinary; v && !m && (g = g.pipe(new l.Utf8EncodeWorker())), !v && m && (g = g.pipe(new l.Utf8DecodeWorker())); } catch (b) { (g = new h("error")).error(b); } return new a(g, x, ""); }, async: function(p, g) { return this.internalStream(p).accumulate(g); }, nodeStream: function(p, g) { return this.internalStream(p || "nodebuffer").toNodejsStream(g); }, _compressWorker: function(p, g) { if (this._data instanceof c && this._data.compression.magic === p.magic) return this._data.getCompressedWorker(); var x = this._decompressWorker(); return this._dataBinary || (x = x.pipe(new l.Utf8EncodeWorker())), c.createWorkerFrom(x, p, g); }, _decompressWorker: function() { return this._data instanceof c ? this._data.getContentWorker() : this._data instanceof h ? this._data : new o(this._data); } }; for (var u = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"], f = function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, d = 0; d < u.length; d++) r.prototype[u[d]] = f; n.exports = r; }, { "./compressedObject": 2, "./stream/DataWorker": 27, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31 }], 36: [function(t, n, i) { (function(r) { var a, o, l = r.MutationObserver || r.WebKitMutationObserver; if (l) { var c = 0, h = new l(p), u = r.document.createTextNode(""); h.observe(u, { characterData: !0 }), a = function() { u.data = c = ++c % 2; }; } else if (r.setImmediate || r.MessageChannel === void 0) a = "document" in r && "onreadystatechange" in r.document.createElement("script") ? function() { var g = r.document.createElement("script"); g.onreadystatechange = function() { p(), g.onreadystatechange = null, g.parentNode.removeChild(g), g = null; }, r.document.documentElement.appendChild(g); } : function() { setTimeout(p, 0); }; else { var f = new r.MessageChannel(); f.port1.onmessage = p, a = function() { f.port2.postMessage(0); }; } var d = []; function p() { var g, x; o = !0; for (var m = d.length; m; ) { for (x = d, d = [], g = -1; ++g < m; ) x[g](); m = d.length; } o = !1; } n.exports = function(g) { d.push(g) !== 1 || o || a(); }; }).call(this, typeof na < "u" ? na : typeof self < "u" ? self : typeof window < "u" ? window : {}); }, {}], 37: [function(t, n, i) { var r = t("immediate"); function a() { } var o = {}, l = ["REJECTED"], c = ["FULFILLED"], h = ["PENDING"]; function u(m) { if (typeof m != "function") throw new TypeError("resolver must be a function"); this.state = h, this.queue = [], this.outcome = void 0, m !== a && g(this, m); } function f(m, v, b) { this.promise = m, typeof v == "function" && (this.onFulfilled = v, this.callFulfilled = this.otherCallFulfilled), typeof b == "function" && (this.onRejected = b, this.callRejected = this.otherCallRejected); } function d(m, v, b) { r(function() { var M; try { M = v(b); } catch (C) { return o.reject(m, C); } M === m ? o.reject(m, new TypeError("Cannot resolve promise with itself")) : o.resolve(m, M); }); } function p(m) { var v = m && m.then; if (m && (typeof m == "object" || typeof m == "function") && typeof v == "function") return function() { v.apply(m, arguments); }; } function g(m, v) { var b = !1; function M(D) { b || (b = !0, o.reject(m, D)); } function C(D) { b || (b = !0, o.resolve(m, D)); } var T = x(function() { v(C, M); }); T.status === "error" && M(T.value); } function x(m, v) { var b = {}; try { b.value = m(v), b.status = "success"; } catch (M) { b.status = "error", b.value = M; } return b; } (n.exports = u).prototype.finally = function(m) { if (typeof m != "function") return this; var v = this.constructor; return this.then(function(b) { return v.resolve(m()).then(function() { return b; }); }, function(b) { return v.resolve(m()).then(function() { throw b; }); }); }, u.prototype.catch = function(m) { return this.then(null, m); }, u.prototype.then = function(m, v) { if (typeof m != "function" && this.state === c || typeof v != "function" && this.state === l) return this; var b = new this.constructor(a); return this.state !== h ? d(b, this.state === c ? m : v, this.outcome) : this.queue.push(new f(b, m, v)), b; }, f.prototype.callFulfilled = function(m) { o.resolve(this.promise, m); }, f.prototype.otherCallFulfilled = function(m) { d(this.promise, this.onFulfilled, m); }, f.prototype.callRejected = function(m) { o.reject(this.promise, m); }, f.prototype.otherCallRejected = function(m) { d(this.promise, this.onRejected, m); }, o.resolve = function(m, v) { var b = x(p, v); if (b.status === "error") return o.reject(m, b.value); var M = b.value; if (M) g(m, M); else { m.state = c, m.outcome = v; for (var C = -1, T = m.queue.length; ++C < T; ) m.queue[C].callFulfilled(v); } return m; }, o.reject = function(m, v) { m.state = l, m.outcome = v; for (var b = -1, M = m.queue.length; ++b < M; ) m.queue[b].callRejected(v); return m; }, u.resolve = function(m) { return m instanceof this ? m : o.resolve(new this(a), m); }, u.reject = function(m) { var v = new this(a); return o.reject(v, m); }, u.all = function(m) { var v = this; if (Object.prototype.toString.call(m) !== "[object Array]") return this.reject(new TypeError("must be an array")); var b = m.length, M = !1; if (!b) return this.resolve([]); for (var C = new Array(b), T = 0, D = -1, U = new this(a); ++D < b; ) S(m[D], D); return U; function S(w, B) { v.resolve(w).then(function(P) { C[B] = P, ++T !== b || M || (M = !0, o.resolve(U, C)); }, function(P) { M || (M = !0, o.reject(U, P)); }); } }, u.race = function(m) { var v = this; if (Object.prototype.toString.call(m) !== "[object Array]") return this.reject(new TypeError("must be an array")); var b = m.length, M = !1; if (!b) return this.resolve([]); for (var C = -1, T = new this(a); ++C < b; ) D = m[C], v.resolve(D).then(function(U) { M || (M = !0, o.resolve(T, U)); }, function(U) { M || (M = !0, o.reject(T, U)); }); var D; return T; }; }, { immediate: 36 }], 38: [function(t, n, i) { var r = {}; (0, t("./lib/utils/common").assign)(r, t("./lib/deflate"), t("./lib/inflate"), t("./lib/zlib/constants")), n.exports = r; }, { "./lib/deflate": 39, "./lib/inflate": 40, "./lib/utils/common": 41, "./lib/zlib/constants": 44 }], 39: [function(t, n, i) { var r = t("./zlib/deflate"), a = t("./utils/common"), o = t("./utils/strings"), l = t("./zlib/messages"), c = t("./zlib/zstream"), h = Object.prototype.toString, u = 0, f = -1, d = 0, p = 8; function g(m) { if (!(this instanceof g)) return new g(m); this.options = a.assign({ level: f, method: p, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: d, to: "" }, m || {}); var v = this.options; v.raw && 0 < v.windowBits ? v.windowBits = -v.windowBits : v.gzip && 0 < v.windowBits && v.windowBits < 16 && (v.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new c(), this.strm.avail_out = 0; var b = r.deflateInit2(this.strm, v.level, v.method, v.windowBits, v.memLevel, v.strategy); if (b !== u) throw new Error(l[b]); if (v.header && r.deflateSetHeader(this.strm, v.header), v.dictionary) { var M; if (M = typeof v.dictionary == "string" ? o.string2buf(v.dictionary) : h.call(v.dictionary) === "[object ArrayBuffer]" ? new Uint8Array(v.dictionary) : v.dictionary, (b = r.deflateSetDictionary(this.strm, M)) !== u) throw new Error(l[b]); this._dict_set = !0; } } function x(m, v) { var b = new g(v); if (b.push(m, !0), b.err) throw b.msg || l[b.err]; return b.result; } g.prototype.push = function(m, v) { var b, M, C = this.strm, T = this.options.chunkSize; if (this.ended) return !1; M = v === ~~v ? v : v === !0 ? 4 : 0, typeof m == "string" ? C.input = o.string2buf(m) : h.call(m) === "[object ArrayBuffer]" ? C.input = new Uint8Array(m) : C.input = m, C.next_in = 0, C.avail_in = C.input.length; do { if (C.avail_out === 0 && (C.output = new a.Buf8(T), C.next_out = 0, C.avail_out = T), (b = r.deflate(C, M)) !== 1 && b !== u) return this.onEnd(b), !(this.ended = !0); C.avail_out !== 0 && (C.avail_in !== 0 || M !== 4 && M !== 2) || (this.options.to === "string" ? this.onData(o.buf2binstring(a.shrinkBuf(C.output, C.next_out))) : this.onData(a.shrinkBuf(C.output, C.next_out))); } while ((0 < C.avail_in || C.avail_out === 0) && b !== 1); return M === 4 ? (b = r.deflateEnd(this.strm), this.onEnd(b), this.ended = !0, b === u) : M !== 2 || (this.onEnd(u), !(C.avail_out = 0)); }, g.prototype.onData = function(m) { this.chunks.push(m); }, g.prototype.onEnd = function(m) { m === u && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = a.flattenChunks(this.chunks)), this.chunks = [], this.err = m, this.msg = this.strm.msg; }, i.Deflate = g, i.deflate = x, i.deflateRaw = function(m, v) { return (v = v || {}).raw = !0, x(m, v); }, i.gzip = function(m, v) { return (v = v || {}).gzip = !0, x(m, v); }; }, { "./utils/common": 41, "./utils/strings": 42, "./zlib/deflate": 46, "./zlib/messages": 51, "./zlib/zstream": 53 }], 40: [function(t, n, i) { var r = t("./zlib/inflate"), a = t("./utils/common"), o = t("./utils/strings"), l = t("./zlib/constants"), c = t("./zlib/messages"), h = t("./zlib/zstream"), u = t("./zlib/gzheader"), f = Object.prototype.toString; function d(g) { if (!(this instanceof d)) return new d(g); this.options = a.assign({ chunkSize: 16384, windowBits: 0, to: "" }, g || {}); var x = this.options; x.raw && 0 <= x.windowBits && x.windowBits < 16 && (x.windowBits = -x.windowBits, x.windowBits === 0 && (x.windowBits = -15)), !(0 <= x.windowBits && x.windowBits < 16) || g && g.windowBits || (x.windowBits += 32), 15 < x.windowBits && x.windowBits < 48 && (15 & x.windowBits) == 0 && (x.windowBits |= 15), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new h(), this.strm.avail_out = 0; var m = r.inflateInit2(this.strm, x.windowBits); if (m !== l.Z_OK) throw new Error(c[m]); this.header = new u(), r.inflateGetHeader(this.strm, this.header); } function p(g, x) { var m = new d(x); if (m.push(g, !0), m.err) throw m.msg || c[m.err]; return m.result; } d.prototype.push = function(g, x) { var m, v, b, M, C, T, D = this.strm, U = this.options.chunkSize, S = this.options.dictionary, w = !1; if (this.ended) return !1; v = x === ~~x ? x : x === !0 ? l.Z_FINISH : l.Z_NO_FLUSH, typeof g == "string" ? D.input = o.binstring2buf(g) : f.call(g) === "[object ArrayBuffer]" ? D.input = new Uint8Array(g) : D.input = g, D.next_in = 0, D.avail_in = D.input.length; do { if (D.avail_out === 0 && (D.output = new a.Buf8(U), D.next_out = 0, D.avail_out = U), (m = r.inflate(D, l.Z_NO_FLUSH)) === l.Z_NEED_DICT && S && (T = typeof S == "string" ? o.string2buf(S) : f.call(S) === "[object ArrayBuffer]" ? new Uint8Array(S) : S, m = r.inflateSetDictionary(this.strm, T)), m === l.Z_BUF_ERROR && w === !0 && (m = l.Z_OK, w = !1), m !== l.Z_STREAM_END && m !== l.Z_OK) return this.onEnd(m), !(this.ended = !0); D.next_out && (D.avail_out !== 0 && m !== l.Z_STREAM_END && (D.avail_in !== 0 || v !== l.Z_FINISH && v !== l.Z_SYNC_FLUSH) || (this.options.to === "string" ? (b = o.utf8border(D.output, D.next_out), M = D.next_out - b, C = o.buf2string(D.output, b), D.next_out = M, D.avail_out = U - M, M && a.arraySet(D.output, D.output, b, M, 0), this.onData(C)) : this.onData(a.shrinkBuf(D.output, D.next_out)))), D.avail_in === 0 && D.avail_out === 0 && (w = !0); } while ((0 < D.avail_in || D.avail_out === 0) && m !== l.Z_STREAM_END); return m === l.Z_STREAM_END && (v = l.Z_FINISH), v === l.Z_FINISH ? (m = r.inflateEnd(this.strm), this.onEnd(m), this.ended = !0, m === l.Z_OK) : v !== l.Z_SYNC_FLUSH || (this.onEnd(l.Z_OK), !(D.avail_out = 0)); }, d.prototype.onData = function(g) { this.chunks.push(g); }, d.prototype.onEnd = function(g) { g === l.Z_OK && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = a.flattenChunks(this.chunks)), this.chunks = [], this.err = g, this.msg = this.strm.msg; }, i.Inflate = d, i.inflate = p, i.inflateRaw = function(g, x) { return (x = x || {}).raw = !0, p(g, x); }, i.ungzip = p; }, { "./utils/common": 41, "./utils/strings": 42, "./zlib/constants": 44, "./zlib/gzheader": 47, "./zlib/inflate": 49, "./zlib/messages": 51, "./zlib/zstream": 53 }], 41: [function(t, n, i) { var r = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Int32Array < "u"; i.assign = function(l) { for (var c = Array.prototype.slice.call(arguments, 1); c.length; ) { var h = c.shift(); if (h) { if (typeof h != "object") throw new TypeError(h + "must be non-object"); for (var u in h) h.hasOwnProperty(u) && (l[u] = h[u]); } } return l; }, i.shrinkBuf = function(l, c) { return l.length === c ? l : l.subarray ? l.subarray(0, c) : (l.length = c, l); }; var a = { arraySet: function(l, c, h, u, f) { if (c.subarray && l.subarray) l.set(c.subarray(h, h + u), f); else for (var d = 0; d < u; d++) l[f + d] = c[h + d]; }, flattenChunks: function(l) { var c, h, u, f, d, p; for (c = u = 0, h = l.length; c < h; c++) u += l[c].length; for (p = new Uint8Array(u), c = f = 0, h = l.length; c < h; c++) d = l[c], p.set(d, f), f += d.length; return p; } }, o = { arraySet: function(l, c, h, u, f) { for (var d = 0; d < u; d++) l[f + d] = c[h + d]; }, flattenChunks: function(l) { return [].concat.apply([], l); } }; i.setTyped = function(l) { l ? (i.Buf8 = Uint8Array, i.Buf16 = Uint16Array, i.Buf32 = Int32Array, i.assign(i, a)) : (i.Buf8 = Array, i.Buf16 = Array, i.Buf32 = Array, i.assign(i, o)); }, i.setTyped(r); }, {}], 42: [function(t, n, i) { var r = t("./common"), a = !0, o = !0; try { String.fromCharCode.apply(null, [0]); } catch { a = !1; } try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch { o = !1; } for (var l = new r.Buf8(256), c = 0; c < 256; c++) l[c] = 252 <= c ? 6 : 248 <= c ? 5 : 240 <= c ? 4 : 224 <= c ? 3 : 192 <= c ? 2 : 1; function h(u, f) { if (f < 65537 && (u.subarray && o || !u.subarray && a)) return String.fromCharCode.apply(null, r.shrinkBuf(u, f)); for (var d = "", p = 0; p < f; p++) d += String.fromCharCode(u[p]); return d; } l[254] = l[254] = 1, i.string2buf = function(u) { var f, d, p, g, x, m = u.length, v = 0; for (g = 0; g < m; g++) (64512 & (d = u.charCodeAt(g))) == 55296 && g + 1 < m && (64512 & (p = u.charCodeAt(g + 1))) == 56320 && (d = 65536 + (d - 55296 << 10) + (p - 56320), g++), v += d < 128 ? 1 : d < 2048 ? 2 : d < 65536 ? 3 : 4; for (f = new r.Buf8(v), g = x = 0; x < v; g++) (64512 & (d = u.charCodeAt(g))) == 55296 && g + 1 < m && (64512 & (p = u.charCodeAt(g + 1))) == 56320 && (d = 65536 + (d - 55296 << 10) + (p - 56320), g++), d < 128 ? f[x++] = d : (d < 2048 ? f[x++] = 192 | d >>> 6 : (d < 65536 ? f[x++] = 224 | d >>> 12 : (f[x++] = 240 | d >>> 18, f[x++] = 128 | d >>> 12 & 63), f[x++] = 128 | d >>> 6 & 63), f[x++] = 128 | 63 & d); return f; }, i.buf2binstring = function(u) { return h(u, u.length); }, i.binstring2buf = function(u) { for (var f = new r.Buf8(u.length), d = 0, p = f.length; d < p; d++) f[d] = u.charCodeAt(d); return f; }, i.buf2string = function(u, f) { var d, p, g, x, m = f || u.length, v = new Array(2 * m); for (d = p = 0; d < m; ) if ((g = u[d++]) < 128) v[p++] = g; else if (4 < (x = l[g])) v[p++] = 65533, d += x - 1; else { for (g &= x === 2 ? 31 : x === 3 ? 15 : 7; 1 < x && d < m; ) g = g << 6 | 63 & u[d++], x--; 1 < x ? v[p++] = 65533 : g < 65536 ? v[p++] = g : (g -= 65536, v[p++] = 55296 | g >> 10 & 1023, v[p++] = 56320 | 1023 & g); } return h(v, p); }, i.utf8border = function(u, f) { var d; for ((f = f || u.length) > u.length && (f = u.length), d = f - 1; 0 <= d && (192 & u[d]) == 128; ) d--; return d < 0 || d === 0 ? f : d + l[u[d]] > f ? d : f; }; }, { "./common": 41 }], 43: [function(t, n, i) { n.exports = function(r, a, o, l) { for (var c = 65535 & r | 0, h = r >>> 16 & 65535 | 0, u = 0; o !== 0; ) { for (o -= u = 2e3 < o ? 2e3 : o; h = h + (c = c + a[l++] | 0) | 0, --u; ) ; c %= 65521, h %= 65521; } return c | h << 16 | 0; }; }, {}], 44: [function(t, n, i) { n.exports = { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_TREES: 6, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_BUF_ERROR: -5, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, Z_BINARY: 0, Z_TEXT: 1, Z_UNKNOWN: 2, Z_DEFLATED: 8 }; }, {}], 45: [function(t, n, i) { var r = (function() { for (var a, o = [], l = 0; l < 256; l++) { a = l; for (var c = 0; c < 8; c++) a = 1 & a ? 3988292384 ^ a >>> 1 : a >>> 1; o[l] = a; } return o; })(); n.exports = function(a, o, l, c) { var h = r, u = c + l; a ^= -1; for (var f = c; f < u; f++) a = a >>> 8 ^ h[255 & (a ^ o[f])]; return -1 ^ a; }; }, {}], 46: [function(t, n, i) { var r, a = t("../utils/common"), o = t("./trees"), l = t("./adler32"), c = t("./crc32"), h = t("./messages"), u = 0, f = 4, d = 0, p = -2, g = -1, x = 4, m = 2, v = 8, b = 9, M = 286, C = 30, T = 19, D = 2 * M + 1, U = 15, S = 3, w = 258, B = w + S + 1, P = 42, O = 113, y = 1, H = 2, Y = 3, j = 4; function J(_, A) { return _.msg = h[A], A; } function Z(_) { return (_ << 1) - (4 < _ ? 9 : 0); } function ae(_) { for (var A = _.length; 0 <= --A; ) _[A] = 0; } function X(_) { var A = _.state, V = A.pending; V > _.avail_out && (V = _.avail_out), V !== 0 && (a.arraySet(_.output, A.pending_buf, A.pending_out, V, _.next_out), _.next_out += V, A.pending_out += V, _.total_out += V, _.avail_out -= V, A.pending -= V, A.pending === 0 && (A.pending_out = 0)); } function q(_, A) { o._tr_flush_block(_, 0 <= _.block_start ? _.block_start : -1, _.strstart - _.block_start, A), _.block_start = _.strstart, X(_.strm); } function ge(_, A) { _.pending_buf[_.pending++] = A; } function pe(_, A) { _.pending_buf[_.pending++] = A >>> 8 & 255, _.pending_buf[_.pending++] = 255 & A; } function de(_, A) { var V, N, I = _.max_chain_length, F = _.strstart, ee = _.prev_length, $ = _.nice_match, G = _.strstart > _.w_size - B ? _.strstart - (_.w_size - B) : 0, L = _.window, E = _.w_mask, z = _.prev, K = _.strstart + w, le = L[F + ee - 1], te = L[F + ee]; _.prev_length >= _.good_match && (I >>= 2), $ > _.lookahead && ($ = _.lookahead); do if (L[(V = A) + ee] === te && L[V + ee - 1] === le && L[V] === L[F] && L[++V] === L[F + 1]) { F += 2, V++; do ; while (L[++F] === L[++V] && L[++F] === L[++V] && L[++F] === L[++V] && L[++F] === L[++V] && L[++F] === L[++V] && L[++F] === L[++V] && L[++F] === L[++V] && L[++F] === L[++V] && F < K); if (N = w - (K - F), F = K - w, ee < N) { if (_.match_start = A, $ <= (ee = N)) break; le = L[F + ee - 1], te = L[F + ee]; } } while ((A = z[A & E]) > G && --I != 0); return ee <= _.lookahead ? ee : _.lookahead; } function ie(_) { var A, V, N, I, F, ee, $, G, L, E, z = _.w_size; do { if (I = _.window_size - _.lookahead - _.strstart, _.strstart >= z + (z - B)) { for (a.arraySet(_.window, _.window, z, z, 0), _.match_start -= z, _.strstart -= z, _.block_start -= z, A = V = _.hash_size; N = _.head[--A], _.head[A] = z <= N ? N - z : 0, --V; ) ; for (A = V = z; N = _.prev[--A], _.prev[A] = z <= N ? N - z : 0, --V; ) ; I += z; } if (_.strm.avail_in === 0) break; if (ee = _.strm, $ = _.window, G = _.strstart + _.lookahead, L = I, E = void 0, E = ee.avail_in, L < E && (E = L), V = E === 0 ? 0 : (ee.avail_in -= E, a.arraySet($, ee.input, ee.next_in, E, G), ee.state.wrap === 1 ? ee.adler = l(ee.adler, $, E, G) : ee.state.wrap === 2 && (ee.adler = c(ee.adler, $, E, G)), ee.next_in += E, ee.total_in += E, E), _.lookahead += V, _.lookahead + _.insert >= S) for (F = _.strstart - _.insert, _.ins_h = _.window[F], _.ins_h = (_.ins_h << _.hash_shift ^ _.window[F + 1]) & _.hash_mask; _.insert && (_.ins_h = (_.ins_h << _.hash_shift ^ _.window[F + S - 1]) & _.hash_mask, _.prev[F & _.w_mask] = _.head[_.ins_h], _.head[_.ins_h] = F, F++, _.insert--, !(_.lookahead + _.insert < S)); ) ; } while (_.lookahead < B && _.strm.avail_in !== 0); } function ce(_, A) { for (var V, N; ; ) { if (_.lookahead < B) { if (ie(_), _.lookahead < B && A === u) return y; if (_.lookahead === 0) break; } if (V = 0, _.lookahead >= S && (_.ins_h = (_.ins_h << _.hash_shift ^ _.window[_.strstart + S - 1]) & _.hash_mask, V = _.prev[_.strstart & _.w_mask] = _.head[_.ins_h], _.head[_.ins_h] = _.strstart), V !== 0 && _.strstart - V <= _.w_size - B && (_.match_length = de(_, V)), _.match_length >= S) if (N = o._tr_tally(_, _.strstart - _.match_start, _.match_length - S), _.lookahead -= _.match_length, _.match_length <= _.max_lazy_match && _.lookahead >= S) { for (_.match_length--; _.strstart++, _.ins_h = (_.ins_h << _.hash_shift ^ _.window[_.strstart + S - 1]) & _.hash_mask, V = _.prev[_.strstart & _.w_mask] = _.head[_.ins_h], _.head[_.ins_h] = _.strstart, --_.match_length != 0; ) ; _.strstart++; } else _.strstart += _.match_length, _.match_length = 0, _.ins_h = _.window[_.strstart], _.ins_h = (_.ins_h << _.hash_shift ^ _.window[_.strstart + 1]) & _.hash_mask; else N = o._tr_tally(_, 0, _.window[_.strstart]), _.lookahead--, _.strstart++; if (N && (q(_, !1), _.strm.avail_out === 0)) return y; } return _.insert = _.strstart < S - 1 ? _.strstart : S - 1, A === f ? (q(_, !0), _.strm.avail_out === 0 ? Y : j) : _.last_lit && (q(_, !1), _.strm.avail_out === 0) ? y : H; } function fe(_, A) { for (var V, N, I; ; ) { if (_.lookahead < B) { if (ie(_), _.lookahead < B && A === u) return y; if (_.lookahead === 0) break; } if (V = 0, _.lookahead >= S && (_.ins_h = (_.ins_h << _.hash_shift ^ _.window[_.strstart + S - 1]) & _.hash_mask, V = _.prev[_.strstart & _.w_mask] = _.head[_.ins_h], _.head[_.ins_h] = _.strstart), _.prev_length = _.match_length, _.prev_match = _.match_start, _.match_length = S - 1, V !== 0 && _.prev_length < _.max_lazy_match && _.strstart - V <= _.w_size - B && (_.match_length = de(_, V), _.match_length <= 5 && (_.strategy === 1 || _.match_length === S && 4096 < _.strstart - _.match_start) && (_.match_length = S - 1)), _.prev_length >= S && _.match_length <= _.prev_length) { for (I = _.strstart + _.lookahead - S, N = o._tr_tally(_, _.strstart - 1 - _.prev_match, _.prev_length - S), _.lookahead -= _.prev_length - 1, _.prev_length -= 2; ++_.strstart <= I && (_.ins_h = (_.ins_h << _.hash_shift ^ _.window[_.strstart + S - 1]) & _.hash_mask, V = _.prev[_.strstart & _.w_mask] = _.head[_.ins_h], _.head[_.ins_h] = _.strstart), --_.prev_length != 0; ) ; if (_.match_available = 0, _.match_length = S - 1, _.strstart++, N && (q(_, !1), _.strm.avail_out === 0)) return y; } else if (_.match_available) { if ((N = o._tr_tally(_, 0, _.window[_.strstart - 1])) && q(_, !1), _.strstart++, _.lookahead--, _.strm.avail_out === 0) return y; } else _.match_available = 1, _.strstart++, _.lookahead--; } return _.match_available && (N = o._tr_tally(_, 0, _.window[_.strstart - 1]), _.match_available = 0), _.insert = _.strstart < S - 1 ? _.strstart : S - 1, A === f ? (q(_, !0), _.strm.avail_out === 0 ? Y : j) : _.last_lit && (q(_, !1), _.strm.avail_out === 0) ? y : H; } function ve(_, A, V, N, I) { this.good_length = _, this.max_lazy = A, this.nice_length = V, this.max_chain = N, this.func = I; } function Ee() { this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = v, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new a.Buf16(2 * D), this.dyn_dtree = new a.Buf16(2 * (2 * C + 1)), this.bl_tree = new a.Buf16(2 * (2 * T + 1)), ae(this.dyn_ltree), ae(this.dyn_dtree), ae(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new a.Buf16(U + 1), this.heap = new a.Buf16(2 * M + 1), ae(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new a.Buf16(2 * M + 1), ae(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; } function Ne(_) { var A; return _ && _.state ? (_.total_in = _.total_out = 0, _.data_type = m, (A = _.state).pending = 0, A.pending_out = 0, A.wrap < 0 && (A.wrap = -A.wrap), A.status = A.wrap ? P : O, _.adler = A.wrap === 2 ? 0 : 1, A.last_flush = u, o._tr_init(A), d) : J(_, p); } function Ye(_) { var A = Ne(_); return A === d && (function(V) { V.window_size = 2 * V.w_size, ae(V.head), V.max_lazy_match = r[V.level].max_lazy, V.good_match = r[V.level].good_length, V.nice_match = r[V.level].nice_length, V.max_chain_length = r[V.level].max_chain, V.strstart = 0, V.block_start = 0, V.lookahead = 0, V.insert = 0, V.match_length = V.prev_length = S - 1, V.match_available = 0, V.ins_h = 0; })(_.state), A; } function ke(_, A, V, N, I, F) { if (!_) return p; var ee = 1; if (A === g && (A = 6), N < 0 ? (ee = 0, N = -N) : 15 < N && (ee = 2, N -= 16), I < 1 || b < I || V !== v || N < 8 || 15 < N || A < 0 || 9 < A || F < 0 || x < F) return J(_, p); N === 8 && (N = 9); var $ = new Ee(); return (_.state = $).strm = _, $.wrap = ee, $.gzhead = null, $.w_bits = N, $.w_size = 1 << $.w_bits, $.w_mask = $.w_size - 1, $.hash_bits = I + 7, $.hash_size = 1 << $.hash_bits, $.hash_mask = $.hash_size - 1, $.hash_shift = ~~(($.hash_bits + S - 1) / S), $.window = new a.Buf8(2 * $.w_size), $.head = new a.Buf16($.hash_size), $.prev = new a.Buf16($.w_size), $.lit_bufsize = 1 << I + 6, $.pending_buf_size = 4 * $.lit_bufsize, $.pending_buf = new a.Buf8($.pending_buf_size), $.d_buf = 1 * $.lit_bufsize, $.l_buf = 3 * $.lit_bufsize, $.level = A, $.strategy = F, $.method = V, Ye(_); } r = [new ve(0, 0, 0, 0, function(_, A) { var V = 65535; for (V > _.pending_buf_size - 5 && (V = _.pending_buf_size - 5); ; ) { if (_.lookahead <= 1) { if (ie(_), _.lookahead === 0 && A === u) return y; if (_.lookahead === 0) break; } _.strstart += _.lookahead, _.lookahead = 0; var N = _.block_start + V; if ((_.strstart === 0 || _.strstart >= N) && (_.lookahead = _.strstart - N, _.strstart = N, q(_, !1), _.strm.avail_out === 0) || _.strstart - _.block_start >= _.w_size - B && (q(_, !1), _.strm.avail_out === 0)) return y; } return _.insert = 0, A === f ? (q(_, !0), _.strm.avail_out === 0 ? Y : j) : (_.strstart > _.block_start && (q(_, !1), _.strm.avail_out), y); }), new ve(4, 4, 8, 4, ce), new ve(4, 5, 16, 8, ce), new ve(4, 6, 32, 32, ce), new ve(4, 4, 16, 16, fe), new ve(8, 16, 32, 32, fe), new ve(8, 16, 128, 128, fe), new ve(8, 32, 128, 256, fe), new ve(32, 128, 258, 1024, fe), new ve(32, 258, 258, 4096, fe)], i.deflateInit = function(_, A) { return ke(_, A, v, 15, 8, 0); }, i.deflateInit2 = ke, i.deflateReset = Ye, i.deflateResetKeep = Ne, i.deflateSetHeader = function(_, A) { return _ && _.state ? _.state.wrap !== 2 ? p : (_.state.gzhead = A, d) : p; }, i.deflate = function(_, A) { var V, N, I, F; if (!_ || !_.state || 5 < A || A < 0) return _ ? J(_, p) : p; if (N = _.state, !_.output || !_.input && _.avail_in !== 0 || N.status === 666 && A !== f) return J(_, _.avail_out === 0 ? -5 : p); if (N.strm = _, V = N.last_flush, N.last_flush = A, N.status === P) if (N.wrap === 2) _.adler = 0, ge(N, 31), ge(N, 139), ge(N, 8), N.gzhead ? (ge(N, (N.gzhead.text ? 1 : 0) + (N.gzhead.hcrc ? 2 : 0) + (N.gzhead.extra ? 4 : 0) + (N.gzhead.name ? 8 : 0) + (N.gzhead.comment ? 16 : 0)), ge(N, 255 & N.gzhead.time), ge(N, N.gzhead.time >> 8 & 255), ge(N, N.gzhead.time >> 16 & 255), ge(N, N.gzhead.time >> 24 & 255), ge(N, N.level === 9 ? 2 : 2 <= N.strategy || N.level < 2 ? 4 : 0), ge(N, 255 & N.gzhead.os), N.gzhead.extra && N.gzhead.extra.length && (ge(N, 255 & N.gzhead.extra.length), ge(N, N.gzhead.extra.length >> 8 & 255)), N.gzhead.hcrc && (_.adler = c(_.adler, N.pending_buf, N.pending, 0)), N.gzindex = 0, N.status = 69) : (ge(N, 0), ge(N, 0), ge(N, 0), ge(N, 0), ge(N, 0), ge(N, N.level === 9 ? 2 : 2 <= N.strategy || N.level < 2 ? 4 : 0), ge(N, 3), N.status = O); else { var ee = v + (N.w_bits - 8 << 4) << 8; ee |= (2 <= N.strategy || N.level < 2 ? 0 : N.level < 6 ? 1 : N.level === 6 ? 2 : 3) << 6, N.strstart !== 0 && (ee |= 32), ee += 31 - ee % 31, N.status = O, pe(N, ee), N.strstart !== 0 && (pe(N, _.adler >>> 16), pe(N, 65535 & _.adler)), _.adler = 1; } if (N.status === 69) if (N.gzhead.extra) { for (I = N.pending; N.gzindex < (65535 & N.gzhead.extra.length) && (N.pending !== N.pending_buf_size || (N.gzhead.hcrc && N.pending > I && (_.adler = c(_.adler, N.pending_buf, N.pending - I, I)), X(_), I = N.pending, N.pending !== N.pending_buf_size)); ) ge(N, 255 & N.gzhead.extra[N.gzindex]), N.gzindex++; N.gzhead.hcrc && N.pending > I && (_.adler = c(_.adler, N.pending_buf, N.pending - I, I)), N.gzindex === N.gzhead.extra.length && (N.gzindex = 0, N.status = 73); } else N.status = 73; if (N.status === 73) if (N.gzhead.name) { I = N.pending; do { if (N.pending === N.pending_buf_size && (N.gzhead.hcrc && N.pending > I && (_.adler = c(_.adler, N.pending_buf, N.pending - I, I)), X(_), I = N.pending, N.pending === N.pending_buf_size)) { F = 1; break; } F = N.gzindex < N.gzhead.name.length ? 255 & N.gzhead.name.charCodeAt(N.gzindex++) : 0, ge(N, F); } while (F !== 0); N.gzhead.hcrc && N.pending > I && (_.adler = c(_.adler, N.pending_buf, N.pending - I, I)), F === 0 && (N.gzindex = 0, N.status = 91); } else N.status = 91; if (N.status === 91) if (N.gzhead.comment) { I = N.pending; do { if (N.pending === N.pending_buf_size && (N.gzhead.hcrc && N.pending > I && (_.adler = c(_.adler, N.pending_buf, N.pending - I, I)), X(_), I = N.pending, N.pending === N.pending_buf_size)) { F = 1; break; } F = N.gzindex < N.gzhead.comment.length ? 255 & N.gzhead.comment.charCodeAt(N.gzindex++) : 0, ge(N, F); } while (F !== 0); N.gzhead.hcrc && N.pending > I && (_.adler = c(_.adler, N.pending_buf, N.pending - I, I)), F === 0 && (N.status = 103); } else N.status = 103; if (N.status === 103 && (N.gzhead.hcrc ? (N.pending + 2 > N.pending_buf_size && X(_), N.pending + 2 <= N.pending_buf_size && (ge(N, 255 & _.adler), ge(N, _.adler >> 8 & 255), _.adler = 0, N.status = O)) : N.status = O), N.pending !== 0) { if (X(_), _.avail_out === 0) return N.last_flush = -1, d; } else if (_.avail_in === 0 && Z(A) <= Z(V) && A !== f) return J(_, -5); if (N.status === 666 && _.avail_in !== 0) return J(_, -5); if (_.avail_in !== 0 || N.lookahead !== 0 || A !== u && N.status !== 666) { var $ = N.strategy === 2 ? (function(G, L) { for (var E; ; ) { if (G.lookahead === 0 && (ie(G), G.lookahead === 0)) { if (L === u) return y; break; } if (G.match_length = 0, E = o._tr_tally(G, 0, G.window[G.strstart]), G.lookahead--, G.strstart++, E && (q(G, !1), G.strm.avail_out === 0)) return y; } return G.insert = 0, L === f ? (q(G, !0), G.strm.avail_out === 0 ? Y : j) : G.last_lit && (q(G, !1), G.strm.avail_out === 0) ? y : H; })(N, A) : N.strategy === 3 ? (function(G, L) { for (var E, z, K, le, te = G.window; ; ) { if (G.lookahead <= w) { if (ie(G), G.lookahead <= w && L === u) return y; if (G.lookahead === 0) break; } if (G.match_length = 0, G.lookahead >= S && 0 < G.strstart && (z = te[K = G.strstart - 1]) === te[++K] && z === te[++K] && z === te[++K]) { le = G.strstart + w; do ; while (z === te[++K] && z === te[++K] && z === te[++K] && z === te[++K] && z === te[++K] && z === te[++K] && z === te[++K] && z === te[++K] && K < le); G.match_length = w - (le - K), G.match_length > G.lookahead && (G.match_length = G.lookahead); } if (G.match_length >= S ? (E = o._tr_tally(G, 1, G.match_length - S), G.lookahead -= G.match_length, G.strstart += G.match_length, G.match_length = 0) : (E = o._tr_tally(G, 0, G.window[G.strstart]), G.lookahead--, G.strstart++), E && (q(G, !1), G.strm.avail_out === 0)) return y; } return G.insert = 0, L === f ? (q(G, !0), G.strm.avail_out === 0 ? Y : j) : G.last_lit && (q(G, !1), G.strm.avail_out === 0) ? y : H; })(N, A) : r[N.level].func(N, A); if ($ !== Y && $ !== j || (N.status = 666), $ === y || $ === Y) return _.avail_out === 0 && (N.last_flush = -1), d; if ($ === H && (A === 1 ? o._tr_align(N) : A !== 5 && (o._tr_stored_block(N, 0, 0, !1), A === 3 && (ae(N.head), N.lookahead === 0 && (N.strstart = 0, N.block_start = 0, N.insert = 0))), X(_), _.avail_out === 0)) return N.last_flush = -1, d; } return A !== f ? d : N.wrap <= 0 ? 1 : (N.wrap === 2 ? (ge(N, 255 & _.adler), ge(N, _.adler >> 8 & 255), ge(N, _.adler >> 16 & 255), ge(N, _.adler >> 24 & 255), ge(N, 255 & _.total_in), ge(N, _.total_in >> 8 & 255), ge(N, _.total_in >> 16 & 255), ge(N, _.total_in >> 24 & 255)) : (pe(N, _.adler >>> 16), pe(N, 65535 & _.adler)), X(_), 0 < N.wrap && (N.wrap = -N.wrap), N.pending !== 0 ? d : 1); }, i.deflateEnd = function(_) { var A; return _ && _.state ? (A = _.state.status) !== P && A !== 69 && A !== 73 && A !== 91 && A !== 103 && A !== O && A !== 666 ? J(_, p) : (_.state = null, A === O ? J(_, -3) : d) : p; }, i.deflateSetDictionary = function(_, A) { var V, N, I, F, ee, $, G, L, E = A.length; if (!_ || !_.state || (F = (V = _.state).wrap) === 2 || F === 1 && V.status !== P || V.lookahead) return p; for (F === 1 && (_.adler = l(_.adler, A, E, 0)), V.wrap = 0, E >= V.w_size && (F === 0 && (ae(V.head), V.strstart = 0, V.block_start = 0, V.insert = 0), L = new a.Buf8(V.w_size), a.arraySet(L, A, E - V.w_size, V.w_size, 0), A = L, E = V.w_size), ee = _.avail_in, $ = _.next_in, G = _.input, _.avail_in = E, _.next_in = 0, _.input = A, ie(V); V.lookahead >= S; ) { for (N = V.strstart, I = V.lookahead - (S - 1); V.ins_h = (V.ins_h << V.hash_shift ^ V.window[N + S - 1]) & V.hash_mask, V.prev[N & V.w_mask] = V.head[V.ins_h], V.head[V.ins_h] = N, N++, --I; ) ; V.strstart = N, V.lookahead = S - 1, ie(V); } return V.strstart += V.lookahead, V.block_start = V.strstart, V.insert = V.lookahead, V.lookahead = 0, V.match_length = V.prev_length = S - 1, V.match_available = 0, _.next_in = $, _.input = G, _.avail_in = ee, V.wrap = F, d; }, i.deflateInfo = "pako deflate (from Nodeca project)"; }, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./messages": 51, "./trees": 52 }], 47: [function(t, n, i) { n.exports = function() { this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; }; }, {}], 48: [function(t, n, i) { n.exports = function(r, a) { var o, l, c, h, u, f, d, p, g, x, m, v, b, M, C, T, D, U, S, w, B, P, O, y, H; o = r.state, l = r.next_in, y = r.input, c = l + (r.avail_in - 5), h = r.next_out, H = r.output, u = h - (a - r.avail_out), f = h + (r.avail_out - 257), d = o.dmax, p = o.wsize, g = o.whave, x = o.wnext, m = o.window, v = o.hold, b = o.bits, M = o.lencode, C = o.distcode, T = (1 << o.lenbits) - 1, D = (1 << o.distbits) - 1; e: do { b < 15 && (v += y[l++] << b, b += 8, v += y[l++] << b, b += 8), U = M[v & T]; t: for (; ; ) { if (v >>>= S = U >>> 24, b -= S, (S = U >>> 16 & 255) === 0) H[h++] = 65535 & U; else { if (!(16 & S)) { if ((64 & S) == 0) { U = M[(65535 & U) + (v & (1 << S) - 1)]; continue t; } if (32 & S) { o.mode = 12; break e; } r.msg = "invalid literal/length code", o.mode = 30; break e; } w = 65535 & U, (S &= 15) && (b < S && (v += y[l++] << b, b += 8), w += v & (1 << S) - 1, v >>>= S, b -= S), b < 15 && (v += y[l++] << b, b += 8, v += y[l++] << b, b += 8), U = C[v & D]; n: for (; ; ) { if (v >>>= S = U >>> 24, b -= S, !(16 & (S = U >>> 16 & 255))) { if ((64 & S) == 0) { U = C[(65535 & U) + (v & (1 << S) - 1)]; continue n; } r.msg = "invalid distance code", o.mode = 30; break e; } if (B = 65535 & U, b < (S &= 15) && (v += y[l++] << b, (b += 8) < S && (v += y[l++] << b, b += 8)), d < (B += v & (1 << S) - 1)) { r.msg = "invalid distance too far back", o.mode = 30; break e; } if (v >>>= S, b -= S, (S = h - u) < B) { if (g < (S = B - S) && o.sane) { r.msg = "invalid distance too far back", o.mode = 30; break e; } if (O = m, (P = 0) === x) { if (P += p - S, S < w) { for (w -= S; H[h++] = m[P++], --S; ) ; P = h - B, O = H; } } else if (x < S) { if (P += p + x - S, (S -= x) < w) { for (w -= S; H[h++] = m[P++], --S; ) ; if (P = 0, x < w) { for (w -= S = x; H[h++] = m[P++], --S; ) ; P = h - B, O = H; } } } else if (P += x - S, S < w) { for (w -= S; H[h++] = m[P++], --S; ) ; P = h - B, O = H; } for (; 2 < w; ) H[h++] = O[P++], H[h++] = O[P++], H[h++] = O[P++], w -= 3; w && (H[h++] = O[P++], 1 < w && (H[h++] = O[P++])); } else { for (P = h - B; H[h++] = H[P++], H[h++] = H[P++], H[h++] = H[P++], 2 < (w -= 3); ) ; w && (H[h++] = H[P++], 1 < w && (H[h++] = H[P++])); } break; } } break; } } while (l < c && h < f); l -= w = b >> 3, v &= (1 << (b -= w << 3)) - 1, r.next_in = l, r.next_out = h, r.avail_in = l < c ? c - l + 5 : 5 - (l - c), r.avail_out = h < f ? f - h + 257 : 257 - (h - f), o.hold = v, o.bits = b; }; }, {}], 49: [function(t, n, i) { var r = t("../utils/common"), a = t("./adler32"), o = t("./crc32"), l = t("./inffast"), c = t("./inftrees"), h = 1, u = 2, f = 0, d = -2, p = 1, g = 852, x = 592; function m(P) { return (P >>> 24 & 255) + (P >>> 8 & 65280) + ((65280 & P) << 8) + ((255 & P) << 24); } function v() { this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new r.Buf16(320), this.work = new r.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; } function b(P) { var O; return P && P.state ? (O = P.state, P.total_in = P.total_out = O.total = 0, P.msg = "", O.wrap && (P.adler = 1 & O.wrap), O.mode = p, O.last = 0, O.havedict = 0, O.dmax = 32768, O.head = null, O.hold = 0, O.bits = 0, O.lencode = O.lendyn = new r.Buf32(g), O.distcode = O.distdyn = new r.Buf32(x), O.sane = 1, O.back = -1, f) : d; } function M(P) { var O; return P && P.state ? ((O = P.state).wsize = 0, O.whave = 0, O.wnext = 0, b(P)) : d; } function C(P, O) { var y, H; return P && P.state ? (H = P.state, O < 0 ? (y = 0, O = -O) : (y = 1 + (O >> 4), O < 48 && (O &= 15)), O && (O < 8 || 15 < O) ? d : (H.window !== null && H.wbits !== O && (H.window = null), H.wrap = y, H.wbits = O, M(P))) : d; } function T(P, O) { var y, H; return P ? (H = new v(), (P.state = H).window = null, (y = C(P, O)) !== f && (P.state = null), y) : d; } var D, U, S = !0; function w(P) { if (S) { var O; for (D = new r.Buf32(512), U = new r.Buf32(32), O = 0; O < 144; ) P.lens[O++] = 8; for (; O < 256; ) P.lens[O++] = 9; for (; O < 280; ) P.lens[O++] = 7; for (; O < 288; ) P.lens[O++] = 8; for (c(h, P.lens, 0, 288, D, 0, P.work, { bits: 9 }), O = 0; O < 32; ) P.lens[O++] = 5; c(u, P.lens, 0, 32, U, 0, P.work, { bits: 5 }), S = !1; } P.lencode = D, P.lenbits = 9, P.distcode = U, P.distbits = 5; } function B(P, O, y, H) { var Y, j = P.state; return j.window === null && (j.wsize = 1 << j.wbits, j.wnext = 0, j.whave = 0, j.window = new r.Buf8(j.wsize)), H >= j.wsize ? (r.arraySet(j.window, O, y - j.wsize, j.wsize, 0), j.wnext = 0, j.whave = j.wsize) : (H < (Y = j.wsize - j.wnext) && (Y = H), r.arraySet(j.window, O, y - H, Y, j.wnext), (H -= Y) ? (r.arraySet(j.window, O, y - H, H, 0), j.wnext = H, j.whave = j.wsize) : (j.wnext += Y, j.wnext === j.wsize && (j.wnext = 0), j.whave < j.wsize && (j.whave += Y))), 0; } i.inflateReset = M, i.inflateReset2 = C, i.inflateResetKeep = b, i.inflateInit = function(P) { return T(P, 15); }, i.inflateInit2 = T, i.inflate = function(P, O) { var y, H, Y, j, J, Z, ae, X, q, ge, pe, de, ie, ce, fe, ve, Ee, Ne, Ye, ke, _, A, V, N, I = 0, F = new r.Buf8(4), ee = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; if (!P || !P.state || !P.output || !P.input && P.avail_in !== 0) return d; (y = P.state).mode === 12 && (y.mode = 13), J = P.next_out, Y = P.output, ae = P.avail_out, j = P.next_in, H = P.input, Z = P.avail_in, X = y.hold, q = y.bits, ge = Z, pe = ae, A = f; e: for (; ; ) switch (y.mode) { case p: if (y.wrap === 0) { y.mode = 13; break; } for (; q < 16; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if (2 & y.wrap && X === 35615) { F[y.check = 0] = 255 & X, F[1] = X >>> 8 & 255, y.check = o(y.check, F, 2, 0), q = X = 0, y.mode = 2; break; } if (y.flags = 0, y.head && (y.head.done = !1), !(1 & y.wrap) || (((255 & X) << 8) + (X >> 8)) % 31) { P.msg = "incorrect header check", y.mode = 30; break; } if ((15 & X) != 8) { P.msg = "unknown compression method", y.mode = 30; break; } if (q -= 4, _ = 8 + (15 & (X >>>= 4)), y.wbits === 0) y.wbits = _; else if (_ > y.wbits) { P.msg = "invalid window size", y.mode = 30; break; } y.dmax = 1 << _, P.adler = y.check = 1, y.mode = 512 & X ? 10 : 12, q = X = 0; break; case 2: for (; q < 16; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if (y.flags = X, (255 & y.flags) != 8) { P.msg = "unknown compression method", y.mode = 30; break; } if (57344 & y.flags) { P.msg = "unknown header flags set", y.mode = 30; break; } y.head && (y.head.text = X >> 8 & 1), 512 & y.flags && (F[0] = 255 & X, F[1] = X >>> 8 & 255, y.check = o(y.check, F, 2, 0)), q = X = 0, y.mode = 3; case 3: for (; q < 32; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } y.head && (y.head.time = X), 512 & y.flags && (F[0] = 255 & X, F[1] = X >>> 8 & 255, F[2] = X >>> 16 & 255, F[3] = X >>> 24 & 255, y.check = o(y.check, F, 4, 0)), q = X = 0, y.mode = 4; case 4: for (; q < 16; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } y.head && (y.head.xflags = 255 & X, y.head.os = X >> 8), 512 & y.flags && (F[0] = 255 & X, F[1] = X >>> 8 & 255, y.check = o(y.check, F, 2, 0)), q = X = 0, y.mode = 5; case 5: if (1024 & y.flags) { for (; q < 16; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } y.length = X, y.head && (y.head.extra_len = X), 512 & y.flags && (F[0] = 255 & X, F[1] = X >>> 8 & 255, y.check = o(y.check, F, 2, 0)), q = X = 0; } else y.head && (y.head.extra = null); y.mode = 6; case 6: if (1024 & y.flags && (Z < (de = y.length) && (de = Z), de && (y.head && (_ = y.head.extra_len - y.length, y.head.extra || (y.head.extra = new Array(y.head.extra_len)), r.arraySet(y.head.extra, H, j, de, _)), 512 & y.flags && (y.check = o(y.check, H, de, j)), Z -= de, j += de, y.length -= de), y.length)) break e; y.length = 0, y.mode = 7; case 7: if (2048 & y.flags) { if (Z === 0) break e; for (de = 0; _ = H[j + de++], y.head && _ && y.length < 65536 && (y.head.name += String.fromCharCode(_)), _ && de < Z; ) ; if (512 & y.flags && (y.check = o(y.check, H, de, j)), Z -= de, j += de, _) break e; } else y.head && (y.head.name = null); y.length = 0, y.mode = 8; case 8: if (4096 & y.flags) { if (Z === 0) break e; for (de = 0; _ = H[j + de++], y.head && _ && y.length < 65536 && (y.head.comment += String.fromCharCode(_)), _ && de < Z; ) ; if (512 & y.flags && (y.check = o(y.check, H, de, j)), Z -= de, j += de, _) break e; } else y.head && (y.head.comment = null); y.mode = 9; case 9: if (512 & y.flags) { for (; q < 16; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if (X !== (65535 & y.check)) { P.msg = "header crc mismatch", y.mode = 30; break; } q = X = 0; } y.head && (y.head.hcrc = y.flags >> 9 & 1, y.head.done = !0), P.adler = y.check = 0, y.mode = 12; break; case 10: for (; q < 32; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } P.adler = y.check = m(X), q = X = 0, y.mode = 11; case 11: if (y.havedict === 0) return P.next_out = J, P.avail_out = ae, P.next_in = j, P.avail_in = Z, y.hold = X, y.bits = q, 2; P.adler = y.check = 1, y.mode = 12; case 12: if (O === 5 || O === 6) break e; case 13: if (y.last) { X >>>= 7 & q, q -= 7 & q, y.mode = 27; break; } for (; q < 3; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } switch (y.last = 1 & X, q -= 1, 3 & (X >>>= 1)) { case 0: y.mode = 14; break; case 1: if (w(y), y.mode = 20, O !== 6) break; X >>>= 2, q -= 2; break e; case 2: y.mode = 17; break; case 3: P.msg = "invalid block type", y.mode = 30; } X >>>= 2, q -= 2; break; case 14: for (X >>>= 7 & q, q -= 7 & q; q < 32; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if ((65535 & X) != (X >>> 16 ^ 65535)) { P.msg = "invalid stored block lengths", y.mode = 30; break; } if (y.length = 65535 & X, q = X = 0, y.mode = 15, O === 6) break e; case 15: y.mode = 16; case 16: if (de = y.length) { if (Z < de && (de = Z), ae < de && (de = ae), de === 0) break e; r.arraySet(Y, H, j, de, J), Z -= de, j += de, ae -= de, J += de, y.length -= de; break; } y.mode = 12; break; case 17: for (; q < 14; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if (y.nlen = 257 + (31 & X), X >>>= 5, q -= 5, y.ndist = 1 + (31 & X), X >>>= 5, q -= 5, y.ncode = 4 + (15 & X), X >>>= 4, q -= 4, 286 < y.nlen || 30 < y.ndist) { P.msg = "too many length or distance symbols", y.mode = 30; break; } y.have = 0, y.mode = 18; case 18: for (; y.have < y.ncode; ) { for (; q < 3; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } y.lens[ee[y.have++]] = 7 & X, X >>>= 3, q -= 3; } for (; y.have < 19; ) y.lens[ee[y.have++]] = 0; if (y.lencode = y.lendyn, y.lenbits = 7, V = { bits: y.lenbits }, A = c(0, y.lens, 0, 19, y.lencode, 0, y.work, V), y.lenbits = V.bits, A) { P.msg = "invalid code lengths set", y.mode = 30; break; } y.have = 0, y.mode = 19; case 19: for (; y.have < y.nlen + y.ndist; ) { for (; ve = (I = y.lencode[X & (1 << y.lenbits) - 1]) >>> 16 & 255, Ee = 65535 & I, !((fe = I >>> 24) <= q); ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if (Ee < 16) X >>>= fe, q -= fe, y.lens[y.have++] = Ee; else { if (Ee === 16) { for (N = fe + 2; q < N; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if (X >>>= fe, q -= fe, y.have === 0) { P.msg = "invalid bit length repeat", y.mode = 30; break; } _ = y.lens[y.have - 1], de = 3 + (3 & X), X >>>= 2, q -= 2; } else if (Ee === 17) { for (N = fe + 3; q < N; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } q -= fe, _ = 0, de = 3 + (7 & (X >>>= fe)), X >>>= 3, q -= 3; } else { for (N = fe + 7; q < N; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } q -= fe, _ = 0, de = 11 + (127 & (X >>>= fe)), X >>>= 7, q -= 7; } if (y.have + de > y.nlen + y.ndist) { P.msg = "invalid bit length repeat", y.mode = 30; break; } for (; de--; ) y.lens[y.have++] = _; } } if (y.mode === 30) break; if (y.lens[256] === 0) { P.msg = "invalid code -- missing end-of-block", y.mode = 30; break; } if (y.lenbits = 9, V = { bits: y.lenbits }, A = c(h, y.lens, 0, y.nlen, y.lencode, 0, y.work, V), y.lenbits = V.bits, A) { P.msg = "invalid literal/lengths set", y.mode = 30; break; } if (y.distbits = 6, y.distcode = y.distdyn, V = { bits: y.distbits }, A = c(u, y.lens, y.nlen, y.ndist, y.distcode, 0, y.work, V), y.distbits = V.bits, A) { P.msg = "invalid distances set", y.mode = 30; break; } if (y.mode = 20, O === 6) break e; case 20: y.mode = 21; case 21: if (6 <= Z && 258 <= ae) { P.next_out = J, P.avail_out = ae, P.next_in = j, P.avail_in = Z, y.hold = X, y.bits = q, l(P, pe), J = P.next_out, Y = P.output, ae = P.avail_out, j = P.next_in, H = P.input, Z = P.avail_in, X = y.hold, q = y.bits, y.mode === 12 && (y.back = -1); break; } for (y.back = 0; ve = (I = y.lencode[X & (1 << y.lenbits) - 1]) >>> 16 & 255, Ee = 65535 & I, !((fe = I >>> 24) <= q); ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if (ve && (240 & ve) == 0) { for (Ne = fe, Ye = ve, ke = Ee; ve = (I = y.lencode[ke + ((X & (1 << Ne + Ye) - 1) >> Ne)]) >>> 16 & 255, Ee = 65535 & I, !(Ne + (fe = I >>> 24) <= q); ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } X >>>= Ne, q -= Ne, y.back += Ne; } if (X >>>= fe, q -= fe, y.back += fe, y.length = Ee, ve === 0) { y.mode = 26; break; } if (32 & ve) { y.back = -1, y.mode = 12; break; } if (64 & ve) { P.msg = "invalid literal/length code", y.mode = 30; break; } y.extra = 15 & ve, y.mode = 22; case 22: if (y.extra) { for (N = y.extra; q < N; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } y.length += X & (1 << y.extra) - 1, X >>>= y.extra, q -= y.extra, y.back += y.extra; } y.was = y.length, y.mode = 23; case 23: for (; ve = (I = y.distcode[X & (1 << y.distbits) - 1]) >>> 16 & 255, Ee = 65535 & I, !((fe = I >>> 24) <= q); ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if ((240 & ve) == 0) { for (Ne = fe, Ye = ve, ke = Ee; ve = (I = y.distcode[ke + ((X & (1 << Ne + Ye) - 1) >> Ne)]) >>> 16 & 255, Ee = 65535 & I, !(Ne + (fe = I >>> 24) <= q); ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } X >>>= Ne, q -= Ne, y.back += Ne; } if (X >>>= fe, q -= fe, y.back += fe, 64 & ve) { P.msg = "invalid distance code", y.mode = 30; break; } y.offset = Ee, y.extra = 15 & ve, y.mode = 24; case 24: if (y.extra) { for (N = y.extra; q < N; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } y.offset += X & (1 << y.extra) - 1, X >>>= y.extra, q -= y.extra, y.back += y.extra; } if (y.offset > y.dmax) { P.msg = "invalid distance too far back", y.mode = 30; break; } y.mode = 25; case 25: if (ae === 0) break e; if (de = pe - ae, y.offset > de) { if ((de = y.offset - de) > y.whave && y.sane) { P.msg = "invalid distance too far back", y.mode = 30; break; } ie = de > y.wnext ? (de -= y.wnext, y.wsize - de) : y.wnext - de, de > y.length && (de = y.length), ce = y.window; } else ce = Y, ie = J - y.offset, de = y.length; for (ae < de && (de = ae), ae -= de, y.length -= de; Y[J++] = ce[ie++], --de; ) ; y.length === 0 && (y.mode = 21); break; case 26: if (ae === 0) break e; Y[J++] = y.length, ae--, y.mode = 21; break; case 27: if (y.wrap) { for (; q < 32; ) { if (Z === 0) break e; Z--, X |= H[j++] << q, q += 8; } if (pe -= ae, P.total_out += pe, y.total += pe, pe && (P.adler = y.check = y.flags ? o(y.check, Y, pe, J - pe) : a(y.check, Y, pe, J - pe)), pe = ae, (y.flags ? X : m(X)) !== y.check) { P.msg = "incorrect data check", y.mode = 30; break; } q = X = 0; } y.mode = 28; case 28: if (y.wrap && y.flags) { for (; q < 32; ) { if (Z === 0) break e; Z--, X += H[j++] << q, q += 8; } if (X !== (4294967295 & y.total)) { P.msg = "incorrect length check", y.mode = 30; break; } q = X = 0; } y.mode = 29; case 29: A = 1; break e; case 30: A = -3; break e; case 31: return -4; case 32: default: return d; } return P.next_out = J, P.avail_out = ae, P.next_in = j, P.avail_in = Z, y.hold = X, y.bits = q, (y.wsize || pe !== P.avail_out && y.mode < 30 && (y.mode < 27 || O !== 4)) && B(P, P.output, P.next_out, pe - P.avail_out) ? (y.mode = 31, -4) : (ge -= P.avail_in, pe -= P.avail_out, P.total_in += ge, P.total_out += pe, y.total += pe, y.wrap && pe && (P.adler = y.check = y.flags ? o(y.check, Y, pe, P.next_out - pe) : a(y.check, Y, pe, P.next_out - pe)), P.data_type = y.bits + (y.last ? 64 : 0) + (y.mode === 12 ? 128 : 0) + (y.mode === 20 || y.mode === 15 ? 256 : 0), (ge == 0 && pe === 0 || O === 4) && A === f && (A = -5), A); }, i.inflateEnd = function(P) { if (!P || !P.state) return d; var O = P.state; return O.window && (O.window = null), P.state = null, f; }, i.inflateGetHeader = function(P, O) { var y; return P && P.state ? (2 & (y = P.state).wrap) == 0 ? d : ((y.head = O).done = !1, f) : d; }, i.inflateSetDictionary = function(P, O) { var y, H = O.length; return P && P.state ? (y = P.state).wrap !== 0 && y.mode !== 11 ? d : y.mode === 11 && a(1, O, H, 0) !== y.check ? -3 : B(P, O, H, H) ? (y.mode = 31, -4) : (y.havedict = 1, f) : d; }, i.inflateInfo = "pako inflate (from Nodeca project)"; }, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./inffast": 48, "./inftrees": 50 }], 50: [function(t, n, i) { var r = t("../utils/common"), a = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0], o = [16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78], l = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0], c = [16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]; n.exports = function(h, u, f, d, p, g, x, m) { var v, b, M, C, T, D, U, S, w, B = m.bits, P = 0, O = 0, y = 0, H = 0, Y = 0, j = 0, J = 0, Z = 0, ae = 0, X = 0, q = null, ge = 0, pe = new r.Buf16(16), de = new r.Buf16(16), ie = null, ce = 0; for (P = 0; P <= 15; P++) pe[P] = 0; for (O = 0; O < d; O++) pe[u[f + O]]++; for (Y = B, H = 15; 1 <= H && pe[H] === 0; H--) ; if (H < Y && (Y = H), H === 0) return p[g++] = 20971520, p[g++] = 20971520, m.bits = 1, 0; for (y = 1; y < H && pe[y] === 0; y++) ; for (Y < y && (Y = y), P = Z = 1; P <= 15; P++) if (Z <<= 1, (Z -= pe[P]) < 0) return -1; if (0 < Z && (h === 0 || H !== 1)) return -1; for (de[1] = 0, P = 1; P < 15; P++) de[P + 1] = de[P] + pe[P]; for (O = 0; O < d; O++) u[f + O] !== 0 && (x[de[u[f + O]]++] = O); if (D = h === 0 ? (q = ie = x, 19) : h === 1 ? (q = a, ge -= 257, ie = o, ce -= 257, 256) : (q = l, ie = c, -1), P = y, T = g, J = O = X = 0, M = -1, C = (ae = 1 << (j = Y)) - 1, h === 1 && 852 < ae || h === 2 && 592 < ae) return 1; for (; ; ) { for (U = P - J, w = x[O] < D ? (S = 0, x[O]) : x[O] > D ? (S = ie[ce + x[O]], q[ge + x[O]]) : (S = 96, 0), v = 1 << P - J, y = b = 1 << j; p[T + (X >> J) + (b -= v)] = U << 24 | S << 16 | w | 0, b !== 0; ) ; for (v = 1 << P - 1; X & v; ) v >>= 1; if (v !== 0 ? (X &= v - 1, X += v) : X = 0, O++, --pe[P] == 0) { if (P === H) break; P = u[f + x[O]]; } if (Y < P && (X & C) !== M) { for (J === 0 && (J = Y), T += y, Z = 1 << (j = P - J); j + J < H && !((Z -= pe[j + J]) <= 0); ) j++, Z <<= 1; if (ae += 1 << j, h === 1 && 852 < ae || h === 2 && 592 < ae) return 1; p[M = X & C] = Y << 24 | j << 16 | T - g | 0; } } return X !== 0 && (p[T + X] = P - J << 24 | 64 << 16 | 0), m.bits = Y, 0; }; }, { "../utils/common": 41 }], 51: [function(t, n, i) { n.exports = { 2: "need dictionary", 1: "stream end", 0: "", "-1": "file error", "-2": "stream error", "-3": "data error", "-4": "insufficient memory", "-5": "buffer error", "-6": "incompatible version" }; }, {}], 52: [function(t, n, i) { var r = t("../utils/common"), a = 0, o = 1; function l(I) { for (var F = I.length; 0 <= --F; ) I[F] = 0; } var c = 0, h = 29, u = 256, f = u + 1 + h, d = 30, p = 19, g = 2 * f + 1, x = 15, m = 16, v = 7, b = 256, M = 16, C = 17, T = 18, D = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], U = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13], S = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], w = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], B = new Array(2 * (f + 2)); l(B); var P = new Array(2 * d); l(P); var O = new Array(512); l(O); var y = new Array(256); l(y); var H = new Array(h); l(H); var Y, j, J, Z = new Array(d); function ae(I, F, ee, $, G) { this.static_tree = I, this.extra_bits = F, this.extra_base = ee, this.elems = $, this.max_length = G, this.has_stree = I && I.length; } function X(I, F) { this.dyn_tree = I, this.max_code = 0, this.stat_desc = F; } function q(I) { return I < 256 ? O[I] : O[256 + (I >>> 7)]; } function ge(I, F) { I.pending_buf[I.pending++] = 255 & F, I.pending_buf[I.pending++] = F >>> 8 & 255; } function pe(I, F, ee) { I.bi_valid > m - ee ? (I.bi_buf |= F << I.bi_valid & 65535, ge(I, I.bi_buf), I.bi_buf = F >> m - I.bi_valid, I.bi_valid += ee - m) : (I.bi_buf |= F << I.bi_valid & 65535, I.bi_valid += ee); } function de(I, F, ee) { pe(I, ee[2 * F], ee[2 * F + 1]); } function ie(I, F) { for (var ee = 0; ee |= 1 & I, I >>>= 1, ee <<= 1, 0 < --F; ) ; return ee >>> 1; } function ce(I, F, ee) { var $, G, L = new Array(x + 1), E = 0; for ($ = 1; $ <= x; $++) L[$] = E = E + ee[$ - 1] << 1; for (G = 0; G <= F; G++) { var z = I[2 * G + 1]; z !== 0 && (I[2 * G] = ie(L[z]++, z)); } } function fe(I) { var F; for (F = 0; F < f; F++) I.dyn_ltree[2 * F] = 0; for (F = 0; F < d; F++) I.dyn_dtree[2 * F] = 0; for (F = 0; F < p; F++) I.bl_tree[2 * F] = 0; I.dyn_ltree[2 * b] = 1, I.opt_len = I.static_len = 0, I.last_lit = I.matches = 0; } function ve(I) { 8 < I.bi_valid ? ge(I, I.bi_buf) : 0 < I.bi_valid && (I.pending_buf[I.pending++] = I.bi_buf), I.bi_buf = 0, I.bi_valid = 0; } function Ee(I, F, ee, $) { var G = 2 * F, L = 2 * ee; return I[G] < I[L] || I[G] === I[L] && $[F] <= $[ee]; } function Ne(I, F, ee) { for (var $ = I.heap[ee], G = ee << 1; G <= I.heap_len && (G < I.heap_len && Ee(F, I.heap[G + 1], I.heap[G], I.depth) && G++, !Ee(F, $, I.heap[G], I.depth)); ) I.heap[ee] = I.heap[G], ee = G, G <<= 1; I.heap[ee] = $; } function Ye(I, F, ee) { var $, G, L, E, z = 0; if (I.last_lit !== 0) for (; $ = I.pending_buf[I.d_buf + 2 * z] << 8 | I.pending_buf[I.d_buf + 2 * z + 1], G = I.pending_buf[I.l_buf + z], z++, $ === 0 ? de(I, G, F) : (de(I, (L = y[G]) + u + 1, F), (E = D[L]) !== 0 && pe(I, G -= H[L], E), de(I, L = q(--$), ee), (E = U[L]) !== 0 && pe(I, $ -= Z[L], E)), z < I.last_lit; ) ; de(I, b, F); } function ke(I, F) { var ee, $, G, L = F.dyn_tree, E = F.stat_desc.static_tree, z = F.stat_desc.has_stree, K = F.stat_desc.elems, le = -1; for (I.heap_len = 0, I.heap_max = g, ee = 0; ee < K; ee++) L[2 * ee] !== 0 ? (I.heap[++I.heap_len] = le = ee, I.depth[ee] = 0) : L[2 * ee + 1] = 0; for (; I.heap_len < 2; ) L[2 * (G = I.heap[++I.heap_len] = le < 2 ? ++le : 0)] = 1, I.depth[G] = 0, I.opt_len--, z && (I.static_len -= E[2 * G + 1]); for (F.max_code = le, ee = I.heap_len >> 1; 1 <= ee; ee--) Ne(I, L, ee); for (G = K; ee = I.heap[1], I.heap[1] = I.heap[I.heap_len--], Ne(I, L, 1), $ = I.heap[1], I.heap[--I.heap_max] = ee, I.heap[--I.heap_max] = $, L[2 * G] = L[2 * ee] + L[2 * $], I.depth[G] = (I.depth[ee] >= I.depth[$] ? I.depth[ee] : I.depth[$]) + 1, L[2 * ee + 1] = L[2 * $ + 1] = G, I.heap[1] = G++, Ne(I, L, 1), 2 <= I.heap_len; ) ; I.heap[--I.heap_max] = I.heap[1], (function(te, Te) { var be, Re, De, he, _e, He, Ue = Te.dyn_tree, Ce = Te.max_code, Ve = Te.stat_desc.static_tree, W = Te.stat_desc.has_stree, we = Te.stat_desc.extra_bits, ye = Te.stat_desc.extra_base, Me = Te.stat_desc.max_length, xe = 0; for (he = 0; he <= x; he++) te.bl_count[he] = 0; for (Ue[2 * te.heap[te.heap_max] + 1] = 0, be = te.heap_max + 1; be < g; be++) Me < (he = Ue[2 * Ue[2 * (Re = te.heap[be]) + 1] + 1] + 1) && (he = Me, xe++), Ue[2 * Re + 1] = he, Ce < Re || (te.bl_count[he]++, _e = 0, ye <= Re && (_e = we[Re - ye]), He = Ue[2 * Re], te.opt_len += He * (he + _e), W && (te.static_len += He * (Ve[2 * Re + 1] + _e))); if (xe !== 0) { do { for (he = Me - 1; te.bl_count[he] === 0; ) he--; te.bl_count[he]--, te.bl_count[he + 1] += 2, te.bl_count[Me]--, xe -= 2; } while (0 < xe); for (he = Me; he !== 0; he--) for (Re = te.bl_count[he]; Re !== 0; ) Ce < (De = te.heap[--be]) || (Ue[2 * De + 1] !== he && (te.opt_len += (he - Ue[2 * De + 1]) * Ue[2 * De], Ue[2 * De + 1] = he), Re--); } })(I, F), ce(L, le, I.bl_count); } function _(I, F, ee) { var $, G, L = -1, E = F[1], z = 0, K = 7, le = 4; for (E === 0 && (K = 138, le = 3), F[2 * (ee + 1) + 1] = 65535, $ = 0; $ <= ee; $++) G = E, E = F[2 * ($ + 1) + 1], ++z < K && G === E || (z < le ? I.bl_tree[2 * G] += z : G !== 0 ? (G !== L && I.bl_tree[2 * G]++, I.bl_tree[2 * M]++) : z <= 10 ? I.bl_tree[2 * C]++ : I.bl_tree[2 * T]++, L = G, le = (z = 0) === E ? (K = 138, 3) : G === E ? (K = 6, 3) : (K = 7, 4)); } function A(I, F, ee) { var $, G, L = -1, E = F[1], z = 0, K = 7, le = 4; for (E === 0 && (K = 138, le = 3), $ = 0; $ <= ee; $++) if (G = E, E = F[2 * ($ + 1) + 1], !(++z < K && G === E)) { if (z < le) for (; de(I, G, I.bl_tree), --z != 0; ) ; else G !== 0 ? (G !== L && (de(I, G, I.bl_tree), z--), de(I, M, I.bl_tree), pe(I, z - 3, 2)) : z <= 10 ? (de(I, C, I.bl_tree), pe(I, z - 3, 3)) : (de(I, T, I.bl_tree), pe(I, z - 11, 7)); L = G, le = (z = 0) === E ? (K = 138, 3) : G === E ? (K = 6, 3) : (K = 7, 4); } } l(Z); var V = !1; function N(I, F, ee, $) { pe(I, (c << 1) + ($ ? 1 : 0), 3), (function(G, L, E, z) { ve(G), ge(G, E), ge(G, ~E), r.arraySet(G.pending_buf, G.window, L, E, G.pending), G.pending += E; })(I, F, ee); } i._tr_init = function(I) { V || ((function() { var F, ee, $, G, L, E = new Array(x + 1); for (G = $ = 0; G < h - 1; G++) for (H[G] = $, F = 0; F < 1 << D[G]; F++) y[$++] = G; for (y[$ - 1] = G, G = L = 0; G < 16; G++) for (Z[G] = L, F = 0; F < 1 << U[G]; F++) O[L++] = G; for (L >>= 7; G < d; G++) for (Z[G] = L << 7, F = 0; F < 1 << U[G] - 7; F++) O[256 + L++] = G; for (ee = 0; ee <= x; ee++) E[ee] = 0; for (F = 0; F <= 143; ) B[2 * F + 1] = 8, F++, E[8]++; for (; F <= 255; ) B[2 * F + 1] = 9, F++, E[9]++; for (; F <= 279; ) B[2 * F + 1] = 7, F++, E[7]++; for (; F <= 287; ) B[2 * F + 1] = 8, F++, E[8]++; for (ce(B, f + 1, E), F = 0; F < d; F++) P[2 * F + 1] = 5, P[2 * F] = ie(F, 5); Y = new ae(B, D, u + 1, f, x), j = new ae(P, U, 0, d, x), J = new ae(new Array(0), S, 0, p, v); })(), V = !0), I.l_desc = new X(I.dyn_ltree, Y), I.d_desc = new X(I.dyn_dtree, j), I.bl_desc = new X(I.bl_tree, J), I.bi_buf = 0, I.bi_valid = 0, fe(I); }, i._tr_stored_block = N, i._tr_flush_block = function(I, F, ee, $) { var G, L, E = 0; 0 < I.level ? (I.strm.data_type === 2 && (I.strm.data_type = (function(z) { var K, le = 4093624447; for (K = 0; K <= 31; K++, le >>>= 1) if (1 & le && z.dyn_ltree[2 * K] !== 0) return a; if (z.dyn_ltree[18] !== 0 || z.dyn_ltree[20] !== 0 || z.dyn_ltree[26] !== 0) return o; for (K = 32; K < u; K++) if (z.dyn_ltree[2 * K] !== 0) return o; return a; })(I)), ke(I, I.l_desc), ke(I, I.d_desc), E = (function(z) { var K; for (_(z, z.dyn_ltree, z.l_desc.max_code), _(z, z.dyn_dtree, z.d_desc.max_code), ke(z, z.bl_desc), K = p - 1; 3 <= K && z.bl_tree[2 * w[K] + 1] === 0; K--) ; return z.opt_len += 3 * (K + 1) + 5 + 5 + 4, K; })(I), G = I.opt_len + 3 + 7 >>> 3, (L = I.static_len + 3 + 7 >>> 3) <= G && (G = L)) : G = L = ee + 5, ee + 4 <= G && F !== -1 ? N(I, F, ee, $) : I.strategy === 4 || L === G ? (pe(I, 2 + ($ ? 1 : 0), 3), Ye(I, B, P)) : (pe(I, 4 + ($ ? 1 : 0), 3), (function(z, K, le, te) { var Te; for (pe(z, K - 257, 5), pe(z, le - 1, 5), pe(z, te - 4, 4), Te = 0; Te < te; Te++) pe(z, z.bl_tree[2 * w[Te] + 1], 3); A(z, z.dyn_ltree, K - 1), A(z, z.dyn_dtree, le - 1); })(I, I.l_desc.max_code + 1, I.d_desc.max_code + 1, E + 1), Ye(I, I.dyn_ltree, I.dyn_dtree)), fe(I), $ && ve(I); }, i._tr_tally = function(I, F, ee) { return I.pending_buf[I.d_buf + 2 * I.last_lit] = F >>> 8 & 255, I.pending_buf[I.d_buf + 2 * I.last_lit + 1] = 255 & F, I.pending_buf[I.l_buf + I.last_lit] = 255 & ee, I.last_lit++, F === 0 ? I.dyn_ltree[2 * ee]++ : (I.matches++, F--, I.dyn_ltree[2 * (y[ee] + u + 1)]++, I.dyn_dtree[2 * q(F)]++), I.last_lit === I.lit_bufsize - 1; }, i._tr_align = function(I) { pe(I, 2, 3), de(I, b, B), (function(F) { F.bi_valid === 16 ? (ge(F, F.bi_buf), F.bi_buf = 0, F.bi_valid = 0) : 8 <= F.bi_valid && (F.pending_buf[F.pending++] = 255 & F.bi_buf, F.bi_buf >>= 8, F.bi_valid -= 8); })(I); }; }, { "../utils/common": 41 }], 53: [function(t, n, i) { n.exports = function() { this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; }; }, {}], 54: [function(t, n, i) { (function(r) { (function(a, o) { if (!a.setImmediate) { var l, c, h, u, f = 1, d = {}, p = !1, g = a.document, x = Object.getPrototypeOf && Object.getPrototypeOf(a); x = x && x.setTimeout ? x : a, l = {}.toString.call(a.process) === "[object process]" ? function(M) { process.nextTick(function() { v(M); }); } : (function() { if (a.postMessage && !a.importScripts) { var M = !0, C = a.onmessage; return a.onmessage = function() { M = !1; }, a.postMessage("", "*"), a.onmessage = C, M; } })() ? (u = "setImmediate$" + Math.random() + "$", a.addEventListener ? a.addEventListener("message", b, !1) : a.attachEvent("onmessage", b), function(M) { a.postMessage(u + M, "*"); }) : a.MessageChannel ? ((h = new MessageChannel()).port1.onmessage = function(M) { v(M.data); }, function(M) { h.port2.postMessage(M); }) : g && "onreadystatechange" in g.createElement("script") ? (c = g.documentElement, function(M) { var C = g.createElement("script"); C.onreadystatechange = function() { v(M), C.onreadystatechange = null, c.removeChild(C), C = null; }, c.appendChild(C); }) : function(M) { setTimeout(v, 0, M); }, x.setImmediate = function(M) { typeof M != "function" && (M = new Function("" + M)); for (var C = new Array(arguments.length - 1), T = 0; T < C.length; T++) C[T] = arguments[T + 1]; var D = { callback: M, args: C }; return d[f] = D, l(f), f++; }, x.clearImmediate = m; } function m(M) { delete d[M]; } function v(M) { if (p) setTimeout(v, 0, M); else { var C = d[M]; if (C) { p = !0; try { (function(T) { var D = T.callback, U = T.args; switch (U.length) { case 0: D(); break; case 1: D(U[0]); break; case 2: D(U[0], U[1]); break; case 3: D(U[0], U[1], U[2]); break; default: D.apply(o, U); } })(C); } finally { m(M), p = !1; } } } } function b(M) { M.source === a && typeof M.data == "string" && M.data.indexOf(u) === 0 && v(+M.data.slice(u.length)); } })(typeof self > "u" ? r === void 0 ? this : r : self); }).call(this, typeof na < "u" ? na : typeof self < "u" ? self : typeof window < "u" ? window : {}); }, {}] }, {}, [10])(10); }); })(nu)), nu.exports; } var Fb = Ob(); const zb = /* @__PURE__ */ Id(Fb); function Nd(s, e) { return function() { return s.apply(e, arguments); }; } const { toString: Hb } = Object.prototype, { getPrototypeOf: xc } = Object, { iterator: Na, toStringTag: kd } = Symbol, ka = /* @__PURE__ */ ((s) => (e) => { const t = Hb.call(e); return s[t] || (s[t] = t.slice(8, -1).toLowerCase()); })(/* @__PURE__ */ Object.create(null)), kn = (s) => (s = s.toLowerCase(), (e) => ka(e) === s), Ua = (s) => (e) => typeof e === s, { isArray: Ls } = Array, Es = Ua("undefined"); function gr(s) { return s !== null && !Es(s) && s.constructor !== null && !Es(s.constructor) && on(s.constructor.isBuffer) && s.constructor.isBuffer(s); } const Ud = kn("ArrayBuffer"); function Vb(s) { let e; return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(s) : e = s && s.buffer && Ud(s.buffer), e; } const Gb = Ua("string"), on = Ua("function"), Bd = Ua("number"), xr = (s) => s !== null && typeof s == "object", Wb = (s) => s === !0 || s === !1, ma = (s) => { if (ka(s) !== "object") return !1; const e = xc(s); return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(kd in s) && !(Na in s); }, Xb = (s) => { if (!xr(s) || gr(s)) return !1; try { return Object.keys(s).length === 0 && Object.getPrototypeOf(s) === Object.prototype; } catch { return !1; } }, jb = kn("Date"), Zb = kn("File"), qb = kn("Blob"), Yb = kn("FileList"), Kb = (s) => xr(s) && on(s.pipe), $b = (s) => { let e; return s && (typeof FormData == "function" && s instanceof FormData || on(s.append) && ((e = ka(s)) === "formdata" || // detect form-data instance e === "object" && on(s.toString) && s.toString() === "[object FormData]")); }, Jb = kn("URLSearchParams"), [Qb, e_, t_, n_] = ["ReadableStream", "Request", "Response", "Headers"].map(kn), i_ = (s) => s.trim ? s.trim() : s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); function vr(s, e, { allOwnKeys: t = !1 } = {}) { if (s === null || typeof s > "u") return; let n, i; if (typeof s != "object" && (s = [s]), Ls(s)) for (n = 0, i = s.length; n < i; n++) e.call(null, s[n], n, s); else { if (gr(s)) return; const r = t ? Object.getOwnPropertyNames(s) : Object.keys(s), a = r.length; let o; for (n = 0; n < a; n++) o = r[n], e.call(null, s[o], o, s); } } function Od(s, e) { if (gr(s)) return null; e = e.toLowerCase(); const t = Object.keys(s); let n = t.length, i; for (; n-- > 0; ) if (i = t[n], e === i.toLowerCase()) return i; return null; } const Ci = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, Fd = (s) => !Es(s) && s !== Ci; function Bl() { const { caseless: s, skipUndefined: e } = Fd(this) && this || {}, t = {}, n = (i, r) => { const a = s && Od(t, r) || r; ma(t[a]) && ma(i) ? t[a] = Bl(t[a], i) : ma(i) ? t[a] = Bl({}, i) : Ls(i) ? t[a] = i.slice() : (!e || !Es(i)) && (t[a] = i); }; for (let i = 0, r = arguments.length; i < r; i++) arguments[i] && vr(arguments[i], n); return t; } const s_ = (s, e, t, { allOwnKeys: n } = {}) => (vr(e, (i, r) => { t && on(i) ? s[r] = Nd(i, t) : s[r] = i; }, { allOwnKeys: n }), s), r_ = (s) => (s.charCodeAt(0) === 65279 && (s = s.slice(1)), s), a_ = (s, e, t, n) => { s.prototype = Object.create(e.prototype, n), s.prototype.constructor = s, Object.defineProperty(s, "super", { value: e.prototype }), t && Object.assign(s.prototype, t); }, o_ = (s, e, t, n) => { let i, r, a; const o = {}; if (e = e || {}, s == null) return e; do { for (i = Object.getOwnPropertyNames(s), r = i.length; r-- > 0; ) a = i[r], (!n || n(a, s, e)) && !o[a] && (e[a] = s[a], o[a] = !0); s = t !== !1 && xc(s); } while (s && (!t || t(s, e)) && s !== Object.prototype); return e; }, l_ = (s, e, t) => { s = String(s), (t === void 0 || t > s.length) && (t = s.length), t -= e.length; const n = s.indexOf(e, t); return n !== -1 && n === t; }, c_ = (s) => { if (!s) return null; if (Ls(s)) return s; let e = s.length; if (!Bd(e)) return null; const t = new Array(e); for (; e-- > 0; ) t[e] = s[e]; return t; }, h_ = /* @__PURE__ */ ((s) => (e) => s && e instanceof s)(typeof Uint8Array < "u" && xc(Uint8Array)), u_ = (s, e) => { const t = (s && s[Na]).call(s); let n; for (; (n = t.next()) && !n.done; ) { const i = n.value; e.call(s, i[0], i[1]); } }, d_ = (s, e) => { let t; const n = []; for (; (t = s.exec(e)) !== null; ) n.push(t); return n; }, f_ = kn("HTMLFormElement"), p_ = (s) => s.toLowerCase().replace( /[-_\s]([a-z\d])(\w*)/g, function(e, t, n) { return t.toUpperCase() + n; } ), su = (({ hasOwnProperty: s }) => (e, t) => s.call(e, t))(Object.prototype), m_ = kn("RegExp"), zd = (s, e) => { const t = Object.getOwnPropertyDescriptors(s), n = {}; vr(t, (i, r) => { let a; (a = e(i, r, s)) !== !1 && (n[r] = a || i); }), Object.defineProperties(s, n); }, g_ = (s) => { zd(s, (e, t) => { if (on(s) && ["arguments", "caller", "callee"].indexOf(t) !== -1) return !1; const n = s[t]; if (on(n)) { if (e.enumerable = !1, "writable" in e) { e.writable = !1; return; } e.set || (e.set = () => { throw Error("Can not rewrite read-only method '" + t + "'"); }); } }); }, x_ = (s, e) => { const t = {}, n = (i) => { i.forEach((r) => { t[r] = !0; }); }; return Ls(s) ? n(s) : n(String(s).split(e)), t; }, v_ = () => { }, b_ = (s, e) => s != null && Number.isFinite(s = +s) ? s : e; function __(s) { return !!(s && on(s.append) && s[kd] === "FormData" && s[Na]); } const y_ = (s) => { const e = new Array(10), t = (n, i) => { if (xr(n)) { if (e.indexOf(n) >= 0) return; if (gr(n)) return n; if (!("toJSON" in n)) { e[i] = n; const r = Ls(n) ? [] : {}; return vr(n, (a, o) => { const l = t(a, i + 1); !Es(l) && (r[o] = l); }), e[i] = void 0, r; } } return n; }; return t(s, 0); }, M_ = kn("AsyncFunction"), S_ = (s) => s && (xr(s) || on(s)) && on(s.then) && on(s.catch), Hd = ((s, e) => s ? setImmediate : e ? ((t, n) => (Ci.addEventListener("message", ({ source: i, data: r }) => { i === Ci && r === t && n.length && n.shift()(); }, !1), (i) => { n.push(i), Ci.postMessage(t, "*"); }))(`axios@${Math.random()}`, []) : (t) => setTimeout(t))( typeof setImmediate == "function", on(Ci.postMessage) ), w_ = typeof queueMicrotask < "u" ? queueMicrotask.bind(Ci) : typeof process < "u" && process.nextTick || Hd, E_ = (s) => s != null && on(s[Na]), se = { isArray: Ls, isArrayBuffer: Ud, isBuffer: gr, isFormData: $b, isArrayBufferView: Vb, isString: Gb, isNumber: Bd, isBoolean: Wb, isObject: xr, isPlainObject: ma, isEmptyObject: Xb, isReadableStream: Qb, isRequest: e_, isResponse: t_, isHeaders: n_, isUndefined: Es, isDate: jb, isFile: Zb, isBlob: qb, isRegExp: m_, isFunction: on, isStream: Kb, isURLSearchParams: Jb, isTypedArray: h_, isFileList: Yb, forEach: vr, merge: Bl, extend: s_, trim: i_, stripBOM: r_, inherits: a_, toFlatObject: o_, kindOf: ka, kindOfTest: kn, endsWith: l_, toArray: c_, forEachEntry: u_, matchAll: d_, isHTMLForm: f_, hasOwnProperty: su, hasOwnProp: su, // an alias to avoid ESLint no-prototype-builtins detection reduceDescriptors: zd, freezeMethods: g_, toObjectSet: x_, toCamelCase: p_, noop: v_, toFiniteNumber: b_, findKey: Od, global: Ci, isContextDefined: Fd, isSpecCompliantForm: __, toJSONObject: y_, isAsyncFn: M_, isThenable: S_, setImmediate: Hd, asap: w_, isIterable: E_ }; function Ke(s, e, t, n, i) { Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = s, this.name = "AxiosError", e && (this.code = e), t && (this.config = t), n && (this.request = n), i && (this.response = i, this.status = i.status ? i.status : null); } se.inherits(Ke, Error, { toJSON: function() { return { // Standard message: this.message, name: this.name, // Microsoft description: this.description, number: this.number, // Mozilla fileName: this.fileName, lineNumber: this.lineNumber, columnNumber: this.columnNumber, stack: this.stack, // Axios config: se.toJSONObject(this.config), code: this.code, status: this.status }; } }); const Vd = Ke.prototype, Gd = {}; [ "ERR_BAD_OPTION_VALUE", "ERR_BAD_OPTION", "ECONNABORTED", "ETIMEDOUT", "ERR_NETWORK", "ERR_FR_TOO_MANY_REDIRECTS", "ERR_DEPRECATED", "ERR_BAD_RESPONSE", "ERR_BAD_REQUEST", "ERR_CANCELED", "ERR_NOT_SUPPORT", "ERR_INVALID_URL" // eslint-disable-next-line func-names ].forEach((s) => { Gd[s] = { value: s }; }); Object.defineProperties(Ke, Gd); Object.defineProperty(Vd, "isAxiosError", { value: !0 }); Ke.from = (s, e, t, n, i, r) => { const a = Object.create(Vd); se.toFlatObject(s, a, function(c) { return c !== Error.prototype; }, (c) => c !== "isAxiosError"); const o = s && s.message ? s.message : "Error", l = e == null && s ? s.code : e; return Ke.call(a, o, l, t, n, i), s && a.cause == null && Object.defineProperty(a, "cause", { value: s, configurable: !0 }), a.name = s && s.name || "Error", r && Object.assign(a, r), a; }; const T_ = null; function Ol(s) { return se.isPlainObject(s) || se.isArray(s); } function Wd(s) { return se.endsWith(s, "[]") ? s.slice(0, -2) : s; } function ru(s, e, t) { return s ? s.concat(e).map(function(n, i) { return n = Wd(n), !t && i ? "[" + n + "]" : n; }).join(t ? "." : "") : e; } function C_(s) { return se.isArray(s) && !s.some(Ol); } const A_ = se.toFlatObject(se, {}, null, function(s) { return /^is[A-Z]/.test(s); }); function Ba(s, e, t) { if (!se.isObject(s)) throw new TypeError("target must be an object"); e = e || new FormData(), t = se.toFlatObject(t, { metaTokens: !0, dots: !1, indexes: !1 }, !1, function(d, p) { return !se.isUndefined(p[d]); }); const n = t.metaTokens, i = t.visitor || c, r = t.dots, a = t.indexes, o = (t.Blob || typeof Blob < "u" && Blob) && se.isSpecCompliantForm(e); if (!se.isFunction(i)) throw new TypeError("visitor must be a function"); function l(d) { if (d === null) return ""; if (se.isDate(d)) return d.toISOString(); if (se.isBoolean(d)) return d.toString(); if (!o && se.isBlob(d)) throw new Ke("Blob is not supported. Use a Buffer instead."); return se.isArrayBuffer(d) || se.isTypedArray(d) ? o && typeof Blob == "function" ? new Blob([d]) : Buffer.from(d) : d; } function c(d, p, g) { let x = d; if (d && !g && typeof d == "object") { if (se.endsWith(p, "{}")) p = n ? p : p.slice(0, -2), d = JSON.stringify(d); else if (se.isArray(d) && C_(d) || (se.isFileList(d) || se.endsWith(p, "[]")) && (x = se.toArray(d))) return p = Wd(p), x.forEach(function(m, v) { !(se.isUndefined(m) || m === null) && e.append( // eslint-disable-next-line no-nested-ternary a === !0 ? ru([p], v, r) : a === null ? p : p + "[]", l(m) ); }), !1; } return Ol(d) ? !0 : (e.append(ru(g, p, r), l(d)), !1); } const h = [], u = Object.assign(A_, { defaultVisitor: c, convertValue: l, isVisitable: Ol }); function f(d, p) { if (!se.isUndefined(d)) { if (h.indexOf(d) !== -1) throw Error("Circular reference detected in " + p.join(".")); h.push(d), se.forEach(d, function(g, x) { (!(se.isUndefined(g) || g === null) && i.call( e, g, se.isString(x) ? x.trim() : x, p, u )) === !0 && f(g, p ? p.concat(x) : [x]); }), h.pop(); } } if (!se.isObject(s)) throw new TypeError("data must be an object"); return f(s), e; } function au(s) { const e = { "!": "%21", "'": "%27", "(": "%28", ")": "%29", "~": "%7E", "%20": "+", "%00": "\0" }; return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g, function(t) { return e[t]; }); } function vc(s, e) { this._pairs = [], s && Ba(s, this, e); } const Xd = vc.prototype; Xd.append = function(s, e) { this._pairs.push([s, e]); }; Xd.toString = function(s) { const e = s ? function(t) { return s.call(this, t, au); } : au; return this._pairs.map(function(t) { return e(t[0]) + "=" + e(t[1]); }, "").join("&"); }; function P_(s) { return encodeURIComponent(s).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+"); } function jd(s, e, t) { if (!e) return s; const n = t && t.encode || P_; se.isFunction(t) && (t = { serialize: t }); const i = t && t.serialize; let r; if (i ? r = i(e, t) : r = se.isURLSearchParams(e) ? e.toString() : new vc(e, t).toString(n), r) { const a = s.indexOf("#"); a !== -1 && (s = s.slice(0, a)), s += (s.indexOf("?") === -1 ? "?" : "&") + r; } return s; } class ou { constructor() { this.handlers = []; } /** * Add a new interceptor to the stack * * @param {Function} fulfilled The function to handle `then` for a `Promise` * @param {Function} rejected The function to handle `reject` for a `Promise` * * @return {Number} An ID used to remove interceptor later */ use(e, t, n) { return this.handlers.push({ fulfilled: e, rejected: t, synchronous: n ? n.synchronous : !1, runWhen: n ? n.runWhen : null }), this.handlers.length - 1; } /** * Remove an interceptor from the stack * * @param {Number} id The ID that was returned by `use` * * @returns {void} */ eject(e) { this.handlers[e] && (this.handlers[e] = null); } /** * Clear all interceptors from the stack * * @returns {void} */ clear() { this.handlers && (this.handlers = []); } /** * Iterate over all the registered interceptors * * This method is particularly useful for skipping over any * interceptors that may have become `null` calling `eject`. * * @param {Function} fn The function to call for each interceptor * * @returns {void} */ forEach(e) { se.forEach(this.handlers, function(t) { t !== null && e(t); }); } } const Zd = { silentJSONParsing: !0, forcedJSONParsing: !0, clarifyTimeoutError: !1 }, R_ = typeof URLSearchParams < "u" ? URLSearchParams : vc, L_ = typeof FormData < "u" ? FormData : null, D_ = typeof Blob < "u" ? Blob : null, I_ = { isBrowser: !0, classes: { URLSearchParams: R_, FormData: L_, Blob: D_ }, protocols: ["http", "https", "file", "blob", "url", "data"] }, bc = typeof window < "u" && typeof document < "u", Fl = typeof navigator == "object" && navigator || void 0, N_ = bc && (!Fl || ["ReactNative", "NativeScript", "NS"].indexOf(Fl.product) < 0), k_ = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef self instanceof WorkerGlobalScope && typeof self.importScripts == "function", U_ = bc && window.location.href || "http://localhost", B_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, hasBrowserEnv: bc, hasStandardBrowserEnv: N_, hasStandardBrowserWebWorkerEnv: k_, navigator: Fl, origin: U_ }, Symbol.toStringTag, { value: "Module" })), Zt = { ...B_, ...I_ }; function O_(s, e) { return Ba(s, new Zt.classes.URLSearchParams(), { visitor: function(t, n, i, r) { return Zt.isNode && se.isBuffer(t) ? (this.append(n, t.toString("base64")), !1) : r.defaultVisitor.apply(this, arguments); }, ...e }); } function F_(s) { return se.matchAll(/\w+|\[(\w*)]/g, s).map((e) => e[0] === "[]" ? "" : e[1] || e[0]); } function z_(s) { const e = {}, t = Object.keys(s); let n; const i = t.length; let r; for (n = 0; n < i; n++) r = t[n], e[r] = s[r]; return e; } function qd(s) { function e(t, n, i, r) { let a = t[r++]; if (a === "__proto__") return !0; const o = Number.isFinite(+a), l = r >= t.length; return a = !a && se.isArray(i) ? i.length : a, l ? (se.hasOwnProp(i, a) ? i[a] = [i[a], n] : i[a] = n, !o) : ((!i[a] || !se.isObject(i[a])) && (i[a] = []), e(t, n, i[a], r) && se.isArray(i[a]) && (i[a] = z_(i[a])), !o); } if (se.isFormData(s) && se.isFunction(s.entries)) { const t = {}; return se.forEachEntry(s, (n, i) => { e(F_(n), i, t, 0); }), t; } return null; } function H_(s, e, t) { if (se.isString(s)) try { return (e || JSON.parse)(s), se.trim(s); } catch (n) { if (n.name !== "SyntaxError") throw n; } return (t || JSON.stringify)(s); } const br = { transitional: Zd, adapter: ["xhr", "http", "fetch"], transformRequest: [function(s, e) { const t = e.getContentType() || "", n = t.indexOf("application/json") > -1, i = se.isObject(s); if (i && se.isHTMLForm(s) && (s = new FormData(s)), se.isFormData(s)) return n ? JSON.stringify(qd(s)) : s; if (se.isArrayBuffer(s) || se.isBuffer(s) || se.isStream(s) || se.isFile(s) || se.isBlob(s) || se.isReadableStream(s)) return s; if (se.isArrayBufferView(s)) return s.buffer; if (se.isURLSearchParams(s)) return e.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), s.toString(); let r; if (i) { if (t.indexOf("application/x-www-form-urlencoded") > -1) return O_(s, this.formSerializer).toString(); if ((r = se.isFileList(s)) || t.indexOf("multipart/form-data") > -1) { const a = this.env && this.env.FormData; return Ba( r ? { "files[]": s } : s, a && new a(), this.formSerializer ); } } return i || n ? (e.setContentType("application/json", !1), H_(s)) : s; }], transformResponse: [function(s) { const e = this.transitional || br.transitional, t = e && e.forcedJSONParsing, n = this.responseType === "json"; if (se.isResponse(s) || se.isReadableStream(s)) return s; if (s && se.isString(s) && (t && !this.responseType || n)) { const i = !(e && e.silentJSONParsing) && n; try { return JSON.parse(s, this.parseReviver); } catch (r) { if (i) throw r.name === "SyntaxError" ? Ke.from(r, Ke.ERR_BAD_RESPONSE, this, null, this.response) : r; } } return s; }], /** * A timeout in milliseconds to abort a request. If set to 0 (default) a * timeout is not created. */ timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", maxContentLength: -1, maxBodyLength: -1, env: { FormData: Zt.classes.FormData, Blob: Zt.classes.Blob }, validateStatus: function(s) { return s >= 200 && s < 300; }, headers: { common: { Accept: "application/json, text/plain, */*", "Content-Type": void 0 } } }; se.forEach(["delete", "get", "head", "post", "put", "patch"], (s) => { br.headers[s] = {}; }); const V_ = se.toObjectSet([ "age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer", "retry-after", "user-agent" ]), G_ = (s) => { const e = {}; let t, n, i; return s && s.split(` `).forEach(function(r) { i = r.indexOf(":"), t = r.substring(0, i).trim().toLowerCase(), n = r.substring(i + 1).trim(), !(!t || e[t] && V_[t]) && (t === "set-cookie" ? e[t] ? e[t].push(n) : e[t] = [n] : e[t] = e[t] ? e[t] + ", " + n : n); }), e; }, lu = Symbol("internals"); function Gs(s) { return s && String(s).trim().toLowerCase(); } function ga(s) { return s === !1 || s == null ? s : se.isArray(s) ? s.map(ga) : String(s); } function W_(s) { const e = /* @__PURE__ */ Object.create(null), t = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; let n; for (; n = t.exec(s); ) e[n[1]] = n[2]; return e; } const X_ = (s) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim()); function Ro(s, e, t, n, i) { if (se.isFunction(n)) return n.call(this, e, t); if (i && (e = t), !!se.isString(e)) { if (se.isString(n)) return e.indexOf(n) !== -1; if (se.isRegExp(n)) return n.test(e); } } function j_(s) { return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (e, t, n) => t.toUpperCase() + n); } function Z_(s, e) { const t = se.toCamelCase(" " + e); ["get", "set", "has"].forEach((n) => { Object.defineProperty(s, n + t, { value: function(i, r, a) { return this[n].call(this, e, i, r, a); }, configurable: !0 }); }); } let ln = class { constructor(s) { s && this.set(s); } set(s, e, t) { const n = this; function i(a, o, l) { const c = Gs(o); if (!c) throw new Error("header name must be a non-empty string"); const h = se.findKey(n, c); (!h || n[h] === void 0 || l === !0 || l === void 0 && n[h] !== !1) && (n[h || o] = ga(a)); } const r = (a, o) => se.forEach(a, (l, c) => i(l, c, o)); if (se.isPlainObject(s) || s instanceof this.constructor) r(s, e); else if (se.isString(s) && (s = s.trim()) && !X_(s)) r(G_(s), e); else if (se.isObject(s) && se.isIterable(s)) { let a = {}, o, l; for (const c of s) { if (!se.isArray(c)) throw TypeError("Object iterator must return a key-value pair"); a[l = c[0]] = (o = a[l]) ? se.isArray(o) ? [...o, c[1]] : [o, c[1]] : c[1]; } r(a, e); } else s != null && i(e, s, t); return this; } get(s, e) { if (s = Gs(s), s) { const t = se.findKey(this, s); if (t) { const n = this[t]; if (!e) return n; if (e === !0) return W_(n); if (se.isFunction(e)) return e.call(this, n, t); if (se.isRegExp(e)) return e.exec(n); throw new TypeError("parser must be boolean|regexp|function"); } } } has(s, e) { if (s = Gs(s), s) { const t = se.findKey(this, s); return !!(t && this[t] !== void 0 && (!e || Ro(this, this[t], t, e))); } return !1; } delete(s, e) { const t = this; let n = !1; function i(r) { if (r = Gs(r), r) { const a = se.findKey(t, r); a && (!e || Ro(t, t[a], a, e)) && (delete t[a], n = !0); } } return se.isArray(s) ? s.forEach(i) : i(s), n; } clear(s) { const e = Object.keys(this); let t = e.length, n = !1; for (; t--; ) { const i = e[t]; (!s || Ro(this, this[i], i, s, !0)) && (delete this[i], n = !0); } return n; } normalize(s) { const e = this, t = {}; return se.forEach(this, (n, i) => { const r = se.findKey(t, i); if (r) { e[r] = ga(n), delete e[i]; return; } const a = s ? j_(i) : String(i).trim(); a !== i && delete e[i], e[a] = ga(n), t[a] = !0; }), this; } concat(...s) { return this.constructor.concat(this, ...s); } toJSON(s) { const e = /* @__PURE__ */ Object.create(null); return se.forEach(this, (t, n) => { t != null && t !== !1 && (e[n] = s && se.isArray(t) ? t.join(", ") : t); }), e; } [Symbol.iterator]() { return Object.entries(this.toJSON())[Symbol.iterator](); } toString() { return Object.entries(this.toJSON()).map(([s, e]) => s + ": " + e).join(` `); } getSetCookie() { return this.get("set-cookie") || []; } get [Symbol.toStringTag]() { return "AxiosHeaders"; } static from(s) { return s instanceof this ? s : new this(s); } static concat(s, ...e) { const t = new this(s); return e.forEach((n) => t.set(n)), t; } static accessor(s) { const e = (this[lu] = this[lu] = { accessors: {} }).accessors, t = this.prototype; function n(i) { const r = Gs(i); e[r] || (Z_(t, i), e[r] = !0); } return se.isArray(s) ? s.forEach(n) : n(s), this; } }; ln.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]); se.reduceDescriptors(ln.prototype, ({ value: s }, e) => { let t = e[0].toUpperCase() + e.slice(1); return { get: () => s, set(n) { this[t] = n; } }; }); se.freezeMethods(ln); function Lo(s, e) { const t = this || br, n = e || t, i = ln.from(n.headers); let r = n.data; return se.forEach(s, function(a) { r = a.call(t, r, i.normalize(), e ? e.status : void 0); }), i.normalize(), r; } function Yd(s) { return !!(s && s.__CANCEL__); } function Ds(s, e, t) { Ke.call(this, s ?? "canceled", Ke.ERR_CANCELED, e, t), this.name = "CanceledError"; } se.inherits(Ds, Ke, { __CANCEL__: !0 }); function Kd(s, e, t) { const n = t.config.validateStatus; !t.status || !n || n(t.status) ? s(t) : e(new Ke( "Request failed with status code " + t.status, [Ke.ERR_BAD_REQUEST, Ke.ERR_BAD_RESPONSE][Math.floor(t.status / 100) - 4], t.config, t.request, t )); } function q_(s) { const e = /^([-+\w]{1,25})(:?\/\/|:)/.exec(s); return e && e[1] || ""; } function Y_(s, e) { s = s || 10; const t = new Array(s), n = new Array(s); let i = 0, r = 0, a; return e = e !== void 0 ? e : 1e3, function(o) { const l = Date.now(), c = n[r]; a || (a = l), t[i] = o, n[i] = l; let h = r, u = 0; for (; h !== i; ) u += t[h++], h = h % s; if (i = (i + 1) % s, i === r && (r = (r + 1) % s), l - a < e) return; const f = c && l - c; return f ? Math.round(u * 1e3 / f) : void 0; }; } function K_(s, e) { let t = 0, n = 1e3 / e, i, r; const a = (o, l = Date.now()) => { t = l, i = null, r && (clearTimeout(r), r = null), s(...o); }; return [(...o) => { const l = Date.now(), c = l - t; c >= n ? a(o, l) : (i = o, r || (r = setTimeout(() => { r = null, a(i); }, n - c))); }, () => i && a(i)]; } const Ta = (s, e, t = 3) => { let n = 0; const i = Y_(50, 250); return K_((r) => { const a = r.loaded, o = r.lengthComputable ? r.total : void 0, l = a - n, c = i(l), h = a <= o; n = a; const u = { loaded: a, total: o, progress: o ? a / o : void 0, bytes: l, rate: c || void 0, estimated: c && o && h ? (o - a) / c : void 0, event: r, lengthComputable: o != null, [e ? "download" : "upload"]: !0 }; s(u); }, t); }, cu = (s, e) => { const t = s != null; return [(n) => e[0]({ lengthComputable: t, total: s, loaded: n }), e[1]]; }, hu = (s) => (...e) => se.asap(() => s(...e)), $_ = Zt.hasStandardBrowserEnv ? /* @__PURE__ */ ((s, e) => (t) => (t = new URL(t, Zt.origin), s.protocol === t.protocol && s.host === t.host && (e || s.port === t.port)))( new URL(Zt.origin), Zt.navigator && /(msie|trident)/i.test(Zt.navigator.userAgent) ) : () => !0, J_ = Zt.hasStandardBrowserEnv ? ( // Standard browser envs support document.cookie { write(s, e, t, n, i, r, a) { if (typeof document > "u") return; const o = [`${s}=${encodeURIComponent(e)}`]; se.isNumber(t) && o.push(`expires=${new Date(t).toUTCString()}`), se.isString(n) && o.push(`path=${n}`), se.isString(i) && o.push(`domain=${i}`), r === !0 && o.push("secure"), se.isString(a) && o.push(`SameSite=${a}`), document.cookie = o.join("; "); }, read(s) { if (typeof document > "u") return null; const e = document.cookie.match(new RegExp("(?:^|; )" + s + "=([^;]*)")); return e ? decodeURIComponent(e[1]) : null; }, remove(s) { this.write(s, "", Date.now() - 864e5, "/"); } } ) : ( // Non-standard browser env (web workers, react-native) lack needed support. { write() { }, read() { return null; }, remove() { } } ); function Q_(s) { return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(s); } function e2(s, e) { return e ? s.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : s; } function $d(s, e, t) { let n = !Q_(e); return s && (n || t == !1) ? e2(s, e) : e; } const uu = (s) => s instanceof ln ? { ...s } : s; function ki(s, e) { e = e || {}; const t = {}; function n(c, h, u, f) { return se.isPlainObject(c) && se.isPlainObject(h) ? se.merge.call({ caseless: f }, c, h) : se.isPlainObject(h) ? se.merge({}, h) : se.isArray(h) ? h.slice() : h; } function i(c, h, u, f) { if (se.isUndefined(h)) { if (!se.isUndefined(c)) return n(void 0, c, u, f); } else return n(c, h, u, f); } function r(c, h) { if (!se.isUndefined(h)) return n(void 0, h); } function a(c, h) { if (se.isUndefined(h)) { if (!se.isUndefined(c)) return n(void 0, c); } else return n(void 0, h); } function o(c, h, u) { if (u in e) return n(c, h); if (u in s) return n(void 0, c); } const l = { url: r, method: r, data: r, baseURL: a, transformRequest: a, transformResponse: a, paramsSerializer: a, timeout: a, timeoutMessage: a, withCredentials: a, withXSRFToken: a, adapter: a, responseType: a, xsrfCookieName: a, xsrfHeaderName: a, onUploadProgress: a, onDownloadProgress: a, decompress: a, maxContentLength: a, maxBodyLength: a, beforeRedirect: a, transport: a, httpAgent: a, httpsAgent: a, cancelToken: a, socketPath: a, responseEncoding: a, validateStatus: o, headers: (c, h, u) => i(uu(c), uu(h), u, !0) }; return se.forEach(Object.keys({ ...s, ...e }), function(c) { const h = l[c] || i, u = h(s[c], e[c], c); se.isUndefined(u) && h !== o || (t[c] = u); }), t; } const Jd = (s) => { const e = ki({}, s); let { data: t, withXSRFToken: n, xsrfHeaderName: i, xsrfCookieName: r, headers: a, auth: o } = e; if (e.headers = a = ln.from(a), e.url = jd($d(e.baseURL, e.url, e.allowAbsoluteUrls), s.params, s.paramsSerializer), o && a.set( "Authorization", "Basic " + btoa((o.username || "") + ":" + (o.password ? unescape(encodeURIComponent(o.password)) : "")) ), se.isFormData(t)) { if (Zt.hasStandardBrowserEnv || Zt.hasStandardBrowserWebWorkerEnv) a.setContentType(void 0); else if (se.isFunction(t.getHeaders)) { const l = t.getHeaders(), c = ["content-type", "content-length"]; Object.entries(l).forEach(([h, u]) => { c.includes(h.toLowerCase()) && a.set(h, u); }); } } if (Zt.hasStandardBrowserEnv && (n && se.isFunction(n) && (n = n(e)), n || n !== !1 && $_(e.url))) { const l = i && r && J_.read(r); l && a.set(i, l); } return e; }, t2 = typeof XMLHttpRequest < "u", n2 = t2 && function(s) { return new Promise(function(e, t) { const n = Jd(s); let i = n.data; const r = ln.from(n.headers).normalize(); let { responseType: a, onUploadProgress: o, onDownloadProgress: l } = n, c, h, u, f, d; function p() { f && f(), d && d(), n.cancelToken && n.cancelToken.unsubscribe(c), n.signal && n.signal.removeEventListener("abort", c); } let g = new XMLHttpRequest(); g.open(n.method.toUpperCase(), n.url, !0), g.timeout = n.timeout; function x() { if (!g) return; const v = ln.from( "getAllResponseHeaders" in g && g.getAllResponseHeaders() ), b = { data: !a || a === "text" || a === "json" ? g.responseText : g.response, status: g.status, statusText: g.statusText, headers: v, config: s, request: g }; Kd(function(M) { e(M), p(); }, function(M) { t(M), p(); }, b), g = null; } "onloadend" in g ? g.onloadend = x : g.onreadystatechange = function() { !g || g.readyState !== 4 || g.status === 0 && !(g.responseURL && g.responseURL.indexOf("file:") === 0) || setTimeout(x); }, g.onabort = function() { g && (t(new Ke("Request aborted", Ke.ECONNABORTED, s, g)), g = null); }, g.onerror = function(v) { const b = v && v.message ? v.message : "Network Error", M = new Ke(b, Ke.ERR_NETWORK, s, g); M.event = v || null, t(M), g = null; }, g.ontimeout = function() { let v = n.timeout ? "timeout of " + n.timeout + "ms exceeded" : "timeout exceeded"; const b = n.transitional || Zd; n.timeoutErrorMessage && (v = n.timeoutErrorMessage), t(new Ke( v, b.clarifyTimeoutError ? Ke.ETIMEDOUT : Ke.ECONNABORTED, s, g )), g = null; }, i === void 0 && r.setContentType(null), "setRequestHeader" in g && se.forEach(r.toJSON(), function(v, b) { g.setRequestHeader(b, v); }), se.isUndefined(n.withCredentials) || (g.withCredentials = !!n.withCredentials), a && a !== "json" && (g.responseType = n.responseType), l && ([u, d] = Ta(l, !0), g.addEventListener("progress", u)), o && g.upload && ([h, f] = Ta(o), g.upload.addEventListener("progress", h), g.upload.addEventListener("loadend", f)), (n.cancelToken || n.signal) && (c = (v) => { g && (t(!v || v.type ? new Ds(null, s, g) : v), g.abort(), g = null); }, n.cancelToken && n.cancelToken.subscribe(c), n.signal && (n.signal.aborted ? c() : n.signal.addEventListener("abort", c))); const m = q_(n.url); if (m && Zt.protocols.indexOf(m) === -1) { t(new Ke("Unsupported protocol " + m + ":", Ke.ERR_BAD_REQUEST, s)); return; } g.send(i || null); }); }, i2 = (s, e) => { const { length: t } = s = s ? s.filter(Boolean) : []; if (e || t) { let n = new AbortController(), i; const r = function(c) { if (!i) { i = !0, o(); const h = c instanceof Error ? c : this.reason; n.abort(h instanceof Ke ? h : new Ds(h instanceof Error ? h.message : h)); } }; let a = e && setTimeout(() => { a = null, r(new Ke(`timeout ${e} of ms exceeded`, Ke.ETIMEDOUT)); }, e); const o = () => { s && (a && clearTimeout(a), a = null, s.forEach((c) => { c.unsubscribe ? c.unsubscribe(r) : c.removeEventListener("abort", r); }), s = null); }; s.forEach((c) => c.addEventListener("abort", r)); const { signal: l } = n; return l.unsubscribe = () => se.asap(o), l; } }, s2 = function* (s, e) { let t = s.byteLength; if (t < e) { yield s; return; } let n = 0, i; for (; n < t; ) i = n + e, yield s.slice(n, i), n = i; }, r2 = async function* (s, e) { for await (const t of a2(s)) yield* s2(t, e); }, a2 = async function* (s) { if (s[Symbol.asyncIterator]) { yield* s; return; } const e = s.getReader(); try { for (; ; ) { const { done: t, value: n } = await e.read(); if (t) break; yield n; } } finally { await e.cancel(); } }, du = (s, e, t, n) => { const i = r2(s, e); let r = 0, a, o = (l) => { a || (a = !0, n && n(l)); }; return new ReadableStream({ async pull(l) { try { const { done: c, value: h } = await i.next(); if (c) { o(), l.close(); return; } let u = h.byteLength; if (t) { let f = r += u; t(f); } l.enqueue(new Uint8Array(h)); } catch (c) { throw o(c), c; } }, cancel(l) { return o(l), i.return(); } }, { highWaterMark: 2 }); }, fu = 64 * 1024, { isFunction: sa } = se, o2 = (({ Request: s, Response: e }) => ({ Request: s, Response: e }))(se.global), { ReadableStream: pu, TextEncoder: mu } = se.global, gu = (s, ...e) => { try { return !!s(...e); } catch { return !1; } }, l2 = (s) => { s = se.merge.call({ skipUndefined: !0 }, o2, s); const { fetch: e, Request: t, Response: n } = s, i = e ? sa(e) : typeof fetch == "function", r = sa(t), a = sa(n); if (!i) return !1; const o = i && sa(pu), l = i && (typeof mu == "function" ? /* @__PURE__ */ ((p) => (g) => p.encode(g))(new mu()) : async (p) => new Uint8Array(await new t(p).arrayBuffer())), c = r && o && gu(() => { let p = !1; const g = new t(Zt.origin, { body: new pu(), method: "POST", get duplex() { return p = !0, "half"; } }).headers.has("Content-Type"); return p && !g; }), h = a && o && gu(() => se.isReadableStream(new n("").body)), u = { stream: h && ((p) => p.body) }; i && ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((p) => { !u[p] && (u[p] = (g, x) => { let m = g && g[p]; if (m) return m.call(g); throw new Ke(`Response type '${p}' is not supported`, Ke.ERR_NOT_SUPPORT, x); }); }); const f = async (p) => { if (p == null) return 0; if (se.isBlob(p)) return p.size; if (se.isSpecCompliantForm(p)) return (await new t(Zt.origin, { method: "POST", body: p }).arrayBuffer()).byteLength; if (se.isArrayBufferView(p) || se.isArrayBuffer(p)) return p.byteLength; if (se.isURLSearchParams(p) && (p = p + ""), se.isString(p)) return (await l(p)).byteLength; }, d = async (p, g) => se.toFiniteNumber(p.getContentLength()) ?? f(g); return async (p) => { let { url: g, method: x, data: m, signal: v, cancelToken: b, timeout: M, onDownloadProgress: C, onUploadProgress: T, responseType: D, headers: U, withCredentials: S = "same-origin", fetchOptions: w } = Jd(p), B = e || fetch; D = D ? (D + "").toLowerCase() : "text"; let P = i2([v, b && b.toAbortSignal()], M), O = null; const y = P && P.unsubscribe && (() => { P.unsubscribe(); }); let H; try { if (T && c && x !== "get" && x !== "head" && (H = await d(U, m)) !== 0) { let X = new t(g, { method: "POST", body: m, duplex: "half" }), q; if (se.isFormData(m) && (q = X.headers.get("content-type")) && U.setContentType(q), X.body) { const [ge, pe] = cu( H, Ta(hu(T)) ); m = du(X.body, fu, ge, pe); } } se.isString(S) || (S = S ? "include" : "omit"); const Y = r && "credentials" in t.prototype, j = { ...w, signal: P, method: x.toUpperCase(), headers: U.normalize().toJSON(), body: m, duplex: "half", credentials: Y ? S : void 0 }; O = r && new t(g, j); let J = await (r ? B(O, w) : B(g, j)); const Z = h && (D === "stream" || D === "response"); if (h && (C || Z && y)) { const X = {}; ["status", "statusText", "headers"].forEach((de) => { X[de] = J[de]; }); const q = se.toFiniteNumber(J.headers.get("content-length")), [ge, pe] = C && cu( q, Ta(hu(C), !0) ) || []; J = new n( du(J.body, fu, ge, () => { pe && pe(), y && y(); }), X ); } D = D || "text"; let ae = await u[se.findKey(u, D) || "text"](J, p); return !Z && y && y(), await new Promise((X, q) => { Kd(X, q, { data: ae, headers: ln.from(J.headers), status: J.status, statusText: J.statusText, config: p, request: O }); }); } catch (Y) { throw y && y(), Y && Y.name === "TypeError" && /Load failed|fetch/i.test(Y.message) ? Object.assign( new Ke("Network Error", Ke.ERR_NETWORK, p, O), { cause: Y.cause || Y } ) : Ke.from(Y, Y && Y.code, p, O); } }; }, c2 = /* @__PURE__ */ new Map(), Qd = (s) => { let e = s && s.env || {}; const { fetch: t, Request: n, Response: i } = e, r = [ n, i, t ]; let a = r.length, o = a, l, c, h = c2; for (; o--; ) l = r[o], c = h.get(l), c === void 0 && h.set(l, c = o ? /* @__PURE__ */ new Map() : l2(e)), h = c; return c; }; Qd(); const _c = { http: T_, xhr: n2, fetch: { get: Qd } }; se.forEach(_c, (s, e) => { if (s) { try { Object.defineProperty(s, "name", { value: e }); } catch { } Object.defineProperty(s, "adapterName", { value: e }); } }); const xu = (s) => `- ${s}`, h2 = (s) => se.isFunction(s) || s === null || s === !1; function u2(s, e) { s = se.isArray(s) ? s : [s]; const { length: t } = s; let n, i; const r = {}; for (let a = 0; a < t; a++) { n = s[a]; let o; if (i = n, !h2(n) && (i = _c[(o = String(n)).toLowerCase()], i === void 0)) throw new Ke(`Unknown adapter '${o}'`); if (i && (se.isFunction(i) || (i = i.get(e)))) break; r[o || "#" + a] = i; } if (!i) { const a = Object.entries(r).map( ([l, c]) => `adapter ${l} ` + (c === !1 ? "is not supported by the environment" : "is not available in the build") ); let o = t ? a.length > 1 ? `since : ` + a.map(xu).join(` `) : " " + xu(a[0]) : "as no adapter specified"; throw new Ke( "There is no suitable adapter to dispatch the request " + o, "ERR_NOT_SUPPORT" ); } return i; } const ef = { /** * Resolve an adapter from a list of adapter names or functions. * @type {Function} */ getAdapter: u2, /** * Exposes all known adapters * @type {Object} */ adapters: _c }; function Do(s) { if (s.cancelToken && s.cancelToken.throwIfRequested(), s.signal && s.signal.aborted) throw new Ds(null, s); } function vu(s) { return Do(s), s.headers = ln.from(s.headers), s.data = Lo.call( s, s.transformRequest ), ["post", "put", "patch"].indexOf(s.method) !== -1 && s.headers.setContentType("application/x-www-form-urlencoded", !1), ef.getAdapter(s.adapter || br.adapter, s)(s).then(function(e) { return Do(s), e.data = Lo.call( s, s.transformResponse, e ), e.headers = ln.from(e.headers), e; }, function(e) { return Yd(e) || (Do(s), e && e.response && (e.response.data = Lo.call( s, s.transformResponse, e.response ), e.response.headers = ln.from(e.response.headers))), Promise.reject(e); }); } const tf = "1.13.2", Oa = {}; ["object", "boolean", "number", "function", "string", "symbol"].forEach((s, e) => { Oa[s] = function(t) { return typeof t === s || "a" + (e < 1 ? "n " : " ") + s; }; }); const bu = {}; Oa.transitional = function(s, e, t) { function n(i, r) { return "[Axios v" + tf + "] Transitional option '" + i + "'" + r + (t ? ". " + t : ""); } return (i, r, a) => { if (s === !1) throw new Ke( n(r, " has been removed" + (e ? " in " + e : "")), Ke.ERR_DEPRECATED ); return e && !bu[r] && (bu[r] = !0, console.warn( n( r, " has been deprecated since v" + e + " and will be removed in the near future" ) )), s ? s(i, r, a) : !0; }; }; Oa.spelling = function(s) { return (e, t) => (console.warn(`${t} is likely a misspelling of ${s}`), !0); }; function d2(s, e, t) { if (typeof s != "object") throw new Ke("options must be an object", Ke.ERR_BAD_OPTION_VALUE); const n = Object.keys(s); let i = n.length; for (; i-- > 0; ) { const r = n[i], a = e[r]; if (a) { const o = s[r], l = o === void 0 || a(o, r, s); if (l !== !0) throw new Ke("option " + r + " must be " + l, Ke.ERR_BAD_OPTION_VALUE); continue; } if (t !== !0) throw new Ke("Unknown option " + r, Ke.ERR_BAD_OPTION); } } const xa = { assertOptions: d2, validators: Oa }, Bn = xa.validators; let Pi = class { constructor(s) { this.defaults = s || {}, this.interceptors = { request: new ou(), response: new ou() }; } /** * Dispatch a request * * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults) * @param {?Object} config * * @returns {Promise} The Promise to be fulfilled */ async request(s, e) { try { return await this._request(s, e); } catch (t) { if (t instanceof Error) { let n = {}; Error.captureStackTrace ? Error.captureStackTrace(n) : n = new Error(); const i = n.stack ? n.stack.replace(/^.+\n/, "") : ""; try { t.stack ? i && !String(t.stack).endsWith(i.replace(/^.+\n.+\n/, "")) && (t.stack += ` ` + i) : t.stack = i; } catch { } } throw t; } } _request(s, e) { typeof s == "string" ? (e = e || {}, e.url = s) : e = s || {}, e = ki(this.defaults, e); const { transitional: t, paramsSerializer: n, headers: i } = e; t !== void 0 && xa.assertOptions(t, { silentJSONParsing: Bn.transitional(Bn.boolean), forcedJSONParsing: Bn.transitional(Bn.boolean), clarifyTimeoutError: Bn.transitional(Bn.boolean) }, !1), n != null && (se.isFunction(n) ? e.paramsSerializer = { serialize: n } : xa.assertOptions(n, { encode: Bn.function, serialize: Bn.function }, !0)), e.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? e.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : e.allowAbsoluteUrls = !0), xa.assertOptions(e, { baseUrl: Bn.spelling("baseURL"), withXsrfToken: Bn.spelling("withXSRFToken") }, !0), e.method = (e.method || this.defaults.method || "get").toLowerCase(); let r = i && se.merge( i.common, i[e.method] ); i && se.forEach( ["delete", "get", "head", "post", "put", "patch", "common"], (d) => { delete i[d]; } ), e.headers = ln.concat(r, i); const a = []; let o = !0; this.interceptors.request.forEach(function(d) { typeof d.runWhen == "function" && d.runWhen(e) === !1 || (o = o && d.synchronous, a.unshift(d.fulfilled, d.rejected)); }); const l = []; this.interceptors.response.forEach(function(d) { l.push(d.fulfilled, d.rejected); }); let c, h = 0, u; if (!o) { const d = [vu.bind(this), void 0]; for (d.unshift(...a), d.push(...l), u = d.length, c = Promise.resolve(e); h < u; ) c = c.then(d[h++], d[h++]); return c; } u = a.length; let f = e; for (; h < u; ) { const d = a[h++], p = a[h++]; try { f = d(f); } catch (g) { p.call(this, g); break; } } try { c = vu.call(this, f); } catch (d) { return Promise.reject(d); } for (h = 0, u = l.length; h < u; ) c = c.then(l[h++], l[h++]); return c; } getUri(s) { s = ki(this.defaults, s); const e = $d(s.baseURL, s.url, s.allowAbsoluteUrls); return jd(e, s.params, s.paramsSerializer); } }; se.forEach(["delete", "get", "head", "options"], function(s) { Pi.prototype[s] = function(e, t) { return this.request(ki(t || {}, { method: s, url: e, data: (t || {}).data })); }; }); se.forEach(["post", "put", "patch"], function(s) { function e(t) { return function(n, i, r) { return this.request(ki(r || {}, { method: s, headers: t ? { "Content-Type": "multipart/form-data" } : {}, url: n, data: i })); }; } Pi.prototype[s] = e(), Pi.prototype[s + "Form"] = e(!0); }); let f2 = class nf { constructor(e) { if (typeof e != "function") throw new TypeError("executor must be a function."); let t; this.promise = new Promise(function(i) { t = i; }); const n = this; this.promise.then((i) => { if (!n._listeners) return; let r = n._listeners.length; for (; r-- > 0; ) n._listeners[r](i); n._listeners = null; }), this.promise.then = (i) => { let r; const a = new Promise((o) => { n.subscribe(o), r = o; }).then(i); return a.cancel = function() { n.unsubscribe(r); }, a; }, e(function(i, r, a) { n.reason || (n.reason = new Ds(i, r, a), t(n.reason)); }); } /** * Throws a `CanceledError` if cancellation has been requested. */ throwIfRequested() { if (this.reason) throw this.reason; } /** * Subscribe to the cancel signal */ subscribe(e) { if (this.reason) { e(this.reason); return; } this._listeners ? this._listeners.push(e) : this._listeners = [e]; } /** * Unsubscribe from the cancel signal */ unsubscribe(e) { if (!this._listeners) return; const t = this._listeners.indexOf(e); t !== -1 && this._listeners.splice(t, 1); } toAbortSignal() { const e = new AbortController(), t = (n) => { e.abort(n); }; return this.subscribe(t), e.signal.unsubscribe = () => this.unsubscribe(t), e.signal; } /** * Returns an object that contains a new `CancelToken` and a function that, when called, * cancels the `CancelToken`. */ static source() { let e; return { token: new nf(function(t) { e = t; }), cancel: e }; } }; function p2(s) { return function(e) { return s.apply(null, e); }; } function m2(s) { return se.isObject(s) && s.isAxiosError === !0; } const zl = { Continue: 100, SwitchingProtocols: 101, Processing: 102, EarlyHints: 103, Ok: 200, Created: 201, Accepted: 202, NonAuthoritativeInformation: 203, NoContent: 204, ResetContent: 205, PartialContent: 206, MultiStatus: 207, AlreadyReported: 208, ImUsed: 226, MultipleChoices: 300, MovedPermanently: 301, Found: 302, SeeOther: 303, NotModified: 304, UseProxy: 305, Unused: 306, TemporaryRedirect: 307, PermanentRedirect: 308, BadRequest: 400, Unauthorized: 401, PaymentRequired: 402, Forbidden: 403, NotFound: 404, MethodNotAllowed: 405, NotAcceptable: 406, ProxyAuthenticationRequired: 407, RequestTimeout: 408, Conflict: 409, Gone: 410, LengthRequired: 411, PreconditionFailed: 412, PayloadTooLarge: 413, UriTooLong: 414, UnsupportedMediaType: 415, RangeNotSatisfiable: 416, ExpectationFailed: 417, ImATeapot: 418, MisdirectedRequest: 421, UnprocessableEntity: 422, Locked: 423, FailedDependency: 424, TooEarly: 425, UpgradeRequired: 426, PreconditionRequired: 428, TooManyRequests: 429, RequestHeaderFieldsTooLarge: 431, UnavailableForLegalReasons: 451, InternalServerError: 500, NotImplemented: 501, BadGateway: 502, ServiceUnavailable: 503, GatewayTimeout: 504, HttpVersionNotSupported: 505, VariantAlsoNegotiates: 506, InsufficientStorage: 507, LoopDetected: 508, NotExtended: 510, NetworkAuthenticationRequired: 511, WebServerIsDown: 521, ConnectionTimedOut: 522, OriginIsUnreachable: 523, TimeoutOccurred: 524, SslHandshakeFailed: 525, InvalidSslCertificate: 526 }; Object.entries(zl).forEach(([s, e]) => { zl[e] = s; }); function sf(s) { const e = new Pi(s), t = Nd(Pi.prototype.request, e); return se.extend(t, Pi.prototype, e, { allOwnKeys: !0 }), se.extend(t, e, null, { allOwnKeys: !0 }), t.create = function(n) { return sf(ki(s, n)); }, t; } const Rt = sf(br); Rt.Axios = Pi; Rt.CanceledError = Ds; Rt.CancelToken = f2; Rt.isCancel = Yd; Rt.VERSION = tf; Rt.toFormData = Ba; Rt.AxiosError = Ke; Rt.Cancel = Rt.CanceledError; Rt.all = function(s) { return Promise.all(s); }; Rt.spread = p2; Rt.isAxiosError = m2; Rt.mergeConfig = ki; Rt.AxiosHeaders = ln; Rt.formToJSON = (s) => qd(se.isHTMLForm(s) ? new FormData(s) : s); Rt.getAdapter = ef.getAdapter; Rt.HttpStatusCode = zl; Rt.default = Rt; const { Axios: q3, AxiosError: Y3, CanceledError: K3, isCancel: $3, CancelToken: J3, VERSION: Q3, all: eM, Cancel: tM, isAxiosError: nM, spread: iM, toFormData: sM, AxiosHeaders: rM, HttpStatusCode: aM, formToJSON: oM, getAdapter: lM, mergeConfig: cM } = Rt; function g2(s, e) { var t; if (window.XMLHttpRequest ? t = new XMLHttpRequest() : window.ActiveXObject ? t = new window.ActiveXObject() : alert("请升级至最新版本的浏览器"), t != null) { let n = s + "?timestamp=" + (/* @__PURE__ */ new Date()).getTime(); t.open("GET", n, !0), t.send(null), t.onreadystatechange = function() { t.readyState == 4 && t.status == 200 && (t.responseText.includes("", 0) && t.responseText.includes("", 0) && t.responseText.includes("", 0) ? e(null) : e(t.responseText)); }, t.onloadend = function() { t.readyState == 4 && t.status == 404 && t.status == 502 && e(null); }; } } function rf(s, e) { Rt({ method: "get", responseType: "blob", url: s + "?timestamp=" + (/* @__PURE__ */ new Date()).getTime() // 文件所在阿里云的链接地址 }).then((n) => { let i = new window.File([n.data], "semantics", { type: "zip" }); zb.loadAsync(i).then((r) => { for (let a in r.files) r.file(r.files[a].name).async("blob").then((o) => { t(o, "utf-8", function(l, c) { e(c); }); }); }); }); function t(n, i, r) { var a = new FileReader(), o = new Blob([n]); a.onload = function(l) { r(null, l.target.result); }, a.onerror = function(l) { r(l.error, null); }, a.readAsText(o, i); } } const Io = /* @__PURE__ */ new WeakMap(); class x2 extends Fi { /** * Constructs a new Draco loader. * * @param {LoadingManager} [manager] - The loading manager. */ constructor(e) { super(e), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = { position: "POSITION", normal: "NORMAL", color: "COLOR", uv: "TEX_COORD" }, this.defaultAttributeTypes = { position: "Float32Array", normal: "Float32Array", color: "Float32Array", uv: "Float32Array" }; } /** * Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins. * * @param {string} path - The decoder path. * @return {DRACOLoader} A reference to this loader. */ setDecoderPath(e) { return this.decoderPath = e, this; } /** * Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins. * * @param {{type:('js'|'wasm')}} config - The decoder config. * @return {DRACOLoader} A reference to this loader. */ setDecoderConfig(e) { return this.decoderConfig = e, this; } /** * Sets the maximum number of Web Workers to be used during decoding. * A lower limit may be preferable if workers are also for other tasks in the application. * * @param {number} workerLimit - The worker limit. * @return {DRACOLoader} A reference to this loader. */ setWorkerLimit(e) { return this.workerLimit = e, this; } /** * Starts loading from the given URL and passes the loaded Draco asset * to the `onLoad()` callback. * * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI. * @param {function(BufferGeometry)} onLoad - Executed when the loading process has been finished. * @param {onProgressCallback} onProgress - Executed while the loading is in progress. * @param {onErrorCallback} onError - Executed when errors occur. */ load(e, t, n, i) { const r = new wa(this.manager); r.setPath(this.path), r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials), r.load(e, (a) => { this.parse(a, t, i); }, n, i); } /** * Parses the given Draco data. * * @param {ArrayBuffer} buffer - The raw Draco data as an array buffer. * @param {function(BufferGeometry)} onLoad - Executed when the loading/parsing process has been finished. * @param {onErrorCallback} onError - Executed when errors occur. */ parse(e, t, n = () => { }) { this.decodeDracoFile(e, t, null, null, mt, n).catch(n); } // decodeDracoFile(e, t, n, i, r = Tt, a = () => { }) { const o = { attributeIDs: n || this.defaultAttributeIDs, attributeTypes: i || this.defaultAttributeTypes, useUniqueIDs: !!n, vertexColorSpace: r }; return this.decodeGeometry(e, o).then(t).catch(a); } decodeGeometry(e, t) { const n = JSON.stringify(t); if (Io.has(e)) { const l = Io.get(e); if (l.key === n) return l.promise; if (e.byteLength === 0) throw new Error( "THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred." ); } let i; const r = this.workerNextTaskID++, a = e.byteLength, o = this._getWorker(r, a).then((l) => (i = l, new Promise((c, h) => { i._callbacks[r] = { resolve: c, reject: h }, i.postMessage({ type: "decode", id: r, taskConfig: t, buffer: e }, [e]); }))).then((l) => this._createGeometry(l.geometry)); return o.catch(() => !0).then(() => { i && r && this._releaseTask(i, r); }), Io.set(e, { key: n, promise: o }), o; } _createGeometry(e) { const t = new xt(); e.index && t.setIndex(new gt(e.index.array, 1)); for (let n = 0; n < e.attributes.length; n++) { const { name: i, array: r, itemSize: a, stride: o, vertexColorSpace: l } = e.attributes[n]; let c; if (a === o) c = new gt(r, a); else { const h = new od(r, o); c = new Pa(h, a, 0); } i === "color" && (this._assignVertexColorSpace(c, l), c.normalized = !(r instanceof Float32Array)), t.setAttribute(i, c); } return t; } _assignVertexColorSpace(e, t) { if (t !== mt) return; const n = new Fe(); for (let i = 0, r = e.count; i < r; i++) n.fromBufferAttribute(e, i), it.colorSpaceToWorking(n, mt), e.setXYZ(i, n.r, n.g, n.b); } _loadLibrary(e, t) { const n = new wa(this.manager); return n.setPath(this.decoderPath), n.setResponseType(t), n.setWithCredentials(this.withCredentials), new Promise((i, r) => { n.load(e, i, void 0, r); }); } preload() { return this._initDecoder(), this; } _initDecoder() { if (this.decoderPending) return this.decoderPending; const e = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = []; return e ? t.push(this._loadLibrary("draco_decoder.js", "text")) : (t.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), t.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))), this.decoderPending = Promise.all(t).then((n) => { const i = n[0]; e || (this.decoderConfig.wasmBinary = n[1]); const r = v2.toString(), a = [ "/* draco decoder */", i, "", "/* worker */", r.substring(r.indexOf("{") + 1, r.lastIndexOf("}")) ].join(` `); this.workerSourceURL = URL.createObjectURL(new Blob([a])); }), this.decoderPending; } _getWorker(e, t) { return this._initDecoder().then(() => { if (this.workerPool.length < this.workerLimit) { const i = new Worker(this.workerSourceURL); i._callbacks = {}, i._taskCosts = {}, i._taskLoad = 0, i.postMessage({ type: "init", decoderConfig: this.decoderConfig }), i.onmessage = function(r) { const a = r.data; switch (a.type) { case "decode": i._callbacks[a.id].resolve(a); break; case "error": i._callbacks[a.id].reject(a); break; default: console.error('THREE.DRACOLoader: Unexpected message, "' + a.type + '"'); } }, this.workerPool.push(i); } else this.workerPool.sort(function(i, r) { return i._taskLoad > r._taskLoad ? -1 : 1; }); const n = this.workerPool[this.workerPool.length - 1]; return n._taskCosts[e] = t, n._taskLoad += t, n; }); } _releaseTask(e, t) { e._taskLoad -= e._taskCosts[t], delete e._callbacks[t], delete e._taskCosts[t]; } debug() { console.log("Task load: ", this.workerPool.map((e) => e._taskLoad)); } dispose() { for (let e = 0; e < this.workerPool.length; ++e) this.workerPool[e].terminate(); return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this; } } function v2() { let s, e; onmessage = function(a) { const o = a.data; switch (o.type) { case "init": s = o.decoderConfig, e = new Promise(function(h) { s.onModuleLoaded = function(u) { h({ draco: u }); }, DracoDecoderModule(s); }); break; case "decode": const l = o.buffer, c = o.taskConfig; e.then((h) => { const u = h.draco, f = new u.Decoder(); try { const d = t(u, f, new Int8Array(l), c), p = d.attributes.map((g) => g.array.buffer); d.index && p.push(d.index.array.buffer), self.postMessage({ type: "decode", id: o.id, geometry: d }, p); } catch (d) { console.error(d), self.postMessage({ type: "error", id: o.id, error: d.message }); } finally { u.destroy(f); } }); break; } }; function t(a, o, l, c) { const h = c.attributeIDs, u = c.attributeTypes; let f, d; const p = o.GetEncodedGeometryType(l); if (p === a.TRIANGULAR_MESH) f = new a.Mesh(), d = o.DecodeArrayToMesh(l, l.byteLength, f); else if (p === a.POINT_CLOUD) f = new a.PointCloud(), d = o.DecodeArrayToPointCloud(l, l.byteLength, f); else throw new Error("THREE.DRACOLoader: Unexpected geometry type."); if (!d.ok() || f.ptr === 0) throw new Error("THREE.DRACOLoader: Decoding failed: " + d.error_msg()); const g = { index: null, attributes: [] }; for (const x in h) { const m = self[u[x]]; let v, b; if (c.useUniqueIDs) b = h[x], v = o.GetAttributeByUniqueId(f, b); else { if (b = o.GetAttributeId(f, a[h[x]]), b === -1) continue; v = o.GetAttribute(f, b); } const M = i(a, o, f, x, m, v); x === "color" && (M.vertexColorSpace = c.vertexColorSpace), g.attributes.push(M); } return p === a.TRIANGULAR_MESH && (g.index = n(a, o, f)), a.destroy(f), g; } function n(a, o, l) { const c = l.num_faces() * 3, h = c * 4, u = a._malloc(h); o.GetTrianglesUInt32Array(l, h, u); const f = new Uint32Array(a.HEAPF32.buffer, u, c).slice(); return a._free(u), { array: f, itemSize: 1 }; } function i(a, o, l, c, h, u) { const f = l.num_points(), d = u.num_components(), p = r(a, h), g = d * h.BYTES_PER_ELEMENT, x = Math.ceil(g / 4) * 4, m = x / h.BYTES_PER_ELEMENT, v = f * g, b = f * x, M = a._malloc(v); o.GetAttributeDataArrayForAllPoints(l, u, p, v, M); const C = new h(a.HEAPF32.buffer, M, v / h.BYTES_PER_ELEMENT); let T; if (g === x) T = C.slice(); else { T = new h(b / h.BYTES_PER_ELEMENT); let D = 0; for (let U = 0, S = C.length; U < S; U++) { for (let w = 0; w < d; w++) T[D + w] = C[U * d + w]; D += m; } } return a._free(M), { name: c, count: f, itemSize: d, array: T, stride: m }; } function r(a, o) { switch (o) { case Float32Array: return a.DT_FLOAT32; case Int8Array: return a.DT_INT8; case Int16Array: return a.DT_INT16; case Int32Array: return a.DT_INT32; case Uint8Array: return a.DT_UINT8; case Uint16Array: return a.DT_UINT16; case Uint32Array: return a.DT_UINT32; } } } var dr = /* @__PURE__ */ ((s) => (s.ModelLoadStart = "model-load-start", s.ModelLoadProgress = "model-load-progress", s.ModelLoaded = "model-loaded", s.ModelError = "model-error", s.SelectionChanged = "selection-changed", s.HoverChanged = "hover-changed", s.Click = "click", s.MouseMove = "mouse-move", s.CameraChanged = "camera-changed", s.CameraIdle = "camera-idle", s.EngineFree = "engine-free", s.EngineBusy = "engine-busy", s))(dr || {}); function b2(s, e, t, n) { let i = 0, r = 0, a = 0, o = s.models.find((d) => d.url == t), l = e.circularMeps, c = e.rectMeps.filter((d) => d.type === "风管"), h = e.rectMeps.filter((d) => d.type === "桥架"), u = e.ellipseMeps, f = s.scene; if (new Nt(), new xt(), ra(f, "InstancedMesh"), l && l.length) { let d = []; for (let p of l) p.color = new Fe(`rgb(${p.color})`), p.position = { x: p.startPoint.X * 0.3048 + i, y: p.startPoint.Z * 0.3048 + r, z: -p.startPoint.Y * 0.3048 + a }, p.rotation = { x: 0, y: 0, z: 0 }, o.nodesMap.set(p.id, [p]), d.push(p); aa("Circle", f, d, 2); } if (ra(f, "InstancedMesh"), c && c.length) { let d = []; for (let p of c) p.color = new Fe(`rgb(${p.color})`), p.position = { x: p.startPoint.X * 0.3048 + i, y: p.startPoint.Z * 0.3048 + r, z: -p.startPoint.Y * 0.3048 + a }, p.rotation = { x: 0, y: 0, z: 0 }, o.nodesMap.set(p.id, [p]), d.push(p); aa("Rect", f, d, 3); } if (ra(f, "InstancedMesh"), u && u.length) { let d = []; for (let p of u) p.color = new Fe(`rgb(${p.color})`), p.position = { x: p.startPoint.X * 0.3048 + i, y: p.startPoint.Z * 0.3048 + r, z: -p.startPoint.Y * 0.3048 + a }, p.rotation = { x: 0, y: 0, z: 0 }, o.nodesMap.set(p.id, [p]), d.push(p); aa("Ellipse", f, d, 4); } if (ra(f, "InstancedMesh"), h && h.length) { let d = []; for (let p of h) p.color = new Fe(`rgb(${p.color})`), p.position = { x: p.startPoint.X * 0.3048 + i, y: p.startPoint.Z * 0.3048 + r, z: -p.startPoint.Y * 0.3048 + a }, p.rotation = { x: 0, y: 0, z: 0 }, o.nodesMap.set(p.id, [p]), d.push(p); aa("Bridge", f, d, 5); } } function ra(s, e) { let t = new oc(e.geometry, e.material, 1); t.index = e.index, t.dataType = e.type, t.url = e.url, t.relativeIndex = e.relativeIndex, t.name = "机电", s.add(t); } function aa(s, e, t, n, i) { let r, a, o = { width: 1, height: 1, length: 1, diameter: 1, color: new Fe(), position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 } }; switch (s) { case "Rect": a = oa("Rect", o); break; case "Bridge": a = oa("Bridge", o); break; case "Circle": a = oa("Circle", o); break; case "Ellipse": a = oa("Ellipse", o); break; } a && (r = new oc(a.geometry, a.material, t.length)); let l = []; for (var c = 0; c < t.length; c++) { let f = t[c], d = new R(f.startPoint.X, 0, -f.startPoint.Y), p = new R(f.endPoint.X, 0, -f.endPoint.Y), g = new R(f.startPoint.X, f.startPoint.Z, -f.startPoint.Y), x = new R(f.endPoint.X, f.endPoint.Z, -f.endPoint.Y), m = 0, v = 0, b = 0; if (Math.abs(p.clone().sub(d.clone()).z) < 0.01 && Math.abs(p.clone().sub(d.clone()).x) < 0.01) { if (m = (f.startPoint.Z > f.endPoint.Z ? 1 : -1) * Math.PI * 0.5, f.base_x != null) { var h = new R(f.base_x.X, 0, -f.base_x.Y); v = (h.clone().cross(new R(0, 0, 1)).y <= 0 ? 1 : -1) * h.angleTo(new R(0, 0, 1)) + Math.PI * 0.5; } } else v = (p.clone().sub(d.clone()).cross(new R(0, 0, 1)).y > 0 ? -1 : 1) * p.clone().sub(d.clone()).angleTo(new R(0, 0, 1)), m = (f.startPoint.Z > f.endPoint.Z ? 1 : -1) * p.clone().sub(d.clone()).angleTo(x.clone().sub(g.clone())); let M = new je(); const C = new cn(m, v, b, "YXZ"); let T = M.clone().makeRotationFromEuler(C), D, U; s === "Circle" ? (D = f.diameter, U = f.diameter) : (D = f.width, U = f.height); let S = M.clone().makeScale(D, U, f.length); M.multiplyMatrices(T, S), M.setPosition(f.position.x, f.position.y, f.position.z), r.setMatrixAt(c, M.clone()), r.setColorAt(c, f.color), r.geometry.computeBoundingBox(); let w = r.geometry.boundingBox.min.clone().applyMatrix4(M.clone()), B = r.geometry.boundingBox.max.clone().applyMatrix4(M.clone()), P = new R(Math.min(w.x, B.x), Math.min(w.y, B.y), Math.min(w.z, B.z)), O = new R(Math.max(w.x, B.x), Math.max(w.y, B.y), Math.max(w.z, B.z)), y = P.clone().add(O.clone()).multiplyScalar(0.5), H = { name: f.name, min: P, max: O, center: y, dbid: c, // url: path + "/" + type, // basePath: url, // relativePath: relativePath, materialName: a.material.name }, Y = null, j = null; s === "Circle" && (Y = { x: f.startPoint.X * 0.3048, y: f.startPoint.Z * 0.3048, z: -f.startPoint.Y * 0.3048 }, j = { x: f.endPoint.X * 0.3048, y: f.endPoint.Z * 0.3048, z: -f.endPoint.Y * 0.3048 }, H.minC = Y, H.maxC = j), l.push(H); } r.castShadow = !0, r.ElementInfos = l, r.name = "rootModel", r.TypeName = "InstancedMesh-Pipe", r.PipeType = s, r.MeshId = null, r.realMaterial = r.material.clone(), r.originalMaterial = r.material.clone(); let u = []; u = { geometry: r.geometry, matrix: r.matrix, position: r.position, rotation: r.rotation }, r.meshs = u, r.instanceMatrix && r.instanceMatrix.array && (r.cloneInstanceMatrix = Array.from(r.instanceMatrix.array)), r.index = n, r.Version = "V1", e.children[n] = r; } function oa(s, e, t) { let n = new gd(); switch (e.width = e.width * 0.3048, e.height = e.height * 0.3048, e.diameter = e.diameter * 0.3048, s) { case "Rect": n.moveTo(-e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, e.height / 2), n.lineTo(e.width / 2, e.height / 2), n.lineTo(e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, -e.height / 2); break; case "Ellipse": n.moveTo(-e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, e.height / 2), n.lineTo(e.width / 2, e.height / 2), n.lineTo(e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, -e.height / 2); break; case "Bridge": n.moveTo(-e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, e.height / 2), n.lineTo(-e.width / 2 + 0.01, e.height / 2), n.lineTo(-e.width / 2 + 0.01, -e.height / 2 + 0.01), n.lineTo(e.width / 2 - 0.01, -e.height / 2 + 0.01), n.lineTo(e.width / 2 - 0.01, e.height / 2), n.lineTo(e.width / 2, e.height / 2), n.lineTo(e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, -e.height / 2); break; case "Circle": n.moveTo(0, 0), n.absarc(0, 0, e.diameter * 0.5, 0, Math.PI * 2, !1); break; } const i = { depth: e.length * 0.3048, //拉伸长度 bevelEnabled: !1 }; return r(n, i, e.color, e.position, e.rotation); function r(a, o, l, c, h) { let u = new dc(a, o), f = new Bm({ color: l, side: Dt // depthTest:false // name: path + "/" + type + "/material" }), d = new ft(u, f); return d.position.set(c.x, c.y, c.z), d.rotation._order = "YXZ", d.rotation.set(h.x, h.y, h.z), d; } } function _2(s, e = !1) { const t = s[0].index !== null, n = new Set(Object.keys(s[0].attributes)), i = new Set(Object.keys(s[0].morphAttributes)), r = {}, a = {}, o = s[0].morphTargetsRelative, l = new xt(); let c = 0; for (let h = 0; h < s.length; ++h) { const u = s[h]; let f = 0; if (t !== (u.index !== null)) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + h + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."), null; for (const d in u.attributes) { if (!n.has(d)) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + h + '. All geometries must have compatible attributes; make sure "' + d + '" attribute exists among all geometries, or in none of them.'), null; r[d] === void 0 && (r[d] = []), r[d].push(u.attributes[d]), f++; } if (f !== n.size) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + h + ". Make sure all geometries have the same number of attributes."), null; if (o !== u.morphTargetsRelative) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + h + ". .morphTargetsRelative must be consistent throughout all geometries."), null; for (const d in u.morphAttributes) { if (!i.has(d)) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + h + ". .morphAttributes must be consistent throughout all geometries."), null; a[d] === void 0 && (a[d] = []), a[d].push(u.morphAttributes[d]); } if (e) { let d; if (t) d = u.index.count; else if (u.attributes.position !== void 0) d = u.attributes.position.count; else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + h + ". The geometry must have either an index or a position attribute"), null; l.addGroup(c, d, h), c += d; } } if (t) { let h = 0; const u = []; for (let f = 0; f < s.length; ++f) { const d = s[f].index; for (let p = 0; p < d.count; ++p) u.push(d.getX(p) + h); h += s[f].attributes.position.count; } l.setIndex(u); } for (const h in r) { const u = _u(r[h]); if (!u) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + h + " attribute."), null; l.setAttribute(h, u); } for (const h in a) { const u = a[h][0].length; if (u === 0) break; l.morphAttributes = l.morphAttributes || {}, l.morphAttributes[h] = []; for (let f = 0; f < u; ++f) { const d = []; for (let g = 0; g < a[h].length; ++g) d.push(a[h][g][f]); const p = _u(d); if (!p) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + h + " morphAttribute."), null; l.morphAttributes[h].push(p); } } return l; } function _u(s) { let e, t, n, i = -1, r = 0; for (let c = 0; c < s.length; ++c) { const h = s[c]; if (e === void 0 && (e = h.array.constructor), e !== h.array.constructor) return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."), null; if (t === void 0 && (t = h.itemSize), t !== h.itemSize) return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."), null; if (n === void 0 && (n = h.normalized), n !== h.normalized) return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."), null; if (i === -1 && (i = h.gpuType), i !== h.gpuType) return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."), null; r += h.count * t; } const a = new e(r), o = new gt(a, t, n); let l = 0; for (let c = 0; c < s.length; ++c) { const h = s[c]; if (h.isInterleavedBufferAttribute) { const u = l / t; for (let f = 0, d = h.count; f < d; f++) for (let p = 0; p < t; p++) { const g = h.getComponent(f, p); o.setComponent(f + u, p, g); } } else a.set(h.array, l); l += h.count * t; } return i !== void 0 && (o.gpuType = i), o; } function yu(s, e) { if (e === Yf) return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), s; if (e === Cl || e === Ku) { let t = s.getIndex(); if (t === null) { const a = [], o = s.getAttribute("position"); if (o !== void 0) { for (let l = 0; l < o.count; l++) a.push(l); s.setIndex(a), t = s.getIndex(); } else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), s; } const n = t.count - 2, i = []; if (e === Cl) for (let a = 1; a <= n; a++) i.push(t.getX(0)), i.push(t.getX(a)), i.push(t.getX(a + 1)); else for (let a = 0; a < n; a++) a % 2 === 0 ? (i.push(t.getX(a)), i.push(t.getX(a + 1)), i.push(t.getX(a + 2))) : (i.push(t.getX(a + 2)), i.push(t.getX(a + 1)), i.push(t.getX(a))); i.length / 3 !== n && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles."); const r = s.clone(); return r.setIndex(i), r.clearGroups(), r; } else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), s; } class y2 extends Fi { /** * Constructs a new glTF loader. * * @param {LoadingManager} [manager] - The loading manager. */ constructor(e) { super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) { return new T2(t); }), this.register(function(t) { return new C2(t); }), this.register(function(t) { return new U2(t); }), this.register(function(t) { return new B2(t); }), this.register(function(t) { return new O2(t); }), this.register(function(t) { return new P2(t); }), this.register(function(t) { return new R2(t); }), this.register(function(t) { return new L2(t); }), this.register(function(t) { return new D2(t); }), this.register(function(t) { return new E2(t); }), this.register(function(t) { return new I2(t); }), this.register(function(t) { return new A2(t); }), this.register(function(t) { return new k2(t); }), this.register(function(t) { return new N2(t); }), this.register(function(t) { return new S2(t); }), this.register(function(t) { return new F2(t); }), this.register(function(t) { return new z2(t); }); } /** * Starts loading from the given URL and passes the loaded glTF asset * to the `onLoad()` callback. * * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI. * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished. * @param {onProgressCallback} onProgress - Executed while the loading is in progress. * @param {onErrorCallback} onError - Executed when errors occur. */ load(e, t, n, i) { const r = this; let a; if (this.resourcePath !== "") a = this.resourcePath; else if (this.path !== "") { const c = tr.extractUrlBase(e); a = tr.resolveURL(c, this.path); } else a = tr.extractUrlBase(e); this.manager.itemStart(e); const o = function(c) { i ? i(c) : console.error(c), r.manager.itemError(e), r.manager.itemEnd(e); }, l = new wa(this.manager); l.setPath(this.path), l.setResponseType("arraybuffer"), l.setRequestHeader(this.requestHeader), l.setWithCredentials(this.withCredentials), l.load(e, function(c) { try { r.parse(c, a, function(h) { t(h), r.manager.itemEnd(e); }, o); } catch (h) { o(h); } }, n, o); } /** * Sets the given Draco loader to this loader. Required for decoding assets * compressed with the `KHR_draco_mesh_compression` extension. * * @param {DRACOLoader} dracoLoader - The Draco loader to set. * @return {GLTFLoader} A reference to this loader. */ setDRACOLoader(e) { return this.dracoLoader = e, this; } /** * Sets the given KTX2 loader to this loader. Required for loading KTX2 * compressed textures. * * @param {KTX2Loader} ktx2Loader - The KTX2 loader to set. * @return {GLTFLoader} A reference to this loader. */ setKTX2Loader(e) { return this.ktx2Loader = e, this; } /** * Sets the given meshopt decoder. Required for decoding assets * compressed with the `EXT_meshopt_compression` extension. * * @param {Object} meshoptDecoder - The meshopt decoder to set. * @return {GLTFLoader} A reference to this loader. */ setMeshoptDecoder(e) { return this.meshoptDecoder = e, this; } /** * Registers a plugin callback. This API is internally used to implement the various * glTF extensions but can also used by third-party code to add additional logic * to the loader. * * @param {function(parser:GLTFParser)} callback - The callback function to register. * @return {GLTFLoader} A reference to this loader. */ register(e) { return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this; } /** * Unregisters a plugin callback. * * @param {Function} callback - The callback function to unregister. * @return {GLTFLoader} A reference to this loader. */ unregister(e) { return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this; } /** * Parses the given FBX data and returns the resulting group. * * @param {string|ArrayBuffer} data - The raw glTF data. * @param {string} path - The URL base path. * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished. * @param {onErrorCallback} onError - Executed when errors occur. */ parse(e, t, n, i) { let r; const a = {}, o = {}, l = new TextDecoder(); if (typeof e == "string") r = JSON.parse(e); else if (e instanceof ArrayBuffer) if (l.decode(new Uint8Array(e, 0, 4)) === af) { try { a[tt.KHR_BINARY_GLTF] = new H2(e); } catch (h) { i && i(h); return; } r = JSON.parse(a[tt.KHR_BINARY_GLTF].content); } else r = JSON.parse(l.decode(e)); else r = e; if (r.asset === void 0 || r.asset.version[0] < 2) { i && i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")); return; } const c = new ey(r, { path: t || this.resourcePath || "", crossOrigin: this.crossOrigin, requestHeader: this.requestHeader, manager: this.manager, ktx2Loader: this.ktx2Loader, meshoptDecoder: this.meshoptDecoder }); c.fileLoader.setRequestHeader(this.requestHeader); for (let h = 0; h < this.pluginCallbacks.length; h++) { const 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 (r.extensionsUsed) for (let h = 0; h < r.extensionsUsed.length; ++h) { const u = r.extensionsUsed[h], f = r.extensionsRequired || []; switch (u) { case tt.KHR_MATERIALS_UNLIT: a[u] = new w2(); break; case tt.KHR_DRACO_MESH_COMPRESSION: a[u] = new V2(r, this.dracoLoader); break; case tt.KHR_TEXTURE_TRANSFORM: a[u] = new G2(); break; case tt.KHR_MESH_QUANTIZATION: a[u] = new W2(); break; default: f.indexOf(u) >= 0 && o[u] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + u + '".'); } } c.setExtensions(a), c.setPlugins(o), c.parse(n, i); } /** * Async version of {@link GLTFLoader#parse}. * * @async * @param {string|ArrayBuffer} data - The raw glTF data. * @param {string} path - The URL base path. * @return {Promise} A Promise that resolves with the loaded glTF when the parsing has been finished. */ parseAsync(e, t) { const n = this; return new Promise(function(i, r) { n.parse(e, t, i, r); }); } } function M2() { 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 tt = { 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 S2 { constructor(e) { this.parser = e, this.name = tt.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} }; } _markDefs() { const e = this.parser, t = this.parser.json.nodes || []; for (let n = 0, i = t.length; n < i; n++) { const r = t[n]; r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light); } } _loadLight(e) { const t = this.parser, n = "light:" + e; let i = t.cache.get(n); if (i) return i; const r = t.json, a = ((r.extensions && r.extensions[this.name] || {}).lights || [])[e]; let o; const l = new Fe(16777215); a.color !== void 0 && l.setRGB(a.color[0], a.color[1], a.color[2], Tt); const c = a.range !== void 0 ? a.range : 0; switch (a.type) { case "directional": o = new os(l), o.target.position.set(0, 0, -1), o.add(o.target); break; case "point": o = new i0(l), o.distance = c; break; case "spot": o = new t0(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), On(o, a), a.intensity !== void 0 && (o.intensity = a.intensity), o.name = t.createUniqueName(a.name || "light_" + e), i = Promise.resolve(o), t.cache.add(n, i), i; } getDependency(e, t) { if (e === "light") return this._loadLight(t); } createNodeAttachment(e) { const t = this, n = this.parser, i = n.json.nodes[e], r = (i.extensions && i.extensions[this.name] || {}).light; return r === void 0 ? null : this._loadLight(r).then(function(a) { return n._getNodeRef(t.cache, r, a); }); } } class w2 { constructor() { this.name = tt.KHR_MATERIALS_UNLIT; } getMaterialType() { return Nt; } extendParams(e, t, n) { const i = []; e.color = new Fe(1, 1, 1), e.opacity = 1; const r = t.pbrMetallicRoughness; if (r) { if (Array.isArray(r.baseColorFactor)) { const a = r.baseColorFactor; e.color.setRGB(a[0], a[1], a[2], Tt), e.opacity = a[3]; } r.baseColorTexture !== void 0 && i.push(n.assignTexture(e, "map", r.baseColorTexture, mt)); } return Promise.all(i); } } class E2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_EMISSIVE_STRENGTH; } extendMaterialParams(e, t) { const n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = n.extensions[this.name].emissiveStrength; return i !== void 0 && (t.emissiveIntensity = i), Promise.resolve(); } } class T2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_CLEARCOAT; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); const r = [], a = i.extensions[this.name]; if (a.clearcoatFactor !== void 0 && (t.clearcoat = a.clearcoatFactor), a.clearcoatTexture !== void 0 && r.push(n.assignTexture(t, "clearcoatMap", a.clearcoatTexture)), a.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = a.clearcoatRoughnessFactor), a.clearcoatRoughnessTexture !== void 0 && r.push(n.assignTexture(t, "clearcoatRoughnessMap", a.clearcoatRoughnessTexture)), a.clearcoatNormalTexture !== void 0 && (r.push(n.assignTexture(t, "clearcoatNormalMap", a.clearcoatNormalTexture)), a.clearcoatNormalTexture.scale !== void 0)) { const o = a.clearcoatNormalTexture.scale; t.clearcoatNormalScale = new ue(o, o); } return Promise.all(r); } } class C2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_DISPERSION; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = n.extensions[this.name]; return t.dispersion = i.dispersion !== void 0 ? i.dispersion : 0, Promise.resolve(); } } class A2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_IRIDESCENCE; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); const r = [], a = i.extensions[this.name]; return a.iridescenceFactor !== void 0 && (t.iridescence = a.iridescenceFactor), a.iridescenceTexture !== void 0 && r.push(n.assignTexture(t, "iridescenceMap", a.iridescenceTexture)), a.iridescenceIor !== void 0 && (t.iridescenceIOR = a.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), a.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = a.iridescenceThicknessMinimum), a.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = a.iridescenceThicknessMaximum), a.iridescenceThicknessTexture !== void 0 && r.push(n.assignTexture(t, "iridescenceThicknessMap", a.iridescenceThicknessTexture)), Promise.all(r); } } class P2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_SHEEN; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); const r = []; t.sheenColor = new Fe(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1; const a = i.extensions[this.name]; if (a.sheenColorFactor !== void 0) { const o = a.sheenColorFactor; t.sheenColor.setRGB(o[0], o[1], o[2], Tt); } return a.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = a.sheenRoughnessFactor), a.sheenColorTexture !== void 0 && r.push(n.assignTexture(t, "sheenColorMap", a.sheenColorTexture, mt)), a.sheenRoughnessTexture !== void 0 && r.push(n.assignTexture(t, "sheenRoughnessMap", a.sheenRoughnessTexture)), Promise.all(r); } } class R2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_TRANSMISSION; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); const r = [], a = i.extensions[this.name]; return a.transmissionFactor !== void 0 && (t.transmission = a.transmissionFactor), a.transmissionTexture !== void 0 && r.push(n.assignTexture(t, "transmissionMap", a.transmissionTexture)), Promise.all(r); } } class L2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_VOLUME; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); const r = [], a = i.extensions[this.name]; t.thickness = a.thicknessFactor !== void 0 ? a.thicknessFactor : 0, a.thicknessTexture !== void 0 && r.push(n.assignTexture(t, "thicknessMap", a.thicknessTexture)), t.attenuationDistance = a.attenuationDistance || 1 / 0; const o = a.attenuationColor || [1, 1, 1]; return t.attenuationColor = new Fe().setRGB(o[0], o[1], o[2], Tt), Promise.all(r); } } class D2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_IOR; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = n.extensions[this.name]; return t.ior = i.ior !== void 0 ? i.ior : 1.5, Promise.resolve(); } } class I2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_SPECULAR; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); const r = [], a = i.extensions[this.name]; t.specularIntensity = a.specularFactor !== void 0 ? a.specularFactor : 1, a.specularTexture !== void 0 && r.push(n.assignTexture(t, "specularIntensityMap", a.specularTexture)); const o = a.specularColorFactor || [1, 1, 1]; return t.specularColor = new Fe().setRGB(o[0], o[1], o[2], Tt), a.specularColorTexture !== void 0 && r.push(n.assignTexture(t, "specularColorMap", a.specularColorTexture, mt)), Promise.all(r); } } class N2 { constructor(e) { this.parser = e, this.name = tt.EXT_MATERIALS_BUMP; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); const r = [], a = i.extensions[this.name]; return t.bumpScale = a.bumpFactor !== void 0 ? a.bumpFactor : 1, a.bumpTexture !== void 0 && r.push(n.assignTexture(t, "bumpMap", a.bumpTexture)), Promise.all(r); } } class k2 { constructor(e) { this.parser = e, this.name = tt.KHR_MATERIALS_ANISOTROPY; } getMaterialType(e) { const t = this.parser.json.materials[e]; return !t.extensions || !t.extensions[this.name] ? null : In; } extendMaterialParams(e, t) { const n = this.parser, i = n.json.materials[e]; if (!i.extensions || !i.extensions[this.name]) return Promise.resolve(); const r = [], a = i.extensions[this.name]; return a.anisotropyStrength !== void 0 && (t.anisotropy = a.anisotropyStrength), a.anisotropyRotation !== void 0 && (t.anisotropyRotation = a.anisotropyRotation), a.anisotropyTexture !== void 0 && r.push(n.assignTexture(t, "anisotropyMap", a.anisotropyTexture)), Promise.all(r); } } class U2 { constructor(e) { this.parser = e, this.name = tt.KHR_TEXTURE_BASISU; } loadTexture(e) { const t = this.parser, n = t.json, i = n.textures[e]; if (!i.extensions || !i.extensions[this.name]) return null; const r = i.extensions[this.name], a = t.options.ktx2Loader; if (!a) { if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0) throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures"); return null; } return t.loadTextureImage(e, r.source, a); } } class B2 { constructor(e) { this.parser = e, this.name = tt.EXT_TEXTURE_WEBP; } loadTexture(e) { const t = this.name, n = this.parser, i = n.json, r = i.textures[e]; if (!r.extensions || !r.extensions[t]) return null; const a = r.extensions[t], o = i.images[a.source]; let l = n.textureLoader; if (o.uri) { const c = n.options.manager.getHandler(o.uri); c !== null && (l = c); } return n.loadTextureImage(e, a.source, l); } } class O2 { constructor(e) { this.parser = e, this.name = tt.EXT_TEXTURE_AVIF; } loadTexture(e) { const t = this.name, n = this.parser, i = n.json, r = i.textures[e]; if (!r.extensions || !r.extensions[t]) return null; const a = r.extensions[t], o = i.images[a.source]; let l = n.textureLoader; if (o.uri) { const c = n.options.manager.getHandler(o.uri); c !== null && (l = c); } return n.loadTextureImage(e, a.source, l); } } class F2 { constructor(e) { this.name = tt.EXT_MESHOPT_COMPRESSION, this.parser = e; } loadBufferView(e) { const t = this.parser.json, n = t.bufferViews[e]; if (n.extensions && n.extensions[this.name]) { const i = n.extensions[this.name], r = this.parser.getDependency("buffer", i.buffer), a = this.parser.options.meshoptDecoder; if (!a || !a.supported) { if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0) throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files"); return null; } return r.then(function(o) { const l = i.byteOffset || 0, c = i.byteLength || 0, h = i.count, u = i.byteStride, f = new Uint8Array(o, l, c); return a.decodeGltfBufferAsync ? a.decodeGltfBufferAsync(h, u, f, i.mode, i.filter).then(function(d) { return d.buffer; }) : a.ready.then(function() { const d = new ArrayBuffer(h * u); return a.decodeGltfBuffer(new Uint8Array(d), h, u, f, i.mode, i.filter), d; }); }); } else return null; } } class z2 { constructor(e) { this.name = tt.EXT_MESH_GPU_INSTANCING, this.parser = e; } createNodeMesh(e) { const t = this.parser.json, n = t.nodes[e]; if (!n.extensions || !n.extensions[this.name] || n.mesh === void 0) return null; const i = t.meshes[n.mesh]; for (const l of i.primitives) if (l.mode !== bn.TRIANGLES && l.mode !== bn.TRIANGLE_STRIP && l.mode !== bn.TRIANGLE_FAN && l.mode !== void 0) return null; const r = n.extensions[this.name].attributes, a = [], o = {}; for (const l in r) a.push(this.parser.getDependency("accessor", r[l]).then((c) => (o[l] = c, o[l]))); return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((l) => { const c = l.pop(), h = c.isGroup ? c.children : [c], u = l[0].count, f = []; for (const d of h) { const p = new je(), g = new R(), x = new Dn(), m = new R(1, 1, 1), v = new oc(d.geometry, d.material, u); for (let b = 0; b < u; b++) o.TRANSLATION && g.fromBufferAttribute(o.TRANSLATION, b), o.ROTATION && x.fromBufferAttribute(o.ROTATION, b), o.SCALE && m.fromBufferAttribute(o.SCALE, b), v.setMatrixAt(b, p.compose(g, x, m)); for (const b in o) if (b === "_COLOR_0") { const M = o[b]; v.instanceColor = new Rl(M.array, M.itemSize, M.normalized); } else b !== "TRANSLATION" && b !== "ROTATION" && b !== "SCALE" && d.geometry.setAttribute(b, o[b]); Mt.prototype.copy.call(v, d), this.parser.assignFinalMaterial(v), f.push(v); } return c.isGroup ? (c.clear(), c.add(...f), c) : f[0]; })); } } const af = "glTF", Ws = 12, Mu = { JSON: 1313821514, BIN: 5130562 }; class H2 { constructor(e) { this.name = tt.KHR_BINARY_GLTF, this.content = null, this.body = null; const t = new DataView(e, 0, Ws), n = new TextDecoder(); if (this.header = { magic: n.decode(new Uint8Array(e.slice(0, 4))), version: t.getUint32(4, !0), length: t.getUint32(8, !0) }, this.header.magic !== af) throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header."); if (this.header.version < 2) throw new Error("THREE.GLTFLoader: Legacy binary file detected."); const i = this.header.length - Ws, r = new DataView(e, Ws); let a = 0; for (; a < i; ) { const o = r.getUint32(a, !0); a += 4; const l = r.getUint32(a, !0); if (a += 4, l === Mu.JSON) { const c = new Uint8Array(e, Ws + a, o); this.content = n.decode(c); } else if (l === Mu.BIN) { const c = Ws + a; this.body = e.slice(c, c + o); } a += o; } if (this.content === null) throw new Error("THREE.GLTFLoader: JSON content not found."); } } class V2 { constructor(e, t) { if (!t) throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided."); this.name = tt.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload(); } decodePrimitive(e, t) { const n = this.json, i = this.dracoLoader, r = e.extensions[this.name].bufferView, a = e.extensions[this.name].attributes, o = {}, l = {}, c = {}; for (const h in a) { const u = Hl[h] || h.toLowerCase(); o[u] = a[h]; } for (const h in e.attributes) { const u = Hl[h] || h.toLowerCase(); if (a[h] !== void 0) { const f = n.accessors[e.attributes[h]], d = us[f.componentType]; c[u] = d.name, l[u] = f.normalized === !0; } } return t.getDependency("bufferView", r).then(function(h) { return new Promise(function(u, f) { i.decodeDracoFile(h, function(d) { for (const p in d.attributes) { const g = d.attributes[p], x = l[p]; x !== void 0 && (g.normalized = x); } u(d); }, o, c, Tt, f); }); }); } } class G2 { constructor() { this.name = tt.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 W2 { constructor() { this.name = tt.KHR_MESH_QUANTIZATION; } } class of extends mr { constructor(e, t, n, i) { super(e, t, n, i); } copySampleValue_(e) { const t = this.resultBuffer, n = this.sampleValues, i = this.valueSize, r = e * i * 3 + i; for (let a = 0; a !== i; a++) t[a] = n[r + a]; return t; } interpolate_(e, t, n, i) { const r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, l = o * 2, c = o * 3, h = i - t, u = (n - t) / h, f = u * u, d = f * u, p = e * c, g = p - c, x = -2 * d + 3 * f, m = d - f, v = 1 - x, b = m - f + u; for (let M = 0; M !== o; M++) { const C = a[g + M + o], T = a[g + M + l] * h, D = a[p + M + o], U = a[p + M] * h; r[M] = v * C + b * T + x * D + m * U; } return r; } } const X2 = new Dn(); class j2 extends of { interpolate_(e, t, n, i) { const r = super.interpolate_(e, t, n, i); return X2.fromArray(r).normalize().toArray(r), r; } } const bn = { POINTS: 0, LINES: 1, LINE_LOOP: 2, LINE_STRIP: 3, TRIANGLES: 4, TRIANGLE_STRIP: 5, TRIANGLE_FAN: 6 }, us = { 5120: Int8Array, 5121: Uint8Array, 5122: Int16Array, 5123: Uint16Array, 5125: Uint32Array, 5126: Float32Array }, Su = { 9728: Gt, 9729: Ht, 9984: Gu, 9985: la, 9986: js, 9987: ti }, wu = { 33071: Hn, 33648: va, 10497: Gn }, No = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 }, Hl = { 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" }, fi = { scale: "scale", translation: "position", rotation: "quaternion", weights: "morphTargetInfluences" }, Z2 = { CUBICSPLINE: void 0, // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each // keyframe track will be initialized with a default interpolation type, then modified. LINEAR: ar, STEP: rr }, ko = { OPAQUE: "OPAQUE", MASK: "MASK", BLEND: "BLEND" }; function q2(s) { return s.DefaultMaterial === void 0 && (s.DefaultMaterial = new Cs({ color: 16777215, emissive: 0, metalness: 1, roughness: 1, transparent: !1, depthTest: !0, side: Rn })), s.DefaultMaterial; } function Ei(s, e, t) { for (const n in t.extensions) s[n] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[n] = t.extensions[n]); } function On(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 Y2(s, e, t) { let n = !1, i = !1, r = !1; for (let c = 0, h = e.length; c < h; c++) { const u = e[c]; if (u.POSITION !== void 0 && (n = !0), u.NORMAL !== void 0 && (i = !0), u.COLOR_0 !== void 0 && (r = !0), n && i && r) break; } if (!n && !i && !r) return Promise.resolve(s); const a = [], o = [], l = []; for (let c = 0, h = e.length; c < h; c++) { const u = e[c]; if (n) { const f = u.POSITION !== void 0 ? t.getDependency("accessor", u.POSITION) : s.attributes.position; a.push(f); } if (i) { const f = u.NORMAL !== void 0 ? t.getDependency("accessor", u.NORMAL) : s.attributes.normal; o.push(f); } if (r) { const f = u.COLOR_0 !== void 0 ? t.getDependency("accessor", u.COLOR_0) : s.attributes.color; l.push(f); } } return Promise.all([ Promise.all(a), Promise.all(o), Promise.all(l) ]).then(function(c) { const h = c[0], u = c[1], f = c[2]; return n && (s.morphAttributes.position = h), i && (s.morphAttributes.normal = u), r && (s.morphAttributes.color = f), s.morphTargetsRelative = !0, s; }); } function K2(s, e) { if (s.updateMorphTargets(), e.weights !== void 0) for (let t = 0, n = e.weights.length; t < n; t++) s.morphTargetInfluences[t] = e.weights[t]; if (e.extras && Array.isArray(e.extras.targetNames)) { const t = e.extras.targetNames; if (s.morphTargetInfluences.length === t.length) { s.morphTargetDictionary = {}; for (let n = 0, i = t.length; n < i; n++) s.morphTargetDictionary[t[n]] = n; } else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names."); } } function $2(s) { let e; const t = s.extensions && s.extensions[tt.KHR_DRACO_MESH_COMPRESSION]; if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + Uo(t.attributes) : e = s.indices + ":" + Uo(s.attributes) + ":" + s.mode, s.targets !== void 0) for (let n = 0, i = s.targets.length; n < i; n++) e += ":" + Uo(s.targets[n]); return e; } function Uo(s) { let e = ""; const t = Object.keys(s).sort(); for (let n = 0, i = t.length; n < i; n++) e += t[n] + ":" + s[t[n]] + ";"; return e; } function Vl(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 J2(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 Q2 = new je(); class ey { constructor(e = {}, t = {}) { this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new M2(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {}; let n = !1, i = -1, r = !1, a = -1; if (typeof navigator < "u") { const o = navigator.userAgent; n = /^((?!chrome|android).)*safari/i.test(o) === !0; const l = o.match(/Version\/(\d+)/); i = n && l ? parseInt(l[1], 10) : -1, r = o.indexOf("Firefox") > -1, a = r ? o.match(/Firefox\/([0-9]+)\./)[1] : -1; } typeof createImageBitmap > "u" || n && i < 17 || r && a < 98 ? this.textureLoader = new wd(this.options.manager) : this.textureLoader = new r0(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new wa(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0); } setExtensions(e) { this.extensions = e; } setPlugins(e) { this.plugins = e; } parse(e, t) { const n = this, i = this.json, r = this.extensions; this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(a) { return a._markDefs && a._markDefs(); }), Promise.all(this._invokeAll(function(a) { return a.beforeRoot && a.beforeRoot(); })).then(function() { return Promise.all([ n.getDependencies("scene"), n.getDependencies("animation"), n.getDependencies("camera") ]); }).then(function(a) { const o = { scene: a[0][i.scene || 0], scenes: a[0], animations: a[1], cameras: a[2], asset: i.asset, parser: n, userData: {} }; return Ei(r, o, i), On(o, i), Promise.all(n._invokeAll(function(l) { return l.afterRoot && l.afterRoot(o); })).then(function() { for (const l of o.scenes) l.updateMatrixWorld(); e(o); }); }).catch(t); } /** * Marks the special nodes/meshes in json for efficient parse. * * @private */ _markDefs() { const e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || []; for (let i = 0, r = t.length; i < r; i++) { const a = t[i].joints; for (let o = 0, l = a.length; o < l; o++) e[a[o]].isBone = !0; } for (let i = 0, r = e.length; i < r; i++) { const a = e[i]; a.mesh !== void 0 && (this._addNodeRef(this.meshCache, a.mesh), a.skin !== void 0 && (n[a.mesh].isSkinnedMesh = !0)), a.camera !== void 0 && this._addNodeRef(this.cameraCache, a.camera); } } /** * Counts references to shared node / Object3D resources. These resources * can be reused, or "instantiated", at multiple nodes in the scene * hierarchy. Mesh, Camera, and Light instances are instantiated and must * be marked. Non-scenegraph resources (like Materials, Geometries, and * Textures) can be reused directly and are not marked here. * * Example: CesiumMilkTruck sample model reuses "Wheel" meshes. * * @private * @param {Object} cache * @param {Object3D} index */ _addNodeRef(e, t) { t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++); } /** * Returns a reference to a shared resource, cloning it if necessary. * * @private * @param {Object} cache * @param {number} index * @param {Object} object * @return {Object} */ _getNodeRef(e, t, n) { if (e.refs[t] <= 1) return n; const i = n.clone(), r = (a, o) => { const l = this.associations.get(a); l != null && this.associations.set(o, l); for (const [c, h] of a.children.entries()) r(h, o.children[c]); }; return r(n, i), i.name += "_instance_" + e.uses[t]++, i; } _invokeOne(e) { const t = Object.values(this.plugins); t.push(this); for (let n = 0; n < t.length; n++) { const i = e(t[n]); if (i) return i; } return null; } _invokeAll(e) { const t = Object.values(this.plugins); t.unshift(this); const n = []; for (let i = 0; i < t.length; i++) { const r = e(t[i]); r && n.push(r); } return n; } /** * Requests the specified dependency asynchronously, with caching. * * @private * @param {string} type * @param {number} index * @return {Promise} */ getDependency(e, t) { const n = e + ":" + t; let i = this.cache.get(n); if (!i) { switch (e) { case "scene": i = this.loadScene(t); break; case "node": i = this._invokeOne(function(r) { return r.loadNode && r.loadNode(t); }); break; case "mesh": i = this._invokeOne(function(r) { return r.loadMesh && r.loadMesh(t); }); break; case "accessor": i = this.loadAccessor(t); break; case "bufferView": i = this._invokeOne(function(r) { return r.loadBufferView && r.loadBufferView(t); }); break; case "buffer": i = this.loadBuffer(t); break; case "material": i = this._invokeOne(function(r) { return r.loadMaterial && r.loadMaterial(t); }); break; case "texture": i = this._invokeOne(function(r) { return r.loadTexture && r.loadTexture(t); }); break; case "skin": i = this.loadSkin(t); break; case "animation": i = this._invokeOne(function(r) { return r.loadAnimation && r.loadAnimation(t); }); break; case "camera": i = this.loadCamera(t); break; default: if (i = this._invokeOne(function(r) { return r != this && r.getDependency && r.getDependency(e, t); }), !i) throw new Error("Unknown type: " + e); break; } this.cache.add(n, i); } return i; } /** * Requests all dependencies of the specified type asynchronously, with caching. * * @private * @param {string} type * @return {Promise>} */ getDependencies(e) { let t = this.cache.get(e); if (!t) { const n = this, i = this.json[e + (e === "mesh" ? "es" : "s")] || []; t = Promise.all(i.map(function(r, a) { return n.getDependency(e, a); })), this.cache.add(e, t); } return t; } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views * * @private * @param {number} bufferIndex * @return {Promise} */ loadBuffer(e) { const t = this.json.buffers[e], n = this.fileLoader; if (t.type && t.type !== "arraybuffer") throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported."); if (t.uri === void 0 && e === 0) return Promise.resolve(this.extensions[tt.KHR_BINARY_GLTF].body); const i = this.options; return new Promise(function(r, a) { n.load(tr.resolveURL(t.uri, i.path), r, void 0, function() { a(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".')); }); }); } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views * * @private * @param {number} bufferViewIndex * @return {Promise} */ loadBufferView(e) { const t = this.json.bufferViews[e]; return this.getDependency("buffer", t.buffer).then(function(n) { const i = t.byteLength || 0, r = t.byteOffset || 0; return n.slice(r, r + i); }); } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors * * @private * @param {number} accessorIndex * @return {Promise} */ loadAccessor(e) { const t = this, n = this.json, i = this.json.accessors[e]; if (i.bufferView === void 0 && i.sparse === void 0) { const a = No[i.type], o = us[i.componentType], l = i.normalized === !0, c = new o(i.count * a); return Promise.resolve(new gt(c, a, l)); } const r = []; return i.bufferView !== void 0 ? r.push(this.getDependency("bufferView", i.bufferView)) : r.push(null), i.sparse !== void 0 && (r.push(this.getDependency("bufferView", i.sparse.indices.bufferView)), r.push(this.getDependency("bufferView", i.sparse.values.bufferView))), Promise.all(r).then(function(a) { const o = a[0], l = No[i.type], c = us[i.componentType], h = c.BYTES_PER_ELEMENT, u = h * l, f = i.byteOffset || 0, d = i.bufferView !== void 0 ? n.bufferViews[i.bufferView].byteStride : void 0, p = i.normalized === !0; let g, x; if (d && d !== u) { const m = Math.floor(f / d), v = "InterleavedBuffer:" + i.bufferView + ":" + i.componentType + ":" + m + ":" + i.count; let b = t.cache.get(v); b || (g = new c(o, m * d, i.count * d / h), b = new od(g, d / h), t.cache.add(v, b)), x = new Pa(b, l, f % d / h, p); } else o === null ? g = new c(i.count * l) : g = new c(o, f, i.count * l), x = new gt(g, l, p); if (i.sparse !== void 0) { const m = No.SCALAR, v = us[i.sparse.indices.componentType], b = i.sparse.indices.byteOffset || 0, M = i.sparse.values.byteOffset || 0, C = new v(a[1], b, i.sparse.count * m), T = new c(a[2], M, i.sparse.count * l); o !== null && (x = new gt(x.array.slice(), x.itemSize, x.normalized)), x.normalized = !1; for (let D = 0, U = C.length; D < U; D++) { const S = C[D]; if (x.setX(S, T[D * l]), l >= 2 && x.setY(S, T[D * l + 1]), l >= 3 && x.setZ(S, T[D * l + 2]), l >= 4 && x.setW(S, T[D * l + 3]), l >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute."); } x.normalized = p; } return x; }); } /** * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures * * @private * @param {number} textureIndex * @return {Promise} */ loadTexture(e) { const t = this.json, n = this.options, i = t.textures[e].source, r = t.images[i]; let a = this.textureLoader; if (r.uri) { const o = n.manager.getHandler(r.uri); o !== null && (a = o); } return this.loadTextureImage(e, i, a); } loadTextureImage(e, t, n) { const i = this, r = this.json, a = r.textures[e], o = r.images[t], l = (o.uri || o.bufferView) + ":" + a.sampler; if (this.textureCache[l]) return this.textureCache[l]; const c = this.loadImageSource(t, n).then(function(h) { h.flipY = !1, h.name = a.name || o.name || "", h.name === "" && typeof o.uri == "string" && o.uri.startsWith("data:image/") === !1 && (h.name = o.uri); const u = (r.samplers || {})[a.sampler] || {}; return h.magFilter = Su[u.magFilter] || Ht, h.minFilter = Su[u.minFilter] || ti, h.wrapS = wu[u.wrapS] || Gn, h.wrapT = wu[u.wrapT] || Gn, h.generateMipmaps = !h.isCompressedTexture && h.minFilter !== Gt && h.minFilter !== Ht, i.associations.set(h, { textures: e }), h; }).catch(function() { return null; }); return this.textureCache[l] = c, c; } loadImageSource(e, t) { const n = this, i = this.json, r = this.options; if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((u) => u.clone()); const a = i.images[e], o = self.URL || self.webkitURL; let l = a.uri || "", c = !1; if (a.bufferView !== void 0) l = n.getDependency("bufferView", a.bufferView).then(function(u) { c = !0; const f = new Blob([u], { type: a.mimeType }); return l = o.createObjectURL(f), 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(f, d) { let p = f; t.isImageBitmapLoader === !0 && (p = function(g) { const x = new Ft(g); x.needsUpdate = !0, f(x); }), t.load(tr.resolveURL(u, r.path), p, void 0, d); }); }).then(function(u) { return c === !0 && o.revokeObjectURL(l), On(u, a), u.userData.mimeType = a.mimeType || J2(a.uri), u; }).catch(function(u) { throw console.error("THREE.GLTFLoader: Couldn't load texture", l), u; }); return this.sourceCache[e] = h, h; } /** * Asynchronously assigns a texture to the given material parameters. * * @private * @param {Object} materialParams * @param {string} mapName * @param {Object} mapDef * @param {string} [colorSpace] * @return {Promise} */ assignTexture(e, t, n, i) { const r = this; return this.getDependency("texture", n.index).then(function(a) { if (!a) return null; if (n.texCoord !== void 0 && n.texCoord > 0 && (a = a.clone(), a.channel = n.texCoord), r.extensions[tt.KHR_TEXTURE_TRANSFORM]) { const o = n.extensions !== void 0 ? n.extensions[tt.KHR_TEXTURE_TRANSFORM] : void 0; if (o) { const l = r.associations.get(a); a = r.extensions[tt.KHR_TEXTURE_TRANSFORM].extendTexture(a, o), r.associations.set(a, l); } } return i !== void 0 && (a.colorSpace = i), e[t] = a, a; }); } /** * Assigns final material to a Mesh, Line, or Points instance. The instance * already has a material (generated from the glTF material options alone) * but reuse of the same glTF material may require multiple threejs materials * to accommodate different primitive types, defines, etc. New materials will * be created if necessary, and reused from a cache. * * @private * @param {Object3D} mesh Mesh, Line, or Points instance. */ assignFinalMaterial(e) { const t = e.geometry; let n = e.material; const i = t.attributes.tangent === void 0, r = t.attributes.color !== void 0, a = t.attributes.normal === void 0; if (e.isPoints) { const o = "PointsMaterial:" + n.uuid; let l = this.cache.get(o); l || (l = new hd(), mn.prototype.copy.call(l, n), l.color.copy(n.color), l.map = n.map, l.sizeAttenuation = !1, this.cache.add(o, l)), n = l; } else if (e.isLine) { const o = "LineBasicMaterial:" + n.uuid; let l = this.cache.get(o); l || (l = new Bi(), mn.prototype.copy.call(l, n), l.color.copy(n.color), l.map = n.map, this.cache.add(o, l)), n = l; } if (i || r || a) { let o = "ClonedMaterial:" + n.uuid + ":"; i && (o += "derivative-tangents:"), r && (o += "vertex-colors:"), a && (o += "flat-shading:"); let l = this.cache.get(o); l || (l = n.clone(), r && (l.vertexColors = !0), a && (l.flatShading = !0), i && (l.normalScale && (l.normalScale.y *= -1), l.clearcoatNormalScale && (l.clearcoatNormalScale.y *= -1)), this.cache.add(o, l), this.associations.set(l, this.associations.get(n))), n = l; } e.material = n; } getMaterialType() { return Cs; } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials * * @private * @param {number} materialIndex * @return {Promise} */ loadMaterial(e) { const t = this, n = this.json, i = this.extensions, r = n.materials[e]; let a; const o = {}, l = r.extensions || {}, c = []; if (l[tt.KHR_MATERIALS_UNLIT]) { const u = i[tt.KHR_MATERIALS_UNLIT]; a = u.getMaterialType(), c.push(u.extendParams(o, r, t)); } else { const u = r.pbrMetallicRoughness || {}; if (o.color = new Fe(1, 1, 1), o.opacity = 1, Array.isArray(u.baseColorFactor)) { const f = u.baseColorFactor; o.color.setRGB(f[0], f[1], f[2], Tt), o.opacity = f[3]; } u.baseColorTexture !== void 0 && c.push(t.assignTexture(o, "map", u.baseColorTexture, mt)), 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(f) { return f.getMaterialType && f.getMaterialType(e); }), c.push(Promise.all(this._invokeAll(function(f) { return f.extendMaterialParams && f.extendMaterialParams(e, o); }))); } r.doubleSided === !0 && (o.side = Dt); const h = r.alphaMode || ko.OPAQUE; if (h === ko.BLEND ? (o.transparent = !0, o.depthWrite = !1) : (o.transparent = !1, h === ko.MASK && (o.alphaTest = r.alphaCutoff !== void 0 ? r.alphaCutoff : 0.5)), r.normalTexture !== void 0 && a !== Nt && (c.push(t.assignTexture(o, "normalMap", r.normalTexture)), o.normalScale = new ue(1, 1), r.normalTexture.scale !== void 0)) { const u = r.normalTexture.scale; o.normalScale.set(u, u); } if (r.occlusionTexture !== void 0 && a !== Nt && (c.push(t.assignTexture(o, "aoMap", r.occlusionTexture)), r.occlusionTexture.strength !== void 0 && (o.aoMapIntensity = r.occlusionTexture.strength)), r.emissiveFactor !== void 0 && a !== Nt) { const u = r.emissiveFactor; o.emissive = new Fe().setRGB(u[0], u[1], u[2], Tt); } return r.emissiveTexture !== void 0 && a !== Nt && c.push(t.assignTexture(o, "emissiveMap", r.emissiveTexture, mt)), Promise.all(c).then(function() { const u = new a(o); return r.name && (u.name = r.name), On(u, r), t.associations.set(u, { materials: e }), r.extensions && Ei(i, u, r), u; }); } /** * When Object3D instances are targeted by animation, they need unique names. * * @private * @param {string} originalName * @return {string} */ createUniqueName(e) { const t = ct.sanitizeNodeName(e || ""); return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t); } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry * * Creates BufferGeometries from primitives. * * @private * @param {Array} primitives * @return {Promise>} */ loadGeometries(e) { const t = this, n = this.extensions, i = this.primitiveCache; function r(o) { return n[tt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o, t).then(function(l) { return Eu(l, o, t); }); } const a = []; for (let o = 0, l = e.length; o < l; o++) { const c = e[o], h = $2(c), u = i[h]; if (u) a.push(u.promise); else { let f; c.extensions && c.extensions[tt.KHR_DRACO_MESH_COMPRESSION] ? f = r(c) : f = Eu(new xt(), c, t), i[h] = { primitive: c, promise: f }, a.push(f); } } return Promise.all(a); } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes * * @private * @param {number} meshIndex * @return {Promise} */ loadMesh(e) { const t = this, n = this.json, i = this.extensions, r = n.meshes[e], a = r.primitives, o = []; for (let l = 0, c = a.length; l < c; l++) { const h = a[l].material === void 0 ? q2(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 d = 0, p = h.length; d < p; d++) { const g = h[d], x = a[d]; let m; const v = c[d]; if (x.mode === bn.TRIANGLES || x.mode === bn.TRIANGLE_STRIP || x.mode === bn.TRIANGLE_FAN || x.mode === void 0) m = r.isSkinnedMesh === !0 ? new Yp(g, v) : new ft(g, v), m.isSkinnedMesh === !0 && m.normalizeSkinWeights(), x.mode === bn.TRIANGLE_STRIP ? m.geometry = yu(m.geometry, Ku) : x.mode === bn.TRIANGLE_FAN && (m.geometry = yu(m.geometry, Cl)); else if (x.mode === bn.LINES) m = new cd(g, v); else if (x.mode === bn.LINE_STRIP) m = new Oi(g, v); else if (x.mode === bn.LINE_LOOP) m = new tm(g, v); else if (x.mode === bn.POINTS) m = new nm(g, v); else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + x.mode); Object.keys(m.geometry.morphAttributes).length > 0 && K2(m, r), m.name = t.createUniqueName(r.name || "mesh_" + e), On(m, r), x.extensions && Ei(i, m, x), t.assignFinalMaterial(m), u.push(m); } for (let d = 0, p = u.length; d < p; d++) t.associations.set(u[d], { meshes: e, primitives: d }); if (u.length === 1) return r.extensions && Ei(i, u[0], r), u[0]; const f = new $t(); r.extensions && Ei(i, f, r), t.associations.set(f, { meshes: e }); for (let d = 0, p = u.length; d < p; d++) f.add(u[d]); return f; }); } /** * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras * * @private * @param {number} cameraIndex * @return {Promise|undefined} */ loadCamera(e) { let t; const n = this.json.cameras[e], i = n[n.type]; if (!i) { console.warn("THREE.GLTFLoader: Missing camera parameters."); return; } return n.type === "perspective" ? t = new jt(Js.radToDeg(i.yfov), i.aspectRatio || 1, i.znear || 1, i.zfar || 2e6) : n.type === "orthographic" && (t = new zi(-i.xmag, i.xmag, i.ymag, -i.ymag, i.znear, i.zfar)), n.name && (t.name = this.createUniqueName(n.name)), On(t, n), Promise.resolve(t); } /** * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins * * @private * @param {number} skinIndex * @return {Promise} */ loadSkin(e) { const t = this.json.skins[e], n = []; for (let i = 0, r = t.joints.length; i < r; i++) n.push(this._loadNodeShallow(t.joints[i])); return t.inverseBindMatrices !== void 0 ? n.push(this.getDependency("accessor", t.inverseBindMatrices)) : n.push(null), Promise.all(n).then(function(i) { const r = i.pop(), a = i, o = [], l = []; for (let c = 0, h = a.length; c < h; c++) { const u = a[c]; if (u) { o.push(u); const f = new je(); r !== null && f.fromArray(r.array, c * 16), l.push(f); } else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[c]); } return new ac(o, l); }); } /** * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations * * @private * @param {number} animationIndex * @return {Promise} */ loadAnimation(e) { const t = this.json, n = this, i = t.animations[e], r = i.name ? i.name : "animation_" + e, a = [], o = [], l = [], c = [], h = []; for (let u = 0, f = i.channels.length; u < f; u++) { const d = i.channels[u], p = i.samplers[d.sampler], g = d.target, x = g.node, m = i.parameters !== void 0 ? i.parameters[p.input] : p.input, v = i.parameters !== void 0 ? i.parameters[p.output] : p.output; g.node !== void 0 && (a.push(this.getDependency("node", x)), o.push(this.getDependency("accessor", m)), l.push(this.getDependency("accessor", v)), c.push(p), h.push(g)); } return Promise.all([ Promise.all(a), Promise.all(o), Promise.all(l), Promise.all(c), Promise.all(h) ]).then(function(u) { const f = u[0], d = u[1], p = u[2], g = u[3], x = u[4], m = []; for (let b = 0, M = f.length; b < M; b++) { const C = f[b], T = d[b], D = p[b], U = g[b], S = x[b]; if (C === void 0) continue; C.updateMatrix && C.updateMatrix(); const w = n._createAnimationTracks(C, T, D, U, S); if (w) for (let B = 0; B < w.length; B++) m.push(w[B]); } const v = new Zm(r, void 0, m); return On(v, i), v; }); } createNodeMesh(e) { const t = this.json, n = this, i = t.nodes[e]; return i.mesh === void 0 ? null : n.getDependency("mesh", i.mesh).then(function(r) { const a = n._getNodeRef(n.meshCache, i.mesh, r); return i.weights !== void 0 && a.traverse(function(o) { if (o.isMesh) for (let l = 0, c = i.weights.length; l < c; l++) o.morphTargetInfluences[l] = i.weights[l]; }), a; }); } /** * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy * * @private * @param {number} nodeIndex * @return {Promise} */ loadNode(e) { const t = this.json, n = this, i = t.nodes[e], r = n._loadNodeShallow(e), a = [], o = i.children || []; for (let c = 0, h = o.length; c < h; c++) a.push(n.getDependency("node", o[c])); const l = i.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", i.skin); return Promise.all([ r, Promise.all(a), l ]).then(function(c) { const h = c[0], u = c[1], f = c[2]; f !== null && h.traverse(function(d) { d.isSkinnedMesh && d.bind(f, Q2); }); for (let d = 0, p = u.length; d < p; d++) h.add(u[d]); return h; }); } // ._loadNodeShallow() parses a single node. // skin and child nodes are created and added in .loadNode() (no '_' prefix). _loadNodeShallow(e) { const t = this.json, n = this.extensions, i = this; if (this.nodeCache[e] !== void 0) return this.nodeCache[e]; const r = t.nodes[e], a = r.name ? i.createUniqueName(r.name) : "", o = [], l = i._invokeOne(function(c) { return c.createNodeMesh && c.createNodeMesh(e); }); return l && o.push(l), r.camera !== void 0 && o.push(i.getDependency("camera", r.camera).then(function(c) { return i._getNodeRef(i.cameraCache, r.camera, c); })), i._invokeAll(function(c) { return c.createNodeAttachment && c.createNodeAttachment(e); }).forEach(function(c) { o.push(c); }), this.nodeCache[e] = Promise.all(o).then(function(c) { let h; if (r.isBone === !0 ? h = new ld() : c.length > 1 ? h = new $t() : c.length === 1 ? h = c[0] : h = new Mt(), h !== c[0]) for (let u = 0, f = c.length; u < f; u++) h.add(c[u]); if (r.name && (h.userData.name = r.name, h.name = a), On(h, r), r.extensions && Ei(n, h, r), r.matrix !== void 0) { const u = new je(); u.fromArray(r.matrix), h.applyMatrix4(u); } else r.translation !== void 0 && h.position.fromArray(r.translation), r.rotation !== void 0 && h.quaternion.fromArray(r.rotation), r.scale !== void 0 && h.scale.fromArray(r.scale); if (!i.associations.has(h)) i.associations.set(h, {}); else if (r.mesh !== void 0 && i.meshCache.refs[r.mesh] > 1) { const u = i.associations.get(h); i.associations.set(h, { ...u }); } return i.associations.get(h).nodes = e, h; }), this.nodeCache[e]; } /** * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes * * @private * @param {number} sceneIndex * @return {Promise} */ loadScene(e) { const t = this.extensions, n = this.json.scenes[e], i = this, r = new $t(); n.name && (r.name = i.createUniqueName(n.name)), On(r, n), n.extensions && Ei(t, r, n); const a = n.nodes || [], o = []; for (let l = 0, c = a.length; l < c; l++) o.push(i.getDependency("node", a[l])); return Promise.all(o).then(function(l) { for (let h = 0, u = l.length; h < u; h++) r.add(l[h]); const c = (h) => { const u = /* @__PURE__ */ new Map(); for (const [f, d] of i.associations) (f instanceof mn || f instanceof Ft) && u.set(f, d); return h.traverse((f) => { const d = i.associations.get(f); d != null && u.set(f, d); }), u; }; return i.associations = c(r), r; }); } _createAnimationTracks(e, t, n, i, r) { const a = [], o = e.name ? e.name : e.uuid, l = []; fi[r.path] === fi.weights ? e.traverse(function(f) { f.morphTargetInfluences && l.push(f.name ? f.name : f.uuid); }) : l.push(o); let c; switch (fi[r.path]) { case fi.weights: c = ys; break; case fi.rotation: c = Ms; break; case fi.translation: case fi.scale: c = Ss; break; default: switch (n.itemSize) { case 1: c = ys; break; case 2: case 3: default: c = Ss; break; } break; } const h = i.interpolation !== void 0 ? Z2[i.interpolation] : ar, u = this._getArrayFromAccessor(n); for (let f = 0, d = l.length; f < d; f++) { const p = new c( l[f] + "." + fi[r.path], t.array, u, h ); i.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(p), a.push(p); } return a; } _getArrayFromAccessor(e) { let t = e.array; if (e.normalized) { const n = Vl(t.constructor), i = new Float32Array(t.length); for (let r = 0, a = t.length; r < a; r++) i[r] = t[r] * n; t = i; } return t; } _createCubicSplineTrackInterpolant(e) { e.createInterpolant = function(t) { const n = this instanceof Ms ? j2 : of; return new n(this.times, this.values, this.getValueSize() / 3, t); }, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0; } } function ty(s, e, t) { const n = e.attributes, i = new zt(); if (n.POSITION !== void 0) { const o = t.json.accessors[n.POSITION], l = o.min, c = o.max; if (l !== void 0 && c !== void 0) { if (i.set( new R(l[0], l[1], l[2]), new R(c[0], c[1], c[2]) ), o.normalized) { const h = Vl(us[o.componentType]); i.min.multiplyScalar(h), i.max.multiplyScalar(h); } } else { console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."); return; } } else return; const r = e.targets; if (r !== void 0) { const o = new R(), l = new R(); for (let c = 0, h = r.length; c < h; c++) { const u = r[c]; if (u.POSITION !== void 0) { const f = t.json.accessors[u.POSITION], d = f.min, p = f.max; if (d !== void 0 && p !== void 0) { if (l.setX(Math.max(Math.abs(d[0]), Math.abs(p[0]))), l.setY(Math.max(Math.abs(d[1]), Math.abs(p[1]))), l.setZ(Math.max(Math.abs(d[2]), Math.abs(p[2]))), f.normalized) { const g = Vl(us[f.componentType]); l.multiplyScalar(g); } o.max(l); } else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION."); } } i.expandByVector(o); } s.boundingBox = i; const a = new Xn(); i.getCenter(a.center), a.radius = i.min.distanceTo(i.max) / 2, s.boundingSphere = a; } function Eu(s, e, t) { const n = e.attributes, i = []; function r(a, o) { return t.getDependency("accessor", a).then(function(l) { s.setAttribute(o, l); }); } for (const a in n) { const o = Hl[a] || a.toLowerCase(); o in s.attributes || i.push(r(n[a], o)); } if (e.indices !== void 0 && !s.index) { const a = t.getDependency("accessor", e.indices).then(function(o) { s.setIndex(o); }); i.push(a); } return it.workingColorSpace !== Tt && "COLOR_0" in n && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${it.workingColorSpace}" not supported.`), On(s, e), ty(s, e, t), Promise.all(i).then(function() { return e.targets !== void 0 ? Y2(s, e.targets, t) : s; }); } function ny(s, e, t) { let n = new $t(); n.name = e, s.scene.add(n), rf(e + "/info.zip?v=" + Date.now(), (i) => { let r = JSON.parse(i); s.engineStatus.models.push({ type: "light", info: r, name: r.baseInfo.name, status: "loading", url: e, elements: /* @__PURE__ */ new Map() }), s.models == null && (s.models = []), s.models.push({ url: e, nodesMap: /* @__PURE__ */ new Map(), boundingBox: { min: new R(r.baseInfo.min.X * 0.3048, r.baseInfo.min.Z * 0.3048, -r.baseInfo.min.Y * 0.3048), max: new R(r.baseInfo.max.X * 0.3048, r.baseInfo.max.Z * 0.3048, -r.baseInfo.max.Y * 0.3048) } }), s.events.trigger(dr.EngineFree, null); }); } function iy(s) { s.engineStatus.models.forEach((e) => { e.loadStatus == null && (e.loadStatus = { mep: !1, instance: !1, normal: !1 }), e.status === "loading" && e.type === "light" && (e.loadStatus.modelMep != !0 && (e.loadStatus.modelMep = !0, b2(s, e.info.modelMep, e.url)), e.loadStatus.normal != !0 && sy(s, e)); }); } function sy(s, e) { if (s.camera.position, e.size, e.info == null || e.info.lods == null) return; e.info.lods.forEach((n) => { if (n.status != !0) if (n.glbs == null) console.log("加载GLB............."), n.glbs = {}, g2(e.url + n.path + "/nodes.json?v=" + Date.now(), (i) => { let r = JSON.parse(i), a = /* @__PURE__ */ new Map(); s.models.find((l) => l.url == e.url).nodesMap = a; let o = 0; for (let l in r) { r[l].forEach((u) => { u.glb = l, a.has(u.id) == !1 ? a.set(u.id, { infos: [u] }) : a.get(u.id).infos.push(u); }); let c = new y2(); const h = new x2(); h.setDecoderPath("/static/js/draco/"), h.preload(), c.setDRACOLoader(h), c.load(e.url + n.path + l + ".glb", (u) => { n.glbs[l] = u.scene.children, o++, o == Object.keys(r).length && s.engineStatus.isFree && (s.events.trigger(dr.EngineFree, null), s.viewCube.CameraGoHome()); }); } }); else { console.log("加载模型............."); let i = t(e, n, n.octreeBox), r = [], a = s.models.find((o) => o.url == e.url); i.forEach((o) => { a.nodesMap.has(o) && a.nodesMap.get(o).infos.forEach((l) => { let c = n.glbs[l.glb][l.mesh]; if (c != null && c.geometry != null && c.material != null) { let h = new je(); h.elements = l.matrix; let u = new ft(c.geometry.clone().applyMatrix4(h), c.material), f = new zt().setFromObject(u); l.box = f, l.mesh = u, u.name = o, u.glb = l.glb, u.url = e.url, r.push(u); } }); }), console.log("加载模型数量", r.length), ry(e.url, s, r); } }); function t(n, i, r) { let a = []; if (r.status != !0) { if (!s.engineStatus.isFree) return a; let o = new R(r.min.X, r.min.Z, -r.min.Y), l = new R(r.max.X, r.max.Z, -r.max.Y); l.distanceTo(o); let c = s.camera.position, h = new R(o.x + l.x / 2, o.y + l.y / 2, o.z + l.z / 2); c.distanceTo(h), r.elements.forEach((u) => { a.push(u); }), r.children.forEach((u) => { a.push(...t(n, i, u)); }), r.children.findIndex((u) => u.status != !0) == -1 && (r.status = !0), r.children.length == 0 && (r.status = !0); } return a; } } function ry(s, e, t) { let n = []; t.forEach((i) => { n.findIndex((a) => a.glb == i.glb) == -1 ? n.push({ glb: i.glb, meshes: [i], currentIndex: i.geometry.index.count, indexes: /* @__PURE__ */ new Map() }) : (n.find((a) => a.glb == i.glb).meshes.push(i), n.find((a) => a.glb == i.glb).currentIndex += i.geometry.index.count); let r = n.find((a) => a.glb == i.glb); r.indexes.set(Number(i.name), [r.currentIndex - i.geometry.index.count, r.currentIndex]); }), n.forEach((i) => { let r = e.scene.children.find((a) => a instanceof ft && a.url == s && a.glb == i.glb); if (r != null) r.castShadow = !0, r.receiveShadow = !0; else { let a = new xt(); i.meshes.map((c) => c.material), a = _2(i.meshes.map((c) => c.geometry), !0); let o = new ft(a, i.meshes.map((c) => c.material)); o.castShadow = !0, o.receiveShadow = !0, e.scene.add(o), o.index = e.scene.children.length - 1, o.url = s, o.glb = i.glb, o.indexes = i.indexes, o.materialClone = i.meshes[0].material; let l = e.models.find((c) => c.url == s); if (l != null) { let c = 0; i.indexes.forEach((h) => { l.nodesMap.get(Number(i.meshes[c].name)).indexes == null && (l.nodesMap.get(Number(i.meshes[c].name)).indexes = []), l.nodesMap.get(Number(i.meshes[c].name)).indexes.push([o.index, c++, h[0], h[1]]); }); } o.material instanceof Array ? o.material.forEach((c) => { Tu(c); }) : Tu(o.material); } }); } function Tu(s) { s.shadowSide = Rn, s.roughness = 0.6, s.metalness = 0, s.side = Dt, s.map != null && (s.map.colorSpace = mt, s.map.needsUpdate = !0, console.log("优化贴图")), s instanceof Cs && (s.map && (s.map.colorSpace = mt, s.map.needsUpdate = !0), s.emissiveMap && (s.emissiveMap.colorSpace = mt, s.emissiveMap.needsUpdate = !0), s.roughnessMap && (s.roughnessMap.colorSpace = Tt, s.roughnessMap.needsUpdate = !0), s.metalnessMap && (s.metalnessMap.colorSpace = Tt, s.metalnessMap.needsUpdate = !0), s.normalMap && (s.normalMap.colorSpace = Tt, s.normalMap.needsUpdate = !0), s.aoMap && (s.aoMap.colorSpace = Tt, s.aoMap.needsUpdate = !0), s.roughness = Math.max(0.1, Math.min(1, s.roughness)), s.metalness = Math.max(0, Math.min(1, s.metalness)), s.envMapIntensity = s.envMapIntensity || 1, s.needsUpdate = !0), s instanceof In && (this.optimizeMaterial(s), s.transmissionMap && (s.transmissionMap.colorSpace = Tt, s.transmissionMap.needsUpdate = !0), s.thicknessMap && (s.thicknessMap.colorSpace = Tt, s.thicknessMap.needsUpdate = !0), s.transmission = Math.max(0, Math.min(1, s.transmission)), s.thickness = Math.max(0, Math.min(10, s.thickness))), s instanceof Nt && s.map && (s.map.colorSpace = mt, s.map.needsUpdate = !0), s instanceof yd && (s.map && (s.map.colorSpace = mt, s.map.needsUpdate = !0), s.emissiveMap && (s.emissiveMap.colorSpace = mt, s.emissiveMap.needsUpdate = !0)); } class ay { engine; constructor(e) { this.engine = e; } // 加载多个模型 async loadModels(e, t) { for (const i of e) n(i) === "light" && ny(this.engine, i); function n(i) { const r = i.split(".").pop(); return r === "glb" || r === "gltf" ? "gltf" : "light"; } } } class oy { engine; isFree; highlightModels; hideModels; models; constructor(e) { this.engine = e, this.isFree = !0, this.highlightModels = [], this.hideModels = [], this.models = []; } init() { this.engine.events.on(dr.EngineFree, () => { this.updateFree(!0), console.log("引擎空闲"), iy(this.engine); }), this.engine.events.on(dr.EngineBusy, () => { this.updateFree(!1), console.log("引擎繁忙"); }); } // 更新引擎空闲状态 updateFree(e) { this.isFree = e; } // 关闭所有功能 closeAllFunction = () => { }; } class ly { listeners = /* @__PURE__ */ 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 n = this.listeners.get(e), i = n.indexOf(t); i !== -1 && n.splice(i, 1); } trigger(e, t) { this.listeners.has(e) && this.listeners.get(e).forEach((n) => { try { n(t); } catch (i) { console.error(`Error in event listener for ${e}:`, i); } }); } } class cy { engine; constructor(e) { this.engine = e; } // 加入场景基本光照 init() { const e = new os(16777215, 2); e.position.set(10, 20, 10), e.castShadow = !0, e.shadow.mapSize.width = 4096, e.shadow.mapSize.height = 4096, e.shadow.camera.near = 0.1, e.shadow.camera.far = 500, e.shadow.bias = -5e-5, e.shadow.normalBias = 0.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, this.engine.scene.add(e); const n = new Ea(16777215, 1); this.engine.scene.add(n); } } var si = /* @__PURE__ */ ((s) => (s.ModelLoadStart = "model-load-start", s.ModelLoadProgress = "model-load-progress", s.ModelLoaded = "model-loaded", s.ModelError = "model-error", s.SelectionChanged = "selection-changed", s.HoverChanged = "hover-changed", s.Click = "click", s.MouseMove = "mouse-move", s.CameraChanged = "camera-changed", s.CameraIdle = "camera-idle", s.EngineFree = "engine-free", s.EngineBusy = "engine-busy", s.MeasureChanged = "measure-changed", s))(si || {}); class hy { engine; behavior; isCtrlDown = !1; constructor(e) { this.engine = e; } init() { this.behavior = this.engine.handelBehaved, this.behavior.init(this); } active() { this.behavior.active(); } disActive() { this.behavior.disActive(); } // 键盘事件 handelKeyCtrlUp() { this.isCtrlDown = !1; } handelKeyCtrlDown() { this.isCtrlDown = !0; } // 业务功能-监听鼠标谈起,点选模型 handleMouseClick(e) { if (e.catch) { const t = e.catch; t.object, this.engine.events.trigger(si.Click, t); let n = t.object; this.isCtrlDown || this.engine.modelToolModule.unhighlightAllModels(), console.log([{ url: n.url, ids: [n.name] }]), this.engine.modelToolModule.highlightModel([{ url: n.url, ids: [n.name] }]); } else this.engine.modelToolModule.unhighlightAllModels(); } // 双击模型事件 handleMouseDoubleClick(e) { if (e.catch) { const n = e.catch; n.object, this.engine.events.trigger(si.Click, n); let i = n.object, r = this.engine.models.find((o) => o.url === i.url).nodesMap.get(i.name).infos.map((o) => o.box), a = t(r); this.engine.viewCube.zoomToModel(a); } function t(n) { let i = new R(1e8, 1e9, 1e10), r = new R(-1e8, -1e9, -1e10); return n.forEach((a) => { a.min.x < i.x && (i.x = a.min.x), a.min.y < i.y && (i.y = a.min.y), a.min.z < i.z && (i.z = a.min.z), a.max.x > r.x && (r.x = a.max.x), a.max.y > r.y && (r.y = a.max.y), a.max.z > r.z && (r.z = a.max.z); }), new zt(i, r); } } } class uy { engine; highlightMaterial; hideMaterial; constructor(e) { this.engine = e, this.highlightMaterial = new Nt({ color: 43775, // 明显的蓝色 depthTest: !1, // 不进行深度测试,始终显示 depthWrite: !1, // 不写入深度缓冲 transparent: !0, opacity: 0.5, // 半透明效果 side: Dt // 双面渲染 }), this.hideMaterial = new Nt({ color: 0, // 明显的蓝色 depthTest: !1, // 不进行深度测试,始终显示 depthWrite: !1, // 不写入深度缓冲 transparent: !0, opacity: 0, // 半透明效果 side: Dt // 双面渲染 }); } // 设置模型高亮 highlightModel(e) { e.forEach((t) => { t.ids.forEach((n) => { this.engine.models.find((i) => i.url == t.url).nodesMap.get(n).indexes.forEach((i) => { Cu(this.engine.scene.children[i[0]]), this.engine.scene.children[i[0]].material[i[1]] = this.highlightMaterial; }); }), this.engine.engineStatus.highlightModels.push(t); }); } // 取消模型高亮 unhighlightModel(e) { e.forEach((t) => { t.ids.forEach((n) => { this.engine.models.find((i) => i.url == t.url).nodesMap.get(n).indexes.forEach((i) => { this.engine.scene.children[i[0]].material[i[1]] = this.engine.scene.children[i[0]].materialClone; }); }); }); } // 取消所有模型高亮 unhighlightAllModels() { this.engine.engineStatus.highlightModels.forEach((e) => { this.unhighlightModel([e]); }), this.engine.engineStatus.highlightModels = []; } // 隐藏模型 hideModel(e) { e.forEach((t) => { t.ids.forEach((i) => { let r = this.engine.models.find((a) => a.url == t.url).nodesMap.get(i); this.engine.modelEdge.hideModelEdge(t.url, i), r.indexes.forEach((a) => { Cu(this.engine.scene.children[a[0]]), this.engine.scene.children[a[0]].material[a[1]] = this.hideMaterial; }); }); let n = this.engine.engineStatus.hideModels.find((i) => i.url == t.url); n != null ? n.ids.push(...t.ids) : this.engine.engineStatus.hideModels.push({ url: t.url, ids: t.ids }), this.engine.engineStatus.highlightModels = []; }); } // 显示模型 showModel(e) { e.forEach((t) => { t.ids.forEach((n) => { let i = this.engine.models.find((r) => r.url == t.url).nodesMap.get(n); this.engine.modelEdge.showModelEdge(t.url, n), i.indexes.forEach((r) => { this.engine.scene.children[r[0]].material[r[1]] = this.engine.scene.children[r[0]].materialClone; }); }), this.engine.engineStatus.hideModels.push(t); }); } // 隔离模型 - 只显示传入的模型,隐藏其他所有模型 isolateModel(e) { const t = []; this.engine.models.forEach((i) => { const r = Array.from(i.nodesMap.keys()); t.push({ url: i.url, ids: r }); }); const n = []; t.forEach((i) => { const r = e.find((a) => a.url === i.url); if (r) { const a = i.ids.filter((o) => !r.ids.includes(o)); a.length > 0 && n.push({ url: i.url, ids: a }); } else n.push(i); }), n.length > 0 && this.hideModel(n); } // 显示所有模型 showAllModels() { } // 设置模型颜色 setModelColor(e, t) { e.material.color.set(t); } // 设置所有模型颜色 setAllModelsColor(e) { this.engine.scene.children.forEach((t) => { t.isMesh; }); } // 恢复所有模型颜色 restoreAllModelsColor() { this.engine.scene.children.forEach((e) => { e.isMesh; }); } // 获取当前选中模型的box包围盒 getModelsBox(e) { new zt(); let t = []; return e.forEach((i) => { let r = this.engine.models.find((a) => a.url == i.url); i.ids.forEach((a) => { r.nodesMap.get(a).infos.forEach((o) => { t.push(o.box); }); }); }), n(t); function n(i) { let r = new R(1e8, 1e9, 1e10), a = new R(-1e8, -1e9, -1e10); return i.forEach((o) => { o.min.x < r.x && (r.x = o.min.x), o.min.y < r.y && (r.y = o.min.y), o.min.z < r.z && (r.z = o.min.z), o.max.x > a.x && (a.x = o.max.x), o.max.y > a.y && (a.y = o.max.y), o.max.z > a.z && (a.z = o.max.z); }), new zt(r, a); } } // 获取模型的精准位置描述,给大模型用的,主要是 getModelDescription(e) { } } function Cu(s) { (s.isSplit == null || s.isSplit == null || s.isSplit == !1) && (s.isSplit = !0); } function lf(s) { const e = { self: null, // 当前激活的行为对象 options: null, // 行为配置选项 mouseDownTime: 0, // 鼠标按下时的时间戳 lastClickTime: 0 // 上次点击时间 }; e.init = function(u, f) { e.self != null && e.self.disActive != null && e.self.disActive(), e.self = u, e.options = f; }, e.render = function() { e.self && e.self.render != null && e.self.render(); }, e.active = function() { s.container.addEventListener("mousedown", o), s.container.addEventListener("mouseup", c), s.container.addEventListener("mousemove", l), window.addEventListener("keydown", t), window.addEventListener("keyup", n); }, e.disActive = function() { s.container.removeEventListener("mousedown", o), s.container.removeEventListener("mouseup", c), s.container.removeEventListener("mousemove", l), window.removeEventListener("keydown", t), window.removeEventListener("keyup", n); }; function t(u) { (u.keyCode === 8 || u.keyCode === 46) && e.self && e.self.handelKeyDeleteDown != null && e.self.handelKeyDeleteDown(), u.keyCode === 27 && e.self && e.self.handelKeyEscDown != null && e.self.handelKeyEscDown(), u.keyCode === 13 && e.self && e.self.handelKeyEnterDown != null && e.self.handelKeyEnterDown(), u.keyCode === 32 && e.self && e.self.handelKeySpaceDown != null && e.self.handelKeySpaceDown(), u.key === "Control" && e.self && e.self.handelKeyCtrlDown != null && e.self.handelKeyCtrlDown(), u.key === "Delete" && e.self && e.self.handelKeyDeleteDown != null && e.self.handelKeyDeleteDown(), u.key === "Shift" && e.self && e.self.handelKeyShiftDown != null && e.self.handelKeyShiftDown(), u.key === "Meta" && e.self && e.self.handelKeyMetaDown != null && e.self.handelKeyMetaDown(); } function n(u) { u.key === "Alt" && e.self && e.self.handelKeyAltUp != null && e.self.handelKeyAltUp(), u.key === "Tab" && e.self && e.self.handelKeyTabUp != null && e.self.handelKeyTabUp(), u.key === "Control" && e.self && e.self.handelKeyCtrlUp != null && e.self.handelKeyCtrlUp(), u.key === "Shift" && e.self && e.self.handelKeyShiftUp != null && e.self.handelKeyShiftUp(), u.key === "Meta" && e.self && e.self.handelKeyMetaUp != null && e.self.handelKeyMetaUp(), u.key === "Command" && e.self && e.self.handelKeyCommandUp != null && e.self.handelKeyCommandUp(), u.key === "Windows" && e.self && e.self.handelKeyWindowsUp != null && e.self.handelKeyWindowsUp(); } function i(u) { const f = new ue(), d = s.renderer.domElement.clientWidth, p = s.renderer.domElement.clientHeight; return f.x = u.clientX / d * 2 - 1, f.y = -(u.clientY / p) * 2 + 1, f; } function r(u) { const f = new Ni(), d = i(u); return f.setFromCamera(d, s.camera), f; } function a(u, f = !1) { const d = r(u); if (u.raycaster = d, f) { const p = h(d, u); u.catch = p; } } function o(u) { u.button === 0 && (e.mouseDownTime = Date.now(), e.self && e.self.handleMouseDown != null && (a(u, !0), e.self.handleMouseDown(u))); } function l(u) { e.self && e.self.handleMouseMove != null && (a(u, !0), e.self.handleMouseMove(u)); } function c(u) { if (u.button !== 0) return; const f = Date.now(), d = f - e.mouseDownTime; if (e.self && e.self.handleMouseUp != null && (a(u, !1), e.self.handleMouseUp(u)), d < 100 && e.self && e.self.handleMouseClick != null) { a(u, !0); const p = f - e.lastClickTime; console.log(p), p < 200 ? e.self.handleMouseDoubleClick(u) : e.self.handleMouseClick(u), e.lastClickTime = Date.now(); } } function h(u, f) { s.catchSvg.innerHTML = ""; const d = s.octreeBox.rayInterationModel(u); if (d.length === 0) return; let p = d[0].object.url, g = d[0].object.name, x = s.modelEdge.getModelEdge(p, g); x || (x = [0, 0, []]); let m = "face", v = [], b = [], M = 5; if (x[2].map((U) => U[0]).forEach((U) => { let S = new R(U.X, U.Z, -U.Y), w = s.worldToScreen.worldToScreen(S), B = Math.sqrt(Math.pow(w.x - f.clientX, 2) + Math.pow(w.y - f.clientY, 2)); B < M && (M = B, v.push({ point: S, distance: B, pointxy: w })); }), v.length > 0 ? (v.sort((U, S) => U.distance - S.distance), m = "point") : (x[2].forEach((U) => { let S = new R(U[0].X, U[0].Z, -U[0].Y), w = new R(U[1].X, U[1].Z, -U[1].Y), B = s.worldToScreen.worldToScreen(S), P = s.worldToScreen.worldToScreen(w), O = C(new ue(f.clientX, f.clientY), B, P); if (O < M) { let y = T(new ue(f.clientX, f.clientY), B, P), H = D(y, S, w); b.push({ distance: O, point: H, pointxy: s.worldToScreen.worldToScreen(H), start: B, end: P }); } }), b.length > 0 && (b.sort((U, S) => U.distance - S.distance), m = "line")), m == "point") { const U = s.worldToScreen.worldToScreen(v[0].point); console.log("捕捉点屏幕坐标:", U.x, U.y), console.log("Canvas尺寸:", s.renderer.domElement.width, s.renderer.domElement.height), console.log("SVG尺寸:", s.catchSvg.clientWidth, s.catchSvg.clientHeight), s.catchSvg.innerHTML = ""; const S = document.createElementNS("http://www.w3.org/2000/svg", "circle"); S.setAttribute("class", "catchPoint"), S.setAttribute("cx", U.x.toString()), S.setAttribute("cy", U.y.toString()), S.setAttribute("r", "5"), S.setAttribute("fill", "rgb(0, 255, 247)"), s.catchSvg.appendChild(S); } else if (m == "line") { const U = s.worldToScreen.worldToScreen(b[0].point), S = b[0].start, w = b[0].end; console.log("捕捉点屏幕坐标:", U.x, U.y), console.log("Canvas尺寸:", s.renderer.domElement.width, s.renderer.domElement.height), console.log("SVG尺寸:", s.catchSvg.clientWidth, s.catchSvg.clientHeight), s.catchSvg.innerHTML = ""; const B = document.createElementNS("http://www.w3.org/2000/svg", "line"); B.setAttribute("class", "catchLine"), B.setAttribute("x1", S.x.toString()), B.setAttribute("y1", S.y.toString()), B.setAttribute("x2", w.x.toString()), B.setAttribute("y2", w.y.toString()), B.setAttribute("stroke", "rgb(0, 255, 247)"), B.setAttribute("stroke-width", "2"), s.catchSvg.appendChild(B); } else if (m == "face") { let U = d[0].point.clone(), S = d[0].normal || (d[0].face ? d[0].face.normal : null); const w = (S ? S.clone() : new R(0, 0, 1)).normalize(), B = Math.abs(w.y) < 0.9 ? new R(0, 1, 0) : new R(1, 0, 0), P = new R().crossVectors(w, B).normalize(), O = new R().crossVectors(w, P).normalize(), y = 0.05, H = [ new R().copy(P).add(O).multiplyScalar(y), new R().copy(P).sub(O).multiplyScalar(y), new R().copy(P).multiplyScalar(-1).sub(O).multiplyScalar(y), new R().copy(P).multiplyScalar(-1).add(O).multiplyScalar(y) ].map((j) => new R().copy(U).add(j)).map((j) => s.worldToScreen.worldToScreen(j)); s.catchSvg.innerHTML = ""; const Y = document.createElementNS("http://www.w3.org/2000/svg", "polygon"); Y.setAttribute("class", "catchFace"), Y.setAttribute("points", H.map((j) => `${j.x},${j.y}`).join(" ")), Y.setAttribute("fill", "rgba(1, 238, 255, 0.2)"), Y.setAttribute("stroke", "rgb(0, 255, 247)"), Y.setAttribute("stroke-width", "1"), s.catchSvg.appendChild(Y); } return d[0]; function C(U, S, w) { const B = new ue().subVectors(w, S), P = B.lengthSq(); if (P < 1e-10) return U.distanceTo(S); const O = new ue().subVectors(U, S), y = Js.clamp(O.dot(B) / P, 0, 1), H = new ue().copy(B).multiplyScalar(y).add(S); return U.distanceTo(H); } function T(U, S, w) { const B = new ue().subVectors(w, S), P = B.lengthSq(); if (P < 1e-10) return 0; const O = new ue().subVectors(U, S); return Js.clamp(O.dot(B) / P, 0, 1); } function D(U, S, w) { const B = Js.clamp(U, 0, 1); return new R().lerpVectors(S, w, B); } } return e; } class vn { /** * 构造函数 * @param camera - Three.js 相机对象(用于投影计算) * @param renderer - Three.js 渲染器对象(用于获取画布尺寸) * @param scene - Three.js 场景对象(用于屏幕坐标转世界坐标时的射线检测,可选) */ constructor(e, t, n) { this.camera = e, this.renderer = t, this.scene = n, this.raycaster = new Ni(); } raycaster; /** * 将世界坐标转换为屏幕坐标(归一化坐标,范围 -1 到 1) * @param worldPos - 世界空间中的3D坐标点 * @returns 归一化的屏幕坐标,x 和 y 的范围都是 -1 到 1 * x: -1 表示屏幕左边缘,1 表示屏幕右边缘 * y: -1 表示屏幕下边缘,1 表示屏幕上边缘 */ worldToScreenNormalized(e) { const t = e.clone(); return t.project(this.camera), new ue(t.x, t.y); } /** * 将世界坐标转换为屏幕坐标(像素坐标) * @param worldPos - 世界空间中的3D坐标点 * @returns 屏幕像素坐标,x 和 y 表示在画布上的实际像素位置 * x: 0 表示屏幕左边缘,width 表示屏幕右边缘 * y: 0 表示屏幕上边缘,height 表示屏幕下边缘 */ worldToScreen(e) { const t = this.worldToScreenNormalized(e), n = this.renderer.domElement.width, i = this.renderer.domElement.height, r = (t.x + 1) * n / 2, a = (1 - t.y) * i / 2; return new ue(r, a); } /** * 将屏幕坐标(像素坐标)转换为归一化坐标 * @param screenX - 屏幕像素 X 坐标 * @param screenY - 屏幕像素 Y 坐标 * @returns 归一化的屏幕坐标,范围 -1 到 1 */ screenToNormalized(e, t) { const n = this.renderer.domElement.width, i = this.renderer.domElement.height, r = e / n * 2 - 1, a = -(t / i * 2 - 1); return new ue(r, a); } /** * 将屏幕坐标(像素坐标)转换为世界坐标 * 使用射线检测,返回与场景中第一个相交对象的世界坐标点 * @param screenX - 屏幕像素 X 坐标 * @param screenY - 屏幕像素 Y 坐标 * @param objects - 可选,指定要检测的对象数组。如果不提供且 scene 存在,则检测场景中的所有对象 * @returns 世界坐标点,如果没有相交则返回 null */ screenToWorld(e, t, n) { if (!this.scene && !n) return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"), null; const i = this.screenToNormalized(e, t); this.raycaster.setFromCamera(i, this.camera); const r = n || this.scene.children, a = this.raycaster.intersectObjects(r, !0); return a.length > 0 ? a[0].point : null; } /** * 将屏幕坐标(像素坐标)转换为世界坐标(指定深度) * 使用相机的逆投影,在指定的深度平面上计算世界坐标 * @param screenX - 屏幕像素 X 坐标 * @param screenY - 屏幕像素 Y 坐标 * @param depth - 深度值(距离相机的距离),默认为 0(相机近平面) * @returns 世界坐标点 */ screenToWorldWithDepth(e, t, n = 0) { const i = this.screenToNormalized(e, t), r = new R(i.x, i.y, n); return r.unproject(this.camera), r; } /** * 更新相机引用(当相机发生变化时调用) * @param camera - 新的相机对象 */ updateCamera(e) { this.camera = e; } /** * 更新渲染器引用(当渲染器发生变化时调用) * @param renderer - 新的渲染器对象 */ updateRenderer(e) { this.renderer = e; } /** * 更新场景引用(当场景发生变化时调用) * @param scene - 新的场景对象 */ updateScene(e) { this.scene = e; } } var Gl = { exports: {} }, dy = Gl.exports, Au; function fy() { return Au || (Au = 1, (function(s, e) { (function(t, n) { s.exports = n(); })(dy, function() { var t = function() { function n(d) { return a.appendChild(d.dom), d; } function i(d) { for (var p = 0; p < a.children.length; p++) a.children[p].style.display = p === d ? "block" : "none"; r = d; } var r = 0, a = document.createElement("div"); a.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", a.addEventListener("click", function(d) { d.preventDefault(), i(++r % a.children.length); }, !1); var o = (performance || Date).now(), l = o, c = 0, h = n(new t.Panel("FPS", "#0ff", "#002")), u = n(new t.Panel("MS", "#0f0", "#020")); if (self.performance && self.performance.memory) var f = n(new t.Panel("MB", "#f08", "#201")); return i(0), { REVISION: 16, dom: a, addPanel: n, showPanel: i, begin: function() { o = (performance || Date).now(); }, end: function() { c++; var d = (performance || Date).now(); if (u.update(d - o, 200), d > l + 1e3 && (h.update(1e3 * c / (d - l), 100), l = d, c = 0, f)) { var p = performance.memory; f.update(p.usedJSHeapSize / 1048576, p.jsHeapSizeLimit / 1048576); } return d; }, update: function() { o = this.end(); }, domElement: a, setMode: i }; }; return t.Panel = function(n, i, r) { var a = 1 / 0, o = 0, l = Math.round, c = l(window.devicePixelRatio || 1), h = 80 * c, u = 48 * c, f = 3 * c, d = 2 * c, p = 3 * c, g = 15 * c, x = 74 * c, m = 30 * c, v = document.createElement("canvas"); v.width = h, v.height = u, v.style.cssText = "width:80px;height:48px"; var b = v.getContext("2d"); return b.font = "bold " + 9 * c + "px Helvetica,Arial,sans-serif", b.textBaseline = "top", b.fillStyle = r, b.fillRect(0, 0, h, u), b.fillStyle = i, b.fillText(n, f, d), b.fillRect(p, g, x, m), b.fillStyle = r, b.globalAlpha = 0.9, b.fillRect(p, g, x, m), { dom: v, update: function(M, C) { a = Math.min(a, M), o = Math.max(o, M), b.fillStyle = r, b.globalAlpha = 1, b.fillRect(0, 0, h, g), b.fillStyle = i, b.fillText(l(M) + " " + n + " (" + l(a) + "-" + l(o) + ")", f, d), b.drawImage(v, p + c, g, x - c, m, p, g, x - c, m), b.fillRect(p + x - c, g, c, m), b.fillStyle = r, b.globalAlpha = 0.9, b.fillRect(p + x - c, g, c, l((1 - M / C) * m)); } }; }, t; }); })(Gl)), Gl.exports; } var py = fy(); const my = /* @__PURE__ */ Id(py); var ds = 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 ? 0.5 * s * s : -0.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 ? 0.5 * s * s * s : 0.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 ? 0.5 * s * s * s * s : -0.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 ? 0.5 * s * s * s * s * s : 0.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 0.5 * (1 - Math.sin(Math.PI * (0.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 ? 0.5 * Math.pow(1024, s - 1) : 0.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 ? -0.5 * (Math.sqrt(1 - s * s) - 1) : 0.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 - 0.1) * 5 * Math.PI) + 1; }, InOut: function(s) { return s === 0 ? 0 : s === 1 ? 1 : (s *= 2, s < 1 ? -0.5 * Math.pow(2, 10 * (s - 1)) * Math.sin((s - 1.1) * 5 * Math.PI) : 0.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 ? 0.5 * (s * s * ((e + 1) * s - e)) : 0.5 * ((s -= 2) * s * ((e + 1) * s + e) + 2); } }), Bounce: Object.freeze({ In: function(s) { return 1 - ds.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 + 0.75 : s < 2.5 / 2.75 ? 7.5625 * (s -= 2.25 / 2.75) * s + 0.9375 : 7.5625 * (s -= 2.625 / 2.75) * s + 0.984375; }, InOut: function(s) { return s < 0.5 ? ds.Bounce.In(s * 2) * 0.5 : ds.Bounce.Out(s * 2 - 1) * 0.5 + 0.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 < 0.5 ? Math.pow(e * 2, s) / 2 : (1 - Math.pow(2 - e * 2, s)) / 2 + 0.5; } }; } }), Ys = function() { return performance.now(); }, gy = ( /** @class */ (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 = Ys()), t === void 0 && (t = !1); var n = Object.keys(this._tweens); if (n.length === 0) return !1; for (; n.length > 0; ) { this._tweensAddedDuringUpdate = {}; for (var i = 0; i < n.length; i++) { var r = this._tweens[n[i]], a = !t; r && r.update(e, a) === !1 && !t && delete this._tweens[n[i]]; } n = Object.keys(this._tweensAddedDuringUpdate); } return !0; }, s; })() ), Wl = { Linear: function(s, e) { var t = s.length - 1, n = t * e, i = Math.floor(n), r = Wl.Utils.Linear; return e < 0 ? r(s[0], s[1], n) : e > 1 ? r(s[t], s[t - 1], t - n) : r(s[i], s[i + 1 > t ? t : i + 1], n - i); }, Utils: { Linear: function(s, e, t) { return (e - s) * t + s; } } }, cf = ( /** @class */ (function() { function s() { } return s.nextId = function() { return s._nextId++; }, s._nextId = 0, s; })() ), Xl = new gy(), xy = ( /** @class */ (function() { function s(e, t) { t === void 0 && (t = Xl), 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 = ds.Linear.None, this._interpolationFunction = Wl.Linear, this._chainedTweens = [], this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._id = cf.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 = Ys()), t === void 0 && (t = !1), this._isPlaying) return this; if (this._group && this._group.add(this), this._repeat = this._initialRepeat, this._reversed) { this._reversed = !1; for (var n in this._valuesStartRepeat) this._swapEndStartRepeatValues(n), this._valuesStart[n] = this._valuesStartRepeat[n]; } if (this._isPlaying = !0, this._isPaused = !1, this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._isChainStopped = !1, this._startTime = e, this._startTime += this._delayTime, !this._propertiesAreSetUp || t) { if (this._propertiesAreSetUp = !0, !this._isDynamic) { var i = {}; for (var r in this._valuesEnd) i[r] = this._valuesEnd[r]; this._valuesEnd = i; } this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, t); } return this; }, s.prototype.startFromCurrentValues = function(e) { return this.start(e, !0); }, s.prototype._setupProperties = function(e, t, n, i, r) { for (var a in n) { var o = e[a], l = Array.isArray(o), c = l ? "array" : typeof o, h = !l && Array.isArray(n[a]); if (!(c === "undefined" || c === "function")) { if (h) { var u = n[a]; if (u.length === 0) continue; for (var f = [o], d = 0, p = u.length; d < p; d += 1) { var g = this._handleRelativeValue(o, u[d]); if (isNaN(g)) { h = !1, console.warn("Found invalid interpolation list. Skipping."); break; } f.push(g); } h && (n[a] = f); } if ((c === "object" || l) && o && !h) { t[a] = l ? [] : {}; var x = o; for (var m in x) t[a][m] = x[m]; i[a] = l ? [] : {}; var u = n[a]; if (!this._isDynamic) { var v = {}; for (var m in u) v[m] = u[m]; n[a] = u = v; } this._setupProperties(x, t[a], u, i[a], r); } else (typeof t[a] > "u" || r) && (t[a] = o), l || (t[a] *= 1), h ? i[a] = n[a].slice().reverse() : i[a] = t[a] || 0; } } }, s.prototype.stop = function() { return this._isChainStopped || (this._isChainStopped = !0, this.stopChainedTweens()), this._isPlaying ? (this._group && this._group.remove(this), this._isPlaying = !1, this._isPaused = !1, this._onStopCallback && this._onStopCallback(this._object), this) : this; }, s.prototype.end = function() { return this._goToEnd = !0, this.update(1 / 0), this; }, s.prototype.pause = function(e) { return e === void 0 && (e = Ys()), 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 = Ys()), !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 = Xl), 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 = ds.Linear.None), this._easingFunction = e, this; }, s.prototype.interpolation = function(e) { return e === void 0 && (e = Wl.Linear), this._interpolationFunction = e, this; }, s.prototype.chain = function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t]; return this._chainedTweens = e, this; }, s.prototype.onStart = function(e) { return this._onStartCallback = e, this; }, s.prototype.onEveryStart = function(e) { return this._onEveryStartCallback = e, this; }, s.prototype.onUpdate = function(e) { return this._onUpdateCallback = e, this; }, s.prototype.onRepeat = function(e) { return this._onRepeatCallback = e, this; }, s.prototype.onComplete = function(e) { return this._onCompleteCallback = e, this; }, s.prototype.onStop = function(e) { return this._onStopCallback = e, this; }, s.prototype.update = function(e, t) { var n = this, i; if (e === void 0 && (e = Ys()), t === void 0 && (t = !0), this._isPaused) return !0; var r, a = this._startTime + this._duration; if (!this._goToEnd && !this._isPlaying) { if (e > a) return !1; t && this.start(e, !0); } if (this._goToEnd = !1, e < this._startTime) return !0; this._onStartCallbackFired === !1 && (this._onStartCallback && this._onStartCallback(this._object), this._onStartCallbackFired = !0), this._onEveryStartCallbackFired === !1 && (this._onEveryStartCallback && this._onEveryStartCallback(this._object), this._onEveryStartCallbackFired = !0); var o = e - this._startTime, l = this._duration + ((i = this._repeatDelayTime) !== null && i !== void 0 ? i : this._delayTime), c = this._duration + this._repeat * l, h = function() { if (n._duration === 0 || o > c) return 1; var x = Math.trunc(o / l), m = o - x * l, v = Math.min(m / n._duration, 1); return v === 0 && o === n._duration ? 1 : v; }, u = h(), f = this._easingFunction(u); if (this._updateProperties(this._object, this._valuesStart, this._valuesEnd, f), this._onUpdateCallback && this._onUpdateCallback(this._object, u), this._duration === 0 || o >= this._duration) if (this._repeat > 0) { var d = Math.min(Math.trunc((o - this._duration) / l) + 1, this._repeat); isFinite(this._repeat) && (this._repeat -= d); for (r in this._valuesStartRepeat) !this._yoyo && typeof this._valuesEnd[r] == "string" && (this._valuesStartRepeat[r] = // eslint-disable-next-line // @ts-ignore FIXME? this._valuesStartRepeat[r] + parseFloat(this._valuesEnd[r])), this._yoyo && this._swapEndStartRepeatValues(r), this._valuesStart[r] = this._valuesStartRepeat[r]; return this._yoyo && (this._reversed = !this._reversed), this._startTime += l * d, this._onRepeatCallback && this._onRepeatCallback(this._object), this._onEveryStartCallbackFired = !1, !0; } else { this._onCompleteCallback && this._onCompleteCallback(this._object); for (var p = 0, g = this._chainedTweens.length; p < g; p++) this._chainedTweens[p].start(this._startTime + this._duration, !1); return this._isPlaying = !1, !1; } return !0; }, s.prototype._updateProperties = function(e, t, n, i) { for (var r in n) if (t[r] !== void 0) { var a = t[r] || 0, o = n[r], l = Array.isArray(e[r]), c = Array.isArray(o), h = !l && c; h ? e[r] = this._interpolationFunction(o, i) : typeof o == "object" && o ? this._updateProperties(e[r], a, o, i) : (o = this._handleRelativeValue(a, o), typeof o == "number" && (e[r] = a + (o - a) * i)); } }, s.prototype._handleRelativeValue = function(e, t) { return typeof t != "string" ? t : t.charAt(0) === "+" || t.charAt(0) === "-" ? e + parseFloat(t) : parseFloat(t); }, s.prototype._swapEndStartRepeatValues = function(e) { var t = this._valuesStartRepeat[e], n = this._valuesEnd[e]; typeof n == "string" ? this._valuesStartRepeat[e] = this._valuesStartRepeat[e] + parseFloat(n) : this._valuesStartRepeat[e] = this._valuesEnd[e], this._valuesEnd[e] = t; }, s; })() ); cf.nextId; var Wn = Xl; Wn.getAll.bind(Wn); Wn.removeAll.bind(Wn); Wn.add.bind(Wn); Wn.remove.bind(Wn); Wn.update.bind(Wn); var Bo = { Easing: ds, Tween: xy }; function vy() { return new ad(); } function by(s, e) { s.appendChild(e.domElement); } function _y(s, e, t) { var n = new Object(); n.visible = !0; let i = null, r, a, o = []; n.init = function() { r || (c(), h(), u()); }, n.Hide = function() { r.style.display = "none", n.visible = !1; }, n.Show = function() { r.style.display = "block", n.visible = !0; }, n.RenderScene = function() { n.camera.quaternion.copy(e.camera.quaternion); let p = new R(0, 0, -1).clone().applyMatrix4(e.camera.matrixWorld.clone()), g = e.camera.position.clone().sub(p.clone()).setLength(100); n.camera.position.copy(g), n.camera.lookAt(new R()), n.sceneOrtho.renderer.render(n.sceneOrtho, n.camera); }, n.ToggleDirectionView = function(p) { console.log(p); var g = new R(0, 0, 0); p == "top" ? g = new R(0, 1, 0) : p == "down" ? g = new R(0, -1, 0) : p == "front" ? g = new R(0, 0, 1) : p == "left" ? g = new R(-1, 0, 0) : p == "back" ? g = new R(0, 0, -1) : p == "right" ? g = new R(1, 0, 0) : p == "top_front" ? g = new R(1, 1, 0) : p == "top_left" ? g = new R(0, 1, -1) : p == "top_back" ? g = new R(-1, 1, 0) : p == "top_right" ? g = new R(0, 1, 1) : p == "down_front" ? g = new R(1, -1, 0) : p == "down_left" ? g = new R(0, -1, -1) : p == "down_back" ? g = new R(-1, -1, 0) : p == "down_right" ? g = new R(0, -1, 1) : p == "front_right" ? g = new R(1, 0, 1) : p == "right_back" ? g = new R(-1, 0, 1) : p == "back_left" ? g = new R(-1, 0, -1) : p == "left_front" ? g = new R(1, 0, -1) : p == "top_left_front" ? g = new R(1, 1, -1) : p == "top_front_right" ? g = new R(1, 1, 1) : p == "top_right_back" ? g = new R(-1, 1, 1) : p == "top_back_left" ? g = new R(-1, 1, -1) : p == "button_left_front" ? g = new R(1, -1, -1) : p == "button_front_right" ? g = new R(1, -1, 1) : p == "button_right_back" ? g = new R(-1, 1, 1) : p == "button_back_left" && (g = new R(-1, -1, -1)); var x = s.octreeBox.getBoundingBox(), m = x.min, v = x.max, b = m.clone().add(v.clone()).multiplyScalar(0.5), M = b.clone().add(g.multiplyScalar(1 * v.distanceTo(m))); l(e.camera.position, M, s.controls.target.clone(), b); }, n.GetCameraPose = function() { var p = e.camera.quaternion, g = e.camera.position, x = s.controls.target, m = { quaternion: p, position: g, target: x }; return m; }, n.ReductionCameraPose = function(p, g = 1e3, x) { var m = new Dn( p.quaternion._x, p.quaternion._y, p.quaternion._z, p.quaternion._w ), v = new R(p.position.x, p.position.y, p.position.z), b = new R(p.target.x, p.target.y, p.target.z); let M = !1; l( e.camera.position, v, s.controls.target.clone(), b, e.camera.quaternion, m, g, (C) => { x && (M || (x(C), M = !0)); } ), x && setTimeout(() => { M || (x(!0), M = !0); }, g + 10); }, n.CameraGoHome = function() { var p = s.octreeBox.getBoundingBox(); console.log(p.min, p.max); var g = p.min.clone().add(p.max.clone()).multiplyScalar(0.5); let x = new R(1, 1, 1); var m = g.clone().add(x.multiplyScalar(1 * p.max.distanceTo(p.min))); l(e.camera.position, m, s.controls.target.clone(), g); }, n.zoomToBox = function(p) { var g = p.min.clone().add(p.max.clone()).multiplyScalar(0.5); let x = e.camera.position.clone().sub(s.controls.target.clone()).normalize(); var m = g.clone().add(x.multiplyScalar(1 * p.max.distanceTo(p.min))); l(e.camera.position, m, s.controls.target.clone(), g); }; function l(p, g, x, m, v, b, M = 1e3, C) { var T; v && b ? (T = new Bo.Tween({ x1: p.x, // 相机当前位置x y1: p.y, // 相机当前位置y z1: p.z, // 相机当前位置z x2: x.x, // 控制当前的中心点x y2: x.y, // 控制当前的中心点y z2: x.z, // 控制当前的中心点z _x: v._x, // 相机当前quaternion _y: v._y, // 相机当前quaternion _z: v._z, // 相机当前quaternion _w: v._w // 相机当前quaternion }), T.to( { x1: g.x, // 新的相机位置x y1: g.y, // 新的相机位置y z1: g.z, // 新的相机位置z x2: m.x, // 新的控制中心点位置x y2: m.y, // 新的控制中心点位置x z2: m.z, // 新的控制中心点位置x _x: b._x, // 新的相机quaternion _y: b._y, // 新的相机quaternion _z: b._z, // 新的相机quaternion _w: b._w // 新的相机quaternion }, M )) : (T = new Bo.Tween({ x1: p.x, // 相机当前位置x y1: p.y, // 相机当前位置y z1: p.z, // 相机当前位置z x2: x.x, // 控制当前的中心点x y2: x.y, // 控制当前的中心点y z2: x.z // 控制当前的中心点z }), T.to( { x1: g.x, // 新的相机位置x y1: g.y, // 新的相机位置y z1: g.z, // 新的相机位置z x2: m.x, // 新的控制中心点位置x y2: m.y, // 新的控制中心点位置x z2: m.z // 新的控制中心点位置x }, M )), T.onUpdate(function(U) { v && b ? (e.camera.quaternion._x = U._x, e.camera.quaternion._y = U._y, e.camera.quaternion._z = U._z, e.camera.quaternion._w = U._w) : s.controls.auto = !0, e.camera.position.x = U.x1, e.camera.position.y = U.y1, e.camera.position.z = U.z1, s.controls.target.x = U.x2, s.controls.target.y = U.y2, s.controls.target.z = U.z2, s.controls.update(), n.RenderScene(); }), T.onComplete(function(U) { s.controls.auto = !1, n.RenderScene(), C && C(!0), cancelAnimationFrame(i), i = null; }), T.easing(Bo.Easing.Cubic.InOut); function D(U) { i = requestAnimationFrame(D), T.update(); } T.start(), D(); } function c() { r = document.createElement("div"), r.className = "ViewCube", t.appendChild(r), a = document.createElement("div"), a.className = "viewSettingWrapper", a.innerHTML = "...", r.appendChild(a); var p = document.createElement("div"); p.className = "homeViewWrapper", p.addEventListener("mousedown", function() { console.log("归位"), n.CameraGoHome(); }), r.appendChild(p); const g = document.createElement("div"); g.className = "cameraToggleWrapper", g.title = "切换正交/透视视图", g.innerHTML = "⊞", g.addEventListener("mousedown", function(M) { M.stopPropagation(), console.log("切换视图"), n.ToggleCameraType(), v(); }), r.appendChild(g); const x = document.createElement("div"); x.className = "screenshotWrapper", x.title = "截图", x.innerHTML = "📷", x.addEventListener("mousedown", function(M) { M.stopPropagation(), console.log("截图"), n.TakeScreenshot(), v(); }), r.appendChild(x); const m = document.createElement("div"); m.className = "fullscreenWrapper", m.title = "全屏", m.innerHTML = "⛶", m.addEventListener("mousedown", function(M) { M.stopPropagation(), console.log("全屏"), n.ToggleFullscreen(), v(); }), r.appendChild(m), a.addEventListener("mousedown", function(M) { M.stopPropagation(), g.classList.contains("show") ? (v(), console.log("隐藏功能按钮")) : (b(), console.log("显示功能按钮")); }); function v() { g.classList.remove("show"), x.classList.remove("show"), m.classList.remove("show"); } function b() { g.classList.add("show"), x.classList.add("show"), m.classList.add("show"); } } function h() { n.sceneOrtho = vy(); var x = t.clientWidth, m = t.clientWidth, p = x > m ? x / m : m / x, g = 300; n.camera = new zi( g * p / -2, g * p / 2, g / 2, g / -2, 0.01, 1e4 ); var x = r.clientWidth, m = r.clientHeight, v = new Rd({ alpha: !0 }); v.setSize(x, m), v.setClearAlpha(0), n.sceneOrtho.renderer = v; let b = new Ea(16777215, 0.8); n.sceneOrtho.add(b), by(r, v); } function u() { const p = "/assets/viewcube/"; let g = [ { label: "右", icon: p + "cn_right.png" }, { label: "左", icon: p + "cn_left.png" }, { label: "顶", icon: p + "cn_top.png" }, { label: "底", icon: p + "cn_bottom.png" }, { label: "前", icon: p + "cn_front.png" }, { label: "后", icon: p + "cn_back.png" } ]; var x = []; for (const v of g) x.push( new Nt({ color: 16777215, map: new wd().load(v.icon) }) ); new yd({ color: 255 }); var m = new ft(new Li(110, 110, 110), x); n.sceneOrtho.add(m), f(122), r.addEventListener("mousedown", (v) => { var b = {}; b.x = v.offsetX / r.clientWidth * 2 - 1, b.y = -(v.offsetY / r.clientHeight) * 2 + 1; var M = new Ni(); M.setFromCamera(b, n.camera); const C = M.intersectObjects(o, !1); C.length > 0 && n.ToggleDirectionView(C[0].object.name); }), r.addEventListener("mousemove", (v) => { var b = {}; b.x = v.offsetX / r.clientWidth * 2 - 1, b.y = -(v.offsetY / r.clientHeight) * 2 + 1; var M = new Ni(); M.setFromCamera(b, n.camera); const C = M.intersectObjects(o, !1); for (var T of o) T.material.opacity = 0.01; C.length > 0 && (C[0].object.material.opacity = 0.2); }); } function f(p) { for (var g = p * 0.5 - 20, x = [ { name: "right", a: 30, b: 75, c: 75, point: new R(g, 0, 0) }, { name: "back", a: 75, b: 75, c: 30, point: new R(0, 0, -g) }, { name: "left", a: 30, b: 75, c: 75, point: new R(-g, 0, 0) }, { name: "front", a: 75, b: 75, c: 30, point: new R(0, 0, g) }, { name: "top", a: 75, b: 30, c: 75, point: new R(0, g, 0) }, { name: "button", a: 75, b: 30, c: 75, point: new R(0, -g, 0) } ], m = [ { name: "top_right_back", a: 30, b: 30, c: 30, point: new R(-g, g, g) }, { name: "button_front_right", a: 30, b: 30, c: 30, point: new R(-g, -g, g) }, { name: "top_front_right", a: 30, b: 30, c: 30, point: new R(g, g, g) }, { name: "button_right_back", a: 30, b: 30, c: 30, point: new R(g, -g, g) }, { name: "top_back_left", a: 30, b: 30, c: 30, point: new R(-g, g, -g) }, { name: "button_back_left", a: 30, b: 30, c: 30, point: new R(-g, -g, -g) }, { name: "top_left_front", a: 30, b: 30, c: 30, point: new R(g, g, -g) }, { name: "button_left_front", a: 30, b: 30, c: 30, point: new R(g, -g, -g) } ], v = [ { name: "top_front", a: 30, b: 30, c: 75, point: new R(g, g, 0) }, { name: "top_right", a: 75, b: 30, c: 30, point: new R(0, g, g) }, { name: "top_back", a: 30, b: 30, c: 75, point: new R(-g, g, 0) }, { name: "top_left", a: 75, b: 30, c: 30, point: new R(0, g, -g) }, { name: "button_front", a: 30, b: 30, c: 75, point: new R(g, -g, 0) }, { name: "button_right", a: 75, b: 30, c: 30, point: new R(0, -g, g) }, { name: "button_back", a: 30, b: 30, c: 75, point: new R(-g, -g, 0) }, { name: "button_left", a: 75, b: 30, c: 30, point: new R(0, -g, -g) }, { name: "front_right", a: 30, b: 75, c: 30, point: new R(g, 0, g) }, { name: "right_back", a: 30, b: 75, c: 30, point: new R(-g, 0, g) }, { name: "back_left", a: 30, b: 75, c: 30, point: new R(-g, 0, -g) }, { name: "left_front", a: 30, b: 75, c: 30, point: new R(g, 0, -g) } ], b = 0; b < x.length; b++) o.push(d(x[b])); for (var b = 0; b < m.length; b++) o.push(d(m[b])); for (var b = 0; b < v.length; b++) o.push(d(v[b])); } function d(p) { const g = new Li(p.a, p.b, p.c), x = new Nt({ color: "blue", transparent: !0, opacity: 0.01 }), m = new je().makeTranslation(p.point.x, p.point.y, p.point.z); let v = g.applyMatrix4(m), b = new ft(v, x); return b.name = p.name, n.sceneOrtho.add(b), b; } return n.ToggleCameraType = function() { s.cameraModule.switchCurrentCamera(); }, n.TakeScreenshot = function() { try { if (!s.renderer) { console.error("渲染器未初始化"); return; } s.renderer.render(e, e.camera); const p = s.renderer.domElement.toDataURL("image/png"), g = document.createElement("a"), x = (/* @__PURE__ */ new Date()).toISOString().replaceAll(/[:.]/g, "-"); g.download = `screenshot_${x}.png`, g.href = p, g.click(), console.log("截图已保存"); } catch (p) { console.error("截图失败:", p); } }, n.ToggleFullscreen = function() { const p = t || document.documentElement; !document.fullscreenElement && !document.webkitFullscreenElement && !document.mozFullScreenElement && !document.msFullscreenElement ? (p.requestFullscreen ? p.requestFullscreen() : p.webkitRequestFullscreen ? p.webkitRequestFullscreen() : p.mozRequestFullScreen ? p.mozRequestFullScreen() : p.msRequestFullscreen && p.msRequestFullscreen(), console.log("已进入全屏模式")) : (document.exitFullscreen ? document.exitFullscreen() : document.webkitExitFullscreen ? document.webkitExitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.msExitFullscreen && document.msExitFullscreen(), console.log("已退出全屏模式")); }, n; } class yy { engine; cubeTool; constructor(e) { this.engine = e; } init() { this.cubeTool = _y(this.engine, this.engine.scene, this.engine.container), this.cubeTool.init(); } // 相机回归正位 CameraGoHome() { this.cubeTool.CameraGoHome(); } // 缩放到指定模型 zoomToModel(e) { this.cubeTool.zoomToBox(e); } } function My(s) { let e = new Object(); return e.getBoundingBox = function() { let t = s.models, n = new R(1e8, 1e9, 1e10), i = new R(-1e8, -1e9, -1e10); t.forEach((u) => { let f = u.boundingBox.min, d = u.boundingBox.max; f.x < n.x && (n.x = f.x), f.y < n.y && (n.y = f.y), f.z < n.z && (n.z = f.z), d.x > i.x && (i.x = d.x), d.y > i.y && (i.y = d.y), d.z > i.z && (i.z = d.z); }); let r = Math.min(n.x, i.x), a = Math.min(n.y, i.y), o = Math.min(n.z, i.z), l = Math.max(n.x, i.x), c = Math.max(n.y, i.y), h = Math.max(n.z, i.z); return { min: new R(r, a, o), max: new R(l, c, h) }; }, e.rayInterationModel = function(t) { let n = []; return s.engineStatus.models.forEach((r) => { r.info.lods.forEach((a) => { let o = a.octreeBox; i(t, o, r); }); }), t.intersectObjects(n, !1); function i(r, a, o) { if (a == null) return; let l = new R(a.min.X * 0.3048, a.min.Z * 0.3048, -a.min.Y * 0.3048), c = new R(a.max.X * 0.3048, a.max.Z * 0.3048, -a.max.Y * 0.3048), h = new R(Math.min(l.x, c.X), Math.min(l.y, c.y), Math.min(l.z, c.z)), u = new R(Math.max(c.x, l.x), Math.max(c.y, l.y), Math.max(c.z, l.z)), f = new zt(h, u), d = r.ray.intersectsBox(f); if (!(d == null || d == !1)) if (a.children == null || a.children.length == 0) { if (a.elements != null) for (var p of a.elements) { let g = s.engineStatus.hideModels.find((m) => m.url == o.url)?.ids; if (g != null && g.includes(p)) continue; s.models.find((m) => m.url == o.url).nodesMap.get(p)?.infos.map((m) => m.mesh).forEach((m) => { n.push(m); }); } } else { if (a.elements != null) for (var p of a.elements) { let x = s.engineStatus.hideModels.find((v) => v.url == o.url)?.ids; if (x != null && x.includes(p)) continue; s.models.find((v) => v.url == o.url).nodesMap.get(p)?.infos.map((v) => v.mesh).forEach((v) => { n.push(v); }); } for (let g of a.children) i(r, g, o); } } }, e; } class Sy { engine; // 绘制状态 isDrawing = !1; startPoint = new ue(); endPoint = new ue(); // UI绘制框元素 selectionBox = null; // 坐标转换工具 worldToScreen = null; // 事件处理函数绑定(用于后续移除监听器) boundMouseDown; boundMouseMove; boundMouseUp; boundKeyDown; constructor(e) { this.engine = e, this.boundMouseDown = this.onMouseDown.bind(this), this.boundMouseMove = this.onMouseMove.bind(this), this.boundMouseUp = this.onMouseUp.bind(this), this.boundKeyDown = this.onKeyDown.bind(this); } /** * 初始化工具 * 创建绘制框UI元素,初始化坐标转换工具 */ init() { this.createSelectionBoxElement(), this.engine.scene && this.engine.camera && this.engine.renderer && (this.worldToScreen = new vn( this.engine.camera, this.engine.renderer, this.engine.scene )); } /** * 激活工具 * 禁用控制器,添加鼠标事件监听器和键盘事件监听器 */ active() { this.engine.controlModule.disActive(); const e = this.engine.renderer?.domElement; e && (e.addEventListener("mousedown", this.boundMouseDown), e.addEventListener("mousemove", this.boundMouseMove), e.addEventListener("mouseup", this.boundMouseUp), e.style.cursor = "crosshair"), window.addEventListener("keydown", this.boundKeyDown); } /** * 停用工具 * 启用控制器,移除鼠标事件监听器和键盘事件监听器 */ disActive() { this.engine.controlModule.active(); const e = this.engine.renderer?.domElement; e && (e.removeEventListener("mousedown", this.boundMouseDown), e.removeEventListener("mousemove", this.boundMouseMove), e.removeEventListener("mouseup", this.boundMouseUp), e.style.cursor = "default"), window.removeEventListener("keydown", this.boundKeyDown), this.isDrawing && this.endDrawing(); } /** * 创建绘制框UI元素 * 用于在屏幕上显示用户绘制的区域 */ createSelectionBoxElement() { this.selectionBox = document.createElement("div"), this.selectionBox.style.position = "absolute", this.selectionBox.style.border = "2px dashed #00aaff", this.selectionBox.style.backgroundColor = "rgba(0, 170, 255, 0.1)", this.selectionBox.style.pointerEvents = "none", this.selectionBox.style.display = "none", this.selectionBox.style.zIndex = "1000", this.selectionBox.style.boxSizing = "border-box"; const e = this.engine.renderer?.domElement; e && e.parentElement && e.parentElement.appendChild(this.selectionBox); } /** * 鼠标按下事件处理 * 开始绘制区域 */ onMouseDown(e) { if (e.button !== 0) return; const t = this.engine.renderer?.domElement; if (!t) return; const n = t.getBoundingClientRect(); this.startPoint.set(e.clientX - n.left, e.clientY - n.top), this.endPoint.copy(this.startPoint), this.isDrawing = !0, this.selectionBox && (this.selectionBox.style.display = "block", this.updateSelectionBoxUI()), e.preventDefault(), e.stopPropagation(); } /** * 鼠标移动事件处理 * 更新绘制框的显示 */ onMouseMove(e) { if (!this.isDrawing) return; const t = this.engine.renderer?.domElement; if (!t) return; const n = t.getBoundingClientRect(); this.endPoint.set(e.clientX - n.left, e.clientY - n.top), this.updateSelectionBoxUI(), e.preventDefault(), e.stopPropagation(); } /** * 鼠标释放事件处理 * 结束绘制,执行缩放操作 */ onMouseUp(e) { this.isDrawing && (this.endDrawing(), this.performZoom(), e.preventDefault(), e.stopPropagation(), this.disActive()); } /** * 键盘按下事件处理 * 按下 ESC 键时退出功能 */ onKeyDown(e) { e.key === "Escape" && (this.disActive(), e.preventDefault(), e.stopPropagation()); } /** * 结束绘制 * 隐藏绘制框 */ endDrawing() { this.isDrawing && (this.isDrawing = !1, this.selectionBox && (this.selectionBox.style.display = "none")); } /** * 更新绘制框UI * 根据起点和终点更新绘制框的位置和大小 */ updateSelectionBoxUI() { if (!this.selectionBox) return; const e = Math.min(this.startPoint.x, this.endPoint.x), t = Math.min(this.startPoint.y, this.endPoint.y), n = Math.abs(this.endPoint.x - this.startPoint.x), i = Math.abs(this.endPoint.y - this.startPoint.y); this.selectionBox.style.left = `${e}px`, this.selectionBox.style.top = `${t}px`, this.selectionBox.style.width = `${n}px`, this.selectionBox.style.height = `${i}px`; } /** * 执行缩放操作 * 将屏幕区域转换为世界坐标,计算包围盒,调整相机视角 */ performZoom() { const e = Math.abs(this.endPoint.x - this.startPoint.x), t = Math.abs(this.endPoint.y - this.startPoint.y); if (e < 5 || t < 5) return; if (!this.worldToScreen) { console.warn("RangeScale: 坐标转换工具未初始化"); return; } const n = Math.min(this.startPoint.x, this.endPoint.x), i = Math.max(this.startPoint.x, this.endPoint.x), r = Math.min(this.startPoint.y, this.endPoint.y), a = Math.max(this.startPoint.y, this.endPoint.y), o = [], l = [ { x: n, y: r }, // 左上 { x: i, y: r }, // 右上 { x: i, y: a }, // 右下 { x: n, y: a } // 左下 ]; for (const h of l) { const u = this.worldToScreen.screenToWorld(h.x, h.y); u && o.push(u); } if (o.length < 3) { const h = this.engine.camera, u = this.engine.scene, f = new zt(); if (u.traverse((d) => { if (d.isMesh && d.visible && d.geometry && (d.geometry.computeBoundingBox(), d.geometry.boundingBox)) { const p = d.geometry.boundingBox.clone(); p.applyMatrix4(d.matrixWorld), f.union(p); } }), f.isEmpty()) for (const d of l) { const p = this.worldToScreen.screenToWorldWithDepth(d.x, d.y, 10); o.push(p); } else { const d = new R(); f.getCenter(d); const p = d.clone().sub(h.position).length(); for (const g of l) { const x = this.worldToScreen.screenToWorldWithDepth(g.x, g.y, p); o.push(x); } } } if (o.length < 3) { console.warn("RangeScale: 无法将屏幕区域转换为世界坐标"); return; } const c = new zt(); for (const h of o) c.expandByPoint(h); if (c.isEmpty()) { console.warn("RangeScale: 计算得到的包围盒无效"); return; } this.fitCameraToBoundingBox(c); } /** * 调整相机视角以适应包围盒 * @param boundingBox - 要适应的包围盒 */ fitCameraToBoundingBox(e) { const t = this.engine.camera, n = this.engine.controls; if (!t || !n) { console.warn("RangeScale: 相机或控制器未初始化"); return; } const i = new R(); e.getCenter(i); const r = new R(); e.getSize(r); const a = Math.max(r.x, r.y, r.z); if (t instanceof jt) { const o = t.fov * (Math.PI / 180), l = a / (2 * Math.tan(o / 2)) * 1.2, c = new R(); t.getWorldDirection(c); const h = i.clone().sub(t.position); c.dot(h.normalize()) < 0 && c.negate(); const u = i.clone().sub(c.multiplyScalar(l)); t.position.copy(u), n.target && n.target.copy(i), t.lookAt(i), n.update(); } else if (t instanceof zi) { const o = a * 1.2, l = this.engine.renderer?.domElement, c = l ? l.width / l.height : 1; t.left = -o * c / 2, t.right = o * c / 2, t.top = o / 2, t.bottom = -o / 2, t.updateProjectionMatrix(); const h = new R(); t.getWorldDirection(h); const u = a * 1.5, f = i.clone().sub(h.multiplyScalar(u)); t.position.copy(f), n.target && n.target.copy(i), t.lookAt(i), n.update(); } } } class wy { engine; ground = null; // 地面对象 constructor(e) { this.engine = e; } init() { } /** * 隐藏或显示性能监视器 * @param visible - true显示,false隐藏 */ setStatsVisible(e) { this.engine.stats?.dom && (this.engine.stats.dom.style.display = e ? "block" : "none"); } /** * 设置环境光照强度 * @param intensity - 光照强度,默认范围 0-5 */ setAmbientLightIntensity(e) { const t = this.engine.scene.children.find( (n) => n instanceof Ea ); t && (t.intensity = e); } /** * 设置环境光照颜色 * @param color - 颜色,可以是十六进制数字 (0xffffff) 或字符串 ('#ffffff') */ setAmbientLightColor(e) { const t = this.engine.scene.children.find( (n) => n instanceof Ea ); t && t.color.set(e); } /** * 设置定向光源强度 * @param intensity - 光照强度,默认范围 0-5 */ setDirectionalLightIntensity(e) { const t = this.engine.scene.children.find( (n) => n instanceof os ); t && (t.intensity = e); } /** * 设置定向光源颜色 * @param color - 颜色,可以是十六进制数字 (0xffffff) 或字符串 ('#ffffff') */ setDirectionalLightColor(e) { const t = this.engine.scene.children.find( (n) => n instanceof os ); t && t.color.set(e); } /** * 设置阴影精细度(阴影贴图分辨率) * @param quality - 质量等级:'low' (1024), 'medium' (2048), 'high' (4096), 'ultra' (8192) */ setShadowQuality(e) { const t = this.engine.scene.children.find( (n) => n instanceof os ); if (t?.shadow) { const n = { low: 1024, medium: 2048, high: 4096, ultra: 8192 }[e]; t.shadow.mapSize.width = n, t.shadow.mapSize.height = n, t.shadow.map?.dispose(), t.shadow.map = null; } } /** * 设置是否开启定向光阴影 * @param enabled - true开启,false关闭 */ setDirectionalLightShadow(e) { const t = this.engine.scene.children.find( (n) => n instanceof os ); t && (t.castShadow = e), this.engine.renderer && (this.engine.renderer.shadowMap.enabled = e); } /** * 设置是否开启GTAO阴影(环境光遮蔽) * @param enabled - true开启,false关闭 */ setGTAOEnabled(e) { if (!this.engine.composerModule?.composer) { console.warn("Composer not initialized"); return; } const t = this.engine.composerModule.composer, n = t.passes.find((i) => i instanceof nn); if (e) if (n) n.enabled = !0; else { const { width: i, height: r } = this.engine.deviceModule.getContainerSize(), a = new nn( this.engine.scene, this.engine.camera, i, r ); a.output = nn.OUTPUT.Default, a.blendIntensity = 0.5, a.updateGtaoMaterial && a.updateGtaoMaterial({ radius: 1, distanceExponent: 1, thickness: 1, scale: 1, distanceFallOff: 1, screenSpaceRadius: !0 }); const o = t.passes.findIndex( (l) => l.constructor.name === "RenderPass" ); t.passes.splice(o + 1, 0, a); } else n && (n.enabled = !1); } /** * 设置场景饱和度 * @param saturation - 饱和度值,1.0为正常,>1增强,<1降低,推荐范围 0.5-2.0 */ setSceneSaturation(e) { if (!this.engine.composerModule?.saturationPass) { console.warn("Saturation pass not initialized"); return; } this.engine.composerModule.saturationPass.uniforms.saturation.value = e; } /** * 设置场景对比度 * @param contrast - 对比度值,1.0为正常,>1增强,<1降低,推荐范围 0.5-2.0 */ setSceneContrast(e) { if (!this.engine.composerModule?.saturationPass) { console.warn("Saturation pass not initialized"); return; } this.engine.composerModule.saturationPass.uniforms.contrast.value = e; } /** * 设置是否开启地面 * @param enabled - true开启,false关闭 * @param options - 地面配置选项 */ setGroundEnabled(e, t) { if (e) if (this.ground) this.ground.visible = !0; else { const n = t?.size ?? 100, i = t?.color ?? 8421504, r = t?.opacity ?? 0.3, a = new Ii(n, n), o = new Cs({ color: i, transparent: !0, opacity: r, side: Dt }); this.ground = new ft(a, o), this.ground.rotation.x = -Math.PI / 2, this.ground.position.y = 0, this.ground.receiveShadow = !0, this.ground.name = "ground", this.engine.scene.add(this.ground); } else this.ground && (this.ground.visible = !1); } /** * 设置HDR背景 * @param hdrTexture - HDR环境贴图(THREE.Texture),传入null则移除背景 */ setHDRBackground(e) { e ? (this.engine.scene.background = e, this.engine.scene.environment = e) : (this.engine.scene.background = null, this.engine.scene.environment = null); } } function ri() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) { var e = Math.random() * 16 | 0, t = s == "x" ? e : e & 3 | 8; return t.toString(16); }); } class ai { engine; handelBehaved; constructor(e) { this.engine = e, this.handelBehaved = lf(e), this.handelBehaved.init(this, null); } active() { this.handelBehaved.active(); } disActive() { this.handelBehaved.disActive(); } // 取消当前选中的标注 cancelCurrentSelectedAnnotation() { let e = this.engine.measure.annotationData; for (let t in e) e[t].forEach((n) => { n.highlight == !0 && (n.highlight = !1, n.container.classList.remove("Hight"), n.container.getElementsByTagName("svg")[0].classList.remove("Hight")); }); } // 监听按下esc handelKeyEscDown() { this.cancelCurrentSelectedAnnotation(); let e = this.engine.measure.annotationData; for (let t in e) for (let n = e[t].length - 1; n >= 0; n--) { let i = e[t][n]; i.isSelect == !0 && (i.container.remove(), e[t].splice(n, 1)); } this.engine.measure.clearAllPoints(); } // 监听按下delete handelKeyDeleteDown() { let e = this.engine.measure.annotationData; for (let t in e) for (let n = e[t].length - 1; n >= 0; n--) { let i = e[t][n]; i.highlight == !0 && (i.container.remove(), e[t].splice(n, 1)); } } clearHighlight() { let e = this.engine.measure.annotationData; for (let t in e) e[t].forEach((n) => { n.highlight = !1, n.container.classList.remove("Hight"), n.container.getElementsByTagName("svg")[0].classList.remove("Hight"); }); } // 绘制普通标注 drawNormalAnnotation() { let e = this; this.engine.measure.annotationData.normalAnnotation.forEach((l) => { o(l); }), this.engine.measure.annotationData.elevationAnnotation.forEach((l) => { a(l); }), this.engine.measure.annotationData.coordinateAnnotation.forEach((l) => { r(l); }), this.engine.measure.annotationData.angleAnnotation.forEach((l) => { t(l); }), this.engine.measure.annotationData.areaAnnotation.forEach((l) => { n(l); }), this.engine.measure.annotationData.slopeAnnotation.forEach((l) => { i(l); }); function t(l) { if (l.container == null) { let g = [ '', '', // 起点 '', // 顶点 '', // 终点 '', // 起点到顶点的线 '', // 顶点到终点的线 '', '' + l.text + "", "" ].join(""); l.container = document.createElement("div"), l.container.className = "angle-annotation", l.container.id = l.id, l.container.style.pointerEvents = "none", l.container.innerHTML = g, e.engine.measure.annotationContainer.appendChild(l.container), l.container.getElementsByTagName("svg")[0].addEventListener("click", function() { e.clearHighlight(), l.container.getElementsByTagName("svg")[0].classList.add("Hight"), l.highlight = !0; }); } let c = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point1), h = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point2), u = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point3), f = l.container; f.getElementsByTagName("circle")[0].setAttribute("cx", c.x), f.getElementsByTagName("circle")[0].setAttribute("cy", c.y), f.getElementsByTagName("circle")[1].setAttribute("cx", h.x), f.getElementsByTagName("circle")[1].setAttribute("cy", h.y), f.getElementsByTagName("circle")[2].setAttribute("cx", u.x), f.getElementsByTagName("circle")[2].setAttribute("cy", u.y), f.getElementsByTagName("polyline")[0].setAttribute("points", c.x + "," + c.y + " " + h.x + "," + h.y), f.getElementsByTagName("polyline")[1].setAttribute("points", h.x + "," + h.y + " " + u.x + "," + u.y); let d = h.x, p = h.y - 30; f.getElementsByTagName("rect")[0].setAttribute("x", d - 40), f.getElementsByTagName("rect")[0].setAttribute("y", p - 12.5), f.getElementsByTagName("text")[0].setAttribute("x", d), f.getElementsByTagName("text")[0].setAttribute("y", p + 4), f.getElementsByTagName("text")[0].innerHTML = l.text, f.style.top = "0px", f.style.left = "0px"; } function n(l) { if (l.container == null) { let x = [ '', '', // 填充区域 '', // 边界线 '', '' + l.text + "", "" ].join(""); l.container = document.createElement("div"), l.container.className = "area-annotation", l.container.id = l.id, l.container.innerHTML = x, e.engine.measure.annotationContainer.appendChild(l.container), l.container.getElementsByTagName("svg")[0].addEventListener("click", function() { e.clearHighlight(), l.container.getElementsByTagName("svg")[0].classList.add("Hight"), l.highlight = !0; }); } if (!l.points || l.points.length < 3) return; let c = [], h = 0, u = 0; for (let x = 0; x < l.points.length; x++) { let m = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.points[x]); c.push(m), h += m.x, u += m.y; } h = h / c.length, u = u / c.length; let f = c.map((x) => x.x + "," + x.y).join(" "), d = l.container; d.getElementsByTagName("polygon")[0].setAttribute("points", f), d.getElementsByTagName("polyline")[0].setAttribute("points", f); let p = h, g = u; d.getElementsByTagName("rect")[0].setAttribute("x", p - 40), d.getElementsByTagName("rect")[0].setAttribute("y", g - 12.5), d.getElementsByTagName("text")[0].setAttribute("x", p), d.getElementsByTagName("text")[0].setAttribute("y", g + 4), d.getElementsByTagName("text")[0].innerHTML = l.text, d.style.top = "0px", d.style.left = "0px"; } function i(l) { if (l.container == null) { let p = [ '', "", '', '', // 箭头形状 "", "", '', // 起点到终点的线,带箭头 '', '' + l.text + "", "" ].join(""); l.container = document.createElement("div"), l.container.className = "slope-annotation", l.container.id = l.id, l.container.innerHTML = p, e.engine.measure.annotationContainer.appendChild(l.container), l.container.getElementsByTagName("svg")[0].addEventListener("click", function() { e.clearHighlight(), l.container.getElementsByTagName("svg")[0].classList.add("Hight"), l.highlight = !0; }); } let c = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point1), h = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point2), u = l.container; u.getElementsByTagName("polyline")[0].setAttribute("points", c.x + "," + c.y + " " + h.x + "," + h.y); let f = (c.x + h.x) / 2, d = (c.y + h.y) / 2 - 30; u.getElementsByTagName("rect")[0].setAttribute("x", f - 50), u.getElementsByTagName("rect")[0].setAttribute("y", d - 12.5), u.getElementsByTagName("text")[0].setAttribute("x", f), u.getElementsByTagName("text")[0].setAttribute("y", d + 4), u.getElementsByTagName("text")[0].innerHTML = l.text, u.style.top = "0px", u.style.left = "0px"; } function r(l) { if (l.container == null) { let g = [ '', '', '', '' + l.textX + "", '', '' + l.textY + "", '', '' + l.textZ + "", "" ].join(""); l.container = document.createElement("div"), l.container.className = "coordinate-annotation", l.container.id = l.id, l.container.style.position = "absolute", l.container.style.pointerEvents = "none", l.container.innerHTML = g, e.engine.measure.annotationContainer.appendChild(l.container), l.container.getElementsByTagName("svg")[0].addEventListener("click", function() { e.clearHighlight(), l.container.getElementsByTagName("svg")[0].classList.add("Hight"), l.highlight = !0; }); } let c = l.container, h = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point); c.style.top = "0px", c.style.left = "0px"; let u = c.getElementsByTagName("circle")[0]; u && (u.setAttribute("cx", h.x), u.setAttribute("cy", h.y)); let f = c.getElementsByTagName("rect"), d = c.getElementsByTagName("text"), p = -55; f[0] && (f[0].setAttribute("x", h.x + 10), f[0].setAttribute("y", h.y + 10 + p)), d[0] && (d[0].setAttribute("x", h.x + 10 + 40), d[0].setAttribute("y", h.y + 10 + 16 + p)), f[1] && (f[1].setAttribute("x", h.x + 10), f[1].setAttribute("y", h.y + 10 + 30 + p)), d[1] && (d[1].setAttribute("x", h.x + 10 + 40), d[1].setAttribute("y", h.y + 10 + 46 + p)), f[2] && (f[2].setAttribute("x", h.x + 10), f[2].setAttribute("y", h.y + 10 + 60 + p)), d[2] && (d[2].setAttribute("x", h.x + 10 + 40), d[2].setAttribute("y", h.y + 10 + 76 + p)), d[0] && (d[0].innerHTML = l.textX), d[1] && (d[1].innerHTML = l.textY), d[2] && (d[2].innerHTML = l.textZ); } function a(l) { if (l.container == null) { let u = [ '', '', '' + l.text + "", '', "" ].join(""); l.container = document.createElement("div"), l.container.className = "elevation-annotation", l.container.id = l.id, l.container.style.position = "absolute", l.container.style.pointerEvents = "none", l.container.innerHTML = u, e.engine.measure.annotationContainer.appendChild(l.container), l.container.getElementsByTagName("svg")[0].addEventListener("click", function() { e.clearHighlight(), l.container.getElementsByTagName("svg")[0].classList.add("Hight"), l.highlight = !0; }); } let c = l.container, h = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point); c.style.top = h.y - 48 + "px", c.style.left = h.x - 16 + "px", c.getElementsByTagName("text")[0].innerHTML = l.text; } function o(l) { if (l.container == null) { let f = [ '', '', '', '', '', '' + l.text + "", "" ].join(""); l.container = document.createElement("div"), l.container.className = "normal-annotation", l.container.id = l.id, l.container.innerHTML = f, e.engine.measure.annotationContainer.appendChild(l.container), l.container.getElementsByTagName("svg")[0].addEventListener("click", function() { e.clearHighlight(), l.container.getElementsByTagName("svg")[0].classList.add("Hight"), l.highlight = !0; }); } let c = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point1), h = new vn(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(l.point2), u = l.container; u.getElementsByTagName("polyline")[0].setAttribute("points", c.x + "," + c.y + " " + h.x + "," + h.y), u.getElementsByTagName("circle")[0].setAttribute("cx", c.x), u.getElementsByTagName("circle")[0].setAttribute("cy", c.y), u.getElementsByTagName("circle")[1].setAttribute("cx", h.x), u.getElementsByTagName("circle")[1].setAttribute("cy", h.y), u.getElementsByTagName("rect")[0].setAttribute("x", c.x * 0.5 + h.x * 0.5 - 40), u.getElementsByTagName("rect")[0].setAttribute("y", c.y * 0.5 + h.y * 0.5 - 12.5), u.getElementsByTagName("text")[0].setAttribute("x", c.x * 0.5 + h.x * 0.5 + 40 - 40), u.getElementsByTagName("text")[0].setAttribute("y", c.y * 0.5 + h.y * 0.5 + 16 - 12.5), u.getElementsByTagName("text")[0].innerHTML = l.text, u.style.top = "0px", u.style.left = "0px"; } } } class Ey { engine; isActive = !1; tools; points = []; behavior; constructor(e) { this.engine = e, this.tools = new ai(e); } // 启动净高测量 active() { this.engine.measure.tools.cancelCurrentSelectedAnnotation(), this.isActive = !0, this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(); } // 停止净高测量 disActive() { this.isActive = !1, this.behavior.disActive(); } // 清空所有点 clearAllPoints() { this.points = []; } // 鼠标点击 handleMouseClick(e) { if (e.catch == null) return; if (this.points.length == 0) { this.points.push(e.catch.point); return; } let t = this.engine.measure.annotationData.normalAnnotation.find((n) => n.isSelect == !0); t != null && (t.isSelect = !1); } // 鼠标移动 handleMouseMove(e) { if (e.catch == null || this.points.length == 0) return; let t = this.engine.measure.annotationData.normalAnnotation.find((a) => a.isSelect == !0); t == null && (t = { text: null, id: ri(), isSelect: !0 }, this.engine.measure.annotationData.normalAnnotation.push(t)); let n = new Ni(e.catch.point, new R(0, 1, 0)); const i = this.engine.octreeBox.rayInterationModel(n); if (i.length === 0) return; let r = e.catch; t.point1 = r.point, t.point2 = i[0].point, t.text = t.point1.clone().distanceTo(t.point2.clone()).toFixed(2) + " m"; } } class Ty { engine; tools; isActive = !1; points = []; behavior; constructor(e) { this.engine = e, this.tools = new ai(e); } // 启动距离测量 active() { this.engine.measure.tools.cancelCurrentSelectedAnnotation(), this.isActive = !0, this.points = [], this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(); } // 停止距离测量 disActive() { this.points = [], this.isActive = !1, this.behavior.disActive(); } // 清空所有点 clearAllPoints() { this.points = []; } // 鼠标点击 handleMouseClick(e) { if (e.catch == null) return; let t = e.catch; if (this.points.length == 0) this.points.push(t.point); else if (this.points.length == 1) { let n = this.engine.measure.annotationData.normalAnnotation.find((i) => i.isSelect == !0); if (n == null) return; n.point2 = t.point, n.isSelect = !1, this.points = [], this.engine.events.trigger(si.MeasureChanged, n); } } // 鼠标移动 handleMouseMove(e) { if (e.catch == null) return; let t = e.catch; if (t != null && this.points.length == 1) { let n = this.engine.measure.annotationData.normalAnnotation.find((i) => i.isSelect == !0); n == null && (n = { id: ri(), point1: this.points[0].clone(), point2: t.point.clone(), text: this.points[0].clone().distanceTo(t.point.clone()).toFixed(2) + " m", isSelect: !0 }, this.engine.measure.annotationData.normalAnnotation.push(n)), n.point2 = t.point, n.text = n.point1.clone().distanceTo(n.point2.clone()).toFixed(2) + " m", console.log("距离", n.text); } } // 按下esc } class Cy { engine; isActive = !1; tools; points = []; behavior; constructor(e) { this.engine = e, this.tools = new ai(e); } // 启动净高测量 active() { this.engine.measure.tools.cancelCurrentSelectedAnnotation(), this.isActive = !0, this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(); } // 停止净高测量 disActive() { this.isActive = !1, this.behavior.disActive(); } // 清空所有点 clearAllPoints() { this.points = []; } // 鼠标点击 handleMouseClick(e) { if (e.catch == null) return; if (this.points.length == 0) { this.points.push(e.catch.point); return; } let t = this.engine.measure.annotationData.normalAnnotation.find((n) => n.isSelect == !0); t != null && (t.isSelect = !1); } // 鼠标移动 handleMouseMove(e) { if (e.catch == null || this.points.length == 0) return; let t = this.engine.measure.annotationData.normalAnnotation.find((a) => a.isSelect == !0); t == null && (t = { text: null, id: ri(), isSelect: !0 }, this.engine.measure.annotationData.normalAnnotation.push(t)); let n = new Ni(e.catch.point, e.catch.normal); const i = this.engine.octreeBox.rayInterationModel(n); if (i.length === 0) return; let r = this.tools.renderCatchElement(e.catch); t.point1 = r.point, t.point2 = i[0].point, t.text = t.point1.clone().distanceTo(t.point2.clone()).toFixed(2) + " m"; } } class Ay { engine; isActive = !1; tools; points = []; behavior; constructor(e) { this.engine = e, this.tools = new ai(e); } active() { this.engine.measure.tools.cancelCurrentSelectedAnnotation(), this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(), this.isActive = !0; } disActive() { this.isActive = !1, this.behavior.disActive(); } // 清空所有点 clearAllPoints() { this.points = []; } handleMouseMove(e) { if (e.catch == null) return; let t = this.engine.measure.annotationData.elevationAnnotation.find((n) => n.isSelect == !0); t == null && (t = { id: ri(), point: e.catch.point.clone(), text: Math.round(e.catch.point.y) + " m", isSelect: !0 }, this.engine.measure.annotationData.elevationAnnotation.push(t)), t.point = e.catch.point.clone(), t.text = Math.round(e.catch.point.y) + " m"; } handleMouseClick(e) { if (e.catch == null) return; let t = this.engine.measure.annotationData.elevationAnnotation.find((n) => n.isSelect == !0); t != null && (t.isSelect = !1, t.point = e.catch.point.clone(), t.text = Math.round(e.catch.point.y) + " m", this.engine.events.trigger(si.MeasureChanged, t)); } } class Py { engine; isActive = !1; tools; points = []; behavior; constructor(e) { this.engine = e, this.tools = new ai(e); } active() { this.engine.measure.tools.cancelCurrentSelectedAnnotation(), this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(), this.isActive = !0; } disActive() { this.isActive = !1, this.behavior.disActive(); } // 清空所有点 clearAllPoints() { this.points = []; } handleMouseMove(e) { if (e.catch == null) return; let t = this.engine.measure.annotationData.coordinateAnnotation.find((n) => n.isSelect == !0); t == null && (t = { id: ri(), point: e.catch.point.clone(), text: Math.round(e.catch.point.y) + " m", isSelect: !0 }, this.engine.measure.annotationData.coordinateAnnotation.push(t)), t.point = e.catch.point.clone(), t.textX = Math.round(e.catch.point.x) + " m", t.textY = Math.round(e.catch.point.y) + " m", t.textZ = Math.round(e.catch.point.z) + " m"; } handleMouseClick(e) { if (e.catch == null) return; let t = this.engine.measure.annotationData.coordinateAnnotation.find((n) => n.isSelect == !0); t != null && (t.isSelect = !1, t.point = e.catch.point.clone(), t.textX = Math.round(e.catch.point.x) + " m", t.textY = Math.round(e.catch.point.y) + " m", t.textZ = Math.round(e.catch.point.z) + " m", this.engine.events.trigger(si.MeasureChanged, t)); } } class Ry { engine; tools; // 存储三个点:起点、顶点(中间点)、终点 points = []; behavior; constructor(e) { this.engine = e, this.tools = new ai(e); } // 启动角度测量 active() { this.engine.measure.tools.cancelCurrentSelectedAnnotation(), this.points = [], this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(); } // 停止角度测量 disActive() { this.points = [], this.behavior.disActive(); } // 清空所有点 clearAllPoints() { this.points = []; } // 计算三点形成的角度(以第二个点为顶点) // point1: 起点, point2: 顶点, point3: 终点 calculateAngle(e, t, n) { const i = new R().subVectors(e, t), r = new R().subVectors(n, t), a = i.length(), o = r.length(); if (a === 0 || o === 0) return 0; const l = i.dot(r) / (a * o), c = Math.max(-1, Math.min(1, l)); return Math.acos(c) * (180 / Math.PI); } // 处理鼠标点击事件 handleMouseClick(e) { if (e.catch == null) return; let t = e.catch; if (this.points.length == 0) this.points.push(t.point); else if (this.points.length == 1) this.points.push(t.point); else if (this.points.length == 2) { let n = this.engine.measure.annotationData.angleAnnotation.find((i) => i.isSelect == !0); if (n == null) return; n.point3 = t.point.clone(), n.angle = this.calculateAngle(n.point1, n.point2, n.point3), n.text = n.angle.toFixed(2) + "°", n.isSelect = !1, this.points = [], this.engine.events.trigger(si.MeasureChanged, n); } } // 处理鼠标移动事件 handleMouseMove(e) { if (e.catch == null) return; let t = this.tools.renderCatchElement(e.catch); if (t != null && this.points.length != 1 && this.points.length == 2) { let n = this.engine.measure.annotationData.angleAnnotation.find((i) => i.isSelect == !0); n == null && (n = { id: ri(), point1: this.points[0].clone(), // 起点 point2: this.points[1].clone(), // 顶点(中间点) point3: t.point.clone(), // 终点(实时更新) angle: 0, text: "0.00°", isSelect: !0 }, this.engine.measure.annotationData.angleAnnotation.push(n)), n.point3 = t.point.clone(), n.angle = this.calculateAngle(n.point1, n.point2, n.point3), n.text = n.angle.toFixed(2) + "°", console.log("角度", n.text); } } } class Ly { engine; tools; // 存储多个点,用于围成区域 points = []; behavior; constructor(e) { this.engine = e, this.tools = new ai(e); } // 启动面积测量 active() { this.engine.measure.tools.cancelCurrentSelectedAnnotation(), this.points = [], this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(); } // 停止面积测量 disActive() { this.points = [], this.behavior.disActive(); } // 清空所有点 clearAllPoints() { this.points = []; } // 计算多边形面积(使用鞋带公式/Shoelace formula) // 注意:这个方法假设点在同一个平面上,使用XZ平面投影计算面积 calculateArea(e) { if (e.length < 3) return 0; let t = 0; const n = e.length; for (let i = 0; i < n; i++) { const r = (i + 1) % n; t += e[i].x * e[r].z, t -= e[r].x * e[i].z; } return t = Math.abs(t) / 2, t; } // 处理鼠标点击事件 handleMouseClick(e) { if (e.catch == null) return; let t = e.catch; if (this.points.push(t.point.clone()), this.points.length >= 3) { let n = this.engine.measure.annotationData.areaAnnotation.find((i) => i.isSelect == !0); n == null ? (n = { id: ri(), points: this.points.map((i) => i.clone()), // 复制所有点 area: 0, text: "0.00 m²", isSelect: !0 }, this.engine.measure.annotationData.areaAnnotation.push(n)) : n.points = this.points.map((i) => i.clone()), n.area = this.calculateArea(n.points), n.text = n.area.toFixed(2) + " m²", console.log("面积", n.text); } } // 处理鼠标移动事件 handleMouseMove(e) { if (e.catch == null) return; let t = this.tools.renderCatchElement(e.catch); if (t != null && this.points.length >= 2) { let n = this.engine.measure.annotationData.areaAnnotation.find((i) => i.isSelect == !0); if (n == null) { if (this.points.length >= 2) { let i = this.points.map((r) => r.clone()); i.push(t.point.clone()), i.length >= 3 && (n = { id: ri(), points: i, area: 0, text: "0.00 m²", isSelect: !0 }, this.engine.measure.annotationData.areaAnnotation.push(n)); } } else if (n.points.length > 0) { const i = n.points.length - 1; n.points[i] = t.point.clone(); } else n.points = this.points.map((i) => i.clone()), n.points.push(t.point.clone()); n && n.points.length >= 3 && (n.area = this.calculateArea(n.points), n.text = n.area.toFixed(2) + " m²"); } } // 完成面积测量(可以用于双击或右键完成) finishMeasure() { let e = this.engine.measure.annotationData.areaAnnotation.find((t) => t.isSelect == !0); e != null && e.points.length >= 3 && (e.points.length > this.points.length && (e.points = this.points.map((t) => t.clone())), e.area = this.calculateArea(e.points), e.text = e.area.toFixed(2) + " m²", e.isSelect = !1, this.points = [], this.engine.events.trigger(si.MeasureChanged, e)); } } class Dy { engine; tools; // 存储两个点:起点和终点 points = []; behavior; constructor(e) { this.engine = e, this.tools = new ai(e); } // 启动坡度测量 active() { this.engine.measure.tools.cancelCurrentSelectedAnnotation(), this.points = [], this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(); } // 停止坡度测量 disActive() { this.points = [], this.behavior.disActive(); } // 清空所有点 clearAllPoints() { this.points = []; } // 计算两点之间的坡度 // point1: 起点, point2: 终点 // 返回:{ percentage: 坡度百分比, angle: 坡度角度(度), heightDiff: 高度差, horizontalDist: 水平距离 } calculateSlope(e, t) { const n = t.y - e.y, i = t.x - e.x, r = t.z - e.z, a = Math.sqrt(i * i + r * r); if (a === 0) return { percentage: 0, angle: 0, heightDiff: n, horizontalDist: 0 }; const o = n / a * 100, l = Math.atan(n / a) * (180 / Math.PI); return { percentage: o, angle: l, heightDiff: n, horizontalDist: a }; } // 处理鼠标点击事件 handleMouseClick(e) { if (e.catch == null) return; let t = this.tools.renderCatchElement(e.catch); if (this.points.length == 0) this.points.push(t.point); else if (this.points.length == 1) { let n = this.engine.measure.annotationData.slopeAnnotation.find((r) => r.isSelect == !0); if (n == null) return; n.point2 = t.point.clone(); const i = this.calculateSlope(n.point1, n.point2); n.slopePercentage = i.percentage, n.slopeAngle = i.angle, n.heightDiff = i.heightDiff, n.horizontalDist = i.horizontalDist, n.text = i.percentage.toFixed(2) + "% (" + i.angle.toFixed(2) + "°)", n.isSelect = !1, this.points = [], this.engine.events.trigger(si.MeasureChanged, n); } } // 处理鼠标移动事件 handleMouseMove(e) { if (e.catch == null) return; let t = this.tools.renderCatchElement(e.catch); if (t != null && this.points.length == 1) { let n = this.engine.measure.annotationData.slopeAnnotation.find((r) => r.isSelect == !0); n == null && (n = { id: ri(), point1: this.points[0].clone(), // 起点 point2: t.point.clone(), // 终点(实时更新) slopePercentage: 0, slopeAngle: 0, heightDiff: 0, horizontalDist: 0, text: "0.00% (0.00°)", isSelect: !0 }, this.engine.measure.annotationData.slopeAnnotation.push(n)), n.point2 = t.point.clone(); const i = this.calculateSlope(n.point1, n.point2); n.slopePercentage = i.percentage, n.slopeAngle = i.angle, n.heightDiff = i.heightDiff, n.horizontalDist = i.horizontalDist, n.text = i.percentage.toFixed(2) + "% (" + i.angle.toFixed(2) + "°)", console.log("坡度", n.text); } } } class Iy { isActive = !1; engine; clearHeightMeasure; distanceMeasure; clearDistanceMeasure; elevationMeasure; pointMeasure; angleMeasure; areaMeasure; slopeMeasure; tools; annotationContainer; // 存储标注信息 annotationData = { normalAnnotation: [], textAnnotation: [], coordinateAnnotation: [], angleAnnotation: [], distanceAnnotation: [], areaAnnotation: [], slopeAnnotation: [], elevationAnnotation: [], volumeAnnotation: [] }; constructor(e) { this.engine = e, this.clearHeightMeasure = new Ey(e), this.distanceMeasure = new Ty(e), this.clearDistanceMeasure = new Cy(e), this.elevationMeasure = new Ay(e), this.pointMeasure = new Py(e), this.angleMeasure = new Ry(e), this.areaMeasure = new Ly(e), this.slopeMeasure = new Dy(e), this.tools = new ai(e), this.annotationContainer = document.createElement("div"), this.annotationContainer.className = "annotation-container", e.container.parentElement.appendChild(this.annotationContainer); } active() { this.isActive = !0, this.tools.active(); } disActive() { this.tools.disActive(), this.clearAll(), this.isActive = !1, this.clearHeightMeasure.disActive(), this.distanceMeasure.disActive(), this.clearDistanceMeasure.disActive(), this.elevationMeasure.disActive(), this.pointMeasure.disActive(), this.angleMeasure.disActive(), this.areaMeasure.disActive(), this.slopeMeasure.disActive(), this.engine.interactionModule.active(); } // 清空所有点的测量 clearAllPoints() { this.clearHeightMeasure.clearAllPoints(), this.distanceMeasure.clearAllPoints(), this.clearDistanceMeasure.clearAllPoints(), this.elevationMeasure.clearAllPoints(), this.pointMeasure.clearAllPoints(), this.angleMeasure.clearAllPoints(), this.areaMeasure.clearAllPoints(), this.slopeMeasure.clearAllPoints(); } // 清除所有测量 clearAll() { e(this.annotationData.normalAnnotation), e(this.annotationData.textAnnotation), e(this.annotationData.coordinateAnnotation), e(this.annotationData.angleAnnotation), e(this.annotationData.distanceAnnotation), e(this.annotationData.areaAnnotation), e(this.annotationData.slopeAnnotation), e(this.annotationData.elevationAnnotation), e(this.annotationData.volumeAnnotation); function e(t) { for (let n = 0; n < t.length; n++) t[n].container.remove(); t = []; } } // 更新标注 update() { this.isActive && this.tools.drawNormalAnnotation(); } } class Ny { engine; isActive = !1; isDrag = !1; meshs = []; box; pickPoint; pickNormal; pickMesh; box_; plane; constructor(e) { this.engine = e, this.meshs = [], this.box = null; } // 启动 active() { if (this.isActive == !0) return; this.isActive = !0, this.init(), this.engine.handelBehaved.init(this), this.engine.handelBehaved.active(); let e = this; e.engine.scene.children.filter((t) => t.type == "Mesh" && t.url).forEach((t) => { t.material && Array.isArray(t.material) ? t.material.forEach((n) => { n.clippingPlanes = e.engine.sectionPlane; }) : t.material.clippingPlanes = e.engine.sectionPlane, e.engine.clipping.clippingStencil.addMesh(e.engine.sectionPlane.find((n) => n.name == "前"), t); }); } disActive() { this.isActive = !1, this.engine.handelBehaved.disActive(); } // 初始化 init() { let e = this.engine.octreeBox.getBoundingBox(); this.box = e, this.updata_face(e); } // 更新面 updata_face(e) { let t = this, n = t.engine.scene.children.find((a) => a.type == "Group" && a.name == "ClippingBox"); n == null && (n = new $t(), n.name = "ClippingBox", t.engine.scene.add(n)); let i = [ new R(e.min.x, e.min.y, e.min.z), new R(e.max.x, e.min.y, e.min.z), new R(e.max.x, e.max.y, e.min.z), new R(e.min.x, e.max.y, e.min.z) ]; r(i, new R(0, 0, -1), "前"); function r(a, o, l) { const c = new xt(), h = new Float32Array([ a[0].x, a[0].y, a[0].z, // 点1 a[1].x, a[1].y, a[1].z, // 点2 a[2].x, a[2].y, a[2].z, // 点3 a[3].x, a[3].y, a[3].z // 点4 ]), u = [ 0, 1, 2, // 第一个三角形 0, 2, 3 // 第二个三角形 ]; c.setAttribute("position", new gt(h, 3)), c.setIndex(u); let f = t.meshs.find((m) => m.name == l); if (f == null) { const m = new Nt({ color: 65280, // 绿色 transparent: !0, opacity: 0.02, side: Dt // 双面渲染 }), v = new ft(c, m); v.normal = o, v.name = l, n.add(v), t.meshs.push(v); } else f.geometry = c; const d = new Float32Array([ a[0].x, a[0].y, a[0].z, // 点1 a[1].x, a[1].y, a[1].z, // 点2 a[2].x, a[2].y, a[2].z, // 点3 a[3].x, a[3].y, a[3].z, // 点4 a[0].x, a[0].y, a[0].z // 点1 ]); let p = new Bi({ color: 255 }), g = new xt(); g.setAttribute("position", new gt(d, 3)); let x = t.meshs.find((m) => m.name == l + "Line"); x == null && (x = new Oi(g, p), x.name = l + "Line", n.add(x), t.meshs.push(x)), x.geometry = g, x.material = p, t.engine.sectionPlane.find((m) => m.name == l).setFromNormalAndCoplanarPoint(o.clone().setLength(-1), e.min); } } // 重写鼠标按下事件 handleMouseDown(e) { this.isDrag = !0; const t = e.raycaster.intersectObjects(this.meshs, !1); if (t != null && t.length > 0) if (this.pickPoint = t[0].point, this.pickNormal = t[0].face.normal, this.engine.controls.enabled = !1, this.pickMesh = t[0].object, this.box_ = { min: this.box.min.clone(), max: this.box.max.clone() }, this.pickNormal.y == 0) { const n = new Ct(); n.setFromNormalAndCoplanarPoint(new R(0, 1, 0), this.pickPoint), this.plane = n; } else { let n = new R(this.engine.camera.position.x, this.pickPoint.y, this.engine.camera.position.z); const i = new Ct(); i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1), this.pickPoint), this.plane = i; } } handleMouseUp(e) { this.isDrag = !1, this.pickPoint = null, this.pickNormal = null, this.pickMesh = null, this.engine.controls.enabled = !0; } handleMouseMove(e) { this.meshs.forEach((n) => { n.material.opacity = 0; }); const t = e.raycaster.intersectObjects(this.meshs, !1); if (t != null && t.length > 0 && (t[0].object.material.opacity = 0.05), this.pickPoint != null) { const n = new R(); if (e.raycaster.ray.intersectPlane(this.plane, n)) { let i = n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone()); this.pickMesh.name == "前" || this.pickMesh.name == "左" || this.pickMesh.name == "底" ? this.box.min = this.box_.min.clone().add(this.pickNormal.clone().setLength(i)) : this.box.max = this.box_.max.clone().add(this.pickNormal.clone().setLength(i)), this.updata_face(this.box); } } } } class ky { engine; isActive = !1; isDrag = !1; meshs = []; box; pickPoint; pickNormal; pickMesh; box_; plane; constructor(e) { this.engine = e, this.meshs = [], this.box = null; } // 启动 active() { this.isActive != !0 && (this.isActive = !0, this.init(), this.engine.handelBehaved.init(this), this.engine.handelBehaved.active()); } disActive() { this.isActive = !1, this.engine.handelBehaved.disActive(); } // 初始化 init() { let e = this.engine.octreeBox.getBoundingBox(); this.box = e, this.updata_face(e); } // 更新面 updata_face(e) { let t = this, n = t.engine.scene.children.find((a) => a.type == "Group" && a.name == "ClippingBox"); n == null && (n = new $t(), n.name = "ClippingBox", t.engine.scene.add(n)); let i = [ new R(e.min.x, e.max.y, e.min.z), new R(e.max.x, e.max.y, e.min.z), new R(e.max.x, e.max.y, e.max.z), new R(e.min.x, e.max.y, e.max.z) ]; r(i, new R(0, 1, 0), "顶"); function r(a, o, l) { const c = new xt(), h = new Float32Array([ a[0].x, a[0].y, a[0].z, // 点1 a[1].x, a[1].y, a[1].z, // 点2 a[2].x, a[2].y, a[2].z, // 点3 a[3].x, a[3].y, a[3].z // 点4 ]), u = [ 0, 1, 2, // 第一个三角形 0, 2, 3 // 第二个三角形 ]; c.setAttribute("position", new gt(h, 3)), c.setIndex(u); let f = t.meshs.find((m) => m.name == l); if (f == null) { const m = new Nt({ color: 65280, // 绿色 transparent: !0, opacity: 0.02, side: Dt // 双面渲染 }), v = new ft(c, m); v.normal = o, v.name = l, n.add(v), t.meshs.push(v); } else f.geometry = c; const d = new Float32Array([ a[0].x, a[0].y, a[0].z, // 点1 a[1].x, a[1].y, a[1].z, // 点2 a[2].x, a[2].y, a[2].z, // 点3 a[3].x, a[3].y, a[3].z, // 点4 a[0].x, a[0].y, a[0].z // 点1 ]); let p = new Bi({ color: 255 }), g = new xt(); g.setAttribute("position", new gt(d, 3)); let x = t.meshs.find((m) => m.name == l + "Line"); x == null && (x = new Oi(g, p), x.name = l + "Line", n.add(x), t.meshs.push(x)), x.geometry = g, x.material = p, t.engine.sectionPlane.find((m) => m.name == l).setFromNormalAndCoplanarPoint(o.clone().setLength(-1), e.max), t.engine.scene.children.filter((m) => m.type == "Mesh" && m.url).forEach((m) => { m.material && Array.isArray(m.material) ? m.material.forEach((v) => { v.clippingPlanes = t.engine.sectionPlane; }) : m.material.clippingPlanes = t.engine.sectionPlane; }); } } // 重写鼠标按下事件 handleMouseDown(e) { this.isDrag = !0; const t = e.raycaster.intersectObjects(this.meshs, !1); if (t != null && t.length > 0) if (this.pickPoint = t[0].point, this.pickNormal = t[0].face.normal, this.engine.controls.enabled = !1, this.pickMesh = t[0].object, this.box_ = { min: this.box.min.clone(), max: this.box.max.clone() }, this.pickNormal.y == 0) { const n = new Ct(); n.setFromNormalAndCoplanarPoint(new R(0, 1, 0), this.pickPoint), this.plane = n; } else { let n = new R(this.engine.camera.position.x, this.pickPoint.y, this.engine.camera.position.z); const i = new Ct(); i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1), this.pickPoint), this.plane = i; } } handleMouseUp(e) { this.isDrag = !1, this.pickPoint = null, this.pickNormal = null, this.pickMesh = null, this.engine.controls.enabled = !0; } handleMouseMove(e) { this.meshs.forEach((n) => { n.material.opacity = 0; }); const t = e.raycaster.intersectObjects(this.meshs, !1); if (t != null && t.length > 0 && (t[0].object.material.opacity = 0.05), this.pickPoint != null) { const n = new R(); if (e.raycaster.ray.intersectPlane(this.plane, n)) { let i = n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone()); this.pickMesh.name == "前" || this.pickMesh.name == "左" || this.pickMesh.name == "底" ? this.box.min = this.box_.min.clone().add(this.pickNormal.clone().setLength(i)) : this.box.max = this.box_.max.clone().add(this.pickNormal.clone().setLength(i)), this.updata_face(this.box); } } } } class Uy { engine; isActive = !1; isDrag = !1; meshs = []; box; pickPoint; pickNormal; pickMesh; box_; plane; constructor(e) { this.engine = e, this.meshs = [], this.box = null; } // 启动 active() { this.isActive != !0 && (this.isActive = !0, this.init(), this.engine.handelBehaved.init(this), this.engine.handelBehaved.active()); } disActive() { this.isActive = !1, this.engine.handelBehaved.disActive(); } // 初始化 init() { let e = this.engine.octreeBox.getBoundingBox(); this.box = e, this.updata_face(e); } // 更新面 updata_face(e) { let t = this, n = t.engine.scene.children.find((a) => a.type == "Group" && a.name == "ClippingBox"); n == null && (n = new $t(), n.name = "ClippingBox", t.engine.scene.add(n)); let i = [ new R(e.min.x, e.min.y, e.max.z), new R(e.min.x, e.min.y, e.min.z), new R(e.min.x, e.max.y, e.min.z), new R(e.min.x, e.max.y, e.max.z) ]; r(i, new R(-1, 0, 0), "左"); function r(a, o, l) { const c = new xt(), h = new Float32Array([ a[0].x, a[0].y, a[0].z, // 点1 a[1].x, a[1].y, a[1].z, // 点2 a[2].x, a[2].y, a[2].z, // 点3 a[3].x, a[3].y, a[3].z // 点4 ]), u = [ 0, 1, 2, // 第一个三角形 0, 2, 3 // 第二个三角形 ]; c.setAttribute("position", new gt(h, 3)), c.setIndex(u); let f = t.meshs.find((m) => m.name == l); if (f == null) { const m = new Nt({ color: 65280, // 绿色 transparent: !0, opacity: 0.02, side: Dt // 双面渲染 }), v = new ft(c, m); v.normal = o, v.name = l, n.add(v), t.meshs.push(v); } else f.geometry = c; const d = new Float32Array([ a[0].x, a[0].y, a[0].z, // 点1 a[1].x, a[1].y, a[1].z, // 点2 a[2].x, a[2].y, a[2].z, // 点3 a[3].x, a[3].y, a[3].z, // 点4 a[0].x, a[0].y, a[0].z // 点1 ]); let p = new Bi({ color: 255 }), g = new xt(); g.setAttribute("position", new gt(d, 3)); let x = t.meshs.find((m) => m.name == l + "Line"); x == null && (x = new Oi(g, p), x.name = l + "Line", n.add(x), t.meshs.push(x)), x.geometry = g, x.material = p, t.engine.sectionPlane.find((m) => m.name == l).setFromNormalAndCoplanarPoint(o.clone().setLength(-1), e.min), t.engine.scene.children.filter((m) => m.type == "Mesh" && m.url).forEach((m) => { m.material && Array.isArray(m.material) ? m.material.forEach((v) => { v.clippingPlanes = t.engine.sectionPlane; }) : m.material.clippingPlanes = t.engine.sectionPlane; }); } } // 重写鼠标按下事件 handleMouseDown(e) { this.isDrag = !0; const t = e.raycaster.intersectObjects(this.meshs, !1); if (t != null && t.length > 0) if (this.pickPoint = t[0].point, this.pickNormal = t[0].face.normal, this.engine.controls.enabled = !1, this.pickMesh = t[0].object, this.box_ = { min: this.box.min.clone(), max: this.box.max.clone() }, this.pickNormal.y == 0) { const n = new Ct(); n.setFromNormalAndCoplanarPoint(new R(0, 1, 0), this.pickPoint), this.plane = n; } else { let n = new R(this.engine.camera.position.x, this.pickPoint.y, this.engine.camera.position.z); const i = new Ct(); i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1), this.pickPoint), this.plane = i; } } handleMouseUp(e) { this.isDrag = !1, this.pickPoint = null, this.pickNormal = null, this.pickMesh = null, this.engine.controls.enabled = !0; } handleMouseMove(e) { this.meshs.forEach((n) => { n.material.opacity = 0; }); const t = e.raycaster.intersectObjects(this.meshs, !1); if (t != null && t.length > 0 && (t[0].object.material.opacity = 0.05), this.pickPoint != null) { const n = new R(); if (e.raycaster.ray.intersectPlane(this.plane, n)) { let i = n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone()); this.pickMesh.name == "前" || this.pickMesh.name == "左" || this.pickMesh.name == "底" ? this.box.min = this.box_.min.clone().add(this.pickNormal.clone().setLength(i)) : this.box.max = this.box_.max.clone().add(this.pickNormal.clone().setLength(i)), this.updata_face(this.box); } } } } class By { engine; isActive = !1; box; pickPoint; pickNormal; pickMesh; box_; plane; meshs; isDrag = !1; constructor(e) { this.engine = e, this.meshs = []; } active() { this.isActive = !0, this.init(), this.engine.handelBehaved.init(this), this.engine.handelBehaved.active(); } disActive() { this.isActive = !1, this.engine.handelBehaved.disActive(); } // 初始化 init() { let e = this.engine.octreeBox.getBoundingBox(); this.box = e, this.updata_face(e); } // 获取xyz值 getboxXyz() { return { minX: this.box.min.x, minY: this.box.min.y, minZ: this.box.min.z, maxX: this.box.max.x, maxY: this.box.max.y, maxZ: this.box.max.z }; } setboxXyz(e) { this.box.min.x = e.minX, this.box.min.y = e.minY, this.box.min.z = e.minZ, this.box.max.x = e.maxX, this.box.max.y = e.maxY, this.box.max.z = e.maxZ, this.updata_face(this.box); } // 设置剖切的box setBox(e) { this.box = e, this.updata_face(e); } // 反向剖切 reverseBox() { } // 重写鼠标按下事件 handleMouseDown(e) { this.isDrag = !0; const t = e.raycaster.intersectObjects(this.meshs, !1); if (t != null && t.length > 0) if (this.pickPoint = t[0].point, this.pickNormal = t[0].face.normal, this.engine.controls.enabled = !1, this.pickMesh = t[0].object, this.box_ = { min: this.box.min.clone(), max: this.box.max.clone() }, this.pickNormal.y == 0) { const n = new Ct(); n.setFromNormalAndCoplanarPoint(new R(0, 1, 0), this.pickPoint), this.plane = n; } else { let n = new R(this.engine.camera.position.x, this.pickPoint.y, this.engine.camera.position.z); const i = new Ct(); i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1), this.pickPoint), this.plane = i; } } handleMouseUp(e) { this.isDrag = !1, this.pickPoint = null, this.pickNormal = null, this.pickMesh = null, this.engine.controls.enabled = !0; } handleMouseMove(e) { this.meshs.forEach((n) => { n.material.opacity = 0; }); const t = e.raycaster.intersectObjects(this.meshs, !1); if (t != null && t.length > 0 && (t[0].object.material.opacity = 0.05), this.pickPoint != null) { const n = new R(); if (e.raycaster.ray.intersectPlane(this.plane, n)) { let i = n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone()); this.pickMesh.name == "前" || this.pickMesh.name == "左" || this.pickMesh.name == "底" ? this.box.min = this.box_.min.clone().add(this.pickNormal.clone().setLength(i)) : this.box.max = this.box_.max.clone().add(this.pickNormal.clone().setLength(i)), this.updata_face(this.box); } } } // 更新面 updata_face(e) { let t = this, n = [ new R(e.min.x, e.min.y, e.min.z), new R(e.max.x, e.min.y, e.min.z), new R(e.max.x, e.max.y, e.min.z), new R(e.min.x, e.max.y, e.min.z) ], i = [ new R(e.min.x, e.min.y, e.max.z), new R(e.max.x, e.min.y, e.max.z), new R(e.max.x, e.max.y, e.max.z), new R(e.min.x, e.max.y, e.max.z) ], r = [ new R(e.max.x, e.min.y, e.max.z), new R(e.max.x, e.min.y, e.min.z), new R(e.max.x, e.max.y, e.min.z), new R(e.max.x, e.max.y, e.max.z) ], a = [ new R(e.min.x, e.min.y, e.min.z), new R(e.min.x, e.min.y, e.max.z), new R(e.min.x, e.max.y, e.max.z), new R(e.min.x, e.max.y, e.min.z) ], o = [ new R(e.min.x, e.max.y, e.min.z), new R(e.max.x, e.max.y, e.min.z), new R(e.max.x, e.max.y, e.max.z), new R(e.min.x, e.max.y, e.max.z) ], l = [ new R(e.min.x, e.min.y, e.min.z), new R(e.max.x, e.min.y, e.min.z), new R(e.max.x, e.min.y, e.max.z), new R(e.min.x, e.min.y, e.max.z) ]; c(n, new R(0, 0, -1), "前"), c(i, new R(0, 0, 1), "后"), c(r, new R(1, 0, 0), "右"), c(a, new R(-1, 0, 0), "左"), c(o, new R(0, 1, 0), "顶"), c(l, new R(0, -1, 0), "底"); function c(h, u, f) { const d = new xt(), p = new Float32Array([ h[0].x, h[0].y, h[0].z, // 点1 h[1].x, h[1].y, h[1].z, // 点2 h[2].x, h[2].y, h[2].z, // 点3 h[3].x, h[3].y, h[3].z // 点4 ]), g = [ 0, 1, 2, // 第一个三角形 0, 2, 3 // 第二个三角形 ]; d.setAttribute("position", new gt(p, 3)), d.setIndex(g); let x = t.engine.scene.children.find((T) => T.type == "Group" && T.name == "ClippingBox"); x == null && (x = new $t(), x.name = "ClippingBox", t.engine.scene.add(x)); let m = t.meshs.find((T) => T.name == f); if (m == null) { const T = new Nt({ color: 65280, // 绿色 transparent: !0, opacity: 0, side: Dt // 双面渲染 }), D = new ft(d, T); D.normal = u, D.name = f, x.add(D), t.meshs.push(D); } else m.geometry = d; const v = new Float32Array([ h[0].x, h[0].y, h[0].z, // 点1 h[1].x, h[1].y, h[1].z, // 点2 h[2].x, h[2].y, h[2].z, // 点3 h[3].x, h[3].y, h[3].z, // 点4 h[0].x, h[0].y, h[0].z // 点1 ]); let b = new Bi({ color: 255 }), M = new xt(); M.setAttribute("position", new gt(v, 3)); let C = t.meshs.find((T) => T.name == f + "Line"); C == null && (C = new Oi(M, b), C.name = f + "Line", x.add(C), t.meshs.push(C)), C.geometry = M, C.material = b, f == "前" || f == "左" || f == "底" ? t.engine.sectionPlane.find((T) => T.name == f).setFromNormalAndCoplanarPoint(u.clone().setLength(-1), e.min) : t.engine.sectionPlane.find((T) => T.name == f).setFromNormalAndCoplanarPoint(u.clone().setLength(-1), e.max), t.engine.scene.children.filter((T) => T.type == "Mesh" && T.url).forEach((T) => { T.material && Array.isArray(T.material) ? T.material.forEach((D) => { D.clippingPlanes = t.engine.sectionPlane; }) : T.material.clippingPlanes = t.engine.sectionPlane; }); } } } class Oy { engine; planeObjects = []; planes = []; isActive = !1; planeSize = 100; // 缓存平面大小,避免每帧计算 constructor(e) { this.engine = e; } init() { this.calculateSceneSize(); const e = new Ii(this.planeSize, this.planeSize); let t = 0; this.planes.forEach((n) => { const i = new $t(), r = new Cs({ color: new Fe(8421504), metalness: 0.1, roughness: 0.75, clippingPlanes: this.planes.filter((o) => o !== n), stencilWrite: !0, stencilRef: 0, stencilFunc: Qf, stencilFail: Va, stencilZFail: Va, stencilZPass: Va, side: Dt, depthWrite: !0, depthTest: !0 }), a = new ft(e, r); a.onAfterRender = function(o) { o.clearStencil(); }, a.renderOrder = t + 1.1, a.visible = !1, this.planeObjects.push(a), t = t + 1, i.add(a), this.engine.scene.add(i); }); } active() { this.isActive = !0, this.planeObjects.forEach((e) => { e.visible = !0; }); } disActive() { this.isActive = !1, this.planeObjects.forEach((e) => { e.visible = !1; }); } // 计算场景大小(只在初始化和添加模型时调用) calculateSceneSize() { const e = new zt(); if (this.engine.scene.traverse((t) => { if (t.isMesh && t.geometry) { const n = new zt().setFromObject(t); e.union(n); } }), e.isEmpty()) this.planeSize = 100; else { const t = e.getSize(new R()), n = Math.max(t.x, t.y, t.z); this.planeSize = n * 2; } } // 添加模型 addMesh(e, t) { const n = this.createPlaneStencilGroup(t.geometry.clone(), e, 1); this.engine.scene.add(n), this.calculateSceneSize(), this.updatePlaneGeometry(); } // 更新平面几何体大小 updatePlaneGeometry() { const e = new Ii(this.planeSize, this.planeSize); this.planeObjects.forEach((t) => { t.geometry.dispose(), t.geometry = e; }); } // 生成补面模型 createPlaneStencilGroup(e, t, n) { const i = new $t(), r = new Nt(); r.depthWrite = !1, r.depthTest = !1, r.colorWrite = !1, r.stencilWrite = !0, r.stencilFunc = Al; const a = r.clone(); a.side = Jt, a.clippingPlanes = [t], a.stencilFail = Ga, a.stencilZFail = Ga, a.stencilZPass = Ga; const o = new ft(e, a); o.renderOrder = n, i.add(o); const l = r.clone(); l.side = Rn, l.clippingPlanes = [t], l.stencilFail = Wa, l.stencilZFail = Wa, l.stencilZPass = Wa; const c = new ft(e, l); return c.renderOrder = n, i.add(c), i; } // 更新 updata() { if (this.isActive) for (let e = 0; e < this.planeObjects.length; e++) { const t = this.planes[e], n = this.planeObjects[e]; Math.abs(t.constant) < 99999 ? (n.visible = !0, t.coplanarPoint(n.position), n.lookAt( n.position.x - t.normal.x, n.position.y - t.normal.y, n.position.z - t.normal.z )) : n.visible = !1; } } } class Fy { engine; sectionPlaneX; sectionPlaneY; sectionPlaneZ; sectionBox; clippingStencil; constructor(e) { this.engine = e, this.sectionPlaneX = new Ny(e), this.sectionPlaneY = new ky(e), this.sectionPlaneZ = new Uy(e), this.sectionBox = new By(e); let t = new Ct(new R(0, 0, 1), 1e5); t.name = "前"; let n = new Ct(new R(0, 0, 1), 1e5); n.name = "左"; let i = new Ct(new R(0, 0, 1), 1e5); i.name = "后"; let r = new Ct(new R(0, 0, 1), 1e5); r.name = "右"; let a = new Ct(new R(0, 0, 1), 1e5); a.name = "顶"; let o = new Ct(new R(0, 0, 1), 1e5); o.name = "底", this.engine.sectionPlane = [t, n, i, r, a, o], this.clippingStencil = new Oy(e), this.clippingStencil.planes = [t, n, i, r, a, o], this.clippingStencil.init(), this.clippingStencil.active(); } disActive() { this.sectionPlaneX.disActive(), this.sectionPlaneY.disActive(), this.sectionPlaneZ.disActive(), this.sectionBox.disActive(); } } class zy { engine; constructor(e) { this.engine = e; } // 获取模型树数据 getTreeData() { let e = []; return this.engine.engineStatus.models.forEach((t) => { e.push({ children: t.info.modelTree.modelTreeLevel, name: t.info.baseInfo.name }); }), e; } } class Hy { engine; constructor(e) { this.engine = e; } /** * 获取引擎统计信息 * 统计场景中所有网格的顶点数和三角面数 * @returns 返回包含顶点数和三角面数的对象 */ getEngineInfo() { let e = 0, t = 0, n = 0; return !this.engine || !this.engine.scene ? { totalVertices: 0, totalTriangles: 0, meshCount: 0 } : (this.engine.scene.traverse((i) => { if (i instanceof ft) { const r = i.geometry; if (r && r.attributes) { const a = r.attributes.position; if (a) { const o = a.count; e += o; let l = 0; r.index ? l = r.index.count / 3 : l = o / 3, t += l, n++; } } } }), { totalVertices: Math.floor(e), totalTriangles: Math.floor(t), meshCount: n }); } } class Vy { engine; constructor(e) { this.engine = e; } init() { } // 查询构件属性 getModelProperties(e, t, n) { let i = this.engine.engineStatus.models.find((a) => a.url === e); i.properties == null && rf(e + "/property.zip", (a) => { let o = JSON.parse(a); i.properties = o, setTimeout(() => { r(o, t, n); }, 100); }), r(i.properties, t, n); function r(a, o, l) { let c = [], h = a.models[o.toString() || ""], u = h.map((f) => f[0]); u = u.filter((f, d) => u.indexOf(f) === d), u.forEach((f) => { let d = { name: a.categorys[f], children: [] }; c.push(d), h.filter((p) => p[0] === f).forEach((p) => { d.children.push({ name: a.names[p[1]], value: a.values[p[2]] }); }); }), l?.({ properties: c, materials: [] }); } } } class Gy { engine; constructor(e) { this.engine = e; } // 获取模型中所有的类型 getModelTypes() { let e = []; this.engine.engineStatus.models.forEach((t) => { t.info.modelMapper.forEach((n) => { e.push(n.typeName); }); }); } // 获取模型中所有的专业 getModelMajors() { let e = []; this.engine.engineStatus.models.forEach((t) => { t.info.modelMapper.forEach((n) => { e.push(n.majorName); }); }); } // 获取模型中所有的楼层 getModelLevels() { let e = []; this.engine.engineStatus.models.forEach((t) => { t.info.modelMapper.forEach((n) => { e.push(n.levelName); }); }); } // 批量获取模型映射 getModelMappers(e) { } // 获取模型的mapper getModelMapper(e, t) { let n = this.engine.engineStatus.models.find((i) => i.url == e); return n ? n.info.modelMapper.find((i) => i.id == t) : null; } // 获取通类构件 getModelSWithType(e, t) { let n = []; return this.engine.engineStatus.models.forEach((i) => { let r = { url: i.url, ids: [] }; n.push(r), i.info.modelMapper.filter((a) => a.typeName === e).forEach((a) => { r.ids.push(Number(a.id)); }); }), t(n), n; } // 获取同层构件 getModelSWithLevel(e, t) { let n = []; return this.engine.engineStatus.models.forEach((i) => { let r = { url: i.url, ids: [] }; n.push(r), i.info.modelMapper.filter((a) => a.levelName === e).forEach((a) => { r.ids.push(Number(a.id)); }); }), t(n), n; } // 获取通专业构件 getModelsWithMajor(e, t) { let n = []; return this.engine.engineStatus.models.forEach((i) => { let r = { url: i.url, ids: [] }; n.push(r), i.info.modelMapper.filter((a) => a.majorName === e).forEach((a) => { r.ids.push(Number(a.id)); }); }), t(n), n; } } class Wy { engine; isActive = !1; groupEdge; material; indexes = /* @__PURE__ */ new Map(); constructor(e) { this.engine = e, this.groupEdge = this.engine.scene.getObjectByName("groupEdge"), this.material = new Bi({ color: "#000000", depthTest: !0 }); } // 启动 active() { this.isActive = !0, this.groupEdge.visible = !0, this.show(); } // 关闭 disActive() { this.isActive = !1, this.groupEdge.visible = !1; } // 显示模型边线 show() { this.engine.engineStatus.models.forEach((e) => { if (!this.groupEdge.children.find((t) => t.url == e.url)) { let t = e.info, n = [], i = /* @__PURE__ */ new Map(); t.modelEdge.forEach((o) => { let l = n.length; for (let c = 0; c < o.points.length; c++) o.points[c].length == 2 && (n.push(o.points[c][0].X), n.push(o.points[c][0].Z), n.push(-o.points[c][0].Y), n.push(o.points[c][1].X), n.push(o.points[c][1].Z), n.push(-o.points[c][1].Y)); i.set(Number(o.id), [l, n.length, o.points]); }), this.indexes.set(e.url, i); let r = new xt(); r.setAttribute("position", new an(n, 3)); const a = new cd(r, this.material); a.url = e.url, this.groupEdge.add(a); } }); } // 获取指定模型的边线 getModelEdge(e, t) { let n = this.indexes.get(e); if (n) { let i = n.get(t); if (i) return i; } return null; } //隐藏边线 hideModelEdge(e, t) { let n = this.indexes.get(e); if (n) { let i = n.get(t); if (i) { let [r, a, o] = i, l = this.groupEdge.children.find((c) => c.url == e); if (l) { let c = l.geometry.attributes.position.array; for (let h = r; h < a; h++) c[h] = NaN; l.geometry.attributes.position.needsUpdate = !0; } } } } // 显示边线 showModelEdge(e, t) { let n = this.indexes.get(e); if (n) { let i = n.get(t); if (i) { let [r, a, o] = i, l = this.groupEdge.children.find((c) => c.url == e); if (l) { let c = l.geometry.attributes.position.array, h = 0; for (let u = r; u < a; u += 3) { const f = Math.floor(h / 6), d = h % 6 >= 3; if (o[f] && o[f].length === 2) { const p = d ? o[f][1] : o[f][0]; c[u] = p.X, c[u + 1] = p.Z, c[u + 2] = -p.Y; } h += 3; } l.geometry.attributes.position.needsUpdate = !0; } } } } } class Xy { // 引擎参数 options; DeviceType; animationId = null; animate; // 基础模块 scene; camera; renderer; sceneModule; cameraModule; deviceModule; renderModule; controlModule; composerModule; loaderModule; engineStatus; events; lightModule; interactionModule; modelToolModule; worldToScreen; handelBehaved; octreeBox; controls; stats; catchSvg; // 功能模块 viewCube; rangeScale; setting; measure; clipping; modelTree; engineInfo; modelProperties; modelMapperBatch; modelEdge; // 业务数据 models = []; // 引擎容器 container; constructor(e) { if (this.options = e, this.container = document.getElementById(e.containerId), !this.container) throw new Error(`Container ${e.containerId} not found`); this.deviceModule = new ab(this), this.DeviceType = this.deviceModule.getDeviceType(), this.cameraModule = new rb(this), this.sceneModule = new sb(this), this.scene = this.sceneModule.scene, this.renderModule = new ob(this), this.renderer = this.renderModule.createRenderer(), this.camera = this.cameraModule.orthographicCamera, this.scene.camera = this.camera, this.controlModule = new Mb(this), this.controlModule.switchDefaultMode(), this.controls = this.controlModule.orbitControls, this.composerModule = new Bb(this), this.composerModule.init(), this.events = new ly(), this.engineStatus = new oy(this), this.engineStatus.init(), this.loaderModule = new ay(this), this.lightModule = new cy(this), this.lightModule.init(), this.viewCube = new yy(this), this.viewCube.init(), this.octreeBox = My(this), this.rangeScale = new Sy(this), this.rangeScale.init(), this.clipping = new Fy(this), this.setting = new wy(this), this.setting.init(), this.handelBehaved = lf(this), this.modelMapperBatch = new Gy(this), this.measure = new Iy(this), this.modelToolModule = new uy(this), this.modelProperties = new Vy(this), this.interactionModule = new hy(this), this.interactionModule.init(), this.interactionModule.active(), this.modelEdge = new Wy(this), this.modelTree = new zy(this), this.engineInfo = new Hy(this), this.worldToScreen = new vn(this.camera, this.renderer, this.scene), this.stats = new my(), this.stats.showPanel(0), this.stats.dom.style.position = "absolute", this.stats.dom.style.top = "0px", this.stats.dom.style.left = "0px", this.stats.dom.style.zIndex = "1000", this.container.appendChild(this.stats.dom); let t = document.createElementNS("http://www.w3.org/2000/svg", "svg"); t.style.position = "absolute", t.style.width = "100%", t.style.height = "100%", t.style.zIndex = "1000", t.style.left = "0px", t.style.top = "0px", t.style.pointerEvents = "none"; const n = this.renderer?.domElement.width || 1920, i = this.renderer?.domElement.height || 1080; t.setAttribute("viewBox", `0 0 ${n} ${i}`), t.setAttribute("preserveAspectRatio", "none"), this.container.appendChild(t), this.catchSvg = t, this.animate = () => { this.animationId = requestAnimationFrame(this.animate), this.stats && this.stats.begin(), this.composerModule, this.renderer?.render(this.scene, this.camera), this.viewCube.cubeTool.RenderScene(), this.measure.update(), this.controlModule.update(), this.clipping && this.clipping.clippingStencil && this.clipping.clippingStencil.updata(), this.stats && this.stats.end(); }, this.animate(); } } function jy(s) { return new Xy(s); } class Zy { /** 第三方 3D 引擎实例 */ engine = null; /** 引擎挂载的容器元素 */ container; /** 引擎容器 ID(用于传递给 createEngine) */ containerId; /** 引擎配置选项(不包含 container) */ options; /** 是否已初始化 */ _isInitialized = !1; /** 是否已销毁 */ _isDestroyed = !1; /** 主题订阅取消函数 */ unsubscribeTheme = null; /** 当前激活的测量类型 */ currentMeasureType = null; /** 主测量功能是否已激活 */ isMeasureActive = !1; /** * 构造函数 * @param options 3D 引擎配置选项 */ 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: "linear-gradient(to bottom, rgb(214, 224, 235), rgb(246, 250, 255))", // 固定背景渐变色 version: e.version ?? "v1", // 默认使用 v1 版本 showStats: e.showStats ?? !1, // 默认不显示统计 showViewCube: e.showViewCube ?? !0 // 默认显示视图立方体 }; } /** * 初始化组件 (接口实现) * 创建 div 容器并初始化引擎 */ init() { if (this._isInitialized) { console.warn("[Engine] Engine already initialized."); return; } if (this._isDestroyed) { console.error("[Engine] Cannot initialize destroyed engine."); return; } try { typeof this.options.backgroundColor == "string" && (this.container.style.background = this.options.backgroundColor); const e = { containerId: this.containerId, backgroundColor: this.options.backgroundColor, version: this.options.version, showStats: this.options.showStats, showViewCube: this.options.showViewCube }; if (console.log("引擎配置信息:", e), this.engine = jy(e), !this.engine) throw new Error("Failed to create engine instance"); this._isInitialized = !0, this.unsubscribeTheme = st.subscribe((t) => { this.setTheme(t); }), this.setTheme(st.getTheme()); } catch (e) { throw console.error("[Engine] Failed to initialize engine:", e), this._isInitialized = !1, e; } } /** * 设置主题 (接口实现) * 根据主题调整 3D 引擎的视觉效果(如背景色) * @param theme 全局主题配置 */ setTheme(e) { } /** * 设置语言 (接口实现) */ setLocales() { } /** * 检查是否已初始化 */ isInitialized() { return this._isInitialized; } /** * 加载 3D 模型 * @param url 模型文件 URL * @param options 加载选项(位置、旋转、缩放) */ 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.loaderModule.loadModels([e], t); } /** * 回到主视角 * @returns */ CameraGoHome() { this.engine.viewCube.CameraGoHome(); } /** * 获取原始 3D 引擎实例 */ getEngine() { return this.engine; } // ==================== 测量功能方法 ==================== /** * 激活具体测量类型的统一入口(私有方法) * @param type 测量类型 * @param activateFunc 第三方引擎的激活函数 */ activateMeasureType(e, t) { if (!this._isInitialized || !this.engine) { console.error("Cannot activate measure: engine not initialized."); return; } if (!this.engine.measure) { console.error("Measure module not available."); return; } this.isMeasureActive || (console.log("激活测测量功能"), this.engine.measure.active(), this.isMeasureActive = !0), t(), this.currentMeasureType = e; } /** * 激活距离测量 */ activateDistanceMeasure() { this.activateMeasureType("distance", () => { console.log("激活距离测量"), this.engine.measure.distanceMeasure.active(); }); } /** * 激活最小距离测量 */ activateMinDistanceMeasure() { this.activateMeasureType("minDistance", () => { console.log("激活最小距离测量"), this.engine.measure.minDistanceMeasure.active(); }); } /** * 激活角度测量 */ activateAngleMeasure() { this.activateMeasureType("angle", () => { console.log("激活角度测量"), this.engine.measure.angleMeasure.active(), console.log("[Engine] Angle measure activated (placeholder)"); }); } /** * 激活标高测量 */ activateElevationMeasure() { this.activateMeasureType("elevation", () => { console.log("激活标高测量"), this.engine.measure.elevationMeasure.active(); }); } /** * 激活体积测量 */ activateVolumeMeasure() { this.activateMeasureType("volume", () => { console.log("激活体积测量"), this.engine.measure.volumeMeasure.active(); }); } /** * 激活激光测距 */ activateLaserDistanceMeasure() { this.activateMeasureType("laserDistance", () => { console.log("[Engine] Laser distance measure activated (placeholder)"); }); } /** * 激活坡度测量 */ activateSlopeMeasure() { this.activateMeasureType("slope", () => { console.log("激活坡度测量"), this.engine.measure.slopeMeasure.active(); }); } /** * 激活空间体积测量 */ activateSpaceVolumeMeasure() { this.activateMeasureType("spaceVolume", () => { console.log("[Engine] Space volume measure activated (placeholder)"); }); } /** * 激活测量功能(根据类型统一入口) * @param mode 测量类型 */ activateMeasure(e) { switch (e) { case "distance": this.activateDistanceMeasure(); break; case "minDistance": this.activateMinDistanceMeasure(); break; case "angle": this.activateAngleMeasure(); break; case "elevation": this.activateElevationMeasure(); break; case "volume": this.activateVolumeMeasure(); break; case "laserDistance": this.activateLaserDistanceMeasure(); break; case "slope": this.activateSlopeMeasure(); break; case "spaceVolume": this.activateSpaceVolumeMeasure(); break; } } /** * 停用测量功能(关闭测量时调用) */ deactivateMeasure() { !this._isInitialized || !this.engine?.measure || this.isMeasureActive && (console.log("停用测量功能"), this.engine.measure.disActive(), this.isMeasureActive = !1, this.currentMeasureType = null); } /** * 获取当前激活的测量类型 * @returns 当前测量类型,如果未激活则返回 null */ getCurrentMeasureType() { return this.currentMeasureType; } // ==================== 结束:测量功能方法 ==================== /** * 销毁组件 (接口实现) * 清理资源、取消订阅、销毁引擎实例 */ destroy() { this._isDestroyed || (this.deactivateMeasure(), this.unsubscribeTheme && (this.unsubscribeTheme(), this.unsubscribeTheme = null), this.container.innerHTML = "", this.currentMeasureType = null, this.isMeasureActive = !1, this._isDestroyed = !0, this._isInitialized = !1); } } class qy { element; content = null; isVisible = !1; onCloseCallback; options; mouseDownTime = 0; CLICK_THRESHOLD = 200; // ms 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(); }; /** * 设置关闭时的回调函数 * 通常用于通知 Manager 状态变更 */ setOnClose(e) { this.onCloseCallback = e; } /** * 挂载内容组件 * @param content 实现了 IRightKeyContent 接口的组件实例 */ mount(e) { this.unmountContent(), this.content = e, this.element.appendChild(e.getElement()); } /** * 卸载当前内容 */ unmountContent() { this.content && (this.content.destroy(), this.element.innerHTML = "", this.content = null); } /** * 在指定位置显示容器 * 包含智能边界检测逻辑,防止溢出屏幕 * @param x 目标 X 坐标 (通常是鼠标点击位置) * @param y 目标 Y 坐标 */ show(e, t) { this.element.classList.add("visible"), this.isVisible = !0, this.element.style.left = `${e}px`, this.element.style.top = `${t}px`; const n = this.element.getBoundingClientRect(), i = window.innerWidth, r = window.innerHeight; let a = e, o = t; e + n.width > i && (a = e - n.width), t + n.height > r && (o = t - n.height), this.element.style.left = `${a}px`, this.element.style.top = `${o}px`; } /** * 隐藏容器 */ hide() { this.element.classList.remove("visible"), this.isVisible = !1, this.unmountContent(), this.onCloseCallback && this.onCloseCallback(); } /** * 处理全局点击事件 * 用于检测是否点击了容器外部 */ handleGlobalClick = (e) => { this.isVisible && (this.element.contains(e.target) || this.hide()); }; } class yc { element; options; unsubscribeLocale = null; unsubscribeTheme = null; // 当前激活的子菜单引用,用于自动关闭 activeSubMenu = null; constructor(e) { this.options = e, this.element = document.createElement("ul"), this.element.className = "bim-menu"; } /** * 初始化组件 * 渲染 DOM 结构并订阅语言变更 */ init() { this.render(), this.unsubscribeLocale = Vt.subscribe(() => { this.setLocales(); }), this.unsubscribeTheme = st.subscribe((e) => { this.setTheme(e); }); } /** * 设置主题 * @param theme 全局主题配置 */ setTheme(e) { const t = this.element.style; t.setProperty("--bim-bg-elevated", e.bgElevated), t.setProperty("--bim-text-primary", e.textPrimary), t.setProperty("--bim-divider", e.divider), t.setProperty("--bim-component-bg-hover", e.componentBgHover), t.setProperty("--bim-shadow-lg", e.shadowLg); } /** * 响应语言变更 * 重新渲染整个菜单以更新文本 */ setLocales() { this.element.innerHTML = "", this.render(); } /** * 销毁组件 * 清理事件监听、子菜单和 DOM 元素 */ destroy() { this.unsubscribeLocale && (this.unsubscribeLocale(), this.unsubscribeLocale = null), this.unsubscribeTheme && (this.unsubscribeTheme(), this.unsubscribeTheme = null), this.closeSubMenu(), this.element.remove(); } /** * 获取组件根元素 * 实现 IRightKeyContent 接口,允许被 RightKey 容器挂载 */ getElement() { return this.element; } /** * 核心渲染逻辑 * 处理分组、排序和 DOM 生成 */ render() { const { items: e, groupOrder: t } = this.options, n = /* @__PURE__ */ new Map(), i = "default"; e.forEach((a) => { const o = a.group || i; n.has(o) || n.set(o, []), n.get(o).push(a); }); let r = []; if (t) { r = t.filter((a) => n.has(a)); for (const a of n.keys()) r.includes(a) || r.push(a); } else r = Array.from(n.keys()); r.forEach((a, o) => { if (o > 0) { const c = document.createElement("li"); c.className = "bim-menu-divider", this.element.appendChild(c); } const l = n.get(a); l.sort((c, h) => (c.order || 0) - (h.order || 0)), l.forEach((c) => { c.visible !== !1 && this.element.appendChild(this.createItemElement(c)); }); }); } /** * 创建单个菜单项的 DOM 元素 */ createItemElement(e) { const t = document.createElement("li"), n = !e.disabled; t.className = `bim-menu-item ${n ? "" : "disabled"}`; const i = document.createElement("div"); i.className = "bim-menu-item-icon", e.icon && (i.innerHTML = e.icon), t.appendChild(i); const r = document.createElement("div"); r.className = "bim-menu-item-label", r.textContent = Ae(e.label), t.appendChild(r); const a = e.children, o = a && a.length > 0; if (o) { const l = document.createElement("div"); l.className = "bim-menu-item-arrow", l.innerHTML = '', t.appendChild(l), t.addEventListener("mouseenter", () => this.openSubMenu(e, t)); } else t.addEventListener("mouseenter", () => this.closeSubMenu()); return n && t.addEventListener("click", (l) => { l.stopPropagation(), console.log(`[BimMenu] Clicked item: ${e.id}`), o || (e.onClick ? (console.log(`[BimMenu] Executing onClick for ${e.id}`), e.onClick()) : console.warn(`[BimMenu] No onClick handler for ${e.id}`)); }), t; } /** * 打开子菜单 * @param item 当前菜单项 * @param parentLi 触发的 DOM 元素(用于定位) */ openSubMenu(e, t) { const n = e.children; if (!n || n.length === 0) return; this.closeSubMenu(); const i = document.createElement("div"); i.style.position = "fixed", i.style.zIndex = "10001"; const r = t.getBoundingClientRect(); i.style.top = `${r.top}px`, i.style.left = `${r.right}px`, i.addEventListener("mousedown", (l) => l.stopPropagation()); const a = new yc({ items: n }); a.init(), i.appendChild(a.element), document.body.appendChild(i), this.activeSubMenu = { menu: a, container: i }; const o = i.getBoundingClientRect(); o.right > window.innerWidth && (i.style.left = `${r.left - o.width}px`); } /** * 关闭当前激活的子菜单 */ closeSubMenu() { this.activeSubMenu && (this.activeSubMenu.menu.destroy(), this.activeSubMenu.container.remove(), this.activeSubMenu = null); } } class hf extends hn { container; rightKeyPanel; // 存储注册的上下文处理器 // 每个处理器接收鼠标事件,返回一组菜单项(如果没有对应菜单则返回 null) contextHandlers = []; constructor(e, t) { super(e), this.container = t, this.rightKeyPanel = new qy({ zIndex: 9e3, container: this.container, onContext: this.handleContextMenu }), this.rightKeyPanel.init(); } destroy() { this.rightKeyPanel.destroy(); } /** * 注册上下文菜单处理器 * @param handler 处理函数,接收鼠标事件,返回菜单项数组 */ registerHandler(e) { this.contextHandlers.push(e); } /** * 手动显示菜单 * 允许外部直接调用以显示特定的菜单,不一定依赖右键事件 * @param x 屏幕 X 坐标 * @param y 屏幕 Y 坐标 * @param items 菜单项列表 * @param groupOrder 可选的分组顺序 */ showMenu(e, t, n, i) { if (!n || n.length === 0) return; const r = new yc({ items: n, groupOrder: i }); r.init(), this.rightKeyPanel.mount(r), this.rightKeyPanel.show(e, t); } /** * 隐藏右键菜单 */ hide() { this.rightKeyPanel.hide(); } /** * 处理右键点击事件 * 由 BimRightKey 组件在检测到有效右键点击时调用 */ handleContextMenu = (e) => { let t = null; for (const n of this.contextHandlers) { const i = n(e); i && i.length > 0 && (t || (t = []), t = t.concat(i)); } t && t.length > 0 ? this.showMenu(e.clientX, e.clientY, t) : this.hide(); }; } const Yy = (s) => ({ id: "infoMenu", label: "menu.info", group: "info", icon: '', onClick: () => { console.log("dianjile"), s.dialog?.showInfoDialog(), s.engine?.rightKey?.hide(); } }), Ky = (s) => ({ id: "fourMenu", label: "menu.info", icon: '', onClick: () => { console.log("dianjile"), s.dialog?.showInfoDialog(), s.engine?.rightKey?.hide(); } }), $y = (s) => ({ id: "infoMenu", label: "menu.info", icon: '', onClick: () => { console.log("dianjile"), s.dialog?.showInfoDialog(), s.engine?.rightKey?.hide(); } }), Jy = (s) => ({ id: "homeMenu", label: "menu.home", group: "home", children: [$y(s), Ky(s)], icon: '', onClick: () => { s.dialog?.showInfoDialog(), s.engine?.rightKey?.hide(); } }); class Qy extends hn { /** 3D 引擎挂载的父容器 */ container; /** 3D 引擎组件实例 */ engineInstance = null; rightKey = null; // 右键菜单管理器 /** * 构造函数 * @param engine 引擎实例 * @param container 3D 引擎挂载的目标容器 */ constructor(e, t) { super(e), this.container = t; } /** * 初始化 3D 引擎 * @param options 引擎配置选项(可选,如果不提供则使用默认配置) * @returns 是否初始化成功 */ 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 Zy({ container: this.container, ...e // 合并配置选项 }), this.engineInstance.init(), this.rightKey = new hf(this.engine, this.container), this.rightKey.registerHandler((t) => [ Yy(this.engine), Jy(this.engine) ]), this.engineInstance.isInitialized(); } catch (t) { return console.error("[EngineManager] Failed to initialize 3D engine:", t), this.engineInstance = null, !1; } } /** * 检��� 3D 引擎是否已初始化 */ isInitialized() { return this.engineInstance !== null && this.engineInstance.isInitialized(); } /** * 加载 3D 模型 * @param url 模型文件 URL * @param options 加载选项(位置、旋转、缩放) */ loadModel(e, t) { if (!this.engineInstance) { console.warn("[EngineManager] 3D Engine not initialized."); return; } this.engineInstance.loadModel(e, t); } /** * 获取原始 3D 引擎实例 * 用于直接调用第三方引擎的其他 API */ getEngine() { return this.engineInstance ? this.engineInstance.getEngine() : (console.warn("[EngineManager] 3D Engine not initialized."), null); } /** * 回到主视角 */ CameraGoHome() { if (!this.engineInstance) { console.warn("[EngineManager] 3D Engine not initialized."); return; } this.engineInstance.CameraGoHome(); } /** * 激活测量功能 * @param mode 测量类型 */ activateMeasure(e) { if (!this.engineInstance) { console.warn("[EngineManager] 3D Engine not initialized."); return; } this.engineInstance.activateMeasure(e); } /** * 停用测量功能 */ deactivateMeasure() { this.engineInstance && this.engineInstance.deactivateMeasure(); } /** * 获取当前激活的测量类型 */ getCurrentMeasureType() { return this.engineInstance ? this.engineInstance.getCurrentMeasureType() : null; } // ==================== 结束:测量功能方法 ==================== /** * 销毁 3D 引擎实例 */ destroy() { this.engineInstance && (this.engineInstance.destroy(), this.engineInstance = null), this.rightKey && (this.rightKey.destroy(), this.rightKey = null); } } var Et = /* @__PURE__ */ ((s) => (s[s.Unchecked = 0] = "Unchecked", s[s.Checked = 1] = "Checked", s[s.Indeterminate = 2] = "Indeterminate", s))(Et || {}); class e3 { config; element; children = []; parent = null; checkState = Et.Unchecked; // UI Elements contentEl; switcherEl; checkboxEl = null; titleEl; actionsEl; // 操作栏容器 childrenContainer; // 外部回调 onExpandChange; onCheckChange; onNodeClick; renderActions; constructor(e, t, n) { this.config = e, this.onExpandChange = n.onExpand, this.onCheckChange = n.onCheck, this.onNodeClick = n.onClick, this.renderActions = t.renderActions, this.checkState = e.checked ? Et.Checked : Et.Unchecked, this.element = this.createDom(t); } /** * 创建节点 DOM */ 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 = ''; const n = this.config.children && this.config.children.length > 0; if (n ? this.config.expanded && this.switcherEl.classList.add("is-expanded") : this.switcherEl.classList.add("is-hidden"), this.switcherEl.addEventListener("click", (r) => { r.stopPropagation(), this.toggleExpand(); }), this.contentEl.appendChild(this.switcherEl), e.checkable !== !1 && (this.checkboxEl = document.createElement("span"), this.checkboxEl.className = "bim-tree-checkbox", this.updateCheckboxUI(), this.checkboxEl.addEventListener("click", (r) => { r.stopPropagation(), !this.config.disabled && this.toggleCheck(); }), this.contentEl.appendChild(this.checkboxEl)), this.config.icon) { const r = document.createElement("span"); r.className = "bim-tree-icon", r.innerHTML = this.config.icon.includes("`, this.contentEl.appendChild(r); } this.titleEl = document.createElement("span"), this.titleEl.className = "bim-tree-title", this.updateLabel(), this.contentEl.appendChild(this.titleEl), this.actionsEl = document.createElement("div"), this.actionsEl.className = "bim-tree-node-actions", this.actionsEl.addEventListener("click", (r) => { r.stopPropagation(); }), this.contentEl.appendChild(this.actionsEl), this.contentEl.addEventListener("click", (r) => { if (r.stopPropagation(), this.config.disabled) return; (this.config.clickAction || "select") === "expand" ? this.toggleExpand() : this.onNodeClick(this); }), t.appendChild(this.contentEl), this.childrenContainer = document.createElement("div"), this.childrenContainer.className = "bim-tree-children"; const i = e.indent || 24; return this.childrenContainer.style.paddingLeft = `${i}px`, this.config.expanded && n && this.childrenContainer.classList.add("is-visible"), t.appendChild(this.childrenContainer), t; } /** * 设置高亮选中状态 (Select 模式下) */ 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 !== Et.Checked; this.setChecked(e ? Et.Checked : Et.Unchecked, !0); } /** * 设置选中状态 (API调用或联动) * @param state 新状态 * @param fireEvent 是否触发事件 */ setChecked(e, t = !1) { this.checkState !== e && (this.checkState = e, this.config.checked = e === Et.Checked, this.updateCheckboxUI(), t && this.onCheckChange(this)); } /** * 更新复选框 UI 样式 */ updateCheckboxUI() { this.checkboxEl && (this.checkboxEl.classList.remove("is-checked", "is-indeterminate"), this.checkState === Et.Checked ? this.checkboxEl.classList.add("is-checked") : this.checkState === Et.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 t3 { element; contentElement; // 树内容容器 searchInput = null; searchResults = null; options; nodeMap = /* @__PURE__ */ new Map(); rootNodes = []; selectedNode = null; // 当前选中的高亮节点 // 订阅清理函数 unsubscribeLocale = null; unsubscribeTheme = null; clickOutsideHandler = null; // 事件回调 (由 Manager 注入) 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 n = document.createElement("span"); n.className = "bim-tree-search-icon", n.innerHTML = '', t.appendChild(n), this.searchInput = document.createElement("input"), this.searchInput.className = "bim-tree-search-input", this.searchInput.type = "text", this.searchInput.placeholder = Ae(this.options.searchPlaceholder || "搜索..."), this.searchInput.addEventListener("input", (i) => { const r = i.target.value; this.handleSearch(r); }), t.appendChild(this.searchInput), e.appendChild(t), this.searchResults = document.createElement("div"), this.searchResults.className = "bim-tree-search-results", e.appendChild(this.searchResults), this.element.appendChild(e), this.clickOutsideHandler = (i) => { this.searchResults && !this.searchResults.contains(i.target) && !this.searchInput?.contains(i.target) && this.searchResults.classList.remove("is-visible"); }, document.addEventListener("click", this.clickOutsideHandler); } init() { this.render(), this.unsubscribeLocale = Vt.subscribe(() => this.setLocales()), this.unsubscribeTheme = st.subscribe((e) => this.setTheme(e)), this.setTheme(st.getTheme()); } /** * 处理搜索逻辑 */ handleSearch(e) { if (!this.searchResults) return; if (!e.trim()) { this.searchResults.classList.remove("is-visible"), this.searchResults.innerHTML = ""; return; } const t = [], n = e.toLowerCase(); this.nodeMap.forEach((i) => { const r = i.config.label; r.toLowerCase().includes(n) && t.push({ node: i, label: r, path: this.getNodePath(i) }); }), this.renderSearchResults(t); } /** * 获取节点路径(面包屑) */ getNodePath(e) { const t = []; let n = e.parent; for (; n; ) t.unshift(n.config.label), n = n.parent; return t.join(" > "); } /** * 渲染搜索结果列表 */ renderSearchResults(e) { if (this.searchResults) { if (this.searchResults.innerHTML = "", e.length === 0) { const t = document.createElement("div"); t.className = "bim-tree-search-item", t.style.cursor = "default", t.style.color = "#999", t.textContent = "No results", this.searchResults.appendChild(t); } else e.forEach((t) => { const n = document.createElement("div"); n.className = "bim-tree-search-item"; const i = document.createElement("span"); i.className = "bim-tree-search-item-title", i.textContent = t.label; const r = document.createElement("span"); r.className = "bim-tree-search-item-path", r.textContent = t.path, n.appendChild(i), t.path && n.appendChild(r), n.addEventListener("click", () => { this.revealNode(t.node); }), this.searchResults.appendChild(n); }); this.searchResults.classList.add("is-visible"); } } /** * 定位到指定节点 */ revealNode(e) { 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-primary", e.primary), t.setProperty("--bim-bg-elevated", e.bgElevated), t.setProperty("--bim-text-primary", e.textPrimary), t.setProperty("--bim-text-secondary", e.textSecondary), t.setProperty("--bim-text-tertiary", e.textTertiary), t.setProperty("--bim-text-disabled", e.textDisabled), t.setProperty("--bim-text-inverse", e.textInverse), t.setProperty("--bim-border-default", e.borderDefault), t.setProperty("--bim-border-disabled", e.borderDisabled), t.setProperty("--bim-component-bg-hover", e.componentBgHover), t.setProperty("--bim-component-bg-selected", e.componentBgSelected), t.setProperty("--bim-component-bg-disabled", e.componentBgDisabled), t.setProperty("--bim-shadow-md", e.shadowMd), t.setProperty("--bim-focus-ring", e.focusRing); } /** * 响应语言变更 */ setLocales() { this.nodeMap.forEach((e) => e.updateLabel()), this.searchInput && (this.searchInput.placeholder = Ae(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 n = new e3(e, this.options, { onExpand: (i) => { this.onNodeExpand && this.onNodeExpand(i); }, onCheck: (i) => this.handleNodeCheck(i), onClick: (i) => this.handleNodeSelect(i) }); this.nodeMap.set(e.id, n), t ? t.appendChild(n) : (this.rootNodes.push(n), this.contentElement.appendChild(n.element)), e.children && e.children.length > 0 && e.children.forEach((i) => { this.createNodeRecursively(i, n); }); } /** * 处理节点选择 (高亮) */ handleNodeSelect(e) { 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 === Et.Checked; if (this.onNodeCheck && this.onNodeCheck(e), this.options.checkStrictly === !1) return; const n = (r, a) => { r.children.forEach((o) => { o.config.disabled || (o.setChecked(a, !1), n(o, a)); }); }; t ? n(e, Et.Checked) : n(e, Et.Unchecked); let i = e.parent; for (; i; ) { if (i.config.disabled) { i = i.parent; continue; } const r = i.children, a = r.every((l) => l.checkState === Et.Checked), o = r.every((l) => l.checkState === Et.Unchecked); a ? i.setChecked(Et.Checked, !1) : o ? i.setChecked(Et.Unchecked, !1) : i.setChecked(Et.Indeterminate, !1), i = i.parent; } } // ================== Public APIs ================== getNode(e) { return this.nodeMap.get(e); } checkNode(e, t) { const n = this.nodeMap.get(e); n && n.setChecked(t ? Et.Checked : Et.Unchecked, !0); } expandAll(e) { this.nodeMap.forEach((t) => t.toggleExpand(e)); } getCheckedNodes(e = !1) { const t = []; return this.nodeMap.forEach((n) => { (n.checkState === Et.Checked || e && n.checkState === Et.Indeterminate) && t.push(n.config); }), t; } } class uf { /** 组件根节点 */ element; /** 头部容器 */ navElement; /** 内容容器 */ contentElement; /** 业务配置 */ options; /** 当前激活的标签 id */ activeId; /** id -> TabItem */ tabMap = /* @__PURE__ */ new Map(); /** id -> 内容容器 */ panelMap = /* @__PURE__ */ 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(st.getTheme()), this.unsubscribeLocale = Vt.subscribe(() => this.setLocales()), this.unsubscribeTheme = st.subscribe((e) => this.setTheme(e)); } /** * 渲染头部标签 */ renderNav() { this.navElement.innerHTML = "", this.navClickHandler = (e) => { const t = e.target.closest(".bim-tab__item"); if (!t) return; const n = t.dataset.id; !n || this.tabMap.get(n)?.disabled || this.activateTab(n); }, this.navElement.addEventListener("click", this.navClickHandler), this.options.tabs.forEach((e) => { const t = document.createElement("button"); if (t.type = "button", t.className = "bim-tab__item", t.dataset.id = e.id, t.setAttribute("role", "tab"), t.id = `tab-${e.id}`, t.setAttribute("aria-selected", `${e.id === this.activeId}`), e.disabled && (t.disabled = !0, t.setAttribute("aria-disabled", "true"), t.classList.add("is-disabled")), e.icon) { const i = document.createElement("span"); i.className = "bim-tab__icon", i.innerHTML = e.icon, t.appendChild(i); } const n = document.createElement("span"); n.className = "bim-tab__title", n.textContent = this.resolveTitle(e.title), t.appendChild(n), e.id === this.activeId && t.classList.add("is-active"), this.navElement.appendChild(t); }); } /** * 渲染内容面板 */ renderPanels() { this.contentElement.innerHTML = "", this.panelMap.clear(), this.options.tabs.forEach((e) => { const t = document.createElement("div"); t.className = "bim-tab__panel", t.dataset.id = e.id, t.setAttribute("role", "tabpanel"), t.setAttribute("aria-labelledby", `tab-${e.id}`), e.content instanceof HTMLElement ? t.appendChild(e.content) : typeof e.content == "string" && (t.innerHTML = e.content), e.id === this.activeId ? t.classList.add("is-active") : t.style.display = "none", this.panelMap.set(e.id, t), this.contentElement.appendChild(t); }); } /** * 激活指定标签 * @param tabId 目标标签 id */ activateTab(e) { if (this.activeId === e) return; const t = this.tabMap.get(e); if (!t || t.disabled) return; this.activeId = e, this.navElement.querySelectorAll(".bim-tab__item").forEach((i) => { const r = i.dataset.id === e; i.classList.toggle("is-active", r), i.setAttribute("aria-selected", `${r}`); }), this.panelMap.forEach((i, r) => { const a = r === e; i.classList.toggle("is-active", a), i.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.bgElevated), t.setProperty("--bim-tab-nav-bg", e.bgElevated), t.setProperty("--bim-tab-text", e.textPrimary), t.setProperty("--bim-tab-text-secondary", e.textSecondary), t.setProperty("--bim-tab-text-active", e.primary), t.setProperty("--bim-tab-border", e.borderDefault), t.setProperty("--bim-tab-hover-bg", e.componentBgHover), t.setProperty("--bim-tab-active-bg", e.componentBgActive), t.setProperty("--bim-tab-icon", e.iconDefault); } /** * 应用当前语言文案 */ setLocales() { this.navElement.querySelectorAll(".bim-tab__item").forEach((t) => { const n = t.dataset.id; if (!n) return; const i = this.tabMap.get(n); if (!i) return; const r = t.querySelector(".bim-tab__title"); r && (r.textContent = this.resolveTitle(i.title)); }); } /** * 清理资源 */ destroy() { this.navClickHandler && (this.navElement.removeEventListener("click", this.navClickHandler), this.navClickHandler = null), this.unsubscribeLocale && (this.unsubscribeLocale(), this.unsubscribeLocale = null), this.unsubscribeTheme && (this.unsubscribeTheme(), this.unsubscribeTheme = null), this.panelMap.clear(), this.tabMap.clear(), this.element.remove(); } /** * 工具:解析标题(优先翻译,不存在则回退原值) */ resolveTitle(e) { try { return Ae(e) || e; } catch { return e; } } } const Pu = { // ========== 来自 assets 的图标 (48x48) ========== 测量: '', 地图: '', 框选放大: '', 漫游: '', 目录树: '', 剖切: '', 剖切盒: '', 全屏: '', 设置: '', 拾曲面剖切: '', 轴向剖切: '', 主视角: '', 文档: '', 第一人称漫游: '', 反向: '', 路径漫游: '', 适应到模型: '', 隐藏: '', 重置: '', // ========== 测量相关图标 (32x32) ========== 标高: '', 距离: '', 最小距离: '', 激光边距: '', 角度: '', 坡度: '', 体积: '', 空间体积: '', // ========== 通用图标 (24x24) ========== close: '', check: '', warning: '', error: '', success: '', plus: '', minus: '', arrowUp: '', arrowDown: '', arrowLeft: '', arrowRight: '', search: '', refresh: '', delete: '', edit: '', save: '', expand: '', collapse: '', // ========== 默认图标 ========== default: '' }; function At(s) { const e = Pu[s]; return e || (console.warn(`[IconManager] Icon "${s}" not found, using default icon`), Pu.default); } const n3 = [ { id: "root", label: "全部构件", expanded: !0, clickAction: "expand", children: [ { id: "level-1", label: "一层", expanded: !1, icon: '', 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 i3 extends hn { 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 jl({ 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: At("目录树"), onClick: () => { this.openConstructTreeDialog(); } }), this.toolbar.render(); } openConstructTreeDialog() { this.setVisible(!1); const e = new t3({ data: n3, checkable: !0, indent: 0, enableSearch: !0, checkStrictly: !0, defaultExpandAll: !0, renderActions: (o) => '', 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 n = document.createElement("div"); n.className = "construct-tab__panel-content"; const i = document.createElement("div"); i.className = "construct-tab__panel-content", i.appendChild(e.element); const r = document.createElement("div"); r.className = "construct-tab__container", r.style.height = "100%", r.style.overflow = "hidden"; const a = new uf({ container: r, tabs: [ { id: "component", title: "tab.component", content: i }, { id: "system", title: "tab.system", content: t }, { id: "space", title: "tab.space", content: n } ], activeId: "component", onChange: () => { this.dialog?.fitWidth(); } }); a.init(), this.dialog = this.engine.dialog.create({ title: "constructTree.title", minWidth: 320, height: 420, content: r, 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; } // --- 转发 API --- 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 s3 { 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 = '', 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 = Ae(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 = Ae(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 Ru { element; options; items = /* @__PURE__ */ new Map(); activeIds = /* @__PURE__ */ new Set(); unsubscribeLocale = null; unsubscribeTheme = null; constructor(e) { this.options = { bordered: !0, accordion: !1, ...e }, this.element = document.createElement("div"), this.element.className = `bim-collapse ${this.options.className || ""}`, this.options.bordered || (this.element.style.border = "none"), this.options.ghost && this.element.classList.add("is-ghost"); const t = typeof this.options.container == "string" ? document.getElementById(this.options.container) : this.options.container; t && t.appendChild(this.element), this.options.activeIds && this.options.activeIds.forEach((n) => this.activeIds.add(n)), this.init(); } init() { this.options.items.forEach((e) => { const t = new s3(e, this); this.items.set(e.id, t), this.element.appendChild(t.element), this.activeIds.has(e.id) && t.setActive(!0); }), this.unsubscribeLocale = Vt.subscribe(() => { this.setLocales(); }), this.unsubscribeTheme = st.subscribe((e) => { this.setTheme(e); }), this.setTheme(st.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.bgElevated), t.setProperty("--bim-border-color", e.borderDefault), t.setProperty("--bim-text-color", e.textPrimary), t.setProperty("--bim-header-bg-color", e.componentBgHover), t.setProperty("--bim-header-hover-bg-color", e.componentBgActive), t.setProperty("--bim-content-bg-color", e.bgElevated), t.setProperty("--bim-disabled-color", e.textDisabled); } 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 Oo { 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 = st.subscribe((e) => { this.setTheme(e); }), this.setTheme(st.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 n = document.createElement("div"); n.className = "bim-description-label", e.labelColor && (n.style.color = e.labelColor), this.options.labelWidth && (n.style.width = this.options.labelWidth), n.textContent = this.options.bordered ? e.label : e.label + ":"; const i = document.createElement("div"); i.className = "bim-description-value", e.valueColor && (i.style.color = e.valueColor), typeof e.value == "string" ? i.innerHTML = e.value : i.appendChild(e.value), t.appendChild(n), t.appendChild(i), 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.borderDefault); } setLocales() { } destroy() { this.unsubscribeTheme && (this.unsubscribeTheme(), this.unsubscribeTheme = null), this.element.remove(); } } class r3 extends hn { dialogId = "property-panel-dialog"; dialog = null; // 保存 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; } if (this.isOpen()) return; const e = 360, t = document.body.clientWidth - e - 40; console.log("x", t), this.dialog = 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, onClose: () => { this.hide(); } }); const n = document.createElement("div"); n.style.height = "100%", n.style.display = "flex", n.style.flexDirection = "column", this.dialog.setContent(n), new uf({ container: n, tabs: [ { id: "props", title: "panel.property.tab.props", // '属性' content: this.createPropsTabContent() }, { id: "material", title: "panel.property.tab.material", // '材质' content: this.createMaterialTabContent() } ] }).init(); } /** * 创建"属性"标签页的内容 (包含 Collapse) */ createPropsTabContent() { const e = document.createElement("div"); return e.style.height = "100%", e.style.overflowY = "auto", new Ru({ 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; } /** * 创建"材质"标签页的内容 (包含 Collapse) */ createMaterialTabContent() { const e = document.createElement("div"); return e.style.height = "100%", e.style.overflowY = "auto", new Ru({ 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 Oo({ container: e, labelWidth: "80px", bordered: !0, items: [ { label: "Guid", value: '1f8d-4a2e-9c' }, { label: "Name", value: "Basic Wall: Generic - 200mm" }, { 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 Oo({ 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 = `
    Concrete - Cast-in-Place Gray `; const n = document.createElement("div"); return new Oo({ container: n, 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(n), e; } /** * 检查属性面板是否打开 */ isOpen() { return this.dialog !== null; } /** * 隐藏属性面板 */ hide() { this.dialog && (this.dialog.destroy(), this.dialog = null); } destroy() { this.hide(); } } const a3 = { distance: '', minDistance: '', angle: '', elevation: '', volume: '', laserDistance: '', slope: '', spaceVolume: '' }; class nr { element; options; activeMode; isExpanded; result = null; /** * 测量配置(单位/精度) * 说明: * - 你要求:创建 MeasurePanel 不传入单位和精度 * - 默认值维护在组件内部 * - 初始化时优先读取缓存(localStorage),否则使用默认值 */ config; /** 设置面板的临时配置(用于“取消”回滚) */ draftConfig = null; /** 当前视图:主面板 / 设置面板 */ view = "main"; /** 缓存 key(默认全局) */ static CONFIG_CACHE_KEY = "bim-engine:measure:config"; /** 默认配置(由组件内部维护) */ static DEFAULT_CONFIG = { unit: "mm", precision: 2 }; // DOM 引用(便于局部更新,减少频繁 querySelector) toolButtons = /* @__PURE__ */ new Map(); toggleBtn; toggleTextEl; mainValueValueEl; mainValueLabelEl; mainNumberEl; mainUnitEl; xyzBoxEl; xyzXEl; xyzYEl; xyzZEl; clearBtn; settingsBtn; // Settings DOM mainViewEl; settingsViewEl; unitSelectEl; precisionSelectEl; saveSettingsBtn; cancelSettingsBtn; // 订阅清理 unsubscribeLocale = null; unsubscribeTheme = null; /** * 构造函数 * @param options 组件配置 */ constructor(e = {}) { this.options = e, this.activeMode = e.defaultMode ?? "distance", this.isExpanded = e.defaultExpanded ?? !1, this.config = this.loadConfigFromCache() ?? { ...nr.DEFAULT_CONFIG }, this.element = this.createDom(); } /** * 初始化组件(实现 IBimComponent) */ init() { this.unsubscribeLocale = Vt.subscribe(() => { this.setLocales(); }), this.unsubscribeTheme = st.subscribe((e) => { this.setTheme(e); }), this.setLocales(), this.setTheme(st.getTheme()), this.applyExpandedState(), this.applyActiveModeState(), this.applyViewState(), this.renderResult(), this.options.onModeChange && this.options.onModeChange(this.activeMode); } /** * 设置主题(实现 IBimComponent) * @param theme 主题配置 */ setTheme(e) { const t = this.element.style; t.setProperty("--bim-bg-inset", e.bgInset ?? "#152232"), t.setProperty("--bim-bg-elevated", e.bgElevated ?? "#1f2d3e"), t.setProperty("--bim-border-default", e.borderDefault ?? "#334155"), t.setProperty("--bim-border-strong", e.borderStrong ?? "#475569"), t.setProperty("--bim-divider", e.divider ?? "#334155"), t.setProperty("--bim-primary", e.primary ?? "#3b82f6"), t.setProperty("--bim-primary-hover", e.primaryHover ?? "#60a5fa"), t.setProperty("--bim-primary-subtle", e.primarySubtle ?? "rgba(59, 130, 246, 0.15)"), t.setProperty("--bim-danger", e.danger ?? "#ef4444"), t.setProperty("--bim-text-primary", e.textPrimary ?? "#ffffff"), t.setProperty("--bim-text-secondary", e.textSecondary ?? "#94a3b8"), t.setProperty("--bim-text-tertiary", e.textTertiary ?? "#64748b"), t.setProperty("--bim-text-inverse", e.textInverse ?? "#152232"), t.setProperty("--bim-icon-default", e.iconDefault ?? "#ffffff"), t.setProperty("--bim-component-bg-hover", e.componentBgHover ?? "rgba(248, 250, 252, 0.06)"); } /** * 设置语言(实现 IBimComponent) */ setLocales() { for (const [t, n] of this.toolButtons.entries()) n.title = Ae(this.getModeI18nKey(t)), n.setAttribute("aria-label", n.title); this.toggleBtn.title = this.isExpanded ? Ae("measure.actions.collapse") : Ae("measure.actions.expand"), this.toggleBtn.setAttribute("aria-label", this.toggleBtn.title), this.toggleTextEl && (this.toggleTextEl.textContent = this.toggleBtn.title), this.clearBtn.textContent = Ae("measure.actions.clearAll"), this.settingsBtn.title = Ae("measure.actions.settings"), this.settingsBtn.setAttribute("aria-label", this.settingsBtn.title), this.mainValueLabelEl.textContent = Ae(this.getModeValueLabelI18nKey(this.activeMode)), this.element.querySelectorAll("[data-i18n-key]").forEach((t) => { const n = t.dataset.i18nKey; n && (t.textContent = Ae(n)); }), this.saveSettingsBtn.textContent = Ae("measure.settings.save"), this.cancelSettingsBtn.textContent = Ae("measure.settings.cancel"); } /** * 销毁组件(实现 IBimComponent) */ destroy() { this.unsubscribeLocale && (this.unsubscribeLocale(), this.unsubscribeLocale = null), this.unsubscribeTheme && (this.unsubscribeTheme(), this.unsubscribeTheme = null), this.element.remove(); } // ========================== // 对外 API(给 Manager / 外部业务调用) // ========================== /** * 获取当前测量方式 */ getActiveMode() { return this.activeMode; } /** * 切换测量方式(你要求的“切换类型的方法”) * @param mode 目标测量方式 */ switchMode(e) { this.setActiveMode(e); } /** * 设置当前测量方式 * @param mode 目标测量方式 */ setActiveMode(e) { this.activeMode !== e && (this.activeMode = e, this.applyActiveModeState(), this.mainValueLabelEl.textContent = Ae(this.getModeValueLabelI18nKey(this.activeMode)), this.options.onModeChange && this.options.onModeChange(e), this.renderResult(), this.options.onExpandedChange && this.options.onExpandedChange(this.isExpanded)); } /** * 设置测量结果(由外部注入) * @param result 测量结果;传 null 表示清空 */ setResult(e) { this.result = e, this.renderResult(); } /** * 删除全部(只做 UI 状态清空 + 回调) */ clearAll() { this.result = null, this.renderResult(), this.options.onClearAll && this.options.onClearAll(); } /** * 打开设置(本次只预留方法/回调) */ openSettings() { this.enterSettingsView(), this.options.onSettings && this.options.onSettings(); } /** * 获取当前测量配置 */ getConfig() { return { ...this.config }; } /** * 设置测量配置(可选对外调用) * @param partial 部分更新 * @param persist 是否写入缓存(默认 false) */ setConfig(e, t = !1) { const n = { unit: e.unit ?? this.config.unit, precision: e.precision ?? this.config.precision }; this.config = n, t && this.saveConfigToCache(n), this.renderResult(), this.view === "settings" && this.syncSettingsFormFromConfig(n); } /** * 展开 / 收起(可选对外调用) * @param expanded 是否展开 */ setExpanded(e) { this.isExpanded !== e && (this.isExpanded = e, this.applyExpandedState(), this.setLocales(), this.options.onExpandedChange && this.options.onExpandedChange(this.isExpanded)); } /** * 获取是否展开 */ getExpanded() { return this.isExpanded; } // ========================== // 内部实现 // ========================== createDom() { const e = document.createElement("div"); e.className = "bim-measure-panel", this.mainViewEl = document.createElement("div"), this.mainViewEl.className = "bim-measure-main"; const t = document.createElement("div"); t.className = "bim-measure-tools"; const n = document.createElement("div"); n.className = "bim-measure-tool-grid"; const i = [ "distance", "minDistance", "angle", "elevation", "volume", "laserDistance", "slope", "spaceVolume" ], r = ` `; for (let g = 0; g < i.length; g++) { const x = i[g], m = document.createElement("button"); m.type = "button", m.className = "bim-measure-tool-btn", m.dataset.mode = x; const v = document.createElement("span"); v.className = "bim-measure-tool-icon", v.innerHTML = a3[x] || r, m.appendChild(v), m.addEventListener("click", () => { this.setActiveMode(x); }), this.toolButtons.set(x, m), n.appendChild(m); } t.appendChild(n); 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 = ` `, 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), this.mainViewEl.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", this.mainValueLabelEl = h; const u = document.createElement("span"); u.className = "value", this.mainValueValueEl = u, this.mainNumberEl = document.createElement("span"), this.mainNumberEl.className = "bim-measure-main-number", this.mainUnitEl = document.createElement("span"), this.mainUnitEl.className = "bim-measure-main-unit", this.mainValueValueEl.appendChild(this.mainNumberEl), this.mainValueValueEl.appendChild(document.createTextNode(" ")), this.mainValueValueEl.appendChild(this.mainUnitEl), c.appendChild(h), c.appendChild(u), l.appendChild(c); const f = document.createElement("div"); f.className = "bim-measure-xyz", this.xyzBoxEl = f; const d = (g, x, m) => { const v = document.createElement("div"); v.className = "bim-measure-row"; const b = document.createElement("span"); b.className = "label", b.dataset.i18nKey = g; const M = document.createElement("span"); return M.className = `value ${x}`, m(M), v.appendChild(b), v.appendChild(M), v; }; f.appendChild(d("measure.labels.x", "bim-measure-xyz-x", (g) => this.xyzXEl = g)), f.appendChild(d("measure.labels.y", "bim-measure-xyz-y", (g) => this.xyzYEl = g)), f.appendChild(d("measure.labels.z", "bim-measure-xyz-z", (g) => this.xyzZEl = g)), l.appendChild(f), this.mainViewEl.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 = ` `, this.settingsBtn.addEventListener("click", () => { this.openSettings(); }), p.appendChild(this.clearBtn), p.appendChild(this.settingsBtn), this.mainViewEl.appendChild(p), this.settingsViewEl = this.createSettingsDom(), e.appendChild(this.mainViewEl), e.appendChild(this.settingsViewEl), e; } /** * 创建“设置面板”DOM */ createSettingsDom() { const e = document.createElement("div"); e.className = "bim-measure-settings"; const t = document.createElement("div"); t.className = "bim-measure-settings-title", t.dataset.i18nKey = "measure.settings.title", e.appendChild(t); const n = document.createElement("div"); n.className = "bim-measure-settings-row"; const i = document.createElement("div"); i.className = "label", i.dataset.i18nKey = "measure.settings.unit", this.unitSelectEl = document.createElement("select"), this.unitSelectEl.className = "bim-measure-settings-select", this.unitSelectEl.appendChild(this.makeOption("m")), this.unitSelectEl.appendChild(this.makeOption("cm")), this.unitSelectEl.appendChild(this.makeOption("mm")), this.unitSelectEl.appendChild(this.makeOption("km")), n.appendChild(i), n.appendChild(this.unitSelectEl), e.appendChild(n); const r = document.createElement("div"); r.className = "bim-measure-settings-hint", r.dataset.i18nKey = "measure.settings.hint", e.appendChild(r); const a = document.createElement("div"); a.className = "bim-measure-settings-row"; const o = document.createElement("div"); o.className = "label", o.dataset.i18nKey = "measure.settings.precision", this.precisionSelectEl = document.createElement("select"), this.precisionSelectEl.className = "bim-measure-settings-select", this.precisionSelectEl.appendChild(this.makePrecisionOption(0)), this.precisionSelectEl.appendChild(this.makePrecisionOption(1)), this.precisionSelectEl.appendChild(this.makePrecisionOption(2)), this.precisionSelectEl.appendChild(this.makePrecisionOption(3)), a.appendChild(o), a.appendChild(this.precisionSelectEl), e.appendChild(a); const l = document.createElement("div"); return l.className = "bim-measure-settings-actions", this.saveSettingsBtn = document.createElement("button"), this.saveSettingsBtn.type = "button", this.saveSettingsBtn.className = "bim-measure-settings-save", this.saveSettingsBtn.addEventListener("click", () => { this.saveSettings(); }), this.cancelSettingsBtn = document.createElement("button"), this.cancelSettingsBtn.type = "button", this.cancelSettingsBtn.className = "bim-measure-settings-cancel", this.cancelSettingsBtn.addEventListener("click", () => { this.cancelSettings(); }), l.appendChild(this.saveSettingsBtn), l.appendChild(this.cancelSettingsBtn), e.appendChild(l), this.syncSettingsFormFromConfig(this.config), e; } makeOption(e) { const t = document.createElement("option"); return t.value = e, t.textContent = e, t; } makePrecisionOption(e) { const t = document.createElement("option"); return t.value = String(e), t.textContent = e === 0 ? "0" : `0.${"0".repeat(e)}`, t; } /** * 进入设置视图:保存一份当前配置作为草稿基线 */ enterSettingsView() { this.draftConfig = { ...this.config }, this.view = "settings", this.syncSettingsFormFromConfig(this.config), this.applyViewState(); } /** * 保存设置:写入 config + 写缓存 + 返回主视图 */ saveSettings() { const e = this.unitSelectEl.value || this.config.unit, t = Number(this.precisionSelectEl.value), n = { unit: e, precision: this.isValidPrecision(t) ? t : this.config.precision }; this.config = n, this.saveConfigToCache(n), this.draftConfig = null, this.view = "main", this.applyViewState(), this.renderResult(), this.options.onExpandedChange && this.options.onExpandedChange(this.isExpanded); } /** * 取消设置:回滚到进入设置前的配置,并返回主视图 */ cancelSettings() { this.draftConfig && (this.config = { ...this.draftConfig }), this.draftConfig = null, this.view = "main", this.applyViewState(), this.renderResult(), this.options.onExpandedChange && this.options.onExpandedChange(this.isExpanded); } syncSettingsFormFromConfig(e) { this.unitSelectEl.value = e.unit, this.precisionSelectEl.value = String(e.precision); } applyViewState() { this.view === "settings" ? (this.mainViewEl.style.display = "none", this.settingsViewEl.style.display = "block") : (this.mainViewEl.style.display = "block", this.settingsViewEl.style.display = "none"); } /** * 从缓存读取配置 * - 有缓存:返回解析后的配置 * - 无缓存/解析失败:返回 null */ loadConfigFromCache() { try { const e = localStorage.getItem(nr.CONFIG_CACHE_KEY); if (!e) return null; const t = JSON.parse(e); if (!t || typeof t != "object") return null; const n = t.unit, i = t.precision; return !this.isValidUnit(n) || !this.isValidPrecision(i) ? null : { unit: n, precision: i }; } catch { return null; } } /** * 写入缓存(localStorage) */ saveConfigToCache(e) { try { localStorage.setItem(nr.CONFIG_CACHE_KEY, JSON.stringify(e)); } catch { } } isValidUnit(e) { return e === "m" || e === "cm" || e === "mm" || e === "km"; } isValidPrecision(e) { return e === 0 || e === 1 || e === 2 || e === 3; } /** * 应用“展开/收起”状态:默认只显示前 4 个按钮 */ 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"); } /** * 渲染结果区(根据 activeMode 从 result 里取对应字段) */ renderResult() { if (this.activeMode === "laserDistance") this.mainValueLabelEl.style.display = "none", this.mainNumberEl.textContent = Ae(this.getModeI18nKey("laserDistance")), this.mainUnitEl.textContent = "", this.mainNumberEl.classList.add("is-laser-text"); else { this.mainValueLabelEl.style.display = "", this.mainValueLabelEl.textContent = Ae(this.getModeValueLabelI18nKey(this.activeMode)); const e = this.formatMainValueParts(this.activeMode, this.result); this.mainNumberEl.textContent = e.numberText, this.mainUnitEl.textContent = e.unitText, this.mainNumberEl.classList.remove("is-laser-text"); } if (this.activeMode === "distance") { this.xyzBoxEl.style.display = ""; const e = this.result?.xyz; if (!e) { this.xyzXEl.textContent = "--", this.xyzYEl.textContent = "--", this.xyzZEl.textContent = "--"; return; } this.xyzXEl.textContent = this.formatNumberWithPrecision(e.x, this.config.precision), this.xyzYEl.textContent = this.formatNumberWithPrecision(e.y, this.config.precision), this.xyzZEl.textContent = this.formatNumberWithPrecision(e.z, this.config.precision); return; } this.xyzBoxEl.style.display = "none"; } /** * 获取模式名称的国际化 key */ getModeI18nKey(e) { return `measure.modes.${e}`; } /** * 获取“主值 label”的国际化 key(随模式变化) */ getModeValueLabelI18nKey(e) { return `measure.labels.value.${e}`; } // 注意:旧的 formatMainValue/formatWithFixedUnit 已被 formatMainValueParts 替代, // 以支持“数值与单位分色显示”和“无数据时仍展示单位”。 /** * 基础数字格式化(按精度显示) */ formatNumberWithPrecision(e, t) { return e.toFixed(t); } // 注意:旧的 formatLengthWithConfig 已被 formatLengthParts 替代。 convertMmToUnit(e, t) { switch (t) { case "mm": return e; case "cm": return e / 10; case "m": return e / 1e3; case "km": return e / 1e6; default: return e; } } getUnitI18nKey(e) { return `measure.units.${e}`; } // 注意:旧的 formatElevationFixedMeters / formatVolumeWithConfig 已被 formatMainValueParts 替代。 convertMm3ToUnit3(e, t) { switch (t) { case "mm": return e; case "cm": return e / 1e3; case "m": return e / 1e9; case "km": return e / 1e18; default: return e; } } /** * 主数据拆分:返回 { 数值文本, 单位文本 } * 规则: * - 没数据时:必须展示 `-- 单位`(而不是只展示 `--`) * - 单位随模式变化: * - 距离/最小距离:单位随设置变动 * - 角度:° * - 标高:固定 m * - 体积/空间体积:单位³(随设置变动) * - 坡度:% */ formatMainValueParts(e, t) { if (e === "laserDistance") return { numberText: Ae(this.getModeI18nKey("laserDistance")), unitText: "" }; if (!t) return this.getEmptyValuePartsByMode(e); switch (e) { case "distance": return this.formatLengthParts(t.distanceMm); case "minDistance": return this.formatLengthParts(t.minDistanceMm); case "angle": return this.formatFixedUnitParts(t.angleDeg, Ae("measure.units.deg")); case "elevation": return this.formatFixedUnitParts( t.elevationMm === void 0 ? void 0 : t.elevationMm / 1e3, Ae("measure.units.m") ); case "volume": return this.formatVolumeParts(t.volumeM3); case "slope": return this.formatFixedUnitParts(t.slopePercent, Ae("measure.units.percent")); case "spaceVolume": return this.formatVolumeParts(t.spaceVolumeM3); default: return { numberText: "--", unitText: "" }; } } getEmptyValuePartsByMode(e) { switch (e) { case "distance": case "minDistance": return { numberText: "--", unitText: Ae(this.getUnitI18nKey(this.config.unit)) }; case "angle": return { numberText: "--", unitText: Ae("measure.units.deg") }; case "elevation": return { numberText: "--", unitText: Ae("measure.units.m") }; case "volume": case "spaceVolume": return { numberText: "--", unitText: `${this.config.unit}³` }; case "slope": return { numberText: "--", unitText: Ae("measure.units.percent") }; default: return { numberText: "--", unitText: "" }; } } formatFixedUnitParts(e, t) { return e == null || Number.isNaN(e) ? { numberText: "--", unitText: t } : { numberText: this.formatNumberWithPrecision(e, this.config.precision), unitText: t }; } formatLengthParts(e) { const t = Ae(this.getUnitI18nKey(this.config.unit)); if (e == null || Number.isNaN(e)) return { numberText: "--", unitText: t }; const n = this.convertMmToUnit(e, this.config.unit); return { numberText: this.formatNumberWithPrecision(n, this.config.precision), unitText: t }; } formatVolumeParts(e) { const t = `${this.config.unit}³`; if (e == null || Number.isNaN(e)) return { numberText: "--", unitText: t }; const n = this.convertMm3ToUnit3(e, this.config.unit); return { numberText: this.formatNumberWithPrecision(n, this.config.precision), unitText: t }; } } class o3 extends hn { dialogId = "measure-dialog"; dialog = null; panel = null; /** * 测量配置项(单位/精度) * 说明:MeasurePanel 会自行从缓存加载默认配置,Manager 这里只做“对外读取/设置”的镜像。 */ config = 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, n = 20, i = this.engine.container, r = i.clientWidth, a = i.clientHeight, o = r - e - n, l = (a - t) / 2; this.destroy(), this.panel = new nr({ defaultMode: "distance", // 默认展示前四个,且默认选中"距离" defaultExpanded: !1, onModeChange: (h) => { console.log("[MeasureDialogManager] 当前测量方式已切换:", h), this.engine.engine?.activateMeasure(h); }, onClearAll: () => { console.log("[MeasureDialogManager] 删除全部(仅 UI 清空,本次不清理引擎侧内容)"); }, onSettings: () => { console.log("[MeasureDialogManager] 打开设置(仅预留接口)"); }, onExpandedChange: () => { this.dialog?.fitHeight(!1); } }), this.panel.init(), this.config = this.panel.getConfig(); 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, // 高度交给 fitHeight 动态计算(避免内容展开后遮挡底部操作区) height: "auto", position: { x: o, y: l }, onClose: () => { this.engine.toolbar?.setBtnActive("measure", !1), this.destroy(); } }), this.dialog.init(), this.dialog.fitHeight(!1); } /** * 获取当前测量方式 * 说明:如果面板未创建,则返回 null */ getActiveMode() { return this.panel ? this.panel.getActiveMode() : null; } /** * 切换测量方式(你要求的“切换类型的方法”) * @param mode 测量方式 */ switchMode(e) { this.panel && this.panel.switchMode(e); } /** * 设置测量结果(推荐使用的新方法名) * 说明:内部直接调用 MeasurePanel.setResult() * @param result 测量结果;传 null 表示清空 */ setMeasureResult(e) { this.panel && this.panel.setResult(e); } /** * 获取测量配置(单位/精度) * - 如果面板存在:返回面板当前配置 * - 否则:返回 Manager 缓存的最后一次配置(可能为 null) */ getConfig() { return this.panel && (this.config = this.panel.getConfig()), this.config ? { ...this.config } : null; } /** * 设置测量配置(单位/精度) * @param partial 部分更新 * @param persist 是否写入缓存(默认 true) */ setConfig(e, t = !0) { if (this.panel) { this.panel.setConfig(e, t), this.config = this.panel.getConfig(), this.dialog?.fitHeight(!1); return; } const n = this.config, i = { unit: e.unit ?? n?.unit ?? "mm", precision: e.precision ?? n?.precision ?? 2 }; this.config = i; } /** * 删除全部(仅清空 UI;真实测量清理逻辑后续再接) */ clearAll() { this.panel && this.panel.clearAll(); } /** * 打开设置(仅预留方法/回调) */ openSettings() { this.panel && this.panel.openSettings(); } destroy() { this.engine.engine && this.engine.engine.deactivateMeasure(), this.dialog && (this.dialog.destroy(), this.dialog = null), this.panel && (this.panel.destroy(), this.panel = null); } } class l3 { element; options; // DOM 引用 hideBtn; reverseBtn; resetBtn; hideLabelEl; reverseLabelEl; resetLabelEl; // 订阅清理 unsubscribeLocale = null; unsubscribeTheme = null; constructor(e = {}) { this.options = e, this.element = this.createDom(); } /** * 初始化组件 */ init() { this.unsubscribeLocale = Vt.subscribe(() => { this.setLocales(); }), this.unsubscribeTheme = st.subscribe((e) => { this.setTheme(e); }), this.setLocales(), this.setTheme(st.getTheme()); } /** * 设置主题 */ setTheme(e) { const t = this.element.style; t.setProperty("--bim-bg-inset", e.bgInset ?? "#152232"), t.setProperty("--bim-border-default", e.borderDefault ?? "#334155"), t.setProperty("--bim-border-strong", e.borderStrong ?? "#475569"), t.setProperty("--bim-primary", e.primary ?? "#3b82f6"), t.setProperty("--bim-primary-subtle", e.primarySubtle ?? "rgba(59, 130, 246, 0.15)"), t.setProperty("--bim-icon-default", e.iconDefault ?? "#ffffff"), t.setProperty("--bim-text-primary", e.textPrimary ?? "#ffffff"), t.setProperty("--bim-component-bg-hover", e.componentBgHover ?? "rgba(248, 250, 252, 0.06)"); } /** * 设置语言 */ setLocales() { this.hideLabelEl.textContent = Ae("sectionPlane.actions.hide"), this.reverseLabelEl.textContent = Ae("sectionPlane.actions.reverse"), this.resetLabelEl.textContent = Ae("sectionPlane.actions.reset"), this.hideBtn.title = Ae("sectionPlane.actions.hide"), this.reverseBtn.title = Ae("sectionPlane.actions.reverse"), this.resetBtn.title = Ae("sectionPlane.actions.reset"); } /** * 销毁组件 */ destroy() { this.unsubscribeLocale && (this.unsubscribeLocale(), this.unsubscribeLocale = null), this.unsubscribeTheme && (this.unsubscribeTheme(), this.unsubscribeTheme = null), this.element.remove(); } /** * 创建 DOM */ createDom() { const e = document.createElement("div"); return e.className = "section-plane-panel", this.hideBtn = this.createButton( "hide", At("隐藏"), () => { this.options.onHide && this.options.onHide(); } ), this.reverseBtn = this.createButton( "reverse", At("反向"), () => { this.options.onReverse && this.options.onReverse(); } ), this.resetBtn = this.createButton( "reset", At("重置"), () => { this.options.onReset && this.options.onReset(); } ), e.appendChild(this.hideBtn), e.appendChild(this.reverseBtn), e.appendChild(this.resetBtn), e; } /** * 创建按钮 */ createButton(e, t, n) { const i = document.createElement("button"); i.type = "button", i.className = "section-plane-btn"; const r = document.createElement("div"); r.className = "section-plane-btn-icon", r.innerHTML = t, i.appendChild(r); const a = document.createElement("div"); return a.className = "section-plane-btn-label", i.appendChild(a), e === "hide" ? this.hideLabelEl = a : e === "reverse" ? this.reverseLabelEl = a : this.resetLabelEl = a, i.addEventListener("click", n), i; } } class c3 extends hn { dialogId = "section-plane-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; } this.destroy(), this.panel = new l3({ onHide: () => { console.log("[SectionPlaneDialogManager] 隐藏"); }, onReverse: () => { console.log("[SectionPlaneDialogManager] 反向"); }, onReset: () => { console.log("[SectionPlaneDialogManager] 重置"); } }), this.panel.init(); const e = 240, t = 120, n = 20, i = 50, r = this.engine.container, a = r.clientWidth, o = r.clientHeight, l = a - e - n, c = o - t - i; this.dialog = this.engine.dialog.create({ id: this.dialogId, title: "sectionPlane.dialogTitle", width: e, height: t, position: { x: l, y: c }, draggable: !0, resizable: !1, content: this.panel.element, onClose: () => { this.engine.toolbar?.setBtnActive("section-plane", !1), this.hide(); } }); } /** * 隐藏弹窗 */ hide() { this.destroy(); } /** * 销毁弹窗 */ destroy() { this.dialog && (this.dialog.destroy(), this.dialog = null), this.panel && (this.panel.destroy(), this.panel = null); } } class h3 { element; options; // 状态 isHidden = !1; activeAxis = "x"; // DOM 引用 - 第一行 hideBtn; reverseBtn; hideLabelEl; reverseLabelEl; // DOM 引用 - 第二行 axisXBtn; axisYBtn; axisZBtn; // 订阅清理 unsubscribeLocale = null; unsubscribeTheme = null; constructor(e = {}) { this.options = e, this.isHidden = e.defaultHidden ?? !1, this.activeAxis = e.defaultAxis ?? "x", this.element = this.createDom(); } /** * 初始化组件 */ init() { this.unsubscribeLocale = Vt.subscribe(() => { this.setLocales(); }), this.unsubscribeTheme = st.subscribe((e) => { this.setTheme(e); }), this.setLocales(), this.setTheme(st.getTheme()), this.updateHideButtonState(), this.updateAxisButtonsState(); } /** * 设置主题 */ setTheme(e) { const t = this.element.style; t.setProperty("--bim-bg-inset", e.bgInset ?? "#152232"), t.setProperty("--bim-border-default", e.borderDefault ?? "#334155"), t.setProperty("--bim-border-strong", e.borderStrong ?? "#475569"), t.setProperty("--bim-divider", e.divider ?? "#334155"), t.setProperty("--bim-primary", e.primary ?? "#3b82f6"), t.setProperty("--bim-primary-subtle", e.primarySubtle ?? "rgba(59, 130, 246, 0.15)"), t.setProperty("--bim-icon-default", e.iconDefault ?? "#ffffff"), t.setProperty("--bim-text-primary", e.textPrimary ?? "#ffffff"), t.setProperty("--bim-component-bg-hover", e.componentBgHover ?? "rgba(248, 250, 252, 0.06)"); } /** * 设置语言 */ setLocales() { this.hideLabelEl.textContent = Ae("sectionAxis.actions.hide"), this.reverseLabelEl.textContent = Ae("sectionAxis.actions.reverse"), this.hideBtn.title = Ae("sectionAxis.actions.hide"), this.reverseBtn.title = Ae("sectionAxis.actions.reverse"), this.axisXBtn.title = Ae("sectionAxis.actions.axisX"), this.axisYBtn.title = Ae("sectionAxis.actions.axisY"), this.axisZBtn.title = Ae("sectionAxis.actions.axisZ"); } /** * 设置隐藏状态 */ setHiddenState(e) { this.isHidden = e, this.updateHideButtonState(); } /** * 获取隐藏状态 */ getHiddenState() { return this.isHidden; } /** * 设置激活的轴向 */ setActiveAxis(e) { this.activeAxis = e, this.updateAxisButtonsState(); } /** * 获取激活的轴向 */ getActiveAxis() { return this.activeAxis; } /** * 销毁组件 */ destroy() { this.unsubscribeLocale && (this.unsubscribeLocale(), this.unsubscribeLocale = null), this.unsubscribeTheme && (this.unsubscribeTheme(), this.unsubscribeTheme = null), this.element.remove(); } /** * 创建 DOM */ createDom() { const e = document.createElement("div"); e.className = "section-axis-panel"; const t = document.createElement("div"); t.className = "section-axis-row-1", this.hideBtn = this.createButton( "hide", At("隐藏"), () => this.handleHideToggle() ), this.reverseBtn = this.createButton( "reverse", At("反向"), () => this.handleReverse() ), t.appendChild(this.hideBtn), t.appendChild(this.reverseBtn); const n = document.createElement("div"); return n.className = "section-axis-row-2", this.axisXBtn = this.createAxisButton("axisX", "X", () => this.handleAxisChange("x")), this.axisYBtn = this.createAxisButton("axisY", "Y", () => this.handleAxisChange("y")), this.axisZBtn = this.createAxisButton("axisZ", "Z", () => this.handleAxisChange("z")), n.appendChild(this.axisXBtn), n.appendChild(this.axisYBtn), n.appendChild(this.axisZBtn), e.appendChild(t), e.appendChild(n), e; } /** * 创建按钮(带图标) */ createButton(e, t, n) { const i = document.createElement("button"); i.type = "button", i.className = "section-axis-btn"; const r = document.createElement("div"); r.className = "section-axis-btn-icon", r.innerHTML = t, i.appendChild(r); const a = document.createElement("div"); return a.className = "section-axis-btn-label", i.appendChild(a), e === "hide" ? this.hideLabelEl = a : e === "reverse" && (this.reverseLabelEl = a), i.addEventListener("click", n), i; } /** * 创建轴向按钮(仅文字) */ createAxisButton(e, t, n) { const i = document.createElement("button"); i.type = "button", i.className = "section-axis-btn section-axis-btn-text"; const r = document.createElement("div"); return r.className = "section-axis-btn-label", r.textContent = t, i.appendChild(r), i.addEventListener("click", n), i; } /** * 处理隐藏按钮切换 */ handleHideToggle() { this.isHidden = !this.isHidden, this.updateHideButtonState(), this.options.onHideToggle && this.options.onHideToggle(this.isHidden); } /** * 处理反向按钮点击 */ handleReverse() { this.options.onReverse && this.options.onReverse(); } /** * 处理轴向切换 */ handleAxisChange(e) { this.activeAxis !== e && (this.activeAxis = e, this.updateAxisButtonsState(), this.options.onAxisChange && this.options.onAxisChange(e)); } /** * 更新隐藏按钮状态 */ updateHideButtonState() { this.isHidden ? this.hideBtn.classList.add("active") : this.hideBtn.classList.remove("active"); } /** * 更新轴向按钮状态 */ updateAxisButtonsState() { this.axisXBtn.classList.toggle("active", this.activeAxis === "x"), this.axisYBtn.classList.toggle("active", this.activeAxis === "y"), this.axisZBtn.classList.toggle("active", this.activeAxis === "z"); } } class u3 extends hn { dialogId = "section-axis-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; } this.destroy(), this.panel = new h3({ defaultAxis: "x", defaultHidden: !1, onHideToggle: (c) => { console.log("[SectionAxisDialogManager] 隐藏切换:", c); }, onReverse: () => { console.log("[SectionAxisDialogManager] 反向剖切"); }, onAxisChange: (c) => { console.log("[SectionAxisDialogManager] 切换轴向:", c); } }), this.panel.init(); const e = 240, t = 20, n = 50, i = this.engine.container, r = i.clientWidth, a = i.clientHeight, o = r - e - t, l = a - n - 200; this.dialog = this.engine.dialog.create({ id: this.dialogId, title: "sectionAxis.dialogTitle", width: e, height: "auto", // 自动高度 position: { x: o, y: l }, draggable: !0, resizable: !1, content: this.panel.element, onClose: () => { this.engine.toolbar?.setBtnActive("section-axis", !1), this.hide(); } }), this.dialog.init(), this.dialog.fitHeight(!1); } /** * 隐藏弹窗 */ hide() { this.destroy(); } /** * 获取隐藏状态 */ getHiddenState() { return this.panel?.getHiddenState() ?? !1; } /** * 设置隐藏状态 */ setHiddenState(e) { this.panel?.setHiddenState(e); } /** * 获取当前激活的轴向 */ getActiveAxis() { return this.panel?.getActiveAxis() ?? "x"; } /** * 设置激活的轴向 */ setActiveAxis(e) { this.panel?.setActiveAxis(e); } /** * 销毁弹窗和面板 */ destroy() { this.dialog && (this.dialog.destroy(), this.dialog = null), this.panel && (this.panel.destroy(), this.panel = null); } } const Lu = { x: { min: 0, max: 100 }, y: { min: 0, max: 100 }, z: { min: 0, max: 100 } }; class d3 { element; options; isHidden = !1; isReversed = !1; range; hideBtn; reverseBtn; fitBtn; resetBtn; hideLabelEl; reverseLabelEl; fitLabelEl; resetLabelEl; xLabelEl; yLabelEl; zLabelEl; unsubscribeLocale = null; unsubscribeTheme = null; xSlider; ySlider; zSlider; xMinHandle; xMaxHandle; yMinHandle; yMaxHandle; zMinHandle; zMaxHandle; dragState = { isDragging: !1, axis: null, handleType: null, pointerId: null }; constructor(e = {}) { this.options = e, this.isHidden = e.defaultHidden ?? !1, this.isReversed = e.defaultReversed ?? !1, this.range = JSON.parse(JSON.stringify(e.defaultRange ?? Lu)); } init() { this.element = this.createPanel(), this.unsubscribeLocale = Vt.subscribe(() => this.setLocales()), this.unsubscribeTheme = st.subscribe((e) => this.setTheme(e)), this.setLocales(), this.setTheme(st.getTheme()), this.updateButtonStates(), this.updateAllSlidersUI(), this.setupDragListeners(); } // --- Public APIs --- setHiddenState(e) { this.isHidden = e, this.updateButtonStates(); } getHiddenState() { return this.isHidden; } setReversedState(e) { this.isReversed = e, this.updateButtonStates(); } getReversedState() { return this.isReversed; } setRange(e) { e.x && (this.range.x = { ...this.range.x, ...e.x }), e.y && (this.range.y = { ...this.range.y, ...e.y }), e.z && (this.range.z = { ...this.range.z, ...e.z }), this.updateAllSlidersUI(); } getRange() { return JSON.parse(JSON.stringify(this.range)); } reset() { this.isHidden = this.options.defaultHidden ?? !1, this.isReversed = this.options.defaultReversed ?? !1, this.range = JSON.parse(JSON.stringify(this.options.defaultRange ?? Lu)), this.updateButtonStates(), this.updateAllSlidersUI(), this.options.onReset?.(), this.options.onRangeChange?.(this.range); } // --- Private Setup --- createPanel() { const e = document.createElement("div"); e.className = "section-box-panel"; const t = document.createElement("div"); t.className = "section-box-row-buttons", this.hideBtn = this.createButton("hide", Ae("sectionBox.actions.hide"), () => { this.isHidden = !this.isHidden, this.updateButtonStates(), this.options.onHideToggle?.(this.isHidden); }, "hide"), this.reverseBtn = this.createButton("reverse", Ae("sectionBox.actions.reverse"), () => { this.isReversed = !this.isReversed, this.updateButtonStates(), this.options.onReverseToggle?.(this.isReversed); }, "reverse"), this.fitBtn = this.createButton("fit", Ae("sectionBox.actions.fitToModel"), () => { this.options.onFitToModel?.(); }, "fit"), this.resetBtn = this.createButton("reset", Ae("sectionBox.actions.reset"), () => this.reset(), "reset"), [this.hideBtn, this.reverseBtn, this.fitBtn, this.resetBtn].forEach((i) => t.appendChild(i)); const n = document.createElement("div"); return n.className = "section-box-sliders", n.addEventListener("pointerdown", (i) => i.stopPropagation()), this.xSlider = this.createSlider("x", Ae("sectionBox.axes.x")), this.ySlider = this.createSlider("y", Ae("sectionBox.axes.y")), this.zSlider = this.createSlider("z", Ae("sectionBox.axes.z")), [this.xSlider, this.ySlider, this.zSlider].forEach((i) => n.appendChild(i)), e.appendChild(t), e.appendChild(n), e; } createButton(e, t, n, i) { const r = document.createElement("button"); r.className = "section-box-btn", r.title = t; const a = { hide: "隐藏", reverse: "反向", fit: "适应到模型", reset: "重置" }, o = document.createElement("div"); o.className = "section-box-btn-icon", o.innerHTML = At(a[e] || e); const l = document.createElement("div"); return l.className = "section-box-btn-label", l.textContent = t, i === "hide" ? this.hideLabelEl = l : i === "reverse" ? this.reverseLabelEl = l : i === "fit" ? this.fitLabelEl = l : i === "reset" && (this.resetLabelEl = l), r.appendChild(o), r.appendChild(l), r.addEventListener("click", n), r; } createSlider(e, t) { const n = document.createElement("div"); n.className = "section-box-slider"; const i = document.createElement("div"); i.className = "section-box-slider-label", i.textContent = t, e === "x" ? this.xLabelEl = i : e === "y" ? this.yLabelEl = i : this.zLabelEl = i; const r = document.createElement("div"); r.className = "section-box-slider-track"; const a = document.createElement("div"); a.className = "section-box-slider-range"; const o = document.createElement("div"); o.className = "section-box-slider-handle", o.setAttribute("data-axis", e), o.setAttribute("data-handle", "min"); const l = document.createElement("div"); return l.className = "section-box-slider-handle", l.setAttribute("data-axis", e), l.setAttribute("data-handle", "max"), r.append(a, o, l), n.append(i, r), e === "x" ? (this.xMinHandle = o, this.xMaxHandle = l) : e === "y" ? (this.yMinHandle = o, this.yMaxHandle = l) : (this.zMinHandle = o, this.zMaxHandle = l), n; } setupDragListeners() { [this.xMinHandle, this.xMaxHandle, this.yMinHandle, this.yMaxHandle, this.zMinHandle, this.zMaxHandle].forEach((t) => { t.addEventListener("pointerdown", (i) => { i.preventDefault(), i.stopPropagation(), t.setPointerCapture(i.pointerId), this.dragState = { isDragging: !0, axis: t.getAttribute("data-axis"), handleType: t.getAttribute("data-handle"), pointerId: i.pointerId }, t.classList.add("dragging"), t.closest(".section-box-slider").style.zIndex = "100"; }), t.addEventListener("pointermove", (i) => { this.dragState.isDragging && this.dragState.pointerId === i.pointerId && this.onDragging(i); }); const n = (i) => { this.dragState.isDragging && this.dragState.pointerId === i.pointerId && (t.releasePointerCapture(i.pointerId), t.closest(".section-box-slider").style.zIndex = "", t.classList.remove("dragging"), this.dragState.isDragging = !1, this.dragState.pointerId = null); }; t.addEventListener("pointerup", n), t.addEventListener("pointercancel", n); }); } onDragging(e) { const { axis: t, handleType: n } = this.dragState; if (!t || !n) return; const a = (t === "x" ? this.xSlider : t === "y" ? this.ySlider : this.zSlider).querySelector(".section-box-slider-track").getBoundingClientRect(); let o = (e.clientX - a.left) / a.width * 100; o = Math.max(0, Math.min(100, o)); const l = this.range[t]; n === "min" ? l.min = Math.min(o, l.max) : l.max = Math.max(o, l.min), this.updateSliderUI(t), this.options.onRangeChange?.(this.range); } updateSliderUI(e) { const t = this.range[e], n = e === "x" ? this.xMinHandle : e === "y" ? this.yMinHandle : this.zMinHandle, i = e === "x" ? this.xMaxHandle : e === "y" ? this.yMaxHandle : this.zMaxHandle, a = (e === "x" ? this.xSlider : e === "y" ? this.ySlider : this.zSlider).querySelector(".section-box-slider-range"); n.style.left = `${t.min}%`, i.style.left = `${t.max}%`, a.style.left = `${t.min}%`, a.style.width = `${t.max - t.min}%`, n.setAttribute("data-value", Math.round(t.min).toString()), i.setAttribute("data-value", Math.round(t.max).toString()); } updateAllSlidersUI() { ["x", "y", "z"].forEach((e) => this.updateSliderUI(e)); } updateButtonStates() { this.hideBtn && this.hideBtn.classList.toggle("active", this.isHidden), this.reverseBtn && this.reverseBtn.classList.toggle("active", this.isReversed); } setLocales() { this.hideLabelEl && (this.hideLabelEl.textContent = Ae("sectionBox.actions.hide"), this.reverseLabelEl.textContent = Ae("sectionBox.actions.reverse"), this.fitLabelEl.textContent = Ae("sectionBox.actions.fitToModel"), this.resetLabelEl.textContent = Ae("sectionBox.actions.reset"), this.xLabelEl.textContent = Ae("sectionBox.axes.x"), this.yLabelEl.textContent = Ae("sectionBox.axes.y"), this.zLabelEl.textContent = Ae("sectionBox.axes.z"), this.hideBtn.title = Ae("sectionBox.actions.hide"), this.reverseBtn.title = Ae("sectionBox.actions.reverse"), this.fitBtn.title = Ae("sectionBox.actions.fitToModel"), this.resetBtn.title = Ae("sectionBox.actions.reset")); } setTheme(e) { if (!this.element) return; const t = this.element.style; t.setProperty("--bim-bg-inset", e.bgInset ?? "#152232"), t.setProperty("--bim-bg-elevated", e.bgElevated ?? "#1f2d3e"), t.setProperty("--bim-border-default", e.borderDefault ?? "#334155"), t.setProperty("--bim-border-strong", e.borderStrong ?? "#475569"), t.setProperty("--bim-divider", e.divider ?? "#334155"), t.setProperty("--bim-primary", e.primary ?? "#3b82f6"), t.setProperty("--bim-primary-subtle", e.primarySubtle ?? "rgba(59, 130, 246, 0.15)"), t.setProperty("--bim-icon-default", e.iconDefault ?? "#ffffff"), t.setProperty("--bim-text-primary", e.textPrimary ?? "#ffffff"), t.setProperty("--bim-component-bg-hover", e.componentBgHover ?? "rgba(248, 250, 252, 0.06)"); } destroy() { this.unsubscribeLocale?.(), this.unsubscribeTheme?.(), this.element && this.element.parentElement && this.element.parentElement.removeChild(this.element); } } class f3 extends hn { dialogId = "section-box-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; } this.destroy(), this.panel = new d3({ defaultHidden: !1, defaultReversed: !1, onHideToggle: (c) => { console.log("[SectionBoxDialogManager] 隐藏切换:", c); }, onReverseToggle: (c) => { console.log("[SectionBoxDialogManager] 反向切换:", c); }, onFitToModel: () => { console.log("[SectionBoxDialogManager] 适应到模型"); }, onReset: () => { console.log("[SectionBoxDialogManager] 重置"); }, onRangeChange: (c) => { console.log("[SectionBoxDialogManager] 范围变化:", c); } }), this.panel.init(); const e = 280, t = 20, n = 50, i = this.engine.container, r = i.clientWidth, a = i.clientHeight, o = r - e - t, l = a - n - 300; this.dialog = this.engine.dialog.create({ id: this.dialogId, title: "sectionBox.dialogTitle", width: e, height: "auto", position: { x: o, y: l }, draggable: !0, resizable: !1, content: this.panel.element, onClose: () => { this.engine.toolbar?.setBtnActive("section-box", !1), this.hide(); } }), this.dialog.init(), this.dialog.fitHeight(!1); } /** * 隐藏弹窗 */ hide() { this.destroy(); } /** * 获取隐藏状态 */ getHiddenState() { return this.panel?.getHiddenState() ?? !1; } /** * 设置隐藏状态 */ setHiddenState(e) { this.panel?.setHiddenState(e); } /** * 获取反向状态 */ getReversedState() { return this.panel?.getReversedState() ?? !1; } /** * 设置反向状态 */ setReversedState(e) { this.panel?.setReversedState(e); } /** * 获取范围值 */ getRange() { return this.panel?.getRange() ?? null; } /** * 设置范围值 */ setRange(e) { this.panel?.setRange(e); } /** * 销毁弹窗和面板 */ destroy() { this.dialog && (this.dialog.destroy(), this.dialog = null), this.panel && (this.panel.destroy(), this.panel = null); } } class p3 { element; options; // 状态 state = { mode: "none", isPlanViewActive: !1, speed: 1, gravity: !1, collision: !1, characterModel: "construction-worker", walkMode: "walk" }; // DOM 引用 - 左侧按钮 planViewBtn; pathModeBtn; walkModeBtn; // DOM 引用 - 中间设置区 settingsContainer; speedControl; speedDecreaseBtn; speedIncreaseBtn; speedDisplay; gravityCheckbox; gravityLabel; collisionCheckbox; collisionLabel; characterModelSelect; characterModelLabel; walkModeSelect; walkModeLabel; // DOM 引用 - 退出按钮 exitBtn; // 国际化订阅 unsubscribeLocale = null; unsubscribeTheme = null; constructor(e = {}) { this.options = e, this.state.speed = e.defaultSpeed ?? 1, this.state.gravity = e.defaultGravity ?? !1, this.state.collision = e.defaultCollision ?? !1, this.state.characterModel = e.defaultCharacterModel ?? "construction-worker", this.state.walkMode = e.defaultWalkMode ?? "walk"; } init() { this.element = this.createPanel(), this.updateSettingsView(), this.unsubscribeLocale = Vt.subscribe(() => this.setLocales()), this.unsubscribeTheme = st.subscribe((e) => this.setTheme(e)), this.setLocales(), this.setTheme(st.getTheme()); } // --- 公共方法 --- setPlanViewActive(e) { this.state.isPlanViewActive = e, this.updateButtonStates(); } setPathModeActive(e) { if (!e && this.state.mode !== "path") return; const t = e ? "path" : "none"; this.setMode(t); } getState() { return { ...this.state }; } // --- 私有方法 --- createPanel() { const e = document.createElement("div"); e.className = "walk-control-panel"; const t = this.createLeftButtons(), n = document.createElement("div"); n.className = "walk-divider", this.settingsContainer = this.createSettingsContainer(); const i = document.createElement("div"); i.className = "walk-divider"; const r = this.createExitButton(); return e.appendChild(t), e.appendChild(n), e.appendChild(this.settingsContainer), e.appendChild(i), e.appendChild(r), e; } createLeftButtons() { const e = document.createElement("div"); return e.className = "walk-control-left", this.planViewBtn = this.createIconButton("plan-view", () => { this.state.isPlanViewActive = !this.state.isPlanViewActive, this.updateButtonStates(), this.options.onPlanViewToggle?.(this.state.isPlanViewActive); }), this.pathModeBtn = this.createIconButton("path", () => { const t = this.state.mode === "path" ? "none" : "path"; this.setMode(t), this.options.onPathModeToggle?.(t === "path"); }), this.walkModeBtn = this.createIconButton("walk", () => { const t = this.state.mode === "walk" ? "none" : "walk"; this.setMode(t), this.options.onWalkModeToggle?.(t === "walk"); }), e.appendChild(this.planViewBtn), e.appendChild(this.pathModeBtn), e.appendChild(this.walkModeBtn), e; } createSettingsContainer() { const e = document.createElement("div"); e.className = "walk-control-settings", this.speedControl = this.createSpeedControl(); const t = document.createElement("label"); t.className = "walk-checkbox-wrapper walk-checkbox-gravity", this.gravityCheckbox = document.createElement("input"), this.gravityCheckbox.type = "checkbox", this.gravityCheckbox.className = "walk-checkbox", this.gravityCheckbox.checked = this.state.gravity, this.gravityCheckbox.addEventListener("change", () => { this.state.gravity = this.gravityCheckbox.checked, this.options.onGravityToggle?.(this.state.gravity); }), this.gravityLabel = document.createElement("span"), this.gravityLabel.className = "walk-checkbox-label", t.appendChild(this.gravityCheckbox), t.appendChild(this.gravityLabel); const n = document.createElement("label"); n.className = "walk-checkbox-wrapper walk-checkbox-collision", this.collisionCheckbox = document.createElement("input"), this.collisionCheckbox.type = "checkbox", this.collisionCheckbox.className = "walk-checkbox", this.collisionCheckbox.checked = this.state.collision, this.collisionCheckbox.addEventListener("change", () => { this.state.collision = this.collisionCheckbox.checked, this.options.onCollisionToggle?.(this.state.collision); }), this.collisionLabel = document.createElement("span"), this.collisionLabel.className = "walk-checkbox-label", n.appendChild(this.collisionCheckbox), n.appendChild(this.collisionLabel); const i = document.createElement("div"); i.className = "walk-select-wrapper walk-select-wrapper-character-model", this.characterModelLabel = document.createElement("label"), this.characterModelLabel.className = "walk-select-label", this.characterModelSelect = document.createElement("select"), this.characterModelSelect.className = "walk-select walk-select-character-model", this.characterModelSelect.addEventListener("change", () => { this.state.characterModel = this.characterModelSelect.value, this.options.onCharacterModelChange?.(this.state.characterModel); }), i.appendChild(this.characterModelLabel), i.appendChild(this.characterModelSelect); const r = document.createElement("div"); return r.className = "walk-select-wrapper walk-select-wrapper-walk-mode", this.walkModeLabel = document.createElement("label"), this.walkModeLabel.className = "walk-select-label", this.walkModeSelect = document.createElement("select"), this.walkModeSelect.className = "walk-select walk-select-walk-mode", this.walkModeSelect.addEventListener("change", () => { this.state.walkMode = this.walkModeSelect.value, this.options.onWalkModeChange?.(this.state.walkMode); }), r.appendChild(this.walkModeLabel), r.appendChild(this.walkModeSelect), e.appendChild(this.speedControl), e.appendChild(i), e.appendChild(r), e.appendChild(t), e.appendChild(n), e; } createSpeedControl() { const e = document.createElement("div"); e.className = "walk-speed-control"; const t = document.createElement("label"); t.className = "walk-speed-label", t.textContent = Ae("walkControl.speed"); const n = document.createElement("div"); return n.className = "walk-speed-group", this.speedDecreaseBtn = document.createElement("button"), this.speedDecreaseBtn.className = "walk-speed-btn", this.speedDecreaseBtn.textContent = "-", this.speedDecreaseBtn.addEventListener("click", () => { this.state.speed > 1 && (this.state.speed--, this.updateSpeedDisplay(), this.options.onSpeedChange?.(this.state.speed)); }), this.speedDisplay = document.createElement("div"), this.speedDisplay.className = "walk-speed-display", this.speedDisplay.textContent = `${this.state.speed}X`, this.speedIncreaseBtn = document.createElement("button"), this.speedIncreaseBtn.className = "walk-speed-btn", this.speedIncreaseBtn.textContent = "+", this.speedIncreaseBtn.addEventListener("click", () => { this.state.speed < 10 && (this.state.speed++, this.updateSpeedDisplay(), this.options.onSpeedChange?.(this.state.speed)); }), n.appendChild(this.speedDecreaseBtn), n.appendChild(this.speedDisplay), n.appendChild(this.speedIncreaseBtn), e.appendChild(t), e.appendChild(n), e; } createIconButton(e, t) { const n = document.createElement("button"); return n.className = `walk-icon-btn walk-icon-btn-${e}`, n.innerHTML = this.getIconSVG(e), n.addEventListener("click", t), n; } createExitButton() { const e = document.createElement("button"); return e.className = "walk-exit-btn", e.addEventListener("click", () => { this.options.onExit?.(); }), this.exitBtn = e, e; } setMode(e) { const t = this.state.mode; t === "walk" && e !== "walk" && this.options.onWalkModeToggle?.(!1), t === "path" && e !== "path" && this.options.onPathModeToggle?.(!1), this.state.mode = e, e === "path" ? (this.state.gravity = !1, this.state.collision = !1, this.gravityCheckbox.checked = !1, this.gravityCheckbox.disabled = !0, this.collisionCheckbox.checked = !1, this.collisionCheckbox.disabled = !0) : (this.gravityCheckbox.disabled = !1, this.collisionCheckbox.disabled = !1), this.updateButtonStates(), this.updateSettingsView(), this.updateSpeedButtonStates(); } updateButtonStates() { this.planViewBtn.classList.toggle("active", this.state.isPlanViewActive), this.pathModeBtn.classList.toggle("active", this.state.mode === "path"), this.walkModeBtn.classList.toggle("active", this.state.mode === "walk"); } updateSettingsView() { const e = this.speedControl, t = this.gravityCheckbox.parentElement, n = this.collisionCheckbox.parentElement, i = this.characterModelSelect.parentElement, r = this.walkModeSelect.parentElement; this.state.mode === "walk" ? (e.style.display = "none", t.style.display = "flex", n.style.display = "flex", i.style.display = "flex", r.style.display = "flex") : (e.style.display = "flex", t.style.display = "flex", n.style.display = "flex", i.style.display = "none", r.style.display = "none"); } updateSpeedDisplay() { this.speedDisplay.textContent = `${this.state.speed}X`, this.updateSpeedButtonStates(); } updateSpeedButtonStates() { this.speedDecreaseBtn.disabled = this.state.speed <= 1, this.speedIncreaseBtn.disabled = this.state.speed >= 10; } getIconSVG(e) { return { "plan-view": At("地图"), path: At("路径漫游"), walk: At("第一人称漫游") }[e] || ""; } setLocales() { const e = this.speedControl.querySelector(".walk-speed-label"); e && (e.textContent = Ae("walkControl.speed")), this.gravityLabel.textContent = Ae("walkControl.gravity"), this.collisionLabel.textContent = Ae("walkControl.collision"), this.characterModelLabel.textContent = Ae("walkControl.characterModel.label"), this.characterModelSelect.innerHTML = ""; const t = document.createElement("option"); t.value = "construction-worker", t.textContent = Ae("walkControl.characterModel.constructionWorker"), t.selected = this.state.characterModel === "construction-worker", this.characterModelSelect.appendChild(t); const n = document.createElement("option"); n.value = "office-male", n.textContent = Ae("walkControl.characterModel.officeMale"), n.selected = this.state.characterModel === "office-male", this.characterModelSelect.appendChild(n), this.walkModeLabel.textContent = Ae("walkControl.walkMode.label"), this.walkModeSelect.innerHTML = ""; const i = document.createElement("option"); i.value = "walk", i.textContent = Ae("walkControl.walkMode.walk"), i.selected = this.state.walkMode === "walk", this.walkModeSelect.appendChild(i); const r = document.createElement("option"); r.value = "run", r.textContent = Ae("walkControl.walkMode.run"), r.selected = this.state.walkMode === "run", this.walkModeSelect.appendChild(r), this.exitBtn.textContent = Ae("walkControl.exit"); } setTheme(e) { if (!this.element) return; const t = this.element.style; t.setProperty("--bim-bg-base", e.bgBase ?? "#152232"), t.setProperty("--bim-bg-elevated", e.bgElevated ?? "#1f2d3e"), t.setProperty("--bim-bg-inset", e.bgInset ?? "#152232"), t.setProperty("--bim-border-default", e.borderDefault ?? "#334155"), t.setProperty("--bim-border-strong", e.borderStrong ?? "#475569"), t.setProperty("--bim-border-subtle", e.borderSubtle ?? "#1e293b"), t.setProperty("--bim-divider", e.divider ?? "#334155"), t.setProperty("--bim-shadow-xl", e.shadowXl ?? "0 20px 40px rgba(0, 0, 0, 0.3)"), t.setProperty("--bim-primary", e.primary ?? "#3b82f6"), t.setProperty("--bim-primary-hover", e.primaryHover ?? "#60a5fa"), t.setProperty("--bim-primary-subtle", e.primarySubtle ?? "rgba(59, 130, 246, 0.15)"), t.setProperty("--bim-text-primary", e.textPrimary ?? "#ffffff"), t.setProperty("--bim-text-inverse", e.textInverse ?? "#152232"), t.setProperty("--bim-icon-default", e.iconDefault ?? "#ffffff"), t.setProperty("--bim-component-bg-hover", e.componentBgHover ?? "rgba(248, 250, 252, 0.06)"), t.setProperty("--bim-component-bg-active", e.componentBgActive ?? "rgba(248, 250, 252, 0.1)"); } destroy() { this.unsubscribeLocale?.(), this.unsubscribeTheme?.(), this.element && this.element.parentElement && this.element.parentElement.removeChild(this.element); } } class m3 { element; unsubscribeLocale = null; unsubscribeTheme = null; constructor() { } init() { this.element = this.createPanel(), this.unsubscribeLocale = Vt.subscribe(() => this.setLocales()), this.unsubscribeTheme = st.subscribe((e) => this.setTheme(e)), this.setLocales(), this.setTheme(st.getTheme()); } createPanel() { const e = document.createElement("div"); return e.className = "walk-path-panel", e.style.padding = "20px", e.style.color = "var(--bim-text-color, #fff)", e.textContent = "路径漫游内容待实现", e; } setLocales() { } setTheme(e) { } destroy() { this.unsubscribeLocale?.(), this.unsubscribeTheme?.(), this.element && this.element.parentElement && this.element.parentElement.removeChild(this.element); } } class g3 extends hn { dialogId = "walk-path-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; } this.destroy(), this.panel = new m3(), this.panel.init(); const e = 300, t = 400, n = 20, i = this.engine.container, r = i.clientHeight, o = i.clientWidth - e - n, l = (r - t) / 2; this.dialog = this.engine.dialog.create({ id: this.dialogId, title: "walkControl.path.dialogTitle", width: e, height: t, position: { x: o, y: l }, draggable: !0, resizable: !1, content: this.panel.element, onClose: () => { this.engine.walkControl && this.engine.walkControl.panel && this.engine.walkControl.panel.setPathModeActive(!1), this.hide(); } }), this.dialog.init(); } /** * 隐藏弹窗 */ hide() { this.destroy(); } /** * 销毁弹窗和面板 */ destroy() { const e = this.dialog; this.dialog = null, e && e.destroy(), this.panel && (this.panel.destroy(), this.panel = null); } } class x3 extends hn { panel = null; pathManager = null; constructor(e) { super(e); } init() { this.pathManager = new g3(this.engine), this.pathManager.init(); } /** * 显示漫游控制面板 */ show() { if (!this.engine.toolbar) { console.warn("Toolbar not initialized"); return; } this.engine.toolbar.hide(), this.panel = new p3({ onPlanViewToggle: (e) => { console.log("[WalkControl] 地图:", e), e ? this.engine.map?.show() : this.engine.map?.hide(), this.emit("walk:plan-view-toggle", { isActive: e }); }, onPathModeToggle: (e) => { console.log("[WalkControl] 路径漫游:", e), e ? this.pathManager?.show() : this.pathManager?.hide(), this.emit("walk:path-mode-toggle", { isActive: e }); }, onWalkModeToggle: (e) => { console.log("[WalkControl] 漫游模式:", e), e && this.pathManager?.hide(), this.emit("walk:walk-mode-toggle", { isActive: e }); }, onSpeedChange: (e) => { console.log("[WalkControl] 速度变化:", e), this.emit("walk:speed-change", { speed: e }); }, onGravityToggle: (e) => { console.log("[WalkControl] 重力:", e), this.emit("walk:gravity-toggle", { enabled: e }); }, onCollisionToggle: (e) => { console.log("[WalkControl] 碰撞:", e), this.emit("walk:collision-toggle", { enabled: e }); }, onCharacterModelChange: (e) => { console.log("[WalkControl] 角色模型:", e); }, onWalkModeChange: (e) => { console.log("[WalkControl] 行走模式:", e); }, onExit: () => { this.hide(); } }), this.panel.init(), this.engine.map?.isOpen() && this.panel.setPlanViewActive(!0), this.engine.on("map:opened", () => { this.panel?.setPlanViewActive(!0); }), this.engine.on("map:closed", () => { this.panel?.setPlanViewActive(!1); }), this.engine.container ? (this.panel.element.style.position = "absolute", this.panel.element.style.bottom = "20px", this.panel.element.style.left = "50%", this.panel.element.style.transform = "translateX(-50%)", this.panel.element.style.zIndex = "1000", this.engine.container.appendChild(this.panel.element)) : console.warn("[WalkControlManager] Container not found"); } /** * 隐藏漫游控制面板 */ hide() { this.pathManager?.hide(), this.panel && (this.panel.destroy(), this.panel = null), this.engine.toolbar && this.engine.toolbar.show(); } /** * 销毁管理器 */ destroy() { this.hide(), this.pathManager?.destroy(), this.pathManager = null; } } class v3 { element; unsubscribeLocale = null; unsubscribeTheme = null; constructor() { } init() { this.element = this.createPanel(), this.unsubscribeLocale = Vt.subscribe(() => this.setLocales()), this.unsubscribeTheme = st.subscribe((e) => this.setTheme(e)), this.setLocales(), this.setTheme(st.getTheme()); } createPanel() { const e = document.createElement("div"); return e.className = "map-panel", e.style.padding = "20px", e.style.color = "#fff", e.textContent = "地图内容待实现", e; } setLocales() { } setTheme(e) { } destroy() { this.unsubscribeLocale?.(), this.unsubscribeTheme?.(), this.element && this.element.parentElement && this.element.parentElement.removeChild(this.element); } } class b3 extends hn { dialogId = "map-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; } if (this.isOpen()) return; this.panel = new v3(), this.panel.init(); const e = 300, t = 400, n = 20, i = 20, a = this.engine.container.clientHeight, o = n, l = a - t - i; this.dialog = this.engine.dialog.create({ id: this.dialogId, title: "map.dialogTitle", width: e, height: t, position: { x: o, y: l }, draggable: !0, resizable: !1, content: this.panel.element, onClose: () => { this.hide(); } }), this.dialog.init(), this.emit("map:opened", {}); } /** * 隐藏弹窗 */ hide() { this.destroy(), this.emit("map:closed", {}); } /** * 检查地图是否打开 */ isOpen() { return this.dialog !== null; } /** * 销毁弹窗和面板 */ destroy() { const e = this.dialog; this.dialog = null, e && e.destroy(), this.panel && (this.panel.destroy(), this.panel = null); } } class _3 { events = /* @__PURE__ */ new Map(); on(e, t) { return this.events.has(e) || this.events.set(e, []), this.events.get(e).push(t), () => this.off(e, t); } off(e, t) { const n = this.events.get(e); if (!n) return; const i = n.indexOf(t); i !== -1 && n.splice(i, 1); } emit(e, t) { const n = this.events.get(e); n && n.forEach((i) => { try { i(t); } catch (r) { console.error(`[EventEmitter] Error in listener for event "${e}":`, r); } }); } clear() { this.events.clear(); } } class hM extends _3 { container; wrapper = null; toolbar = null; // 底部专用 constructTreeBtn = null; // 底部专用 buttonGroup = null; // 通用 dialog = null; engine = null; // 3D 引擎管理器 rightKey = null; // 右键菜单管理器 propertyPanel = null; // 属性面板 (演示 Collapse) measure = null; // 测量面板 sectionPlane = null; // 拾取面剖切面板 sectionAxis = null; // 轴向剖切面板 sectionBox = null; // 剖切盒面板 walkControl = null; // 漫游控制面板 map = null; // 地图面板 constructor(e, t) { super(); const n = typeof e == "string" ? document.getElementById(e) : e; if (!n) throw new Error("Container not found"); this.container = n, t?.locale && Vt.setLocale(t.locale), t?.theme && (t.theme === "custom" ? console.warn("Custom theme should be set via setCustomTheme().") : st.setTheme(t.theme)), this.init(); } // Typed wrappers for events emit(e, t) { super.emit(e, t); } on(e, t) { return super.on(e, t); } setLocale(e) { Vt.setLocale(e); } getLocale() { return Vt.getLocale(); } setTheme(e) { st.setTheme(e); } setCustomTheme(e) { st.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 Qy(this, this.wrapper), this.dialog = new Af(this, this.wrapper), this.toolbar = new Ef(this, this.wrapper), this.buttonGroup = new Tf(this, this.wrapper), this.rightKey = new hf(this, this.wrapper), this.constructTreeBtn = new i3(this, this.wrapper), this.propertyPanel = new r3(this), this.measure = new o3(this), this.sectionPlane = new c3(this), this.sectionAxis = new u3(this), this.sectionBox = new f3(this), this.walkControl = new x3(this), this.walkControl.init(), this.map = new b3(this), this.map.init(), this.updateTheme(st.getTheme()), st.subscribe((e) => { this.updateTheme(e); }); } updateTheme(e) { this.wrapper && (this.wrapper.style.color = e.textPrimary); } destroy() { this.toolbar?.destroy(), this.buttonGroup?.destroy(), this.engine?.destroy(), this.dialog?.destroy(), this.rightKey?.destroy(), this.propertyPanel?.destroy(), this.measure?.destroy(), this.sectionPlane?.destroy(), this.sectionAxis?.destroy(), this.sectionBox?.destroy(), this.walkControl?.destroy(), this.container.innerHTML = "", this.clear(); } } const y3 = (s) => ({ id: "home", groupId: "group-1", type: "button", label: "toolbar.home", icon: At("主视角"), keepActive: !1, onClick: (e) => { console.log("首页按钮被点击:", e.id), s.engine?.CameraGoHome(); } }), M3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createHomeButton: y3 }, Symbol.toStringTag, { value: "Module" })), S3 = (s) => ({ id: "zoom-box", groupId: "group-1", keepActive: !1, type: "button", label: "toolbar.zoomBox", icon: At("框选放大"), onClick: () => { s.engine?.getEngine().rangeScale.active(); } }), w3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createZoomBoxButton: S3 }, Symbol.toStringTag, { value: "Module" })), E3 = (s) => ({ id: "walk", groupId: "group-1", type: "button", label: "toolbar.walk", align: "vertical", icon: At("漫游"), onClick: () => { console.log("漫游按钮被点击"), s.walkControl?.show(); } }), T3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createWalkMenuButton: E3 }, Symbol.toStringTag, { value: "Module" })), C3 = (s) => (s.on("map:opened", () => { s.toolbar?.setBtnActive("map", !0); }), s.on("map:closed", () => { s.toolbar?.setBtnActive("map", !1); }), { id: "map", groupId: "group-1", type: "button", label: "toolbar.map", align: "vertical", keepActive: !0, icon: At("地图"), onClick: () => { s.map?.isOpen() ? s.map?.hide() : s.map?.show(); } }), A3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createMapButton: C3 }, Symbol.toStringTag, { value: "Module" })), P3 = (s) => ({ id: "property", groupId: "group-1", type: "button", label: "toolbar.property", align: "vertical", icon: At("文档"), onClick: () => { console.log("构件详情按钮被点击"), s.propertyPanel?.show(); } }), R3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createPropertyButton: P3 }, Symbol.toStringTag, { value: "Module" })), L3 = (s) => ({ id: "setting", groupId: "group-2", type: "button", label: "toolbar.setting", icon: At("设置"), keepActive: !1, onClick: (e) => { console.log("设置按钮被点击:", e.id); } }), D3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createSettingButton: L3 }, Symbol.toStringTag, { value: "Module" })), I3 = '', N3 = (s) => ({ id: "toolbar-info", groupId: "group-2", type: "button", label: "toolbar.info", icon: I3, onClick: () => { document.dispatchEvent(new CustomEvent("bim-demo:open-property-panel")); } }), k3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createInfoButton: N3 }, Symbol.toStringTag, { value: "Module" })), U3 = (s) => ({ id: "fullscreen", groupId: "group-2", type: "button", label: "toolbar.fullscreen", align: "vertical", icon: At("全屏"), onClick: async () => { console.log("全屏按钮被点击"), window.self !== window.top && console.warn('检测到在 Iframe 中运行,请确保父级 iframe 标签拥有 allow="fullscreen" 属性'); try { const t = document, i = !!(t.fullscreenElement || t.webkitFullscreenElement || t.mozFullScreenElement || t.msFullscreenElement); console.log("当前是否全屏:", i); const a = document.querySelector(".bim-engine-container") || document.body, o = a; if (i) { console.log("准备退出全屏..."); const l = t.exitFullscreen || t.webkitExitFullscreen || t.mozCancelFullScreen || t.msExitFullscreen; l && (await l.call(t), console.log("退出全屏请求已发送")); } else { console.log("准备进入全屏..."), (a.style.backgroundColor === "" || a.style.backgroundColor === "transparent") && (a.style.backgroundColor = "#ffffff"); const l = o.requestFullscreen || o.webkitRequestFullscreen || o.mozRequestFullScreen || o.msRequestFullscreen; l ? (await l.call(o, { navigationUI: "hide" }), console.log("全屏请求已发送")) : (console.warn("当前浏览器不支持全屏 API"), alert("当前浏览器不支持全屏功能")); } } catch (t) { console.error("全屏操作失败:", t), t && t.message && t.message.includes("denied") && console.error('全屏请求被拒绝。如果是 Iframe,请检查 allow="fullscreen"。如果是自动触发,请确保由用户点击触发。'); } } }), B3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createFullscreenButton: U3 }, Symbol.toStringTag, { value: "Module" })), O3 = (s) => ({ id: "measure", groupId: "group-1", type: "button", label: "toolbar.measure", icon: At("测量"), keepActive: !0, onClick: (e) => { e.isActive ? s.measure?.show() : s.measure?.destroy(); } }), F3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createMeasureButton: O3 }, Symbol.toStringTag, { value: "Module" })), z3 = (s) => ({ id: "section", groupId: "group-1", type: "menu", label: "toolbar.section", align: "vertical", icon: At("剖切"), keepActive: !0, onClick: (e) => { console.log("剖切按钮被点击:", e.id); } }), H3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createSectionMenuButton: z3 }, Symbol.toStringTag, { value: "Module" })), V3 = (s) => ({ id: "section-plane", groupId: "group-1", parentId: "section", type: "button", keepActive: !0, exclusive: !0, align: "vertical", label: "toolbar.sectionPlane", icon: At("拾曲面剖切"), onClick: (e) => { console.log("拾取面剖切被点击:", e.id, "激活状态:", e.isActive), e.isActive ? s.sectionPlane?.show() : s.sectionPlane?.hide(); } }), G3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createSectionPlaneButton: V3 }, Symbol.toStringTag, { value: "Module" })), W3 = (s) => ({ id: "section-axis", groupId: "group-1", parentId: "section", type: "button", keepActive: !0, exclusive: !0, align: "vertical", label: "toolbar.sectionAxis", icon: At("轴向剖切"), onClick: (e) => { e.isActive ? s.sectionAxis?.show() : s.sectionAxis?.destroy(); } }), X3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createSectionAxisButton: W3 }, Symbol.toStringTag, { value: "Module" })), j3 = (s) => ({ id: "section-box", groupId: "group-1", parentId: "section", type: "button", keepActive: !0, exclusive: !0, align: "vertical", label: "toolbar.sectionBox", icon: At("剖切盒"), onClick: (e) => { console.log("剖切盒被点击:", e.id, "激活状态:", e.isActive), e.isActive ? s.sectionBox?.show() : s.sectionBox?.hide(); } }), Z3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, createSectionBoxButton: j3 }, Symbol.toStringTag, { value: "Module" })); export { hM as BimEngine }; //# sourceMappingURL=iflow-engine.es.js.map