diff --git a/GC-UI/frontend/courseware/assets/app.js b/GC-UI/frontend/courseware/assets/app.js new file mode 100644 index 0000000..0dc43b7 --- /dev/null +++ b/GC-UI/frontend/courseware/assets/app.js @@ -0,0 +1,663 @@ +(function () { + "use strict"; + + const STEP_COPY = [ + { title: "等高切割", description: "观察水平面与山体在同一海拔相交,形成连续闭合线。" }, + { title: "形成交线", description: "每个水平切面都会留下同高交线,多层交线共同描述山体起伏。" }, + { title: "投影成图", description: "把各高度交线垂直投影到同一平面,得到完整等高线地形图。" }, + { title: "疏密判坡", description: "等高线越密,坡度越陡;等高线越疏,坡度越缓。" } + ]; + + const DEFAULT_VIEW = { + title: "实验流程", + summary: "点击开始实验,在当前背景中观察等高切割与交线形成,再通过右侧图解理解垂直投影和疏密判坡。", + features: ["同一条等高线上海拔相等", "相邻等高线高差保持一致"], + hint: "点击“开始实验”,直接在当前画面播放形成交线视频" + }; + + const LANDFORMS = { + peak: { + name: "山峰", + subtitle: "闭合等高线", + image: "assets/peak-3d.jpg", + topImage: "assets/peak-top.jpg", + alt: "山峰立体示意图,蓝色等高线围绕山体逐级闭合", + topAlt: "山峰真实俯视图,多层近同心闭合等高线向中心收缩", + summary: "山峰四周较低、中心突起;等高线闭合成环,海拔数值由外向内逐渐升高。", + features: ["中心海拔高、四周海拔低", "闭合线越向内,数值越大", "若数值向内降低,则应判为洼地"], + hint: "山峰:闭合曲线,数值向中心升高" + }, + ridge: { + name: "山脊", + subtitle: "凸低为脊", + image: "assets/ridge-3d.jpg", + topImage: "assets/ridge-top.jpg", + alt: "山脊立体示意图,蓝色等高线沿凸出的脊线向低处弯曲", + topAlt: "山脊真实俯视图,等高线沿狭长高地呈舌状延伸", + summary: "等高线弯曲部分向海拔低处凸出,脊线常成为两侧水系的分水岭。", + features: ["等高线凸向低值方向", "脊线由高处向低处延伸", "雨水沿脊线两侧分流"], + hint: "山脊:等高线向低处凸出,凸低为脊" + }, + valley: { + name: "山谷", + subtitle: "凸高为谷", + image: "assets/valley-3d.jpg", + topImage: "assets/valley-top.jpg", + alt: "山谷立体示意图,两座山体之间的谷地有河流穿过", + topAlt: "山谷真实俯视图,两侧坡面夹持低槽,等高线形成 V 形凹入", + summary: "等高线弯曲部分向海拔高处凸出,谷底低洼并容易汇水形成河流。", + features: ["等高线凸向高值方向", "V 形尖端指向上游高处", "谷底常发育河流"], + hint: "山谷:等高线向高处凸出,凸高为谷" + }, + saddle: { + name: "鞍部", + subtitle: "两峰之间", + image: "assets/saddle-3d.jpg", + topImage: "assets/saddle-top.jpg", + alt: "鞍部立体示意图,两座山峰之间形成马鞍状低地", + topAlt: "鞍部真实俯视图,两组峰顶闭合圈之间的等高线明显收腰", + summary: "鞍部位于相邻两座山峰之间,是沿山脊方向相对低洼的过渡地带。", + features: ["两组闭合等高线相邻", "中部线条收窄,形似马鞍", "常是翻越山岭的低垭口"], + hint: "鞍部:两峰之间相对低洼,俯视轮廓呈收腰形" + }, + cliff: { + name: "陡崖", + subtitle: "密集或重合", + image: "assets/cliff-3d.jpg", + topImage: "assets/cliff-top.jpg", + alt: "陡崖立体示意图,崖壁处蓝色等高线高度密集", + topAlt: "陡崖真实俯视图,崖壁处大量等高线极密集并近似重合", + summary: "陡崖坡面近直立,不同高程的等高线会高度密集,局部可投影到同一位置而重合。", + features: ["密集表示陡坡,重合才是陡崖特征", "单位水平距离内高差很大", "n 条线重合时:(n−1)d ≤ ΔH < (n+1)d"], + hint: "陡崖:等高线密集或重合,坡度极陡" + } + }; + + const dom = { + app: document.getElementById("app-shell"), + experimentVideo: document.getElementById("experiment-video"), + densityBackground: document.getElementById("density-background"), + landformImage: document.getElementById("landform-image"), + landformTopImage: document.getElementById("landform-top-image"), + projectionDiagram: document.getElementById("projection-diagram"), + densityDiagram: document.getElementById("density-diagram"), + mediaLoading: document.getElementById("media-loading"), + mediaLabelKicker: document.getElementById("media-label-kicker"), + mediaLabelTitle: document.getElementById("media-label-title"), + mediaLabelCopy: document.getElementById("media-label-copy"), + progress: document.getElementById("video-progress-fill"), + playButton: document.getElementById("play-button"), + playIcon: document.getElementById("play-icon"), + playLabel: document.getElementById("play-label"), + resetButton: document.getElementById("reset-button"), + fullscreenButton: document.getElementById("fullscreen-button"), + fullscreenLabel: document.getElementById("fullscreen-label"), + workflowOpen: document.getElementById("workflow-open"), + flowSteps: Array.from(document.querySelectorAll(".flow-step[data-step]")), + flowCount: document.getElementById("flow-count"), + flowLineFill: document.getElementById("flow-line-fill"), + taskTitle: document.getElementById("task-title"), + taskDescription: document.getElementById("task-description"), + terrainTabs: Array.from(document.querySelectorAll(".terrain-tab[data-landform]")), + returnExperiment: document.getElementById("return-experiment"), + observationHeading: document.getElementById("observation-heading"), + observationSummary: document.getElementById("observation-summary"), + featureList: document.getElementById("feature-list"), + topViewToggle: document.getElementById("top-view-toggle"), + topViewToggleLabel: document.getElementById("top-view-toggle-label"), + topViewToggleHint: document.getElementById("top-view-toggle-hint"), + topViewThumbnail: document.getElementById("top-view-thumbnail"), + hintText: document.getElementById("hint-text"), + controlPanel: document.querySelector(".control-panel"), + panelClose: document.getElementById("panel-close"), + panelOpen: document.getElementById("panel-open"), + toast: document.getElementById("toast") + }; + + const state = { + selectedLandform: null, + pendingLandform: null, + viewMode: "perspective", + step: 0, + imageToken: 0, + scanTimer: 0, + annotationTimer: 0, + toastTimer: 0, + pendingStep: null, + workflowTimer: 0, + workflowRunToken: 0, + workflowAutoPlaying: false + }; + + const ICONS = { + play: '', + pause: '' + }; + + function showToast(message) { + window.clearTimeout(state.toastTimer); + dom.toast.textContent = message; + dom.toast.classList.add("is-visible"); + state.toastTimer = window.setTimeout(function () { + dom.toast.classList.remove("is-visible"); + }, 2600); + } + + function hideLoading() { + dom.mediaLoading.classList.add("is-hidden"); + } + + function cancelWorkflowSequence() { + window.clearTimeout(state.workflowTimer); + state.workflowTimer = 0; + state.workflowRunToken += 1; + state.workflowAutoPlaying = false; + } + + function setWorkflowDiagram(element, active) { + element.toggleAttribute("hidden", !active); + element.classList.toggle("is-active", active); + } + + function hideWorkflowVisuals() { + setWorkflowDiagram(dom.projectionDiagram, false); + setWorkflowDiagram(dom.densityDiagram, false); + dom.densityBackground.classList.remove("is-visible"); + dom.app.classList.remove("has-workflow-visual"); + } + + function syncWorkflowPresentation(index) { + const safeIndex = Math.max(0, Math.min(3, Number(index) || 0)); + const isExperiment = !state.selectedLandform; + const showProjection = isExperiment && safeIndex === 2; + const showDensity = isExperiment && safeIndex === 3; + const densityWasVisible = dom.densityBackground.classList.contains("is-visible"); + setWorkflowDiagram(dom.projectionDiagram, showProjection); + setWorkflowDiagram(dom.densityDiagram, showDensity); + dom.densityBackground.classList.toggle("is-visible", showDensity); + dom.app.classList.toggle("has-workflow-visual", showProjection || showDensity); + if (isExperiment) dom.experimentVideo.classList.toggle("is-visible", !showDensity); + if (showDensity && !densityWasVisible) triggerScan(dom.densityBackground); + } + + function beginStaticWorkflowSequence() { + cancelWorkflowSequence(); + const token = state.workflowRunToken; + state.workflowAutoPlaying = true; + renderStep(2); + setPlayButton(); + dom.hintText.textContent = "自动演示:" + STEP_COPY[2].description; + state.workflowTimer = window.setTimeout(function () { + if (token !== state.workflowRunToken) return; + renderStep(3); + dom.hintText.textContent = "自动演示:" + STEP_COPY[3].description; + state.workflowTimer = window.setTimeout(function () { + if (token !== state.workflowRunToken) return; + state.workflowTimer = 0; + state.workflowAutoPlaying = false; + setPlayButton(); + dom.hintText.textContent = "实验流程播放完成 · 可重新实验或选择典型地貌观察"; + }, 3600); + }, 3200); + } + + function renderStep(index) { + const safeIndex = Math.max(0, Math.min(3, Number(index) || 0)); + state.step = safeIndex; + const copy = STEP_COPY[safeIndex]; + dom.flowCount.textContent = (safeIndex + 1) + "/4"; + dom.flowLineFill.style.width = (safeIndex / 3) * 100 + "%"; + dom.taskTitle.textContent = copy.title; + dom.taskDescription.textContent = copy.description; + dom.flowSteps.forEach(function (button, buttonIndex) { + button.classList.toggle("is-active", buttonIndex === safeIndex); + button.classList.toggle("is-complete", buttonIndex < safeIndex); + button.setAttribute("aria-current", buttonIndex === safeIndex ? "step" : "false"); + }); + syncWorkflowPresentation(safeIndex); + } + + function renderObservation(view) { + dom.observationHeading.textContent = view.name || view.title; + dom.observationSummary.textContent = view.summary; + dom.featureList.replaceChildren(); + view.features.forEach(function (feature) { + const item = document.createElement("li"); + item.textContent = feature; + dom.featureList.appendChild(item); + }); + } + + function setPlayButton() { + const duration = dom.experimentVideo.duration; + const finished = dom.experimentVideo.ended || (Number.isFinite(duration) && duration > 0 && dom.experimentVideo.currentTime >= duration - 0.08); + if (!dom.experimentVideo.paused) { + dom.playLabel.textContent = "暂停实验"; + dom.playIcon.innerHTML = ICONS.pause; + return; + } + dom.playIcon.innerHTML = ICONS.play; + if (!state.selectedLandform && state.step >= 2) { + dom.playLabel.textContent = "重新实验"; + return; + } + if (finished) dom.playLabel.textContent = "重新实验"; + else if (dom.experimentVideo.currentTime > 0.12) dom.playLabel.textContent = "继续实验"; + else dom.playLabel.textContent = "开始实验"; + } + + function updateMediaLabel(view) { + if (view) { + dom.mediaLabelKicker.textContent = state.viewMode === "top" ? "典型地貌 · 真实俯视图" : "典型地貌 · 立体示意"; + dom.mediaLabelTitle.textContent = view.name; + dom.mediaLabelCopy.textContent = state.viewMode === "top" ? view.subtitle + "|" + view.summary : view.summary; + return; + } + dom.mediaLabelKicker.textContent = "实验流程"; + dom.mediaLabelTitle.textContent = "形成交线与垂直投影"; + dom.mediaLabelCopy.textContent = dom.experimentVideo.paused + ? "点击“开始实验”,直接在当前画面播放形成交线视频" + : STEP_COPY[state.step].description; + } + + function updateViewToggle() { + const view = LANDFORMS[state.selectedLandform]; + const hasLandform = Boolean(view); + const isTopView = hasLandform && state.viewMode === "top"; + dom.topViewToggle.disabled = !hasLandform; + dom.topViewToggle.classList.toggle("is-active", isTopView); + dom.topViewToggle.setAttribute("aria-pressed", String(isTopView)); + dom.topViewToggleLabel.textContent = isTopView ? "立体图" : "俯视图"; + dom.topViewToggleHint.textContent = hasLandform ? "点击切换" : "选择地貌后切换"; + dom.topViewToggle.setAttribute( + "aria-label", + hasLandform ? "切换为" + (isTopView ? "立体图" : "俯视图") : "请先选择一种典型地貌" + ); + + if (!view) { + dom.topViewThumbnail.hidden = true; + dom.topViewThumbnail.removeAttribute("src"); + dom.topViewThumbnail.alt = ""; + return; + } + dom.topViewThumbnail.src = isTopView ? view.image : view.topImage; + dom.topViewThumbnail.alt = isTopView ? view.name + "立体图预览" : view.name + "真实俯视图预览"; + dom.topViewThumbnail.hidden = false; + } + + function triggerScan(targetImage) { + window.clearTimeout(state.scanTimer); + dom.app.classList.remove("is-scanning"); + dom.densityBackground.classList.remove("is-revealing"); + dom.landformImage.classList.remove("is-revealing"); + dom.landformTopImage.classList.remove("is-revealing"); + void dom.app.offsetWidth; + dom.app.classList.add("is-scanning"); + (targetImage || (state.viewMode === "top" ? dom.landformTopImage : dom.landformImage)).classList.add("is-revealing"); + state.scanTimer = window.setTimeout(function () { + dom.app.classList.remove("is-scanning"); + dom.densityBackground.classList.remove("is-revealing"); + dom.landformImage.classList.remove("is-revealing"); + dom.landformTopImage.classList.remove("is-revealing"); + }, 1220); + } + + async function decodeImage(image) { + if (typeof image.decode === "function") { + await image.decode(); + return; + } + if (!image.complete) { + await new Promise(function (resolve, reject) { + image.addEventListener("load", resolve, { once: true }); + image.addEventListener("error", reject, { once: true }); + }); + } + } + + function hideTerrainAnnotation() { + window.clearTimeout(state.annotationTimer); + dom.app.classList.remove("is-landform"); + if (window.TerrainAnnotation) window.TerrainAnnotation.hide(); + } + + function clearTerrainAnnotationNow() { + window.clearTimeout(state.annotationTimer); + state.annotationTimer = 0; + if (window.TerrainAnnotation) window.TerrainAnnotation.hide(true); + } + + function scheduleTerrainAnnotation(withScan) { + window.clearTimeout(state.annotationTimer); + dom.app.classList.add("is-landform"); + state.annotationTimer = window.setTimeout(function () { + if (!state.selectedLandform || !window.TerrainAnnotation) return; + window.TerrainAnnotation.show(state.selectedLandform, state.viewMode); + }, withScan ? 420 : 0); + } + + function applyLandformView(view, withScan) { + const isTopView = state.viewMode === "top"; + hideWorkflowVisuals(); + dom.experimentVideo.classList.remove("is-visible"); + dom.landformImage.classList.toggle("is-visible", !isTopView); + dom.landformTopImage.classList.toggle("is-visible", isTopView); + updateMediaLabel(view); + updateViewToggle(); + dom.hintText.textContent = isTopView + ? view.name + "俯视图:" + view.hint.replace(view.name + ":", "") + : view.hint; + if (withScan) triggerScan(); + scheduleTerrainAnnotation(withScan); + } + + function collapsePanelForCompactView() { + if (!window.matchMedia("(max-width: 680px)").matches) return; + dom.controlPanel.classList.add("is-collapsed"); + dom.panelOpen.hidden = false; + } + + async function selectLandform(key) { + const view = LANDFORMS[key]; + if (!view) return; + const token = ++state.imageToken; + cancelWorkflowSequence(); + state.pendingLandform = key; + clearTerrainAnnotationNow(); + hideWorkflowVisuals(); + const nextMode = state.selectedLandform ? state.viewMode : "perspective"; + dom.experimentVideo.pause(); + const perspectiveProbe = new Image(); + const topProbe = new Image(); + perspectiveProbe.src = view.image; + topProbe.src = view.topImage; + + try { + await Promise.all([decodeImage(perspectiveProbe), decodeImage(topProbe)]); + } catch (error) { + if (token === state.imageToken) { + state.pendingLandform = null; + syncWorkflowPresentation(state.step); + showToast("地貌图片加载失败,请检查对应资源文件"); + } + return; + } + if (token !== state.imageToken) return; + + state.pendingLandform = null; + state.selectedLandform = key; + state.viewMode = nextMode; + dom.landformImage.src = view.image; + dom.landformImage.alt = view.alt; + dom.landformTopImage.src = view.topImage; + dom.landformTopImage.alt = view.topAlt; + + dom.terrainTabs.forEach(function (button) { + const active = button.dataset.landform === key; + button.classList.toggle("is-active", active); + button.setAttribute("aria-pressed", String(active)); + }); + dom.returnExperiment.hidden = false; + renderObservation(view); + applyLandformView(view, true); + collapsePanelForCompactView(); + setPlayButton(); + } + + async function toggleTopView() { + const view = LANDFORMS[state.selectedLandform]; + if (!view) return; + const previousMode = state.viewMode; + const token = ++state.imageToken; + state.pendingLandform = null; + clearTerrainAnnotationNow(); + state.viewMode = previousMode === "top" ? "perspective" : "top"; + try { + await decodeImage(state.viewMode === "top" ? dom.landformTopImage : dom.landformImage); + } catch (error) { + state.viewMode = previousMode; + showToast("对应视图加载失败,请检查图片资源"); + return; + } + if (token !== state.imageToken) return; + applyLandformView(view, true); + collapsePanelForCompactView(); + } + + function showExperiment() { + cancelWorkflowSequence(); + state.imageToken += 1; + state.pendingLandform = null; + state.selectedLandform = null; + state.viewMode = "perspective"; + dom.app.classList.remove("is-scanning"); + hideWorkflowVisuals(); + hideTerrainAnnotation(); + dom.landformImage.classList.remove("is-visible", "is-revealing"); + dom.landformTopImage.classList.remove("is-visible", "is-revealing"); + dom.experimentVideo.classList.add("is-visible"); + dom.terrainTabs.forEach(function (button) { + button.classList.remove("is-active"); + button.setAttribute("aria-pressed", "false"); + }); + dom.returnExperiment.hidden = true; + renderObservation(DEFAULT_VIEW); + updateViewToggle(); + updateMediaLabel(null); + } + + function playVideo() { + dom.experimentVideo.play().then(function () { + setPlayButton(); + updateMediaLabel(null); + dom.hintText.textContent = "实验播放中:" + STEP_COPY[state.step].description; + }).catch(function (error) { + if (error && error.name === "AbortError") return; + showToast("视频暂时无法播放,请检查浏览器媒体权限"); + }); + } + + function toggleExperimentPlayback() { + if (state.selectedLandform || state.pendingLandform || state.step >= 2) { + showExperiment(); + if (Number.isFinite(dom.experimentVideo.duration) && dom.experimentVideo.duration > 0) { + dom.experimentVideo.currentTime = 0; + } else { + state.pendingStep = 0; + } + renderStep(0); + playVideo(); + return; + } + if (!dom.experimentVideo.paused) { + dom.experimentVideo.pause(); + return; + } + const duration = dom.experimentVideo.duration; + if (dom.experimentVideo.ended || (Number.isFinite(duration) && dom.experimentVideo.currentTime >= duration - 0.08)) { + dom.experimentVideo.currentTime = 0; + renderStep(0); + } + playVideo(); + } + + function playFromBeginning() { + showExperiment(); + renderStep(0); + if (Number.isFinite(dom.experimentVideo.duration) && dom.experimentVideo.duration > 0) { + dom.experimentVideo.currentTime = 0; + } else { + state.pendingStep = 0; + } + playVideo(); + } + + function playStep(index) { + const safeIndex = Math.max(0, Math.min(3, Number(index) || 0)); + showExperiment(); + renderStep(safeIndex); + if (safeIndex <= 1) { + if (Number.isFinite(dom.experimentVideo.duration) && dom.experimentVideo.duration > 0) { + dom.experimentVideo.currentTime = safeIndex === 0 ? 0 : dom.experimentVideo.duration / 2; + } else { + state.pendingStep = safeIndex; + } + playVideo(); + return; + } + state.pendingStep = null; + dom.experimentVideo.pause(); + setPlayButton(); + updateMediaLabel(null); + dom.hintText.textContent = STEP_COPY[safeIndex].title + ":" + STEP_COPY[safeIndex].description; + } + + function resetExperience() { + state.pendingStep = null; + dom.experimentVideo.pause(); + showExperiment(); + renderStep(0); + if (Number.isFinite(dom.experimentVideo.duration) && dom.experimentVideo.duration > 0) { + dom.experimentVideo.currentTime = 0; + } else { + state.pendingStep = 0; + } + dom.progress.style.width = "0%"; + dom.hintText.textContent = DEFAULT_VIEW.hint; + setPlayButton(); + showToast("已重置到视频首帧"); + } + + function toggleFullscreen() { + if (!document.fullscreenElement) { + if (!dom.app.requestFullscreen) { + showToast("当前浏览器不支持全屏"); + return; + } + dom.app.requestFullscreen().catch(function () { showToast("当前浏览器未允许进入全屏"); }); + return; + } + if (document.exitFullscreen) document.exitFullscreen().catch(function () {}); + } + + dom.experimentVideo.addEventListener("loadeddata", hideLoading, { once: true }); + dom.experimentVideo.addEventListener("canplay", hideLoading, { once: true }); + dom.experimentVideo.addEventListener("loadedmetadata", function () { + if (state.pendingStep === null) return; + const pending = state.pendingStep; + state.pendingStep = null; + const duration = dom.experimentVideo.duration; + if (Number.isFinite(duration) && duration > 0) { + dom.experimentVideo.currentTime = pending === 0 ? 0 : duration / 2; + renderStep(pending); + } + }); + dom.experimentVideo.addEventListener("error", function () { + hideLoading(); + showToast("形成交线视频加载失败,请确认“contour-formation.mp4”在当前目录"); + }); + dom.experimentVideo.addEventListener("play", function () { + setPlayButton(); + updateMediaLabel(null); + dom.hintText.textContent = "实验播放中:" + STEP_COPY[state.step].description; + }); + dom.experimentVideo.addEventListener("pause", function () { + setPlayButton(); + updateMediaLabel(null); + if (!state.selectedLandform && state.step >= 2) { + dom.hintText.textContent = STEP_COPY[state.step].title + ":" + STEP_COPY[state.step].description; + return; + } + if (!dom.experimentVideo.ended && dom.experimentVideo.currentTime > 0.12 && !state.selectedLandform) { + dom.hintText.textContent = "实验已暂停 · 点击“继续实验”恢复播放"; + } + }); + dom.experimentVideo.addEventListener("ended", function () { + if ( + state.selectedLandform || + state.pendingLandform || + state.step > 1 || + !dom.experimentVideo.ended + ) return; + dom.progress.style.width = "100%"; + beginStaticWorkflowSequence(); + }); + dom.experimentVideo.addEventListener("timeupdate", function () { + const duration = dom.experimentVideo.duration; + const ratio = Number.isFinite(duration) && duration > 0 ? dom.experimentVideo.currentTime / duration : 0; + dom.progress.style.width = Math.max(0, Math.min(100, ratio * 100)) + "%"; + if (!state.selectedLandform && state.step === 0 && ratio >= 0.5) { + renderStep(1); + dom.hintText.textContent = "实验播放中:" + STEP_COPY[1].description; + } + if (!dom.experimentVideo.paused) updateMediaLabel(null); + }); + + dom.playButton.addEventListener("click", toggleExperimentPlayback); + dom.workflowOpen.addEventListener("click", playFromBeginning); + dom.resetButton.addEventListener("click", resetExperience); + dom.returnExperiment.addEventListener("click", resetExperience); + dom.topViewToggle.addEventListener("click", toggleTopView); + dom.terrainTabs.forEach(function (button) { + button.addEventListener("click", function () { selectLandform(button.dataset.landform); }); + }); + dom.flowSteps.forEach(function (button) { + button.addEventListener("click", function () { playStep(Number(button.dataset.step)); }); + }); + + dom.fullscreenButton.addEventListener("click", toggleFullscreen); + document.addEventListener("fullscreenchange", function () { + dom.fullscreenLabel.textContent = document.fullscreenElement ? "退出全屏" : "全屏"; + }); + dom.panelClose.addEventListener("click", function () { + dom.controlPanel.classList.add("is-collapsed"); + dom.panelOpen.hidden = false; + }); + dom.panelOpen.addEventListener("click", function () { + dom.controlPanel.classList.remove("is-collapsed"); + dom.panelOpen.hidden = true; + }); + + document.addEventListener("keydown", function (event) { + if (event.code === "Space" && !/BUTTON|INPUT|VIDEO/.test(document.activeElement.tagName)) { + event.preventDefault(); + toggleExperimentPlayback(); + } + if (/^[1-5]$/.test(event.key) && !event.metaKey && !event.ctrlKey && !event.altKey) { + const keys = ["peak", "ridge", "valley", "saddle", "cliff"]; + selectLandform(keys[Number(event.key) - 1]); + } + }); + + window.setTimeout(hideLoading, 7000); + renderStep(0); + renderObservation(DEFAULT_VIEW); + updateViewToggle(); + updateMediaLabel(null); + setPlayButton(); + + window.__GEO_LAB_TEST__ = { + getState: function () { + return { + selectedLandform: state.selectedLandform, + pendingLandform: state.pendingLandform, + viewMode: state.viewMode, + step: state.step, + videoPlaying: !dom.experimentVideo.paused, + videoTime: dom.experimentVideo.currentTime, + videoSource: dom.experimentVideo.currentSrc || dom.experimentVideo.src, + workflowDiagram: !dom.projectionDiagram.hasAttribute("hidden") ? "projection" : !dom.densityDiagram.hasAttribute("hidden") ? "density" : null, + workflowAutoPlaying: state.workflowAutoPlaying, + densityBackground: dom.densityBackground.classList.contains("is-visible"), + scanning: dom.app.classList.contains("is-scanning"), + terrainAnnotation: window.TerrainAnnotation ? window.TerrainAnnotation.getState() : null, + fullscreen: Boolean(document.fullscreenElement) + }; + }, + selectLandform: selectLandform, + toggleTopView: toggleTopView, + showExperiment: showExperiment, + playStep: playStep, + reset: resetExperience + }; +})(); diff --git a/GC-UI/frontend/courseware/assets/cliff-3d.jpg b/GC-UI/frontend/courseware/assets/cliff-3d.jpg new file mode 100644 index 0000000..ecc02d2 Binary files /dev/null and b/GC-UI/frontend/courseware/assets/cliff-3d.jpg differ diff --git a/GC-UI/frontend/courseware/assets/cliff-top.jpg b/GC-UI/frontend/courseware/assets/cliff-top.jpg new file mode 100644 index 0000000..2cf7a41 Binary files /dev/null and b/GC-UI/frontend/courseware/assets/cliff-top.jpg differ diff --git a/GC-UI/frontend/courseware/assets/contour-formation.mp4 b/GC-UI/frontend/courseware/assets/contour-formation.mp4 new file mode 100644 index 0000000..9c707a8 Binary files /dev/null and b/GC-UI/frontend/courseware/assets/contour-formation.mp4 differ diff --git a/GC-UI/frontend/courseware/assets/density-background.jpg b/GC-UI/frontend/courseware/assets/density-background.jpg new file mode 100644 index 0000000..a939d68 Binary files /dev/null and b/GC-UI/frontend/courseware/assets/density-background.jpg differ diff --git a/GC-UI/frontend/courseware/assets/peak-3d.jpg b/GC-UI/frontend/courseware/assets/peak-3d.jpg new file mode 100644 index 0000000..0f610ae Binary files /dev/null and b/GC-UI/frontend/courseware/assets/peak-3d.jpg differ diff --git a/GC-UI/frontend/courseware/assets/peak-top.jpg b/GC-UI/frontend/courseware/assets/peak-top.jpg new file mode 100644 index 0000000..304f677 Binary files /dev/null and b/GC-UI/frontend/courseware/assets/peak-top.jpg differ diff --git a/GC-UI/frontend/courseware/assets/ridge-3d.jpg b/GC-UI/frontend/courseware/assets/ridge-3d.jpg new file mode 100644 index 0000000..9b7a2c3 Binary files /dev/null and b/GC-UI/frontend/courseware/assets/ridge-3d.jpg differ diff --git a/GC-UI/frontend/courseware/assets/ridge-top.jpg b/GC-UI/frontend/courseware/assets/ridge-top.jpg new file mode 100644 index 0000000..03241da Binary files /dev/null and b/GC-UI/frontend/courseware/assets/ridge-top.jpg differ diff --git a/GC-UI/frontend/courseware/assets/saddle-3d.jpg b/GC-UI/frontend/courseware/assets/saddle-3d.jpg new file mode 100644 index 0000000..78e6278 Binary files /dev/null and b/GC-UI/frontend/courseware/assets/saddle-3d.jpg differ diff --git a/GC-UI/frontend/courseware/assets/saddle-top.jpg b/GC-UI/frontend/courseware/assets/saddle-top.jpg new file mode 100644 index 0000000..2f54c9e Binary files /dev/null and b/GC-UI/frontend/courseware/assets/saddle-top.jpg differ diff --git a/GC-UI/frontend/courseware/assets/style.css b/GC-UI/frontend/courseware/assets/style.css new file mode 100644 index 0000000..c34b079 --- /dev/null +++ b/GC-UI/frontend/courseware/assets/style.css @@ -0,0 +1,1382 @@ +:root { + color-scheme: light; + --blue: #0878ff; + --blue-deep: #0667e8; + --blue-soft: #eaf4ff; + --ink: #071d36; + --ink-soft: #29445f; + --muted: #65798d; + --glass: rgba(244, 250, 255, 0.76); + --glass-strong: rgba(251, 253, 255, 0.88); + --line: rgba(255, 255, 255, 0.82); + --shadow: 0 26px 70px rgba(9, 42, 76, 0.20), inset 0 1px 0 rgba(255, 255, 255, 0.86); + --radius: 15px; + font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif; +} + +* { + box-sizing: border-box; +} + +[hidden] { + display: none !important; +} + +html, +body { + width: 100%; + height: 100%; + margin: 0; + overflow: hidden; + background: #9fc7ed; +} + +button, +video { + font: inherit; +} + +button { + -webkit-tap-highlight-color: transparent; +} + +button:focus-visible { + outline: 3px solid rgba(8, 120, 255, 0.42); + outline-offset: 3px; +} + +.app-shell { + position: relative; + isolation: isolate; + width: 100%; + height: 100%; + min-width: 320px; + min-height: 560px; + overflow: hidden; + color: var(--ink); + background: #9fc7ed; +} + +.media-stage { + position: absolute; + inset: 0; + z-index: -2; + overflow: hidden; + background-color: #76a8d2; + background-image: linear-gradient(145deg, rgba(157, 201, 239, .18), rgba(16, 47, 79, .10)); + background-position: center; + background-size: cover; + background-repeat: no-repeat; +} + +.stage-media { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + object-fit: cover; + object-position: center center; + opacity: 0; + transition: opacity 320ms ease; + user-select: none; +} + +.stage-video { + z-index: 0; +} + +.stage-image { + z-index: 1; + transition: none; +} + +.workflow-step-background { + object-position: center center; +} + +.stage-media.is-visible { + opacity: 1; +} + +.stage-image.is-revealing { + will-change: clip-path; + animation: scanner-image-reveal 1.02s cubic-bezier(.2, .72, .22, 1) both; +} + +.workflow-diagram { + position: absolute; + z-index: 6; + top: 132px; + right: auto; + left: 508px; + display: block; + height: auto; + overflow: visible; + pointer-events: none; + transform-origin: top left; + animation: workflow-diagram-enter 460ms cubic-bezier(.2, .78, .22, 1) both; +} + +.workflow-diagram--projection { + width: clamp(238px, 18.9vw, 300px); +} + +.workflow-diagram--density { + width: clamp(300px, 23.2vw, 368px); +} + +.workflow-diagram .diagram-card { + stroke: rgba(255, 255, 255, .9); + stroke-width: 1.5; + vector-effect: non-scaling-stroke; +} + +.workflow-diagram .diagram-heading, +.workflow-diagram .diagram-footer, +.workflow-diagram .density-callout text { + font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif; +} + +.workflow-diagram .diagram-heading { + fill: #071a2d; + font-size: 18px; + font-weight: 760; +} + +.projection-layer { + fill: rgba(188, 239, 255, .08); + stroke: url(#projection-layer-stroke); + stroke-width: 1.4; + vector-effect: non-scaling-stroke; + stroke-dasharray: 700; + stroke-dashoffset: 700; + animation: projection-draw 760ms cubic-bezier(.2, .72, .22, 1) calc(var(--i) * 45ms) forwards; +} + +.projection-column { + fill: none; + stroke: url(#projection-beam); + stroke-width: 1.25; + stroke-linecap: round; + vector-effect: non-scaling-stroke; + opacity: .68; +} + +.projection-grid { + fill: none; + stroke: #8eadd2; + stroke-width: .75; + vector-effect: non-scaling-stroke; + opacity: .38; +} + +.projection-contour { + fill: rgba(83, 143, 255, .018); + stroke: #4385ff; + stroke-width: 1.35; + vector-effect: non-scaling-stroke; + opacity: .95; + stroke-dasharray: 700; + stroke-dashoffset: 700; + animation: projection-draw 720ms ease calc(180ms + var(--i) * 55ms) forwards; +} + +.projection-landings circle, +.projection-crossings circle { + fill: #fff; + stroke: #4bdcff; + stroke-width: 1.2; + vector-effect: non-scaling-stroke; +} + +.workflow-diagram .diagram-footer { + fill: #304258; + font-size: 18px; + font-weight: 720; +} + +.density-contour { + fill: none; + stroke: url(#density-contour-stroke); + stroke-width: 1.35; + stroke-linecap: round; + stroke-linejoin: round; + vector-effect: non-scaling-stroke; + stroke-dasharray: 1000; + stroke-dashoffset: 1000; + animation: density-draw 760ms cubic-bezier(.2, .72, .22, 1) calc(var(--i) * 42ms) forwards; +} + +.density-callout > path { + fill: none; + stroke-width: 2; + stroke-linecap: round; + vector-effect: non-scaling-stroke; +} + +.density-callout > circle { + stroke: #fff; + stroke-width: 2; + vector-effect: non-scaling-stroke; + filter: url(#density-dot-glow); +} + +.density-callout > rect { + stroke: none; +} + +.density-callout text { + font-size: 17px; + font-weight: 730; +} + +.density-callout--gentle > rect { + fill: rgba(235, 247, 255, .72); +} + +.density-callout--gentle > path { + stroke: #0874ff; +} + +.density-callout--gentle > circle { + fill: #0874ff; +} + +.density-callout--gentle text { + fill: #0874ff; +} + +.density-callout--steep > rect { + fill: rgba(255, 244, 226, .76); +} + +.density-callout--steep > path { + stroke: #f58a0a; +} + +.density-callout--steep > circle { + fill: #f58a0a; +} + +.density-callout--steep text { + fill: #e87500; +} + +.app-shell.has-workflow-visual .media-label { + opacity: 0; + transform: translateY(8px); +} + +@keyframes workflow-diagram-enter { + from { opacity: 0; transform: translateY(12px) scale(.965); } + to { opacity: 1; transform: translateY(0) scale(1); } +} + +@keyframes projection-draw { + to { stroke-dashoffset: 0; } +} + +@keyframes projection-flow { + to { stroke-dashoffset: -30; } +} + +@keyframes density-draw { + to { stroke-dashoffset: 0; } +} + +@keyframes scanner-image-reveal { + from { clip-path: inset(0 0 100% 0); } + to { clip-path: inset(0 0 0 0); } +} + +.media-shade { + position: absolute; + inset: 0; + z-index: 2; + pointer-events: none; + background: + linear-gradient(180deg, rgba(195, 225, 250, .28) 0%, rgba(156, 198, 232, .04) 22%, transparent 46%), + linear-gradient(90deg, rgba(9, 42, 74, .14) 0%, transparent 43%), + linear-gradient(0deg, rgba(4, 25, 45, .19) 0%, transparent 23%); +} + +.scan-effect { + position: absolute; + inset: 0; + z-index: 3; + overflow: hidden; + pointer-events: none; + opacity: 0; +} + +.scan-grid { + position: absolute; + inset: 0; + opacity: 0; + background-image: + linear-gradient(rgba(94, 216, 255, .14) 1px, transparent 1px), + linear-gradient(90deg, rgba(94, 216, 255, .12) 1px, transparent 1px); + background-size: 32px 32px; + mask-image: linear-gradient(180deg, transparent, #000 15%, #000 85%, transparent); +} + +.scan-beam { + position: absolute; + top: -18%; + right: -4%; + left: -4%; + height: 142px; + background: linear-gradient(180deg, transparent 0%, rgba(51, 196, 255, .04) 25%, rgba(48, 205, 255, .28) 68%, rgba(218, 251, 255, .82) 86%, rgba(255,255,255,.96) 90%, rgba(26, 174, 255, .16) 94%, transparent 100%); + filter: drop-shadow(0 0 16px #2bd2ff) drop-shadow(0 0 38px rgba(0, 128, 255, .78)); +} + +.scan-beam::before, +.scan-beam::after { + content: ""; + position: absolute; + right: 0; + left: 0; + border-radius: 50%; +} + +.scan-beam::before { + bottom: 13px; + height: 2px; + background: #e8fdff; + box-shadow: 0 0 8px #fff, 0 0 20px #24c9ff, 0 0 38px #0878ff; +} + +.scan-beam::after { + bottom: 9px; + height: 9px; + border-top: 1px solid rgba(164, 241, 255, .8); + background: linear-gradient(90deg, transparent, rgba(102, 222, 255, .25), transparent); +} + +.app-shell.is-scanning .scan-effect { + opacity: 1; +} + +.app-shell.is-scanning .scan-grid { + animation: grid-flash 1.02s ease both; +} + +.app-shell.is-scanning .scan-beam { + animation: scan-sweep 1.02s cubic-bezier(.2, .72, .22, 1) both; +} + +.terrain-annotation { + position: absolute; + inset: 0; + z-index: 7; + overflow: hidden; + pointer-events: none; +} + +#terrain-annotation-canvas { + position: absolute; + inset: 0; + display: block; + width: 100%; + height: 100%; + opacity: 0; + filter: drop-shadow(0 0 7px rgba(246, 178, 26, .52)); + transition: opacity 240ms ease; + z-index: 0; +} + +.terrain-annotation.is-visible #terrain-annotation-canvas { + opacity: 1; +} + +.terrain-callout-connector { + position: absolute; + inset: 0; + z-index: 1; + display: block; + width: 100%; + height: 100%; + overflow: visible; + opacity: 0; + filter: drop-shadow(0 4px 6px rgba(2, 27, 49, .20)); + transition: opacity 220ms ease; +} + +.terrain-callout-connector polygon { + fill: rgba(249, 253, 255, .98); + stroke: rgba(20, 121, 255, .46); + stroke-width: 2; + stroke-linejoin: round; + vector-effect: non-scaling-stroke; +} + +.terrain-annotation.is-callout-visible .terrain-callout-connector { + opacity: 1; +} + +.terrain-callout { + position: absolute; + top: var(--callout-y, 45%); + left: var(--callout-x, 72%); + display: flex; + z-index: 2; + width: min(280px, calc(100vw - 28px)); + padding: 15px 18px 16px; + flex-direction: column; + gap: 3px; + border: 3px solid #1479ff; + border-radius: 20px; + color: #082742; + background: rgba(249, 253, 255, .94); + box-shadow: 0 16px 40px rgba(2, 27, 49, .24), inset 0 1px 0 rgba(255, 255, 255, .96); + backdrop-filter: blur(16px) saturate(1.12); + -webkit-backdrop-filter: blur(16px) saturate(1.12); + opacity: 0; + transition: opacity 220ms ease, transform 280ms cubic-bezier(.2, .8, .2, 1); +} + +.terrain-callout::before { + display: none; +} + +.terrain-annotation[data-side="right"] .terrain-callout { + transform: translate(0, -50%) scale(.97); +} + +.terrain-annotation[data-side="right"] .terrain-callout::before { + top: calc(50% + var(--pointer-offset-y, 0px) - 28px); + left: -56px; + border-right-color: rgba(249, 253, 255, .97); +} + +.terrain-annotation[data-side="left"] .terrain-callout { + transform: translate(-100%, -50%) scale(.97); +} + +.terrain-annotation[data-side="left"] .terrain-callout::before { + top: calc(50% + var(--pointer-offset-y, 0px) - 28px); + right: -56px; + border-left-color: rgba(249, 253, 255, .97); +} + +.terrain-annotation[data-side="below"] .terrain-callout { + transform: translate(-50%, 0) scale(.97); +} + +.terrain-annotation[data-side="below"] .terrain-callout::before { + top: -56px; + left: calc(50% + var(--pointer-offset-x, 0px) - 28px); + border-bottom-color: rgba(249, 253, 255, .97); +} + +.terrain-annotation[data-side="above"] .terrain-callout { + transform: translate(-50%, -100%) scale(.97); +} + +.terrain-annotation[data-side="above"] .terrain-callout::before { + bottom: -56px; + left: calc(50% + var(--pointer-offset-x, 0px) - 28px); + border-top-color: rgba(249, 253, 255, .97); +} + +.terrain-annotation.is-callout-visible[data-side="right"] .terrain-callout { + opacity: 1; + transform: translate(0, -50%) scale(1); +} + +.terrain-annotation.is-callout-visible[data-side="left"] .terrain-callout { + opacity: 1; + transform: translate(-100%, -50%) scale(1); +} + +.terrain-annotation.is-callout-visible[data-side="below"] .terrain-callout { + opacity: 1; + transform: translate(-50%, 0) scale(1); +} + +.terrain-annotation.is-callout-visible[data-side="above"] .terrain-callout { + opacity: 1; + transform: translate(-50%, -100%) scale(1); +} + +.terrain-callout-kicker { + color: #0878ff; + font-size: 10px; + font-weight: 800; + letter-spacing: .11em; +} + +.terrain-callout strong { + font-size: 20px; + line-height: 1.34; + letter-spacing: .015em; +} + +.terrain-callout p { + margin: 3px 0 0; + color: #435e75; + font-size: 13px; + line-height: 1.55; +} + +.terrain-annotation[data-tone="warning"] #terrain-annotation-canvas { + filter: drop-shadow(0 0 7px rgba(246, 178, 26, .52)); +} + +.terrain-annotation[data-tone="warning"] .terrain-callout { + border-color: #1479ff; +} + +.terrain-annotation[data-tone="warning"] .terrain-callout-kicker { + color: #0878ff; +} + +@keyframes scan-sweep { + from { top: -18%; } + to { top: 108%; } +} + +@keyframes grid-flash { + 0%, 100% { opacity: 0; } + 28%, 70% { opacity: .36; } +} + +.media-loading { + position: absolute; + inset: 0; + z-index: 5; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 12px; + color: #fff; + font-size: 14px; + letter-spacing: .08em; + background: linear-gradient(145deg, #91bee7, #356e9f); + transition: opacity 400ms ease, visibility 400ms ease; +} + +.media-loading.is-hidden { + opacity: 0; + visibility: hidden; +} + +.loading-ring { + width: 34px; + height: 34px; + border: 3px solid rgba(255,255,255,.35); + border-top-color: #fff; + border-radius: 50%; + animation: spin .8s linear infinite; +} + +@keyframes spin { to { transform: rotate(360deg); } } + +.media-label { + position: absolute; + z-index: 6; + top: 42%; + right: 8.4%; + display: flex; + min-width: 122px; + max-width: 260px; + padding: 13px 16px 14px; + flex-direction: column; + gap: 3px; + border: 1px solid rgba(255,255,255,.82); + border-radius: 12px; + color: var(--ink); + background: rgba(248, 252, 255, .84); + box-shadow: 0 16px 40px rgba(5, 34, 61, .18), inset 0 1px 0 rgba(255,255,255,.9); + backdrop-filter: blur(18px) saturate(1.2); + -webkit-backdrop-filter: blur(18px) saturate(1.2); + transition: transform 360ms ease, opacity 360ms ease; +} + +.media-label-kicker { + font-size: 11px; + font-weight: 700; + color: var(--blue); + letter-spacing: .08em; +} + +.media-label strong { + font-size: 17px; + line-height: 1.35; +} + +.media-label small { + margin-top: 2px; + color: #536b82; + font-size: 11px; + line-height: 1.5; +} + +.app-shell.is-landform .media-label { + opacity: 0; + transform: translateY(8px); +} + +.video-progress { + position: absolute; + z-index: 5; + right: 0; + bottom: 0; + left: 0; + height: 3px; + background: rgba(255,255,255,.18); +} + +.video-progress span { + display: block; + width: 0; + height: 100%; + background: linear-gradient(90deg, #29d8ff, #0878ff); + box-shadow: 0 0 12px #1ec9ff; + transition: width 120ms linear; +} + +.topbar { + position: absolute; + z-index: 10; + top: 17px; + right: 30px; + left: 29px; + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 24px; +} + +.heading-group { + display: flex; + align-items: flex-start; + gap: 22px; + min-width: 0; +} + +.subject-chip { + display: inline-flex; + align-items: center; + justify-content: center; + height: 46px; + margin-top: 1px; + padding: 0 16px; + flex: 0 0 auto; + border: 1px solid rgba(255,255,255,.78); + border-radius: 12px; + color: #0872f6; + font-size: 17px; + font-weight: 750; + background: rgba(248, 252, 255, .76); + box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 10px 25px rgba(11,54,91,.08); + backdrop-filter: blur(18px); + -webkit-backdrop-filter: blur(18px); +} + +.heading-copy { + min-width: 0; +} + +.heading-copy h1 { + margin: 0; + color: #051b34; + font-size: clamp(27px, 2.45vw, 39px); + font-weight: 760; + line-height: 1.18; + letter-spacing: .015em; + text-shadow: 0 1px 0 rgba(255,255,255,.38); +} + +.heading-copy p { + margin: 10px 0 0; + color: #38536c; + font-size: clamp(13px, 1.2vw, 19px); + font-weight: 500; + letter-spacing: .055em; +} + +.top-actions, +.experiment-actions { + display: flex; + align-items: center; + gap: 18px; + flex: 0 0 auto; +} + +.glass-button, +.primary-button { + border: 1px solid rgba(255,255,255,.82); + border-radius: 13px; + cursor: pointer; + transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease; +} + +.glass-button:hover, +.primary-button:hover { + transform: translateY(-2px); +} + +.glass-button:active, +.primary-button:active { + transform: translateY(0) scale(.985); +} + +.glass-button { + display: inline-flex; + height: 52px; + padding: 0 18px; + align-items: center; + justify-content: center; + gap: 10px; + color: #0b1826; + font-size: 15px; + font-weight: 700; + background: rgba(251, 253, 255, .85); + box-shadow: 0 12px 28px rgba(10,42,70,.13), inset 0 1px 0 rgba(255,255,255,.95); + backdrop-filter: blur(20px) saturate(1.15); + -webkit-backdrop-filter: blur(20px) saturate(1.15); +} + +.glass-button svg { + width: 21px; + height: 21px; + fill: none; + stroke: currentColor; + stroke-width: 1.9; + stroke-linecap: round; + stroke-linejoin: round; +} + +.top-actions .glass-button:first-child { + min-width: 137px; +} + +.top-actions .glass-button:last-child { + min-width: 123px; +} + +.control-panel { + position: absolute; + z-index: 9; + top: 132px; + bottom: 131px; + left: 29px; + width: min(458px, calc(100vw - 58px)); + padding: 17px 9px 14px 10px; + overflow: hidden; + border: 1px solid rgba(255,255,255,.84); + border-radius: 18px; + background: var(--glass); + box-shadow: var(--shadow); + backdrop-filter: blur(28px) saturate(1.12); + -webkit-backdrop-filter: blur(28px) saturate(1.12); + transition: transform 360ms cubic-bezier(.2,.8,.2,1), opacity 280ms ease; +} + +.control-panel.is-collapsed { + transform: translateX(calc(-100% - 38px)); + opacity: 0; + pointer-events: none; +} + +.panel-scroll { + height: 100%; + padding: 0 10px 4px; + overflow-y: auto; + overscroll-behavior: contain; + scrollbar-width: none; +} + +.panel-scroll::-webkit-scrollbar { + display: none; +} + +.section-heading, +.card-title-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 10px; +} + +.section-heading h2 { + margin: 0; + font-size: 16px; + font-weight: 760; + letter-spacing: .02em; +} + +.panel-close { + display: none; + width: 28px; + height: 28px; + padding: 0 0 2px; + border: 0; + border-radius: 8px; + color: #526a81; + font-size: 24px; + line-height: 1; + cursor: pointer; + background: rgba(255,255,255,.58); +} + +.flow-track { + position: relative; + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 0; + margin-top: 17px; + padding: 0 0 8px; +} + +.flow-line { + position: absolute; + top: 17px; + right: 11.5%; + left: 11.5%; + height: 2px; + overflow: hidden; + background: #abc1d9; +} + +.flow-line i { + display: block; + width: 0; + height: 100%; + background: var(--blue); + transition: width 320ms ease; +} + +.flow-step { + position: relative; + z-index: 1; + display: flex; + padding: 0; + flex-direction: column; + align-items: center; + gap: 8px; + border: 0; + color: #415970; + cursor: pointer; + background: transparent; +} + +.step-dot { + display: grid; + width: 35px; + height: 35px; + place-items: center; + border: 3px solid rgba(237,246,255,.92); + border-radius: 50%; + color: #fff; + font-size: 16px; + font-weight: 750; + background: #92a9c2; + box-shadow: 0 2px 7px rgba(17, 55, 88, .13); + transition: background 200ms ease, transform 200ms ease, box-shadow 200ms ease; +} + +.step-name { + font-size: 13px; + font-weight: 650; + white-space: nowrap; +} + +.flow-step.is-active, +.flow-step.is-complete { + color: var(--blue); +} + +.flow-step.is-active .step-dot, +.flow-step.is-complete .step-dot { + background: var(--blue); +} + +.flow-step.is-active .step-dot { + transform: scale(1.06); + box-shadow: 0 0 0 5px rgba(8,120,255,.12), 0 6px 15px rgba(8,90,190,.24); +} + +.glass-card { + margin-top: 10px; + padding: 12px 13px; + border: 1px solid rgba(255,255,255,.72); + border-radius: var(--radius); + background: rgba(248, 252, 255, .53); + box-shadow: inset 0 1px 0 rgba(255,255,255,.75), 0 6px 20px rgba(12,50,82,.06); +} + +.card-eyebrow { + display: block; + color: #132b43; + font-size: 13px; + font-weight: 750; + letter-spacing: .035em; +} + +.task-card h3, +.observation-copy h3 { + margin: 6px 0 4px; + color: var(--blue); + font-size: 24px; + line-height: 1.25; +} + +.task-card > p, +.observation-copy > p { + margin: 0; + color: #506981; + font-size: 12px; + line-height: 1.6; +} + +.fixed-condition { + display: flex; + min-height: 36px; + margin-top: 9px; + padding: 0 11px; + align-items: center; + justify-content: space-between; + gap: 8px; + border-radius: 9px; + color: #536b82; + font-size: 12px; + background: rgba(226, 239, 251, .72); +} + +.fixed-condition span { + display: inline-flex; + align-items: center; + gap: 6px; +} + +.fixed-condition i { + width: 7px; + height: 7px; + border-radius: 50%; + background: var(--blue); + box-shadow: 0 0 0 3px rgba(8,120,255,.12); +} + +.fixed-condition strong { + color: #233d57; + font-size: 12px; +} + +.text-action { + padding: 2px 0; + border: 0; + color: var(--blue); + font-size: 12px; + font-weight: 700; + cursor: pointer; + background: transparent; +} + +.terrain-tabs { + display: grid; + grid-template-columns: repeat(5, minmax(0, 1fr)); + gap: 9px; + margin-top: 9px; +} + +.terrain-tab { + display: flex; + min-width: 0; + height: 76px; + padding: 8px 4px 7px; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 5px; + border: 1px solid rgba(184,205,226,.6); + border-radius: 10px; + color: #314a65; + cursor: pointer; + background: rgba(248,252,255,.72); + box-shadow: inset 0 1px 0 rgba(255,255,255,.84); + transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease; +} + +.terrain-tab:hover { + transform: translateY(-2px); + color: var(--blue); + border-color: rgba(8,120,255,.38); +} + +.terrain-tab.is-active { + color: var(--blue); + border-color: var(--blue); + background: rgba(244,249,255,.95); + box-shadow: 0 0 0 2px rgba(8,120,255,.11), 0 7px 15px rgba(8,83,173,.13), inset 0 1px 0 #fff; +} + +.terrain-tab svg { + width: 37px; + height: 31px; + overflow: visible; + fill: none; + stroke: currentColor; + stroke-width: 1.75; + stroke-linecap: round; + stroke-linejoin: round; +} + +.terrain-tab svg .solid { + fill: currentColor; + stroke: none; +} + +.terrain-tab svg .accent { + stroke: #0cb2ed; +} + +.terrain-tab span { + font-size: 13px; + font-weight: 680; + white-space: nowrap; +} + +.observation-card { + display: grid; + min-height: 187px; + grid-template-columns: minmax(0, 1.05fr) minmax(145px, .95fr); + gap: 12px; + align-items: stretch; +} + +.observation-copy { + min-width: 0; +} + +.observation-copy h3 { + font-size: 22px; +} + +.feature-list { + display: grid; + gap: 4px; + margin: 7px 0 0; + padding: 0; + list-style: none; +} + +.feature-list li { + position: relative; + padding-left: 12px; + color: #38546d; + font-size: 11px; + line-height: 1.42; +} + +.feature-list li::before { + content: ""; + position: absolute; + top: .52em; + left: 0; + width: 5px; + height: 5px; + border-radius: 50%; + background: var(--blue); + box-shadow: 0 0 0 2px rgba(8,120,255,.1); +} + +.top-view-card { + position: relative; + display: flex; + min-height: 160px; + padding: 24px 5px 3px; + align-items: center; + justify-content: center; + overflow: hidden; + border: 1px solid rgba(180,205,229,.68); + border-radius: 11px; + color: inherit; + font: inherit; + text-align: left; + cursor: pointer; + background: rgba(240,248,255,.70); + box-shadow: inset 0 1px 0 rgba(255,255,255,.82); + transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease; +} + +.top-view-card:not(:disabled):hover { + transform: translateY(-2px); + border-color: rgba(8,120,255,.58); + background: rgba(244,250,255,.9); + box-shadow: 0 8px 18px rgba(8,82,160,.12), inset 0 1px 0 #fff; +} + +.top-view-card.is-active { + border-color: var(--blue); + background: rgba(232,244,255,.94); + box-shadow: 0 0 0 2px rgba(8,120,255,.10), inset 0 1px 0 #fff; +} + +.top-view-card:disabled { + cursor: default; +} + +.top-view-card > span { + position: absolute; + top: 8px; + left: 10px; + color: #607990; + font-size: 10px; + font-weight: 750; + letter-spacing: .08em; + z-index: 2; + padding: 3px 6px; + border-radius: 6px; + background: rgba(244,250,255,.86); + box-shadow: 0 2px 7px rgba(5,36,64,.10); +} + +.top-view-card > small { + position: absolute; + top: 7px; + right: 9px; + color: var(--blue); + font-size: 9px; + font-weight: 700; + z-index: 2; + padding: 3px 5px; + border-radius: 6px; + background: rgba(244,250,255,.86); +} + +#top-view-thumbnail { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + object-fit: cover; + object-position: center; + filter: saturate(.92) brightness(.94); + transition: transform 240ms ease, filter 240ms ease; +} + +.top-view-card:not(:disabled):hover #top-view-thumbnail { + transform: scale(1.035); + filter: saturate(1.05) brightness(1); +} + +.panel-open { + position: absolute; + z-index: 12; + top: 138px; + left: 29px; + display: grid; + width: 46px; + height: 46px; + padding: 12px; + gap: 4px; + border: 1px solid rgba(255,255,255,.85); + border-radius: 13px; + cursor: pointer; + background: rgba(248,252,255,.84); + box-shadow: 0 14px 35px rgba(5,39,70,.18); + backdrop-filter: blur(18px); +} + +.panel-open span { + display: block; + height: 2px; + border-radius: 2px; + background: #1e4669; +} + +.experiment-actions { + position: absolute; + z-index: 11; + top: 109px; + right: 35px; +} + +.primary-button { + display: inline-flex; + min-width: 211px; + height: 63px; + padding: 0 23px; + align-items: center; + justify-content: center; + gap: 12px; + border-color: rgba(73,166,255,.8); + color: #fff; + font-size: 18px; + font-weight: 700; + background: linear-gradient(180deg, #338bff 0%, #0874f6 100%); + box-shadow: 0 14px 30px rgba(0,88,210,.28), inset 0 1px 0 rgba(255,255,255,.32); +} + +.primary-button:hover { + box-shadow: 0 18px 38px rgba(0,88,210,.34), inset 0 1px 0 rgba(255,255,255,.32); +} + +.round-icon { + display: grid; + width: 37px; + height: 37px; + flex: 0 0 auto; + place-items: center; + border-radius: 50%; + color: var(--blue); + background: #fff; + box-shadow: 0 3px 10px rgba(0,52,123,.15); +} + +.round-icon svg { + width: 23px; + height: 23px; + fill: currentColor; + stroke: none; +} + +.reset-button { + min-width: 151px; + height: 63px; + font-size: 18px; +} + +.reset-button svg { + width: 27px; + height: 27px; +} + +.hint-bar { + position: absolute; + z-index: 9; + bottom: 36px; + left: 29px; + display: inline-flex; + max-width: min(610px, calc(100vw - 58px)); + min-height: 51px; + padding: 0 19px; + align-items: center; + gap: 11px; + border: 1px solid rgba(255,255,255,.8); + border-radius: 13px; + color: #395671; + font-size: 14px; + font-weight: 560; + letter-spacing: .025em; + background: rgba(247,251,255,.78); + box-shadow: 0 14px 35px rgba(5,36,64,.15), inset 0 1px 0 rgba(255,255,255,.9); + backdrop-filter: blur(20px) saturate(1.15); + -webkit-backdrop-filter: blur(20px) saturate(1.15); +} + +.hint-bar svg { + width: 22px; + height: 22px; + flex: 0 0 auto; + fill: none; + stroke: currentColor; + stroke-width: 1.8; + stroke-linecap: round; +} + +.toast { + position: absolute; + z-index: 30; + right: 30px; + bottom: 28px; + max-width: 360px; + padding: 12px 16px; + border: 1px solid rgba(255,255,255,.78); + border-radius: 11px; + color: #15304a; + font-size: 13px; + background: rgba(248,252,255,.92); + box-shadow: 0 16px 42px rgba(5,35,61,.2); + opacity: 0; + transform: translateY(12px); + pointer-events: none; + transition: opacity 200ms ease, transform 200ms ease; +} + +.toast.is-visible { + opacity: 1; + transform: none; +} + +@media (max-width: 1250px), (max-height: 820px) { + .topbar { top: 15px; right: 22px; left: 22px; } + .heading-group { gap: 14px; } + .subject-chip { height: 42px; padding: 0 13px; font-size: 15px; } + .heading-copy p { margin-top: 5px; } + .top-actions { gap: 10px; } + .top-actions .glass-button { min-width: 0; height: 46px; padding: 0 14px; } + .control-panel { top: 108px; bottom: 88px; left: 22px; width: 420px; } + .experiment-actions { top: 82px; right: 22px; gap: 10px; } + .primary-button { min-width: 184px; height: 56px; font-size: 16px; } + .reset-button { min-width: 125px; height: 56px; font-size: 16px; } + .hint-bar { bottom: 22px; left: 22px; min-height: 46px; } + .observation-card { min-height: 178px; } + .workflow-diagram { top: 108px; right: auto; left: 458px; } + .workflow-diagram--projection { width: min(250px, 21vw); } + .workflow-diagram--density { width: min(320px, 27vw); } +} + +@media (max-width: 920px) { + .heading-copy h1 { font-size: 24px; } + .heading-copy p { display: none; } + .top-actions .glass-button span { display: none; } + .top-actions .glass-button { width: 46px; padding: 0; } + .control-panel { top: 94px; bottom: 82px; width: 400px; } + .experiment-actions { top: 72px; } + .primary-button { min-width: 165px; } + .media-label { right: 24px; } + .workflow-diagram { top: 94px; right: auto; left: 436px; } + .workflow-diagram--projection { width: min(220px, 28vw); } + .workflow-diagram--density { width: min(278px, 35vw); } + .terrain-callout { width: min(250px, calc(100vw - 30px)); } +} + +@media (max-width: 680px) { + .stage-image { object-fit: contain; } + .workflow-step-background { object-fit: cover; } + .topbar { right: 14px; left: 14px; } + .subject-chip { display: none; } + .heading-copy h1 { max-width: calc(100vw - 122px); font-size: 19px; line-height: 1.32; } + .control-panel { + top: 112px; + right: 12px; + bottom: 12px; + left: 12px; + width: auto; + padding-top: 13px; + } + .panel-close { display: block; } + .panel-open { top: 88px; left: 14px; } + .experiment-actions { top: 64px; right: 14px; } + .primary-button { min-width: 142px; height: 48px; padding: 0 14px; font-size: 14px; } + .round-icon { width: 30px; height: 30px; } + .reset-button { min-width: 48px; width: 48px; height: 48px; padding: 0; } + .reset-button span { display: none; } + .hint-bar { display: none; } + .media-label { display: none; } + .workflow-diagram { top: 112px; right: 10px; left: auto; transform-origin: top right; } + .workflow-diagram--projection { width: min(190px, 48vw); } + .workflow-diagram--density { width: min(235px, 60vw); } + .terrain-callout { width: min(210px, calc(100vw - 20px)); padding: 12px 14px 13px; } + .terrain-callout strong { font-size: 17px; } + .terrain-callout p { font-size: 12px; } + .observation-card { grid-template-columns: 1fr; } + .top-view-card { min-height: 150px; } +} + +@media (prefers-reduced-motion: reduce) { + *, *::before, *::after { + scroll-behavior: auto !important; + animation-duration: .01ms !important; + animation-iteration-count: 1 !important; + transition-duration: .01ms !important; + } + .scan-effect { display: none; } + #terrain-annotation-canvas { transition: none; } + .terrain-callout-connector { transition: none; } + .terrain-callout { transition: none; } +} diff --git a/GC-UI/frontend/courseware/assets/terrain-annotation.js b/GC-UI/frontend/courseware/assets/terrain-annotation.js new file mode 100644 index 0000000..edf38c9 --- /dev/null +++ b/GC-UI/frontend/courseware/assets/terrain-annotation.js @@ -0,0 +1,671 @@ +(function () { + "use strict"; + + const THREE = window.THREE; + const root = document.getElementById("terrain-annotation"); + const canvas = document.getElementById("terrain-annotation-canvas"); + const callout = document.getElementById("terrain-callout"); + const calloutTitle = document.getElementById("terrain-callout-title"); + const calloutCopy = document.getElementById("terrain-callout-copy"); + const calloutConnector = document.getElementById("terrain-callout-connector"); + const calloutConnectorShape = document.getElementById("terrain-callout-connector-shape"); + const stage = document.querySelector(".media-stage"); + + if (!THREE || !root || !canvas || !callout || !calloutTitle || !calloutCopy || !calloutConnector || !calloutConnectorShape || !stage) return; + + const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)"); + const compactLayout = window.matchMedia("(max-width: 680px)"); + const SOURCE_ASPECT = 1586 / 992; + const GUIDE_COLOR = "#f6b21a"; + const OUTLINE_COLOR = 0x082742; + const TARGET_OUTER_RADIUS = 20; + const ROLE_STYLES = { + main: { width: 8, outline: 14, opacity: 1, dashed: 0, dashCount: 1, dashRatio: 1, dashSpeed: 0 }, + branch: { width: 6.5, outline: 11.5, opacity: 1, dashed: 1, dashCount: 4, dashRatio: 0.62, dashSpeed: 0 }, + ring: { width: 6, outline: 10.5, opacity: 1, dashed: 0, dashCount: 1, dashRatio: 1, dashSpeed: 0 }, + contour: { width: 4.5, outline: 8.5, opacity: 1, dashed: 0, dashCount: 1, dashRatio: 1, dashSpeed: 0 }, + bracket: { width: 5.5, outline: 10, opacity: 1, dashed: 1, dashCount: 4, dashRatio: 0.62, dashSpeed: 0 } + }; + + const ANNOTATIONS = { + peak: { + title: "山峰 · 最高中心", + copy: "闭合等高线由外向内数值升高,中心位置为山峰。", + color: GUIDE_COLOR, + perspective: { + traces: [ + { role: "main", arrow: true, points: [[0.628, 0.575], [0.650, 0.455], [0.670, 0.280], [0.709, 0.143]] } + ], + target: [0.709, 0.143], + placement: { side: "right", dx: 34, dy: 24 } + }, + top: { + traces: [ + { role: "main", arrow: true, points: [[0.575, 0.645], [0.610, 0.555], [0.645, 0.485], [0.668, 0.449]] } + ], + target: [0.668, 0.449], + placement: { side: "right", dx: 34, dy: -10 } + } + }, + ridge: { + title: "山脊 · 分水脊线", + copy: "等高线向低处凸出,脊线两侧水流向外分开。", + color: GUIDE_COLOR, + perspective: { + traces: [ + { role: "main", arrow: true, points: [[0.765, 0.245], [0.720, 0.365], [0.675, 0.500], [0.625, 0.645]] }, + { role: "branch", arrow: true, points: [[0.675, 0.500], [0.635, 0.535], [0.595, 0.565]] }, + { role: "branch", arrow: true, points: [[0.675, 0.500], [0.715, 0.535], [0.755, 0.570]] } + ], + target: [0.675, 0.500], + placement: { side: "left", dx: -34, dy: -85 } + }, + top: { + traces: [ + { role: "main", arrow: true, points: [[0.690, 0.270], [0.655, 0.395], [0.620, 0.520], [0.590, 0.650]] }, + { role: "branch", arrow: true, points: [[0.620, 0.520], [0.582, 0.545], [0.548, 0.575]] }, + { role: "branch", arrow: true, points: [[0.620, 0.520], [0.658, 0.548], [0.695, 0.580]] } + ], + target: [0.620, 0.520], + placement: { side: "left", dx: -34, dy: -85 } + } + }, + valley: { + title: "山谷 · 汇水谷线", + copy: "V形尖端指向上游,水流沿谷底向下游汇集。", + color: GUIDE_COLOR, + perspective: { + traces: [ + { role: "main", arrow: true, points: [[0.690, 0.410], [0.678, 0.520], [0.676, 0.550], [0.660, 0.650], [0.640, 0.790]] }, + { role: "branch", arrow: true, points: [[0.590, 0.560], [0.630, 0.560], [0.676, 0.550]] }, + { role: "branch", arrow: true, points: [[0.750, 0.560], [0.710, 0.560], [0.676, 0.550]] } + ], + target: [0.676, 0.550], + placement: { side: "right", dx: 34, dy: -80 } + }, + top: { + traces: [ + { role: "main", arrow: true, points: [[0.600, 0.355], [0.565, 0.470], [0.525, 0.585], [0.470, 0.690]] }, + { role: "branch", arrow: true, points: [[0.455, 0.520], [0.490, 0.555], [0.525, 0.585]] }, + { role: "branch", arrow: true, points: [[0.600, 0.510], [0.565, 0.550], [0.525, 0.585]] } + ], + target: [0.525, 0.585], + placement: { side: "right", dx: 34, dy: 70 } + } + }, + saddle: { + title: "鞍部 · 两峰低口", + copy: "两组闭合等高线之间的低口,就是鞍部。", + color: GUIDE_COLOR, + perspective: { + traces: [ + { role: "main", points: [[0.625, 0.425], [0.675, 0.465], [0.725, 0.420]] } + ], + target: [0.675, 0.465], + placement: { side: "below", dx: 0, dy: 38 } + }, + top: { + traces: [ + { role: "main", points: [[0.515, 0.475], [0.560, 0.505], [0.610, 0.475]] } + ], + target: [0.560, 0.505], + placement: { side: "below", dx: 0, dy: 38 } + } + }, + cliff: { + title: "陡崖 · 密集重合带", + copy: "等高线极密集或重合,表示此处坡度陡峭。", + color: GUIDE_COLOR, + perspective: { + traces: [ + { role: "contour", points: [[0.535, 0.345], [0.565, 0.352], [0.590, 0.360]] }, + { role: "contour", points: [[0.532, 0.390], [0.562, 0.398], [0.590, 0.405]] }, + { role: "contour", points: [[0.530, 0.435], [0.560, 0.443], [0.590, 0.452]] }, + { role: "main", arrow: true, points: [[0.595, 0.305], [0.590, 0.405], [0.598, 0.510]] } + ], + target: [0.590, 0.405], + placement: { side: "right", dx: 34, dy: 0 } + }, + top: { + traces: [ + { role: "main", arrow: true, points: [[0.535, 0.560], [0.585, 0.520], [0.635, 0.480]] }, + { role: "contour", points: [[0.555, 0.455], [0.575, 0.515], [0.595, 0.575]] }, + { role: "contour", points: [[0.590, 0.435], [0.610, 0.495], [0.630, 0.555]] } + ], + target: [0.585, 0.520], + placement: { side: "below", dx: 0, dy: 70 } + } + } + }; + + let renderer; + let scene; + let camera; + let annotationGroup; + let aspect = 1; + let stageHeight = 1; + let animationFrame = 0; + let revealStart = 0; + let calloutTimer = 0; + let hideTimer = 0; + let currentKey = null; + let currentMode = "perspective"; + let buildToken = 0; + let animatedMaterials = []; + let revealGeometries = []; + let pulseMeshes = []; + let delayedMarkers = []; + let runnerDots = []; + + try { + renderer = new THREE.WebGLRenderer({ canvas: canvas, alpha: true, antialias: true, powerPreference: "high-performance" }); + renderer.setClearColor(0x000000, 0); + renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75)); + scene = new THREE.Scene(); + camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0.1, 10); + camera.position.z = 4; + } catch (error) { + root.dataset.renderer = "unavailable"; + return; + } + + function sourceToScreen(point) { + let renderedWidth = 1; + let renderedHeight = 1; + let offsetX = 0; + let offsetY = 0; + if (compactLayout.matches) { + if (aspect >= SOURCE_ASPECT) { + renderedWidth = SOURCE_ASPECT / aspect; + offsetX = (1 - renderedWidth) / 2; + } else { + renderedHeight = aspect / SOURCE_ASPECT; + offsetY = (1 - renderedHeight) / 2; + } + } else { + if (aspect >= SOURCE_ASPECT) { + renderedHeight = aspect / SOURCE_ASPECT; + offsetY = (1 - renderedHeight) / 2; + } else { + renderedWidth = SOURCE_ASPECT / aspect; + offsetX = (1 - renderedWidth) / 2; + } + } + return [offsetX + point[0] * renderedWidth, offsetY + point[1] * renderedHeight]; + } + + function toWorld(point) { + const screenPoint = sourceToScreen(point); + return new THREE.Vector3((screenPoint[0] - 0.5) * 2 * aspect, (0.5 - screenPoint[1]) * 2, 0); + } + + function getVisualScale() { + return Math.max(0.72, Math.min(1, stage.clientWidth / 1200)); + } + + function disposeMaterial(material) { + if (Array.isArray(material)) material.forEach(disposeMaterial); + else if (material && typeof material.dispose === "function") material.dispose(); + } + + function clearAnnotation() { + if (!annotationGroup) return; + annotationGroup.traverse(function (object) { + if (object.geometry) object.geometry.dispose(); + if (object.material) disposeMaterial(object.material); + }); + scene.remove(annotationGroup); + annotationGroup = null; + animatedMaterials = []; + revealGeometries = []; + pulseMeshes = []; + delayedMarkers = []; + runnerDots = []; + } + + function createRibbonGeometry(samples, widthInPixels) { + const positions = []; + const uvs = []; + const indices = []; + const halfWidth = widthInPixels / Math.max(1, stageHeight); + samples.forEach(function (point, index) { + const previous = samples[Math.max(0, index - 1)]; + const next = samples[Math.min(samples.length - 1, index + 1)]; + const tangentX = next.x - previous.x; + const tangentY = next.y - previous.y; + const length = Math.hypot(tangentX, tangentY) || 1; + const normalX = -tangentY / length; + const normalY = tangentX / length; + const progress = index / Math.max(1, samples.length - 1); + positions.push(point.x + normalX * halfWidth, point.y + normalY * halfWidth, point.z); + positions.push(point.x - normalX * halfWidth, point.y - normalY * halfWidth, point.z); + uvs.push(progress, 0, progress, 1); + if (index < samples.length - 1) { + const base = index * 2; + indices.push(base, base + 1, base + 2, base + 1, base + 3, base + 2); + } + }); + const geometry = new THREE.BufferGeometry(); + geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3)); + geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2)); + geometry.setIndex(indices); + geometry.computeBoundingSphere(); + return geometry; + } + + function makeLineMaterial(color, style) { + return new THREE.ShaderMaterial({ + uniforms: { + uTime: { value: 0 }, + uColor: { value: new THREE.Color(color) }, + uOpacity: { value: style.opacity }, + uMotion: { value: reducedMotion.matches ? 0 : 1 }, + uDashed: { value: style.dashed }, + uDashCount: { value: style.dashCount }, + uDashRatio: { value: style.dashRatio }, + uDashSpeed: { value: style.dashSpeed } + }, + vertexShader: [ + "varying vec2 vUv;", + "void main() {", + " vUv = uv;", + " gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", + "}" + ].join("\n"), + fragmentShader: [ + "uniform float uTime;", + "uniform vec3 uColor;", + "uniform float uOpacity;", + "uniform float uMotion;", + "uniform float uDashed;", + "uniform float uDashCount;", + "uniform float uDashRatio;", + "uniform float uDashSpeed;", + "varying vec2 vUv;", + "void main() {", + " float edge = 1.0 - smoothstep(0.43, 0.50, abs(vUv.y - 0.5));", + " float dashPhase = fract(vUv.x * uDashCount - uTime * uDashSpeed * uMotion);", + " float dash = 1.0 - smoothstep(uDashRatio - 0.04, uDashRatio + 0.04, dashPhase);", + " float pattern = mix(1.0, dash, uDashed);", + " float alpha = uOpacity * edge * pattern;", + " gl_FragColor = vec4(uColor, alpha);", + "}" + ].join("\n"), + transparent: true, + depthTest: false, + depthWrite: false, + blending: THREE.NormalBlending + }); + } + + function createArrow(points, color, sizeInPixels, delay, stopBeforePixels) { + const end = toWorld(points[points.length - 1]); + const before = toWorld(points[points.length - 2]); + const direction = end.clone().sub(before).normalize(); + const angle = Math.atan2(direction.y, direction.x); + const unit = 2 / Math.max(1, stageHeight); + const visualScale = getVisualScale(); + const scaledSize = sizeInPixels * visualScale; + const arrowPosition = end.clone().addScaledVector(direction, -(stopBeforePixels || 0) * visualScale * unit); + function createArrowGeometry(pixelSize) { + const size = pixelSize * unit; + const geometry = new THREE.BufferGeometry(); + geometry.setAttribute("position", new THREE.Float32BufferAttribute([ + 0, 0, 0, + -size * 1.90, size * 0.88, 0, + -size * 1.90, -size * 0.88, 0 + ], 3)); + return geometry; + } + const outlineMaterial = new THREE.MeshBasicMaterial({ color: OUTLINE_COLOR, transparent: true, opacity: 1, depthTest: false, depthWrite: false }); + const material = new THREE.MeshBasicMaterial({ color: color, transparent: true, opacity: 1, depthTest: false, depthWrite: false }); + const outline = new THREE.Mesh(createArrowGeometry(scaledSize + 2.5 * visualScale), outlineMaterial); + const arrow = new THREE.Mesh(createArrowGeometry(scaledSize), material); + outline.position.copy(arrowPosition).addScaledVector(direction, 1.25 * visualScale * unit); + arrow.position.copy(arrowPosition); + outline.rotation.z = angle; + arrow.rotation.z = angle; + outline.renderOrder = 40; + arrow.renderOrder = 41; + annotationGroup.add(outline, arrow); + delayedMarkers.push({ mesh: outline, delay: delay + 0.46 }); + delayedMarkers.push({ mesh: arrow, delay: delay + 0.46 }); + } + + function createRunnerDots(curve, delay, count) { + const pixelUnit = 2 / Math.max(1, stageHeight); + const visualScale = getVisualScale(); + const phases = count === 1 ? [0.18] : count === 2 ? [0.18, 0.70] : [0.12, 0.45, 0.78]; + phases.forEach(function (phase, index) { + const glowMaterial = new THREE.MeshBasicMaterial({ + color: 0xffffff, + transparent: true, + opacity: 0.28, + depthTest: false, + depthWrite: false, + blending: THREE.AdditiveBlending + }); + const dotMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: 1, depthTest: false, depthWrite: false }); + const glow = new THREE.Mesh(new THREE.CircleGeometry(11 * visualScale * pixelUnit, 40), glowMaterial); + const dot = new THREE.Mesh(new THREE.CircleGeometry(7.5 * visualScale * pixelUnit, 40), dotMaterial); + const position = curve.getPointAt(phase); + glow.position.copy(position); + dot.position.copy(position); + glow.renderOrder = 44; + dot.renderOrder = 45; + glow.visible = false; + dot.visible = false; + annotationGroup.add(glow, dot); + runnerDots.push({ glow: glow, dot: dot, curve: curve, phase: phase, delay: delay + 0.18, pulseOffset: index * 1.8 }); + }); + } + + function createTrace(trace, color, index, target) { + const style = ROLE_STYLES[trace.role] || ROLE_STYLES.main; + const worldPoints = trace.points.map(toWorld); + const curve = new THREE.CatmullRomCurve3(worldPoints, Boolean(trace.closed), "centripetal", 0.5); + const pathLengthPixels = curve.getLength() * stageHeight / 2; + const samples = curve.getSpacedPoints(Math.max(36, trace.points.length * 12)); + const visualScale = getVisualScale(); + const outlineGeometry = createRibbonGeometry(samples, style.outline * visualScale); + const lineGeometry = createRibbonGeometry(samples, style.width * visualScale); + const outlineMaterial = makeLineMaterial(OUTLINE_COLOR, style); + const lineMaterial = makeLineMaterial(color, style); + const outline = new THREE.Mesh(outlineGeometry, outlineMaterial); + const line = new THREE.Mesh(lineGeometry, lineMaterial); + const isMain = trace.role === "main"; + outline.renderOrder = isMain ? 30 : 20; + line.renderOrder = isMain ? 31 : 21; + annotationGroup.add(outline, line); + animatedMaterials.push(outlineMaterial, lineMaterial); + const delay = index * 0.075; + if (trace.role === "main") createRunnerDots(curve, delay, pathLengthPixels < 180 ? 1 : pathLengthPixels < 320 ? 2 : 3); + revealGeometries.push({ geometry: outlineGeometry, count: outlineGeometry.index.count, delay: delay }); + revealGeometries.push({ geometry: lineGeometry, count: lineGeometry.index.count, delay: delay }); + if (trace.arrow && !trace.closed) { + const endPoint = trace.points[trace.points.length - 1]; + const endsAtTarget = target && Math.hypot(endPoint[0] - target[0], endPoint[1] - target[1]) < 0.002; + const arrowScale = Math.max(0.82, Math.min(1, pathLengthPixels / 240)); + createArrow(trace.points, color, (trace.role === "branch" ? 14 : 15) * arrowScale, delay, endsAtTarget ? TARGET_OUTER_RADIUS + 4 : 0); + } + } + + function createTarget(point, color) { + const position = toWorld(point); + const pixelUnit = 2 / Math.max(1, stageHeight); + const visualScale = getVisualScale(); + const halo = new THREE.Mesh( + new THREE.CircleGeometry(25 * visualScale * pixelUnit, 64), + new THREE.MeshBasicMaterial({ color: color, transparent: true, opacity: 0.20, depthTest: false, depthWrite: false, blending: THREE.AdditiveBlending }) + ); + const outer = new THREE.Mesh( + new THREE.CircleGeometry(TARGET_OUTER_RADIUS * visualScale * pixelUnit, 64), + new THREE.MeshBasicMaterial({ color: OUTLINE_COLOR, transparent: true, opacity: 1, depthTest: false, depthWrite: false }) + ); + const gold = new THREE.Mesh( + new THREE.CircleGeometry(17.5 * visualScale * pixelUnit, 64), + new THREE.MeshBasicMaterial({ color: color, transparent: true, opacity: 1, depthTest: false, depthWrite: false }) + ); + const white = new THREE.Mesh( + new THREE.CircleGeometry(13.5 * visualScale * pixelUnit, 64), + new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: 1, depthTest: false, depthWrite: false }) + ); + const inner = new THREE.Mesh( + new THREE.CircleGeometry(10 * visualScale * pixelUnit, 56), + new THREE.MeshBasicMaterial({ color: OUTLINE_COLOR, transparent: true, opacity: 1, depthTest: false, depthWrite: false }) + ); + const core = new THREE.Mesh( + new THREE.CircleGeometry(7.5 * visualScale * pixelUnit, 56), + new THREE.MeshBasicMaterial({ color: color, transparent: true, opacity: 1, depthTest: false, depthWrite: false }) + ); + [halo, outer, gold, white, inner, core].forEach(function (mesh, index) { + mesh.position.copy(position); + mesh.renderOrder = 49 + index; + annotationGroup.add(mesh); + }); + pulseMeshes.push(halo); + } + + function updateCallout(definition, view) { + const targetScreen = sourceToScreen(view.target); + const placement = view.placement; + calloutTitle.textContent = definition.title + (currentMode === "top" ? " · 俯视判读" : ""); + calloutCopy.textContent = definition.copy; + const width = stage.clientWidth; + const height = stage.clientHeight; + const targetX = targetScreen[0] * width; + const targetY = targetScreen[1] * height; + const cardWidth = callout.offsetWidth || Math.min(width <= 680 ? 210 : width <= 920 ? 250 : 280, width - 28); + const cardHeight = callout.offsetHeight || 88; + let side = placement.side; + let x = targetX + placement.dx; + let y = targetY + placement.dy; + const targetGap = TARGET_OUTER_RADIUS * getVisualScale() + 18; + const horizontalGap = Math.max(Math.abs(placement.dx), targetGap); + const verticalGap = Math.max(Math.abs(placement.dy), targetGap); + + if (side === "right") x = targetX + horizontalGap; + else if (side === "left") x = targetX - horizontalGap; + else if (side === "below") y = targetY + verticalGap; + else if (side === "above") y = targetY - verticalGap; + + if (side === "right" && x + cardWidth > width - 14) { + side = "left"; + x = targetX - horizontalGap; + } else if (side === "left" && x - cardWidth < 14) { + side = "right"; + x = targetX + horizontalGap; + } else if (side === "below" && y + cardHeight > height - 14) { + side = "above"; + y = targetY - verticalGap; + } else if (side === "above" && y - cardHeight < 14) { + side = "below"; + y = targetY + verticalGap; + } + + if (side === "right" || side === "left") { + const horizontalMargin = compactLayout.matches ? 0 : 14; + if (side === "right") x = Math.max(horizontalMargin, Math.min(width - cardWidth - horizontalMargin, x)); + else x = Math.max(cardWidth + horizontalMargin, Math.min(width - horizontalMargin, x)); + y = Math.max(cardHeight / 2 + 14, Math.min(height - cardHeight / 2 - 14, y)); + } else { + x = Math.max(cardWidth / 2 + 14, Math.min(width - cardWidth / 2 - 14, x)); + } + + const connectorBaseHalf = 28 * getVisualScale(); + let anchorX = x; + let anchorY = y; + let baseOne; + let baseTwo; + if (side === "right" || side === "left") { + const verticalLimit = Math.max(0, cardHeight / 2 - connectorBaseHalf - 4); + anchorY = y + Math.max(-verticalLimit, Math.min(verticalLimit, targetY - y)); + baseOne = [anchorX, anchorY - connectorBaseHalf]; + baseTwo = [anchorX, anchorY + connectorBaseHalf]; + } else { + const horizontalLimit = Math.max(0, cardWidth / 2 - connectorBaseHalf - 4); + anchorX = x + Math.max(-horizontalLimit, Math.min(horizontalLimit, targetX - x)); + baseOne = [anchorX - connectorBaseHalf, anchorY]; + baseTwo = [anchorX + connectorBaseHalf, anchorY]; + } + const connectorX = anchorX - targetX; + const connectorY = anchorY - targetY; + const connectorLength = Math.hypot(connectorX, connectorY) || 1; + const tipRadius = TARGET_OUTER_RADIUS * getVisualScale() * 0.72; + const tipX = targetX + connectorX / connectorLength * tipRadius; + const tipY = targetY + connectorY / connectorLength * tipRadius; + calloutConnector.setAttribute("viewBox", "0 0 " + width + " " + height); + calloutConnectorShape.setAttribute( + "points", + tipX.toFixed(1) + "," + tipY.toFixed(1) + " " + + baseOne[0].toFixed(1) + "," + baseOne[1].toFixed(1) + " " + + baseTwo[0].toFixed(1) + "," + baseTwo[1].toFixed(1) + ); + + const pointerInset = 32; + const pointerOffsetX = Math.max(-cardWidth / 2 + pointerInset, Math.min(cardWidth / 2 - pointerInset, targetX - x)); + const pointerOffsetY = Math.max(-cardHeight / 2 + pointerInset, Math.min(cardHeight / 2 - pointerInset, targetY - y)); + root.style.setProperty("--callout-x", x + "px"); + root.style.setProperty("--callout-y", y + "px"); + root.style.setProperty("--pointer-offset-x", pointerOffsetX + "px"); + root.style.setProperty("--pointer-offset-y", pointerOffsetY + "px"); + root.dataset.side = side; + root.dataset.tone = currentKey === "cliff" ? "warning" : "default"; + } + + function buildAnnotation(key, mode, animate) { + const definition = ANNOTATIONS[key]; + if (!definition) return; + const view = definition[mode === "top" ? "top" : "perspective"]; + clearAnnotation(); + annotationGroup = new THREE.Group(); + scene.add(annotationGroup); + view.traces.forEach(function (trace, index) { createTrace(trace, definition.color, index, view.target); }); + createTarget(view.target, definition.color); + updateCallout(definition, view); + revealGeometries.forEach(function (item) { + item.geometry.setDrawRange(0, animate && !reducedMotion.matches ? 0 : item.count); + }); + delayedMarkers.forEach(function (item) { item.mesh.visible = !animate || reducedMotion.matches; }); + runnerDots.forEach(function (item) { + const position = item.curve.getPointAt(item.phase); + item.glow.position.copy(position); + item.dot.position.copy(position); + item.glow.visible = !animate || reducedMotion.matches; + item.dot.visible = !animate || reducedMotion.matches; + }); + revealStart = performance.now() - (animate && !reducedMotion.matches ? 0 : 760); + } + + function resize() { + const width = Math.max(1, stage.clientWidth); + const height = Math.max(1, stage.clientHeight); + const nextAspect = width / height; + const sizeChanged = Math.abs(nextAspect - aspect) > 0.001 || Math.abs(height - stageHeight) > 1; + aspect = nextAspect; + stageHeight = height; + renderer.setSize(width, height, false); + camera.left = -nextAspect; + camera.right = nextAspect; + camera.top = 1; + camera.bottom = -1; + camera.updateProjectionMatrix(); + if (sizeChanged && currentKey && !root.hidden) buildAnnotation(currentKey, currentMode, false); + renderer.render(scene, camera); + } + + function renderFrame(now) { + if (!currentKey || root.hidden || document.hidden) { + animationFrame = 0; + return; + } + const seconds = now * 0.001; + const elapsed = (now - revealStart) / 760; + animatedMaterials.forEach(function (material) { + material.uniforms.uTime.value = seconds; + material.uniforms.uMotion.value = reducedMotion.matches ? 0 : 1; + }); + if (!reducedMotion.matches) { + revealGeometries.forEach(function (item) { + const progress = Math.max(0, Math.min(1, (elapsed - item.delay) / 0.62)); + const eased = 1 - Math.pow(1 - progress, 3); + const count = Math.floor(item.count * eased / 6) * 6; + item.geometry.setDrawRange(0, Math.max(0, count)); + }); + delayedMarkers.forEach(function (item) { item.mesh.visible = elapsed >= item.delay; }); + const motionSeconds = Math.max(0, (now - revealStart) * 0.001); + runnerDots.forEach(function (item) { + const visible = elapsed >= item.delay; + item.glow.visible = visible; + item.dot.visible = visible; + if (!visible) return; + const position = item.curve.getPointAt((item.phase + motionSeconds * 0.065) % 1); + item.glow.position.copy(position); + item.dot.position.copy(position); + item.glow.scale.setScalar(1 + Math.sin(seconds * 3.6 + item.pulseOffset) * 0.14); + }); + const pulse = 1 + Math.sin(seconds * 3.2) * 0.10; + pulseMeshes.forEach(function (mesh) { mesh.scale.setScalar(pulse); }); + } + renderer.render(scene, camera); + if (reducedMotion.matches) { + animationFrame = 0; + return; + } + animationFrame = window.requestAnimationFrame(renderFrame); + } + + function startRendering() { + if (!animationFrame) animationFrame = window.requestAnimationFrame(renderFrame); + } + + function show(key, mode) { + if (!ANNOTATIONS[key]) return; + window.clearTimeout(calloutTimer); + window.clearTimeout(hideTimer); + buildToken += 1; + currentKey = key; + currentMode = mode === "top" ? "top" : "perspective"; + root.hidden = false; + root.classList.remove("is-visible", "is-callout-visible"); + resize(); + buildAnnotation(currentKey, currentMode, true); + const token = buildToken; + window.requestAnimationFrame(function () { + if (token === buildToken) root.classList.add("is-visible"); + }); + calloutTimer = window.setTimeout(function () { + if (token === buildToken) root.classList.add("is-callout-visible"); + }, reducedMotion.matches ? 0 : 430); + startRendering(); + } + + function hide(immediate) { + buildToken += 1; + currentKey = null; + window.clearTimeout(calloutTimer); + window.clearTimeout(hideTimer); + root.classList.remove("is-visible", "is-callout-visible"); + if (immediate) { + root.hidden = true; + clearAnnotation(); + if (animationFrame) { + window.cancelAnimationFrame(animationFrame); + animationFrame = 0; + } + return; + } + hideTimer = window.setTimeout(function () { + if (!currentKey) { + root.hidden = true; + clearAnnotation(); + } + }, 220); + } + + if (typeof ResizeObserver === "function") { + const observer = new ResizeObserver(resize); + observer.observe(stage); + } else { + window.addEventListener("resize", resize, { passive: true }); + } + const handleMotionPreference = function () { + if (currentKey) { + buildAnnotation(currentKey, currentMode, false); + startRendering(); + } + }; + if (typeof reducedMotion.addEventListener === "function") reducedMotion.addEventListener("change", handleMotionPreference); + else if (typeof reducedMotion.addListener === "function") reducedMotion.addListener(handleMotionPreference); + document.addEventListener("visibilitychange", function () { + if (!document.hidden && currentKey) startRendering(); + }); + + window.TerrainAnnotation = { + show: show, + hide: hide, + getState: function () { + return { key: currentKey, mode: currentMode, renderer: "three-r" + THREE.REVISION, side: root.dataset.side || null }; + } + }; +})(); diff --git a/GC-UI/frontend/courseware/assets/three.min.js b/GC-UI/frontend/courseware/assets/three.min.js new file mode 100644 index 0000000..7723e1d --- /dev/null +++ b/GC-UI/frontend/courseware/assets/three.min.js @@ -0,0 +1,4113 @@ +/*! Three.js r184 | MIT License | https://threejs.org */ +var THREE=(()=>{var qh=Object.defineProperty;var yg=Object.getOwnPropertyDescriptor;var Mg=Object.getOwnPropertyNames;var Sg=Object.prototype.hasOwnProperty;var bg=(s,e)=>{for(var t in e)qh(s,t,{get:e[t],enumerable:!0})},Tg=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Mg(e))!Sg.call(s,n)&&n!==t&&qh(s,n,{get:()=>e[n],enumerable:!(i=yg(e,n))||i.enumerable});return s};var Eg=s=>Tg(qh({},"__esModule",{value:!0}),s);var ov={};bg(ov,{ACESFilmicToneMapping:()=>Xc,AddEquation:()=>or,AddOperation:()=>_d,AdditiveAnimationBlendMode:()=>Ph,AdditiveBlending:()=>Lc,AgXToneMapping:()=>qc,AlphaFormat:()=>yd,AlwaysCompare:()=>Rd,AlwaysDepth:()=>Fc,AlwaysStencilFunc:()=>hf,AmbientLight:()=>Ya,AnimationAction:()=>so,AnimationClip:()=>Tn,AnimationLoader:()=>Hl,AnimationMixer:()=>ic,AnimationObjectGroup:()=>tc,AnimationUtils:()=>kl,ArcCurve:()=>pa,ArrayCamera:()=>to,ArrowHelper:()=>Ac,AttachedBindMode:()=>Sl,Audio:()=>no,AudioAnalyser:()=>ec,AudioContext:()=>vs,AudioListener:()=>$l,AudioLoader:()=>Jl,AxesHelper:()=>wc,BackSide:()=>Ht,BasicDepthPacking:()=>km,BasicShadowMap:()=>Rm,BatchedMesh:()=>ra,BezierInterpolant:()=>Va,Bone:()=>Jr,BooleanKeyframeTrack:()=>Ui,Box2:()=>pc,Box3:()=>xt,Box3Helper:()=>Tc,BoxGeometry:()=>yn,BoxHelper:()=>bc,BufferAttribute:()=>Je,BufferGeometry:()=>Ue,BufferGeometryLoader:()=>Qa,ByteType:()=>Zc,Cache:()=>vi,Camera:()=>rr,CameraHelper:()=>Sc,CanvasTexture:()=>zl,CapsuleGeometry:()=>ca,CatmullRomCurve3:()=>ma,CineonToneMapping:()=>Wc,CircleGeometry:()=>ha,ClampToEdgeWrapping:()=>ei,Clock:()=>cc,Color:()=>ue,ColorKeyframeTrack:()=>ms,ColorManagement:()=>Ge,Compatibility:()=>bf,CompressedArrayTexture:()=>Ol,CompressedCubeTexture:()=>Bl,CompressedTexture:()=>Qn,CompressedTextureLoader:()=>Wl,ConeGeometry:()=>es,ConstantAlphaFactor:()=>pd,ConstantColorFactor:()=>ud,Controls:()=>Rc,CubeCamera:()=>eo,CubeDepthTexture:()=>la,CubeReflectionMapping:()=>nn,CubeRefractionMapping:()=>wn,CubeTexture:()=>xn,CubeTextureLoader:()=>Xl,CubeUVReflectionMapping:()=>Ms,CubicBezierCurve:()=>ts,CubicBezierCurve3:()=>fa,CubicInterpolant:()=>za,CullFaceBack:()=>Pc,CullFaceFront:()=>qu,CullFaceFrontBack:()=>Cm,CullFaceNone:()=>ju,Curve:()=>Zt,CurvePath:()=>_a,CustomBlending:()=>Zu,CustomToneMapping:()=>jc,CylinderGeometry:()=>Qr,Cylindrical:()=>uc,Data3DTexture:()=>Zn,DataArrayTexture:()=>Yn,DataTexture:()=>qt,DataTextureLoader:()=>jl,DataUtils:()=>Al,DecrementStencilOp:()=>$m,DecrementWrapStencilOp:()=>ef,DefaultLoadingManager:()=>Ud,DepthFormat:()=>rn,DepthStencilFormat:()=>Cn,DepthTexture:()=>Bi,DetachedBindMode:()=>vd,DirectionalLight:()=>qa,DirectionalLightHelper:()=>Mc,DiscreteInterpolant:()=>Ga,DodecahedronGeometry:()=>ua,DoubleSide:()=>bi,DstAlphaFactor:()=>ad,DstColorFactor:()=>ld,DynamicCopyUsage:()=>_f,DynamicDrawUsage:()=>uf,DynamicReadUsage:()=>mf,EdgesGeometry:()=>da,EllipseCurve:()=>er,EqualCompare:()=>Ad,EqualDepth:()=>Bc,EqualStencilFunc:()=>sf,EquirectangularReflectionMapping:()=>lo,EquirectangularRefractionMapping:()=>co,Euler:()=>ai,EventDispatcher:()=>Yt,ExternalTexture:()=>$r,ExtrudeGeometry:()=>Ma,FileLoader:()=>oi,Float16BufferAttribute:()=>Ll,Float32BufferAttribute:()=>pe,FloatType:()=>Dt,Fog:()=>Js,FogExp2:()=>Zs,FramebufferTexture:()=>Fl,FrontSide:()=>ar,Frustum:()=>Qi,FrustumArray:()=>na,GLBufferAttribute:()=>oc,GLSL1:()=>xf,GLSL3:()=>Dh,GreaterCompare:()=>wd,GreaterDepth:()=>Gc,GreaterEqualCompare:()=>bo,GreaterEqualDepth:()=>zc,GreaterEqualStencilFunc:()=>cf,GreaterStencilFunc:()=>of,GridHelper:()=>xc,Group:()=>Zi,HTMLTexture:()=>Gl,HalfFloatType:()=>Ai,HemisphereLight:()=>Ha,HemisphereLightHelper:()=>vc,IcosahedronGeometry:()=>Sa,ImageBitmapLoader:()=>Zl,ImageLoader:()=>En,ImageUtils:()=>Ys,IncrementStencilOp:()=>Km,IncrementWrapStencilOp:()=>Qm,InstancedBufferAttribute:()=>$i,InstancedBufferGeometry:()=>$a,InstancedInterleavedBuffer:()=>ac,InstancedMesh:()=>ia,Int16BufferAttribute:()=>Il,Int32BufferAttribute:()=>Pl,Int8BufferAttribute:()=>wl,IntType:()=>uo,InterleavedBuffer:()=>$n,InterleavedBufferAttribute:()=>vn,Interpolant:()=>tn,InterpolateBezier:()=>bl,InterpolateDiscrete:()=>zr,InterpolateLinear:()=>js,InterpolateSmooth:()=>ks,InterpolationSamplingMode:()=>Sf,InterpolationSamplingType:()=>Mf,InvertStencilOp:()=>tf,KeepStencilOp:()=>pn,KeyframeTrack:()=>Gt,LOD:()=>Qs,LatheGeometry:()=>ba,Layers:()=>Jn,LessCompare:()=>Ed,LessDepth:()=>Oc,LessEqualCompare:()=>So,LessEqualDepth:()=>ao,LessEqualStencilFunc:()=>af,LessStencilFunc:()=>rf,Light:()=>Si,LightProbe:()=>Ja,Line:()=>Mi,Line3:()=>mc,LineBasicMaterial:()=>Et,LineCurve:()=>is,LineCurve3:()=>ga,LineDashedMaterial:()=>Ba,LineLoop:()=>sa,LineSegments:()=>ti,LinearFilter:()=>at,LinearInterpolant:()=>ps,LinearMipMapLinearFilter:()=>Nm,LinearMipMapNearestFilter:()=>Dm,LinearMipmapLinearFilter:()=>zi,LinearMipmapNearestFilter:()=>ho,LinearSRGBColorSpace:()=>Vr,LinearToneMapping:()=>kc,LinearTransfer:()=>kr,Loader:()=>wt,LoaderUtils:()=>_s,LoadingManager:()=>fs,LoopOnce:()=>Fm,LoopPingPong:()=>Bm,LoopRepeat:()=>Om,MOUSE:()=>Am,Material:()=>yt,MaterialBlending:()=>Im,MaterialLoader:()=>Ka,MathUtils:()=>If,Matrix2:()=>dc,Matrix3:()=>De,Matrix4:()=>Re,MaxEquation:()=>Qu,Mesh:()=>ot,MeshBasicMaterial:()=>yi,MeshDepthMaterial:()=>us,MeshDistanceMaterial:()=>ds,MeshLambertMaterial:()=>Fa,MeshMatcapMaterial:()=>Oa,MeshNormalMaterial:()=>Ua,MeshPhongMaterial:()=>Da,MeshPhysicalMaterial:()=>La,MeshStandardMaterial:()=>hs,MeshToonMaterial:()=>Na,MinEquation:()=>$u,MirroredRepeatWrapping:()=>Br,MixOperation:()=>gd,MultiplyBlending:()=>Nc,MultiplyOperation:()=>fd,NearestFilter:()=>Lt,NearestMipMapLinearFilter:()=>Lm,NearestMipMapNearestFilter:()=>Pm,NearestMipmapLinearFilter:()=>Ss,NearestMipmapNearestFilter:()=>xd,NeutralToneMapping:()=>Yc,NeverCompare:()=>Td,NeverDepth:()=>Uc,NeverStencilFunc:()=>nf,NoBlending:()=>Ti,NoColorSpace:()=>In,NoNormalPacking:()=>jm,NoToneMapping:()=>li,NormalAnimationBlendMode:()=>Sd,NormalBlending:()=>ys,NormalGAPacking:()=>Ym,NormalRGPacking:()=>qm,NotEqualCompare:()=>Cd,NotEqualDepth:()=>Vc,NotEqualStencilFunc:()=>lf,NumberKeyframeTrack:()=>Mn,Object3D:()=>Ye,ObjectLoader:()=>Yl,ObjectSpaceNormalMap:()=>bd,OctahedronGeometry:()=>os,OneFactor:()=>td,OneMinusConstantAlphaFactor:()=>md,OneMinusConstantColorFactor:()=>dd,OneMinusDstAlphaFactor:()=>od,OneMinusDstColorFactor:()=>cd,OneMinusSrcAlphaFactor:()=>sd,OneMinusSrcColorFactor:()=>nd,OrthographicCamera:()=>An,PCFShadowMap:()=>xs,PCFSoftShadowMap:()=>Yu,PMREMGenerator:()=>Co,Path:()=>tr,PerspectiveCamera:()=>ft,Plane:()=>fi,PlaneGeometry:()=>nr,PlaneHelper:()=>Ec,PointLight:()=>ja,PointLightHelper:()=>_c,Points:()=>aa,PointsMaterial:()=>Kr,PolarGridHelper:()=>yc,PolyhedronGeometry:()=>en,PositionalAudio:()=>Ql,PropertyBinding:()=>Ke,PropertyMixer:()=>ro,QuadraticBezierCurve:()=>ns,QuadraticBezierCurve3:()=>rs,Quaternion:()=>Tt,QuaternionKeyframeTrack:()=>Sn,QuaternionLinearInterpolant:()=>ka,R11_EAC_Format:()=>lh,RED_GREEN_RGTC2_Format:()=>Mo,RED_RGTC1_Format:()=>Ch,REVISION:()=>Xu,RG11_EAC_Format:()=>yo,RGBADepthPacking:()=>Hm,RGBAFormat:()=>Vt,RGBAIntegerFormat:()=>eh,RGBA_ASTC_10x10_Format:()=>Sh,RGBA_ASTC_10x5_Format:()=>xh,RGBA_ASTC_10x6_Format:()=>yh,RGBA_ASTC_10x8_Format:()=>Mh,RGBA_ASTC_12x10_Format:()=>bh,RGBA_ASTC_12x12_Format:()=>Th,RGBA_ASTC_4x4_Format:()=>uh,RGBA_ASTC_5x4_Format:()=>dh,RGBA_ASTC_5x5_Format:()=>ph,RGBA_ASTC_6x5_Format:()=>mh,RGBA_ASTC_6x6_Format:()=>fh,RGBA_ASTC_8x5_Format:()=>gh,RGBA_ASTC_8x6_Format:()=>_h,RGBA_ASTC_8x8_Format:()=>vh,RGBA_BPTC_Format:()=>Eh,RGBA_ETC2_EAC_Format:()=>oh,RGBA_PVRTC_2BPPV1_Format:()=>rh,RGBA_PVRTC_4BPPV1_Format:()=>nh,RGBA_S3TC_DXT1_Format:()=>_o,RGBA_S3TC_DXT3_Format:()=>vo,RGBA_S3TC_DXT5_Format:()=>xo,RGBDepthPacking:()=>Wm,RGBFormat:()=>Md,RGBIntegerFormat:()=>Um,RGB_BPTC_SIGNED_Format:()=>Ah,RGB_BPTC_UNSIGNED_Format:()=>wh,RGB_ETC1_Format:()=>sh,RGB_ETC2_Format:()=>ah,RGB_PVRTC_2BPPV1_Format:()=>ih,RGB_PVRTC_4BPPV1_Format:()=>th,RGB_S3TC_DXT1_Format:()=>go,RGDepthPacking:()=>Xm,RGFormat:()=>Rn,RGIntegerFormat:()=>Qc,RawShaderMaterial:()=>cs,Ray:()=>Ki,Raycaster:()=>lc,RectAreaLight:()=>Za,RedFormat:()=>fo,RedIntegerFormat:()=>bs,ReinhardToneMapping:()=>Hc,RenderTarget:()=>jr,RenderTarget3D:()=>nc,RepeatWrapping:()=>Or,ReplaceStencilOp:()=>Jm,ReverseSubtractEquation:()=>Ku,RingGeometry:()=>Ta,SIGNED_R11_EAC_Format:()=>ch,SIGNED_RED_GREEN_RGTC2_Format:()=>Ih,SIGNED_RED_RGTC1_Format:()=>Rh,SIGNED_RG11_EAC_Format:()=>hh,SRGBColorSpace:()=>Bt,SRGBTransfer:()=>Ze,Scene:()=>Ks,ShaderChunk:()=>Be,ShaderLib:()=>wi,ShaderMaterial:()=>kt,ShadowMaterial:()=>Pa,Shape:()=>Oi,ShapeGeometry:()=>Ea,ShapePath:()=>Cc,ShapeUtils:()=>si,ShortType:()=>Jc,Skeleton:()=>ta,SkeletonHelper:()=>gc,SkinnedMesh:()=>ea,Source:()=>_i,Sphere:()=>gt,SphereGeometry:()=>ls,Spherical:()=>hc,SphericalHarmonics3:()=>gs,SplineCurve:()=>ss,SpotLight:()=>Xa,SpotLightHelper:()=>fc,Sprite:()=>$s,SpriteMaterial:()=>Zr,SrcAlphaFactor:()=>rd,SrcAlphaSaturateFactor:()=>hd,SrcColorFactor:()=>id,StaticCopyUsage:()=>gf,StaticDrawUsage:()=>Hr,StaticReadUsage:()=>pf,StereoCamera:()=>Kl,StreamCopyUsage:()=>vf,StreamDrawUsage:()=>df,StreamReadUsage:()=>ff,StringKeyframeTrack:()=>Fi,SubtractEquation:()=>Ju,SubtractiveBlending:()=>Dc,TOUCH:()=>wm,TangentSpaceNormalMap:()=>Lh,TetrahedronGeometry:()=>Aa,Texture:()=>ct,TextureLoader:()=>ql,TextureUtils:()=>Ic,Timer:()=>io,TimestampQuery:()=>yf,TorusGeometry:()=>wa,TorusKnotGeometry:()=>Ca,Triangle:()=>gi,TriangleFanDrawMode:()=>Vm,TriangleStripDrawMode:()=>Gm,TrianglesDrawMode:()=>zm,TubeGeometry:()=>Ra,UVMapping:()=>oo,Uint16BufferAttribute:()=>qr,Uint32BufferAttribute:()=>Yr,Uint8BufferAttribute:()=>Cl,Uint8ClampedBufferAttribute:()=>Rl,Uniform:()=>rc,UniformsGroup:()=>sc,UniformsLib:()=>ce,UniformsUtils:()=>Dd,UnsignedByteType:()=>Jt,UnsignedInt101111Type:()=>$c,UnsignedInt248Type:()=>cr,UnsignedInt5999Type:()=>Kc,UnsignedIntType:()=>Ei,UnsignedShort4444Type:()=>po,UnsignedShort5551Type:()=>mo,UnsignedShortType:()=>lr,VSMShadowMap:()=>sr,Vector2:()=>Q,Vector3:()=>w,Vector4:()=>$e,VectorKeyframeTrack:()=>bn,VideoFrameTexture:()=>Ul,VideoTexture:()=>oa,WebGL3DRenderTarget:()=>El,WebGLArrayRenderTarget:()=>Tl,WebGLCoordinateSystem:()=>xi,WebGLCubeRenderTarget:()=>Ro,WebGLRenderTarget:()=>Nt,WebGLRenderer:()=>$d,WebGLUtils:()=>dg,WebGPUCoordinateSystem:()=>gn,WebXRController:()=>Kn,WireframeGeometry:()=>Ia,WrapAroundEnding:()=>Gr,ZeroCurvatureEnding:()=>mn,ZeroFactor:()=>ed,ZeroSlopeEnding:()=>fn,ZeroStencilOp:()=>Zm,createCanvasElement:()=>Id,error:()=>ve,getConsoleFunction:()=>Af,log:()=>Xr,setConsoleFunction:()=>Ef,warn:()=>re,warnOnce:()=>qs});/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */var Xu="184",Am={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},wm={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ju=0,Pc=1,qu=2,Cm=3,Rm=0,xs=1,Yu=2,sr=3,ar=0,Ht=1,bi=2,Ti=0,ys=1,Lc=2,Dc=3,Nc=4,Zu=5,Im=6,or=100,Ju=101,Ku=102,$u=103,Qu=104,ed=200,td=201,id=202,nd=203,rd=204,sd=205,ad=206,od=207,ld=208,cd=209,hd=210,ud=211,dd=212,pd=213,md=214,Uc=0,Fc=1,Oc=2,ao=3,Bc=4,zc=5,Gc=6,Vc=7,fd=0,gd=1,_d=2,li=0,kc=1,Hc=2,Wc=3,Xc=4,jc=5,qc=6,Yc=7,Sl="attached",vd="detached",oo=300,nn=301,wn=302,lo=303,co=304,Ms=306,Or=1e3,ei=1001,Br=1002,Lt=1003,xd=1004,Pm=1004,Ss=1005,Lm=1005,at=1006,ho=1007,Dm=1007,zi=1008,Nm=1008,Jt=1009,Zc=1010,Jc=1011,lr=1012,uo=1013,Ei=1014,Dt=1015,Ai=1016,po=1017,mo=1018,cr=1020,Kc=35902,$c=35899,yd=1021,Md=1022,Vt=1023,rn=1026,Cn=1027,fo=1028,bs=1029,Rn=1030,Qc=1031,Um=1032,eh=1033,go=33776,_o=33777,vo=33778,xo=33779,th=35840,ih=35841,nh=35842,rh=35843,sh=36196,ah=37492,oh=37496,lh=37488,ch=37489,yo=37490,hh=37491,uh=37808,dh=37809,ph=37810,mh=37811,fh=37812,gh=37813,_h=37814,vh=37815,xh=37816,yh=37817,Mh=37818,Sh=37819,bh=37820,Th=37821,Eh=36492,Ah=36494,wh=36495,Ch=36283,Rh=36284,Mo=36285,Ih=36286,Fm=2200,Om=2201,Bm=2202,zr=2300,js=2301,ks=2302,bl=2303,mn=2400,fn=2401,Gr=2402,Sd=2500,Ph=2501,zm=0,Gm=1,Vm=2,km=3200,Hm=3201,Wm=3202,Xm=3203,Lh=0,bd=1,In="",Bt="srgb",Vr="srgb-linear",kr="linear",Ze="srgb",jm="",qm="rg",Ym="ga",Zm=0,pn=7680,Jm=7681,Km=7682,$m=7683,Qm=34055,ef=34056,tf=5386,nf=512,rf=513,sf=514,af=515,of=516,lf=517,cf=518,hf=519,Td=512,Ed=513,Ad=514,So=515,wd=516,Cd=517,bo=518,Rd=519,Hr=35044,uf=35048,df=35040,pf=35045,mf=35049,ff=35041,gf=35046,_f=35050,vf=35042,xf="100",Dh="300 es",xi=2e3,gn=2001,yf={COMPUTE:"compute",RENDER:"render"},Mf={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},Sf={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},bf={TEXTURE_COMPARE:"depthTextureCompare"},Ag={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ur(s,e){return new Ag[s](e)}function Tf(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Wr(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Id(){let s=Wr("canvas");return s.style.display="block",s}var gp={},_n=null;function Ef(s){_n=s}function Af(){return _n}function Xr(...s){let e="THREE."+s.shift();_n?_n("log",e,...s):console.log(e,...s)}function wf(s){let e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function re(...s){let e="THREE."+(s=wf(s)).shift();if(_n)_n("warn",e,...s);else{let t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ve(...s){let e="THREE."+(s=wf(s)).shift();if(_n)_n("error",e,...s);else{let t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function qs(...s){let e=s.join(" ");e in gp||(gp[e]=!0,re(...s))}function Cf(s,e,t){return new Promise(function(i,n){setTimeout(function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:n();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}},t)})}var Rf={[Uc]:1,[Oc]:6,[Bc]:7,[ao]:5,[Fc]:0,[Gc]:2,[Vc]:4,[zc]:3},Yt=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return i!==void 0&&i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){let i=this._listeners;if(i===void 0)return;let n=i[e];if(n!==void 0){let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let i=t[e.type];if(i!==void 0){e.target=this;let n=i.slice(0);for(let r=0,a=n.length;r>8&255]+Rt[s>>16&255]+Rt[s>>24&255]+"-"+Rt[255&e]+Rt[e>>8&255]+"-"+Rt[e>>16&15|64]+Rt[e>>24&255]+"-"+Rt[63&t|128]+Rt[t>>8&255]+"-"+Rt[t>>16&255]+Rt[t>>24&255]+Rt[255&i]+Rt[i>>8&255]+Rt[i>>16&255]+Rt[i>>24&255]).toLowerCase()}function Ce(s,e,t){return Math.max(e,Math.min(t,s))}function Du(s,e){return(s%e+e)%e}function Hs(s,e,t){return(1-t)*s+t*e}function zt(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 Oe(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(4294967295*s);case Uint16Array:return Math.round(65535*s);case Uint8Array:return Math.round(255*s);case Int32Array:return Math.round(2147483647*s);case Int16Array:return Math.round(32767*s);case Int8Array:return Math.round(127*s);default:throw new Error("Invalid component type.")}}var If={DEG2RAD:jn,RAD2DEG:qn,generateUUID:Qt,clamp:Ce,euclideanModulo:Du,mapLinear:function(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)},inverseLerp:function(s,e,t){return s!==e?(t-s)/(e-s):0},lerp:Hs,damp:function(s,e,t,i){return Hs(s,e,1-Math.exp(-t*i))},pingpong:function(s,e=1){return e-Math.abs(Du(s,2*e)-e)},smoothstep:function(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e))*s*(3-2*s)},smootherstep:function(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e))*s*s*(s*(6*s-15)+10)},randInt:function(s,e){return s+Math.floor(Math.random()*(e-s+1))},randFloat:function(s,e){return s+Math.random()*(e-s)},randFloatSpread:function(s){return s*(.5-Math.random())},seededRandom:function(s){s!==void 0&&(_p=s);let e=_p+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(s){return s*jn},radToDeg:function(s){return s*qn},isPowerOfTwo:function(s){return!(s&s-1)&&s!==0},ceilPowerOfTwo:function(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))},floorPowerOfTwo:function(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))},setQuaternionFromProperEuler:function(s,e,t,i,n){let r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+i)/2),h=a((e+i)/2),u=r((e-i)/2),d=a((e-i)/2),p=r((i-e)/2),f=a((i-e)/2);switch(n){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*f,c*p,o*l);break;case"YXY":s.set(c*p,o*h,c*f,o*l);break;case"ZYZ":s.set(c*f,c*p,o*h,o*l);break;default:re("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}},normalize:Oe,denormalize:zt},Q=class s{static{s.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ce(this.x,e.x,t.x),this.y=Ce(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ce(this.x,e,t),this.y=Ce(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Ce(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Ce(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*n+e.x,this.y=r*n+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Tt=class{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,r,a,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=r[a+0],p=r[a+1],f=r[a+2],m=r[a+3];if(u!==m||c!==d||l!==p||h!==f){let v=c*d+l*p+h*f+u*m;v<0&&(d=-d,p=-p,f=-f,m=-m,v=-v);let g=1-o;if(v<.9995){let _=Math.acos(v),x=Math.sin(_);g=Math.sin(g*_)/x,c=c*g+d*(o=Math.sin(o*_)/x),l=l*g+p*o,h=h*g+f*o,u=u*g+m*o}else{c=c*g+d*o,l=l*g+p*o,h=h*g+f*o,u=u*g+m*o;let _=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=_,l*=_,h*=_,u*=_}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,r,a){let o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=r[a],d=r[a+1],p=r[a+2],f=r[a+3];return e[t]=o*f+h*u+c*p-l*d,e[t+1]=c*f+h*d+l*u-o*p,e[t+2]=l*f+h*p+o*d-c*u,e[t+3]=h*f-o*u-c*d-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,n=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(r/2),d=c(i/2),p=c(n/2),f=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*p*f,this._y=l*p*u-d*h*f,this._z=l*h*f+d*p*u,this._w=l*h*u-d*p*f;break;case"YXZ":this._x=d*h*u+l*p*f,this._y=l*p*u-d*h*f,this._z=l*h*f-d*p*u,this._w=l*h*u+d*p*f;break;case"ZXY":this._x=d*h*u-l*p*f,this._y=l*p*u+d*h*f,this._z=l*h*f+d*p*u,this._w=l*h*u-d*p*f;break;case"ZYX":this._x=d*h*u-l*p*f,this._y=l*p*u+d*h*f,this._z=l*h*f-d*p*u,this._w=l*h*u+d*p*f;break;case"YZX":this._x=d*h*u+l*p*f,this._y=l*p*u+d*h*f,this._z=l*h*f-d*p*u,this._w=l*h*u-d*p*f;break;case"XZY":this._x=d*h*u-l*p*f,this._y=l*p*u-d*h*f,this._z=l*h*f+d*p*u,this._w=l*h*u+d*p*f;break;default:re("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],n=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=i+o+u;if(d>0){let p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(a-n)*p}else if(i>o&&i>u){let p=2*Math.sqrt(1+i-o-u);this._w=(h-c)/p,this._x=.25*p,this._y=(n+a)/p,this._z=(r+l)/p}else if(o>u){let p=2*Math.sqrt(1+o-i-u);this._w=(r-l)/p,this._x=(n+a)/p,this._y=.25*p,this._z=(c+h)/p}else{let p=2*Math.sqrt(1+u-i-o);this._w=(a-n)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ce(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let n=Math.min(1,t/i);return this.slerp(e,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,n=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=i*h+a*o+n*l-r*c,this._y=n*h+a*c+r*o-i*l,this._z=r*h+a*l+i*c-n*o,this._w=a*h-i*o-n*c-r*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){let l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},w=class s{static{s.prototype.isVector3=!0}constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(vp.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(vp.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,n=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*a,this}applyQuaternion(e){let t=this.x,i=this.y,n=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*n-o*i),h=2*(o*t-r*n),u=2*(r*i-a*t);return this.x=t+c*l+a*u-o*h,this.y=i+c*h+o*l-r*u,this.z=n+c*u+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ce(this.x,e.x,t.x),this.y=Ce(this.y,e.y,t.y),this.z=Ce(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ce(this.x,e,t),this.y=Ce(this.y,e,t),this.z=Ce(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Ce(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,n=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=n*c-r*o,this.y=r*a-i*c,this.z=i*o-n*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Yh.copy(this).projectOnVector(e),this.sub(Yh)}reflect(e){return this.sub(Yh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Ce(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=2*Math.random()-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Yh=new w,vp=new Tt,De=class s{static{s.prototype.isMatrix3=!0}constructor(e,t,i,n,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,a,o,c,l)}set(e,t,i,n,r,a,o,c,l){let h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,n=t.elements,r=this.elements,a=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],p=i[5],f=i[8],m=n[0],v=n[3],g=n[6],_=n[1],x=n[4],S=n[7],b=n[2],M=n[5],I=n[8];return r[0]=a*m+o*_+c*b,r[3]=a*v+o*x+c*M,r[6]=a*g+o*S+c*I,r[1]=l*m+h*_+u*b,r[4]=l*v+h*x+u*M,r[7]=l*g+h*S+u*I,r[2]=d*m+p*_+f*b,r[5]=d*v+p*x+f*M,r[8]=d*g+p*S+f*I,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-i*r*h+i*o*c+n*r*l-n*a*c}invert(){let e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,p=l*r-a*c,f=t*u+i*d+n*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(n*l-h*i)*m,e[2]=(o*i-n*a)*m,e[3]=d*m,e[4]=(h*t-n*c)*m,e[5]=(n*r-o*t)*m,e[6]=p*m,e[7]=(i*c-l*t)*m,e[8]=(a*t-i*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(i*c,i*l,-i*(c*a+l*o)+a+e,-n*l,n*c,-n*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Zh.makeScale(e,t)),this}rotate(e){return this.premultiply(Zh.makeRotation(-e)),this}translate(e,t){return this.premultiply(Zh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Zh=new De,xp=new De().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),yp=new De().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function wg(){let s={enabled:!0,workingColorSpace:Vr,spaces:{},convert:function(n,r,a){return this.enabled!==!1&&r!==a&&r&&a&&(this.spaces[r].transfer===Ze&&(n.r=Ji(n.r),n.g=Ji(n.g),n.b=Ji(n.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[r].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ze&&(n.r=Fr(n.r),n.g=Fr(n.g),n.b=Fr(n.b))),n},workingToColorSpace:function(n,r){return this.convert(n,this.workingColorSpace,r)},colorSpaceToWorking:function(n,r){return this.convert(n,r,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===""?kr:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,r=this.workingColorSpace){return n.fromArray(this.spaces[r].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,r,a){return n.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,r){return qs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(n,r)},toWorkingColorSpace:function(n,r){return qs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(n,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[Vr]:{primaries:e,whitePoint:i,transfer:kr,toXYZ:xp,fromXYZ:yp,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Bt},outputColorSpaceConfig:{drawingBufferColorSpace:Bt}},[Bt]:{primaries:e,whitePoint:i,transfer:Ze,toXYZ:xp,fromXYZ:yp,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Bt}}}),s}var Ge=wg();function Ji(s){return s<.04045?.0773993808*s:Math.pow(.9478672986*s+.0521327014,2.4)}function Fr(s){return s<.0031308?12.92*s:1.055*Math.pow(s,.41666)-.055}var gr,Ys=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{gr===void 0&&(gr=Wr("canvas")),gr.width=e.width,gr.height=e.height;let n=gr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=gr}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Wr("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let n=i.getImageData(0,0,e.width,e.height),r=n.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Kh).x}get height(){return this.source.getSize(Kh).y}get depth(){return this.source.getSize(Kh).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let i=e[t];if(i===void 0){re(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let n=this[t];n!==void 0?n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[t]=i:re(`Texture.setValues(): property '${t}' does not exist.`)}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==oo)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Or:e.x=e.x-Math.floor(e.x);break;case ei:e.x=e.x<0?0:1;break;case Br:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Or:e.y=e.y-Math.floor(e.y);break;case ei:e.y=e.y<0?0:1;break;case Br:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};ct.DEFAULT_IMAGE=null,ct.DEFAULT_MAPPING=oo,ct.DEFAULT_ANISOTROPY=1;var $e=class s{static{s.prototype.isVector4=!0}constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,n=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r,c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],p=c[5],f=c[9],m=c[2],v=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-m)<.01&&Math.abs(f-v)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+m)<.1&&Math.abs(f+v)<.1&&Math.abs(l+p+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let x=(l+1)/2,S=(p+1)/2,b=(g+1)/2,M=(h+d)/4,I=(u+m)/4,F=(f+v)/4;return x>S&&x>b?x<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(x),n=M/i,r=I/i):S>b?S<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(S),i=M/n,r=F/n):b<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(b),i=I/r,n=F/r),this.set(i,n,r,t),this}let _=Math.sqrt((v-f)*(v-f)+(u-m)*(u-m)+(d-h)*(d-h));return Math.abs(_)<.001&&(_=1),this.x=(v-f)/_,this.y=(u-m)/_,this.z=(d-h)/_,this.w=Math.acos((l+p+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ce(this.x,e.x,t.x),this.y=Ce(this.y,e.y,t.y),this.z=Ce(this.z,e.z,t.z),this.w=Ce(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ce(this.x,e,t),this.y=Ce(this.y,e,t),this.z=Ce(this.z,e,t),this.w=Ce(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Ce(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},jr=class extends Yt{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:at,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new $e(0,0,e,t),this.scissorTest=!1,this.viewport=new $e(0,0,e,t),this.textures=[];let n={width:e,height:t,depth:i.depth},r=new ct(n),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l0){n.children=[];for(let o=0;o0){n.animations=[];for(let o=0;o0&&(i.geometries=o),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),f.length>0&&(i.nodes=f)}return i.object=n,i;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;ip+f?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=p-f&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Fg)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Zi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Pf={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},on={h:0,s:0,l:0},Uo={h:0,s:0,l:0};function Qh(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+6*(e-s)*t:t<.5?e:t<2/3?s+6*(e-s)*(2/3-t):s}var ue=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Bt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Ge.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=Ge.workingColorSpace){return this.r=e,this.g=t,this.b=i,Ge.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=Ge.workingColorSpace){if(e=Du(e,1),t=Ce(t,0,1),i=Ce(i,0,1),t===0)this.r=this.g=this.b=i;else{let r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=Qh(a,r,e+1/3),this.g=Qh(a,r,e),this.b=Qh(a,r,e-1/3)}return Ge.colorSpaceToWorking(this,n),this}setStyle(e,t=Bt){function i(r){r!==void 0&&parseFloat(r)<1&&re("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:re("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=n[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);re("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Bt){let i=Pf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):re("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ji(e.r),this.g=Ji(e.g),this.b=Ji(e.b),this}copyLinearToSRGB(e){return this.r=Fr(e.r),this.g=Fr(e.g),this.b=Fr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Bt){return Ge.workingToColorSpace(It.copy(this),e),65536*Math.round(Ce(255*It.r,0,255))+256*Math.round(Ce(255*It.g,0,255))+Math.round(Ce(255*It.b,0,255))}getHexString(e=Bt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ge.workingColorSpace){Ge.workingToColorSpace(It.copy(this),t);let i=It.r,n=It.g,r=It.b,a=Math.max(i,n,r),o=Math.min(i,n,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case i:c=(n-r)/u+(n0&&(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}},pi=new w,Hi=new w,eu=new w,Wi=new w,yr=new w,Mr=new w,Cp=new w,tu=new w,iu=new w,nu=new w,ru=new $e,su=new $e,au=new $e,gi=class s{constructor(e=new w,t=new w,i=new w){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),pi.subVectors(e,t),n.cross(pi);let r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){pi.subVectors(n,t),Hi.subVectors(i,t),eu.subVectors(e,t);let a=pi.dot(pi),o=pi.dot(Hi),c=pi.dot(eu),l=Hi.dot(Hi),h=Hi.dot(eu),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,p=(l*c-o*h)*d,f=(a*h-o*c)*d;return r.set(1-p-f,f,p)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,Wi)!==null&&Wi.x>=0&&Wi.y>=0&&Wi.x+Wi.y<=1}static getInterpolation(e,t,i,n,r,a,o,c){return this.getBarycoord(e,t,i,n,Wi)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Wi.x),c.addScaledVector(a,Wi.y),c.addScaledVector(o,Wi.z),c)}static getInterpolatedAttribute(e,t,i,n,r,a){return ru.setScalar(0),su.setScalar(0),au.setScalar(0),ru.fromBufferAttribute(e,t),su.fromBufferAttribute(e,i),au.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(ru,r.x),a.addScaledVector(su,r.y),a.addScaledVector(au,r.z),a}static isFrontFacing(e,t,i,n){return pi.subVectors(i,t),Hi.subVectors(e,t),pi.cross(Hi).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return pi.subVectors(this.c,this.b),Hi.subVectors(this.a,this.b),.5*pi.cross(Hi).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return s.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return s.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,r){return s.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return s.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return s.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,n=this.b,r=this.c,a,o;yr.subVectors(n,i),Mr.subVectors(r,i),tu.subVectors(e,i);let c=yr.dot(tu),l=Mr.dot(tu);if(c<=0&&l<=0)return t.copy(i);iu.subVectors(e,n);let h=yr.dot(iu),u=Mr.dot(iu);if(h>=0&&u<=h)return t.copy(n);let d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(i).addScaledVector(yr,a);nu.subVectors(e,r);let p=yr.dot(nu),f=Mr.dot(nu);if(f>=0&&p<=f)return t.copy(r);let m=p*l-c*f;if(m<=0&&l>=0&&f<=0)return o=l/(l-f),t.copy(i).addScaledVector(Mr,o);let v=h*f-p*u;if(v<=0&&u-h>=0&&p-f>=0)return Cp.subVectors(r,n),o=(u-h)/(u-h+(p-f)),t.copy(n).addScaledVector(Cp,o);let g=1/(v+m+d);return a=m*g,o=d*g,t.copy(i).addScaledVector(yr,a).addScaledVector(Mr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},xt=class{constructor(e=new w(1/0,1/0,1/0),t=new w(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,mi),mi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Rs),Oo.subVectors(this.max,Rs),Sr.subVectors(e.a,Rs),br.subVectors(e.b,Rs),Tr.subVectors(e.c,Rs),ln.subVectors(br,Sr),cn.subVectors(Tr,br),Dn.subVectors(Sr,Tr);let t=[0,-ln.z,ln.y,0,-cn.z,cn.y,0,-Dn.z,Dn.y,ln.z,0,-ln.x,cn.z,0,-cn.x,Dn.z,0,-Dn.x,-ln.y,ln.x,0,-cn.y,cn.x,0,-Dn.y,Dn.x,0];return!!ou(t,Sr,br,Tr,Oo)&&(t=[1,0,0,0,1,0,0,0,1],!!ou(t,Sr,br,Tr,Oo)&&(Bo.crossVectors(ln,cn),t=[Bo.x,Bo.y,Bo.z],ou(t,Sr,br,Tr,Oo)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,mi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(mi).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Xi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Xi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Xi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Xi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Xi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Xi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Xi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Xi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Xi)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Xi=[new w,new w,new w,new w,new w,new w,new w,new w],mi=new w,Fo=new xt,Sr=new w,br=new w,Tr=new w,ln=new w,cn=new w,Dn=new w,Rs=new w,Oo=new w,Bo=new w,Nn=new w;function ou(s,e,t,i,n){for(let r=0,a=s.length-3;r<=a;r+=3){Nn.fromArray(s,r);let o=n.x*Math.abs(Nn.x)+n.y*Math.abs(Nn.y)+n.z*Math.abs(Nn.z),c=e.dot(Nn),l=t.dot(Nn),h=i.dot(Nn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var Yi=Og();function Og(){let s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),i=new Uint32Array(512),n=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(i[c]=0,i[256|c]=32768,n[c]=24,n[256|c]=24):l<-14?(i[c]=1024>>-l-14,i[256|c]=1024>>-l-14|32768,n[c]=-l-1,n[256|c]=-l-1):l<=15?(i[c]=l+15<<10,i[256|c]=l+15<<10|32768,n[c]=13,n[256|c]=13):l<128?(i[c]=31744,i[256|c]=64512,n[c]=24,n[256|c]=24):(i[c]=31744,i[256|c]=64512,n[c]=13,n[256|c]=13)}let r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;!(8388608&l);)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:r,exponentTable:a,offsetTable:o}}function jt(s){Math.abs(s)>65504&&re("DataUtils.toHalfFloat(): Value out of range."),s=Ce(s,-65504,65504),Yi.floatView[0]=s;let e=Yi.uint32View[0],t=e>>23&511;return Yi.baseTable[t]+((8388607&e)>>Yi.shiftTable[t])}function Gs(s){let e=s>>10;return Yi.uint32View[0]=Yi.mantissaTable[Yi.offsetTable[e]+(1023&s)]+Yi.exponentTable[e],Yi.floatView[0]}var Al=class{static toHalfFloat(e){return jt(e)}static fromHalfFloat(e){return Gs(e)}},mt=new w,zo=new Q,Bg=0,Je=class extends Yt{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Bg++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Hr,this.updateRanges=[],this.gpuType=Dt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;nthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Is.subVectors(e,this.center);let t=Is.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),n=.5*(i-this.radius);this.center.addScaledVector(Is,n/i),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(lu.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Is.copy(e.center).add(lu)),this.expandByPoint(Is.copy(e.center).sub(lu))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Gg=0,ri=new Re,cu=new Ye,Er=new w,$t=new xt,Ps=new xt,bt=new w,Ue=class s extends Yt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Gg++}),this.uuid=Qt(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new((function(t){for(let i=t.length-1;i>=0;--i)if(t[i]>=65535)return!0;return!1})(e)?Yr:qr)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let r=new De().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}let n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return ri.makeRotationFromQuaternion(e),this.applyMatrix4(ri),this}rotateX(e){return ri.makeRotationX(e),this.applyMatrix4(ri),this}rotateY(e){return ri.makeRotationY(e),this.applyMatrix4(ri),this}rotateZ(e){return ri.makeRotationZ(e),this.applyMatrix4(ri),this}translate(e,t,i){return ri.makeTranslation(e,t,i),this.applyMatrix4(ri),this}scale(e,t,i){return ri.makeScale(e,t,i),this.applyMatrix4(ri),this}lookAt(e){return cu.lookAt(e),cu.updateMatrix(),this.applyMatrix4(cu.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Er).negate(),this.translate(Er.x,Er.y,Er.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let i=[];for(let n=0,r=e.length;nt.count&&re("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return ve("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new w(-1/0,-1/0,-1/0),new w(1/0,1/0,1/0));if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let c in i){let l=i[c];e.data.attributes[c]=l.toJSON(e.data)}let n={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u0&&(n[c]=h,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone());let n=e.attributes;for(let l in n){let h=n[l];this.setAttribute(l,h.clone(t))}let r=e.morphAttributes;for(let l in r){let h=[],u=r[l];for(let d=0,p=u.length;d0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){re(`Material: parameter '${t}' has value of undefined.`);continue}let n=this[t];n!==void 0?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i:re(`Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function n(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(i.blending=this.blending),this.side!==0&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==204&&(i.blendSrc=this.blendSrc),this.blendDst!==205&&(i.blendDst=this.blendDst),this.blendEquation!==100&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==pn&&(i.stencilFail=this.stencilFail),this.stencilZFail!==pn&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==pn&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),t){let r=n(e.textures),a=n(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let n=t.length;i=new Array(n);for(let r=0;r!==n;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Zr=class extends yt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ue(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ls=new w,wr=new w,Cr=new w,Rr=new Q,Ds=new Q,Lf=new Re,Go=new w,Ns=new w,Vo=new w,Rp=new Q,hu=new Q,Ip=new Q,$s=class extends Ye{constructor(e=new Zr){if(super(),this.isSprite=!0,this.type="Sprite",Ar===void 0){Ar=new Ue;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new $n(t,5);Ar.setIndex([0,1,2,0,2,3]),Ar.setAttribute("position",new vn(i,3,0,!1)),Ar.setAttribute("uv",new vn(i,2,3,!1))}this.geometry=Ar,this.material=e,this.center=new Q(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ve('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),wr.setFromMatrixScale(this.matrixWorld),Lf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Cr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&wr.multiplyScalar(-Cr.z);let i=this.material.rotation,n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));let a=this.center;ko(Go.set(-.5,-.5,0),Cr,a,wr,n,r),ko(Ns.set(.5,-.5,0),Cr,a,wr,n,r),ko(Vo.set(.5,.5,0),Cr,a,wr,n,r),Rp.set(0,0),hu.set(1,0),Ip.set(1,1);let o=e.ray.intersectTriangle(Go,Ns,Vo,!1,Ls);if(o===null&&(ko(Ns.set(-.5,.5,0),Cr,a,wr,n,r),hu.set(0,1),o=e.ray.intersectTriangle(Go,Vo,Ns,!1,Ls),o===null))return;let c=e.ray.origin.distanceTo(Ls);ce.far||t.push({distance:c,point:Ls.clone(),uv:gi.getInterpolation(Ls,Go,Ns,Vo,Rp,hu,Ip,new Q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function ko(s,e,t,i,n,r){Rr.subVectors(s,t).addScalar(.5).multiply(i),n!==void 0?(Ds.x=r*Rr.x-n*Rr.y,Ds.y=n*Rr.x+r*Rr.y):Ds.copy(Rr),s.copy(e),s.x+=Ds.x,s.y+=Ds.y,s.applyMatrix4(Lf)}var Ho=new w,Pp=new w,Qs=class extends Ye{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let i=0,n=t.length;i0){let i,n;for(i=1,n=t.length;i0){Ho.setFromMatrixPosition(this.matrixWorld);let i=e.ray.origin.distanceTo(Ho);this.getObjectForDistance(i).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Ho.setFromMatrixPosition(e.matrixWorld),Pp.setFromMatrixPosition(this.matrixWorld);let i=Ho.distanceTo(Pp)/e.zoom,n,r;for(t[0].object.visible=!0,n=1,r=t.length;n=a))break;t[n-1].object.visible=!1,t[n].object.visible=!0}for(this._currentLevel=n-1;n0)if(u=a*c-o,d=a*o-c,f=r*h,u>=0)if(d>=-f)if(d<=f){let m=1/h;u*=m,d*=m,p=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;else d<=-f?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l):d<=f?(u=0,d=Math.min(Math.max(-r,-c),r),p=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(uu).addScaledVector(Wo,d),p}intersectSphere(e,t){ji.subVectors(e.center,this.origin);let i=ji.dot(this.direction),n=ji.dot(ji)-i*i,r=e.radius*e.radius;if(n>r)return null;let a=Math.sqrt(r-n),o=i-a,c=i+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0?!0:e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(e.min.x-d.x)*l,n=(e.max.x-d.x)*l):(i=(e.max.x-d.x)*l,n=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||r>n?null:((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),i>c||o>n?null:((o>i||i!=i)&&(i=o),(c=0?i:n,t)))}intersectsBox(e){return this.intersectBox(e,ji)!==null}intersectTriangle(e,t,i,n,r){du.subVectors(t,e),Xo.subVectors(i,e),pu.crossVectors(du,Xo);let a,o=this.direction.dot(pu);if(o>0){if(n)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}hn.subVectors(this.origin,e);let c=a*this.direction.dot(Xo.crossVectors(hn,Xo));if(c<0)return null;let l=a*this.direction.dot(du.cross(hn));if(l<0||c+l>o)return null;let h=-a*hn.dot(pu);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},yi=class extends yt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ue(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 ai,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Lp=new Re,Un=new Ki,jo=new gt,Dp=new w,qo=new w,Yo=new w,Zo=new w,mu=new w,Jo=new w,Np=new w,Ko=new w,ot=class extends Ye{constructor(e=new Ue,t=new yi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=i.length;n(e.far-e.near)**2))return;Lp.copy(r).invert(),Un.copy(e.ray).applyMatrix4(Lp),i.boundingBox!==null&&Un.intersectsBox(i.boundingBox)===!1||this._computeIntersections(e,t,Un)}}_computeIntersections(e,t,i){let n,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let f=0,m=d.length;fp.far?null:{distance:S,point:Ko.clone(),object:u}})(s,e,t,i,qo,Yo,Zo,Np);if(h){let u=new w;gi.getBarycoord(Np,qo,Yo,Zo,u),n&&(h.uv=gi.getInterpolatedAttribute(n,o,c,l,u,new Q)),r&&(h.uv1=gi.getInterpolatedAttribute(r,o,c,l,u,new Q)),a&&(h.normal=gi.getInterpolatedAttribute(a,o,c,l,u,new w),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:c,c:l,normal:new w,materialIndex:0};gi.getNormal(qo,Yo,Zo,d.normal),h.face=d,h.barycoord=u}return h}var Us=new $e,Up=new $e,Fp=new $e,kg=new $e,Op=new Re,Qo=new w,fu=new gt,Bp=new Re,gu=new Ki,ea=class extends ot{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Sl,this.bindMatrix=new Re,this.bindMatrixInverse=new Re,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new xt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i1)?null:t.copy(e.start).addScaledVector(n,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||jg.getNormalMatrix(e),n=this.coplanarPoint(_u).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Fn=new gt,qg=new Q(.5,.5),tl=new w,Qi=class{constructor(e=new fi,t=new fi,i=new fi,n=new fi,r=new fi,a=new fi){this.planes=[e,t,i,n,r,a]}set(e,t,i,n,r,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(a),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=2e3,i=!1){let n=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],p=r[7],f=r[8],m=r[9],v=r[10],g=r[11],_=r[12],x=r[13],S=r[14],b=r[15];if(n[0].setComponents(l-a,p-h,g-f,b-_).normalize(),n[1].setComponents(l+a,p+h,g+f,b+_).normalize(),n[2].setComponents(l+o,p+u,g+m,b+x).normalize(),n[3].setComponents(l-o,p-u,g-m,b-x).normalize(),i)n[4].setComponents(c,d,v,S).normalize(),n[5].setComponents(l-c,p-d,g-v,b-S).normalize();else if(n[4].setComponents(l-c,p-d,g-v,b-S).normalize(),t===xi)n[5].setComponents(l+c,p+d,g+v,b+S).normalize();else{if(t!==gn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(c,d,v,S).normalize()}return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Fn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Fn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Fn)}intersectsSprite(e){Fn.center.set(0,0,0);let t=qg.distanceTo(e.center);return Fn.radius=.7071067811865476+t,Fn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Fn)}intersectsSphere(e){let t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,tl.y=n.normal.y>0?e.max.y:e.min.y,tl.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(tl)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Li=new Re,Di=new Qi,na=class s{constructor(){this.coordinateSystem=xi}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let o=r[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=i,o.index=n}reset(){this.list.length=0,this.index=0}},Xt=new Re,Jg=new ue(1,1,1),kp=new Qi,Kg=new na,il=new xt,On=new gt,Bs=new w,Hp=new w,$g=new w,xu=new Nu,Pt=new ot,nl=[];function Qg(s,e,t=0){let i=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){let n=s.count;for(let r=0;r65535?new Uint32Array(n):new Uint16Array(n);t.setIndex(new Je(r,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let n=e.getAttribute(i),r=t.getAttribute(i);if(n.itemSize!==r.itemSize||n.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xt);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,n=t.length;i=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");let t={visible:!0,active:!0,geometryIndex:e},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(vu),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=t):(i=this._instanceInfo.length,this._instanceInfo.push(t));let n=this._matricesTexture;Xt.identity().toArray(n.image.data,16*i),n.needsUpdate=!0;let r=this._colorsTexture;return r&&(Jg.toArray(r.image.data,4*i),r.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);let n={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;n.vertexStart=this._nextVertexStart,n.reservedVertexCount=t===-1?e.getAttribute("position").count:t;let a=e.getIndex();if(a!==null&&(n.indexStart=this._nextIndexStart,n.reservedIndexCount=i===-1?a.count:i),n.indexStart!==-1&&n.indexStart+n.reservedIndexCount>this._maxIndexCount||n.vertexStart+n.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(vu),o=this._availableGeometryIds.shift(),r[o]=n):(o=this._geometryCount,this._geometryCount++,r.push(n)),this.setGeometryAt(o,e),this._nextIndexStart=n.indexStart+n.reservedIndexCount,this._nextVertexStart=n.vertexStart+n.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,n=i.getIndex()!==null,r=i.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(n&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let c=o.vertexStart,l=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(let h in i.attributes){let u=t.getAttribute(h),d=i.getAttribute(h);Qg(u,d,c);let p=u.itemSize;for(let f=u.count,m=l;f=t.length||t[e].active===!1)return this;let i=this._instanceInfo;for(let n=0,r=i.length;no).sort((a,o)=>i[a].vertexStart-i[o].vertexStart),r=this.geometry;for(let a=0,o=i.length;a=this._geometryCount)return null;let i=this.geometry,n=this._geometryInfo[e];if(n.boundingBox===null){let r=new xt,a=i.index,o=i.attributes.position;for(let c=n.start,l=n.start+n.count;c=this._geometryCount)return null;let i=this.geometry,n=this._geometryInfo[e];if(n.boundingSphere===null){let r=new gt;this.getBoundingBoxAt(e,il),il.getCenter(r.center);let a=i.index,o=i.attributes.position,c=0;for(let l=n.start,h=n.start+n.count;la.active);if(Math.max(...i.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(a=>a.indexStart+a.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let n=this.geometry;n.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Ue,this._initializeGeometry(n));let r=this.geometry;n.index&&Bn(n.index.array,r.index.array);for(let a in n.attributes)Bn(n.attributes[a].array,r.attributes[a].array)}raycast(e,t){let i=this._instanceInfo,n=this._geometryInfo,r=this.matrixWorld,a=this.geometry;Pt.material=this.material,Pt.geometry.index=a.index,Pt.geometry.attributes=a.attributes,Pt.geometry.boundingBox===null&&(Pt.geometry.boundingBox=new xt),Pt.geometry.boundingSphere===null&&(Pt.geometry.boundingSphere=new gt);for(let o=0,c=i.length;o({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,n,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=n.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,c=1;r.wireframe&&(c=2,o=n.attributes.position.count>65535?4:2);let l=this._instanceInfo,h=this._multiDrawStarts,u=this._multiDrawCounts,d=this._geometryInfo,p=this.perObjectFrustumCulled,f=this._indirectTexture,m=f.image.data,v=i.isArrayCamera?Kg:kp;p&&!i.isArrayCamera&&(Xt.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),kp.setFromProjectionMatrix(Xt,i.coordinateSystem,i.reversedDepth));let g=0;if(this.sortObjects){Xt.copy(this.matrixWorld).invert(),Bs.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Xt),Hp.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Xt);for(let S=0,b=l.length;S0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=i.length;ni)return;yu.applyMatrix4(s.matrixWorld);let c=e.ray.origin.distanceTo(yu);return ce.far?void 0:{distance:c,point:Xp.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}var jp=new w,qp=new w,ti=class extends Mi{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let n=0,r=t.count;n0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=i.length;nn.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}var oa=class extends ct{constructor(e,t,i,n,r=1006,a=1006,o,c,l){super(e,t,i,n,r,a,o,c,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let h=this;"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(function u(){h.needsUpdate=!0,h._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}},Ul=class extends oa{constructor(e,t,i,n,r,a,o,c){super({},e,t,i,n,r,a,o,c),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},Fl=class extends ct{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Lt,this.minFilter=Lt,this.generateMipmaps=!1,this.needsUpdate=!0}},Qn=class extends ct{constructor(e,t,i,n,r,a,o,c,l,h,u,d){super(null,a,o,c,l,h,n,r,u,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},Ol=class extends Qn{constructor(e,t,i,n,r,a){super(e,t,i,r,a),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=ei,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Bl=class extends Qn{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,nn),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},xn=class extends ct{constructor(e=[],t=301,i,n,r,a,o,c,l,h){super(e,t,i,n,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},zl=class extends ct{constructor(e,t,i,n,r,a,o,c,l){super(e,t,i,n,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Gl=class extends ct{constructor(e,t,i,n,r,a,o,c,l){super(e,t,i,n,r,a,o,c,l),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;let h=e?e.parentNode:null;h!==null&&"requestPaint"in h&&(h.onpaint=()=>{this.needsUpdate=!0},h.requestPaint())}dispose(){let e=this.image?this.image.parentNode:null;e!==null&&"onpaint"in e&&(e.onpaint=null),super.dispose()}},Bi=class extends ct{constructor(e,t,i=1014,n,r,a,o=1003,c=1003,l,h=1026,u=1){if(h!==rn&&h!==1027)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:u},n,r,a,o,c,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new _i(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},la=class extends Bi{constructor(e,t=1014,i=301,n,r,a=1003,o=1003,c,l=1026){let h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,i,n,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},$r=class extends ct{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},yn=class s extends Ue{constructor(e=1,t=1,i=1,n=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:a};let o=this;n=Math.floor(n),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],u=[],d=0,p=0;function f(m,v,g,_,x,S,b,M,I,F,P){let L=S/I,H=b/F,O=S/2,j=b/2,G=M/2,z=I+1,q=F+1,X=0,le=0,me=new w;for(let Ae=0;Ae0?1:-1,h.push(me.x,me.y,me.z),u.push(Se/I),u.push(1-Ae/F),X+=1}}for(let Ae=0;Ae0){let P=(_-1)*m;for(let L=0;L0||F!==0)&&(h.push(P,L,O),b+=3),(t>0||F!==r-1)&&(h.push(L,H,O),b+=3)}l.addGroup(g,b,0),g+=b})(),a===!1&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new pe(u,3)),this.setAttribute("normal",new pe(d,3)),this.setAttribute("uv",new pe(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new s(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},es=class s extends Qr{constructor(e=1,t=1,i=32,n=1,r=!1,a=0,o=2*Math.PI){super(0,e,t,i,n,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new s(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},en=class s extends Ue{constructor(e=[],t=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};let r=[],a=[];function o(p,f,m,v){let g=v+1,_=[];for(let x=0;x<=g;x++){_[x]=[];let S=p.clone().lerp(m,x/g),b=f.clone().lerp(m,x/g),M=g-x;for(let I=0;I<=M;I++)_[x][I]=I===0&&x===g?S:S.clone().lerp(b,I/M)}for(let x=0;x.9&&x<.1&&(m<.2&&(a[f+0]+=1),v<.2&&(a[f+2]+=1),g<.2&&(a[f+4]+=1))}})()})(),this.setAttribute("position",new pe(r,3)),this.setAttribute("normal",new pe(r.slice(),3)),this.setAttribute("uv",new pe(a,2)),n===0?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new s(e.vertices,e.indices,e.radius,e.detail)}},ua=class s extends en{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,n=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new s(e.radius,e.detail)}},ll=new w,cl=new w,Mu=new w,hl=new gi,da=class extends Ue{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=Math.pow(10,4),r=Math.cos(jn*t),a=e.getIndex(),o=e.getAttribute("position"),c=a?a.count:o.count,l=[0,0,0],h=["a","b","c"],u=new Array(3),d={},p=[];for(let f=0;f0)){l=n;break}l=n-1}if(n=l,i[n]===a)return n/(r-1);let h=i[n];return(n+(a-h)/(i[n+1]-h))/(r-1)}getTangent(e,t){let n=e-1e-4,r=e+1e-4;n<0&&(n=0),r>1&&(r=1);let a=this.getPoint(n),o=this.getPoint(r),c=t||(a.isVector2?new Q:new w);return c.copy(o).sub(a).normalize(),c}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){let i=new w,n=[],r=[],a=[],o=new w,c=new Re;for(let p=0;p<=e;p++){let f=p/e;n[p]=this.getTangentAt(f,new w)}r[0]=new w,a[0]=new w;let l=Number.MAX_VALUE,h=Math.abs(n[0].x),u=Math.abs(n[0].y),d=Math.abs(n[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),d<=l&&i.set(0,0,1),o.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],o),a[0].crossVectors(n[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(n[p-1],n[p]),o.length()>Number.EPSILON){o.normalize();let f=Math.acos(Ce(n[p-1].dot(n[p]),-1,1));r[p].applyMatrix4(c.makeRotationAxis(o,f))}a[p].crossVectors(n[p],r[p])}if(t===!0){let p=Math.acos(Ce(r[0].dot(r[e]),-1,1));p/=e,n[0].dot(o.crossVectors(r[0],r[e]))>0&&(p=-p);for(let f=1;f<=e;f++)r[f].applyMatrix4(c.makeRotationAxis(n[f],p*f)),a[f].crossVectors(n[f],r[f])}return{tangents:n,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},er=class extends Zt{constructor(e=0,t=0,i=1,n=1,r=0,a=2*Math.PI,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=c}getPoint(e,t=new Q){let i=t,n=2*Math.PI,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)n;)r-=n;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:h===0&&l===r-1&&(l=r-2,h=1),this.closed||l>0?o=n[(l-1)%r]:(Kp.subVectors(n[0],n[1]).add(n[0]),o=Kp);let u=n[l%r],d=n[(l+1)%r];if(this.closed||l+2n.length-2?n.length-1:a+1],u=n[a>n.length-3?n.length-1:a+2];return i.set($p(o,c.x,l.x,h.x,u.x),$p(o,c.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){let a=n[r]-i,o=this.curves[r],c=o.getLength(),l=c===0?0:1-a/c;return o.getPointAt(l,t)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,n=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Oi=class extends tr{constructor(e){super(e),this.uuid=Qt(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,n=this.holes.length;i80*t){o=s[0],c=s[1];let h=o,u=c;for(let d=t;dh&&(h=p),f>u&&(u=f)}l=Math.max(h-o,u-c),l=l!==0?32767/l:0}return va(r,a,t,o,c,l,0),a}function Qp(s,e,t,i,n){let r;if(n===(function(a,o,c,l){let h=0;for(let u=o,d=c-l;u0)for(let a=e;a=e;a-=i)r=em(a/i|0,s[a],s[a+1],r);return r&&as(r,r.next)&&(ya(r),r=r.next),r}function ir(s,e){if(!s)return s;e||(e=s);let t,i=s;do if(t=!1,i.steiner||!as(i,i.next)&&st(i.prev,i,i.next)!==0)i=i.next;else{if(ya(i),i=e=i.prev,i===i.next)break;t=!0}while(t||i!==e);return e}function va(s,e,t,i,n,r,a){if(!s)return;!a&&r&&(function(c,l,h,u){let d=c;do d.z===0&&(d.z=Fu(d.x,d.y,l,h,u)),d.prevZ=d.prev,d.nextZ=d.next,d=d.next;while(d!==c);d.prevZ.nextZ=null,d.prevZ=null,(function(p){let f,m=1;do{let v,g=p;p=null;let _=null;for(f=0;g;){f++;let x=g,S=0;for(let M=0;M0||b>0&&x;)S!==0&&(b===0||!x||g.z<=x.z)?(v=g,g=g.nextZ,S--):(v=x,x=x.nextZ,b--),_?_.nextZ=v:p=v,v.prevZ=_,_=v;g=x}_.nextZ=null,m*=2}while(f>1)})(d)})(s,i,n,r);let o=s;for(;s.prev!==s.next;){let c=s.prev,l=s.next;if(r?i0(s,i,n,r):t0(s))e.push(c.i,s.i,l.i),ya(s),s=l.next,o=l.next;else if((s=l)===o){a?a===1?va(s=n0(ir(s),e),e,t,i,n,r,2):a===2&&r0(s,e,t,i,n,r):va(ir(s),e,t,i,n,r,1);break}}}function t0(s){let e=s.prev,t=s,i=s.next;if(st(e,t,i)>=0)return!1;let n=e.x,r=t.x,a=i.x,o=e.y,c=t.y,l=i.y,h=Math.min(n,r,a),u=Math.min(o,c,l),d=Math.max(n,r,a),p=Math.max(o,c,l),f=i.next;for(;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&Vs(n,o,r,c,a,l,f.x,f.y)&&st(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function i0(s,e,t,i){let n=s.prev,r=s,a=s.next;if(st(n,r,a)>=0)return!1;let o=n.x,c=r.x,l=a.x,h=n.y,u=r.y,d=a.y,p=Math.min(o,c,l),f=Math.min(h,u,d),m=Math.max(o,c,l),v=Math.max(h,u,d),g=Fu(p,f,e,t,i),_=Fu(m,v,e,t,i),x=s.prevZ,S=s.nextZ;for(;x&&x.z>=g&&S&&S.z<=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=v&&x!==n&&x!==a&&Vs(o,h,c,u,l,d,x.x,x.y)&&st(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=p&&S.x<=m&&S.y>=f&&S.y<=v&&S!==n&&S!==a&&Vs(o,h,c,u,l,d,S.x,S.y)&&st(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=v&&x!==n&&x!==a&&Vs(o,h,c,u,l,d,x.x,x.y)&&st(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=_;){if(S.x>=p&&S.x<=m&&S.y>=f&&S.y<=v&&S!==n&&S!==a&&Vs(o,h,c,u,l,d,S.x,S.y)&&st(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function n0(s,e){let t=s;do{let i=t.prev,n=t.next.next;!as(i,n)&&Nf(i,t,t.next,n)&&xa(i,n)&&xa(n,i)&&(e.push(i.i,t.i,n.i),ya(t),ya(t.next),t=s=n),t=t.next}while(t!==s);return ir(t)}function r0(s,e,t,i,n,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&c0(a,o)){let c=Uf(a,o);return a=ir(a,a.next),c=ir(c,c.next),va(a,e,t,i,n,r,0),void va(c,e,t,i,n,r,0)}o=o.next}a=a.next}while(a!==s)}function s0(s,e){let t=s.x-e.x;return t===0&&(t=s.y-e.y,t===0)&&(t=(s.next.y-s.y)/(s.next.x-s.x)-(e.next.y-e.y)/(e.next.x-e.x)),t}function a0(s,e){let t=(function(n,r){let a=r,o=n.x,c=n.y,l,h=-1/0;if(as(n,a))return a;do{if(as(n,a.next))return a.next;if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){let m=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(m<=o&&m>h&&(h=m,l=a.x=a.x&&a.x>=d&&o!==a.x&&Df(cl.x||a.x===l.x&&o0(l,a)))&&(l=a,f=m)}a=a.next}while(a!==u);return l})(s,e);if(!t)return e;let i=Uf(t,s);return ir(i,i.next),ir(t,t.next)}function o0(s,e){return st(s.prev,s,e.prev)<0&&st(e.next,s,s.next)<0}function Fu(s,e,t,i,n){return(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-t)*n|0)|s<<8))|s<<4))|s<<2))|s<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function l0(s){let e=s,t=s;do(e.x=(s-a)*(r-o)&&(s-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(n-a)*(i-o)}function Vs(s,e,t,i,n,r,a,o){return!(s===a&&e===o)&&Df(s,e,t,i,n,r,a,o)}function c0(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!(function(t,i){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==i.i&&n.next.i!==i.i&&Nf(n,n.next,t,i))return!0;n=n.next}while(n!==t);return!1})(s,e)&&(xa(s,e)&&xa(e,s)&&(function(t,i){let n=t,r=!1,a=(t.x+i.x)/2,o=(t.y+i.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&a<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==t);return r})(s,e)&&(st(s.prev,s,e.prev)||st(s,e.prev,e))||as(s,e)&&st(s.prev,s,s.next)>0&&st(e.prev,e,e.next)>0)}function st(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function as(s,e){return s.x===e.x&&s.y===e.y}function Nf(s,e,t,i){let n=dl(st(s,e,t)),r=dl(st(s,e,i)),a=dl(st(t,i,s)),o=dl(st(t,i,e));return n!==r&&a!==o||!(n!==0||!ul(s,t,e))||!(r!==0||!ul(s,i,e))||!(a!==0||!ul(t,s,i))||!(o!==0||!ul(t,e,i))}function ul(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 dl(s){return s>0?1:s<0?-1:0}function xa(s,e){return st(s.prev,s,s.next)<0?st(s,e,s.next)>=0&&st(s,s.prev,e)>=0:st(s,e,s.prev)<0||st(s,s.next,e)<0}function Uf(s,e){let t=Ou(s.i,s.x,s.y),i=Ou(e.i,e.x,e.y),n=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=n,n.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function em(s,e,t,i){let n=Ou(s,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function ya(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Ou(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}var Bu=class{static triangulate(e,t,i=2){return e0(e,t,i)}},si=class s{static area(e){let t=e.length,i=0;for(let n=t-1,r=0;r2&&s[e-1].equals(s[0])&&s.pop()}function im(s,e){for(let t=0;tNumber.EPSILON){let _e=Math.sqrt(fe),he=Math.sqrt(K*K+ee*ee),ge=U.x-W/_e,ae=U.y+k/_e,Te=((y.x-ee/he-ge)*ee-(y.y+K/he-ae)*K)/(k*ee-W*K);D=ge+k*Te-C.x,N=ae+W*Te-C.y;let ke=D*D+N*N;if(ke<=2)return new Q(D,N);A=Math.sqrt(ke/2)}else{let _e=!1;k>Number.EPSILON?K>Number.EPSILON&&(_e=!0):k<-Number.EPSILON?K<-Number.EPSILON&&(_e=!0):Math.sign(W)===Math.sign(ee)&&(_e=!0),_e?(D=-W,N=k,A=Math.sqrt(fe)):(D=k,N=W,A=Math.sqrt(fe/2))}return new Q(D/A,N/A)}let le=[];for(let C=0,U=G.length,y=U-1,D=C+1;C=0;C--){let U=C/v,y=p*Math.cos(U*Math.PI/2),D=f*Math.sin(U*Math.PI/2)+m;for(let N=0,A=G.length;N=0;){let D=y,N=y-1;N<0&&(N=C.length-1);for(let A=0,k=h+2*v;A0)&&p.push(x,S,M),(g!==i-1||c0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},cs=class extends kt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},hs=class extends yt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ue(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 ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(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 ai,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}},La=class extends hs{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 Q(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ce(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ue(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 ue(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ue(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Da=class extends yt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ue(16777215),this.specular=new ue(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ai,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Na=class extends yt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ue(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ua=class extends yt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(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}},Fa=class extends yt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ai,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},us=class extends yt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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}},ds=class extends yt{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}},Oa=class extends yt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ue(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}},Ba=class extends Et{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function Xn(s,e){return s&&s.constructor!==e?typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s):s}function Ff(s){let e=s.length,t=new Array(e);for(let i=0;i!==e;++i)t[i]=i;return t.sort(function(i,n){return s[i]-s[n]}),t}function zu(s,e,t){let i=s.length,n=new s.constructor(i);for(let r=0,a=0;a!==i;++r){let o=t[r]*e;for(let c=0;c!==e;++c)n[a++]=s[o+c]}return n}function Nd(s,e,t,i){let n=1,r=s[0];for(;r!==void 0&&r[i]===void 0;)r=s[n++];if(r===void 0)return;let a=r[i];if(a!==void 0)if(Array.isArray(a))do a=r[i],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[n++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[i],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[n++];while(r!==void 0);else do a=r[i],a!==void 0&&(e.push(r.time),t.push(a)),r=s[n++];while(r!==void 0)}var kl=class{static convertArray(e,t){return Xn(e,t)}static isTypedArray(e){return Tf(e)}static getKeyframeOrder(e){return Ff(e)}static sortedArray(e,t,i){return zu(e,t,i)}static flattenJSON(e,t,i,n){Nd(e,t,i,n)}static subclip(e,t,i,n,r=30){return(function(a,o,c,l,h=30){let u=a.clone();u.name=o;let d=[];for(let f=0;f=l)){g.push(m.times[x]);for(let b=0;bu.tracks[f].times[0]&&(p=u.tracks[f].times[0]);for(let f=0;f=d.times[x]){let M=x*v+m,I=M+v-m;S=d.values.slice(M,I)}else{let M=d.createInterpolant(),I=m,F=v-m;M.evaluate(h),S=M.resultBuffer.slice(I,F)}p==="quaternion"&&new Tt().fromArray(S).normalize().conjugate().toArray(S);let b=f.times.length;for(let M=0;M=r)){let o=t[1];e=r)break t}a=i,i=0;break i}break e}for(;i>>1;et;)--a;if(++a,r!==0||a!==n){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=i.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(ve("KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,n=this.values,r=i.length;r===0&&(ve("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){let c=i[o];if(typeof c=="number"&&isNaN(c)){ve("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){ve("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(n!==void 0&&Tf(n))for(let o=0,c=n.length;o!==c;++o){let l=n[o];if(isNaN(l)){ve("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===ks,r=e.length-1,a=1;for(let o=1;o0){e[a]=e[r];for(let o=r*i,c=a*i,l=0;l!==i;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Gt.prototype.ValueTypeName="",Gt.prototype.TimeBufferType=Float32Array,Gt.prototype.ValueBufferType=Float32Array,Gt.prototype.DefaultInterpolation=js;var Ui=class extends Gt{constructor(e,t,i){super(e,t,i)}};Ui.prototype.ValueTypeName="bool",Ui.prototype.ValueBufferType=Array,Ui.prototype.DefaultInterpolation=zr,Ui.prototype.InterpolantFactoryMethodLinear=void 0,Ui.prototype.InterpolantFactoryMethodSmooth=void 0;var ms=class extends Gt{constructor(e,t,i,n){super(e,t,i,n)}};ms.prototype.ValueTypeName="color";var Mn=class extends Gt{constructor(e,t,i,n){super(e,t,i,n)}};Mn.prototype.ValueTypeName="number";var ka=class extends tn{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(i-t)/(n-t),l=e*o;for(let h=l+o;l!==h;l+=4)Tt.slerpFlat(r,0,a,l-o,a,l,c);return r}},Sn=class extends Gt{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new ka(this.times,this.values,this.getValueSize(),e)}};Sn.prototype.ValueTypeName="quaternion",Sn.prototype.InterpolantFactoryMethodSmooth=void 0;var Fi=class extends Gt{constructor(e,t,i){super(e,t,i)}};Fi.prototype.ValueTypeName="string",Fi.prototype.ValueBufferType=Array,Fi.prototype.DefaultInterpolation=zr,Fi.prototype.InterpolantFactoryMethodLinear=void 0,Fi.prototype.InterpolantFactoryMethodSmooth=void 0;var bn=class extends Gt{constructor(e,t,i,n){super(e,t,i,n)}};bn.prototype.ValueTypeName="vector";var Tn=class{constructor(e="",t=-1,i=[],n=2500){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Qt(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,n=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(u0(i[a]).scale(n));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=i.length;r!==a;++r)t.push(Gt.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){let r=t.length,a=[];for(let o=0;o1){let u=h[1],d=n[u];d||(n[u]=d=[]),d.push(l)}}let a=[];for(let o in n)a.push(this.CreateFromMorphTargetSequence(o,n[o],t,i));return a}static parseAnimation(e,t){if(re("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return ve("AnimationClip: No animation in JSONLoader data."),null;let i=function(h,u,d,p,f){if(d.length!==0){let m=[],v=[];Nd(d,m,v,p),m.length!==0&&f.push(new h(u,m,v))}},n=[],r=e.name||"default",a=e.fps||30,o=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let h=0;h{t&&t(r),this.manager.itemEnd(e)},0);if(qi[e]!==void 0)return void qi[e].push({onLoad:t,onProgress:i,onError:n});qi[e]=[],qi[e].push({onLoad:t,onProgress:i,onError:n});let 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,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&re("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=qi[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),p=d?parseInt(d):0,f=p!==0,m=0,v=new ReadableStream({start(g){(function _(){u.read().then(({done:x,value:S})=>{if(x)g.close();else{m+=S.byteLength;let b=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:p});for(let M=0,I=h.length;M{g.error(x)})})()}});return new Response(v)}throw new Gu(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(o),u=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(u);return l.arrayBuffer().then(p=>d.decode(p))}}}).then(l=>{vi.add(`file:${e}`,l);let h=qi[e];delete qi[e];for(let u=0,d=h.length;u{let h=qi[e];if(h===void 0)throw this.manager.itemError(e),l;delete qi[e];for(let u=0,d=h.length;u{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Hl=class extends wt{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new oi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(c){n?n(c):ve(c),r.manager.itemError(e)}},i,n)}parse(e){let t=[];for(let i=0;i0:n.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let r in e.uniforms){let a=e.uniforms[r];switch(n.uniforms[r]={},a.type){case"t":n.uniforms[r].value=i(a.value);break;case"c":n.uniforms[r].value=new ue().setHex(a.value);break;case"v2":n.uniforms[r].value=new Q().fromArray(a.value);break;case"v3":n.uniforms[r].value=new w().fromArray(a.value);break;case"v4":n.uniforms[r].value=new $e().fromArray(a.value);break;case"m3":n.uniforms[r].value=new De().fromArray(a.value);break;case"m4":n.uniforms[r].value=new Re().fromArray(a.value);break;default:n.uniforms[r].value=a.value}}if(e.defines!==void 0&&(n.defines=e.defines),e.vertexShader!==void 0&&(n.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(n.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(n.glslVersion=e.glslVersion),e.extensions!==void 0)for(let r in e.extensions)n.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(n.lights=e.lights),e.clipping!==void 0&&(n.clipping=e.clipping),e.size!==void 0&&(n.size=e.size),e.sizeAttenuation!==void 0&&(n.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(n.map=i(e.map)),e.matcap!==void 0&&(n.matcap=i(e.matcap)),e.alphaMap!==void 0&&(n.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(n.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(n.bumpScale=e.bumpScale),e.normalMap!==void 0&&(n.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(n.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),n.normalScale=new Q().fromArray(r)}return e.displacementMap!==void 0&&(n.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(n.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(n.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(n.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(n.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(n.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(n.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(n.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(n.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(n.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(n.envMap=i(e.envMap)),e.envMapRotation!==void 0&&n.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(n.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(n.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(n.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(n.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(n.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(n.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(n.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(n.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(n.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(n.clearcoatNormalScale=new Q().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(n.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(n.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(n.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(n.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(n.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(n.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(n.sheenRoughnessMap=i(e.sheenRoughnessMap)),n}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return s.createMaterialFromType(e)}static createMaterialFromType(e){return new{ShadowMaterial:Pa,SpriteMaterial:Zr,RawShaderMaterial:cs,ShaderMaterial:kt,PointsMaterial:Kr,MeshPhysicalMaterial:La,MeshStandardMaterial:hs,MeshPhongMaterial:Da,MeshToonMaterial:Na,MeshNormalMaterial:Ua,MeshLambertMaterial:Fa,MeshDepthMaterial:us,MeshDistanceMaterial:ds,MeshBasicMaterial:yi,MeshMatcapMaterial:Oa,LineDashedMaterial:Ba,LineBasicMaterial:Et,Material:yt}[e]}},_s=class{static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},$a=class extends Ue{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Qa=class extends wt{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new oi(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(c){n?n(c):ve(c),r.manager.itemError(e)}},i,n)}parse(e){let t={},i={};function n(u,d){if(t[d]!==void 0)return t[d];let p=u.interleavedBuffers[d],f=(function(g,_){if(i[_]!==void 0)return i[_];let x=g.arrayBuffers,S=x[_],b=new Uint32Array(S).buffer;return i[_]=b,b})(u,p.buffer),m=Ur(p.type,f),v=new $n(m,p.stride);return v.uuid=p.uuid,t[d]=v,v}let r=e.isInstancedBufferGeometry?new $a:new Ue,a=e.data.index;if(a!==void 0){let u=Ur(a.type,a.array);r.setIndex(new Je(u,1))}let o=e.data.attributes;for(let u in o){let d=o[u],p;if(d.isInterleavedBufferAttribute){let f=n(e.data,d.data);p=new vn(f,d.itemSize,d.offset,d.normalized)}else{let f=Ur(d.type,d.array);p=new(d.isInstancedBufferAttribute?$i:Je)(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),r.setAttribute(u,p)}let c=e.data.morphAttributes;if(c)for(let u in c){let d=c[u],p=[];for(let f=0,m=d.length;f0){let o=new fs(t);r=new En(o),r.setCrossOrigin(this.crossOrigin);for(let c=0,l=e.length;c0){n=new En(this.manager),n.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a{let g=null,_=null;return v.boundingBox!==void 0&&(g=new xt().fromJSON(v.boundingBox)),v.boundingSphere!==void 0&&(_=new gt().fromJSON(v.boundingSphere)),{...v,boundingBox:g,boundingSphere:_}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=u(e.matricesTexture.uuid),a._indirectTexture=u(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=u(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new gt().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new xt().fromJSON(e.boundingBox));break;case"LOD":a=new Qs;break;case"Line":a=new Mi(l(e.geometry),h(e.material));break;case"LineLoop":a=new sa(l(e.geometry),h(e.material));break;case"LineSegments":a=new ti(l(e.geometry),h(e.material));break;case"PointCloud":case"Points":a=new aa(l(e.geometry),h(e.material));break;case"Sprite":a=new $s(h(e.material));break;case"Group":a=new Zi;break;case"Bone":a=new Jr;break;default:a=new Ye}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.pivot!==void 0&&(a.pivot=new w().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){let d=e.children;for(let p=0;p"u"&&re("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&re("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=vi.get(`image-bitmap:${e}`);if(a!==void 0)return r.manager.itemStart(e),a.then?void a.then(l=>{wu.has(a)===!0?(n&&n(wu.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(l),r.manager.itemEnd(e))}):void setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);let 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;let c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){vi.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e)}).catch(function(l){n&&n(l),wu.set(c,l),vi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});vi.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},fl,vs=class{static getContext(){return fl===void 0&&(fl=new(window.AudioContext||window.webkitAudioContext)),fl}static setContext(e){fl=e}},Jl=class extends wt{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new oi(this.manager);function o(c){n?n(c):ve(c),r.manager.itemError(e)}a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{let l=c.slice(0),h=vs.getContext(),u=e+"#decode";r.manager.itemStart(u),h.decodeAudioData(l,function(d){t(d),r.manager.itemEnd(u)}).catch(function(d){o(d),r.manager.itemEnd(u)})}catch(l){o(l)}},i,n)}},pm=new Re,mm=new Re,zn=new Re,Kl=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ft,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ft,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,zn.copy(e.projectionMatrix);let i=t.eyeSep/2,n=i*t.near/t.focus,r=t.near*Math.tan(jn*t.fov*.5)/t.zoom,a,o;mm.elements[12]=-i,pm.elements[12]=i,a=-r*t.aspect+n,o=r*t.aspect+n,zn.elements[0]=2*t.near/(o-a),zn.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(zn),a=-r*t.aspect-n,o=r*t.aspect-n,zn.elements[0]=2*t.near/(o-a),zn.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(zn)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(mm),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(pm)}},Lr=-90,eo=class extends Ye{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let n=new ft(Lr,1,e,t);n.layers=this.layers,this.add(n);let r=new ft(Lr,1,e,t);r.layers=this.layers,this.add(r);let a=new ft(Lr,1,e,t);a.layers=this.layers,this.add(a);let o=new ft(Lr,1,e,t);o.layers=this.layers,this.add(o);let c=new ft(Lr,1,e,t);c.layers=this.layers,this.add(c);let l=new ft(Lr,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,n,r,a,o,c]=t;for(let l of t)this.remove(l);if(e===xi)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else{if(e!==gn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1)}for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let v=!1;v=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(i,0,n),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,n),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,n),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,n),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(i,4,n),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=m,e.setRenderTarget(i,5,n),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,p),e.xr.enabled=f,i.texture.needsPMREMUpdate=!0}},to=class extends ft{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},io=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=p0.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function p0(){this._document.hidden===!1&&this.reset()}var Gn=new w,Cu=new Tt,m0=new w,Vn=new w,kn=new w,$l=class extends Ye{constructor(){super(),this.type="AudioListener",this.context=vs.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new io}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this._timer.update();let t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(Gn,Cu,m0),Vn.set(0,0,-1).applyQuaternion(Cu),kn.set(0,1,0).applyQuaternion(Cu),t.positionX){let i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Gn.x,i),t.positionY.linearRampToValueAtTime(Gn.y,i),t.positionZ.linearRampToValueAtTime(Gn.z,i),t.forwardX.linearRampToValueAtTime(Vn.x,i),t.forwardY.linearRampToValueAtTime(Vn.y,i),t.forwardZ.linearRampToValueAtTime(Vn.z,i),t.upX.linearRampToValueAtTime(kn.x,i),t.upY.linearRampToValueAtTime(kn.y,i),t.upZ.linearRampToValueAtTime(kn.z,i)}else t.setPosition(Gn.x,Gn.y,Gn.z),t.setOrientation(Vn.x,Vn.y,Vn.z,kn.x,kn.y,kn.z)}},no=class extends Ye{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0)return void re("Audio: Audio is already playing.");if(this.hasPlaybackControl===!1)return void re("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl!==!1)return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;re("Audio: this Audio has no playback control.")}stop(e=0){if(this.hasPlaybackControl!==!1)return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this;re("Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(i[c]!==i[c+t]){o.setValue(i,n);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let r=i,a=n;r!==a;++r)t[r]=t[n+r%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let a=0;a!==r;++a)e[t+a]=e[i+a]}_slerp(e,t,i,n){Tt.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){let a=this._workIndex*r;Tt.multiplyQuaternionsFlat(e,a,e,t,e,i),Tt.slerpFlat(e,t,e,t,e,a,n)}_lerp(e,t,i,n,r){let a=1-n;for(let o=0;o!==r;++o){let c=t+o;e[c]=e[c]*a+e[i+o]*n}}_lerpAdditive(e,t,i,n,r){for(let a=0;a!==r;++a){let o=t+a;e[o]=e[o]+e[i+a]*n}}},Fd="\\[\\]\\.:\\/",g0=new RegExp("["+Fd+"]","g"),Ru="[^"+Fd+"]",_0="[^"+Fd.replace("\\.","")+"]",v0=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Ru)+/(WCOD+)?/.source.replace("WCOD",_0)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ru)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ru)+"$"),x0=["material","materials","bones","map"],Ke=class s{constructor(e,t,i){this.path=t,this.parsedPath=i||s.parseTrackName(t),this.node=s.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new s.Composite(e,t,i):new s(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(g0,"")}static parseTrackName(e){let t=v0.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let r=i.nodeName.substring(n+1);x0.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(r){for(let a=0;a=r){let u=r++,d=e[u];t[d.uuid]=h,e[h]=d,t[l]=u,e[u]=c;for(let p=0,f=n;p!==f;++p){let m=i[p],v=m[u],g=m[h];m[h]=v,m[u]=g}}}this.nCachedObjects_=r}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length,r=this.nCachedObjects_,a=e.length;for(let o=0,c=arguments.length;o!==c;++o){let l=arguments[o].uuid,h=t[l];if(h!==void 0)if(delete t[l],h0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let p=0,f=n;p!==f;++p){let m=i[p];m[h]=m[u],m.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){let i=this._bindingsIndicesByPath,n=i[e],r=this._bindings;if(n!==void 0)return r[n];let a=this._paths,o=this._parsedPaths,c=this._objects,l=c.length,h=this.nCachedObjects_,u=new Array(l);n=r.length,i[e]=n,a.push(e),o.push(t),r.push(u);for(let d=h,p=c.length;d!==p;++d){let f=c[d];u[d]=new Ke(f,e,t)}return u}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let n=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,c=a[o];t[e[o]]=i,a[i]=c,a.pop(),r[i]=r[o],r.pop(),n[i]=n[o],n.pop()}}},so=class{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;let r=t.tracks,a=r.length,o=new Array(a),c={endingStart:mn,endingEnd:mn};for(let l=0;l!==a;++l){let h=r[l].createInterpolant(null);o[l]=h,h.settings&&Object.assign(c,h.settings),h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){let n=this._clip.duration,r=e._clip.duration,a=r/n,o=n/r;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let n=this._mixer,r=n.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);let c=o.parameterPositions,l=o.sampleValues;return c[0]=r,c[1]=r+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled)return void this._updateWeight(e);let r=this._startTime;if(r!==null){let c=(e-r)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let c=this._interpolants,l=this._propertyBindings;if(this.blendMode===Ph)for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);else for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(n,o)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;i!==null&&(t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,n=this.time+e,r=this._loopCount,a=i===2202;if(e===0)return r===-1||!a||1&~r?n:t-n;if(i===2200){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),n>=t||n<0){let o=Math.floor(n/t);n-=t*o,r+=Math.abs(o);let c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=n;if(a&&!(1&~r))return t-n}return n}_setEndings(e,t,i){let n=this._interpolantSettings;i?(n.endingStart=fn,n.endingEnd=fn):(n.endingStart=e?this.zeroSlopeAtStart?fn:mn:Gr,n.endingEnd=t?this.zeroSlopeAtEnd?fn:mn:Gr)}_scheduleFading(e,t,i){let n=this._mixer,r=n.time,a=this._weightInterpolant;a===null&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,c=a.sampleValues;return o[0]=r,c[0]=t,o[1]=r+e,c[1]=i,this}},y0=new Float32Array(1),ic=class extends Yt{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,a=e._propertyBindings,o=e._interpolants,c=i.uuid,l=this._bindingsByRootAndName,h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){let d=n[u],p=d.name,f=h[p];if(f!==void 0)++f.referenceCount,a[u]=f;else{if(f=a[u],f!==void 0){f._cacheIndex===null&&(++f.referenceCount,this._addInactiveBinding(f,c,p));continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new ro(Ke.create(i,p,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,c,p),a[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,i)}let t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){let r=t[i];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){let r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(n,e,r,a);let o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vm).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},xm=new w,gl=new w,Dr=new w,Nr=new w,Iu=new w,S0=new w,b0=new w,mc=class{constructor(e=new w,t=new w){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){xm.subVectors(e,this.start),gl.subVectors(this.end,this.start);let i=gl.dot(gl);if(i===0)return 0;let n=gl.dot(xm)/i;return t&&(n=Ce(n,0,1)),n}closestPointToPoint(e,t,i){let n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}distanceSqToLine3(e,t=S0,i=b0){let n=10000000000000001e-32,r,a,o=this.start,c=e.start,l=this.end,h=e.end;Dr.subVectors(l,o),Nr.subVectors(h,c),Iu.subVectors(o,c);let u=Dr.dot(Dr),d=Nr.dot(Nr),p=Nr.dot(Iu);if(u<=n&&d<=n)return t.copy(o),i.copy(c),t.sub(i),t.dot(t);if(u<=n)r=0,a=p/d,a=Ce(a,0,1);else{let f=Dr.dot(Iu);if(d<=n)a=0,r=Ce(-f/u,0,1);else{let m=Dr.dot(Nr),v=u*d-m*m;r=v!==0?Ce((m*p-f*d)/v,0,1):0,a=(m*r+p)/d,a<0?(a=0,r=Ce(-f/u,0,1)):a>1&&(a=1,r=Ce((m-f)/u,0,1))}}return t.copy(o).addScaledVector(Dr,r),i.copy(c).addScaledVector(Nr,a),t.distanceToSquared(i)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},ym=new w,fc=class extends Ye{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ue,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,c=32;a1)for(let h=0;h.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Em.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Em,t)}}setLength(e,t=.2*e,i=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},wc=class extends ti{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=new Ue;i.setAttribute("position",new pe(t,3)),i.setAttribute("color",new pe([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new Et({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,i){let n=new ue,r=this.geometry.attributes.color.array;return n.set(e),n.toArray(r,0),n.toArray(r,3),n.set(t),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Cc=class{constructor(){this.type="ShapePath",this.color=new ue,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new tr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this}bezierCurveTo(e,t,i,n,r,a){return this.currentPath.bezierCurveTo(e,t,i,n,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(v,g){let _=g.length,x=!1;for(let S=_-1,b=0;b<_;S=b++){let M=g[S],I=g[b],F=I.x-M.x,P=I.y-M.y;if(Math.abs(P)>Number.EPSILON){if(P<0&&(M=g[b],F=-F,I=g[S],P=-P),v.yI.y)continue;if(v.y===M.y){if(v.x===M.x)return!0}else{let L=P*(v.x-M.x)-F*(v.y-M.y);if(L===0)return!0;if(L<0)continue;x=!x}}else{if(v.y!==M.y)continue;if(I.x<=v.x&&v.x<=M.x||M.x<=v.x&&v.x<=I.x)return!0}}return x}let i=si.isClockWise,n=this.subPaths;if(n.length===0)return[];let r,a,o,c=[];if(n.length===1)return a=n[0],o=new Oi,o.curves=a.curves,c.push(o),c;let l=!i(n[0].getPoints());l=e?!l:l;let h=[],u=[],d,p,f=[],m=0;u[m]=void 0,f[m]=[];for(let v=0,g=n.length;v1){let v=!1,g=0;for(let _=0,x=u.length;_0&&v===!1&&(f=h)}for(let v=0,g=u.length;vn?(i.repeat.x=1,i.repeat.y=r/n,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=n/r,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i})(e,t)}static cover(e,t){return(function(i,n){let r=i.image&&i.image.width?i.image.width/i.image.height:1;return r>n?(i.repeat.x=n/r,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=r/n,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i})(e,t)}static fill(e){return(function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t})(e)}static getByteLength(e,t,i,n){return Nh(e,t,i,n)}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"184"}})),typeof window<"u"&&(window.__THREE__?re("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="184");/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function ag(){let s=null,e=!1,t=null,i=null;function n(r,a){t(r,a),i=s.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&s!==null&&(i=s.requestAnimationFrame(n),e=!0)},stop:function(){s!==null&&s.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function E0(s){let e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);let i=e.get(t);i&&(s.deleteBuffer(i.buffer),e.delete(t))},update:function(t,i){if(t.isInterleavedBufferAttribute&&(t=t.data),t.isGLBufferAttribute){let r=e.get(t);return void((!r||r.versionu.start-d.start);let h=0;for(let u=1;u 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`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,common:`#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`,cube_uv_reflection_fragment:`#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`,defaultnormal_vertex:`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`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:`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 ); +}`,envmap_fragment:`#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 * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,envmap_pars_fragment:`#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`,envmap_pars_vertex:`#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`,envmap_physical_pars_fragment:`#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`,envmap_vertex:`#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`,fog_vertex:`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,fog_pars_vertex:`#ifdef USE_FOG + varying float vFogDepth; +#endif`,fog_fragment:`#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`,fog_pars_fragment:`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,gradientmap_pars_fragment:`#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 +}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,lights_lambert_fragment:`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`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`,lights_pars_begin:`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 +#include `,lights_toon_fragment:`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`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`,lights_phong_fragment:`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`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`,lights_physical_fragment:`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,lights_fragment_begin:` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,lightprobes_pars_fragment:`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,map_fragment:`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,map_pars_fragment:`#ifdef USE_MAP + uniform sampler2D map; +#endif`,map_particle_fragment:`#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`,map_particle_pars_fragment:`#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`,metalnessmap_fragment:`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,morphinstance_vertex:`#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`,morphcolor_vertex:`#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`,morphnormal_vertex:`#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`,morphtarget_pars_vertex:`#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`,morphtarget_vertex:`#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`,normal_fragment_begin:`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;`,normal_fragment_maps:`#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; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_vertex:`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,normalmap_pars_fragment:`#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`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,clearcoat_pars_fragment:`#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`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,opaque_fragment:`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,project_vertex:`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;`,dithering_fragment:`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,dithering_pars_fragment:`#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`,roughnessmap_fragment:`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,shadowmap_pars_vertex:`#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`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + 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`,shadowmask_pars_fragment:`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,skinbase_vertex:`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,skinning_pars_vertex:`#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`,skinning_vertex:`#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`,skinnormal_vertex:`#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`,specularmap_fragment:`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,tonemapping_pars_fragment:`#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; }`,transmission_fragment:`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,transmission_pars_fragment:`#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`,uv_pars_fragment:`#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`,uv_pars_vertex:`#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`,uv_vertex:`#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`,worldpos_vertex:`#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`,background_vert:`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,background_frag:`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,backgroundCube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #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 +}`,cube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,cube_frag:`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,depth_vert:`#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; +}`,depth_frag:`#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 +}`,distance_vert:`#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; +}`,distance_frag:`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#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 = vec4( dist, 0.0, 0.0, 1.0 ); +}`,equirect_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,equirect_frag:`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,linedashed_vert:`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 +}`,linedashed_frag:`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 +}`,meshbasic_vert:`#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 +}`,meshbasic_frag:`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 +}`,meshlambert_vert:`#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 +}`,meshlambert_frag:`#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 +#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 +}`,meshmatcap_vert:`#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; +}`,meshmatcap_frag:`#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 +}`,meshnormal_vert:`#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 +}`,meshnormal_frag:`#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 +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,meshphong_vert:`#define PHONG +varying vec3 vViewPosition; +#include +#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 +}`,meshphong_frag:`#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 +#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 +}`,meshphysical_vert:`#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 +}`,meshphysical_frag:`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#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 + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,meshtoon_vert:`#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 +}`,meshtoon_frag:`#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 +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 +}`,points_vert:`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 +}`,points_frag:`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 +}`,shadow_vert:`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,shadow_frag:`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,sprite_vert:`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 +}`,sprite_frag:`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 +}`},ce={common:{diffuse:{value:new ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new De},alphaMap:{value:null},alphaMapTransform:{value:new De},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new De}},envmap:{envMap:{value:null},envMapRotation:{value:new De},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new De}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new De}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new De},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new De},normalScale:{value:new Q(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new De},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new De}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new De}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new De}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ue(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new w},probesMax:{value:new w},probesResolution:{value:new w}},points:{diffuse:{value:new ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new De},alphaTest:{value:0},uvTransform:{value:new De}},sprite:{diffuse:{value:new ue(16777215)},opacity:{value:1},center:{value:new Q(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new De},alphaMap:{value:null},alphaMapTransform:{value:new De},alphaTest:{value:0}}},wi={basic:{uniforms:Ut([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.fog]),vertexShader:Be.meshbasic_vert,fragmentShader:Be.meshbasic_frag},lambert:{uniforms:Ut([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new ue(0)},envMapIntensity:{value:1}}]),vertexShader:Be.meshlambert_vert,fragmentShader:Be.meshlambert_frag},phong:{uniforms:Ut([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new ue(0)},specular:{value:new ue(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Be.meshphong_vert,fragmentShader:Be.meshphong_frag},standard:{uniforms:Ut([ce.common,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.roughnessmap,ce.metalnessmap,ce.fog,ce.lights,{emissive:{value:new ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag},toon:{uniforms:Ut([ce.common,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.gradientmap,ce.fog,ce.lights,{emissive:{value:new ue(0)}}]),vertexShader:Be.meshtoon_vert,fragmentShader:Be.meshtoon_frag},matcap:{uniforms:Ut([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,{matcap:{value:null}}]),vertexShader:Be.meshmatcap_vert,fragmentShader:Be.meshmatcap_frag},points:{uniforms:Ut([ce.points,ce.fog]),vertexShader:Be.points_vert,fragmentShader:Be.points_frag},dashed:{uniforms:Ut([ce.common,ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Be.linedashed_vert,fragmentShader:Be.linedashed_frag},depth:{uniforms:Ut([ce.common,ce.displacementmap]),vertexShader:Be.depth_vert,fragmentShader:Be.depth_frag},normal:{uniforms:Ut([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,{opacity:{value:1}}]),vertexShader:Be.meshnormal_vert,fragmentShader:Be.meshnormal_frag},sprite:{uniforms:Ut([ce.sprite,ce.fog]),vertexShader:Be.sprite_vert,fragmentShader:Be.sprite_frag},background:{uniforms:{uvTransform:{value:new De},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Be.background_vert,fragmentShader:Be.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new De}},vertexShader:Be.backgroundCube_vert,fragmentShader:Be.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Be.cube_vert,fragmentShader:Be.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Be.equirect_vert,fragmentShader:Be.equirect_frag},distance:{uniforms:Ut([ce.common,ce.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Be.distance_vert,fragmentShader:Be.distance_frag},shadow:{uniforms:Ut([ce.lights,ce.fog,{color:{value:new ue(0)},opacity:{value:1}}]),vertexShader:Be.shadow_vert,fragmentShader:Be.shadow_frag}};wi.physical={uniforms:Ut([wi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new De},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new De},clearcoatNormalScale:{value:new Q(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new De},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new De},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new De},sheen:{value:0},sheenColor:{value:new ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new De},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new De},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new De},transmissionSamplerSize:{value:new Q},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new De},attenuationDistance:{value:0},attenuationColor:{value:new ue(0)},specularColor:{value:new ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new De},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new De},anisotropyVector:{value:new Q},anisotropyMap:{value:null},anisotropyMapTransform:{value:new De}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag};var Uh={r:0,b:0,g:0},A0=new Re,og=new De;function w0(s,e,t,i,n,r){let a=new ue(0),o,c,l=n===!0?0:1,h=null,u=0,d=null;function p(m){let v=m.isScene===!0?m.background:null;if(v&&v.isTexture){let g=m.backgroundBlurriness>0;v=e.get(v,g)}return v}function f(m,v){m.getRGB(Uh,Ld(s)),t.buffers.color.setClear(Uh.r,Uh.g,Uh.b,v,r)}return{getClearColor:function(){return a},setClearColor:function(m,v=1){a.set(m),l=v,f(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,f(a,l)},render:function(m){let v=!1,g=p(m);g===null?f(a,l):g&&g.isColor&&(f(g,1),v=!0);let _=s.xr.getEnvironmentBlendMode();_==="additive"?t.buffers.color.setClear(0,0,0,1,r):_==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||v)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))},addToRenderList:function(m,v){let g=p(v);g&&(g.isCubeTexture||g.mapping===Ms)?(c===void 0&&(c=new ot(new yn(1,1,1),new kt({name:"BackgroundCubeMaterial",uniforms:hr(wi.backgroundCube.uniforms),vertexShader:wi.backgroundCube.vertexShader,fragmentShader:wi.backgroundCube.fragmentShader,side:Ht,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(_,x,S){this.matrixWorld.copyPosition(S.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=g,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(A0.makeRotationFromEuler(v.backgroundRotation)).transpose(),g.isCubeTexture&&g.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(og),c.material.toneMapped=Ge.getTransfer(g.colorSpace)!==Ze,h===g&&u===g.version&&d===s.toneMapping||(c.material.needsUpdate=!0,h=g,u=g.version,d=s.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null)):g&&g.isTexture&&(o===void 0&&(o=new ot(new nr(2,2),new kt({name:"BackgroundMaterial",uniforms:hr(wi.background.uniforms),vertexShader:wi.background.vertexShader,fragmentShader:wi.background.fragmentShader,side:ar,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=g,o.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,o.material.toneMapped=Ge.getTransfer(g.colorSpace)!==Ze,g.matrixAutoUpdate===!0&&g.updateMatrix(),o.material.uniforms.uvTransform.value.copy(g.matrix),h===g&&u===g.version&&d===s.toneMapping||(o.material.needsUpdate=!0,h=g,u=g.version,d=s.toneMapping),o.layers.enableAll(),m.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),o!==void 0&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function C0(s,e){let t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},n=l(null),r=n,a=!1;function o(g){return s.bindVertexArray(g)}function c(g){return s.deleteVertexArray(g)}function l(g){let _=[],x=[],S=[];for(let b=0;b=0){let X=O[q],le=j[q];if(le===void 0&&(q==="instanceMatrix"&&F.instanceMatrix&&(le=F.instanceMatrix),q==="instanceColor"&&F.instanceColor&&(le=F.instanceColor)),X===void 0||X.attribute!==le||le&&X.data!==le.data)return!0;G++}return r.attributesNum!==G||r.index!==H})(g,S,x,b),M&&(function(F,P,L,H){let O={},j=P.attributes,G=0,z=L.getAttributes();for(let q in z)if(z[q].location>=0){let X=j[q];X===void 0&&(q==="instanceMatrix"&&F.instanceMatrix&&(X=F.instanceMatrix),q==="instanceColor"&&F.instanceColor&&(X=F.instanceColor));let le={};le.attribute=X,X&&X.data&&(le.data=X.data),O[q]=le,G++}r.attributes=O,r.attributesNum=G,r.index=H})(g,S,x,b),b!==null&&e.update(b,s.ELEMENT_ARRAY_BUFFER),(M||a)&&(a=!1,(function(F,P,L,H){h();let O=H.attributes,j=L.getAttributes(),G=P.defaultAttributeValues;for(let z in j){let q=j[z];if(q.location>=0){let X=O[z];if(X===void 0&&(z==="instanceMatrix"&&F.instanceMatrix&&(X=F.instanceMatrix),z==="instanceColor"&&F.instanceColor&&(X=F.instanceColor)),X!==void 0){let le=X.normalized,me=X.itemSize,Ae=e.get(X);if(Ae===void 0)continue;let be=Ae.buffer,Se=Ae.type,te=Ae.bytesPerElement,oe=Se===s.INT||Se===s.UNSIGNED_INT||X.gpuType===uo;if(X.isInterleavedBufferAttribute){let ne=X.data,ye=ne.stride,Ve=X.offset;if(ne.isInstancedInterleavedBuffer){for(let ie=0;ie0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";h="mediump"}return h==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=t.precision!==void 0?t.precision:"highp",o=r(a);o!==a&&(re("WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);let c=t.logarithmicDepthBuffer===!0,l=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");return t.reversedDepthBuffer===!0&&l===!1&&re("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),{isWebGL2:!0,getMaxAnisotropy:function(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){let h=e.get("EXT_texture_filter_anisotropic");n=s.getParameter(h.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,textureFormatReadable:function(h){return h===Vt||i.convert(h)===s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(h){let u=h===Ai&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(h!==Jt&&i.convert(h)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&h!==Dt&&!u)},precision:a,logarithmicDepthBuffer:c,reversedDepthBuffer:l,maxTextures:s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:s.getParameter(s.MAX_TEXTURE_SIZE),maxCubemapSize:s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:s.getParameter(s.MAX_VERTEX_ATTRIBS),maxVertexUniforms:s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:s.getParameter(s.MAX_VARYING_VECTORS),maxFragmentUniforms:s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:s.getParameter(s.MAX_SAMPLES),samples:s.getParameter(s.SAMPLES)}}function P0(s){let e=this,t=null,i=0,n=!1,r=!1,a=new fi,o=new De,c={value:null,needsUpdate:!1};function l(h,u,d,p){let f=h!==null?h.length:0,m=null;if(f!==0){if(m=c.value,p!==!0||m===null){let v=d+4*f,g=u.matrixWorldInverse;o.getNormalMatrix(g),(m===null||m.length0),e.numPlanes=i,e.numIntersection=0})();else{let g=r?0:i,_=4*g,x=v.clippingState||null;c.value=x,x=l(p,u,_,d);for(let S=0;S!==_;++S)x[S]=t[S];v.clippingState=x,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=g}}}og.set(-1,0,0,0,1,0,0,0,1);var Bf=[.125,.215,.35,.446,.526,.582],To=20,Eo=new An,zf=new ue,Od=null,Bd=0,zd=0,Gd=!1,L0=new w,Co=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,n=100,r={}){let{size:a=256,position:o=L0}=r;Od=this._renderer.getRenderTarget(),Bd=this._renderer.getActiveCubeFace(),zd=this._renderer.getActiveMipmapLevel(),Gd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,i,n,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=kf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Vf(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;ea-4?f=Bf[d-a+4-1]:d===0&&(f=0),c.push(f);let m=1/(p-2),v=-m,g=1+m,_=[v,v,g,v,g,g,v,v,g,g,v,g],x=6,S=6,b=3,M=2,I=1,F=new Float32Array(b*S*x),P=new Float32Array(M*S*x),L=new Float32Array(I*S*x);for(let O=0;O2?0:-1,z=[j,G,0,j+2/3,G,0,j+2/3,G+1,0,j,G,0,j+2/3,G+1,0,j,G+1,0];F.set(z,b*S*O),P.set(_,M*S*O);let q=[O,O,O,O,O,O];L.set(q,I*S*O)}let H=new Ue;H.setAttribute("position",new Je(F,b)),H.setAttribute("uv",new Je(P,M)),H.setAttribute("faceIndex",new Je(L,I)),l.push(new ot(H,null)),h>4&&h--}return{lodMeshes:l,sizeLods:o,sigmas:c}})(r)),this._blurMaterial=(function(a,o,c){let l=new Float32Array(To),h=new w(0,1,0);return new kt({name:"SphericalGaussianBlur",defines:{n:To,CUBEUV_TEXEL_WIDTH:1/o,CUBEUV_TEXEL_HEIGHT:1/c,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:l},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:h}},vertexShader:Oh(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:Ti,depthTest:!1,depthWrite:!1})})(r,e,t),this._ggxMaterial=(function(a,o,c){return new kt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/o,CUBEUV_TEXEL_HEIGHT:1/c,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Oh(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:Ti,depthTest:!1,depthWrite:!1})})(r,e,t)}return n}_compileMaterial(e){let t=new ot(new Ue,e);this._renderer.compile(t,Eo)}_sceneToCubeUV(e,t,i,n,r){let a=new ft(90,1,t,i),o=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],l=this._renderer,h=l.autoClear,u=l.toneMapping;l.getClearColor(zf),l.toneMapping=li,l.autoClear=!1,l.state.buffers.depth.getReversed()&&(l.setRenderTarget(n),l.clearDepth(),l.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new ot(new yn,new yi({name:"PMREM.Background",side:Ht,depthWrite:!1,depthTest:!1})));let d=this._backgroundBox,p=d.material,f=!1,m=e.background;m?m.isColor&&(p.color.copy(m),e.background=null,f=!0):(p.color.copy(zf),f=!0);for(let v=0;v<6;v++){let g=v%3;g===0?(a.up.set(0,o[v],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+c[v],r.y,r.z)):g===1?(a.up.set(0,0,o[v]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+c[v],r.z)):(a.up.set(0,o[v],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+c[v]));let _=this._cubeSize;Ts(n,g*_,v>2?_:0,_,_),l.setRenderTarget(n),f&&l.render(d,a),l.render(e,a)}l.toneMapping=u,l.autoClear=h,e.background=m}_textureToCubeUV(e,t){let i=this._renderer,n=e.mapping===nn||e.mapping===wn;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=kf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Vf());let r=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r,r.uniforms.envMap.value=e;let o=this._cubeSize;Ts(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Eo)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let n=this._lodMeshes.length;for(let r=1;rd-4?i-d+4:0),m=4*(this._cubeSize-p);c.envMap.value=e.texture,c.roughness.value=u,c.mipInt.value=d-t,Ts(r,f,m,3*p,2*p),n.setRenderTarget(r),n.render(o,Eo),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=d-i,Ts(e,f,m,3*p,2*p),n.setRenderTarget(e),n.render(o,Eo)}_blur(e,t,i,n,r){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",r),this._halfBlur(a,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,a,o){let c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ve("blur direction must be either latitudinal or longitudinal!");let h=this._lodMeshes[n];h.material=l;let u=l.uniforms,d=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,f=r/p,m=isFinite(r)?1+Math.floor(3*f):To;m>To&&re(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);let v=[],g=0;for(let S=0;S_-4?n-_+4:0),4*(this._cubeSize-x),3*x,2*x),c.setRenderTarget(t),c.render(h,Eo)}};function Gf(s,e,t){let i=new Nt(s,e,t);return i.texture.mapping=Ms,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ts(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function Vf(){return new kt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Oh(),fragmentShader:` + + 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:Ti,depthTest:!1,depthWrite:!1})}function kf(){return new kt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Oh(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:Ti,depthTest:!1,depthWrite:!1})}function Oh(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}var Ro=class extends Nt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},n=[i,i,i,i,i,i];this.texture=new xn(n),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},n=new yn(5,5,5),r=new kt({name:"CubemapFromEquirect",uniforms:hr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ht,blending:Ti});r.uniforms.tEquirect.value=t;let a=new ot(n,r),o=t.minFilter;return t.minFilter===zi&&(t.minFilter=at),new eo(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,n=!0){let r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,n);e.setRenderTarget(r)}};function D0(s){let e=new WeakMap,t=new WeakMap,i=null;function n(o,c){return c===lo?o.mapping=nn:c===co&&(o.mapping=wn),o}function r(o){let c=o.target;c.removeEventListener("dispose",r);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function a(o){let c=o.target;c.removeEventListener("dispose",a);let l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}return{get:function(o,c=!1){return o==null?null:c?(function(l){if(l&&l.isTexture){let h=l.mapping,u=h===lo||h===co,d=h===nn||h===wn;if(u||d){let p=t.get(l),f=p!==void 0?p.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==f)return i===null&&(i=new Co(s)),p=u?i.fromEquirectangular(l,p):i.fromCubemap(l,p),p.texture.pmremVersion=l.pmremVersion,t.set(l,p),p.texture;if(p!==void 0)return p.texture;{let m=l.image;return u&&m&&m.height>0||d&&m&&(function(v){let g=0,_=6;for(let x=0;x<_;x++)v[x]!==void 0&&g++;return g===_})(m)?(i===null&&(i=new Co(s)),p=u?i.fromEquirectangular(l):i.fromCubemap(l),p.texture.pmremVersion=l.pmremVersion,t.set(l,p),l.addEventListener("dispose",a),p.texture):null}}}return l})(o):(function(l){if(l&&l.isTexture){let h=l.mapping;if(h===lo||h===co){if(e.has(l))return n(e.get(l).texture,l.mapping);{let u=l.image;if(u&&u.height>0){let d=new Ro(u.height);return d.fromEquirectangularTexture(s,l),e.set(l,d),l.addEventListener("dispose",r),n(d.texture,l.mapping)}return null}}}return l})(o)},dispose:function(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}}}function N0(s){let e={};function t(i){if(e[i]!==void 0)return e[i];let n=s.getExtension(i);return e[i]=n,n}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let n=t(i);return n===null&&qs("WebGLRenderer: "+i+" extension not supported."),n}}}function U0(s,e,t,i){let n={},r=new WeakMap;function a(c){let l=c.target;l.index!==null&&e.remove(l.index);for(let u in l.attributes)e.remove(l.attributes[u]);l.removeEventListener("dispose",a),delete n[l.id];let h=r.get(l);h&&(e.remove(h),r.delete(l)),i.releaseStatesOfGeometry(l),l.isInstancedBufferGeometry===!0&&delete l._maxInstanceCount,t.memory.geometries--}function o(c){let l=[],h=c.index,u=c.attributes.position,d=0;if(u===void 0)return;if(h!==null){let m=h.array;d=h.version;for(let v=0,g=m.length;v=65535?Yr:qr)(l,1);p.version=d;let f=r.get(c);f&&e.remove(f),r.set(c,p)}return{get:function(c,l){return n[l.id]===!0||(l.addEventListener("dispose",a),n[l.id]=!0,t.memory.geometries++),l},update:function(c){let l=c.attributes;for(let h in l)e.update(l[h],s.ARRAY_BUFFER)},getWireframeAttribute:function(c){let l=r.get(c);if(l){let h=c.index;h!==null&&l.versione.maxTextureSize&&(S=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);let b=new Float32Array(x*S*4*h),M=new Yn(b,x,S,h);M.type=Dt,M.needsUpdate=!0;let I=4*_;for(let P=0;P + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),l=new ot(o,c),h=new An(-1,1,1,-1,0,1),u,d=null,p=null,f=!1,m=null,v=[],g=!1;this.setSize=function(_,x){r.setSize(_,x),a.setSize(_,x);for(let S=0;S0&&v[0].isRenderPass===!0;let x=r.width,S=r.height;for(let b=0;b0)return s;let n=e*t,r=Hf[n];if(r===void 0&&(r=new Float32Array(n),Hf[n]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function Mt(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t0&&(this.seq=n.concat(r))}setValue(e,t,i,n){let r=this.map[t];r!==void 0&&r.setValue(e,i,n)}setOptional(e,t,i){let n=t[i];n!==void 0&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let r=0,a=t.length;r!==a;++r){let o=t[r],c=i[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,n)}}static seqWithValue(e,t){let i=[];for(let n=0,r=e.length;n!==r;++n){let a=e[n];a.id in t&&i.push(a)}return i}};function Zf(s,e,t){let i=s.createShader(e);return s.shaderSource(i,t),s.compileShader(i),i}var w_=0,Jf=new De;function Kf(s,e,t){let i=s.getShaderParameter(e,s.COMPILE_STATUS),n=(s.getShaderInfoLog(e)||"").trim();if(i&&n==="")return"";let r=/ERROR: 0:(\d+)/.exec(n);if(r){let a=parseInt(r[1]);return t.toUpperCase()+` + +`+n+` + +`+(function(o,c){let l=o.split(` +`),h=[],u=Math.max(c-6,0),d=Math.min(c+6,l.length);for(let p=u;p":" "} ${f}: ${l[p]}`)}return h.join(` +`)})(s.getShaderSource(e),a)}return n}function C_(s,e){let t=(function(i){Ge._getMatrix(Jf,Ge.workingColorSpace,i);let n=`mat3( ${Jf.elements.map(r=>r.toFixed(4))} )`;switch(Ge.getTransfer(i)){case kr:return[n,"LinearTransferOETF"];case Ze:return[n,"sRGBTransferOETF"];default:return re("WebGLProgram: Unsupported color space: ",i),[n,"LinearTransferOETF"]}})(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}var R_={[kc]:"Linear",[Hc]:"Reinhard",[Wc]:"Cineon",[Xc]:"ACESFilmic",[qc]:"AgX",[Yc]:"Neutral",[jc]:"Custom"};function I_(s,e){let t=R_[e];return t===void 0?(re("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Fh=new w;function P_(){return Ge.getLuminanceCoefficients(Fh),["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${Fh.x.toFixed(4)}, ${Fh.y.toFixed(4)}, ${Fh.z.toFixed(4)} );`," return dot( weights, rgb );","}"].join(` +`)}function Ao(s){return s!==""}function $f(s,e){let 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 Qf(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var L_=/^[ \t]*#include +<([\w\d./]+)>/gm;function qd(s){return s.replace(L_,N_)}var D_=new Map;function N_(s,e){let t=Be[e];if(t===void 0){let i=D_.get(e);if(i===void 0)throw new Error("Can not resolve #include <"+e+">");t=Be[i],re('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i)}return qd(t)}var U_=/#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 eg(s){return s.replace(U_,F_)}function F_(s,e,t,i){let n="";for(let r=parseInt(e);r0&&(v+=` +`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f].filter(Ao).join(` +`),g.length>0&&(g+=` +`)):(v=[tg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f,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.vertexNormals?"#define HAS_NORMAL":"",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 "+c:"",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(Ao).join(` +`),g=[tg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f,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 "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",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!==li?"#define TONE_MAPPING":"",t.toneMapping!==li?Be.tonemapping_pars_fragment:"",t.toneMapping!==li?I_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Be.colorspace_pars_fragment,C_("linearToOutputTexel",t.outputColorSpace),P_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(Ao).join(` +`)),a=qd(a),a=$f(a,t),a=Qf(a,t),o=qd(o),o=$f(o,t),o=Qf(o,t),a=eg(a),o=eg(o),t.isRawShaderMaterial!==!0&&(_=`#version 300 es +`,v=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+v,g=["#define varying in",t.glslVersion===Dh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Dh?"":"#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(` +`)+` +`+g);let x=_+v+a,S=_+g+o,b=Zf(n,n.VERTEX_SHADER,x),M=Zf(n,n.FRAGMENT_SHADER,S);function I(H){if(s.debug.checkShaderErrors){let O=n.getProgramInfoLog(m)||"",j=n.getShaderInfoLog(b)||"",G=n.getShaderInfoLog(M)||"",z=O.trim(),q=j.trim(),X=G.trim(),le=!0,me=!0;if(n.getProgramParameter(m,n.LINK_STATUS)===!1)if(le=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(n,m,b,M);else{let Ae=Kf(n,b,"vertex"),be=Kf(n,M,"fragment");ve("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(m,n.VALIDATE_STATUS)+` + +Material Name: `+H.name+` +Material Type: `+H.type+` + +Program Info Log: `+z+` +`+Ae+` +`+be)}else z!==""?re("WebGLProgram: Program Info Log:",z):q!==""&&X!==""||(me=!1);me&&(H.diagnostics={runnable:le,programLog:z,vertexShader:{log:q,prefix:v},fragmentShader:{log:X,prefix:g}})}n.deleteShader(b),n.deleteShader(M),F=new Es(n,m),P=(function(O,j){let G={},z=O.getProgramParameter(j,O.ACTIVE_ATTRIBUTES);for(let q=0;q0,N=m.clearcoat>0,A=m.dispersion>0,k=m.iridescence>0,W=m.sheen>0,K=m.transmission>0,ee=D&&!!m.anisotropyMap,fe=N&&!!m.clearcoatMap,Z=N&&!!m.clearcoatNormalMap,_e=N&&!!m.clearcoatRoughnessMap,he=k&&!!m.iridescenceMap,ge=k&&!!m.iridescenceThicknessMap,ae=W&&!!m.sheenColorMap,Te=W&&!!m.sheenRoughnessMap,ke=!!m.specularMap,et=!!m.specularColorMap,je=!!m.specularIntensityMap,tt=K&&!!m.transmissionMap,Ft=K&&!!m.thicknessMap,Ee=!!m.gradientMap,ze=!!m.alphaMap,Ie=m.alphaTest>0,Qe=!!m.alphaHash,Ct=!!m.extensions,Ci=li;m.toneMapped&&(me!==null&&me.isXRRenderTarget!==!0||(Ci=s.toneMapping));let ii={shaderID:H,shaderType:m.type,shaderName:m.name,vertexShader:G,fragmentShader:z,defines:m.defines,customVertexShaderID:q,customFragmentShaderID:X,isRawShaderMaterial:m.isRawShaderMaterial===!0,glslVersion:m.glslVersion,precision:d,batching:Se,batchingColor:Se&&x._colorsTexture!==null,instancing:be,instancingColor:be&&x.instanceColor!==null,instancingMorph:be&&x.morphTexture!==null,outputColorSpace:me===null?s.outputColorSpace:me.isXRRenderTarget===!0?me.texture.colorSpace:Ge.workingColorSpace,alphaToCoverage:!!m.alphaToCoverage,map:te,matcap:oe,envMap:ne,envMapMode:ne&&P.mapping,envMapCubeUVHeight:L,aoMap:ye,lightMap:Ve,bumpMap:ie,normalMap:R,displacementMap:T,emissiveMap:C,normalMapObjectSpace:R&&m.normalMapType===bd,normalMapTangentSpace:R&&m.normalMapType===Lh,packedNormalMap:R&&m.normalMapType===Lh&&(_t=m.normalMap.format,_t===Rn||_t===yo||_t===Mo),metalnessMap:U,roughnessMap:y,anisotropy:D,anisotropyMap:ee,clearcoat:N,clearcoatMap:fe,clearcoatNormalMap:Z,clearcoatRoughnessMap:_e,dispersion:A,iridescence:k,iridescenceMap:he,iridescenceThicknessMap:ge,sheen:W,sheenColorMap:ae,sheenRoughnessMap:Te,specularMap:ke,specularColorMap:et,specularIntensityMap:je,transmission:K,transmissionMap:tt,thicknessMap:Ft,gradientMap:Ee,opaque:m.transparent===!1&&m.blending===ys&&m.alphaToCoverage===!1,alphaMap:ze,alphaTest:Ie,alphaHash:Qe,combine:m.combine,mapUv:te&&f(m.map.channel),aoMapUv:ye&&f(m.aoMap.channel),lightMapUv:Ve&&f(m.lightMap.channel),bumpMapUv:ie&&f(m.bumpMap.channel),normalMapUv:R&&f(m.normalMap.channel),displacementMapUv:T&&f(m.displacementMap.channel),emissiveMapUv:C&&f(m.emissiveMap.channel),metalnessMapUv:U&&f(m.metalnessMap.channel),roughnessMapUv:y&&f(m.roughnessMap.channel),anisotropyMapUv:ee&&f(m.anisotropyMap.channel),clearcoatMapUv:fe&&f(m.clearcoatMap.channel),clearcoatNormalMapUv:Z&&f(m.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&f(m.clearcoatRoughnessMap.channel),iridescenceMapUv:he&&f(m.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&f(m.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&f(m.sheenColorMap.channel),sheenRoughnessMapUv:Te&&f(m.sheenRoughnessMap.channel),specularMapUv:ke&&f(m.specularMap.channel),specularColorMapUv:et&&f(m.specularColorMap.channel),specularIntensityMapUv:je&&f(m.specularIntensityMap.channel),transmissionMapUv:tt&&f(m.transmissionMap.channel),thicknessMapUv:Ft&&f(m.thicknessMap.channel),alphaMapUv:ze&&f(m.alphaMap.channel),vertexTangents:!!M.attributes.tangent&&(R||D),vertexNormals:!!M.attributes.normal,vertexColors:m.vertexColors,vertexAlphas:m.vertexColors===!0&&!!M.attributes.color&&M.attributes.color.itemSize===4,pointsUvs:x.isPoints===!0&&!!M.attributes.uv&&(te||ze),fog:!!b,useFog:m.fog===!0,fogExp2:!!b&&b.isFogExp2,flatShading:m.wireframe===!1&&(m.flatShading===!0||M.attributes.normal===void 0&&R===!1&&(m.isMeshLambertMaterial||m.isMeshPhongMaterial||m.isMeshStandardMaterial||m.isMeshPhysicalMaterial)),sizeAttenuation:m.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:Ae,skinning:x.isSkinnedMesh===!0,morphTargets:M.morphAttributes.position!==void 0,morphNormals:M.morphAttributes.normal!==void 0,morphColors:M.morphAttributes.color!==void 0,morphTargetsCount:j,morphTextureStride:le,numDirLights:v.directional.length,numPointLights:v.point.length,numSpotLights:v.spot.length,numSpotLightMaps:v.spotLightMap.length,numRectAreaLights:v.rectArea.length,numHemiLights:v.hemi.length,numDirLightShadows:v.directionalShadowMap.length,numPointLightShadows:v.pointShadowMap.length,numSpotLightShadows:v.spotShadowMap.length,numSpotLightShadowsWithMaps:v.numSpotLightShadowsWithMaps,numLightProbes:v.numLightProbes,numLightProbeGrids:S.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:m.dithering,shadowMapEnabled:s.shadowMap.enabled&&g.length>0,shadowMapType:s.shadowMap.type,toneMapping:Ci,decodeVideoTexture:te&&m.map.isVideoTexture===!0&&Ge.getTransfer(m.map.colorSpace)===Ze,decodeVideoTextureEmissive:C&&m.emissiveMap.isVideoTexture===!0&&Ge.getTransfer(m.emissiveMap.colorSpace)===Ze,premultipliedAlpha:m.premultipliedAlpha,doubleSided:m.side===bi,flipSided:m.side===Ht,useDepthPacking:m.depthPacking>=0,depthPacking:m.depthPacking||0,index0AttributeName:m.index0AttributeName,extensionClipCullDistance:Ct&&m.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ct&&m.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:m.customProgramCacheKey()};var _t;return ii.vertexUv1s=c.has(1),ii.vertexUv2s=c.has(2),ii.vertexUv3s=c.has(3),c.clear(),ii},getProgramCacheKey:function(m){let v=[];if(m.shaderID?v.push(m.shaderID):(v.push(m.customVertexShaderID),v.push(m.customFragmentShaderID)),m.defines!==void 0)for(let g in m.defines)v.push(g),v.push(m.defines[g]);return m.isRawShaderMaterial===!1&&((function(g,_){g.push(_.precision),g.push(_.outputColorSpace),g.push(_.envMapMode),g.push(_.envMapCubeUVHeight),g.push(_.mapUv),g.push(_.alphaMapUv),g.push(_.lightMapUv),g.push(_.aoMapUv),g.push(_.bumpMapUv),g.push(_.normalMapUv),g.push(_.displacementMapUv),g.push(_.emissiveMapUv),g.push(_.metalnessMapUv),g.push(_.roughnessMapUv),g.push(_.anisotropyMapUv),g.push(_.clearcoatMapUv),g.push(_.clearcoatNormalMapUv),g.push(_.clearcoatRoughnessMapUv),g.push(_.iridescenceMapUv),g.push(_.iridescenceThicknessMapUv),g.push(_.sheenColorMapUv),g.push(_.sheenRoughnessMapUv),g.push(_.specularMapUv),g.push(_.specularColorMapUv),g.push(_.specularIntensityMapUv),g.push(_.transmissionMapUv),g.push(_.thicknessMapUv),g.push(_.combine),g.push(_.fogExp2),g.push(_.sizeAttenuation),g.push(_.morphTargetsCount),g.push(_.morphAttributeCount),g.push(_.numDirLights),g.push(_.numPointLights),g.push(_.numSpotLights),g.push(_.numSpotLightMaps),g.push(_.numHemiLights),g.push(_.numRectAreaLights),g.push(_.numDirLightShadows),g.push(_.numPointLightShadows),g.push(_.numSpotLightShadows),g.push(_.numSpotLightShadowsWithMaps),g.push(_.numLightProbes),g.push(_.shadowMapType),g.push(_.toneMapping),g.push(_.numClippingPlanes),g.push(_.numClipIntersection),g.push(_.depthPacking)})(v,m),(function(g,_){a.disableAll(),_.instancing&&a.enable(0),_.instancingColor&&a.enable(1),_.instancingMorph&&a.enable(2),_.matcap&&a.enable(3),_.envMap&&a.enable(4),_.normalMapObjectSpace&&a.enable(5),_.normalMapTangentSpace&&a.enable(6),_.clearcoat&&a.enable(7),_.iridescence&&a.enable(8),_.alphaTest&&a.enable(9),_.vertexColors&&a.enable(10),_.vertexAlphas&&a.enable(11),_.vertexUv1s&&a.enable(12),_.vertexUv2s&&a.enable(13),_.vertexUv3s&&a.enable(14),_.vertexTangents&&a.enable(15),_.anisotropy&&a.enable(16),_.alphaHash&&a.enable(17),_.batching&&a.enable(18),_.dispersion&&a.enable(19),_.batchingColor&&a.enable(20),_.gradientMap&&a.enable(21),_.packedNormalMap&&a.enable(22),_.vertexNormals&&a.enable(23),g.push(a.mask),a.disableAll(),_.fog&&a.enable(0),_.useFog&&a.enable(1),_.flatShading&&a.enable(2),_.logarithmicDepthBuffer&&a.enable(3),_.reversedDepthBuffer&&a.enable(4),_.skinning&&a.enable(5),_.morphTargets&&a.enable(6),_.morphNormals&&a.enable(7),_.morphColors&&a.enable(8),_.premultipliedAlpha&&a.enable(9),_.shadowMapEnabled&&a.enable(10),_.doubleSided&&a.enable(11),_.flipSided&&a.enable(12),_.useDepthPacking&&a.enable(13),_.dithering&&a.enable(14),_.transmission&&a.enable(15),_.sheen&&a.enable(16),_.opaque&&a.enable(17),_.pointsUvs&&a.enable(18),_.decodeVideoTexture&&a.enable(19),_.decodeVideoTextureEmissive&&a.enable(20),_.alphaToCoverage&&a.enable(21),_.numLightProbeGrids>0&&a.enable(22),g.push(a.mask)})(v,m),v.push(s.outputColorSpace)),v.push(m.customProgramCacheKey),v.join()},getUniforms:function(m){let v=p[m.type],g;if(v){let _=wi[v];g=Dd.clone(_.uniforms)}else g=m.uniforms;return g},acquireProgram:function(m,v){let g=h.get(v);return g!==void 0?++g.usedTimes:(g=new V_(s,v,m,n),l.push(g),h.set(v,g)),g},releaseProgram:function(m){if(--m.usedTimes===0){let v=l.indexOf(m);l[v]=l[l.length-1],l.pop(),h.delete(m.cacheKey),m.destroy()}},releaseShaderCache:function(m){o.remove(m)},programs:l,dispose:function(){o.dispose()}}}function W_(){let s=new WeakMap;return{has:function(e){return s.has(e)},get:function(e){let t=s.get(e);return t===void 0&&(t={},s.set(e,t)),t},remove:function(e){s.delete(e)},update:function(e,t,i){s.get(e)[t]=i},dispose:function(){s=new WeakMap}}}function X_(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function ig(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 ng(){let s=[],e=0,t=[],i=[],n=[];function r(o){let c=0;return o.isInstancedMesh&&(c+=2),o.isSkinnedMesh&&(c+=1),c}function a(o,c,l,h,u,d){let p=s[e];return p===void 0?(p={id:o.id,object:o,geometry:c,material:l,materialVariant:r(o),groupOrder:h,renderOrder:o.renderOrder,z:u,group:d},s[e]=p):(p.id=o.id,p.object=o,p.geometry=c,p.material=l,p.materialVariant=r(o),p.groupOrder=h,p.renderOrder=o.renderOrder,p.z=u,p.group=d),e++,p}return{opaque:t,transmissive:i,transparent:n,init:function(){e=0,t.length=0,i.length=0,n.length=0},push:function(o,c,l,h,u,d){let p=a(o,c,l,h,u,d);l.transmission>0?i.push(p):l.transparent===!0?n.push(p):t.push(p)},unshift:function(o,c,l,h,u,d){let p=a(o,c,l,h,u,d);l.transmission>0?i.unshift(p):l.transparent===!0?n.unshift(p):t.unshift(p)},finish:function(){for(let o=e,c=s.length;o1&&t.sort(o||X_),i.length>1&&i.sort(c||ig),n.length>1&&n.sort(c||ig)}}}function j_(){let s=new WeakMap;return{get:function(e,t){let i=s.get(e),n;return i===void 0?(n=new ng,s.set(e,[n])):t>=i.length?(n=new ng,i.push(n)):n=i[t],n},dispose:function(){s=new WeakMap}}}function q_(){let s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new w,color:new ue};break;case"SpotLight":t={position:new w,direction:new w,color:new ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new w,color:new ue,distance:0,decay:0};break;case"HemisphereLight":t={direction:new w,skyColor:new ue,groundColor:new ue};break;case"RectAreaLight":t={color:new ue,position:new w,halfWidth:new w,halfHeight:new w}}return s[e.id]=t,t}}}var Y_=0;function Z_(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function J_(s){let e=new q_,t=(function(){let o={};return{get:function(c){if(o[c.id]!==void 0)return o[c.id];let l;switch(c.type){case"DirectionalLight":case"SpotLight":l={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q};break;case"PointLight":l={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q,shadowCameraNear:1,shadowCameraFar:1e3}}return o[c.id]=l,l}}})(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let o=0;o<9;o++)i.probe.push(new w);let n=new w,r=new Re,a=new Re;return{setup:function(o){let c=0,l=0,h=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let u=0,d=0,p=0,f=0,m=0,v=0,g=0,_=0,x=0,S=0,b=0;o.sort(Z_);for(let I=0,F=o.length;I0&&(s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ce.LTC_FLOAT_1,i.rectAreaLTC2=ce.LTC_FLOAT_2):(i.rectAreaLTC1=ce.LTC_HALF_1,i.rectAreaLTC2=ce.LTC_HALF_2)),i.ambient[0]=c,i.ambient[1]=l,i.ambient[2]=h;let M=i.hash;M.directionalLength===u&&M.pointLength===d&&M.spotLength===p&&M.rectAreaLength===f&&M.hemiLength===m&&M.numDirectionalShadows===v&&M.numPointShadows===g&&M.numSpotShadows===_&&M.numSpotMaps===x&&M.numLightProbes===b||(i.directional.length=u,i.spot.length=p,i.rectArea.length=f,i.point.length=d,i.hemi.length=m,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=g,i.spotLightMatrix.length=_+x-S,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=b,M.directionalLength=u,M.pointLength=d,M.spotLength=p,M.rectAreaLength=f,M.hemiLength=m,M.numDirectionalShadows=v,M.numPointShadows=g,M.numSpotShadows=_,M.numSpotMaps=x,M.numLightProbes=b,i.version=Y_++)},setupView:function(o,c){let l=0,h=0,u=0,d=0,p=0,f=c.matrixWorldInverse;for(let m=0,v=o.length;m=n.length?(r=new rg(s),n.push(r)):r=n[i],r},dispose:function(){e=new WeakMap}}}var $_=[new w(1,0,0),new w(-1,0,0),new w(0,1,0),new w(0,-1,0),new w(0,0,1),new w(0,0,-1)],Q_=[new w(0,-1,0),new w(0,-1,0),new w(0,0,1),new w(0,0,-1),new w(0,-1,0),new w(0,-1,0)],sg=new Re,wo=new w,kd=new w;function ev(s,e,t){let i=new Qi,n=new Q,r=new Q,a=new $e,o=new us,c=new ds,l={},h=t.maxTextureSize,u={[ar]:Ht,[Ht]:ar,[bi]:bi},d=new kt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Q},radius:{value:4}},vertexShader:`void main() { + gl_Position = vec4( position, 1.0 ); +}`,fragmentShader:`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ue;f.setAttribute("position",new Je(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new ot(f,d),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xs;let g=this.type;function _(M,I){let F=e.update(m);d.defines.VSM_SAMPLES!==M.blurSamples&&(d.defines.VSM_SAMPLES=M.blurSamples,p.defines.VSM_SAMPLES=M.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new Nt(n.x,n.y,{format:Rn,type:Ai})),d.uniforms.shadow_pass.value=M.map.depthTexture,d.uniforms.resolution.value=M.mapSize,d.uniforms.radius.value=M.radius,s.setRenderTarget(M.mapPass),s.clear(),s.renderBufferDirect(I,null,F,d,m,null),p.uniforms.shadow_pass.value=M.mapPass.texture,p.uniforms.resolution.value=M.mapSize,p.uniforms.radius.value=M.radius,s.setRenderTarget(M.map),s.clear(),s.renderBufferDirect(I,null,F,p,m,null)}function x(M,I,F,P){let L=null,H=F.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(H!==void 0)L=H;else if(L=F.isPointLight===!0?c:o,s.localClippingEnabled&&I.clipShadows===!0&&Array.isArray(I.clippingPlanes)&&I.clippingPlanes.length!==0||I.displacementMap&&I.displacementScale!==0||I.alphaMap&&I.alphaTest>0||I.map&&I.alphaTest>0||I.alphaToCoverage===!0){let O=L.uuid,j=I.uuid,G=l[O];G===void 0&&(G={},l[O]=G);let z=G[j];z===void 0&&(z=L.clone(),G[j]=z,I.addEventListener("dispose",b)),L=z}return L.visible=I.visible,L.wireframe=I.wireframe,L.side=P===sr?I.shadowSide!==null?I.shadowSide:I.side:I.shadowSide!==null?I.shadowSide:u[I.side],L.alphaMap=I.alphaMap,L.alphaTest=I.alphaToCoverage===!0?.5:I.alphaTest,L.map=I.map,L.clipShadows=I.clipShadows,L.clippingPlanes=I.clippingPlanes,L.clipIntersection=I.clipIntersection,L.displacementMap=I.displacementMap,L.displacementScale=I.displacementScale,L.displacementBias=I.displacementBias,L.wireframeLinewidth=I.wireframeLinewidth,L.linewidth=I.linewidth,F.isPointLight===!0&&L.isMeshDistanceMaterial===!0&&(s.properties.get(L).light=F),L}function S(M,I,F,P,L){if(M.visible===!1)return;if(M.layers.test(I.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&L===sr)&&(!M.frustumCulled||i.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,M.matrixWorld);let O=e.update(M),j=M.material;if(Array.isArray(j)){let G=O.groups;for(let z=0,q=G.length;zz.needsUpdate=!0):G.material.needsUpdate=!0)});for(let G=0,z=M.length;Gh||n.y>h)&&(n.x>h&&(r.x=Math.floor(h/le.x),n.x=r.x*le.x,X.mapSize.x=r.x),n.y>h&&(r.y=Math.floor(h/le.y),n.y=r.y*le.y,X.mapSize.y=r.y));let me=s.state.buffers.depth.getReversed();if(X.camera._reversedDepth=me,X.map===null||j===!0){if(X.map!==null&&(X.map.depthTexture!==null&&(X.map.depthTexture.dispose(),X.map.depthTexture=null),X.map.dispose()),this.type===sr){if(q.isPointLight){re("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}X.map=new Nt(n.x,n.y,{format:Rn,type:Ai,minFilter:at,magFilter:at,generateMipmaps:!1}),X.map.texture.name=q.name+".shadowMap",X.map.depthTexture=new Bi(n.x,n.y,Dt),X.map.depthTexture.name=q.name+".shadowMapDepth",X.map.depthTexture.format=rn,X.map.depthTexture.compareFunction=null,X.map.depthTexture.minFilter=Lt,X.map.depthTexture.magFilter=Lt}else q.isPointLight?(X.map=new Ro(n.x),X.map.depthTexture=new la(n.x,Ei)):(X.map=new Nt(n.x,n.y),X.map.depthTexture=new Bi(n.x,n.y,Ei)),X.map.depthTexture.name=q.name+".shadowMap",X.map.depthTexture.format=rn,this.type===xs?(X.map.depthTexture.compareFunction=me?bo:So,X.map.depthTexture.minFilter=at,X.map.depthTexture.magFilter=at):(X.map.depthTexture.compareFunction=null,X.map.depthTexture.minFilter=Lt,X.map.depthTexture.magFilter=Lt);X.camera.updateProjectionMatrix()}let Ae=X.map.isWebGLCubeRenderTarget?6:1;for(let be=0;be=1):q.indexOf("OpenGL ES")!==-1&&(z=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),G=z>=2);let X=null,le={},me=s.getParameter(s.SCISSOR_BOX),Ae=s.getParameter(s.VIEWPORT),be=new $e().fromArray(me),Se=new $e().fromArray(Ae);function te(y,D,N,A){let k=new Uint8Array(4),W=s.createTexture();s.bindTexture(y,W),s.texParameteri(y,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(y,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let K=0;KC||y.height>C)&&(U=C/Math.max(y.width,y.height)),U<1){if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){let D=Math.floor(U*y.width),N=Math.floor(U*y.height);d===void 0&&(d=m(D,N));let A=T?m(D,N):d;return A.width=D,A.height=N,A.getContext("2d").drawImage(R,0,0,D,N),re("WebGLRenderer: Texture has been resized from ("+y.width+"x"+y.height+") to ("+D+"x"+N+")."),A}return"data"in R&&re("WebGLRenderer: Image in DataTexture is too big ("+y.width+"x"+y.height+")."),R}return R}function g(R){return R.generateMipmaps}function _(R){s.generateMipmap(R)}function x(R){return R.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?s.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function S(R,T,C,U,y,D=!1){if(R!==null){if(s[R]!==void 0)return s[R];re("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let N;U&&(N=e.get("EXT_texture_norm16"),N||re("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let A=T;if(T===s.RED&&(C===s.FLOAT&&(A=s.R32F),C===s.HALF_FLOAT&&(A=s.R16F),C===s.UNSIGNED_BYTE&&(A=s.R8),C===s.UNSIGNED_SHORT&&N&&(A=N.R16_EXT),C===s.SHORT&&N&&(A=N.R16_SNORM_EXT)),T===s.RED_INTEGER&&(C===s.UNSIGNED_BYTE&&(A=s.R8UI),C===s.UNSIGNED_SHORT&&(A=s.R16UI),C===s.UNSIGNED_INT&&(A=s.R32UI),C===s.BYTE&&(A=s.R8I),C===s.SHORT&&(A=s.R16I),C===s.INT&&(A=s.R32I)),T===s.RG&&(C===s.FLOAT&&(A=s.RG32F),C===s.HALF_FLOAT&&(A=s.RG16F),C===s.UNSIGNED_BYTE&&(A=s.RG8),C===s.UNSIGNED_SHORT&&N&&(A=N.RG16_EXT),C===s.SHORT&&N&&(A=N.RG16_SNORM_EXT)),T===s.RG_INTEGER&&(C===s.UNSIGNED_BYTE&&(A=s.RG8UI),C===s.UNSIGNED_SHORT&&(A=s.RG16UI),C===s.UNSIGNED_INT&&(A=s.RG32UI),C===s.BYTE&&(A=s.RG8I),C===s.SHORT&&(A=s.RG16I),C===s.INT&&(A=s.RG32I)),T===s.RGB_INTEGER&&(C===s.UNSIGNED_BYTE&&(A=s.RGB8UI),C===s.UNSIGNED_SHORT&&(A=s.RGB16UI),C===s.UNSIGNED_INT&&(A=s.RGB32UI),C===s.BYTE&&(A=s.RGB8I),C===s.SHORT&&(A=s.RGB16I),C===s.INT&&(A=s.RGB32I)),T===s.RGBA_INTEGER&&(C===s.UNSIGNED_BYTE&&(A=s.RGBA8UI),C===s.UNSIGNED_SHORT&&(A=s.RGBA16UI),C===s.UNSIGNED_INT&&(A=s.RGBA32UI),C===s.BYTE&&(A=s.RGBA8I),C===s.SHORT&&(A=s.RGBA16I),C===s.INT&&(A=s.RGBA32I)),T===s.RGB&&(C===s.UNSIGNED_SHORT&&N&&(A=N.RGB16_EXT),C===s.SHORT&&N&&(A=N.RGB16_SNORM_EXT),C===s.UNSIGNED_INT_5_9_9_9_REV&&(A=s.RGB9_E5),C===s.UNSIGNED_INT_10F_11F_11F_REV&&(A=s.R11F_G11F_B10F)),T===s.RGBA){let k=D?kr:Ge.getTransfer(y);C===s.FLOAT&&(A=s.RGBA32F),C===s.HALF_FLOAT&&(A=s.RGBA16F),C===s.UNSIGNED_BYTE&&(A=k===Ze?s.SRGB8_ALPHA8:s.RGBA8),C===s.UNSIGNED_SHORT&&N&&(A=N.RGBA16_EXT),C===s.SHORT&&N&&(A=N.RGBA16_SNORM_EXT),C===s.UNSIGNED_SHORT_4_4_4_4&&(A=s.RGBA4),C===s.UNSIGNED_SHORT_5_5_5_1&&(A=s.RGB5_A1)}return A!==s.R16F&&A!==s.R32F&&A!==s.RG16F&&A!==s.RG32F&&A!==s.RGBA16F&&A!==s.RGBA32F||e.get("EXT_color_buffer_float"),A}function b(R,T){let C;return R?T===null||T===Ei||T===cr?C=s.DEPTH24_STENCIL8:T===Dt?C=s.DEPTH32F_STENCIL8:T===lr&&(C=s.DEPTH24_STENCIL8,re("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):T===null||T===Ei||T===cr?C=s.DEPTH_COMPONENT24:T===Dt?C=s.DEPTH_COMPONENT32F:T===lr&&(C=s.DEPTH_COMPONENT16),C}function M(R,T){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Lt&&R.minFilter!==at?Math.log2(Math.max(T.width,T.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?T.mipmaps.length:1}function I(R){let T=R.target;T.removeEventListener("dispose",I),(function(C){let U=i.get(C);if(U.__webglInit===void 0)return;let y=C.source,D=p.get(y);if(D){let N=D[U.__cacheKey];N.usedTimes--,N.usedTimes===0&&P(C),Object.keys(D).length===0&&p.delete(y)}i.remove(C)})(T),T.isVideoTexture&&h.delete(T),T.isHTMLTexture&&u.delete(T)}function F(R){let T=R.target;T.removeEventListener("dispose",F),(function(C){let U=i.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),i.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let D=0;D<6;D++){if(Array.isArray(U.__webglFramebuffer[D]))for(let N=0;N0&&C.__version!==R.version){let U=R.image;if(U===null)re("WebGLRenderer: Texture marked for update but no image data found.");else{if(U.complete!==!1)return void le(C,R,T);re("WebGLRenderer: Texture marked for update but image is incomplete")}}else R.isExternalTexture&&(C.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,C.__webglTexture,s.TEXTURE0+T)}let O={[Or]:s.REPEAT,[ei]:s.CLAMP_TO_EDGE,[Br]:s.MIRRORED_REPEAT},j={[Lt]:s.NEAREST,[xd]:s.NEAREST_MIPMAP_NEAREST,[Ss]:s.NEAREST_MIPMAP_LINEAR,[at]:s.LINEAR,[ho]:s.LINEAR_MIPMAP_NEAREST,[zi]:s.LINEAR_MIPMAP_LINEAR},G={[Td]:s.NEVER,[Rd]:s.ALWAYS,[Ed]:s.LESS,[So]:s.LEQUAL,[Ad]:s.EQUAL,[bo]:s.GEQUAL,[wd]:s.GREATER,[Cd]:s.NOTEQUAL};function z(R,T){if(T.type!==Dt||e.has("OES_texture_float_linear")!==!1||T.magFilter!==at&&T.magFilter!==ho&&T.magFilter!==Ss&&T.magFilter!==zi&&T.minFilter!==at&&T.minFilter!==ho&&T.minFilter!==Ss&&T.minFilter!==zi||re("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(R,s.TEXTURE_WRAP_S,O[T.wrapS]),s.texParameteri(R,s.TEXTURE_WRAP_T,O[T.wrapT]),R!==s.TEXTURE_3D&&R!==s.TEXTURE_2D_ARRAY||s.texParameteri(R,s.TEXTURE_WRAP_R,O[T.wrapR]),s.texParameteri(R,s.TEXTURE_MAG_FILTER,j[T.magFilter]),s.texParameteri(R,s.TEXTURE_MIN_FILTER,j[T.minFilter]),T.compareFunction&&(s.texParameteri(R,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(R,s.TEXTURE_COMPARE_FUNC,G[T.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(T.magFilter===Lt||T.minFilter!==Ss&&T.minFilter!==zi||T.type===Dt&&e.has("OES_texture_float_linear")===!1)return;if(T.anisotropy>1||i.get(T).__currentAnisotropy){let C=e.get("EXT_texture_filter_anisotropic");s.texParameterf(R,C.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(T.anisotropy,n.getMaxAnisotropy())),i.get(T).__currentAnisotropy=T.anisotropy}}}function q(R,T){let C=!1;R.__webglInit===void 0&&(R.__webglInit=!0,T.addEventListener("dispose",I));let U=T.source,y=p.get(U);y===void 0&&(y={},p.set(U,y));let D=(function(N){let A=[];return A.push(N.wrapS),A.push(N.wrapT),A.push(N.wrapR||0),A.push(N.magFilter),A.push(N.minFilter),A.push(N.anisotropy),A.push(N.internalFormat),A.push(N.format),A.push(N.type),A.push(N.generateMipmaps),A.push(N.premultiplyAlpha),A.push(N.flipY),A.push(N.unpackAlignment),A.push(N.colorSpace),A.join()})(T);if(D!==R.__cacheKey){y[D]===void 0&&(y[D]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,C=!0),y[D].usedTimes++;let N=y[R.__cacheKey];N!==void 0&&(y[R.__cacheKey].usedTimes--,N.usedTimes===0&&P(T)),R.__cacheKey=D,R.__webglTexture=y[D].texture}return C}function X(R,T,C){return Math.floor(Math.floor(R/C)/T)}function le(R,T,C){let U=s.TEXTURE_2D;(T.isDataArrayTexture||T.isCompressedArrayTexture)&&(U=s.TEXTURE_2D_ARRAY),T.isData3DTexture&&(U=s.TEXTURE_3D);let y=q(R,T),D=T.source;t.bindTexture(U,R.__webglTexture,s.TEXTURE0+C);let N=i.get(D);if(D.version!==N.__version||y===!0){if(t.activeTexture(s.TEXTURE0+C),!(typeof ImageBitmap<"u"&&T.image instanceof ImageBitmap)){let ae=Ge.getPrimaries(Ge.workingColorSpace),Te=T.colorSpace===In?null:Ge.getPrimaries(T.colorSpace),ke=T.colorSpace===In||ae===Te?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,T.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,T.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ke)}t.pixelStorei(s.UNPACK_ALIGNMENT,T.unpackAlignment);let A=v(T.image,!1,n.maxTextureSize);A=Ve(T,A);let k=r.convert(T.format,T.colorSpace),W=r.convert(T.type),K,ee=S(T.internalFormat,k,W,T.normalized,T.colorSpace,T.isVideoTexture);z(U,T);let fe=T.mipmaps,Z=T.isVideoTexture!==!0,_e=N.__version===void 0||y===!0,he=D.dataReady,ge=M(T,A);if(T.isDepthTexture)ee=b(T.format===Cn,T.type),_e&&(Z?t.texStorage2D(s.TEXTURE_2D,1,ee,A.width,A.height):t.texImage2D(s.TEXTURE_2D,0,ee,A.width,A.height,0,k,W,null));else if(T.isDataTexture)if(fe.length>0){Z&&_e&&t.texStorage2D(s.TEXTURE_2D,ge,ee,fe[0].width,fe[0].height);for(let ae=0,Te=fe.length;aeIe.start-Qe.start);let tt=0;for(let Ie=1;Ie0){let ke=Nh(K.width,K.height,T.format,T.type);for(let et of T.layerUpdates){let je=K.data.subarray(et*ke/K.data.BYTES_PER_ELEMENT,(et+1)*ke/K.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ae,0,0,et,K.width,K.height,1,k,je)}T.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ae,0,0,0,K.width,K.height,A.depth,k,K.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ae,ee,K.width,K.height,A.depth,0,K.data,0,0);else re("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Z?he&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ae,0,0,0,K.width,K.height,A.depth,k,W,K.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ae,ee,K.width,K.height,A.depth,0,k,W,K.data)}else{Z&&_e&&t.texStorage2D(s.TEXTURE_2D,ge,ee,fe[0].width,fe[0].height);for(let ae=0,Te=fe.length;ae0){let ae=Nh(A.width,A.height,T.format,T.type);for(let Te of T.layerUpdates){let ke=A.data.subarray(Te*ae/A.data.BYTES_PER_ELEMENT,(Te+1)*ae/A.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Te,A.width,A.height,1,k,W,ke)}T.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,A.width,A.height,A.depth,k,W,A.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,ee,A.width,A.height,A.depth,0,k,W,A.data);else if(T.isData3DTexture)Z?(_e&&t.texStorage3D(s.TEXTURE_3D,ge,ee,A.width,A.height,A.depth),he&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,A.width,A.height,A.depth,k,W,A.data)):t.texImage3D(s.TEXTURE_3D,0,ee,A.width,A.height,A.depth,0,k,W,A.data);else if(T.isFramebufferTexture){if(_e)if(Z)t.texStorage2D(s.TEXTURE_2D,ge,ee,A.width,A.height);else{let ae=A.width,Te=A.height;for(let ke=0;ke>=1,Te>>=1}}else if(T.isHTMLTexture){if("texElementImage2D"in s){let ae=s.canvas;if(ae.hasAttribute("layoutsubtree")||ae.setAttribute("layoutsubtree","true"),A.parentNode!==ae)return ae.appendChild(A),u.add(T),ae.onpaint=tt=>{let Ft=tt.changedElements;for(let Ee of u)Ft.includes(Ee.image)&&(Ee.needsUpdate=!0)},void ae.requestPaint();let Te=0,ke=s.RGBA,et=s.RGBA,je=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,Te,ke,et,je,A),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(fe.length>0){if(Z&&_e){let ae=ie(fe[0]);t.texStorage2D(s.TEXTURE_2D,ge,ee,ae.width,ae.height)}for(let ae=0,Te=fe.length;ae>D),fe=Math.max(1,T.height>>D);y===s.TEXTURE_3D||y===s.TEXTURE_2D_ARRAY?t.texImage3D(y,D,k,ee,fe,T.depth,0,N,A,null):t.texImage2D(y,D,k,ee,fe,0,N,A,null)}t.bindFramebuffer(s.FRAMEBUFFER,R),ye(T)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,U,y,K.__webglTexture,0,ne(T)):(y===s.TEXTURE_2D||y>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&y<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,U,y,K.__webglTexture,D),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ae(R,T,C){if(s.bindRenderbuffer(s.RENDERBUFFER,R),T.depthBuffer){let U=T.depthTexture,y=U&&U.isDepthTexture?U.type:null,D=b(T.stencilBuffer,y),N=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;ye(T)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ne(T),D,T.width,T.height):C?s.renderbufferStorageMultisample(s.RENDERBUFFER,ne(T),D,T.width,T.height):s.renderbufferStorage(s.RENDERBUFFER,D,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,N,s.RENDERBUFFER,R)}else{let U=T.textures;for(let y=0;y{delete T.__boundDepthTexture,delete T.__depthDisposeCallback,U.removeEventListener("dispose",y)};U.addEventListener("dispose",y),T.__depthDisposeCallback=y}T.__boundDepthTexture=U}if(R.depthTexture&&!T.__autoAllocateDepthBuffer)if(C)for(let U=0;U<6;U++)be(T.__webglFramebuffer[U],R,U);else{let U=R.texture.mipmaps;U&&U.length>0?be(T.__webglFramebuffer[0],R,0):be(T.__webglFramebuffer,R,0)}else if(C){T.__webglDepthbuffer=[];for(let U=0;U<6;U++)if(t.bindFramebuffer(s.FRAMEBUFFER,T.__webglFramebuffer[U]),T.__webglDepthbuffer[U]===void 0)T.__webglDepthbuffer[U]=s.createRenderbuffer(),Ae(T.__webglDepthbuffer[U],R,!1);else{let y=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,D=T.__webglDepthbuffer[U];s.bindRenderbuffer(s.RENDERBUFFER,D),s.framebufferRenderbuffer(s.FRAMEBUFFER,y,s.RENDERBUFFER,D)}}else{let U=R.texture.mipmaps;if(U&&U.length>0?t.bindFramebuffer(s.FRAMEBUFFER,T.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,T.__webglFramebuffer),T.__webglDepthbuffer===void 0)T.__webglDepthbuffer=s.createRenderbuffer(),Ae(T.__webglDepthbuffer,R,!1);else{let y=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,D=T.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,D),s.framebufferRenderbuffer(s.FRAMEBUFFER,y,s.RENDERBUFFER,D)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}let te=[],oe=[];function ne(R){return Math.min(n.maxSamples,R.samples)}function ye(R){let T=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&T.__useRenderToTexture!==!1}function Ve(R,T){let C=R.colorSpace,U=R.format,y=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||C!==Vr&&C!==In&&(Ge.getTransfer(C)===Ze?U===Vt&&y===Jt||re("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ve("WebGLTextures: Unsupported texture color space:",C)),T}function ie(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(l.width=R.displayWidth,l.height=R.displayHeight):(l.width=R.width,l.height=R.height),l}this.allocateTextureUnit=function(){let R=L;return R>=n.maxTextures&&re("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+n.maxTextures),L+=1,R},this.resetTextureUnits=function(){L=0},this.getTextureUnits=function(){return L},this.setTextureUnits=function(R){L=R},this.setTexture2D=H,this.setTexture2DArray=function(R,T){let C=i.get(R);R.isRenderTargetTexture===!1&&R.version>0&&C.__version!==R.version?le(C,R,T):(R.isExternalTexture&&(C.__webglTexture=R.sourceTexture?R.sourceTexture:null),t.bindTexture(s.TEXTURE_2D_ARRAY,C.__webglTexture,s.TEXTURE0+T))},this.setTexture3D=function(R,T){let C=i.get(R);R.isRenderTargetTexture===!1&&R.version>0&&C.__version!==R.version?le(C,R,T):t.bindTexture(s.TEXTURE_3D,C.__webglTexture,s.TEXTURE0+T)},this.setTextureCube=function(R,T){let C=i.get(R);R.isCubeDepthTexture!==!0&&R.version>0&&C.__version!==R.version?(function(U,y,D){if(y.image.length!==6)return;let N=q(U,y),A=y.source;t.bindTexture(s.TEXTURE_CUBE_MAP,U.__webglTexture,s.TEXTURE0+D);let k=i.get(A);if(A.version!==k.__version||N===!0){t.activeTexture(s.TEXTURE0+D);let W=Ge.getPrimaries(Ge.workingColorSpace),K=y.colorSpace===In?null:Ge.getPrimaries(y.colorSpace),ee=y.colorSpace===In||W===K?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,y.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ee);let fe=y.isCompressedTexture||y.image[0].isCompressedTexture,Z=y.image[0]&&y.image[0].isDataTexture,_e=[];for(let Ee=0;Ee<6;Ee++)_e[Ee]=fe||Z?Z?y.image[Ee].image:y.image[Ee]:v(y.image[Ee],!0,n.maxCubemapSize),_e[Ee]=Ve(y,_e[Ee]);let he=_e[0],ge=r.convert(y.format,y.colorSpace),ae=r.convert(y.type),Te=S(y.internalFormat,ge,ae,y.normalized,y.colorSpace),ke=y.isVideoTexture!==!0,et=k.__version===void 0||N===!0,je=A.dataReady,tt,Ft=M(y,he);if(z(s.TEXTURE_CUBE_MAP,y),fe){ke&&et&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Ft,Te,he.width,he.height);for(let Ee=0;Ee<6;Ee++){tt=_e[Ee].mipmaps;for(let ze=0;ze0&&Ft++;let Ee=ie(_e[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Ft,Te,Ee.width,Ee.height)}for(let Ee=0;Ee<6;Ee++)if(Z){ke?je&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,0,0,0,_e[Ee].width,_e[Ee].height,ge,ae,_e[Ee].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,0,Te,_e[Ee].width,_e[Ee].height,0,ge,ae,_e[Ee].data);for(let ze=0;ze1;if(N||(U.__webglTexture===void 0&&(U.__webglTexture=s.createTexture()),U.__version=T.version,a.memory.textures++),D){C.__webglFramebuffer=[];for(let A=0;A<6;A++)if(T.mipmaps&&T.mipmaps.length>0){C.__webglFramebuffer[A]=[];for(let k=0;k0){C.__webglFramebuffer=[];for(let A=0;A0&&ye(R)===!1){C.__webglMultisampledFramebuffer=s.createFramebuffer(),C.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,C.__webglMultisampledFramebuffer);for(let A=0;A0)for(let k=0;k0)for(let k=0;k0){if(ye(R)===!1){let T=R.textures,C=R.width,U=R.height,y=s.COLOR_BUFFER_BIT,D=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,N=i.get(R),A=T.length>1;if(A)for(let W=0;W0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,N.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,N.__webglFramebuffer);for(let W=0;W= 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; + + } + +}`,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ot(new nr(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Kd=class extends Yt{constructor(e,t){super();let i=this,n=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,p=null,f=null,m=typeof XRWebGLBinding<"u",v=new Jd,g={},_=t.getContextAttributes(),x=null,S=null,b=[],M=[],I=new Q,F=null,P=new ft;P.viewport=new $e;let L=new ft;L.viewport=new $e;let H=[P,L],O=new to,j=null,G=null;function z(te){let oe=M.indexOf(te.inputSource);if(oe===-1)return;let ne=b[oe];ne!==void 0&&(ne.update(te.inputSource,te.frame,l||a),ne.dispatchEvent({type:te.type,data:te.inputSource}))}function q(){n.removeEventListener("select",z),n.removeEventListener("selectstart",z),n.removeEventListener("selectend",z),n.removeEventListener("squeeze",z),n.removeEventListener("squeezestart",z),n.removeEventListener("squeezeend",z),n.removeEventListener("end",q),n.removeEventListener("inputsourceschange",X);for(let te=0;te=0&&(M[ye]=null,b[ye].disconnect(ne))}for(let oe=0;oe=M.length){M.push(ne),ye=ie;break}if(M[ie]===null){M[ie]=ne,ye=ie;break}}if(ye===-1)break}let Ve=b[ye];Ve&&Ve.connect(ne)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let oe=b[te];return oe===void 0&&(oe=new Kn,b[te]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(te){let oe=b[te];return oe===void 0&&(oe=new Kn,b[te]=oe),oe.getGripSpace()},this.getHand=function(te){let oe=b[te];return oe===void 0&&(oe=new Kn,b[te]=oe),oe.getHandSpace()},this.setFramebufferScaleFactor=function(te){r=te,i.isPresenting===!0&&re("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){o=te,i.isPresenting===!0&&re("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(te){l=te},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(n,t)),u},this.getFrame=function(){return f},this.getSession=function(){return n},this.setSession=async function(te){if(n=te,n!==null){if(x=e.getRenderTarget(),n.addEventListener("select",z),n.addEventListener("selectstart",z),n.addEventListener("selectend",z),n.addEventListener("squeeze",z),n.addEventListener("squeezestart",z),n.addEventListener("squeezeend",z),n.addEventListener("end",q),n.addEventListener("inputsourceschange",X),_.xrCompatible!==!0&&await t.makeXRCompatible(),F=e.getPixelRatio(),e.getSize(I),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let oe=null,ne=null,ye=null;_.depth&&(ye=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,oe=_.stencil?Cn:rn,ne=_.stencil?cr:Ei);let Ve={colorFormat:t.RGBA8,depthFormat:ye,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Ve),n.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new Nt(d.textureWidth,d.textureHeight,{format:Vt,type:Jt,depthTexture:new Bi(d.textureWidth,d.textureHeight,ne,void 0,void 0,void 0,void 0,void 0,void 0,oe),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{let oe={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(n,t,oe),n.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),S=new Nt(p.framebufferWidth,p.framebufferHeight,{format:Vt,type:Jt,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await n.requestReferenceSpace(o),Se.setContext(n),Se.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};let le=new w,me=new w;function Ae(te,oe){oe===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(oe.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(n===null)return;let oe=te.near,ne=te.far;v.texture!==null&&(v.depthNear>0&&(oe=v.depthNear),v.depthFar>0&&(ne=v.depthFar)),O.near=L.near=P.near=oe,O.far=L.far=P.far=ne,j===O.near&&G===O.far||(n.updateRenderState({depthNear:O.near,depthFar:O.far}),j=O.near,G=O.far),O.layers.mask=6|te.layers.mask,P.layers.mask=-5&O.layers.mask,L.layers.mask=-3&O.layers.mask;let ye=te.parent,Ve=O.cameras;Ae(O,ye);for(let ie=0;ie0&&(n.alphaTest.value=r.alphaTest);let a=e.get(r),o=a.envMap,c=a.envMapRotation;o&&(n.envMap.value=o,n.envMapRotation.value.setFromMatrix4(nv.makeRotationFromEuler(c)).transpose(),o.isCubeTexture&&o.isRenderTargetTexture===!1&&n.envMapRotation.value.premultiply(pg),n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap&&(n.lightMap.value=r.lightMap,n.lightMapIntensity.value=r.lightMapIntensity,t(r.lightMap,n.lightMapTransform)),r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity,t(r.aoMap,n.aoMapTransform))}return{refreshFogUniforms:function(n,r){r.color.getRGB(n.fogColor.value,Ld(s)),r.isFog?(n.fogNear.value=r.near,n.fogFar.value=r.far):r.isFogExp2&&(n.fogDensity.value=r.density)},refreshMaterialUniforms:function(n,r,a,o,c){r.isNodeMaterial?r.uniformsNeedUpdate=!1:r.isMeshBasicMaterial?i(n,r):r.isMeshLambertMaterial?(i(n,r),r.envMap&&(n.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(i(n,r),(function(l,h){h.gradientMap&&(l.gradientMap.value=h.gradientMap)})(n,r)):r.isMeshPhongMaterial?(i(n,r),(function(l,h){l.specular.value.copy(h.specular),l.shininess.value=Math.max(h.shininess,1e-4)})(n,r),r.envMap&&(n.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(i(n,r),(function(l,h){l.metalness.value=h.metalness,h.metalnessMap&&(l.metalnessMap.value=h.metalnessMap,t(h.metalnessMap,l.metalnessMapTransform)),l.roughness.value=h.roughness,h.roughnessMap&&(l.roughnessMap.value=h.roughnessMap,t(h.roughnessMap,l.roughnessMapTransform)),h.envMap&&(l.envMapIntensity.value=h.envMapIntensity)})(n,r),r.isMeshPhysicalMaterial&&(function(l,h,u){l.ior.value=h.ior,h.sheen>0&&(l.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),l.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(l.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,l.sheenColorMapTransform)),h.sheenRoughnessMap&&(l.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,l.sheenRoughnessMapTransform))),h.clearcoat>0&&(l.clearcoat.value=h.clearcoat,l.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(l.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,l.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(l.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,l.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(l.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,l.clearcoatNormalMapTransform),l.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===Ht&&l.clearcoatNormalScale.value.negate())),h.dispersion>0&&(l.dispersion.value=h.dispersion),h.iridescence>0&&(l.iridescence.value=h.iridescence,l.iridescenceIOR.value=h.iridescenceIOR,l.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],l.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(l.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,l.iridescenceMapTransform)),h.iridescenceThicknessMap&&(l.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,l.iridescenceThicknessMapTransform))),h.transmission>0&&(l.transmission.value=h.transmission,l.transmissionSamplerMap.value=u.texture,l.transmissionSamplerSize.value.set(u.width,u.height),h.transmissionMap&&(l.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,l.transmissionMapTransform)),l.thickness.value=h.thickness,h.thicknessMap&&(l.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,l.thicknessMapTransform)),l.attenuationDistance.value=h.attenuationDistance,l.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(l.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(l.anisotropyMap.value=h.anisotropyMap,t(h.anisotropyMap,l.anisotropyMapTransform))),l.specularIntensity.value=h.specularIntensity,l.specularColor.value.copy(h.specularColor),h.specularColorMap&&(l.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,l.specularColorMapTransform)),h.specularIntensityMap&&(l.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,l.specularIntensityMapTransform))})(n,r,c)):r.isMeshMatcapMaterial?(i(n,r),(function(l,h){h.matcap&&(l.matcap.value=h.matcap)})(n,r)):r.isMeshDepthMaterial?i(n,r):r.isMeshDistanceMaterial?(i(n,r),(function(l,h){let u=e.get(h).light;l.referencePosition.value.setFromMatrixPosition(u.matrixWorld),l.nearDistance.value=u.shadow.camera.near,l.farDistance.value=u.shadow.camera.far})(n,r)):r.isMeshNormalMaterial?i(n,r):r.isLineBasicMaterial?((function(l,h){l.diffuse.value.copy(h.color),l.opacity.value=h.opacity,h.map&&(l.map.value=h.map,t(h.map,l.mapTransform))})(n,r),r.isLineDashedMaterial&&(function(l,h){l.dashSize.value=h.dashSize,l.totalSize.value=h.dashSize+h.gapSize,l.scale.value=h.scale})(n,r)):r.isPointsMaterial?(function(l,h,u,d){l.diffuse.value.copy(h.color),l.opacity.value=h.opacity,l.size.value=h.size*u,l.scale.value=.5*d,h.map&&(l.map.value=h.map,t(h.map,l.uvTransform)),h.alphaMap&&(l.alphaMap.value=h.alphaMap,t(h.alphaMap,l.alphaMapTransform)),h.alphaTest>0&&(l.alphaTest.value=h.alphaTest)})(n,r,a,o):r.isSpriteMaterial?(function(l,h){l.diffuse.value.copy(h.color),l.opacity.value=h.opacity,l.rotation.value=h.rotation,h.map&&(l.map.value=h.map,t(h.map,l.mapTransform)),h.alphaMap&&(l.alphaMap.value=h.alphaMap,t(h.alphaMap,l.alphaMapTransform)),h.alphaTest>0&&(l.alphaTest.value=h.alphaTest)})(n,r):r.isShadowMaterial?(n.color.value.copy(r.color),n.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function sv(s,e,t,i){let n={},r={},a=[],o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(u,d,p,f){let m=u.value,v=d+"_"+p;if(f[v]===void 0)return typeof m=="number"||typeof m=="boolean"?f[v]=m:ArrayBuffer.isView(m)?f[v]=m.slice():f[v]=m.clone(),!0;{let g=f[v];if(typeof m=="number"||typeof m=="boolean"){if(g!==m)return f[v]=m,!0}else{if(ArrayBuffer.isView(m))return!0;if(g.equals(m)===!1)return g.copy(m),!0}}return!1}function l(u){let d={boundary:0,storage:0};return typeof u=="number"||typeof u=="boolean"?(d.boundary=4,d.storage=4):u.isVector2?(d.boundary=8,d.storage=8):u.isVector3||u.isColor?(d.boundary=16,d.storage=12):u.isVector4?(d.boundary=16,d.storage=16):u.isMatrix3?(d.boundary=48,d.storage=48):u.isMatrix4?(d.boundary=64,d.storage=64):u.isTexture?re("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(u)?(d.boundary=16,d.storage=u.byteLength):re("WebGLRenderer: Unsupported uniform value type.",u),d}function h(u){let d=u.target;d.removeEventListener("dispose",h);let p=a.indexOf(d.__bindingPointIndex);a.splice(p,1),s.deleteBuffer(n[d.id]),delete n[d.id],delete r[d.id]}return{bind:function(u,d){let p=d.program;i.uniformBlockBinding(u,p)},update:function(u,d){let p=n[u.id];p===void 0&&((function(v){let g=v.uniforms,_=0,x=16;for(let b=0,M=g.length;b0&&(_+=x-S),v.__size=_,v.__cache={}})(u),p=(function(v){let g=(function(){for(let b=0;b0),kh=!!At.morphAttributes.position,pr=!!At.morphAttributes.normal,_g=!!At.morphAttributes.color,pp=li;Le.toneMapped&&(z!==null&&z.isXRRenderTarget!==!0||(pp=L.toneMapping));let mp=At.morphAttributes.position||At.morphAttributes.normal||At.morphAttributes.color,vg=mp!==void 0?mp.length:0,Ne=he.get(Le),Ln=M.state.lights;if(U===!0&&(y===!0||He!==X)){let pt=He===X&&Le.id===q;ze.setState(Le,He,pt)}let hi=!1;Le.version===Ne.__version?Ne.needsLights&&Ne.lightsStateVersion!==Ln.state.version||Ne.outputColorSpace!==Lo||Fe.isBatchedMesh&&Ne.batching===!1?hi=!0:Fe.isBatchedMesh||Ne.batching!==!0?Fe.isBatchedMesh&&Ne.batchingColor===!0&&Fe.colorTexture===null||Fe.isBatchedMesh&&Ne.batchingColor===!1&&Fe.colorTexture!==null||Fe.isInstancedMesh&&Ne.instancing===!1?hi=!0:Fe.isInstancedMesh||Ne.instancing!==!0?Fe.isSkinnedMesh&&Ne.skinning===!1?hi=!0:Fe.isSkinnedMesh||Ne.skinning!==!0?Fe.isInstancedMesh&&Ne.instancingColor===!0&&Fe.instanceColor===null||Fe.isInstancedMesh&&Ne.instancingColor===!1&&Fe.instanceColor!==null||Fe.isInstancedMesh&&Ne.instancingMorph===!0&&Fe.morphTexture===null||Fe.isInstancedMesh&&Ne.instancingMorph===!1&&Fe.morphTexture!==null||Ne.envMap!==Ri||Le.fog===!0&&Ne.fog!==ci?hi=!0:Ne.numClippingPlanes===void 0||Ne.numClippingPlanes===ze.numPlanes&&Ne.numIntersection===ze.numIntersection?(Ne.vertexAlphas!==dr||Ne.vertexTangents!==Vi||Ne.morphTargets!==kh||Ne.morphNormals!==pr||Ne.morphColors!==_g||Ne.toneMapping!==pp||Ne.morphTargetsCount!==vg||!!Ne.lightProbeGrid!=M.state.lightProbeGridArray.length>0)&&(hi=!0):hi=!0:hi=!0:hi=!0:hi=!0:(hi=!0,Ne.__version=Le.version);let sn=Ne.currentProgram;hi===!0&&(sn=Po(Le,nt,Fe),O&&Le.isNodeMaterial&&O.onUpdateProgram(Le,sn,Ne));let fp=!1,mr=!1,Hh=!1,rt=sn.getUniforms(),ni=Ne.uniforms;if(Z.useProgram(sn.program)&&(fp=!0,mr=!0,Hh=!0),Le.id!==q&&(q=Le.id,mr=!0),Ne.needsLights){let pt=(function(Pi,Xh){if(Pi.length===0)return null;if(Pi.length===1)return Pi[0].texture!==null?Pi[0]:null;S.setFromMatrixPosition(Xh.matrixWorld);for(let fr=0,xg=Pi.length;fr0&&rt.setValue(B,"directionalShadowMap",Ln.state.directionalShadowMap,ge),Ln.state.spotShadowMap.length>0&&rt.setValue(B,"spotShadowMap",Ln.state.spotShadowMap,ge),Ln.state.pointShadowMap.length>0&&rt.setValue(B,"pointShadowMap",Ln.state.pointShadowMap,ge)),Fe.isSkinnedMesh){rt.setOptional(B,Fe,"bindMatrix"),rt.setOptional(B,Fe,"bindMatrixInverse");let pt=Fe.skeleton;pt&&(pt.boneTexture===null&&pt.computeBoneTexture(),rt.setValue(B,"boneTexture",pt.boneTexture,ge))}Fe.isBatchedMesh&&(rt.setOptional(B,Fe,"batchingTexture"),rt.setValue(B,"batchingTexture",Fe._matricesTexture,ge),rt.setOptional(B,Fe,"batchingIdTexture"),rt.setValue(B,"batchingIdTexture",Fe._indirectTexture,ge),rt.setOptional(B,Fe,"batchingColorTexture"),Fe._colorsTexture!==null&&rt.setValue(B,"batchingColorTexture",Fe._colorsTexture,ge));let Wh=At.morphAttributes;if(Wh.position===void 0&&Wh.normal===void 0&&Wh.color===void 0||Ct.update(Fe,At,sn),(mr||Ne.receiveShadow!==Fe.receiveShadow)&&(Ne.receiveShadow=Fe.receiveShadow,rt.setValue(B,"receiveShadow",Fe.receiveShadow)),(Le.isMeshStandardMaterial||Le.isMeshLambertMaterial||Le.isMeshPhongMaterial)&&Le.envMap===null&&nt.environment!==null&&(ni.envMapIntensity.value=nt.environmentIntensity),ni.dfgLUT!==void 0&&(ni.dfgLUT.value=(Gi===null&&(Gi=new qt(av,16,16,Rn,Ai),Gi.name="DFG_LUT",Gi.minFilter=at,Gi.magFilter=at,Gi.wrapS=ei,Gi.wrapT=ei,Gi.generateMipmaps=!1,Gi.needsUpdate=!0),Gi)),mr){if(rt.setValue(B,"toneMappingExposure",L.toneMappingExposure),Ne.needsLights&&(ui=Hh,(Ii=ni).ambientLightColor.needsUpdate=ui,Ii.lightProbe.needsUpdate=ui,Ii.directionalLights.needsUpdate=ui,Ii.directionalLightShadows.needsUpdate=ui,Ii.pointLights.needsUpdate=ui,Ii.pointLightShadows.needsUpdate=ui,Ii.spotLights.needsUpdate=ui,Ii.spotLightShadows.needsUpdate=ui,Ii.rectAreaLights.needsUpdate=ui,Ii.hemisphereLights.needsUpdate=ui),ci&&Le.fog===!0&&tt.refreshFogUniforms(ni,ci),tt.refreshMaterialUniforms(ni,Le,ne,oe,M.state.transmissionRenderTarget[He.id]),Ne.needsLights&&Ne.lightProbeGrid){let pt=Ne.lightProbeGrid;ni.probesSH.value=pt.texture,ni.probesMin.value.copy(pt.boundingBox.min),ni.probesMax.value.copy(pt.boundingBox.max),ni.probesResolution.value.copy(pt.resolution)}Es.upload(B,up(Ne),ni,ge)}var Ii,ui;if(Le.isShaderMaterial&&Le.uniformsNeedUpdate===!0&&(Es.upload(B,up(Ne),ni,ge),Le.uniformsNeedUpdate=!1),Le.isSpriteMaterial&&rt.setValue(B,"center",Fe.center),rt.setValue(B,"modelViewMatrix",Fe.modelViewMatrix),rt.setValue(B,"normalMatrix",Fe.normalMatrix),rt.setValue(B,"modelMatrix",Fe.matrixWorld),Le.uniformsGroups!==void 0){let pt=Le.uniformsGroups;for(let Pi=0,Xh=pt.length;Pi{function se(){$.forEach(function(de){he.get(de).currentProgram.isReady()&&$.delete(de)}),$.size!==0?setTimeout(se,10):J(E)}ee.get("KHR_parallel_shader_compile")!==null?se():setTimeout(se,10)})};let zh=null;function ap(){Pn.stop()}function op(){Pn.start()}let Pn=new ag;function Gh(E,V,Y,$){if(E.visible===!1)return;if(E.layers.test(V.layers)){if(E.isGroup)Y=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(V);else if(E.isLightProbeGrid)M.pushLightProbeGrid(E);else if(E.isLight)M.pushLight(E),E.castShadow&&M.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||C.intersectsSprite(E)){$&&A.setFromMatrixPosition(E.matrixWorld).applyMatrix4(D);let se=et.update(E),de=E.material;de.visible&&b.push(E,se,de,Y,A.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||C.intersectsObject(E))){let se=et.update(E),de=E.material;if($&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),A.copy(E.boundingSphere.center)):(se.boundingSphere===null&&se.computeBoundingSphere(),A.copy(se.boundingSphere.center)),A.applyMatrix4(E.matrixWorld).applyMatrix4(D)),Array.isArray(de)){let xe=se.groups;for(let Me=0,Pe=xe.length;Me0&&Io(J,V,Y),se.length>0&&Io(se,V,Y),de.length>0&&Io(de,V,Y),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function cp(E,V,Y,$){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[$.id]===void 0){let Xe=ee.has("EXT_color_buffer_half_float")||ee.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[$.id]=new Nt(1,1,{generateMipmaps:!0,type:Xe?Ai:Jt,minFilter:zi,samples:Math.max(4,fe.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ge.workingColorSpace})}let J=M.state.transmissionRenderTarget[$.id],se=$.viewport||le;J.setSize(se.z*L.transmissionResolutionScale,se.w*L.transmissionResolutionScale);let de=L.getRenderTarget(),xe=L.getActiveCubeFace(),Me=L.getActiveMipmapLevel();L.setRenderTarget(J),L.getClearColor(be),Se=L.getClearAlpha(),Se<1&&L.setClearColor(16777215,.5),L.clear(),W&&Qe.render(Y);let Pe=L.toneMapping;L.toneMapping=li;let We=$.viewport;if($.viewport!==void 0&&($.viewport=void 0),M.setupLightsView($),U===!0&&ze.setGlobalState(L.clippingPlanes,$),Io(E,Y,$),ge.updateMultisampleRenderTarget(J),ge.updateRenderTargetMipmap(J),ee.has("WEBGL_multisampled_render_to_texture")===!1){let Xe=!1;for(let we=0,qe=V.length;we0,$.currentProgram=Xe,$.uniformsList=null,Xe}function up(E){if(E.uniformsList===null){let V=E.currentProgram.getUniforms();E.uniformsList=Es.seqWithValue(V.seq,E.uniforms)}return E.uniformsList}function dp(E,V){let Y=he.get(E);Y.outputColorSpace=V.outputColorSpace,Y.batching=V.batching,Y.batchingColor=V.batchingColor,Y.instancing=V.instancing,Y.instancingColor=V.instancingColor,Y.instancingMorph=V.instancingMorph,Y.skinning=V.skinning,Y.morphTargets=V.morphTargets,Y.morphNormals=V.morphNormals,Y.morphColors=V.morphColors,Y.morphTargetsCount=V.morphTargetsCount,Y.numClippingPlanes=V.numClippingPlanes,Y.numIntersection=V.numClipIntersection,Y.vertexAlphas=V.vertexAlphas,Y.vertexTangents=V.vertexTangents,Y.toneMapping=V.toneMapping}Pn.setAnimationLoop(function(E){zh&&zh(E)}),typeof self<"u"&&Pn.setContext(self),this.setAnimationLoop=function(E){zh=E,ut.setAnimationLoop(E),E===null?Pn.stop():Pn.start()},ut.addEventListener("sessionstart",ap),ut.addEventListener("sessionend",op),this.render=function(E,V){if(V!==void 0&&V.isCamera!==!0)return void ve("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(H===!0)return;O!==null&&O.renderStart(E,V);let Y=ut.enabled===!0&&ut.isPresenting===!0,$=P!==null&&(z===null||Y)&&P.begin(L,z);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),ut.enabled!==!0||ut.isPresenting!==!0||P!==null&&P.isCompositing()!==!1||(ut.cameraAutoUpdate===!0&&ut.updateCamera(V),V=ut.getCamera()),E.isScene===!0&&E.onBeforeRender(L,E,V,z),M=Ee.get(E,F.length),M.init(V),M.state.textureUnits=ge.getTextureUnits(),F.push(M),D.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),C.setFromProjectionMatrix(D,xi,V.reversedDepth),y=this.localClippingEnabled,U=ze.init(this.clippingPlanes,y),b=Ft.get(E,I.length),b.init(),I.push(b),ut.enabled===!0&&ut.isPresenting===!0){let se=L.xr.getDepthSensingMesh();se!==null&&Gh(se,V,-1/0,L.sortObjects)}Gh(E,V,0,L.sortObjects),b.finish(),L.sortObjects===!0&&b.sort(ye,Ve),W=ut.enabled===!1||ut.isPresenting===!1||ut.hasDepthSensing()===!1,W&&Qe.addToRenderList(b,E),this.info.render.frame++,U===!0&&ze.beginShadows();let J=M.state.shadowsArray;if(Ie.render(J,E,V),U===!0&&ze.endShadows(),this.info.autoReset===!0&&this.info.reset(),($&&P.hasRenderPass())===!1){let se=b.opaque,de=b.transmissive;if(M.setupLights(),V.isArrayCamera){let xe=V.cameras;if(de.length>0)for(let Me=0,Pe=xe.length;Me0&&cp(se,de,E,V),W&&Qe.render(E),lp(b,E,V)}z!==null&&G===0&&(ge.updateMultisampleRenderTarget(z),ge.updateRenderTargetMipmap(z)),$&&P.end(L),E.isScene===!0&&E.onAfterRender(L,E,V),Wt.resetDefaultState(),q=-1,X=null,F.pop(),F.length>0?(M=F[F.length-1],ge.setTextureUnits(M.state.textureUnits),U===!0&&ze.setGlobalState(L.clippingPlanes,M.state.camera)):M=null,I.pop(),b=I.length>0?I[I.length-1]:null,O!==null&&O.renderEnd()},this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return z},this.setRenderTargetTextures=function(E,V,Y){let $=he.get(E);$.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,$.__autoAllocateDepthBuffer===!1&&($.__useRenderToTexture=!1),he.get(E.texture).__webglTexture=V,he.get(E.depthTexture).__webglTexture=$.__autoAllocateDepthBuffer?void 0:Y,$.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,V){let Y=he.get(E);Y.__webglFramebuffer=V,Y.__useDefaultFramebuffer=V===void 0};let mg=B.createFramebuffer();this.setRenderTarget=function(E,V=0,Y=0){z=E,j=V,G=Y;let $=null,J=!1,se=!1;if(E){let de=he.get(E);if(de.__useDefaultFramebuffer!==void 0)return Z.bindFramebuffer(B.FRAMEBUFFER,de.__webglFramebuffer),le.copy(E.viewport),me.copy(E.scissor),Ae=E.scissorTest,Z.viewport(le),Z.scissor(me),Z.setScissorTest(Ae),void(q=-1);if(de.__webglFramebuffer===void 0)ge.setupRenderTarget(E);else if(de.__hasExternalTextures)ge.rebindTextures(E,he.get(E.texture).__webglTexture,he.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){let Pe=E.depthTexture;if(de.__boundDepthTexture!==Pe){if(Pe!==null&&he.has(Pe)&&(E.width!==Pe.image.width||E.height!==Pe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ge.setupDepthRenderbuffer(E)}}let xe=E.texture;(xe.isData3DTexture||xe.isDataArrayTexture||xe.isCompressedArrayTexture)&&(se=!0);let Me=he.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?($=Array.isArray(Me[V])?Me[V][Y]:Me[V],J=!0):$=E.samples>0&&ge.useMultisampledRTT(E)===!1?he.get(E).__webglMultisampledFramebuffer:Array.isArray(Me)?Me[Y]:Me,le.copy(E.viewport),me.copy(E.scissor),Ae=E.scissorTest}else le.copy(ie).multiplyScalar(ne).floor(),me.copy(R).multiplyScalar(ne).floor(),Ae=T;if(Y!==0&&($=mg),Z.bindFramebuffer(B.FRAMEBUFFER,$)&&Z.drawBuffers(E,$),Z.viewport(le),Z.scissor(me),Z.setScissorTest(Ae),J){let de=he.get(E.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+V,de.__webglTexture,Y)}else if(se){let de=V;for(let xe=0;xe1&&B.readBuffer(B.COLOR_ATTACHMENT0+xe),!fe.textureFormatReadable(We))return void ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!fe.textureTypeReadable(Xe))return void ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");V>=0&&V<=E.width-$&&Y>=0&&Y<=E.height-J&&B.readPixels(V,Y,$,J,_t.convert(We),_t.convert(Xe),se)}finally{let Pe=z!==null?he.get(z).__webglFramebuffer:null;Z.bindFramebuffer(B.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(E,V,Y,$,J,se,de,xe=0){if(!E||!E.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Me=he.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&de!==void 0&&(Me=Me[de]),Me){if(V>=0&&V<=E.width-$&&Y>=0&&Y<=E.height-J){Z.bindFramebuffer(B.FRAMEBUFFER,Me);let Pe=E.textures[xe],We=Pe.format,Xe=Pe.type;if(E.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+xe),!fe.textureFormatReadable(We))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!fe.textureTypeReadable(Xe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let we=B.createBuffer();B.bindBuffer(B.PIXEL_PACK_BUFFER,we),B.bufferData(B.PIXEL_PACK_BUFFER,se.byteLength,B.STREAM_READ),B.readPixels(V,Y,$,J,_t.convert(We),_t.convert(Xe),0);let qe=z!==null?he.get(z).__webglFramebuffer:null;Z.bindFramebuffer(B.FRAMEBUFFER,qe);let vt=B.fenceSync(B.SYNC_GPU_COMMANDS_COMPLETE,0);return B.flush(),await Cf(B,vt,4),B.bindBuffer(B.PIXEL_PACK_BUFFER,we),B.getBufferSubData(B.PIXEL_PACK_BUFFER,0,se),B.deleteBuffer(we),B.deleteSync(vt),se}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(E,V=null,Y=0){let $=Math.pow(2,-Y),J=Math.floor(E.image.width*$),se=Math.floor(E.image.height*$),de=V!==null?V.x:0,xe=V!==null?V.y:0;ge.setTexture2D(E,0),B.copyTexSubImage2D(B.TEXTURE_2D,Y,0,0,de,xe,J,se),Z.unbindTexture()};let fg=B.createFramebuffer(),gg=B.createFramebuffer();this.copyTextureToTexture=function(E,V,Y=null,$=null,J=0,se=0){let de,xe,Me,Pe,We,Xe,we,qe,vt,dt=E.isCompressedTexture?E.mipmaps[se]:E.image;if(Y!==null)de=Y.max.x-Y.min.x,xe=Y.max.y-Y.min.y,Me=Y.isBox3?Y.max.z-Y.min.z:1,Pe=Y.min.x,We=Y.min.y,Xe=Y.isBox3?Y.min.z:0;else{let Ri=Math.pow(2,-J);de=Math.floor(dt.width*Ri),xe=Math.floor(dt.height*Ri),Me=E.isDataArrayTexture?dt.depth:E.isData3DTexture?Math.floor(dt.depth*Ri):1,Pe=0,We=0,Xe=0}$!==null?(we=$.x,qe=$.y,vt=$.z):(we=0,qe=0,vt=0);let it=_t.convert(V.format),He=_t.convert(V.type),nt;V.isData3DTexture?(ge.setTexture3D(V,0),nt=B.TEXTURE_3D):V.isDataArrayTexture||V.isCompressedArrayTexture?(ge.setTexture2DArray(V,0),nt=B.TEXTURE_2D_ARRAY):(ge.setTexture2D(V,0),nt=B.TEXTURE_2D),Z.activeTexture(B.TEXTURE0),Z.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,V.flipY),Z.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),Z.pixelStorei(B.UNPACK_ALIGNMENT,V.unpackAlignment);let At=Z.getParameter(B.UNPACK_ROW_LENGTH),Le=Z.getParameter(B.UNPACK_IMAGE_HEIGHT),Fe=Z.getParameter(B.UNPACK_SKIP_PIXELS),ci=Z.getParameter(B.UNPACK_SKIP_ROWS),Vh=Z.getParameter(B.UNPACK_SKIP_IMAGES);Z.pixelStorei(B.UNPACK_ROW_LENGTH,dt.width),Z.pixelStorei(B.UNPACK_IMAGE_HEIGHT,dt.height),Z.pixelStorei(B.UNPACK_SKIP_PIXELS,Pe),Z.pixelStorei(B.UNPACK_SKIP_ROWS,We),Z.pixelStorei(B.UNPACK_SKIP_IMAGES,Xe);let Lo=E.isDataArrayTexture||E.isData3DTexture,ws=V.isDataArrayTexture||V.isData3DTexture;if(E.isDepthTexture){let Ri=he.get(E),dr=he.get(V),Vi=he.get(Ri.__renderTarget),kh=he.get(dr.__renderTarget);Z.bindFramebuffer(B.READ_FRAMEBUFFER,Vi.__webglFramebuffer),Z.bindFramebuffer(B.DRAW_FRAMEBUFFER,kh.__webglFramebuffer);for(let pr=0;pr + + + + + + 等高线地形——五大典型地貌判读 + + + +
+
+ + 山体两侧以疏密不同的等高线对比坡度 + + + + + + + + +
+ + 实验影像加载中 +
+
+ 实验流程 + 形成交线与垂直投影 + 点击“开始实验”,直接在当前画面播放形成交线视频 +
+ +
+ +
+
+ 高中地理 +
+

等高线地形——五大典型地貌判读

+

观察水平切割、垂直投影与等高线地貌特征

+
+
+
+ + +
+
+ + + + + +
+ + +
+ +
+ + 点击“开始实验”,观看形成交线视频 +
+ +
+
+ + + + + + + diff --git a/GC-UI/frontend/lib/i18n.dart b/GC-UI/frontend/lib/i18n.dart index ef85cf0..2b90261 100644 --- a/GC-UI/frontend/lib/i18n.dart +++ b/GC-UI/frontend/lib/i18n.dart @@ -13,6 +13,7 @@ class I18n { 'app.name': 'Morris GC', 'app.tagline': '天文教学模型 · 可视化启动器', 'nav.home': '主页', + 'nav.courseware': '等高线课件', 'nav.download': '下载', 'nav.settings': '设置', 'nav.about': '关于', @@ -148,6 +149,7 @@ class I18n { 'app.name': 'Morris GC', 'app.tagline': 'Astronomy teaching models · visual launcher', 'nav.home': 'Home', + 'nav.courseware': 'Contour Course', 'nav.download': 'Download', 'nav.settings': 'Settings', 'nav.about': 'About', diff --git a/GC-UI/frontend/lib/pages.dart b/GC-UI/frontend/lib/pages.dart index ff4cc5f..4b87036 100644 --- a/GC-UI/frontend/lib/pages.dart +++ b/GC-UI/frontend/lib/pages.dart @@ -2,6 +2,7 @@ // 保留这个文件是为了让 shell.dart 等调用方的 import 路径不变。 export 'pages/home.dart'; +export 'pages/courseware.dart'; export 'pages/download.dart'; export 'pages/settings.dart'; export 'pages/about.dart'; diff --git a/GC-UI/frontend/lib/pages/courseware.dart b/GC-UI/frontend/lib/pages/courseware.dart new file mode 100644 index 0000000..be8898c --- /dev/null +++ b/GC-UI/frontend/lib/pages/courseware.dart @@ -0,0 +1,294 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; + +import '../theme.dart'; + +/// 等高线课件页:用 WebView 承载去除授权验证后的离线 HTML 课件。 +/// +/// 资源(index.html + assets/)作为 Flutter assets 打包。桌面 WebView 不能直接 +/// 读 flutter assets,因此用一个仅监听 127.0.0.1 的静态服务器(端口 0 自动分配, +/// 不与后端/其他进程冲突)把 assets 暴露成 http://127.0.0.1:/ 再交给 +/// WebView 加载。图片、视频、Three.js 与全部交互都保持原课件原样。 +class CoursewarePage extends StatefulWidget { + const CoursewarePage({super.key}); + + @override + State createState() => _CoursewarePageState(); +} + +class _CoursewarePageState extends State + with AutomaticKeepAliveClientMixin { + @override + bool get wantKeepAlive => true; + + HttpServer? _server; + int? _port; + InAppWebViewController? _controller; + double _progress = 0; + String? _error; + Directory? _extractDir; + + /// 打包后的 app 工作目录不固定,不能直接用相对路径读 flutter assets。 + /// 首次进入时把课件资源解压到临时目录,服务器再从这里提供文件。 + Future _extractAssets() async { + final dir = await Directory.systemTemp.createTemp('gc-courseware-'); + final manifest = await AssetManifest.loadFromAssetBundle(rootBundle); + const prefix = 'courseware/'; + for (final key in manifest.listAssets()) { + if (!key.startsWith(prefix)) continue; + final rel = key.substring(prefix.length); + if (rel.isEmpty) continue; + final data = await rootBundle.load(key); + final out = File('${dir.path}/$rel'); + await out.parent.create(recursive: true); + await out.writeAsBytes(data.buffer.asUint8List( + data.offsetInBytes, data.lengthInBytes)); + } + return dir; + } + + @override + void initState() { + super.initState(); + _start(); + } + + Future _start() async { + try { + _extractDir = await _extractAssets(); + final server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0); + _server = server; + _port = server.port; + server.listen(_handleRequest); + if (mounted) setState(() {}); + } catch (e) { + if (mounted) setState(() => _error = e.toString()); + } + } + + /// 只服务课件目录内的文件,路径做规范化防止越界。 + Future _handleRequest(HttpRequest req) async { + var path = Uri.decodeFull(req.uri.path); + if (path == '/' || path.isEmpty) path = '/index.html'; + // 去掉开头斜杠,拼到资源根目录 + final rel = path.replaceFirst(RegExp(r'^/+'), ''); + final normalized = _normalize(rel); + final file = File('${_extractDir?.path ?? "."}/$normalized'); + try { + if (!await file.exists()) { + req.response.statusCode = HttpStatus.notFound; + req.response.write('404 $rel'); + await req.response.close(); + return; + } + final length = await file.length(); + // _mimeOf 返回完整 MIME(含主/子类型);charset 由 HTML 的 meta 声明。 + req.response.headers.contentType = ContentType.parse(_mimeOf(rel)); + req.response.headers.set('Accept-Ranges', 'bytes'); + + // 视频拖动依赖 HTTP Range;解析 "bytes=start-end" 返回 206。 + final range = req.headers.value('range'); + if (range != null && range.startsWith('bytes=')) { + final span = range.substring(6).split('-'); + var start = int.tryParse(span.first) ?? 0; + var end = span.length > 1 ? int.tryParse(span.last) : null; + if (start < 0) start = 0; + if (start >= length) { + req.response.statusCode = HttpStatus.requestedRangeNotSatisfiable; + req.response.headers.set('Content-Range', 'bytes */$length'); + await req.response.close(); + return; + } + end ??= length - 1; + if (end >= length) end = length - 1; + if (end < start) end = start; + req.response.statusCode = HttpStatus.partialContent; + req.response.headers.set('Content-Range', 'bytes $start-$end/$length'); + req.response.headers.set('Content-Length', '${end - start + 1}'); + await req.response.addStream( + file.openRead(start, end + 1).cast>()); + await req.response.close(); + return; + } + + req.response.headers.set('Content-Length', '$length'); + await req.response.addStream(file.openRead().cast>()); + await req.response.close(); + } catch (e) { + req.response.statusCode = HttpStatus.internalServerError; + await req.response.close(); + } + } + + /// 折叠 .. 与 .,防止 ../ 越界读取其他文件。 + static String _normalize(String path) { + final parts = []; + for (final seg in path.split('/')) { + if (seg.isEmpty || seg == '.') continue; + if (seg == '..') { + if (parts.isNotEmpty) parts.removeLast(); + continue; + } + parts.add(seg); + } + return parts.join('/'); + } + + static String _mimeOf(String path) { + final ext = path.split('.').last.toLowerCase(); + switch (ext) { + case 'html': + case 'htm': + return 'text/html'; + case 'css': + return 'text/css'; + case 'js': + return 'text/javascript'; + case 'json': + return 'application/json'; + case 'png': + return 'image/png'; + case 'jpg': + case 'jpeg': + return 'image/jpeg'; + case 'gif': + return 'image/gif'; + case 'svg': + return 'image/svg+xml'; + case 'mp4': + return 'video/mp4'; + case 'webm': + return 'video/webm'; + case 'ico': + return 'image/x-icon'; + default: + return 'application/octet-stream'; + } + } + + Future _reload() async { + if (_port == null) return; + await _controller?.loadUrl( + urlRequest: URLRequest( + url: WebUri('http://127.0.0.1:$_port/index.html'), + ), + ); + } + + @override + void dispose() { + unawaited(() async { + await _server?.close(); + try { + await _extractDir?.delete(recursive: true); + } catch (_) { + // 临时目录清理失败无需影响页面销毁。 + } + }()); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + super.build(context); + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _toolbar(), + Expanded(child: _body()), + ], + ); + } + + Widget _toolbar() { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12), + decoration: BoxDecoration( + color: GcColors.surface, + border: Border(bottom: BorderSide(color: GcColors.line)), + ), + child: Row( + children: [ + const Icon(Icons.terrain_rounded, size: 20), + const SizedBox(width: 10), + const Text( + '等高线地形 · 五大典型地貌判读', + style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600), + ), + const Spacer(), + IconButton( + tooltip: '刷新', + icon: const Icon(Icons.refresh_rounded, size: 18), + onPressed: _reload, + ), + IconButton( + tooltip: '全屏', + icon: const Icon(Icons.fullscreen_rounded, size: 18), + onPressed: () => _controller?.evaluateJavascript( + source: 'document.documentElement.requestFullscreen?.();', + ), + ), + ], + ), + ); + } + + Widget _body() { + if (_error != null) { + return Center(child: Text('课件加载失败:$_error')); + } + if (_port == null) { + return const Center(child: CircularProgressIndicator(strokeWidth: 2)); + } + return _webview(); + } + + Widget _webview() { + return Stack( + children: [ + InAppWebView( + initialUrlRequest: URLRequest( + url: WebUri('http://127.0.0.1:$_port/index.html'), + ), + initialSettings: InAppWebViewSettings( + javaScriptEnabled: true, + mediaPlaybackRequiresUserGesture: false, + allowsInlineMediaPlayback: true, + supportZoom: false, + clearCache: false, + // 本地可信内容,允许混合加载。 + mixedContentMode: MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, + ), + onWebViewCreated: (controller) => _controller = controller, + onProgressChanged: (_, progress) { + if (mounted && progress < 100) { + setState(() => _progress = progress / 100); + } + }, + onLoadStop: (_, __) { + if (mounted) setState(() => _progress = 1); + }, + onReceivedError: (_, request, error) { + if (mounted) { + setState(() => _error = '${error.type} ${error.description}'); + } + }, + ), + if (_progress < 1) + Positioned( + top: 0, + left: 0, + right: 0, + child: SizedBox( + height: 2, + child: LinearProgressIndicator(value: _progress), + ), + ), + ], + ); + } +} diff --git a/GC-UI/frontend/lib/pages/home.dart b/GC-UI/frontend/lib/pages/home.dart index 98128ab..af051d8 100644 --- a/GC-UI/frontend/lib/pages/home.dart +++ b/GC-UI/frontend/lib/pages/home.dart @@ -276,12 +276,12 @@ class _HomePageViewState extends State { ), const SizedBox(width: GcSpace.md), OutlinedButton( - onPressed: () => widget.controller.goTo(1), + onPressed: () => widget.controller.goTo(2), child: Text(T('home.download')), ), const SizedBox(width: GcSpace.xs), TextButton( - onPressed: () => widget.controller.goTo(2), + onPressed: () => widget.controller.goTo(3), child: Text(T('home.settings')), ), ], @@ -414,7 +414,7 @@ class _HomePageViewState extends State { ), const SizedBox(height: GcSpace.xl), FilledButton( - onPressed: () => widget.controller.goTo(1), + onPressed: () => widget.controller.goTo(2), child: Text(T('home.emptyAction')), ), ], diff --git a/GC-UI/frontend/lib/shell.dart b/GC-UI/frontend/lib/shell.dart index cc14a59..ab90e6f 100644 --- a/GC-UI/frontend/lib/shell.dart +++ b/GC-UI/frontend/lib/shell.dart @@ -15,6 +15,7 @@ class _NavItem { const List<_NavItem> _navItems = <_NavItem>[ _NavItem(Icons.dashboard_rounded, 'nav.home'), + _NavItem(Icons.terrain_rounded, 'nav.courseware'), _NavItem(Icons.download_rounded, 'nav.download'), _NavItem(Icons.tune_rounded, 'nav.settings'), _NavItem(Icons.info_outline_rounded, 'nav.about'), @@ -89,7 +90,10 @@ class _ShellPageState extends State { } Widget _content(ShellController controller) { - if (!controller.backendReady) { + // 课件页是纯前端资源,不依赖后端:即使后端未就绪也可打开。 + // 注意 _buildPage 内部对 index 1 返回课件页,这里单独放行它。 + final courseware = controller.index == 1; + if (!courseware && !controller.backendReady) { if (controller.loadError != null) { return _BackendDown(controller: controller); } @@ -124,10 +128,13 @@ class _ShellPageState extends State { Widget _buildPage(ShellController controller, int index) { switch (index) { case 1: - return DownloadPageView(controller: controller); + // 课件页自持有 WebView 状态,不需要 controller。 + return const CoursewarePage(); case 2: - return SettingsPageView(controller: controller); + return DownloadPageView(controller: controller); case 3: + return SettingsPageView(controller: controller); + case 4: return AboutPageView(controller: controller); default: return HomePageView(controller: controller); diff --git a/GC-UI/frontend/macos/Flutter/Flutter-Debug.xcconfig b/GC-UI/frontend/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b..4b81f9b 100644 --- a/GC-UI/frontend/macos/Flutter/Flutter-Debug.xcconfig +++ b/GC-UI/frontend/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/GC-UI/frontend/macos/Flutter/Flutter-Release.xcconfig b/GC-UI/frontend/macos/Flutter/Flutter-Release.xcconfig index c2efd0b..5caa9d1 100644 --- a/GC-UI/frontend/macos/Flutter/Flutter-Release.xcconfig +++ b/GC-UI/frontend/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/GC-UI/frontend/macos/Podfile b/GC-UI/frontend/macos/Podfile new file mode 100644 index 0000000..4a5a5e3 --- /dev/null +++ b/GC-UI/frontend/macos/Podfile @@ -0,0 +1,47 @@ +platform :osx, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + # Xcode 27 起最低部署目标为 12.0;逐个 pod 提升,避免旧 pod 的 10.13/10.14 报错。 + target.build_configurations.each do |config| + config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '12.0' + end + end +end diff --git a/GC-UI/frontend/macos/Runner.xcodeproj/project.pbxproj b/GC-UI/frontend/macos/Runner.xcodeproj/project.pbxproj index 13f53d0..797fd1a 100644 --- a/GC-UI/frontend/macos/Runner.xcodeproj/project.pbxproj +++ b/GC-UI/frontend/macos/Runner.xcodeproj/project.pbxproj @@ -27,6 +27,8 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 6115A3AA09C0554E004627A7 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8206FEA4073335056184BFE7 /* Pods_RunnerTests.framework */; }; + D97968A61668AD5CB0F4AD81 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3E308B8A5C9BFB85DE87E1A /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -60,11 +62,13 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 182DFB26FB114E38C6E212AD /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + 280B76C220FC1F5F9A19A983 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* gc_ui.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "gc_ui.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* gc_ui.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = gc_ui.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -76,8 +80,14 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 41137AAB2DF4C73772AD6680 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 75F404C3BC9A85A0940A1E7A /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 8206FEA4073335056184BFE7 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8892D008E4FA6821A291BE17 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + 8EFF00FDE3D0667C00609F10 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + A3E308B8A5C9BFB85DE87E1A /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -85,6 +95,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 6115A3AA09C0554E004627A7 /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -92,6 +103,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D97968A61668AD5CB0F4AD81 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -125,6 +137,7 @@ 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, + A82E8A367D68D5C69E25C9BA /* Pods */, ); sourceTree = ""; }; @@ -172,9 +185,25 @@ path = Runner; sourceTree = ""; }; + A82E8A367D68D5C69E25C9BA /* Pods */ = { + isa = PBXGroup; + children = ( + 280B76C220FC1F5F9A19A983 /* Pods-Runner.debug.xcconfig */, + 8EFF00FDE3D0667C00609F10 /* Pods-Runner.release.xcconfig */, + 41137AAB2DF4C73772AD6680 /* Pods-Runner.profile.xcconfig */, + 75F404C3BC9A85A0940A1E7A /* Pods-RunnerTests.debug.xcconfig */, + 8892D008E4FA6821A291BE17 /* Pods-RunnerTests.release.xcconfig */, + 182DFB26FB114E38C6E212AD /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; D73912EC22F37F3D000D13A0 /* Frameworks */ = { isa = PBXGroup; children = ( + A3E308B8A5C9BFB85DE87E1A /* Pods_Runner.framework */, + 8206FEA4073335056184BFE7 /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -186,6 +215,7 @@ isa = PBXNativeTarget; buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( + EBEBA5BB2F5B8B60B8CBB8D2 /* [CP] Check Pods Manifest.lock */, 331C80D1294CF70F00263BE5 /* Sources */, 331C80D2294CF70F00263BE5 /* Frameworks */, 331C80D3294CF70F00263BE5 /* Resources */, @@ -204,11 +234,13 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 6098269FDFAA15D26448E434 /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, + A1BACCAA4E3E0600DECC8167 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -329,6 +361,67 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; + 6098269FDFAA15D26448E434 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + A1BACCAA4E3E0600DECC8167 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + EBEBA5BB2F5B8B60B8CBB8D2 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -380,6 +473,7 @@ /* Begin XCBuildConfiguration section */ 331C80DB294CF71000263BE5 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 75F404C3BC9A85A0940A1E7A /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -394,6 +488,7 @@ }; 331C80DC294CF71000263BE5 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8892D008E4FA6821A291BE17 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -408,6 +503,7 @@ }; 331C80DD294CF71000263BE5 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 182DFB26FB114E38C6E212AD /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; diff --git a/GC-UI/frontend/macos/Runner.xcworkspace/contents.xcworkspacedata b/GC-UI/frontend/macos/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/GC-UI/frontend/macos/Runner.xcworkspace/contents.xcworkspacedata +++ b/GC-UI/frontend/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/GC-UI/frontend/macos/Runner/DebugProfile.entitlements b/GC-UI/frontend/macos/Runner/DebugProfile.entitlements index dddb8a3..3ba6c12 100644 --- a/GC-UI/frontend/macos/Runner/DebugProfile.entitlements +++ b/GC-UI/frontend/macos/Runner/DebugProfile.entitlements @@ -6,6 +6,8 @@ com.apple.security.cs.allow-jit + com.apple.security.network.client + com.apple.security.network.server diff --git a/GC-UI/frontend/pubspec.lock b/GC-UI/frontend/pubspec.lock index e02ce0c..427a614 100644 --- a/GC-UI/frontend/pubspec.lock +++ b/GC-UI/frontend/pubspec.lock @@ -62,6 +62,70 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_inappwebview: + dependency: "direct main" + description: + name: flutter_inappwebview + sha256: "80092d13d3e29b6227e25b67973c67c7210bd5e35c4b747ca908e31eb71a46d5" + url: "https://pub.dev" + source: hosted + version: "6.1.5" + flutter_inappwebview_android: + dependency: transitive + description: + name: flutter_inappwebview_android + sha256: "62557c15a5c2db5d195cb3892aab74fcaec266d7b86d59a6f0027abd672cddba" + url: "https://pub.dev" + source: hosted + version: "1.1.3" + flutter_inappwebview_internal_annotations: + dependency: transitive + description: + name: flutter_inappwebview_internal_annotations + sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + flutter_inappwebview_ios: + dependency: transitive + description: + name: flutter_inappwebview_ios + sha256: "5818cf9b26cf0cbb0f62ff50772217d41ea8d3d9cc00279c45f8aabaa1b4025d" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_inappwebview_macos: + dependency: transitive + description: + name: flutter_inappwebview_macos + sha256: c1fbb86af1a3738e3541364d7d1866315ffb0468a1a77e34198c9be571287da1 + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_inappwebview_platform_interface: + dependency: transitive + description: + name: flutter_inappwebview_platform_interface + sha256: cf5323e194096b6ede7a1ca808c3e0a078e4b33cc3f6338977d75b4024ba2500 + url: "https://pub.dev" + source: hosted + version: "1.3.0+1" + flutter_inappwebview_web: + dependency: transitive + description: + name: flutter_inappwebview_web + sha256: "55f89c83b0a0d3b7893306b3bb545ba4770a4df018204917148ebb42dc14a598" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_inappwebview_windows: + dependency: transitive + description: + name: flutter_inappwebview_windows + sha256: "8b4d3a46078a2cdc636c4a3d10d10f2a16882f6be607962dbfff8874d1642055" + url: "https://pub.dev" + source: hosted + version: "0.6.0" flutter_lints: dependency: "direct dev" description: @@ -75,6 +139,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" http: dependency: "direct main" description: @@ -155,6 +224,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" sky_engine: dependency: transitive description: flutter @@ -242,4 +319,4 @@ packages: version: "1.1.1" sdks: dart: ">=3.5.4 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" + flutter: ">=3.24.0" diff --git a/GC-UI/frontend/pubspec.yaml b/GC-UI/frontend/pubspec.yaml index 4d0ae1a..8c535f7 100644 --- a/GC-UI/frontend/pubspec.yaml +++ b/GC-UI/frontend/pubspec.yaml @@ -34,6 +34,9 @@ dependencies: # 与 GC-UI 后端(本地 HTTP 服务)通信 http: ^1.2.2 + # 桌面 WebView:承载离线等高线课件(Win/macOS/Linux) + flutter_inappwebview: 6.1.5 + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 @@ -60,10 +63,10 @@ flutter: # the material Icons class. uses-material-design: true - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg + assets: + # 离线等高线课件(去除授权验证后的纯净版),整体作为目录打包。 + - courseware/ + - courseware/assets/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/to/resolution-aware-images