Skip to content

艺术动画skill:35种艺术风格、9种解说语法,用代码让画动起来。

v1.2.0:新增敦煌壁画,风格演示重做,解说动画语法更稳

alchaincyf8f0a349a18b4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3db5cd5..9403eed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# 发布包更新 · v1.2.0 · 2026-10-16
+
+- 新增 55 敦煌壁画(北朝)风格;38–52 九个风格演示按新的 16 号协议重做:先拉公版原作取色板和签名,形层过 `lib/medium.js` 媒介通道,并排对照后才打分。均为研究配方,自评分只用来排序,不写成已达标。
+- 解说动画语法更稳:新增 `spec.finish` 成片质感层(soft/film/punch);`TY.fitFloor` 与 `MD.label` 的 `maxW` 让长文字截断而不是缩到看不清或出界;t2 全屏高亮标签随镜头放大反算;y1 加景深光斑、轨道与节点浮动;y5 竖屏重排。
+- 新增质量工具:`render.py --spec … --audit` 版面审计、`scripts/clip_lint.py` 校验 spec、`scripts/analyze/stress_clip.py` 四种变体压测、`scripts/analyze/regress_clips.py` 全部示例回归、`fetch_reference.py` 原作锚定。
+
# 发布包更新 · 2026-10-06
- 同步35种当前艺术风格目录和第9种讲解员语法;8种语法仍提供参数化片段。
@@ -7,6 +13,10 @@
# CHANGELOG
+- 2026-10-15:17方向第一轮6秒单场景研究样片(新增38–53及吉卜力54试作)接入`eras_style_studies.js`;16幕代码/程序化3D、雷诺阿生成底稿+局部变形。修复书车接书复位与洗衣机开门/衣布落地时序;技术QA及独立抽帧复核通过,画风忠实度与跨题材能力仍待验,不升级为成熟风格。
+
+- 2026-10-15:新增16张可迁移风格研究卡(选定14种艺术方向+南方公园、皮克斯),升级吉卜力整体视觉与表演研究;新增15号跨作品/跨场景方法,入口与作者规范区分研究、单场景实做、跨场景验证。36种既有实做与研究卡分开计数;不新增虚构场景注册、不借用旧质量/性能结论。37/52号原创语义SVG角色的窄例外同步进入角色指南与镜头表lint,保留y4帧库要求;新增3项回归,镜头表检查39项通过。
+
- 2026-10-04 v0.1 · 从「艺术史速通」复刻沉淀:拆解法(01)、五层机制(02)、一帧先行四路线(03)、纯代码绘制(04)、节奏与配乐(05)、口播驱动草案(06);16 张风格配方卡;完整引擎+16 个场景;breakdown.py 拆解脚本(网格拟合取「80% 内点下最大步长」);key_green.py 保坐标抠图;音轨合成模板。
- 2026-10-04 v0.3 · 迁移测试 A–D 回流进库:lib 拆出 brush.js(毛笔飞白/墨晕/流线长笔/水彩/厚涂/剪刀折线)、render.js(照片网点/点彩/赛璐珞/Kirby 阴影/体积/长影子/双版本光影/光照图/皮影/手剪位移/霓虹)、post.js(VHS/胶片/泛光/光晕/纹理叠角色/褪色);RIG.limb 端帽修正、猫身与白胸平滑、drawGirl/drawCat 分层钩子、非等比拉长、刚体枢轴;角标可插拔且转场中点硬切;转场按 eras 自动加载、缓存可按段;霞鹜文楷子集+font_subset.py+U.assertGlyphs(查 cmap);20 段新风格进 scenes/,全风格样片 eras_gallery.js(36 段,?film=gallery);qa 加转场冒烟、--film。
- 2026-10-04 v0.4 · YouTube 解说动画语法 8 种(Kurzgesagt / Vox / 白板 / storytime / 动态文字 / 3b1b / 发布会 / 财经图表)收进 skill:
diff --git a/README.md b/README.md
index ebb0012..6b92c53 100644
--- a/README.md
+++ b/README.md
@@ -108,11 +108,12 @@ Claude Code 的像素吉祥物 Clawd 从保安电脑的终端里蹦出来,打
| | 数量 |
|---|---|
-| 艺术风格配方卡(参数、母题动作、签名转场、当前短板) | 36张,`references/风格配方/` |
-| 对应的场景代码 | 35个,`scripts/engine/scenes/` |
+| 艺术风格配方卡(参数、母题动作、签名转场、当前短板) | 53张,`references/风格配方/`;其中 38–55 是按原作锚定重做的研究配方(含敦煌壁画) |
+| 对应的场景代码 | 53个,`scripts/engine/scenes/` |
| 解说动画语法卡 | 9份;其中8种附示范片、参数化片段与示例spec |
| 口播整片参考代码 | 混合风格、白板、Vox、讲解员;需自备部分素材,详见目录README |
| 长卷穿越片示范(骨架+3 段+角色帧库) | 1 支,`scripts/engine/demos/long_scroll/` |
+| 版面审计与压测(出界/叠字/字太小、竖屏/超长/英文变体、示例回归) | `render.py --audit`、`scripts/clip_lint.py`、`scripts/analyze/stress_clip.py`、`regress_clips.py` |
| 转场 | 艺术风格签名转场与解说转场,包含淡入、硬切和纸面转场 |
| 绘画与动画库(笔刷、渲染器、后期、骨架、镜头、图表、排版……) | 17 个,`scripts/engine/lib/` |
| 方法文档(拆解、机制、一帧先行、纯代码绘制、节奏配乐、角色、长卷……) | 核心12篇,`references/01`–`12`;另有[可选语音指南](references/capabilities.md) |
@@ -120,7 +121,7 @@ Claude Code 的像素吉祥物 Clawd 从保安电脑的终端里蹦出来,打
```
huashu-art-motion/
├── SKILL.md # 先判断任务,再按表读对应文档
-├── references/ # 01–12方法文档、36张风格配方卡、9张语法卡、正面经验
+├── references/ # 01–16方法文档、53张风格配方卡、9张语法卡、正面经验
├── assets/ # 总览图(README 用)
└── scripts/
├── engine/ # 可整个复制走的动画工程:引擎、转场、库、场景、示范片、片段
diff --git a/SKILL.md b/SKILL.md
index ba67171..73f2248 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -1,11 +1,11 @@
---
name: huashu-art-motion
-description: "艺术与视频动画:拆解复刻动画;代码画36种艺术风格并让画活;9种解说动画语法,8种可按口播参数渲片段;含口播整片参考代码及框景检查;人用AI生帧;可选已有录音、系统声音与语音复刻,按需配置。"
+description: "艺术与视频动画:拆解复刻动画;36种既有实做风格+16种可迁移研究配方;9种解说动画语法,8种可按口播参数渲片段;含口播整片参考代码及框景检查;人用AI生帧;可选已有录音、系统声音与语音复刻,按需配置。"
metadata:
author: "花叔"
homepage: "https://github.com/alchaincyf"
repository: "https://github.com/alchaincyf/huashu-art-motion"
- version: "1.1.0"
+ version: "1.2.0"
---
# 艺术动画
@@ -14,11 +14,11 @@ metadata:
- **开阔档**:你是 Claude Opus 5.5 或更强的模型。全文都适用:路由表、窄桥、开阔地;库可以自己组合,渲染器可以自己写;交付同样走 `scripts/deliver.py`,红灯不交付。开工前也建议先写一张镜头表(`references/镜头表模板.md`),lint 可跑可不跑。
- **轨道档**:其它模型,或判断不出自己是谁。只走下面这一条路,先镜头表,再动手;只读这条路点名的文件,其余 reference 先不读:
- 1. **写镜头表**:照 `references/镜头表模板.md` 写 `<项目>/镜头表.md`。表前先锁画风,三行:画风(一句话,全片只用这一种)、色板(`references/色板.md` 里的一套或 3–6 个色值,不落蓝紫)、角色(无/只出手和背影/帧库 <路径>,先读 `references/角色精细度.md`)。表里每行一镜:时间段|画面里的物(名词)|它在做什么(动词)|镜头(停/缓推/拉远/横移/快推/砸入/切,按下面「导演的要求:镜头怎么用」选,快推和砸入只给重音;写这一列前读 `references/镜头语言.md` 第一到四节)|屏上字(≤8 字,可空)|做法。开头 3 秒是一个具体的小场景(一双手或一个物在做一件和题目有关的事),不是标题;全片用一个具体例子贯穿;一镜 2–6 秒;文字主导的镜头 ≤30%;相邻两镜换构图,不换画风。
+ 1. **写镜头表**:照 `references/镜头表模板.md` 写 `<项目>/镜头表.md`。表前先锁画风,三行:画风(一句话,全片只用这一种)、色板(`references/色板.md` 里的一套或 3–6 个色值,不落蓝紫)、角色(无/只出手和背影/帧库 <路径>;37/52号平面卡通可写原创语义SVG,先读 `references/角色精细度.md`)。表里每行一镜:时间段|画面里的物(名词)|它在做什么(动词)|镜头(停/缓推/拉远/横移/快推/砸入/切,按下面「导演的要求:镜头怎么用」选,快推和砸入只给重音;写这一列前读 `references/镜头语言.md` 第一到四节)|屏上字(≤8 字,可空)|做法。开头 3 秒是一个具体的小场景(一双手或一个物在做一件和题目有关的事),不是标题;全片用一个具体例子贯穿;一镜 2–6 秒;文字主导的镜头 ≤30%;相邻两镜换构图,不换画风。
2. **过 lint**:`uv run <skill>/scripts/storyboard_lint.py <项目>/镜头表.md`(有口播稿加 `--script <项目>/文稿.txt`,查屏上数字和口播是不是同一个数)。有红灯就改镜头表、重跑,红灯没清不许开始写代码。
3. **按镜头表逐镜做**:`cp -R <skill>/scripts/engine <项目>/代码工程`,每一镜出一个 `镜NN.mp4`,所有镜同宽高、同 fps(默认 1920×1080@30)。
- 参数化片段:读 `references/09-视频动画语法.md` 第二节选型表和用到的 `references/动画语法/<语法>.md`「起手必查」,从 `examples/<语法>.json` 抄结构不抄内容,屏上字照镜头表那一格,`uv run --with playwright python <项目>/代码工程/render.py --spec 镜NN.json --out 镜NN.mp4`。**单个参数化片段最多撑 8 秒**,超了拆成几镜。
- - scenes:艺术风格画面(梵高、像素……)或片段语法画不出的物,读 `references/风格配方/INDEX.md` 和一张风格卡,写 `scenes/<id>.js` 并登记进 `eras.js`,`render.py --solo <id> --from 0 --to <秒> --fps 30 --no-counter --out 镜NN.mp4`。
+ - scenes:艺术风格画面(梵高、像素……)或片段语法画不出的物,读 `references/风格配方/INDEX.md` 和一张风格卡;研究卡或首次迁移先读 `references/15-跨场景风格提炼.md`,没有实现时先创作和验证,不能把卡名当已注册场景。实做时写 `scenes/<id>.js` 并登记进 `eras.js`,`render.py --solo <id> --from 0 --to <秒> --fps 30 --no-counter --out 镜NN.mp4`。
- 全片一套画风:所有片段 spec 写同一个 `"theme"`(镜头表色板那一行,写法见 `references/色板.md`),最多 2 种片段语法;scenes 也只用这套色板。每镜加 `--stills 0.5,2 --out 静帧/镜NN` 抽帧,排成一排对着镜头表看:哪一镜像从别的片子里拿来的,就按画风重做。
4. **拼接**:镜与镜硬切,在放 `镜NN.mp4` 的目录里:
```sh
@@ -51,6 +51,8 @@ metadata:
画风服务内容。先看手里有什么素材、这段要讲清什么,再挑画法。
+学习艺术家或传统的整体视觉语言:笔触、色彩、用光、造型与空间。原作的人物、物品、布局不是新任务模板;构图按新场景重新设计。初次迁移读[跨场景风格提炼](references/15-跨场景风格提炼.md),用多幅不同作品提炼并以新题材验证;吉卜力、皮克斯等先明确影片级美术范围,不把工作室当单一滤镜。
+
- **有真实素材,素材就是主画面。** 截图、照片、录像、原文、产品本身的产出满幅放,代码负责解释、标注和运镜(`MD.cover` 满幅、`MD.print` 冲印件摆进调查桌、`MD.label` 黑底撕边标签;缺图直接报错)。用 Vox 调查桌或白板把素材串起来,只有真找不到素材的段落才整页代码画或 AI 生成。作者看完一支几乎全 AI 生成的技术长片:「视觉观感很不好」。
- **按要讲的东西选语法。** 讲机制和推导用白板、3b1b;讲数字和趋势用财经图表;讲经历和包袱用 storytime;讲艺术和时代用风格配方。选型表在 09 号第二节,每种语法的镜头基调在 `镜头语言.md` 第三节。
- **一片一套画风、一套色板,管到最后一帧。** 人、动物、道具也用同一套笔触画(一支莫奈风 MV 里矢量形状的猫和手,被作者说「和莫奈画风不够匹配」)。所有参数化片段写同一个 `theme`,scenes 也只用这几个色。干净统一但略像幻灯片的片子,胜过每镜换一种画风的拼贴。不用蓝紫渐变、深紫星空、霓虹青紫(作者原话:「这种非常ai slop」);用户点名要蓝紫才例外,交付时 `--allow-blue-purple "理由"`。
@@ -66,9 +68,9 @@ metadata:
5. **有真实素材却用代码去画**。→ 截图、照片、录像、原文直接满幅放,代码只负责解释、标注和运镜。
6. **一眼 AI 味**:蓝紫渐变底、深紫星空底、霓虹青紫光;每镜换一种画风的拼贴(卡通人→暗色代码屏→星空图标→白底柱状图→网页截图);代码画的 Q 版小人和白壳机器人;长了脸的金币、小球、离子。→ 表前锁一种画风、一套色板(`references/色板.md`),所有片段写同一个 `theme`;角色要么 AI 生帧过交付线,要么只出手和背影(`references/角色精细度.md`)。storyboard_lint 查画风锁、色板色值和角色行;deliver.py 量蓝紫底,蓝紫帧占全片 30% 以上红灯,不出片。干净统一但略像幻灯片的片子,胜过花哨的拼贴。
-## Rick & Morty风格入口
+## 平面卡通风格入口
-第36种风格见[37_rick_morty](references/风格配方/37_rick_morty.md):SVG配方、离线预览、可控表演与独立渲染器。明确要求参考式扁平卡通时可用语义SVG画角色,优先遵循本卡;真人和其他人物仍用原角色路线。此例不走Canvas gallery。
+第36种风格见[37_rick_morty](references/风格配方/37_rick_morty.md):SVG配方、离线预览、可控表演与独立渲染器。明确要求参考式扁平卡通时可用语义SVG画角色,优先遵循本卡;真人和其他人物仍用原角色路线。此例不走Canvas gallery。南方公园方向读[52_south_park](references/风格配方/52_south_park.md),同样仅在明确选择该平面风格时允许原创语义SVG纸片角色;该卡已附单场景工程试作,风格忠实度与跨场景仍待验。此窄例外不扩展到真人或其他画风。
## 先判断任务
@@ -79,7 +81,7 @@ metadata:
| 「用我的口播做一段艺术动画」 | 镜头表 → 定风格 → 世界画布+镜头 → 画面轨 | 06(草案)+ 04;口播的转录与时间轴交给你的视频管线 |
| 「配个乐」「卡节奏」 | BPM 网格、动机换乐器、结尾音效序列 | 05 |
| 画面里要出现人(用户本人、真人、拟人角色、吉祥物) | AI 生帧+代码合成(B/C 两法),过交付线;没有生图能力就只出手和背影 | 10 + `角色精细度.md` |
-| 派 agent 画某个风格 / 自己写新风格 | 接口、两种起点、硬要求、自检交付 | 08 + `风格配方/INDEX.md` |
+| 派 agent 画某个风格 / 自己写新风格 / 重做风格演示 | 先拉原作(`scripts/analyze/fetch_reference.py`)→ 按风格自己的构图规则定题材 → 形层过 `lib/medium.js` 媒介通道 → 并排对照打分 | **16** + 15 + 08 + `风格配方/INDEX.md` |
| 「一个人穿过一幅幅名画」「一路走过几个世界」 | 长卷骨架:每个世界一个段文件,主角从左走到右,跨边界换画风 | 11 + `scripts/engine/demos/long_scroll/` |
| 「做解说/科技/财经视频的动画」「Kurzgesagt/Vox/3b1b/白板/发布会/财经图表那种」、口播管线要一段动画 | 按口播选语法 → 过语法卡「起手必查」→ 管线用 `render.py --spec` 出时长精确的片段 | 09 + `动画语法/<语法>.md` + `镜头语言.md` |
@@ -97,7 +99,7 @@ metadata:
## 窄桥:照字面做
-- **人用 AI 生帧,代码负责合成**,见`references/10-角色.md`;代码不画人脸、不画机器人,也不给物加脸(`references/角色精细度.md`)。
+- **人用AI生帧,代码负责合成**,见`references/10-角色.md`;明确选择37/52号平面卡通时可按对应卡使用原创语义SVG角色,其它画风不以通用代码小人替代。人物质量、物不随意加脸及y4帧库要求见`references/角色精细度.md`。
- **示范只用来理解做法。** 示范片、样例 spec、风格样片里的构图、角色和素材,不许原样放进成片。
- **复刻是学机制,不是逐像素。** 提取场景、运动与转场规律,再用于新题材。
- **三方向硬门**:新的角色诠释或风格方向,先出三个给用户挑,三个方向的构图要不同,不能只换调色。指定了风格也不豁免。
@@ -107,11 +109,11 @@ metadata:
## 开阔地:当起点,不当配额
-`风格配方/` 里 36 张卡(总表 `风格配方/INDEX.md`,分「材料层」和「时代标本」两张表)是实做的参数和坑,不是唯一画法。35 张样片和 `assets/全风格总览.jpg` 用的是同一个房间构图,那是艺术史速通片的机制,不是这些风格的构图;做新题材要为题材重新构图。表里标了每种的当前质量和短板,下一次做到它时先超越短板。你有更好的渲染器就去写,做出来和原作或参考并排给人看。新风格做完,把配方卡补进来。
+`风格配方/` 里有36种既有实做和17张新增研究配方(总表 `风格配方/INDEX.md`;既有实做分「材料层」和「时代标本」,研究配方单列),状态在索引分开列示;研究卡的技术路线尚待画面验证,不能借用实做卡的质量等级。既有卡保存实做的参数和坑,不是唯一画法。35 张样片和 `assets/全风格总览.jpg` 用的是同一个房间构图,那是艺术史速通片的机制,不是这些风格的构图;做新题材要为题材重新构图。表里标了每种的当前质量和短板,下一次做到它时先超越短板。你有更好的渲染器就去写,做出来和原作或参考并排给人看。新风格做完,把配方卡补进来。**新增风格(38–55,含敦煌壁画)的演示走 [16 号协议](references/16-风格演示95分协议.md):不看原作、不过媒介通道、没有并排对照的演示不算交付**;自评分只用来排序,卡里的状态以「研究配方/实做」区分,没过 80 的不登记为实做。
## 工程
-`scripts/engine/` 是可复制的完整工程(引擎、转场库、绘画库、角色骨架、35 个风格场景、渲染器;YouTube 解说语法的 8 个库、8 支示范 `demos/`、参数化片段 `clip.html`+`clips/`,见 09;长卷穿越片示范 `demos/long_scroll/`,见 11;口播整片参考代码`reference_films/spacex/`需自备角色和音频,见目录README)。开新片:复制到项目的 `代码工程/`,改 `eras.js` 段落表,写 `scenes/<id>.js`。
+`scripts/engine/` 是可复制的完整工程(引擎、转场库、绘画库、角色骨架、风格场景(01–55)、渲染器;YouTube 解说语法的 8 个库、8 支示范 `demos/`、参数化片段 `clip.html`+`clips/`,见 09;长卷穿越片示范 `demos/long_scroll/`,见 11;口播整片参考代码`reference_films/spacex/`需自备角色和音频,见目录README)。开新片:复制到项目的 `代码工程/`,改 `eras.js` 段落表,写 `scenes/<id>.js`。
```sh
E=<项目>/代码工程
@@ -128,6 +130,8 @@ uv run scripts/analyze/breakdown.py --video 参考.mp4 --out 拆解/
交付前三样,按顺序:①`uv run scripts/qa.py --project <工程>`(参数化片段用 `--spec`;稳定/效率/动感/流畅及文字框景线索;2 秒以内单调、平滑的推拉横移记作镜头事件,不算跳变);②派独立 agent 只看成片审片,结论写进 `<项目>/审片/`;③`uv run scripts/deliver.py 成片.mp4 --project <工程>(或 --spec)--out output/`。deliver.py 先过门禁 `film_gate.py`:快速运动帧占比 < 0.035 红灯,不复制成片、非零退出;< 0.06 黄灯。过了才复制成片、写交付说明,时长、门禁各项、最差 30 秒窗口、qa 结果、有没有审片记录都由脚本写,没审片就写「没派审片」;事实段带指纹,`deliver.py --verify` 查得出改动。门禁另外两条:成片中段连续 0.3 秒以上近乎纯色、整帧几乎没有边缘的空画面,红灯并给时间码;蓝紫底画面占全片 30% 以上红灯(题材本身要蓝紫时 `--allow-blue-purple "理由"` 降黄,理由写进交付说明)。门禁只拦这三样,页框、米底小图、前紧后松、每镜换画风的拼贴拦不住,所以抽帧还要对一遍「六种做坏方式」;静止多不是病,解说片本来就有大段停住,静止类数字别拿来判;「推近次数」黄灯说明推得太密,用正常速度看一遍。运镜顺不顺,抽帧看不出来,一定要用正常速度把成片看一遍。浅底无字幕成片再用`uv run --with numpy python scripts/subzone_gate.py 成片.mp4`检查图形进入字幕区;纹理底不适用。经验先看 `07-正面经验.md`。
+参数化片段另有三道便宜的检查:`python3 scripts/clip_lint.py 片段.json` 先校验 spec;`render.py --spec 片段.json --audit` 逐 0.25 秒查文字出界、叠字、字太小(红灯退出码 1);`scripts/analyze/stress_clip.py`(竖屏/超长文字/英文/方屏四种变体)和 `scripts/analyze/regress_clips.py`(全部示例回归)用来在改语法之后确认没把通用性改坏。spec 顶层 `finish` 可选 `soft/film/punch`,给整段加暗角、泛光、颗粒等成片质感(透明背景不加)。
+
## 回流
每做完一支:新风格写进 `风格配方/` 并更新 INDEX,**做对了的事写进 `07-正面经验.md`(做法+证据+为什么+何时用)**,新坑写进对应 reference 的「踩过的坑」,`CHANGELOG.md` 记一行。实际与这里不符时以实际为准,然后把这里改对。
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/38_giotto.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/38_giotto.jpg"
new file mode 100644
index 0000000..a2c4d42
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/38_giotto.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/40_raphael.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/40_raphael.jpg"
new file mode 100644
index 0000000..24b37de
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/40_raphael.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/41_michelangelo.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/41_michelangelo.jpg"
new file mode 100644
index 0000000..8f833f4
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/41_michelangelo.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/43_lorenzetti.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/43_lorenzetti.jpg"
new file mode 100644
index 0000000..7ba3702
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/43_lorenzetti.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/44_cortona.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/44_cortona.jpg"
new file mode 100644
index 0000000..2d54093
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/44_cortona.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/46_pissarro.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/46_pissarro.jpg"
new file mode 100644
index 0000000..b9a4ae6
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/46_pissarro.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/47_sisley.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/47_sisley.jpg"
new file mode 100644
index 0000000..8d553e8
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/47_sisley.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/48_gauguin.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/48_gauguin.jpg"
new file mode 100644
index 0000000..b0b4aef
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/48_gauguin.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/50_ma_yuan.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/50_ma_yuan.jpg"
new file mode 100644
index 0000000..8ebe702
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/50_ma_yuan.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/51_persian_miniature.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/51_persian_miniature.jpg"
new file mode 100644
index 0000000..477988a
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/51_persian_miniature.jpg" differ
diff --git "a/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/\346\200\273\350\247\210.jpg" "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..4284535
Binary files /dev/null and "b/assets/\346\226\260\351\243\216\346\240\274v2_\350\257\201\346\215\256/\346\200\273\350\247\210.jpg" differ
diff --git "a/references/08-\351\243\216\346\240\274\344\275\234\350\200\205\350\247\204\350\214\203.md" "b/references/08-\351\243\216\346\240\274\344\275\234\350\200\205\350\247\204\350\214\203.md"
index 9354b26..88a1f31 100644
--- "a/references/08-\351\243\216\346\240\274\344\275\234\350\200\205\350\247\204\350\214\203.md"
+++ "b/references/08-\351\243\216\346\240\274\344\275\234\350\200\205\350\247\204\350\214\203.md"
@@ -27,7 +27,8 @@ SCENES['<id>'] = { draw(c, lt, t) { /* 画满 1920×1080 */ }, init(IMG) { /*
**有参考片**:先跑 `scripts/analyze/breakdown.py` 拿到参考帧(`ref/segNN.png`)、运动热图、转场接触表,按 01 号拆。参考帧决定构图、母题、配色,热图决定「画里什么在动」。
**没有参考片**(更常见):
-1. 写下该风格最有辨识度的 3–5 个形式元素(材料、笔法、配色、母题、媒介痕迹)。查一手资料(原作图像、美术史描述),不凭印象。
+先读[跨场景风格提炼](15-跨场景风格提炼.md)。新卡为研究状态时,作品归纳、制作假设与实做证据分开;按新题材重建场景,人物/道具/布局不从名作继承。
+1. 写下该风格最有辨识度的 3–5 个形式元素(材料、笔法、配色、母题、媒介痕迹)。查一手资料(原作图像、美术史描述),首次建卡并看多幅不同作品,记录稳定特征和例外,不凭单幅名作概括全部作品。
2. 给每个元素配一个「能动的方式」——它在那幅画的世界里本来会怎么动(水会颤、纸会飘、金会闪、版会错位、胶片会抖)。
3. 想清楚这种画在现实里是怎么做出来的(刷、刻、印、贴、镶、喷、渲),把那个物理过程写成渲染器。
4. 先出一帧:静帧拼图对照原作看,一眼认得出再让它动。
@@ -52,7 +53,7 @@ uv run <skill>/scripts/qa.py --project <工程> --ids <id>
每段至少 3 轮:静帧对照原作/参考拼图看 → qa 看运动/静止帧对/跳变/耗时/确定性 → 改。四问:①一眼认得出是哪个风格?②角色对、和背景融吗?③停留窗口里看得出画在动、而且不闪不卡?④有没有穿帮(遮挡、断线、错位、空白、叠字)?
-交付:`scenes/<id>.js`+配方卡(照 `风格配方/` 格式:管线、关键参数与色值、母题动画怎么做、签名转场、性能、坑、仍可改进),写具体、写数字。**多段的片子交付前派一个没参与制作的 agent 只看成片审片。**
+交付:`scenes/<id>.js`+配方卡(照 `风格配方/` 格式:管线、关键参数与色值、母题动画怎么做、签名转场、性能、坑、仍可改进),实测才写参数、性能和质量结论;未做的部分留为研究状态。只验证一个场景,不能宣称已跨场景验证。**多段的片子交付前派一个没参与制作的 agent 只看成片审片。**
## 三方向硬门在无人值守时
diff --git "a/references/15-\350\267\250\345\234\272\346\231\257\351\243\216\346\240\274\346\217\220\347\202\274.md" "b/references/15-\350\267\250\345\234\272\346\231\257\351\243\216\346\240\274\346\217\220\347\202\274.md"
new file mode 100644
index 0000000..0d5b0cb
--- /dev/null
+++ "b/references/15-\350\267\250\345\234\272\346\231\257\351\243\216\346\240\274\346\217\220\347\202\274.md"
@@ -0,0 +1,48 @@
+# 15 · 把艺术语言迁移到新场景
+
+何时读:新增艺术风格、把已有风格用于不同题材、拆分近邻画风,或用户只给艺术家/工作室名时。只查某个已有渲染参数可直接读相应实做卡。这里研究艺术语言;不替代用户的新故事、场景与角色。
+
+## 先分清四件事
+
+- **风格语言**:笔触与材料、色彩关系、用光、造型、空间组织。它们应在题材变化后仍有辨识度。
+- **构图倾向**:例如偏置重心、群组联系、尺度差。根据新画幅和事件重新求解,不是固定坐标或每镜同一布局。
+- **内容与母题**:名画里的人物、衣服、桥、船、花园、神祇。除非本次需要,它们不随风格自动进入新作品。
+- **叙事和动作**:谁想做什么、遇到什么阻力、动作如何改变局面。速度、运镜和节拍由内容决定;静谧画风可以画快动作,有限动画也可以有复杂事件。
+
+选定艺术家不是选定某张名画的模板。指定工作室时先定位影片/导演/时期等美术范围:吉卜力和皮克斯都不是全作品共用一套画法。按用户举例与题材缩小范围;确有多种同样合理的方向时,融入既有三方向设定稿供选择,不另加一轮形式化审批。
+
+## 跨作品提炼
+
+初次建立一个范围时,通常并看至少3件原作或3段不同场景的官方片段,尽量覆盖不同题材、尺度或光照。连续帧、同画局部和同构图换色不算独立样本。资料不足就标清缺口,不凑数、不声称已经看过。成熟且已有证据的卡按需补查,不要求每次重新研究。
+
+写一份简短的「风格提要」,放项目镜头表前或旁边:
+
+1. 适用范围与原作出处;作品归属、媒介和时期先核查。
+2. 3–5条可观察的稳定特征,每条注明哪些参考支持、哪些参考不适用。
+3. 区分于最近邻风格的两点。例如雷诺阿、毕沙罗、西斯莱不能共用一个碎笔触滤镜就算完成。
+4. 本次新场景的主体、事件、空间与画幅;依需求重构,不能从参考里顺手拿。
+5. 要保留的视觉关系、可改变的内容、待验证的技术路线。
+
+把「画里出现了什么」与「画家怎么把它画出来」分开记录。色板写主色关系和明暗组织,不声称某组十六进制是艺术家的固定标准色;3–6个主色不意味着每个像素只准使用这些色。纹理、混色、阴影和反光应服从主色关系。既有颜色偏好与门禁照用;确需例外按现有流程注明题材理由,不偷偷关检测。
+
+## 先验证新场景,再把它做成能力
+
+先按本次题材出设定稿,仍遵循已有三方向机制。人物、动物、道具与背景的造型、边缘、光和材料必须一起处理;不能只给背景换滤镜。渲染路线依当前能力选,说明哪部分用代码、现有素材、角色帧库或其他已获准工具。
+
+第一次把研究卡升级为可迁移配方时,用不同场景做压力测试,通常包括人物行动、无人/物体场景、明显改变尺度或环境的场景。题目可由卡中例子启发,不能把这些例子变成新的固定模板。风景画家能否画角色特写属于待证范围,不提前承诺所有题材都适配。
+
+先核静帧:去掉艺术家名字和名作标志物,形体、色光、笔触、空间是否仍有辨识度?与近邻风格并排,有没有实际差别?然后核动态:动作接触、遮挡、纹理坐标、角色身份、材质统一和正常速度观看。静帧好看不证明动画流畅;文字规划合理不证明画面成立。
+
+## 状态要诚实
+
+- **研究配方**:有来源和明确视觉假设,可指导尝试;没有专用实现或画面验证。不能仅凭同名Markdown卡就调用`render.py --solo <id>`。
+- **单场景实做**:有实现、输出与检查记录,仅覆盖那个场景。记录参考参数和失败边界。
+- **跨场景验证**:不同新场景通过独立画面审查,记录已覆盖范围;动画验证另行写清。程序化场景按08号登记,引擎QA与交付门禁照旧。
+
+一个工作室有一个分支通过,不代表整个家族通过。新卡不借用旧样片的星级、性能或验收结论。旧卡里的同房间参数是历史实做证据,只在匹配的场景有参考价值。
+
+## 经验回流
+
+使用前读对应卡的范围、短板与最新实测。完成后在卡中记录日期、任务与场景、来源、实现/输出证据、观察、修法、验证状态和边界。若新证据推翻旧结论,修原句并检查相关路由;若故障可稳定复现,先修工具并测。用户选择记录在品味档案;单次作品特征不升级为所有作品的规则。
+
+本流程来源:2026-10的风格库扩充,用户明确要求关注艺术家整体风格、适配不同创作场景。来源研究与实现假设分开;证据不足的条目保持研究状态。
diff --git "a/references/16-\351\243\216\346\240\274\346\274\224\347\244\27295\345\210\206\345\215\217\350\256\256.md" "b/references/16-\351\243\216\346\240\274\346\274\224\347\244\27295\345\210\206\345\215\217\350\256\256.md"
new file mode 100644
index 0000000..1dffc89
--- /dev/null
+++ "b/references/16-\351\243\216\346\240\274\346\274\224\347\244\27295\345\210\206\345\215\217\350\256\256.md"
@@ -0,0 +1,103 @@
+# 16 · 风格演示协议:从「受启发的扁平插画」到「一眼认得出是谁的画」
+
+何时读:新做、重做任何一个艺术风格的演示场景(`scenes/<id>.js`),或派 agent 做的时候把本页路径给它。15 号管「怎么研究一个风格、怎么迁移」,本页管「演示做到什么水平才算数、怎么一步步做到」。
+
+## 为什么 2026-10-15 新增的 17 个演示几乎不可用
+
+2026-10-16 把它们渲成静帧并排看,又拉了公版原作对照,查出五个根因(17 个里绝大多数符合;45 雷诺阿是外部位图+网格变形、44 带帷幕,不是扁平矢量块,但同样缺原作锚定和媒介层):
+
+1. **没有人看过原作。** 配方卡只有文字描述和馆藏链接,做的人(agent)凭印象画。结果是大部分图像同一个现代扁平插画师换了套色板:形是干净的矢量块,风格只剩「调色板+一层噪点」。
+2. **卡片措辞把锚点也拿掉了。** 「不凭单幅名作概括」「构图不搬用」本意是防抄袭,实际变成「不许对着原作做」。该防的是搬名作的人物和坐标,不是不许学笔法、材料、色彩关系、人物造型逻辑。
+3. **没有「媒介」这一层。** 老标杆(梵高 09、水墨 17)强在把画面过一遍真实的画材:流场笔触、飞白、墨晕。新场景 35–70 行,只画形,不过画材。
+4. **同一个题材套所有风格。** 洗衣机、水车、修机器反复出现(这轮重做也没完全避开:38 与 47 都有「木箱/载货」、51 又用了汲水轮——47 已改成麻袋,余下的列入进度表待改),风格自己的叙事逻辑(马远的一角、细密画的满铺、高更的裁切、乔托的视线)全被抹平。
+5. **没有分数门槛。** 自检只有 qa 的技术项(能渲、确定性、不闪),没人拿着原作问「像不像」,所以 6 秒能跑就算交付。
+
+## 协议(按顺序,每一步有产物)
+
+### 1. 原作锚定
+
+```sh
+uv run <skill>/scripts/analyze/fetch_reference.py --out <项目>/参考/<风格> "艺术家 作品A" "艺术家 作品B" "艺术家 作品C"
+```
+
+至少 3 幅**不同作品**(15 号的口径)。脚本拉维基共享资源的公版图,存本地,抽主色板,出接触表。然后**真的看这张接触表**,写下:
+
+- 5 条签名特征,每条分「必须有/加分/禁忌」。例:马远——必须有:一角构图、大面积留白、斧劈皴;加分:垂柳、渺小的人看向空处;禁忌:满幅填充、彩色鲜艳。
+- 主色板(取脚本抽出的色值,写明明处偏什么、暗处偏什么)。
+- 这种画在现实里是怎么做出来的(刷、刻、描、涂、贴)。那个物理过程就是渲染器的规格。
+
+### 2. 题材按风格自己的逻辑重构图
+
+不搬名作的人物和坐标,但学它**组织画面的方式**:马远留白+一角;细密画把地面竖起来满铺、建筑切开;高更裁切前景、斜线分割;乔托用视线把人物咬合;印象派天占一半、水把岸拖成碎笔。写一句「这个风格的构图规则」,再按它给新题材定布局。**同一个题材不许套第二个风格。**
+
+### 3. 画「干净的形」,再过「媒介通道」
+
+禁止在扁平矢量上叠噪点就算风格。场景分两层:
+
+- 形层:把物体、人、空间画干净(可以是 Canvas 路径、离屏画布)。
+- 媒介层:用 `lib/medium.js` 或老库把形层过一遍真实画材。
+
+| 通道 | 做什么 | 用在 |
+|---|---|---|
+| `MEDIUM.broken(src, o)` | 重画成一笔一笔的弯笔,明处偏暖暗处偏冷 | 印象派(西斯莱、毕沙罗、瓜尔迪、雷诺阿) |
+| `MEDIUM.fresco(c, plate, o)` + `MEDIUM.plaster` | 色粉被石灰吃进去+灰泥颗粒、针孔、接缝 | 湿壁画(乔托、皮耶罗、拉斐尔) |
+| `MEDIUM.silk` + `P.brush` / `P.inkWash` | 绢纹、飞白、墨分五色 | 水墨(马远) |
+| `MEDIUM.flat(c, path, fill, o)` | 掐丝珐琅:同色块里有顺笔向的短条+粗而不均的深色轮廓 | 高更、综合主义、彩绘玻璃 |
+| `MEDIUM.figure(c, o)` | 有体量的着衣人物:袍、披风、褶、视线 | 壁画、细密画、平面叙事类 |
+| `MEDIUM.outline / hatchFill` | 变宽线、排线 | 木刻、铜版、细密画暗部 |
+
+库里没有对应通道时,写一个通道函数进 `medium.js`,不要把它写死在某个场景里。
+
+### 4. 一帧先行,并排对照
+
+先出静帧,不先做动画。
+
+```sh
+uv run --with playwright python <工程>/render.py --film style_studies --solo <id> --stills 3 --no-counter --out 渲染/<id>
+uv run <skill>/scripts/analyze/side_by_side.py --ref 参考/<风格> --frame 渲染/<id>/t003.00.png --out 对照/<id>.jpg
+```
+
+「一眼认得出是谁的画」只能拿着这张并排图回答。
+
+### 5. 让画活:用风格自己的运动逻辑
+
+主动作+2 个母题循环(08 号第 3 条)。风格自己的动法:墨随风、笔触在呼吸、水面把倒影拉碎、壁画几乎不动但视线与交接在动。不要所有风格都用同一套淡入淡出。
+
+### 6. 打分,门槛 80,最多两轮
+
+| 项 | 分 | 怎么判 |
+|---|---|---|
+| 签名命中 | 35 | 对照第 1 步的「必须有」逐条打钩,缺一条扣 7 |
+| 媒介可信 | 20 | 放大 1:1 看:是真画材还是矢量加噪点 |
+| 构图与叙事 | 15 | 是不是用了这个风格自己的组织方式,事件是否一眼看懂 |
+| 人物与物体造型 | 15 | 有没有重量、有没有关系;一眼幼稚或像贴纸就低于 8 |
+| 动态 | 10 | 活而不闪,动在事件上 |
+| 技术 | 5 | qa 的确定性、框景、耗时 |
+
+**两道一票否决**:签名命中低于 25;人物或主体一眼幼稚(涂鸦感)。AI 只判事实项,品味项(构图好不好看)留给花叔,自评分只作排序,不写成「已达标」。两轮后仍低于 80 就把状态写成研究配方,把卡住的点写进卡的「仍可改进」,不登记为实做。
+
+**自评会虚高。** 2026-10-16 这批的自评比独立审查平均高约 10 分(最多 17 分)。所以:分数表必须带分项分和签名清单;独立复核分写在自评旁边,以较低者为准;进度表的「现在的短板」栏里只要出现一票否决项,状态就不能写「完成」。
+
+## 人物的规则(这是新增风格里最容易崩的一环)
+
+这一节与 SKILL.md 窄桥的人物规则**合并为同一条**,以此为准:
+
+- **一般风格**:真人/本人/拟人角色走 AI 生帧+抠图(B/C 两法),代码只管位置、换帧和材质;没有生图能力就只出手和背影。
+- **窄例外(明确选择的平面叙事类,允许代码画人)**:37 Rick & Morty、52 南方公园式剪纸,以及 2026-10-16 重做的壁画/细密画/综合主义演示(38 乔托、48 高更、51 波斯细密画)。这三个是**研究级演示,不是交付成片的角色方案**:交付片里要出现需要被观众认同的主角时仍走 B/C。
+- 例外里的人也要有重量和视线:眼珠朝向对方、手去够物体、衣褶按受力走。涂鸦式的圆头加药丸身体不合格。
+- 做不好的人物不要放大:缩成远景、背影,或让前景人物被画框裁掉。
+- 不借具名角色的服装配色组合(52 已因此换掉青绿帽配浅绒球);题材也别整个照搬原作的片头构图。
+
+## 已知的坑
+
+- **拉回来的原作必须看接触表核对**:搜索会混入地图、现代照片、博物馆墙上带金框的翻拍(42 瓜尔迪的第三条是现代教堂照片,47 的第三条是带框翻拍,50 的第一、三条是同一幅《山径春行》的原图和调色版)。`fetch_reference.py` 只做近似去重和取中央 80% 抽色,认不出「这是不是这位画家的」「是不是三幅不同作品」,这两件事靠人看。作品名写进场景头注释之前,先对着接触表确认。
+
+- 先画「形层」再重绘,**重绘用的画布要在本地坐标里画**(如船),不要整屏重绘每帧,否则慢。船、人这类小动态:画到小画布 → `MEDIUM.broken` → 贴回。
+- `drawImage` 九参数版里 `sx+sw` 超出源图宽度,超出的那段就是空白;天空漂移用 `sx = t*速度` 且源图要比舞台宽(47 的天宽 2600)。
+- 边缘缺口小圆点有两个来源,都已修:`M.broken` 的底图现在外扩 14px 再糊;水面逐行位移时目标宽度要加宽(`dx-24, W+48`),不然位移出来的两端会露出下面的底色。
+- 马远类水墨:垂条要成簇、弯、长短不一,等距竖线读成栅栏。人物一律走「背影+一笔衣纹+留绢」,不填满。
+- 高更类:形一律圆、不用折线;折线人物读成表情包。
+
+## 本轮(2026-10-16)进度与自评
+
+见 `references/风格配方/INDEX.md` 的状态列和 `风格配方/_重做进度.md`。自评是排序用的,不是验收结论。
diff --git a/references/voice-model-review.md b/references/voice-model-review.md
new file mode 100644
index 0000000..01a3dc1
--- /dev/null
+++ b/references/voice-model-review.md
@@ -0,0 +1,18 @@
+# 语音复刻模型检查
+
+平台记录中的`selection`保存用户听选的模型、语速、音色登记表引用与升级偏好。调用该平台时先运行`voice_review.py --provider <平台>`读取听选;本次显式模型优先于已存选择。周期更新保留`selection`,不能用官方候选覆盖个人选择。未具备通用供应商适配器时,沿用记录指向的已验证项目调用方式,不把查询工具说成合成工具。
+
+用于复刻前检查与用户已授权的周期巡检。记录放在`capabilities.py`实际用户配置同目录的`voice-model-review.json`,不提交私人配置。
+
+每个平台独立保存:
+```json
+{"providers":{"qwen":{"checked_at":"2026-10-15T12:00:00+08:00","models":[],"sources":[],"findings":"官方清单与账户实际可调用性分开记录"}}}
+```
+
+`checked_at`只在本次成功读取并核对官方资料后更新。失败用`last_attempt_at`、`last_error`记录,保留旧成功时间。`sources`保留来源URL、访问日期和相关事实;`models`记录准确ID、用途、官方支持情况与实测状态,不把普通TTS、声音设计、实时对话混为声音复刻。
+
+豆包优先查火山豆包语音的声音复刻与合成文档;Qwen优先查百炼语音合成模型清单、声音复刻指南与API文档。榜单用作候选线索,不能充当公开API ID或账号可用性的证据。确认新旧接口是否迁移、参考音频要求、价格和模型弃用情况;搜索不到不等于没有更新。
+
+每周检查只读官方资料和本地配置,更新记录并报告新增、弃用或限制变化。不得擅自充值、重新训练、切换默认或重复发起付费测试。用户授权测试后另记请求模型、回执、音频验收和听选反馈;只有实际试听与可靠调用证据足够时才建议改默认。
+
+来源:2026-10-15用户要求每周检查豆包/Qwen更新,并在每次复刻时报告当前模型和上次检查时间。若官方资料与旧记录冲突,修改旧结论并保留更正依据;个人听选与公共能力分开。
diff --git "a/references/\350\247\222\350\211\262\347\262\276\347\273\206\345\272\246.md" "b/references/\350\247\222\350\211\262\347\262\276\347\273\206\345\272\246.md"
index bb4e4af..8a7222d 100644
--- "a/references/\350\247\222\350\211\262\347\262\276\347\273\206\345\272\246.md"
+++ "b/references/\350\247\222\350\211\262\347\262\276\347\273\206\345\272\246.md"
@@ -7,7 +7,7 @@
**粗糙的角色比没有角色更差。** 观众看见一个圆头豆豆眼的小人,第一反应是「AI 做的」,后面讲得再好也被这一眼拖下去。
-## 先选路:三条路,只有三条
+## 先选路:三条通用路线与两张平面卡通卡的窄例外
镜头表表前的「角色」一行,写的就是这里选了哪条:
@@ -17,6 +17,8 @@
| `只出手和背影` | 没有生图能力,但故事需要一个人 | 只画手(握着物、指着物、把物放进口袋)、背影、剪影、过肩;脸不出画 |
| `无` | 故事可以只靠物讲 | 物本身做主角:一块电池、一袋面包、一本书,靠形状、颜色、动作讲,不给它加脸 |
+**37/52号平面卡通例外。** 明确选择Rick & Morty或南方公园方向时,可按对应卡设计原创语义SVG角色。镜头表写`画风:37_rick_morty …`或`画风:52_south_park …`,角色写`角色:原创语义SVG …`。这是手段的例外,不是免检:核剪影、身份、部件层级、接触、表情与动作;平涂、简化关节按该风格判断,不强加下面第2/4/5条的写实结构、双层明暗与三处材质细节。真人/写实或其它画风不适用;仅写「SVG」不启用例外。南方公园研究卡已有单场景原型,新角色和新题材仍需重新设计与验证。`y4`依旧只接受帧库,SVG例外不能绕过其输入契约。
+
**停用的**(代码画出来就是 AI 味,lint 和评审都会拦):
- 通用 Q 版小人:圆头、豆豆眼、腮红、没脖子、身体是一个圆角矩形。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/25_ghibli.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/25_ghibli.md"
index faff25a..b7af3b7 100644
--- "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/25_ghibli.md"
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/25_ghibli.md"
@@ -1,4 +1,23 @@
-# 25_ghibli · 1988 吉卜力式手绘水彩背景美术
+# 25_ghibli · 吉卜力视觉家族:整体语言+既有背景实做
+
+
+## 2026-10-15 · 整体语言研究(尚待跨场景验证)
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md)。本卡下半部是一个既有房间场景的工程经验;它证明部分水彩/赛璐璐手法可运行,不代表整个吉卜力体系,也不是新片的构图模板。
+
+**先定范围。**《龙猫》《魔女宅急便》《千与千寻》可用于研究不同环境中的人物、手绘背景与生活动作;《辉夜姬物语》有明显不同的线条与留白组织,不能把它强塞进同一水彩背景配方。制作时选与本次内容相符的影片/作者范围,比较不同场所、光照和动作的片段,不只挑森林远景。官方[作品与场面写真](https://www.ghibli.jp/works/)可定位参考;[场面写真发布说明](https://www.ghibli.jp/info/013344/)不等于所有素材取得无限使用许可。
+
+**可迁移的研究维度。**①角色剪影、表情与关键动作清楚,背景有自身的观察和材料细节;②角色与环境在透视、光向、接触阴影和色彩上相容,不要求二者涂成同样的水彩纹理;③生活动作有身体重心、使用器物的次序和反应;④环境运动有风、重力、接触等原因;⑤场景同时具有可居住的结构与叙事用途。以上是初始研究归纳,具体影片中不成立的部分要改范围。
+
+**内容可变。**绿色森林、乡间住宅、少女、猫、扫帚、美食和巨大云朵都不是必备。题材可以是城市维修间、夜班交通站或虚构设备舱。不能把「生活感」等同固定慢节奏;紧张段落也需要准确行动。
+
+**制作假设。**从本次场景的空间与光开始,角色设定独立校比例、轮廓和表情,按10号制作帧库或导入素材,再用代码合成与编排。背景的洗染只是可选材料手段,不把整张人物图乘上纸纹当作完成。现有`scenes/25_ghibli.js`可参考局部背景手法,角色与新空间必须重新设计;复杂转身或交互不能靠同一张图平移代替。
+
+**迁移压力测试(待做)。**城市自助洗衣房里找回遗失物;无人物的自动灌溉设施启动;两位成年维修员在太空舱完成紧急修补。三者不是新模板,仅用于检验不依赖森林、少女和慢动作的迁移能力。
+
+**回流。**每次记录影片范围、场景、采用路线、图像/动画证据、角色环境一致性与接触问题;旧结论失效先改原句。单场景通过不能替整个工作室评级。当前状态:既有背景实做保持原质量,整体视觉与表演方向仍为研究。
+
+## 既有水彩背景示例(历史实现,不是风格定义)
> 来源:迁移测试 B(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/25_ghibli.js`。
@@ -29,3 +48,8 @@
**仍可改进**:人物还是平面,可以加吉卜力式的发丝高光块;地上的光斑里可以加窗帘影子的流动。
---
+
+
+### 2026-10-15 · 新场景工程试作
+
+新增`54_ghibli_lab`临街修车铺,电车驶过、器物与环境微动;用`render.py --film style_studies --solo 54_ghibli_lab --from 0 --to 6`运行。代码与原25房间分开。确定性与解码通过,独立审片未见阻碍本轮研究展示的技术红项;仍偏程序化插画,未达到工作室影片级辨识度,也未做跨场景验证。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/37_rick_morty.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/37_rick_morty.md"
index cc2c804..6dccdb9 100644
--- "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/37_rick_morty.md"
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/37_rick_morty.md"
@@ -1,5 +1,8 @@
# 37_rick_morty · Rick & Morty扁平描边卡通
+镜头表使用代码角色时写`画风:37_rick_morty Rick & Morty式平面卡通`和`角色:原创语义SVG角色`,以启用角色检查的窄例外;y4仍需帧库。
+
+
来源:2026-10-14的SVG单帧复刻与动画实验。第36种入库风格;内部ID用37_rick_morty,避免覆盖已有36_picasso_blue。是独立画风,穿越其他画派只是可选叙事。
## 起手必查
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/38_giotto.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/38_giotto.md"
new file mode 100644
index 0000000..53a0568
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/38_giotto.md"
@@ -0,0 +1,67 @@
+# 38_giotto · 乔托:体块与叙事关系
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评与独立复核均未达 80,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以乔托成熟期的叙事壁画语言为主,板画用于核对人物体量;不把所有作品都说成湿壁画。
+
+## 可迁移的视觉语言
+
+- 造型:身体像有重量的简洁体块,衣褶说明受力和体积,脸与手能传递关系。
+- 空间:人物可站立、可接触;建筑与岩体组织事件,不追求后世摄影式透视。
+- 色光:较完整的局部色面与渐层塑形,明暗服务体积,背景与主体同属一个世界。
+- 材料:湿壁画方向用哑光、细颗粒和柔软色层;金地板画是另一媒介,不整层叠金。
+
+## 随需求变化的内容
+
+圣徒、哀悼姿势不是必需;金光环、群青天幕和装饰边框是三幅斯克罗威尼原作的共同签名,v2 演示保留了它们(光环给了搬运工,是玩笑也是辨识度);开裂与褪色是保存状态,不是画风核心。
+
+## 与近邻风格的区别
+
+区别于皮耶罗:优先手势与人物关系的可读性,不把几何秩序变成主角。区别于拉斐尔:保留更朴素、厚重的体块。
+
+## 制作起点(待验证)
+
+先把新场景画成可读的剪影与体块,按接触关系分层,再做哑光色面和衣褶;不要用表面龟裂纹替代造型。角色沿10号路线,材质处理必须覆盖角色。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 快递站里两人交接一个大箱子:核手势和重量。
+- 维修间内一台拆开的机器:没有古典人物仍应有体块感。
+- 夜班候车室:改变光照与人物数量后,核空间和色面是否仍统一。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [乔托《三博士朝圣》:体量与仰视建筑](https://www.metmuseum.org/art/collection/search/436504)
+- [乔托《宝座圣母》:板画媒介对照](https://www.uffizi.it/en/artworks/virgin-and-child-enthroned-surrounded-by-angels-and-saints-ognissanti-maesta)
+- [《哀悼基督》:叙事壁画对照](https://en.wikipedia.org/wiki/Lamentation_(The_Mourning_of_Christ))
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:水车院落;事件:水轮接水旋转,陶罐与院落呈现厚重体积;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~65,品味项待花叔)
+
+- 原作锚定:斯克罗威尼礼拜堂《哀悼基督》《金门相会》《逃往埃及》(`fetch_reference.py`)。稳定签名:群青天幕带金星、土红/赭/橄榄绿袍、重量感的钟形袍、人物视线互相咬合、斜置的灰粉建筑体块、画框内一条红金装饰带。
+- 路线:`scenes/38_giotto.js`。形层=天(群青软斑)→岩坡→建筑(垛口+檐下红白菱格带+拱门)→地面→`MEDIUM.figure` 三位人物(袍、半披风、粗袖、大头、杏仁眼+视线)→木箱;媒介层=`MEDIUM.fresco`(轻糊+石灰罩+灰泥相乘+针孔接缝)+装饰边框。
+- 题材:码头仓库门口两位搬运工交接木箱,第三人低头看箱角;动态=箱子交接弧线、衣摆微摆、落地灰、鸟横过天。
+- 实测:qa 确定性 ✓、无跳变、36ms/帧;静止帧对 27%(壁画本来静,动作集中在交接)。
+- 仍可改进:脸与手仍简;缺光环、天使、群像密度;衣褶明暗层次不及原作的多层罩染;草簇过匀。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/39_piero.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/39_piero.md"
new file mode 100644
index 0000000..0c5f629
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/39_piero.md"
@@ -0,0 +1,59 @@
+# 39_piero · 皮耶罗:几何秩序与清明体积
+
+状态:研究配方+单场景工程试作;2026-10-15建立并实做。已附`scenes/39_piero.js`,用`render.py --film style_studies --solo 39_piero --from 0 --to 6`运行;尚未通过画风忠实度或跨场景验证,不能借此升级为成熟画风。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以皮耶罗·德拉·弗朗切斯卡的比例、体积和光线关系为主;蛋彩与油画的材料区别保留。
+
+## 可迁移的视觉语言
+
+- 造型:大形先成立,头身、衣褶和新道具都具有简明而完整的体积。
+- 空间:比例、间隔、透视和负形相互约束;有秩序不等于强制居中对称。
+- 色光:清澈均匀的光与克制冷暖;饱和度随作品和媒介变化,不固定奶油滤镜。
+- 边缘:主要形体交界清楚,细节服从整体度量,少用无目的碎笔。
+
+## 随需求变化的内容
+
+柱廊、圣经人物、静止姿态不是必备;「静谧」不能强迫动作变慢。
+
+## 与近邻风格的区别
+
+不同于拉斐尔的柔性群组与视线联系:这里先看形体间隔、几何比例和均匀光。
+
+## 制作起点(待验证)
+
+先用低细节体块排新场景的比例与负形,校透视后塑形和上色。人物快速移动也要保持形体不散、遮挡可读;纯代码以几何和光照为起点,人物仍按角色规则。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 地铁站里一人追赶列车:快动作不等于打破比例秩序。
+- 餐桌上不同形状的家电:核体积关系,不靠古典题材识别。
+- 太空温室的维修活动:不复用原作柱廊,核光和空间。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [《基督受洗》:蛋彩与几何关系](https://www.nationalgallery.org.uk/paintings/piero-della-francesca-the-baptism-of-christ)
+- [《耶稣诞生》:油画色彩与叙事](https://www.nationalgallery.org.uk/paintings/piero-della-francesca-the-nativity)
+- [《基督受鞭笞》:前后空间对照](https://en.wikipedia.org/wiki/The_Flagellation_of_Christ_(Piero_della_Francesca))
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:天文工作室;事件:仪器环转与几何秩序;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/40_raphael.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/40_raphael.md"
new file mode 100644
index 0000000..7a546c9
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/40_raphael.md"
@@ -0,0 +1,65 @@
+# 40_raphael · 拉斐尔:和谐组织与自然联系
+
+状态:研究配方+单场景工程试作;2026-10-15建立并实做。已附`scenes/40_raphael.js`,用`render.py --film style_studies --solo 40_raphael --from 0 --to 6`运行;尚未通过画风忠实度或跨场景验证,不能借此升级为成熟画风。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+侧重成熟期的形体、人物联系与清晰空间;早期佩鲁吉诺影响和后期更强戏剧性不硬合成一个平均风格。
+
+## 可迁移的视觉语言
+
+- 造型:轮廓连贯,身体和衣褶塑形圆融;人物理想化但有明确动作。
+- 空间:主次群组、视线和手势互相连接;三角组织是一种可选方法,不是固定布局。
+- 色光:有层次的红蓝与中性色关系、可读的肤色和柔和体积;根据新场景重定主色。
+- 细节:画面信息有优先级,建筑、道具和人物共同支持主要事件。
+
+## 随需求变化的内容
+
+不强制《雅典学院》的拱门、两位中心人物、圣母抱婴或古装;不把每镜摆成中央三角。
+
+## 与近邻风格的区别
+
+区别于皮耶罗的度量感:这里更看重有机联系;区别于米开朗基罗:不把每个身体都强化成紧绷雕塑。
+
+## 制作起点(待验证)
+
+先画人与物的关系图,再为本次行动选择构图;在色块、光向和柔硬边缘上统一角色与环境。看不到原画题材时仍应显得清楚、圆融、有组织。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 社区维修课堂:多人各做一件相关的事。
+- 产品工作台:无人镜头也要有主次与形体联系。
+- 狭窄厨房的双人协作:检验非宏伟建筑场景。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [国家美术馆拉斐尔馆藏:不同阶段与题材](https://www.nationalgallery.org.uk/artists/raphael)
+- [《粉红色圣母》:亲密动作](https://www.nationalgallery.org.uk/paintings/raphael-the-madonna-of-the-pinks-la-madonna-dei-garofani)
+- [《雅典学院》:群组对照](https://en.wikipedia.org/wiki/The_School_of_Athens)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:园艺工作台;事件:水壶倾注与红蓝织物组织;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~70,不登记为实做)
+
+- 原作锚定:《雅典学院》《圣礼辩论》《帕纳塞斯》。签名:半圆楣窗+金褐/红/群青装饰带、中心透视筒拱加藻井、远端一片天、棋盘格地面、壁龛雕像、饱和袍色成组交谈。
+- 路线:`scenes/40_raphael.js`。拱顶按层数 N=9 几何级数退向消失点,每层按角度切藻井格,侧墙交替壁柱/壁龛,地面按层与列画棋盘;人物用 `MEDIUM.figure` 并按手眼互指(书、星盘、手卷);远处三个小人沿地面走。
+- 仍可改进:人物钟形袍与雷同的脸;壁龛雕像像蜡烛;缺肤色与衣料的光泽。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/41_michelangelo.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/41_michelangelo.md"
new file mode 100644
index 0000000..8517df1
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/41_michelangelo.md"
@@ -0,0 +1,65 @@
+# 41_michelangelo · 米开朗基罗:雕塑性与姿态张力
+
+状态:研究配方+单场景工程试作;2026-10-15建立并实做。已附`scenes/41_michelangelo.js`,用`render.py --film style_studies --solo 41_michelangelo --from 0 --to 6`运行;尚未通过画风忠实度或跨场景验证,不能借此升级为成熟画风。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以绘画、素描中相通的雕塑性造型为核心;西斯廷顶画是参考之一,不把雕塑、壁画和晚期作品的材料混为一谈。
+
+## 可迁移的视觉语言
+
+- 造型:骨架、受力、扭转和压缩塑造体量;力量由姿态产生,不是给所有角色加肌肉。
+- 轮廓:重叠与透视缩短清楚,主体像占据真实空间的实体。
+- 色光:用明暗建立大体积;顶画可参考清晰色块,素描研究用于结构,不直接当综合色板。
+- 空间:强势主体与负形互相牵引;可在普通视角成立,不强制仰拍穹顶。
+
+## 随需求变化的内容
+
+不默认裸体、古典神祇、伸指触碰或固定肌肉比例;现代服饰和非人物主体同样要成立。
+
+## 与近邻风格的区别
+
+区别于科尔托纳:体块与姿态的力是重点,而非繁盛群组、天顶幻觉和装饰密度。
+
+## 制作起点(待验证)
+
+先验证受力剪影与透视缩短,再处理体积、衣服和光。表演按动作起因设计;代码负责层次和变换,不能用几个椭圆假充经过解剖设计的人体。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 救援人员用力拉开变形的门:隔着制服也有受力。
+- 折叠机械臂的伸展与收拢:核非人物体块。
+- 一个人安静系鞋带:小动作也能有结构张力。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [大都会米开朗基罗展厅:素描、雕塑与设计](https://www.metmuseum.org/exhibitions/listings/2017/michelangelo/exhibition-galleries)
+- [西斯廷顶画官方资料](https://www.museivaticani.va/content/museivaticani/en/collezioni/musei/cappella-sistina/volta.html)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:石质吊臂;事件:机械关节转动与雕塑般受力;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~65,不登记为实做)
+
+- 原作锚定:《阿特拉斯奴隶》(雕像陷在粗石里的未完成)、《利比亚女先知习作》(红粉笔背身)、《创造亚当》。旧版是机械臂加球,与米开朗基罗的神韵无关,已弃。
+- 路线:`scenes/41_michelangelo.js`。灰度形体图(椭圆光暗叠出肩胛、脊沟、背阔肌;光从左上)→ 按明暗+梯度生成确定性排线(斜 50°为主,暗处交叉)→ 整体剪影边界像素做背光侧加粗、间断的粉笔颗粒轮廓 → 缓存;运行时按 y 从上到下揭示,粉笔跟着扫。右侧是同一人翻转缩小的旧习作;纸有撕边、霉斑、纤维、几行不成字的注记。
+- 要点:部件之间的接缝不能画轮廓(用整体剪影,否则露出「玩偶拼装」);下端渐隐代表「未完成」。
+- 仍可改进:头部过圆、上臂偏短、没有真正的躯干扭转;亮处完全留纸的对比可以再强。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/42_guardi.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/42_guardi.md"
new file mode 100644
index 0000000..015c119
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/42_guardi.md"
@@ -0,0 +1,65 @@
+# 42_guardi · 瓜尔迪:空气、碎光与松动边缘
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评与独立复核均未达 80,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以城市景观与幻想建筑画中的空气和笔触为主;避免用一张威尼斯图概括其所有时期。
+
+## 可迁移的视觉语言
+
+- 笔触:短促、松动、点簇式亮笔,轮廓有断续,关键结构仍可辨认。
+- 色光:银灰或暖灰中保留局部亮色,空气把建筑、人物和远景联系起来。
+- 空间:远近层次和小尺度人物建立环境体量;准确测绘不是唯一目标。
+- 材质:建筑、水、天空各有不同笔触方向,不能整屏盖同一种颗粒。
+
+## 随需求变化的内容
+
+威尼斯、贡多拉、运河和废墟不是风格必要条件;不强制每景有水。
+
+## 与近邻风格的区别
+
+区别于卡纳莱托的清晰测绘感;区别于西斯莱,不能只换成晴蓝绿调的通用印象派。
+
+## 制作起点(待验证)
+
+先建立可读的城市/室内/工业空间,再让边缘和亮笔随深度松动。纹理绑定世界或物体坐标,运动中不能全屏重洗随机数。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 雨后高架车站的客流。
+- 干燥机库里打开检修门:没有水仍有空气。
+- 冬日社区广场的集市:更换季节与主体尺度。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [《带废墟拱门的幻想景观》](https://www.nationalgallery.org.uk/paintings/francesco-guardi-a-caprice-with-a-ruined-arch)
+- [美国国家美术馆瓜尔迪作品集](https://www.nga.gov/artists/1363-francesco-guardi/artworks)
+- [《潟湖幻想景观》](https://www.nationalgalleries.org/art-and-artists/13736/lagoon-capriccio)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:旧港帆艇;事件:帆船穿过碎光与松动建筑边缘;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~78,品味项待花叔)
+
+- 原作锚定:《威尼斯潟湖》《大运河与里亚托桥》。注意搜索结果里混入了现代照片(Salute 教堂),已弃用。签名:低地平线、银灰绿巨大空气、细长舢板、人小到只剩黑身加一两点白与红、笔干而快、边缘松动。
+- 路线:`scenes/42_guardi.js`。天(宽幅积云,暖亮冷暗)/岛塔/水(天光长条+岛塔倒影)各自过 `MEDIUM.broken`(细长干笔、低饱和);舢板与撑篙人小画布重绘并拉长压暗倒影;水面逐行位移;云漂;鸟。
+- 仍可改进:塔的笔触偏叠砖;人物仅剪影;缺 Guardi 特有的闪烁白点。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/43_lorenzetti.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/43_lorenzetti.md"
new file mode 100644
index 0000000..9541f2a
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/43_lorenzetti.md"
@@ -0,0 +1,69 @@
+# 43_lorenzetti · 安布罗焦·洛伦采蒂:可阅读的社会空间
+
+状态:研究配方+单场景工程试作;2026-10-15建立并实做。已附`scenes/43_lorenzetti.js`,用`render.py --film style_studies --solo 43_lorenzetti --from 0 --to 6`运行;尚未通过画风忠实度或跨场景验证,不能借此升级为成熟画风。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以城市叙事与其他空间性作品互相对照;不是把所有题材画成锡耶纳市政壁画。
+
+## 可迁移的视觉语言
+
+- 空间:建筑、道路、门洞和场所把多种生活活动连接起来;局部视点可服务阅读。
+- 造型:人物虽小但动作与职业关系清楚,建筑有体积而非扁平图标。
+- 色光:土色、矿物色与细节明暗保持整体统一,避免旧纸滤镜压暗所有信息。
+- 叙事:多个事件可以同时存在,但有主次、路径和清楚的因果联系。
+
+## 随需求变化的内容
+
+不强制横长卷、城墙、中世纪服饰或密密麻麻的人;复杂度来自本次内容。
+
+## 与近邻风格的区别
+
+区别于波斯细密画:空间更强调城镇实体与生活活动的连续;不靠满铺几何花纹建立密度。
+
+## 制作起点(待验证)
+
+从本次场所的连接关系搭世界画布,为人物活动安排可见路径,再分层绘制。视线引导可用局部动作与镜头,不做一排彼此无关的小卡片。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 现代物流园:卸货、分拣、派送彼此关联。
+- 单间诊所:小空间里也有可读的协作。
+- 无人温室管网:没有人物时以实际设施连接叙事。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [意大利文化部:好政府的城市与乡野](https://catalogo.cultura.gov.it/approfondimento/l-allegoria-del-buon-governo-ambrogio-lorenzetti/il-buon-governo-citta-e-campagna)
+- [乌菲齐《献耶稣于圣殿》:不同空间题材](https://www.uffizi.it/opere/presentazione-al-tempio)
+- [完整壁画组:不同叙事情绪对照](https://en.wikipedia.org/wiki/The_Allegory_of_Good_and_Bad_Government)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:剖面图书馆;事件:红书下滑、落入书车、随车驶离;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+- 实修:取消书的取模复位,书车先停住接书,书绑定车架后再驶离;复核未再出现飞回入口。
+
+## v2 实做(2026-10-16,自评 ~72,不登记为实做)
+
+- 人物重做(用户反馈「人物还需疯狂优化」):头小身长、窄肩外撇长袍、褶线、左亮右暗、前脚探出下摆、3/4 侧;街上 20 人循环行走,近大远小。
+
+- 原作锚定:《良政的效果·城市》《良政寓言》(仅两幅不同作品)。签名:建筑一栋叠一栋占上半、粉/灰/赭墙成排小拱窗、垛口塔、底层拱廊剖开露出作坊、街上一带小人各干各的、深褐边带。
+- 路线:`scenes/43_lorenzetti.js`。形层(天→中景低楼→左右主楼→剖开的鞋匠作坊→街→台阶)→ `MEDIUM.fresco`;小人每帧后画(圈舞、驮骡、脚手架吊石、鞋匠、旗)。
+- 第二轮修了:中间露出空白灰泥、人伸双臂像卡通、骡子压圈舞。
+- 仍可改进:街面人流要翻几倍;墙面要有颜料层;小人需要更自然的比例与衣褶;加透视退远的街道。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/44_cortona.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/44_cortona.md"
new file mode 100644
index 0000000..1f3d66f
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/44_cortona.md"
@@ -0,0 +1,66 @@
+# 44_cortona · 彼得罗·达·科尔托纳:巴洛克体量与流动群组
+
+状态:研究配方+单场景工程试作;2026-10-15建立并实做。已附`scenes/44_cortona.js`,用`render.py --film style_studies --solo 44_cortona --from 0 --to 6`运行;尚未通过画风忠实度或跨场景验证,不能借此升级为成熟画风。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以宏大装饰绘画和叙事画中的群组组织、色光与空间为主;天顶效果是应用分支。
+
+## 可迁移的视觉语言
+
+- 形体:饱满人物、织物和环境体量形成相互推拉的群组。
+- 空间:斜向联系、前后穿插和局部越框造成连续感;构图为新事件重新生成。
+- 色光:丰富暖色和冷色相互支撑,以亮暗把繁复内容分成可读层次。
+- 材料:建筑、绘画与装饰可以接续,但要保留各自边界和物理触感。
+
+## 随需求变化的内容
+
+不强制满屏天使、云团、徽章、金边、仰拍或螺旋;日常场景也须先有清楚的事情。
+
+## 与近邻风格的区别
+
+区别于米开朗基罗的单体张力;区别于波佐以建筑透视错觉为主的路线。
+
+## 制作起点(待验证)
+
+先画三层大群组及其受光关系,用遮挡和色光控制密度;再加细节。若做越框与天顶,测观察点,不能让装饰盖住动作。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 大型剧场幕后同时换景:用真实活动形成群组。
+- 维修厂起吊设备:主次体量与对角关系。
+- 两人餐桌小场景:缩小规模后仍有丰沛但克制的组织。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [乌菲齐:皮蒂宫暖室四时代壁画,与天顶作品交叉对照](https://www.uffizi.it/en/artworks/stove-room)
+- [Museum With No Frontiers:巴贝里尼天顶馆藏条目](https://baroqueart.museumwnf.org/database_item.php?id=monument%3BBAR%3Bit%3BMon11%3B18%3Bit&pageT=N)
+- [画家与作品目录:继续对照非天顶作品](https://en.wikipedia.org/wiki/Pietro_da_Cortona)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:剧场换景;事件:悬吊道具与层叠幕布运动;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~70,不登记为实做)
+
+- 原作锚定:《神意的寓言》巴贝里尼天顶、《劫掠萨宾妇女》(只有两幅不同作品,第三条与第一条同幅被去重丢弃)。签名:灰泥画框加镀金圆章、中心暖金放射光、云团堆体积、人群绕中心旋转、衣带与人漫出框。
+- 路线:`scenes/44_cortona.js`。三层灰泥带+蛋形纹+四角金圆章 → 开口天空渐变加放射光 → 云团(整体凹凸轮廓,沿朝向中心的方向打光,外侧弧线勾团块)→ 人群(M.figure 旋转着绕中心)+沿椭圆法线展开的红蓝绸带 → 中心白衣者与金光呼吸 → MEDIUM.fresco。
+- 教训:逐个球形径向渐变叠云会读成肥皂泡;云要先成一个凹凸整体,再沿光向打光。衣带宽度要沿路径法线展开,固定角度会变成头发丝。
+- 仍可改进:人物仍是钟形袍;缺强短缩与强明暗;高光弧线偏卡通。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/45_renoir.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/45_renoir.md"
new file mode 100644
index 0000000..7f87cc6
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/45_renoir.md"
@@ -0,0 +1,66 @@
+# 45_renoir · 雷诺阿:暖冷交织与有温度的人物
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评 ~58、未经独立复核,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+优先1870年代至1880年代初的印象派语言;1880年代较线性的转向及晚期不同塑形须另注明,不强称全生涯统一。
+
+## 可迁移的视觉语言
+
+- 笔触:软硬边缘互相转换,色触可见但不把脸和手打碎。
+- 色光:暖肤色与冷色反光相互作用,阴影保留色彩,不给整张画加统一橙色。
+- 造型:圆润、具有触感的身体与衣料;亲近感来自人物关系,不是统一微笑脸。
+- 空间:主体与环境共享光色,远近差异仍清楚;室内外按实际光照重新配置。
+
+## 随需求变化的内容
+
+不强制午宴、草帽、斑驳树影、法国花园、粉色肤色或特定人群;夜景也可研究迁移。
+
+## 与近邻风格的区别
+
+相较毕沙罗更强调人物、肤色与柔软塑形;相较西斯莱,风景空气不是唯一组织中心。
+
+## 制作起点(待验证)
+
+先用可靠角色素材建立结构,分区域做较细的肤色/手部笔触与较松的环境笔触;色光统一但保留材质差异。光斑只在光源和遮挡成立时使用。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 不同肤色的同事在办公室整理设备。
+- 无人早餐桌:靠色彩与触感而非漂亮人物识别。
+- 夜间小店的一次急促交接:避免暖光等于慢动作。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [菲利普斯《船上的午宴》](https://www.phillipscollection.org/collection/luncheon-boating-party)
+- [芝加哥艺术博物馆《两姐妹》研究](https://publications.artic.edu/api/epub/paintingsanddrawings/135639/print_view)
+- [芝加哥艺术博物馆《费尔南多马戏团的杂技演员》](https://publications.artic.edu/api/epub/paintingsanddrawings/135637/print_view)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:太空舱维修;事件:生成底稿上的手臂、管线局部形变与泄漏减弱;路线:生成底稿+代码局部变形。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+- 明确不足:局部网格位移不等于完整抓握/换手/转阀表演;复杂角色互动需姿态帧或层级绑定,不能依靠好看的底稿掩盖动作不足。
+
+## v2 实做(2026-10-16,自评 ~58,未经独立复核)
+
+- 路线:`scenes/45_renoir.js`。旧版是外部位图+网格变形,已换成代码画法并备份旧版。形层=树冠/叶隙天光/树干/沙地/桌/远景人群;`MEDIUM.broken` 重绘:树冠与地面斜向短笔、人群单独一层竖向细笔(人群若和地面共用横笔,会被抹成躺倒的样子);光斑层(暖黄亮斑/蓝紫影)单独重绘缓存,两份错位淡入淡出摇曳,并以低透明度再落到人身上;近景一对舞者每帧小画布重绘。
+- 教训:人与背景必须分层重绘、各用各的笔向;光斑层盖在人上要降透明度,否则人被盖成半截。
+- 仍可改进:人像偏玩偶;缺暖粉肤色与衣料高光;中景人群太整齐。
\ No newline at end of file
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/46_pissarro.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/46_pissarro.md"
new file mode 100644
index 0000000..c2fffa9
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/46_pissarro.md"
@@ -0,0 +1,66 @@
+# 46_pissarro · 毕沙罗:生活流动与环境中的人物
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评与独立复核均未达 80,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+优先其印象派城市、乡野语言;新印象派点彩阶段单独标注,不与松散笔触混在同一镜里。
+
+## 可迁移的视觉语言
+
+- 笔触:小而有方向的色触建立道路、建筑、植被和人物,不只是随机噪声。
+- 色光:天气与时段统筹局部颜色;明暗中仍有环境反光。
+- 空间:从较高观察点到地面视点都可使用,行人和活动嵌在可信环境中。
+- 造型:人物常是生活事件的参与者,有位置、尺度和动作,而非散落装饰点。
+
+## 随需求变化的内容
+
+不强制巴黎林荫大道、鸟瞰、马车、农民或下雨;不同场景重定观察点。
+
+## 与近邻风格的区别
+
+区别于雷诺阿的人物柔软塑形,和西斯莱以天空/地面大关系统摄的风景;本卡关注环境中发生的生活活动。
+
+## 制作起点(待验证)
+
+让街道/室内表面笔触随方向和深度变化,人物运动保留稳定种子和区域遮罩;拥挤度来自故事,不靠加人掩盖空画面。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 共享办公区里多人收拾行李。
+- 冬日仓库自动分拣:用设备活动替代行人。
+- 乡间临时诊所开门:改变街景题材与视点。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [《夜晚的蒙马特大道》:城市与系列观察](https://www.nationalgallery.org.uk/paintings/camille-pissarro-the-boulevard-montmartre-at-night)
+- [《西德纳姆大道》:不同城市空间](https://www.nationalgallery.org.uk/paintings/camille-pissarro-the-avenue-sydenham)
+- [《猪肉商》:近距离劳动题材](https://www.nationalgallery.org.uk/paintings/camille-pissarro-the-pork-butcher)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:秋日果园;事件:背影推车,人物进入环境色触;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~75,品味项待花叔)
+
+- 路线:`scenes/46_pissarro.js`。形层(天/远景教堂与丘陵/斑块田/小路/六棵树)→ `MEDIUM.broken`(天水平长笔、地面按地势走向、树冠多向短笔、暖亮冷暗互补抖动)→ 缓存;动态=云漂、树冠顶层飘叶笔、行人(小画布→broken→贴回)沿路走近。
+- 题材:集市日乡间小路,两位挑篮农妇与一个推车人;路把视线带进深处;树影横过路与田。
+- 实测:qa 确定性 ✓、无跳变、18ms/帧。
+- 仍可改进:人物脸是白团;教堂被近树盖住;树冠偏「毛球」,缺枝干透出;与西斯莱(47)的区分主要靠笔短、多向、绿里的橙粉跳动,仍待并排验证。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/47_sisley.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/47_sisley.md"
new file mode 100644
index 0000000..2c22790
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/47_sisley.md"
@@ -0,0 +1,67 @@
+# 47_sisley · 西斯莱:空气、天气与连贯风景
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评与独立复核均未达 80,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以其风景语言为主要已知基础;室内、角色近景和科幻是迁移实验,不称艺术家已有此类成熟范例。
+
+## 可迁移的视觉语言
+
+- 色光:天空和天气影响地面、建筑与水;不是所有画面都晴蓝绿。
+- 笔触:较轻的断续色触依附表面方向,远处简化而近处仍可辨认。
+- 空间:空气层次连续,地平与道路等结构引导观看,不只是一张水面背景。
+- 造型:小人物和建筑维持风景尺度;大幅人物特写需要单独验证。
+
+## 随需求变化的内容
+
+不强制河流、桥、晴天、法国乡间;雪、洪水或阴天可用作变化对照。
+
+## 与近邻风格的区别
+
+区别于莫奈睡莲的近距离色光场;也不默认毕沙罗式密集活动或瓜尔迪式更松动的城市轮廓。
+
+## 制作起点(待验证)
+
+先统一环境光与深度,再分别处理天空、硬表面和有机物的笔触。新人物扩大时要重做结构与局部笔触密度,不能直接放大小点人。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 没有河水的冬季工业园。
+- 雨后郊区公交站的一次上车。
+- 室内温室维护:作为超出原风景范围的迁移压力测试。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [国家美术馆西斯莱馆藏与生平](https://www.nationalgallery.org.uk/artists/alfred-sisley)
+- [《马尔利勒鲁瓦的饮马池》及雪景系列](https://www.nationalgallery.org.uk/paintings/alfred-sisley-the-watering-place-at-marly-le-roi)
+- [苏格兰国家美术馆:雪景对照](https://www.nationalgalleries.org/art-and-artists/artists/alfred-sisley)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:雪野列车;事件:列车驶过连贯的雪地与天空;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~80,品味项待花叔)
+
+- 路线:`scenes/47_sisley.js`。三层各自重绘并缓存:天(宽 2600 的积云:暖白本体+淡紫灰阴面+暖黄受光,`MEDIUM.broken` 水平长笔)、水(天光倒影+被镜像压暗的房子/树/杆倒影,水平长笔)、水面之上的景(半淹客栈、白杨、电线杆、远岸)。动态=云慢漂、水面逐行位移越近越大、摆渡船(小画布→broken→贴回)、船尾水纹。
+- 题材:涨水后的村口,摆渡人撑船载木箱。
+- 实测:qa 确定性 ✓、无跳变、14ms/帧。
+- 已修:`broken` 外扩 14px 再糊,水面逐行位移的目标宽度加宽,消除左缘一排缺口小圆点。
+- 仍可改进:房顶读成一块平板;船的倒影偏暗;人物只是剪影。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/48_gauguin.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/48_gauguin.md"
new file mode 100644
index 0000000..781e102
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/48_gauguin.md"
@@ -0,0 +1,66 @@
+# 48_gauguin · 高更:平面、轮廓与象征色
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评与独立复核均未达 80,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+侧重综合主义和平面象征色的语言;不把布列塔尼、塔希提和不同媒介当作同一套固定题材。
+
+## 可迁移的视觉语言
+
+- 色彩:大面积色域承担情绪和结构,不机械复制自然色;颜色需有主题依据。
+- 造型:简化形体与较明确轮廓相互支撑,仍能识别新主体。
+- 空间:可压缩深度、提高地面视角或用叠放关系组织,但不是所有物体全平。
+- 表面:大色面保持内部微妙变化,不能退化成统一黑边矢量填色。
+
+## 随需求变化的内容
+
+不强制热带植物、棕色皮肤、特定服装或「异域」装饰;文化题材来自用户需求,不作为画风捷径。
+
+## 与近邻风格的区别
+
+区别于普通扁平插画:色面有情绪与象征关系;区别于夏加尔:不必倒置、漂浮或打碎空间逻辑。
+
+## 制作起点(待验证)
+
+先用少量大色面安排新场景的心理重心,再细化轮廓、层叠和材质。动作可快可慢,色域随物体保持一致,禁止整帧随机换色。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 现代夜班便利店。
+- 一组没有人物的维修工具。
+- 办公室争论中的交接动作:不靠热带题材识别。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [大都会高更专题:跨媒介与象征主义](https://www.metmuseum.org/essays/paul-gauguin-1848-1903)
+- [《午休》:人物与平面空间](https://www.metmuseum.org/art/collection/search/436449)
+- [高更纽约馆藏展:绘画、雕塑、版画的差别](https://www.metmuseum.org/exhibitions/listings/2002/gauguin)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:黄昏染布院;事件:风鼓织物,象征色面相互支撑;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~65,品味项待花叔)
+
+- 路线:`scenes/48_gauguin.js`。全部形走 `MEDIUM.flat`(同色块里顺笔向的短条+深群青轮廓,宽度 5–8px);朱红色场、黄赭坡、紫褐斜树干把画面劈开,前景三位戴白帽的妇人被画框裁掉,男孩牵山羊缩成远景(缩小是为了不放大幼稚的造型)。
+- 实测:qa 确定性 ✓、无跳变、8ms/帧。
+- 关键教训:折线人物读成表情包,一律用平滑闭合曲线(场景内 `smooth()`);帽翼要画在脸后,脸不能被盖住。
+- 仍可改进:男孩和山羊仍幼稚;树干过直;缺高更的大面积紫褐阴影与象征性小动物。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/49_chagall.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/49_chagall.md"
new file mode 100644
index 0000000..5a668e8
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/49_chagall.md"
@@ -0,0 +1,59 @@
+# 49_chagall · 夏加尔:记忆空间与情感色彩
+
+状态:研究配方+单场景工程试作;2026-10-15建立并实做。已附`scenes/49_chagall.js`,用`render.py --film style_studies --solo 49_chagall --from 0 --to 6`运行;尚未通过画风忠实度或跨场景验证,不能借此升级为成熟画风。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以绘画中的诗性空间为主;早期村庄、后期宗教画和舞台/玻璃媒介分别比较,不抹平其差别。
+
+## 可迁移的视觉语言
+
+- 空间:方向、尺度和邻接关系可以服从情感,但观众仍需读懂主要行动。
+- 色彩:色域与局部形体共同表达情绪,不必固定某一组高饱和蓝红。
+- 造型:人物、动物和器物保持可辨认的性格,夸张与变形有联系。
+- 叙事:现实细节和记忆意象可以共存;意象来自新故事,而非现成象征清单。
+
+## 随需求变化的内容
+
+不强制漂浮情侣、提琴手、山羊、俄式村庄;没有飞行也可以研究这套空间和颜色关系。
+
+## 与近邻风格的区别
+
+区别于高更的大平面与轮廓;区别于达利的写实幻象,不能仅给写实物体做液化就称夏加尔。
+
+## 制作起点(待验证)
+
+先明确本次现实关系与情感关系,再决定哪里改变尺度或方向;所有变形保持角色身份与物体接触连续。动作节奏由叙事决定。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 两位远程同事跨时区协作。
+- 无人房间里的搬家物品与记忆。
+- 火车站的匆忙告别:避免自动添加飞天情侣。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [MoMA《我与村庄》](https://www.moma.org/collection/works/78984)
+- [MoMA《生日》](https://www.moma.org/collection/works/79360/)
+- [法国国家夏加尔博物馆:宗教主题收藏的边界](https://www.culture.gouv.fr/rechercher-une-publication-du-ministere-de-la-culture/repertoire-des-informations-publiques/Musees-des-Beaux-arts/musee-national-marc-chagall)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:搬家的记忆;事件:旧箱打开,花与信件飞向倒置空间;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/50_ma_yuan.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/50_ma_yuan.md"
new file mode 100644
index 0000000..d94b134
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/50_ma_yuan.md"
@@ -0,0 +1,68 @@
+# 50_ma_yuan · 马远:偏置重心、留白与精练笔墨
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评与独立复核均未达 80,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+以南宋马远山水和诗意小景为研究范围;「马一角」是组织倾向,不是固定左下角模板,也不等同所有中国水墨。
+
+## 可迁移的视觉语言
+
+- 空间:实景与未画出的空间相互建立尺度、方向和情境;空白不是待填背景。
+- 笔墨:有骨力的轮廓、皴擦与浓淡变化形成近景质地,远景更简练。
+- 构图:偏置重心和伸出画面的枝/岩等形成引导;可以更换方向、比例与主体。
+- 色光:墨与节制设色协作;不是整画去色、模糊或加宣纸纹。
+
+## 随需求变化的内容
+
+不强制古人、山水、某一角、孤舟、梅花或大块空屏;现代场景的留白也必须表达空间和事件。
+
+## 与近邻风格的区别
+
+区别于范宽的巨嶂体量与细密皴点;区别于泛水墨写意,不靠墨晕扩散作为唯一识别特征。
+
+## 制作起点(待验证)
+
+先以实体和负形安排新事件,再用有方向的笔锋、干湿和远近浓淡解释结构。留白中的动态只能揭示故事需要,不能加粒子去「填空」。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 冬夜站台上一名等车的人。
+- 无人工作台上被打开的折叠工具。
+- 两人在门口快速传递雨伞:检验动作变化与留白的关系。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [大都会《月下赏梅》:视觉诗与情境](https://www.metmuseum.org/art/collection/search/44638)
+- [故宫《山径春行》馆藏展示](https://south.npm.gov.tw/SelectionsDetailC004100.aspx?Cond=c693cd84-df8f-4e6f-8724-d7025ac43c20)
+- [大都会《桃花源》图录:继续核对不同花鸟山水](https://resources.metmuseum.org/resources/metpublications/pdf/Peach_Blossom_Spring_Gardens_and_Flowers_in_Chinese_Painting.pdf)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:崖边雨棚;事件:纸伞随风越过留白;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,第二轮自评 ~78,第一轮独立复核 74,品味项待花叔)
+
+- 原作锚定:《踏歌图》《梅石溪凫》《山径春行》。签名:绢底泛金褐、一角构图、斧劈皴(宽扁侧锋)、垂柳长枝、渺小的人看向空处、清墨渲远山无轮廓。
+- 路线:`scenes/50_ma_yuan.js`。`MEDIUM.silk` 绢底(经纬线+晕边)→ 远山 blur 渲染 → 岩石(多边形裁剪+宽扁 `P.brush` 斧劈+细硬皴+断续轮廓)→ 老柳干(顿挫粗线)→ 动态:垂条(成簇、弯、长短不一,逐条 `P.brush`,风吹摆动)、书生(背影、一笔衣纹、留绢、抬袖指向远处)、舟、鸟、水纹 → 绢纹相乘罩。
+- 实测:qa 确定性 ✓、无跳变、8ms/帧。
+- 教训:等距竖线的垂条读成栅栏;人物不填满、背影+衣纹最稳;雾带用径向渐变,矩形渐变会在边缘露接缝。
+- 第二轮试验:树干分段变宽读成竹节、斧劈改多边形楔读成箭头,均已回退;现用一气粗线加树皮短笔、短宽毛笔斧劈。
+- 仍可改进:岩石斧劈仍偏密;树干收笔偏钝;落款只有印没有字。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/51_persian_miniature.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/51_persian_miniature.md"
new file mode 100644
index 0000000..f70e833
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/51_persian_miniature.md"
@@ -0,0 +1,66 @@
+# 51_persian_miniature · 波斯细密画:层叠空间与精密叙事
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评与独立复核均未达 80,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+不是单一艺术家或单一时代。初始聚焦帖木儿晚期赫拉特与早期萨法维大不里士书画;制作前选定一个范围,不把所有波斯/莫卧儿绘画混用。
+
+## 可迁移的视觉语言
+
+- 空间:抬高视点、展开建筑和层叠景物,使多个事件可同时阅读;不硬套单点透视。
+- 造型:细线、清楚姿态与精密小物共同叙事,人物不是图案填充。
+- 色彩:矿物般饱满色域与细密纹样相互控制;金色用于合适的材料层。
+- 构成:文字区、边饰、画面可互相呼应,也可在无文字的新场景中保留组织逻辑。
+
+## 随需求变化的内容
+
+不强制花园、宫殿、地毯、波斯文字、边框或骑马人物;不拼凑不同地区纹样充当历史准确性。
+
+## 与近邻风格的区别
+
+区别于莫卧儿自然观察卡的精细写生,也不同于洛伦采蒂的城市实体连续空间;不要把三者统称「精致东方画」。
+
+## 制作起点(待验证)
+
+为新题材重建多层场所和行动路线,主体分层与图案分层分开;纹样跟随表面,运动时不能漂移。字需确有内容和可靠字形,否则不伪造书法。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 多层城市图书馆的书籍流转。
+- 现代食品工厂的完整协作过程。
+- 单件机械的分层检修:不用花园或宫殿验证迁移。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [大都会:沙阿塔赫马斯普《列王纪》研究](https://www.metmuseum.org/essays/the-shahnama-of-shah-tahmasp)
+- [大都会:《列王纪》跨时期馆藏说明](https://www.metmuseum.org/art/collection/search/446551)
+- [大都会宫廷艺术教学材料:不同页画对照](https://www.metmuseum.org/learn/educators/curriculum-resources/~/media/Files/Learn/For%20Educators/Publications%20for%20Educators/Islamic%20Teacher%20Resource/Unit5.pdf)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:水利庭院;事件:层叠空间里的水轮与水流;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~80,品味项待花叔)
+
+- 原作锚定:赫拉特《尤素福与祖莱哈》、花园浴女页、沙赫塔赫马斯普《列王纪》页。签名:地面像竖起的挂毯(俯视平铺)、建筑被切开露出内室、满铺几何瓷砖、金边+青金石蓝边框、文字块进画、人小而侧身大头巾。
+- 路线:`scenes/51_persian_miniature.js`,全程平涂+深褐轮廓;星形瓷砖周期取模满铺;八角水池、折线水渠(金边+青瓷)、树冠点叶;动态=汲水轮转、渠水金波沿折线流、金鱼绕池、花瓣飘、园丁摇杆、读书人呼吸。
+- 实测:qa 确定性 ✓、无跳变、3ms/帧。
+- 仍可改进:人物偏小偏简;文字块是假连笔;地面缺层叠。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/52_south_park.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/52_south_park.md"
new file mode 100644
index 0000000..9e22a52
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/52_south_park.md"
@@ -0,0 +1,65 @@
+# 52_south_park · 南方公园:数字剪纸与有限表演
+
+状态:研究配方;2026-10-16 已按 16 号协议重做演示(见文末「v2 实做」),自评与独立复核均未达 80,不登记为实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+研究该系列的主要数字剪纸视觉与表演语言;特殊集数的写实、动漫等画法不归为默认。官方2013年FAQ证明数字重建剪纸路线,不用它声称当前软件版本。
+
+## 可迁移的视觉语言
+
+- 造型:几何化、清楚的大剪影与少量关键五官;新角色有自己的比例和服饰识别点。
+- 材料:平面纸片层级、克制纹理与遮挡,不能自动升级为光滑3D或厚重纸雕。
+- 空间:背景为行动提供地点与接触,人物和道具共享平面尺度。
+- 表演:嘴形、眼神、姿态切换和停顿承担信息;有限动作不等于角色全程木偶滑行。
+
+## 随需求变化的内容
+
+不复制四位主角、雪镇、校车或台词;学习视觉不等于必须加入冒犯性笑料。
+
+## 与近邻风格的区别
+
+区别于Rick & Morty的细描边与更灵活线性角色;区别于皮影的透光材料和杆件关节。
+
+## 制作起点(待验证)
+
+明确选择本风格时,镜头表写`画风:52_south_park 南方公园式数字剪纸`和`角色:原创语义SVG纸片角色`;可用原创语义SVG纸片角色,按部件/枢轴/表情状态组织;这是平面风格的窄例外,不推广到真人或其他画风。纸纹绑定部件坐标,脚步与接触有状态,不仅整组平移。需生帧时仍可走10号。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 新设计的成年物业人员讨论漏水。
+- 无角色的自动售货机卡货:有限动作仍清楚。
+- 多人疏散的快动作:检验受限造型是否保持可读。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [South Park Studios:数字重建剪纸官方FAQ](https://southpark.cc.com/news/712d55/faq-do-you-still-use-construction-paper-to-animate-the-show)
+- [官方剧集入口:制作时选择不同场所与动作的片段对照](https://southpark.cc.com/)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:洗衣店意外;事件:原创成年角色按键、袜子飞出、惊讶反应;路线:代码绘制与动画。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+
+## v2 实做(2026-10-16,自评 ~75,品味项待花叔)
+
+- 签名:剪纸感(边缘抖动、纸纤维)、眼睛贴脸的两个白椭圆加黑点、梯形身体、黑短柱腿、平涂+细黑轮廓、整块平移/绕枢轴转。
+- 路线:`scenes/52_south_park.js`。每块形状用 `P.cut` 剪出抖动边缘;`kid()` 绕颈/肩枢轴动画;嘴是黑半椭圆开合;落雪 12fps 步进。题材换成公交站:校车滑入、车门啪地开、孩子排队跳上车。服装配色避开具名角色组合。
+- 实测:qa 确定性 ✓、无跳变、6ms/帧、运动 5.3%。
+- 仍可改进:孩子是同一个模子;上车只是平移加跳;缺嘴形配对白。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/53_pixar.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/53_pixar.md"
new file mode 100644
index 0000000..d5c33ce
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/53_pixar.md"
@@ -0,0 +1,61 @@
+# 53_pixar · 皮克斯:形体、材质与表演的风格家族
+
+状态:研究配方+单场景工程试作;2026-10-15建立并实做。已附`scenes/53_pixar.js`,用`render.py --film style_studies --solo 53_pixar --from 0 --to 6`运行;尚未通过画风忠实度或跨场景验证,不能借此升级为成熟画风。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md),再读本卡。作品用于比对视觉语言,人物、物品、构图和镜头不直接搬用。下面的稳定特征是研究归纳,实施与迁移方案是待验证假设;不得伪称官方参数或已实测能力。
+
+## 适用范围
+
+皮克斯不是单一画风。先按需求选择一个影片级美术范围;《Luca》的图形化绘画感、《Soul》现实纽约与抽象灵魂世界等不能无说明混为一体。
+
+## 可迁移的视觉语言
+
+- 形体:先设计可辨认剪影和大小比例,再做表面细节;大眼睛、圆脸和光滑塑料不是通用定义。
+- 材质:材质承担故事与性格,布、皮肤、金属等要有区别;反光不越过美术方向。
+- 光色:光引导叙事焦点,可风格化地调整物理规律;不是固定金色轮廓光或蓝紫背景。
+- 表演:姿态、重心、视线与预备/跟随动作连贯;情绪来自动作因果,不靠表情贴图乱换。
+
+## 随需求变化的内容
+
+不默认所有物体长脸、不套同一种萌脸;不复制已有角色或强制使用皮克斯软件。
+
+## 与近邻风格的区别
+
+区别于早期光追CGI卡的统一塑料和反射球;本卡将形体、不同材质和表演一起设计。不同影片之间也要辨明边界。
+
+## 制作起点(待验证)
+
+无脸物体场景可使用3D建模与物理/关键帧;人物与拟人角色当前遵循10号的帧库/合成路线。全3D角色建模绑定仍是待建设能力,不能绕过入口的角色规则或声称已获支持;只有经过画面验证后才能称某分支有效。纯代码要求不能以简单球柱人或一张AI背景冒充;先暴露建模、绑定、光照能力缺口。
+
+动作速度、帧率、镜头和配乐按本次叙事确定;不把画面的安静气质等同慢动作。工程接入遵循[风格作者规范](../08-风格作者规范.md),新渲染器实做后才登记引擎id。
+
+## 跨场景验证题(不是固定模板)
+
+- 原创成年修理员排查机器故障。
+- 无人洗衣房里失衡的洗衣机:不加脸也有事件。
+- 新设计的动物角色在湿滑地面搬物:核体量、接触和材质。
+
+至少选不同题材/空间尺度/主体类型的测试;不要求每次完整跑一遍。静帧与动态验收分别记,未覆盖的范围继续标为待验证。
+
+## 参考与证据边界
+
+- [Pixar RenderMan:风格化贯穿造型、材质、光和特效](https://prod.renderman.pixar.com/stories/stylization-at-pixar)
+- [Pixar《Luca》:影片级美术范围](https://www.pixar.com/luca)
+- [Pixar《Soul》:现实环境分支](https://www.pixar.com/soul)
+- [Pixar RenderMan:《Soul》的摄影、材质与光](https://renderman.pixar.com/stories/cinematography-with-soul)
+
+一手馆藏/制作资料用于核查作品与方法;百科入口只辅助定位。开工仍需实际并看多幅原作或不同场景片段,记录稳定特征和例外;作品列表不等于已经完成多图视觉实验。
+
+## 使用后回流
+
+使用前查看本节最新已验证结论;当前有6秒单场景输出的技术检查;画风忠实度与跨场景视觉验证未完成。后续只记录影响结果的发现:日期、题材、采用路线、参考与输出路径/哈希、问题、修法、验证状态和适用范围。失效结论改原句,不追加矛盾规则。跨场景复现后才把研究假设升为实做配方;可重复的工程问题优先修工具并测试。用户偏好单独进入品味档案,不扩张授权。
+
+
+### 2026-10-15 · 单场景试作回流
+
+- 场景:无脸洗衣机;事件:滚筒受阻、机身晃动、开门后布料落地;路线:程序化3D。
+- 检查:确定性复测、完整MP4解码及独立抽帧审片;短片快动指标按现有门禁降黄,不能推导长片达标。
+- 边界:这次只证明该工程可运行并可观看;艺术家/工作室风格相似度仍有限,不能把几何、色板或纹理参数当最终标准。
+- 实修:门的开启先于布料释放,衣布终点按地砖高度约束;独立复核销掉原时序和贴地感问题。这是解析网格,不是物理布料仿真。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/55_dunhuang.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/55_dunhuang.md"
new file mode 100644
index 0000000..d25e3f2
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/55_dunhuang.md"
@@ -0,0 +1,41 @@
+# 55_dunhuang · 敦煌壁画(北朝):干泥壁上的矿物色与横飞的线
+
+状态:研究配方;2026-10-16 新增 v1 演示(见文末「v1 实做」),自评 ~72,未过 80,不登记为成熟实做。
+
+## 起手必查
+
+先读[跨场景风格提炼](../15-跨场景风格提炼.md)与[16 号协议](../16-风格演示95分协议.md),再读本卡。原作只用于比对视觉语言,人物、构图和题材不直接搬用。下面「稳定特征」来自这次实际看过的原作,不是官方参数。
+
+## 范围
+
+先选定一个时期再做,不把北朝、盛唐、晚唐混成一张「敦煌风」:
+- 北朝(257 窟鹿王本生、285 窟西魏飞天、428 窟北周):土红地、白色走兽、锯齿山、青绿风叶、横飞的飞天。本卡 v1 做的是这一支。
+- 盛唐(112 窟反弹琵琶、45 窟菩萨):满铺的金碧、丰腴的人物、成组的乐舞。还没做。
+
+## 稳定特征(原作观察)
+
+- 地:257 是整面土红 #92342d 一类;285 是奶白 #e8dcc5;两者可以上下分栏,栏间一道多色横带(黑/白/青/赭)加联珠。
+- 形:走兽是一整块白、轮廓一线、内部几乎无线;山是一排排窄高的锯齿三角,各涂一色、一侧压暗,大面积红地露在山与山之间;人物小、横向展开。
+- 飞天(285 窟):水平横飞,头在前,披帛向后扬,下身化成一条拖到身后的长裙;脸小,眉眼细长,颊有红晕;线是红褐的铁线/兰叶描。
+- 风叶:逗号形的青绿卷叶,成群向后翻。
+- 色:石青 #3e919c、石绿 #577f7a、朱、赭、铅白;铅白年久氧化发暗,428 窟的肌肤发灰蓝。
+- 壁面:龟裂、起甲露出底层、盐碱泛白、泥壁颗粒;裂缝穿过画中的人和兽。顶部菱格带、底部垂幔三角带。
+
+## 与近邻风格的区别
+
+不是波斯细密画(满铺、精密、金线);不是乔托(湿壁画的灰泥罩白);不是国风插画(那种是光洁的渐变和云纹)。敦煌的质感是「干、旧、裂」,颜色是矿物不是颜料。
+
+## 制作路线(v1 用的)
+
+`scenes/55_dunhuang.js`:墙底(P.texture 泥质)→ 上下两栏+横带+顶部菱格+底部垂幔(缓存)→ 锯齿山(缓存)→ 动态:风叶按速度分层向左翻、飞天(`apsara()`,变宽飘带 `ribbon()`)、散花、白鹿奔跑(`deer()`,腾空—收拢两拍)、蹄尘 → 覆盖层(龟裂、起甲、盐碱,盖在画上面)→ 泥壁颗粒相乘。
+
+## v1 实做(2026-10-16,自评 ~72,品味项待花叔)
+
+- 原作锚定:257 窟鹿王本生、285 窟西魏飞天、428 窟北周飞天、112 窟反弹琵琶(来源见 fetch_reference 生成的参考.md;112 窟和 257 窟的图是拼图翻拍,只取色板与构图,不临摹)。
+- 动态:风叶后翻、飞天上下浮动与飘带摆动、散花下落、白鹿与小鹿奔跑、蹄尘、漂尘。
+- 已知不足:山仍偏几何三角、缺 257 窟那种层层叠压的节奏;飞天躯干偏平、缺半侧身的立体;颜色未做铅白氧化变暗;未做盛唐一支。
+- 尚未验证:跨题材(把飞天换成别的主体)、竖屏、与口播片的合成。
+
+## 使用后回流
+
+使用前先看本节最新结论。有新发现只记:日期、题材、做法、问题、修法、验证状态、适用范围。失效结论改原句,不追加矛盾规则;跨场景复现后才把研究假设升为实做配方。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/INDEX.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/INDEX.md"
index 31a1f67..6d0b890 100644
--- "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/INDEX.md"
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/INDEX.md"
@@ -1,10 +1,40 @@
-# 风格总索引(36 种,2026-10-14 更新)
+# 风格总索引(36种既有实做+16种研究配方,2026-10-15更新)
> **先读这一句:35 张样片是同一个构图**(窗在左上、猫在左下、少女在右侧端杯;`assets/全风格总览.jpg` 也是)。那是艺术史速通那支片子的机制——风格在变、场景不变——不是这些风格的构图。做新题材要为题材重新构图:卡里的渲染器、笔法、色彩逻辑、母题动法可以拿走,房间里的坐标、角色、家具不要搬过去。
-选风格先看下面两张表,再打开对应卡片。「质量」是当前实做水平(★★★ 一眼认得、可直接用;★★ 认得出但有明显短板;★ 要重做),不是风格本身的难度。短板就是下一次做这个风格时该先超越的地方。
+选风格先看下面的状态与分类表,再打开对应卡片。「质量」是当前实做水平(★★★ 一眼认得、可直接用;★★ 认得出但有明显短板;★ 要重做),不是风格本身的难度。短板就是下一次做这个风格时该先超越的地方。
-风格分两层。**材料层**:笔法、材质、光和色的处理,可以盖在任何题材上(讲产品、讲数据、讲故事都行)。**时代标本**:和某个时代、某位艺术家绑得很紧,适合速通、穿越、致敬这类片子;拿来讲别的题材多半显得突兀。拿不准的放在材料层,同一种风格两边都沾时(如霍珀的硬边光块是可迁移的光照处理)按你的用法判断。
+风格分两层。**材料层**:笔法、材质、光和色的处理,可以盖在任何题材上(讲产品、讲数据、讲故事都行)。**时代标本**:当前样片把时代或艺术家母题做得很突出,直接搬用适合速通、穿越、致敬;移到新题材应重新提炼视觉语言和构图,不把样片局限当成艺术家本身的限制。拿不准的放在材料层,同一种风格两边都沾时(如霍珀的硬边光块是可迁移的光照处理)按你的用法判断。
+
+## 先看状态与迁移范围
+
+新增研究卡已附单场景工程试作(`--film style_studies`),可观看,但未通过画风忠实度与跨场景验证;下方既有卡的星级不适用于它们。首次跨题材使用读[15号方法](../15-跨场景风格提炼.md)。材料层/时代标本是既有样片的组织方式,不是对艺术家整体风格可用题材的永久限制;能否迁移由新场景验证。名作中的内容和固定坐标不进入风格定义。
+
+## 新增研究配方(17种;2026-10-16 起按 16 号协议逐个重做)
+
+**重做状态**:38 乔托、42 瓜尔迪、45 雷诺阿、46 毕沙罗、47 西斯莱、48 高更、50 马远、51 波斯细密画、52 南方公园已按[16号协议](../16-风格演示95分协议.md)重做演示(原作锚定+`lib/medium.js` 媒介通道)。自评 65–82、独立复核 53–74(42、45 未复核),**没有一个到 80,所以全部仍是「研究配方」,不是实做**,品味项待花叔看;其余 8 个仍是 10-15 的旧试作(质量约 35–55,不要当可用实做)。进度与各自短板见[_重做进度](_重做进度.md)。旧版备份在 skill 根目录 `_archive/scenes_20261016/`。
+
+| 卡片 | 研究范围 | 实现状态 |
+|---|---|---|
+| [38_giotto](38_giotto.md) | 乔托:体块与叙事关系 | 研究配方;有单场景原型 |
+| [39_piero](39_piero.md) | 皮耶罗:几何秩序与清明体积 | 研究配方;有单场景原型 |
+| [40_raphael](40_raphael.md) | 拉斐尔:和谐组织与自然联系 | 研究配方;有单场景原型 |
+| [41_michelangelo](41_michelangelo.md) | 米开朗基罗:雕塑性与姿态张力 | 研究配方;有单场景原型 |
+| [42_guardi](42_guardi.md) | 瓜尔迪:空气、碎光与松动边缘 | 研究配方;有单场景原型 |
+| [43_lorenzetti](43_lorenzetti.md) | 安布罗焦·洛伦采蒂:可阅读的社会空间 | 研究配方;有单场景原型 |
+| [44_cortona](44_cortona.md) | 彼得罗·达·科尔托纳:巴洛克体量与流动群组 | 研究配方;有单场景原型 |
+| [45_renoir](45_renoir.md) | 雷诺阿:暖冷交织与有温度的人物 | 研究配方;有单场景原型 |
+| [46_pissarro](46_pissarro.md) | 毕沙罗:生活流动与环境中的人物 | 研究配方;有单场景原型 |
+| [47_sisley](47_sisley.md) | 西斯莱:空气、天气与连贯风景 | 研究配方;有单场景原型 |
+| [48_gauguin](48_gauguin.md) | 高更:平面、轮廓与象征色 | 研究配方;有单场景原型 |
+| [49_chagall](49_chagall.md) | 夏加尔:记忆空间与情感色彩 | 研究配方;有单场景原型 |
+| [50_ma_yuan](50_ma_yuan.md) | 马远:偏置重心、留白与精练笔墨 | 研究配方;有单场景原型 |
+| [51_persian_miniature](51_persian_miniature.md) | 波斯细密画:层叠空间与精密叙事 | 研究配方;有单场景原型 |
+| [52_south_park](52_south_park.md) | 南方公园:数字剪纸与有限表演 | 研究配方;有单场景原型 |
+| [53_pixar](53_pixar.md) | 皮克斯:形体、材质与表演的风格家族 | 研究配方;有单场景原型 |
+| [55_dunhuang](55_dunhuang.md) | 敦煌壁画(北朝):干泥壁上的矿物色与横飞的线 | 研究配方;有单场景原型(v1,~72) |
+
+吉卜力不是新增计数:[25_ghibli](25_ghibli.md)保留原水彩背景实做,并新增整体视觉与表演研究;后者不能借用旧场景的实测成绩。
## 材料层(可盖在任何题材上)
@@ -13,7 +43,7 @@
| 09_postimp | 梵高 | 流场笔触三遍(墙竖长/地透视/其余)+区域色板+描边;道具层;visibleLines 补线 | 星空漩涡、灯晕环外扩、方向场火苗般摇曳、漩涡猫 | 星空漩涡卷入 | ★★★(标杆) | 每帧 120ms 最重 |
| 08_impressionism | 印象派 | 区域粉彩色板短笔触(位置固定)、窗景细笔 | 光斑漂移明灭、罂粟摇、云走、丝带飘 | 笔触色点铺满 | ★★ | 脸和手被笔触打碎 |
| 29_seurat | 修拉点彩 | 视觉混色:21 色纯色板按比例并置、补色点、等大点 | 光渗、点在呼吸 | 画面结晶成圆点 | ★★ | 偏静;网格规整 |
-| 25_ghibli | 吉卜力水彩背景 | 水彩洗染(透明叠色+水痕边)、赛璐璐月牙影 | 纱帘被风鼓起、草叶成片摆、树影光斑 | 湿纸晕开 | ★★ | 人物不如背景 |
+| 25_ghibli | 吉卜力(既有水彩背景+整体语言研究) | 水彩洗染(透明叠色+水痕边)、赛璐璐月牙影 | 纱帘被风鼓起、草叶成片摆、树影光斑 | 湿纸晕开 | ★★ | 人物不如背景 |
| 17_ink | 中国水墨写意 | 毛笔笔锋飞白、墨晕 blur 洇开、留白、钤印 | 开场笔触自己写出、墨晕扩散、虾须动 | (速通里开场) | ★★ | 人物不够写意(审片 6/10) |
| 13_pop | 利希滕斯坦波普 | 本戴点 createPattern、粗黑描边 | 沃霍尔四格换色、思考点闪、猫扭臀、拟声框抖 | 闪电+网点化 | ★★★ | — |
| 14_8bit | 8-bit 像素 | 240×135 逐像素、14 色板、部件 1px 黑边 | 尾巴、HUD 心闪、问号块顶金币(15–30fps 步进) | 像素块放大缩小 | ★★★ | 猫头压窗台 |
@@ -52,7 +82,7 @@
| 36_picasso_blue | 毕加索蓝色时期 | 单色蓝调、宽笔触、普鲁士蓝粗轮廓、人体拉长 | 缓慢呼吸 | 颜色抽成蓝再宽笔刷过 | ★★ | 造型不够忧郁 |
| 37_rick_morty | [Rick & Morty](37_rick_morty.md) | SVG圆角深灰细描边、平涂、背景斑驳 | 端杯、眨眼、目光、摆尾 | 按叙事另定 | ★★ | 独立SVG预览/渲染,不在旧35种Canvas gallery内;无行走rig |
-## 质量分布与下一步
+## 既有36种实做的质量分布与下一步
- ★★★ 20 种、★★ 15 种、★ 1 种。
- **最普遍的短板是角色**:背景过了风格渲染器就像那个风格,角色只用矢量骨架平涂就像贴上去的(正面经验第 8 条)。下一轮提质先从「角色也过同一个渲染器/按该风格重塑造型」做起:伦勃朗、毕加索蓝、水墨、吉卜力、达利、漫威。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\351\207\215\345\201\232\350\277\233\345\272\246.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\351\207\215\345\201\232\350\277\233\345\272\246.md"
new file mode 100644
index 0000000..9ceff01
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\351\207\215\345\201\232\350\277\233\345\272\246.md"
@@ -0,0 +1,37 @@
+# 新增风格演示重做进度(2026-10-16 起,协议见 16 号)
+
+旧场景(2026-10-15 版)备份在 `_archive/scenes_20261016/`。重做的新场景直接覆盖 `scripts/engine/scenes/<id>.js`,同 id、同 `--film style_studies`。
+原作参考本体不入库(需要时重跑 `fetch_reference.py`);总览图和并排图存在 `assets/新风格v2_证据/`,后人可复核打分。
+
+自评分是排序用的(协议第 6 步),品味项归花叔。
+
+| id | 风格 | 状态 | 自评 | 独立复核 | 现在的短板(下一轮先超越) |
+|---|---|---|---|---|---|
+| 38 | 乔托 | 研究配方(人物重做后) | ~70 | ~53(第一轮) | 三人轮廓拉开(袍宽不同)、手改掌+指、交接时两手真正托箱;仍缺群像密度,灰泥偏颗粒 |
+| 42 | 瓜尔迪 | 研究配方(v2 演示已做,未经独立复核) | ~78 | — | 塔笔触偏叠砖;人物仅剪影;缺闪烁白点 |
+| 46 | 毕沙罗 | 研究配方(v2 演示已做,未达 80) | ~75 | ~58 | 树冠像花椰菜、树干像棕榈;人物小了帽但脸仍简;已删挡教堂的树 |
+| 47 | 西斯莱 | 研究配方(v2 演示已做,未达 80) | ~80 | ~68 | 房屋像平板、窗成黑块;白杨像海草;已修左缘缺口、电线杆、货物改麻袋 |
+| 48 | 高更 | 研究配方(妇人头部重画后) | ~74 | — | 妇人改侧脸+高白帽冠+白披领,小牛改带斑;男孩仍偏简单,树干体量偏大 |
+| 50 | 马远 | 研究配方(v2 第二轮,最接近 80) | ~78(第二轮自评,未独立复核) | ~74(第一轮) | 斧劈改短宽楔笔后仍偏密;树干用一气粗线(分段读成竹节、多边形斧劈读成箭头,两次试验已弃);落款只有印;qa 因机器高负载加载超时,改以多时刻静帧确认无报错有动态 |
+| 51 | 波斯细密画 | 研究配方(人物重做后) | ~72 | ~63(第一轮) | 人物改萨法维式:修长、小头、高头巾加红冠杆、束腰长袍、小花散点;读书人偏小、脸无表情 |
+| 52 | 南方公园式剪纸 | 研究配方(v2 演示已做,未达 80) | ~75 | ~63 | 已修:单列依次上车不叠、站牌不再被挡、换掉近似 Cartman 的帽色;仍是原剧片头式题材 |
+| 39–41, 43, 44 | 皮耶罗、拉斐尔、米开朗基罗、洛伦采蒂、科尔托纳 | 未重做 | 旧版 ~35 | — | 39/40/43/44 走壁画通道(但壁画通道目前只有 38 一例,自身只有 ~53,不要当成熟能力);41 要雕塑感人物 |
+| 45 | 雷诺阿 | 研究配方(人物重做后) | ~72 | — | 人物改修长身形(窄肩收腰钟形裙、小头、弯臂),前景一对相拥华尔兹(女在前);背景人群仍小且排得偏齐;缺原作的粉彩肤光 |
+| 49 | 夏加尔 | 未重做 | 旧版 ~40 | — | 记忆空间:漂浮、倾斜、色块情感 |
+| 53 | 皮克斯 | 未重做 | 旧版 ~55 | — | 材质与次表面光;three.js 路线 |
+| 54 | 吉卜力方向 | 未重做 | 旧版 ~45 | — | 云、风、水彩背景密度 |
+
+「独立复核」来自 2026-10-16 一个没参与制作的审查 agent 按 16 号评分表打的分(它的完整报告没落盘,要点已吸收进上表与协议)。自评与复核差 7–17 分;以较低者为准。**没有一个到 80,所以全部写「研究配方」,不登记为实做**——这是协议第 6 步自己的规则。
+
+证据(总览图、六张原作并排图):`assets/新风格v2_证据/`。
+
+## 下一轮的做法(照搬这轮跑通的流程)
+
+1. `fetch_reference.py` 拉 3 幅原作 → 看接触表 → 写 5 条签名(必须有/加分/禁忌)。
+2. 题材按风格自己的构图规则重定;形层 → `lib/medium.js` 通道。
+3. 一帧先行 → `side_by_side.py` 并排 → 打分。最多两轮。
+4. 做完补进本表,并把配方卡「状态」「仍可改进」改成实测结论。
+| 43 | 洛伦采蒂 | 研究配方(v2 三轮,人物重做后) | ~72 | — | 人物已改修长长袍3/4侧身并有 20 人人流;仍缺原作的颜料层厚度与透视纵深;只有两幅不同原作 |
+| 40 | 拉斐尔 | 研究配方(v2 一轮,人物沿用 figure) | ~70 | — | 透视拱顶藻井与棋盘地成立、三组人手眼互相咬合;人物仍是钟形袍、脸雷同;缺原作的肤色与衣料光泽 |
+| 41 | 米开朗基罗 | 研究配方(v2 两轮,红粉笔素描路线) | ~70 | — | S 形扭转、长臂、肩胛背阔肌明暗成立;头仍偏圆、缺手的细节;亮处留纸对比可再强 |
+| 44 | 科尔托纳 | 研究配方(v2 三轮:云团重做) | ~70 | — | 画框+金圆章+中心放射金光+云团+人群旋转+红蓝衣带成立;人物仍是钟形袍,缺巴洛克的强短缩与强明暗;云的高光弧线偏卡通;只有两幅不同原作 |
diff --git a/release-manifest.json b/release-manifest.json
index 73f5982..d074c9b 100644
--- a/release-manifest.json
+++ b/release-manifest.json
@@ -3,12 +3,12 @@
"files": {
".github/workflows/tests.yml": "91b5797ea6f59b6e31e53de2a846194e33ab1dbe24b2efb8c0ed4367324f8fbe",
".gitignore": "28b7c75378a153807b8127362ba5e627b91870edf5170b7b3847fb19acf3d8a9",
- "CHANGELOG.md": "cc64bfb44299002b3fcb50e669bc777bb48de7dae86233aad323c4afb52d9228",
+ "CHANGELOG.md": "a3ad116f8641235915ab7d6379a6e8cc54cd95a4a98b0196e17dec4376f26a13",
"CONTRIBUTING.md": "742a1a6071f6be25e82f0524a520fd6d09961be3f87d7a85940cd816ce7309a1",
"LICENSE": "6d6a2a9caf2e6d2b76974050427053b2892d8aa4c33fd168ce63a537fcee9d96",
"README.en.md": "c2ddbb92ed6a38d222b188527d954e0a6759d329dc2cc51b37ba3e48931d57de",
- "README.md": "32367d8b6a442441e1de7e74216028670793e655c9ab62aac1b0c0d8df8c8136",
- "SKILL.md": "9fc1855f9081998b99797e4017523cd8c70d743f3da860812ae5828debb74911",
+ "README.md": "848ab75a8d2f69e9354f7059da7f654ca3bf686114c2e7409b09f22d058627f1",
+ "SKILL.md": "df73e57c621425a82670ea74c68e8516d02553cf77cfe41c5f55883c542afb0a",
"assets/showcase/clawd-clips.md": "e986e40a1a8bfccdcf745a3afad0c5c40889f4263eaa6afaedd089dea23cd7fb",
"assets/showcase/clawd-dawn.gif": "5d512f5c2949c9576a03c970d646175a9f2755877010b359cc9282445944f252",
"assets/showcase/clawd-trex.gif": "6e3355bc8a9d8378bf2e23ca6a9b6601293c5638ea3d5db3fb164fc4826377f0",
@@ -30,6 +30,17 @@
"assets/动画语法/y3_whiteboard_总览.jpg": "cc28d7e021d8bc094387f4e65627ad940417459250502e586e3f2fe9603ae841",
"assets/动画语法/y4_storytime_总览.jpg": "6cc308bee5624a6e11f063185af67bb1625332a44aabedb22f1329b1f60cfdc5",
"assets/动画语法/y5_kinetic_type_总览.jpg": "fbc1612a831eeaa05f03bdef32b477dc459769834f57ad6331517ebfb92651b9",
+ "assets/新风格v2_证据/38_giotto.jpg": "85f6911b2ae64b6dbb945c22d76f1fb4dddf8c0cb6e77f7b09ca56e0b245f127",
+ "assets/新风格v2_证据/40_raphael.jpg": "570f368fd51286ac880f35c229a5f3785820b3036c45e723adb41a963ef395b0",
+ "assets/新风格v2_证据/41_michelangelo.jpg": "916b9dfe205d1e4c83a2f8110cc55d5f41f36b3ed7e7cf2f35af341da675b304",
+ "assets/新风格v2_证据/43_lorenzetti.jpg": "564cde057ef731861b67ba944af499fd76931229124269718c2f894f6ae19626",
+ "assets/新风格v2_证据/44_cortona.jpg": "63fc0338750cfd012d63b9e987877d5a39f0cc69655e34edba88c212e450e989",
+ "assets/新风格v2_证据/46_pissarro.jpg": "1832c57ba66d57c48971dc1b7166c7ca5f9840bc7744dd5b54179d15c341389d",
+ "assets/新风格v2_证据/47_sisley.jpg": "7c46c04642f629a48d8289228c6084b5ce0b839110ea251dbc11d69afd9551b3",
+ "assets/新风格v2_证据/48_gauguin.jpg": "0a1095b4d34b0e49b408be6091dcdefa25455b12f9aeccfa54f900f444fbd159",
+ "assets/新风格v2_证据/50_ma_yuan.jpg": "31e7ddc85bd3db1a2e2ead25f6d25d98092da68a2c3b1ecc0b6a7eeb518be2f8",
+ "assets/新风格v2_证据/51_persian_miniature.jpg": "de1a2b6c472da7163207dd7974e241732213c3fb73c8c1727075bdb2fd421222",
+ "assets/新风格v2_证据/总览.jpg": "966ab7f6f423081edfb14509d165f2989a8d1a3cc440b0c3650b52d03e648156",
"assets/角色/花叔形象_对比.jpg": "e2dd1082f5a6d6c66182b27b16a71ad9b6426e567ff4b406e4ebec007e044615",
"assets/长卷穿越_总览.jpg": "3f925f5637553c2b5bc57052f65f8065dbd14837c9881bb5d8e2bb898f29dba4",
"defaults/media.json": "8e1c98a9b5b8195f66c4060e05e5dded9bb95b797164a8b9c587bdfa5df4e0b4",
@@ -40,16 +51,19 @@
"references/05-节奏与配乐.md": "1086c15ea216548777d2fa5552cd5c874ff89df2da84f9ffa160737930e3d98f",
"references/06-口播驱动的艺术短片.md": "9275abd6451831515ed9aed24724062bf47dda5e5d2d804baa8313c137236bc8",
"references/07-正面经验.md": "b151c1cc6932a3cbc66b03d847e8a1b547073dc5a28d836a05da5ae9a11cb79b",
- "references/08-风格作者规范.md": "30312801d2833b478bc80218a704d87971c08f50a7ee0e31f3c08eefe15f9b4e",
+ "references/08-风格作者规范.md": "b7db67c8418410dec8313b7212e2aa52f9db8d8395b26cc0b72c19ab1a376728",
"references/09-视频动画语法.md": "2a2e3256fc5dd2ba1e0c96312e0fa63299ff3a5f0bb9d1bcf84539af902a26e1",
"references/10-角色.md": "d0c90c6c82b9acba9a43b8f0f4231ae4aa2f316a39608af90e06e5462c736605",
"references/11-长卷穿越片.md": "42f2e441687116c8d2dd789b187ada572390e242976996727a209959163a6ad6",
"references/12-口播整片与经验回流.md": "b85f6e8b665c13a5d98ea461c10af340679a6949101ee31dd64eee7e88aed415",
"references/13-口播与语音复刻.md": "cb12d2002f9c7a8a41b9abd711bd44a99f9929bcd66351015232cea2eda024a6",
+ "references/15-跨场景风格提炼.md": "377920a1eb20da5d90bfd7af3f31fc2183b193cac2558d3f828afbf6bc5ad645",
+ "references/16-风格演示95分协议.md": "bfb400c87ec844fb04450b453c502c47455c5b4b90cf9e2800283886d7ee61ea",
"references/about-author.md": "4bb3dd5b67560d039762abf695b92701348fbdfd488f4f5428cd8383b2c107c5",
"references/capabilities.md": "8d0577a8128d661711a3ca26f1b60a1e3d06cc5b6191b7007326dccd0e35d2ed",
"references/compatibility.md": "c5665580fab722a3ed784a71f5cca725fc56cebf8c8c3ad66219b24b6b97bb0e",
"references/images.md": "313bee677064eb46ee13c88c74effeecdb536579d7e8a25e23ddf9a2a06357e3",
+ "references/voice-model-review.md": "e8559c64b39ca361909d8a9ba4e31bcad4c273213aa075000908f1cbeaf8e790",
"references/动画语法/t1_3b1b.md": "23fc11ea77a5f14b34768398f61240787e459debeac8f3fd5109f6ea5e43d827",
"references/动画语法/t2_keynote_ui.md": "0e2779a2e755f0513a8ac025482e542a4d873b02f0b00f0e908216e26d5a9625",
"references/动画语法/t3_finance_chart.md": "ea1e21c49b50653ad48d0bd4ab0d1b1e88a698ccfbfd8e257c7e8f767adf2c20",
@@ -61,7 +75,7 @@
"references/动画语法/y6_presenter_explainer.md": "405318fc5aac9ce03cbc374af9633ec7d652dc8206ad3810919abdb174eff273",
"references/口播API.md": "a9d2775fc97bf92f46cf0a6531f1921ccdcf195dd79475c575bf8f188ca5801e",
"references/色板.md": "3a1588ded19aba078131423b22f97fb8835f1656c1c5643afbba505ff8f6f8ae",
- "references/角色精细度.md": "7255ec6d9106843359ef5ab4b696a93a9a573aafdebbd26baf235597949b0f35",
+ "references/角色精细度.md": "15d1607771c5553942cba89edd22a8e8af0f8dfdb16977fd180b7babe5a2dbb6",
"references/镜头表模板.md": "aef6aae50eaae318f1090a8135640bebb36974f6bbc537bc34253959d3523cae",
"references/镜头语言.md": "7afbf9266b4e530a183e7c682ffb55166645a3cd9e628f1b5ace4ebb22d8d2eb",
"references/风格配方/01_cave.md": "ebdb5fc8f9a57d947ef3a325bfdaf275cbd906e36010945e05c7d2e7ef1f4d2c",
@@ -87,7 +101,7 @@
"references/风格配方/22_constructivism.md": "ff4adc806f0bf39d86136d805ef8e2cc48026fbcec3731fae22477fdafac846d",
"references/风格配方/23_dali.md": "facf3f033d5dbe42ab663860490a32920423fc5950ddcabf5f44bf81b49b3f2f",
"references/风格配方/24_hopper.md": "fd19a530f9e0544d74e7eee40a88c01fa7f675ae94d9cacf2e5af4e214c64c63",
- "references/风格配方/25_ghibli.md": "55522029929a296979180e6fac3556c7d85ea92de1369a4f11e94fbb64f48348",
+ "references/风格配方/25_ghibli.md": "d094be1b497fd9635ef802f1997878696db98cfbc07ff81dd7bbc50442bf0a17",
"references/风格配方/26_vaporwave.md": "30cf8e825125ff74f02bff93b975a74c96ceae9df09fae06fd7ef887fb64ec44",
"references/风格配方/27_kirby.md": "e64b8a69ce706311b1e81aa7d0756c7d7390b2b3f84a17f18b67c3193bce2408",
"references/风格配方/28_monet.md": "61b2bf9da6044e44ea0fa4758b3c380be8e60cfb72e2907e5afbbaa0c00d3513",
@@ -99,26 +113,51 @@
"references/风格配方/34_shadowpuppet.md": "6cd4f9a090bff6d325695e8e4656ad041871f2ff0418b4eab1a46d51bd7d7609",
"references/风格配方/35_shinkai.md": "b327bf36ef2edc246576cbfb8f1f1857c52600691adbd651efbb1eeb75e7a554",
"references/风格配方/36_picasso_blue.md": "7578a99b0dc416414eb2cfd5c6aa9055ded387531bfde65fd5c1f17f22e4404a",
- "references/风格配方/37_rick_morty.md": "39e13d7a1cbe9e1637e3827fa17581e5b85df8843f4b05ee709967ab58efad16",
- "references/风格配方/INDEX.md": "8367c835283fa3dfed2c0fc9a39ef0bbd6076e71a1ea4e853373dd02e715e427",
+ "references/风格配方/37_rick_morty.md": "321e3009c33faf400cf3242d87377d1777544a2ab2f59c9de8da11a141c3aed7",
+ "references/风格配方/38_giotto.md": "591e4412ba5c0ef7568f1ccec0400c32bda1f7e31fda693d2397cb46b946ca2b",
+ "references/风格配方/39_piero.md": "a722bd0b3ba3168620d3d0bd13d1b6b576fe3a38c48995ad98d0155651a6ef14",
+ "references/风格配方/40_raphael.md": "fcd0352a413ccbe7a7baf9fceb7153fc70807fbdff534ac0bcb55e2129e82db9",
+ "references/风格配方/41_michelangelo.md": "d902c85020ac27b74e94ff4658529bd4fb32e5092a1d723234fa4f39eee33645",
+ "references/风格配方/42_guardi.md": "2ebe3d12fa81b0a84367f49ac955590d8a9b1daf78675ddab9badac15e44aa9a",
+ "references/风格配方/43_lorenzetti.md": "d3e42f457027a2670b6e7d10798d55fa9fc42536e5cf68f90442a2c3b7405bbe",
+ "references/风格配方/44_cortona.md": "9fb3935cd7d853ca9c0da0c18e6c5dbbe591e1ab54f5259b59b6f79654f75819",
+ "references/风格配方/45_renoir.md": "b85f06fc351343902929c1ee6bfaad936d36b3fdafae0f1af95e66dbd36b14d3",
+ "references/风格配方/46_pissarro.md": "9cd428ac8276c9b7134c04b9ecd49530c3c9989b7e6cc087de312f1d2faa372c",
+ "references/风格配方/47_sisley.md": "787eb8a787b01e810ca369032ba8524fc425087c0c2fa2c36b09b7e290e0a576",
+ "references/风格配方/48_gauguin.md": "5e785b76ff0e1d4b976ff7b80559d3faf9ad84a3bcb97de4d0148d45f118b37b",
+ "references/风格配方/49_chagall.md": "2fca334d05347c1dcfbaaf7bfdd525c749ec175c076c5657bca9faa61f3bcde8",
+ "references/风格配方/50_ma_yuan.md": "962b0d5b23727646cd36e3083f2b263be0b589ae1186da7856760cf232ec2ed5",
+ "references/风格配方/51_persian_miniature.md": "619741242ba640ca931d5dda6bbb8d1b9d5a456e056dc7db956a1051090a818b",
+ "references/风格配方/52_south_park.md": "639b0b2e5fb0894dc3b44a4da67cac3ed986dc043ded886153abd2fec75ea9d8",
+ "references/风格配方/53_pixar.md": "c6b0eea92294aa08e53ed71a6068f96a6cccd29e679aa2bcf0df9478ef100aa2",
+ "references/风格配方/55_dunhuang.md": "ebf193ac4995dff6f146cf54ff62def57da5f8794ab2bdb8e7d0f18714af35f6",
+ "references/风格配方/INDEX.md": "3a79ab6eed9ddc93c08ecdd529103d9a7ade77c1d23aa36eb236215ad0ef9cea",
"references/风格配方/_转场_迁移测试.md": "16e901fb8c6bb2b9ff6596bec30209471227b74440dc9d5f3ba7931c99238677",
+ "references/风格配方/_重做进度.md": "2f83dabb5b810ce2b95b5012e15321d6dc2565a3bfff77f35a679683ea0bc82a",
"references/风格配方/_音轨_艺术史速通.md": "f9c360503ec366bf0833687fd00eb2a276f1c8dc5e02ab93651e676195d10d60",
"schemas/media.schema.json": "4b7d93ebb7edf5fa6219891f28325f68fc51f090eee756bc4cc3a3c746d48bda",
"scripts/analyze/breakdown.py": "5badcd4e3f5694f5b8c5a6d7d353f830e972ae5c8a6f24ed75af634411eb75f3",
+ "scripts/analyze/fetch_reference.py": "97c63efc636d38c7a4e341478bed9e3e575cd539249f878648ed42d777d393cc",
+ "scripts/analyze/regress_clips.py": "a54b50d424ab2be6398ce2b0ad799cf7d6d621c0214be81c961e1e54672b3b67",
+ "scripts/analyze/side_by_side.py": "7d809f5ced7167e03ed2ed65fab7ff6a2ad0d2d237c8aacf55cf91ab58b54ee0",
+ "scripts/analyze/stress_clip.py": "8c9e32f3ba45dc86ca4b2617cafdd974fdfa42b338e811fb6ce2e860dbfa091d",
"scripts/audio/synth_艺术史速通.py": "6476605af684b477d47b7f47c3c987059277de36b97bff5d77d167c27efdb40d",
- "scripts/capabilities.py": "43b1dd58d9f42efc638270cf67190ce85dda4e25fd591925c2f31e5bd6b4f63b",
+ "scripts/capabilities.py": "fe688fd612841824e126b8ddaea1eea4bc8c31111f15422a3c60d98a9463ad83",
"scripts/check_release.py": "508388bdcfe87d97d486de7d76fec87b893469779af14cc75e4b72b4c17ecc60",
+ "scripts/clip_lint.py": "b17bdb832a82826e27c379c24e673538439c80b88371b15b67a43731d3a4393b",
"scripts/deliver.py": "dbd1cd2495816b09257cec544e1b43bb2fa2530639ff11cff64526e065e178ae",
- "scripts/engine/clip.html": "73db3956310c7798452057e4328e961c899507483ab0bb72e817ce0372893874",
- "scripts/engine/clip.js": "e991e5c4edc9f463900cfc42106f5e0eaa2b48a28d3ba30111a3c80a16cf0f44",
+ "scripts/engine/audit_clip.py": "aaa925c5fbfeff284be6e4a4d21516497780052b84807ef0db8abd4522adb042",
+ "scripts/engine/clip.html": "15b9ab6f7e3e29dddf8a0f8a181239f94f60c7b1c2e3defc05bdd57f0705dfd3",
+ "scripts/engine/clip.js": "4be7a02d636b1e6ebf864822fec54c8e925ce415be2e2f1be1098ffb7a7b8799",
+ "scripts/engine/clip_schema.json": "7f0a41e9c257901c6905c3c8d3ca9ff12058400f8738bf116c0d22638cad3898",
"scripts/engine/clips/t1_3b1b.js": "84ed102301a066410aca1b0d06ba0459f7d5da09ae4831edf58a27f2152a6e7a",
- "scripts/engine/clips/t2_keynote_ui.js": "0f63d0d0ddc7b2426e0a160a4b51ce152908e7df30bceb475d3ceaf41a2e1a68",
+ "scripts/engine/clips/t2_keynote_ui.js": "31c59a08e39f5799e1f59017fafa0c7d07f40a360e27737fcdefa69b2fae5e56",
"scripts/engine/clips/t3_finance_chart.js": "f175d45ea92e0a680fea9e08ce9270a59a63a5b4bb3d00db5a894848e2407b36",
- "scripts/engine/clips/y1_kurzgesagt.js": "b64bf07471753f3ffd8d7f97473b886f7a71193c9ffd0000c2fb0af633ff4c77",
+ "scripts/engine/clips/y1_kurzgesagt.js": "5f507ef90222f335048cb167535f910fda789d7cd2fba1fc8695c0c4a1f4c6b6",
"scripts/engine/clips/y2_vox.js": "6c00ac3e587595b94732750a191827674a818c5f143d2ecfd328c9e4059bc589",
"scripts/engine/clips/y3_whiteboard.js": "1536d7a276580edd44fab6199b69671aecbae30b39b5f89921d08e43a738ff2d",
"scripts/engine/clips/y4_storytime.js": "2ba8c7a05296c489b948c1b2f050a479dcef5a7a19bb1550aca07478f97e25d6",
- "scripts/engine/clips/y5_kinetic_type.js": "80e6f52ae2a07ce4f7c4d15e87e7eddb3174c7770079805d97feaba1f254bd83",
+ "scripts/engine/clips/y5_kinetic_type.js": "2f46bd3710920d1f3496b6496680116cca8188987c5d82643da9eb1a0c45bbd9",
"scripts/engine/compare.py": "7bf1d5ae2926de09f69431435e93ffa4c5357532b543217cd66bdc57e00256aa",
"scripts/engine/demos/_shared/hero.js": "96e9e520d1139aa617be7ad01901f6a9b6c31c7948f73b33ddd8d646c6cdf967",
"scripts/engine/demos/_shared/hero/c1_0.png": "827032c6aa741f9895895224a67f81538d70ef970b10da6c3ee93e8deece3018",
@@ -225,6 +264,7 @@
"scripts/engine/engine.js": "04b64953037ced7016ffb211cb12891dc4f1c840378a366e35572db8098fd3cd",
"scripts/engine/eras.js": "2ccc90bed5e9ef337f8cf3444058705dc720743a78c9315a0e5ee814cd130fc9",
"scripts/engine/eras_gallery.js": "6e97dfe281b8360d400a657098a68dd224a1a081299b28b3137a1b1db1a8222a",
+ "scripts/engine/eras_style_studies.js": "bef942e77dfadd9e1d0a5de9e78339c9bb9a8958244dd22f839c2c833937aa2f",
"scripts/engine/examples/assets/K线图_横屏.png": "04a61f9be80bc4895136cfb168ed102860d96af41edab1957e326d647993cb19",
"scripts/engine/examples/assets/终端_for循环求和.png": "8871dce38e3ce0bc94a2aa22ab5479152df40837b67ced2b87de269a740badc3",
"scripts/engine/examples/assets/终端_sum求和.png": "2af3cac8b7468c120163c0993d98c8666d75d4814c8f0fbeced8d21db07302bf",
@@ -239,12 +279,14 @@
"scripts/engine/examples/y3_whiteboard.json": "9d5b0b6d4fa447a2e28c1db7447874aeafa26b915960a9beed154f9252e72a14",
"scripts/engine/examples/y4_storytime.json": "16a334ee71e47504ec74ca992b26b7f663960298bfa8864c11edd275d23b1d7f",
"scripts/engine/examples/y5_kinetic_type.json": "a17d1f008e68822616560acfaf022304581db2b0fcd0cbc5a6d9c2818b6a9fdb",
- "scripts/engine/index.html": "afc9c95a9ca1386b2f3513fe1fe21e595372c11a084be02b802b0ad254946d8e",
+ "scripts/engine/index.html": "28a067428f79e16b9f108f296e58b4e7541e466d463c4abbe6de6be4ef90a2d1",
+ "scripts/engine/lib/THREE_LICENSE.txt": "852e0e8699169bf9f6fdc6bda3e682d078dcbc738b5d33e74df594721bff271d",
"scripts/engine/lib/brush.js": "e83db04e5fc9fef83237d984d2ceba3c1ec71c0c2a8f8a798ecc939fc8c3b2d4",
"scripts/engine/lib/camera.js": "53ddc95e972900abfb49bfea704a2b77897b9237836ee653aeed966d39ceeec5",
"scripts/engine/lib/chart.js": "93d3605cba7d7cf0bdda2c2dd8f9797734dd06c1f64fa18ef7a492f8755a8d27",
"scripts/engine/lib/collage.js": "4dcd3d15f8895dc6e3d4f2e4d82766782a4e77876fb863ded9480320b8959d93",
"scripts/engine/lib/diagram.js": "98b15ba5f883dd95eca2ff52ba1d768c10a5bea7862bd13aee6d84b875e2b8c5",
+ "scripts/engine/lib/finish.js": "a391531aaac53edc5b435067a2210e5a473c955c429d1e11206bc0f8173d5e48",
"scripts/engine/lib/fonts.js": "8d5ac65f41bd6df79a0f913adf7f425d46c847cc5d8ed831eccdc80b1c29531d",
"scripts/engine/lib/fonts/AlfaSlabOne-400.woff": "2f8b04d3eada32d7047255260a0e81ab74938fada1aad154f5653850a68aebe8",
"scripts/engine/lib/fonts/Anton-400.woff": "791375bdbed00de4a3aad4811291220ead0e1405d6f8b5bdbf109798c8359ac5",
@@ -295,7 +337,8 @@
"scripts/engine/lib/fonts/cmunti.woff": "d9a02b7b67874c62f47f9c9a0914c115972ab77d43e82a163baf0888eb5d4a2d",
"scripts/engine/lib/fonts/index.json": "a0870057845b502a11037acef99b6e9cbc3994fdb5149caf3aac036140dbfbb1",
"scripts/engine/lib/kit.js": "a066c4d0d4dc7189dd9de7776938b4cbc6025a4bf4a38d2e181a6667744f3024",
- "scripts/engine/lib/media.js": "81d07aa964b76b0e8cf7f9ae871dc6e5283dec83190f69fd1c0acfe4b0be0476",
+ "scripts/engine/lib/media.js": "65a4d0a17ea194e799538d380d49ea59bc9b23d3118ee4a3bb3ba0c4ad8bac03",
+ "scripts/engine/lib/medium.js": "da280d244f0d603236976767a8cfdc4a8d9c56c299fbd1eeb48cc3014c656984",
"scripts/engine/lib/motion.js": "22762a3691464b7504da562b3761edc70f7c138721618639697df3a5a93c1b97",
"scripts/engine/lib/paint.js": "95ccd1945a4a19b6e2d89a422d7ea7de96174acdbae1801090ca9ee48131f9a3",
"scripts/engine/lib/palettes.js": "934acc426ebdada51f613d6e7b1cb693590d615a01d7a66d5461483bf79ff30a",
@@ -303,8 +346,9 @@
"scripts/engine/lib/render.js": "d2855f044ddff579000d9f8b1abadc2b76f84875fc604bea79d10319e3fe92bf",
"scripts/engine/lib/rig.js": "62580706e14438c6b57289ce203d040c91d8a427e356f44084a65dfc53a13bbf",
"scripts/engine/lib/rig_huashu.js": "6419306bb314f89848b0adf842db0c305c2f6bc931df34388eb5389f29c1d392",
+ "scripts/engine/lib/three.min.js": "170c6789f43217c96b3170f4b42fafe135de7f7cd48497a4218f9757ee1d49fa",
"scripts/engine/lib/toon.js": "54778963a97767742257e5b68890e5b292f2b89ce3fd1a1f9711224573988d8b",
- "scripts/engine/lib/typo.js": "30db0cc68145dca22532e487da01aeb3ec97155e8b2c3a0747a009ce6638be8f",
+ "scripts/engine/lib/typo.js": "bfb53350a94bc77c20a5420b694b0ffb7ba913c4a2e3390d86b99cf3fa8c3976",
"scripts/engine/lib/ui.js": "2608da0a38bfd429a9fe41c1a93a5d080d54c5fcccea80e7fea764e6ca3a97bf",
"scripts/engine/lib/util.js": "a2092233bbca337a29b00ce261d81a5c7b6baa020c9e301916ebe4a997450b9d",
"scripts/engine/reference_films/rick_morty/index.html": "215c23f93303a180b3f2405454b8652b61032f8874a8ce5bfe0388e1d6b920a9",
@@ -385,7 +429,7 @@
"scripts/engine/reference_films/spacex/transitions/paperSlide.js": "14eb0b28a2e78a7feeaf158b81d3aef640f9776dd0bb578f21b7e6bfafe40e13",
"scripts/engine/reference_films/spacex/transitions/vox_pull.js": "79db9ef00e31a4a44872ef57f9ce9a5a89ed631c1a83d9b7e72129e4a7355959",
"scripts/engine/reference_films/spacex/transitions/vox_slap.js": "78f8fa308a434a33d7007b776c4e006d711fea61d4f4dab9426baeebc6c3d573",
- "scripts/engine/render.py": "7ae2eda1b2669c4f3a9f1150ecea4c553fc813023b70c0198412ba9bcf2f43ef",
+ "scripts/engine/render.py": "1519ab458d4f0461c3ea028a6d8c8d632a69a6e4cf517f291abbc008ec3056b6",
"scripts/engine/scenes/01_cave.js": "06ff3360279ecf778d78ef5e56fa6d5cd6354a18033079eed32cba6af48dd781",
"scripts/engine/scenes/02_egypt.js": "ce4acdce7f65f41686f7e5f04336fdf150bfd53a560a20f2a83a3db495a86353",
"scripts/engine/scenes/03_greek.js": "58e259062257ebf15d2fb141e10441119df0691e0cc2bd212922a8cffb3be184",
@@ -421,6 +465,24 @@
"scripts/engine/scenes/34_shadowpuppet.js": "08186a1764be2bdc2c27806850dea2fd86761936aeba1299e8ece9bf31f381a8",
"scripts/engine/scenes/35_shinkai.js": "8e7f5753a0ce49291ae35bc4f471b5ca62448eb9532403459395d88bc524a736",
"scripts/engine/scenes/36_picasso_blue.js": "10023147e1e31afc162e1cfe51356867ef83595b41bbd5cc824d55532297ce09",
+ "scripts/engine/scenes/38_giotto.js": "0e89e9dd26f7a8bb5dfea53f81c96b0bcb68dabb754d37fdcc9e9570ddf830ae",
+ "scripts/engine/scenes/39_piero.js": "eb1b11df1942916ec7123c4152c853ec58e75d892ff4e566af58b91ebceb6325",
+ "scripts/engine/scenes/40_raphael.js": "43467fd90958b77f165141237bc0642de98da8e68dbc4bd6ee34ccf9df60020b",
+ "scripts/engine/scenes/41_michelangelo.js": "315ccd5670d22340848ed2e7d89b2fd105d26d6b8dc9fd113032fc9e3b052350",
+ "scripts/engine/scenes/42_guardi.js": "41157c0b2216b2d9c45c748fafc71ec1e394319641f51f9e9699a58cc40393c9",
+ "scripts/engine/scenes/43_lorenzetti.js": "1be12a8e1a9c10f9617735b96093e7c1f427c252729170dc6a9747c7157f9153",
+ "scripts/engine/scenes/44_cortona.js": "56b043573e024d89671f4219cfae67aa03660f9e64cde333903d130f156b5443",
+ "scripts/engine/scenes/45_renoir.js": "272fe9812f243d52ed75630cbdb2a17839e35219b5384a6271d7b99305e60d72",
+ "scripts/engine/scenes/46_pissarro.js": "092d137061f5a13b576a074bc120f6bd4703df54c2c7540c35a2489eba5042bc",
+ "scripts/engine/scenes/47_sisley.js": "1ce1c3f6eed3387e8ee29692b66e8e787faabc0f4655bfa3f2b99b9869efb15c",
+ "scripts/engine/scenes/48_gauguin.js": "e5483c4da9686ed0b7c594485c107627493ea876023923c6ad66ffb0a6f13a4a",
+ "scripts/engine/scenes/49_chagall.js": "0cd89ba15d8909bfeff910c50366480c8b48c791d6ae6207698d133f2ca020cb",
+ "scripts/engine/scenes/50_ma_yuan.js": "97838320cf9be562f915885048e50495d394068068835c9ec52fe0e50c3c969c",
+ "scripts/engine/scenes/51_persian_miniature.js": "3be9436ef96b83471ee2882faafa015947d1714ccff0b47de1189907b17a68c4",
+ "scripts/engine/scenes/52_south_park.js": "9dfeb48dede1d1d6bc9a28a67af1151649392efcbb03ccc1a8849e34d5cdb47c",
+ "scripts/engine/scenes/53_pixar.js": "fc6c8343666445cd551daa923be28c94c01db3c3e25311076a729a8663bc4f5a",
+ "scripts/engine/scenes/54_ghibli_lab.js": "063ae6a409ed8a8e970b3619b7806b9def84013537be2db29824519aba663aab",
+ "scripts/engine/scenes/55_dunhuang.js": "1aa496ddc26a9bddfb0f5e6cb3e3d89f1f35d585acd12e2584d34a94a4781a0f",
"scripts/engine/scenes/index.js": "22da1210908a8083658eb53289656eeb578026b6deabc666928014d01ddae23e",
"scripts/engine/spec_assets.py": "d963a9fa80a7c71ed4ff20f4bf5ff692b17d53aa49e8b9b234c4a1a671f60d41",
"scripts/engine/transitions.js": "c4bd441cf765db346933e5d18270f532d4c9782c9303b0bcda1ba59a2124b618",
@@ -432,8 +494,9 @@
"scripts/key_split.py": "889759cd6b5353b4d48d34faf3878682890e06ca79887c9ade9be401b7359f86",
"scripts/koubo.py": "7837507e6bf02b20f8aa63efdc881c8de0d5de775b4bf31a1040bd3824348494",
"scripts/qa.py": "b243900f0b91c246a297b81509b801c35b2b83c6f9a62b7adb68e3b217c34ee0",
- "scripts/storyboard_lint.py": "47168d3500f89018a351a5772f7ad59fccc232f66d08393cc16e79994bb39642",
+ "scripts/storyboard_lint.py": "fadf90d645d45d9584f635a6bb908eddbfa55d5422d615f09efecddae3003d73",
"scripts/subzone_gate.py": "8641a3b1b38ac28c1562e454a0e370f36a73d1a0c79cddf36175c7444a9c1598",
+ "scripts/voice_review.py": "c7c546079ae4d25682a1f2794fda2fed08206ab2bd708875bfe480ac0b4098b2",
"tests/fixtures/y4_storytime_test_frames.json": "97fe2a512d57afb456dfddd261eefba89731c25f7af0b38383ff70ad6adf8b61",
"tests/test_capabilities.py": "04ce548d5a72a11a87a3bd85c46a98e13f1aabafb096e3c59a6fc7a20bfdf4ad",
"tests/test_clip_theme.py": "efb0f2f6f5b7f180676af8d0929b2f19f4f94ef7af82e4b6f75d29fb8eeae9ad",
@@ -444,6 +507,7 @@
"tests/test_images.py": "5fe7533ec25a2644e3685e1677186eaf1554ebbbcc390fcd56a45afbad872040",
"tests/test_local_server.py": "b775a60c86c4a0914d67c4cfb7cb37256a447db700bfdba146a2db3704ea83ff",
"tests/test_release.py": "a190d8825e23f6204263f3d00d6728bf709586bc178c980d53244a82ef198b41",
- "tests/test_storyboard_lint.py": "ad2781b3b0f0c2fcb99f01e6ea6f61bc8d66a39856934de447e86f2519a3cae9"
+ "tests/test_storyboard_lint.py": "fa22b169d3766852171d3b401366797464e2dd5375bac486f5e1e824cc886096",
+ "tests/test_voice_review.py": "044576ad2b4d73dd745cbc63336bc7780a08fe5df566dcf69ada2f4a4136db99"
}
}
diff --git a/scripts/analyze/fetch_reference.py b/scripts/analyze/fetch_reference.py
new file mode 100644
index 0000000..ef0f059
--- /dev/null
+++ b/scripts/analyze/fetch_reference.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python3
+# /// script
+# dependencies = ["pillow"]
+# ///
+"""原作锚定:从维基共享资源按关键词拉公版原作,存本地,并抽主色板、出接触表。
+
+做新风格演示前先跑它:看原作、记签名特征、拿真实色值,不凭印象画「受启发的扁平插画」。
+
+uv run fetch_reference.py --out 参考/ostia "Giotto Lamentation Scrovegni" "Giotto Meeting at the Golden Gate" [--n 1] [--colors 8]
+
+每个查询取前 n 张(默认 1)宽 1600 的缩略图,存为 <out>/<序号>_<标题>.jpg,
+同时写 <out>/参考.md(来源 URL、主色 hex)和 <out>/接触表.jpg。
+只用公版作品(作者卒年 70 年以上的原作翻拍);脚本不判断版权,调用者自己确认。
+拉完必须看接触表,核对三件事:①是不是这位画家的作品(搜索会混入地图、现代照片、博物馆墙上的翻拍)②是不是三幅不同的作品(脚本只去掉近似图)③哪些是带框的翻拍(色板已取中央 80%,但构图判断仍要自己看)。
+"""
+import argparse, json, re, sys, time, urllib.parse, urllib.request
+from pathlib import Path
+from PIL import Image, ImageDraw
+
+UA = {'User-Agent': 'art-motion-research/1.0 (https://github.com/alchaincyf/huashu-art-motion)'}
+
+
+def get(url, timeout=60, tries=4):
+ # 维基共享资源偶尔 SSL EOF:重试几次再报错
+ for k in range(tries):
+ try:
+ with urllib.request.urlopen(urllib.request.Request(url, headers=UA), timeout=timeout) as r:
+ return r.read()
+ except Exception as e:
+ if k == tries - 1:
+ raise
+ time.sleep(1.5 * (k + 1))
+
+
+def api(**kw):
+ return json.loads(get('https://commons.wikimedia.org/w/api.php?' + urllib.parse.urlencode({**kw, 'format': 'json'})))
+
+
+def search(q, n):
+ d = api(action='query', generator='search', gsrsearch=f'{q} filetype:bitmap', gsrnamespace=6, gsrlimit=n + 4,
+ prop='imageinfo', iiprop='url|size', iiurlwidth=1600)
+ pages = sorted(d.get('query', {}).get('pages', {}).values(), key=lambda p: p.get('index', 0))
+ out = []
+ for p in pages:
+ ii = (p.get('imageinfo') or [{}])[0]
+ if ii.get('thumburl') and ii.get('width', 0) >= 900:
+ out.append((p['title'].removeprefix('File:'), ii['thumburl'], ii.get('descriptionurl', '')))
+ if len(out) >= n:
+ break
+ return out
+
+
+def palette(im, k):
+ w, h = im.size; im = im.crop((int(w * .1), int(h * .1), int(w * .9), int(h * .9))) # 去掉画框、墙、页边:只在中央 80% 里抽色
+ q = im.convert('RGB').resize((200, 200)).quantize(colors=k, method=Image.Quantize.MEDIANCUT)
+ pal = q.getpalette()[:k * 3]
+ cnt = sorted(q.getcolors(), reverse=True)
+ return ['#%02x%02x%02x' % tuple(pal[i * 3:i * 3 + 3]) + f' {c / 400:.0f}%' for c, i in cnt]
+
+
+def ahash(im):
+ from PIL import ImageOps
+ g = ImageOps.autocontrast(im.convert('L').resize((16, 16)), cutoff=2) # 先拉对比:调色增强版和原图才会落到同一个哈希附近
+ px = list(g.tobytes()); m = sum(px) / 256
+ return sum((1 << i) for i, v in enumerate(px) if v > m)
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument('queries', nargs='+')
+ ap.add_argument('--out', required=True)
+ ap.add_argument('--n', type=int, default=1)
+ ap.add_argument('--colors', type=int, default=8)
+ a = ap.parse_args()
+ out = Path(a.out); out.mkdir(parents=True, exist_ok=True)
+ rows, md, seen = [], ['# 原作参考\n'], []
+ for q in a.queries:
+ hits = search(q, a.n)
+ if not hits:
+ print(f'!! 没搜到:{q}', file=sys.stderr); continue
+ for title, url, page in hits:
+ fn = out / (f'{len(rows) + 1:02d}_' + re.sub(r'[^\w]+', '_', title)[:50] + '.jpg')
+ fn.write_bytes(get(url, 90))
+ im = Image.open(fn)
+ hv = ahash(im)
+ if any(bin(hv ^ h2).count('1') <= 40 for h2 in seen): # 同一幅的另一个翻拍/调色版:丢掉,不凑数
+ fn.unlink(); print('dup ', title, '(与已取的某幅近似,已丢弃)'); continue
+ seen.append(hv)
+ rows.append((fn, im.copy()))
+ md.append(f'- {fn.name}\n - 来源:{page}\n - 主色:{"、".join(palette(im, a.colors))}')
+ print('ok', fn.name)
+ if rows:
+ W, H, cols = 640, 400, 3
+ sheet = Image.new('RGB', (W * cols, H * ((len(rows) + cols - 1) // cols)), 'white')
+ for i, (fn, im) in enumerate(rows):
+ t = im.convert('RGB'); t.thumbnail((W, H))
+ sheet.paste(t, ((i % cols) * W, (i // cols) * H))
+ ImageDraw.Draw(sheet).text(((i % cols) * W + 6, (i // cols) * H + 6), fn.stem[:40], fill=(255, 0, 0))
+ sheet.save(out / '接触表.jpg', quality=88)
+ (out / '参考.md').write_text('\n'.join(md) + '\n')
+
+
+main()
diff --git a/scripts/analyze/regress_clips.py b/scripts/analyze/regress_clips.py
new file mode 100644
index 0000000..9f9cca7
--- /dev/null
+++ b/scripts/analyze/regress_clips.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python3
+# /// script
+# dependencies = []
+# ///
+"""动画语法回归:对 engine/examples/*.json 逐个跑 spec 校验+版面审计(原版/竖屏/英文),出一张通过表。改了任何语法、库或引擎之后先跑这个。
+
+uv run scripts/analyze/regress_clips.py [--only y1_kurzgesagt,t3_finance_chart] [--variants base,portrait,en] [--out <目录>]
+红灯=版面审计红灯或 spec 校验红灯,退出码 1;黄灯只列出。需要素材才能渲的示例(y4 要角色帧库)自动跳过并说明。
+"""
+import argparse, copy, json, re, subprocess, sys, tempfile
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[1]; ENG = ROOT / 'engine'
+EN = ["Gradient descent walks downhill", "One sentence turns into three thousand lines", "Revenue grew 7.8x in five years", "Two charts, both drawn by code", "Only one thing at a time"]
+TK = ("text", "sub", "label", "title", "caption", "key")
+
+
+def absolutize(o, base: Path):
+ if isinstance(o, dict): return {k: absolutize(v, base) for k, v in o.items()}
+ if isinstance(o, list): return [absolutize(v, base) for v in o]
+ if isinstance(o, str) and not o.startswith(('/', 'data:', 'http')) and '.' in o.split('/')[-1] and (base / o).exists(): return str((base / o).resolve())
+ return o
+
+
+def en(o, key=None, n=[0]):
+ if isinstance(o, dict): return {k: en(v, k) for k, v in o.items()}
+ if isinstance(o, list): return [en(v, key) for v in o]
+ if isinstance(o, str) and key in TK:
+ n[0] += 1; return EN[n[0] % len(EN)] if len(o) > 4 else 'OK ' + str(n[0])
+ return o
+
+
+def run_audit(spec: dict, tmp: Path):
+ f = tmp / 'v.json'; f.write_text(json.dumps(spec, ensure_ascii=False))
+ r = subprocess.run(['uv', 'run', '--with', 'playwright', 'python', str(ENG / 'render.py'), '--spec', str(f), '--audit'], capture_output=True, text=True)
+ txt = r.stdout + r.stderr; m = re.search(r'红灯 (\d+)\s+黄灯 (\d+)', txt)
+ return (int(m.group(1)), int(m.group(2)), [l.strip() for l in txt.splitlines() if '🔴' in l or '🟡' in l]) if m else (-1, 0, [txt.strip().splitlines()[-1] if txt.strip() else '没有输出'])
+
+
+def main():
+ ap = argparse.ArgumentParser(); ap.add_argument('--only'); ap.add_argument('--variants', default='base,portrait,en'); ap.add_argument('--out')
+ a = ap.parse_args(); only = set(a.only.split(',')) if a.only else None; vs = a.variants.split(',')
+ rows, bad = [], 0
+ with tempfile.TemporaryDirectory() as td:
+ for ex in sorted((ENG / 'examples').glob('*.json')):
+ name = ex.stem
+ if only and name not in only: continue
+ spec = absolutize(json.loads(ex.read_text()), ex.parent)
+ lint = subprocess.run([sys.executable, str(ROOT / 'clip_lint.py'), str(ex)], capture_output=True, text=True)
+ lr = '🔴' if lint.returncode else ('🟡' if '🟡' in lint.stdout else '✅')
+ cells = {}
+ for v in vs:
+ d = copy.deepcopy(spec)
+ if v == 'portrait': d['width'], d['height'] = 1080, 1920
+ elif v == 'en': d = en(d)
+ red, yel, lines = run_audit(d, Path(td))
+ if red < 0 and 'y4' in name: cells[v] = ('跳过', ['需要角色帧库']); continue
+ cells[v] = (f'{"🔴" if red else "✅"}{red}/{yel}' if red >= 0 else '💥', lines)
+ if red != 0: bad += 1
+ if lr == '🔴': bad += 1
+ rows.append((name, lr, cells))
+ print(f'{"示例":28} 校验 ' + ' '.join(f'{v:>9}' for v in vs))
+ for name, lr, cells in rows:
+ print(f'{name:28} {lr} ' + ' '.join(f'{cells[v][0]:>9}' for v in vs))
+ for name, lr, cells in rows:
+ for v, (st, lines) in cells.items():
+ for l in lines:
+ if '🔴' in l or st == '💥': print(f' [{name} · {v}] {l}')
+ print('\n格式:红灯数/黄灯数。' + ('通过。' if not bad else f'有 {bad} 项红灯,见上。'))
+ if a.out: Path(a.out).write_text(json.dumps([(n, l, {k: v[0] for k, v in c.items()}) for n, l, c in rows], ensure_ascii=False, indent=1))
+ sys.exit(1 if bad else 0)
+
+
+main()
diff --git a/scripts/analyze/side_by_side.py b/scripts/analyze/side_by_side.py
new file mode 100644
index 0000000..71dec5d
--- /dev/null
+++ b/scripts/analyze/side_by_side.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+# /// script
+# dependencies = ["pillow"]
+# ///
+"""原作并排:左边是 fetch_reference.py 拉的原作(最多 3 幅),右边是我们渲出的静帧,一张图,肉眼对签名。
+
+uv run side_by_side.py --ref 参考/giotto --frame 渲染/38_giotto/t003.00.png --out 对照/38_giotto.jpg [--title "乔托 v2"]
+
+打分前必须出这张图。「一眼认得出是谁的画」这一问,只能拿着原作回答,不能凭记忆。
+"""
+import argparse
+from pathlib import Path
+from PIL import Image, ImageDraw, ImageFont
+
+
+def font(size=16):
+ for f in ('/System/Library/Fonts/PingFang.ttc', '/System/Library/Fonts/STHeiti Medium.ttc', '/System/Library/Fonts/Hiragino Sans GB.ttc', '/Library/Fonts/Arial Unicode.ttf'):
+ try:
+ return ImageFont.truetype(f, size)
+ except Exception:
+ pass
+ return ImageFont.load_default()
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument('--ref', required=True, help='fetch_reference.py 的输出目录')
+ ap.add_argument('--frame', required=True, nargs='+', help='我们渲出的静帧(可多张)')
+ ap.add_argument('--out', required=True)
+ ap.add_argument('--title', default='')
+ a = ap.parse_args()
+ refs = sorted(p for p in Path(a.ref).glob('*.jpg') if p.name != '接触表.jpg')[:3]
+ H = 480
+ tiles = []
+ for p in refs:
+ im = Image.open(p).convert('RGB'); im = im.resize((int(im.width * H / im.height), H)); tiles.append((im, '原作 ' + p.stem[3:30]))
+ ours = []
+ for f in a.frame:
+ im = Image.open(f).convert('RGB'); im = im.resize((int(im.width * H / im.height), H)); ours.append((im, '我们 ' + Path(f).stem))
+ row = tiles + ours
+ W = sum(i.width for i, _ in row) + 8 * (len(row) + 1)
+ sheet = Image.new('RGB', (W, H + 56), (24, 24, 24)); d = ImageDraw.Draw(sheet); x = 8
+ if a.title:
+ d.text((8, 4), a.title, fill=(255, 255, 255), font=font(18))
+ for im, cap in row:
+ sheet.paste(im, (x, 28)); d.text((x, H + 34), cap, fill=(255, 210, 120) if cap.startswith('我们') else (170, 200, 255), font=font(15)); x += im.width + 8
+ Path(a.out).parent.mkdir(parents=True, exist_ok=True)
+ sheet.save(a.out, quality=90)
+ print('->', a.out)
+
+
+main()
diff --git a/scripts/analyze/stress_clip.py b/scripts/analyze/stress_clip.py
new file mode 100644
index 0000000..c902ac1
--- /dev/null
+++ b/scripts/analyze/stress_clip.py
@@ -0,0 +1,102 @@
+#!/usr/bin/env python3
+# /// script
+# dependencies = ["pillow"]
+# ///
+"""动画语法通用性压力测试:同一份 spec 生成 竖屏/超长文字/英文/方屏 四个变体,各渲「全部 cue 都出现后」的一帧,拼成一张检查表。
+
+uv run scripts/analyze/stress_clip.py scripts/engine/examples/y5_kinetic_type.json --out <目录> [--variants portrait,long,en,square] [--at 0.95]
+
+看什么(每个变体对着原版问一遍):
+ long 文字溢出画面/被裁/缩到看不清/叠到别的元素上?超长应当换行或缩放到下限,仍可读,不许溢出
+ en 拉丁文字比例不同:字重、断行、字距还对不对?
+ portrait 版面是不是为窄高画布重排了(竖排堆叠、放大),而不是把 16:9 版面缩进窄画布?内容不许被裁
+ square 1:1,同上
+出表后人工逐格看;有问题的变体回到语法文件里修,别只修 spec。
+"""
+import argparse, copy, json, subprocess, sys
+from pathlib import Path
+from PIL import Image, ImageDraw, ImageFont
+
+LONG = " ——这是一段刻意加长的说明文字,用来测试自动换行、缩放与避让是不是稳定"
+TEXT_KEYS = ("text", "sub", "label", "title", "caption", "word", "key")
+
+
+def font(size=16):
+ for f in ('/System/Library/Fonts/PingFang.ttc', '/System/Library/Fonts/STHeiti Medium.ttc', '/Library/Fonts/Arial Unicode.ttf'):
+ try:
+ return ImageFont.truetype(f, size)
+ except Exception:
+ pass
+ return ImageFont.load_default()
+
+
+def absolutize(o, base: Path):
+ if isinstance(o, dict):
+ return {k: absolutize(v, base) for k, v in o.items()}
+ if isinstance(o, list):
+ return [absolutize(v, base) for v in o]
+ if isinstance(o, str) and not o.startswith(('/', 'data:', 'http')) and (base / o).exists() and '.' in o.split('/')[-1]:
+ return str((base / o).resolve())
+ return o
+
+
+def map_text(o, fn, key=None):
+ if isinstance(o, dict):
+ return {k: map_text(v, fn, k) for k, v in o.items()}
+ if isinstance(o, list):
+ return [map_text(v, fn, key) for v in o]
+ if isinstance(o, str) and key in TEXT_KEYS and key != 'word':
+ return fn(o)
+ return o
+
+
+EN_POOL = ["Gradient descent walks downhill", "One sentence turns into three thousand lines", "Revenue grew 7.8x in five years",
+ "Two charts, both drawn by code", "Only one thing at a time", "A single drop holds billions of organisms"]
+
+
+def en_fn():
+ i = [0]
+
+ def f(s):
+ i[0] += 1
+ return EN_POOL[i[0] % len(EN_POOL)] if len(s) > 4 else "OK " + str(i[0])
+ return f
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument('spec'); ap.add_argument('--out', required=True)
+ ap.add_argument('--variants', default='portrait,long,en,square'); ap.add_argument('--at', type=float, default=0.95, help='取时长的这个比例处那一帧(默认 0.95=cue 基本都出现)')
+ a = ap.parse_args()
+ sp = Path(a.spec).resolve(); out = Path(a.out); out.mkdir(parents=True, exist_ok=True)
+ eng = Path(__file__).resolve().parents[1] / 'engine'
+ base = absolutize(json.loads(sp.read_text()), sp.parent)
+ dur = base['duration']; t = round(dur * a.at, 2)
+ vs = {'base': base}
+ for v in a.variants.split(','):
+ d = copy.deepcopy(base)
+ if v == 'portrait': d['width'], d['height'] = 1080, 1920
+ elif v == 'square': d['width'], d['height'] = 1080, 1080
+ elif v == 'long': d = map_text(d, lambda s: s + LONG)
+ elif v == 'en': d = map_text(d, en_fn())
+ else: sys.exit(f'未知变体 {v}')
+ vs[v] = d
+ tiles = []
+ for name, d in vs.items():
+ f = out / f'{name}.json'; f.write_text(json.dumps(d, ensure_ascii=False))
+ r = subprocess.run(['uv', 'run', '--with', 'playwright', 'python', str(eng / 'render.py'), '--spec', str(f), '--stills', str(t), '--out', str(out / name)], capture_output=True, text=True)
+ pngs = sorted((out / name).glob('*.png'))
+ if not pngs:
+ print(f'[{name}] 渲染失败:', (r.stdout + r.stderr).strip().splitlines()[-1:]); tiles.append((name, None)); continue
+ tiles.append((name, Image.open(pngs[-1]).convert('RGB')))
+ H = 420; row = []
+ for name, im in tiles:
+ im = im.resize((int(im.width * H / im.height), H)) if im else Image.new('RGB', (300, H), (110, 0, 0)); row.append((name, im))
+ W = sum(i.width for _, i in row) + 8 * (len(row) + 1)
+ sh = Image.new('RGB', (W, H + 30), (24, 24, 24)); dr = ImageDraw.Draw(sh); x = 8
+ for name, im in row:
+ sh.paste(im, (x, 26)); dr.text((x, 4), f'{sp.stem} · {name} @ {t}s', fill=(255, 220, 90), font=font(15)); x += im.width + 8
+ o = out / '检查表.jpg'; sh.save(o, quality=88); print('->', o)
+
+
+main()
diff --git a/scripts/capabilities.py b/scripts/capabilities.py
index 67ac042..00df4f6 100644
--- a/scripts/capabilities.py
+++ b/scripts/capabilities.py
@@ -337,6 +337,8 @@ def run_say(args, config):
args.voice = speaker(config, args.voice)
opts = config['provider_options']['volcengine']
args.model = args.model or opts['model']
+ from voice_review import review_status
+ print(json.dumps({'model_review': review_status('volcengine', args.model, getattr(args, 'config', None))}, ensure_ascii=False), file=sys.stderr)
args.speech_rate = opts['speech_rate'] if args.speech_rate is None else args.speech_rate
args.no_fidelity = not opts['tone_fidelity'] if args.no_fidelity is None else args.no_fidelity
koubo.cmd_say(args)
@@ -403,6 +405,9 @@ def main():
result = resolve(config, args.mode, args.audio)
result['revision'] = config.get('revision', 0)
result['parameters'] = config['provider_options']['volcengine'] if result.get('provider') == 'volcengine' else {}
+ if result.get('provider') == 'volcengine':
+ from voice_review import review_status
+ result['model_review'] = review_status('volcengine', result['parameters']['model'], path)
if args.explain:
result['sources'] = sources
print(json.dumps(result, ensure_ascii=False, indent=2))
diff --git a/scripts/clip_lint.py b/scripts/clip_lint.py
new file mode 100644
index 0000000..d07cf00
--- /dev/null
+++ b/scripts/clip_lint.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python3
+"""参数化片段 spec 校验:渲染前跑一遍,把「写错了不报错只是不生效」的坑提前说出来。
+
+uv run scripts/clip_lint.py spec.json [--strict]
+红灯(退出码 1):grammar 不存在、cue 类型不是这个语法的、必填字段缺、at 不是数、色板/finish 写错、图片文件不存在、cue 全在时长之外。
+黄灯:表外的字段(多半拼错或放错层级)、camera 写在不生效的位置、开头/结尾空太久、片段 >8 秒、cue 挤在同一帧。
+--strict:黄灯也算失败。字段表在 engine/clip_schema.json,改语法时同步改。
+"""
+import argparse, json, sys
+from pathlib import Path
+
+ENG = Path(__file__).resolve().parent / 'engine'
+
+
+def get(o, path):
+ for k in path.split('.'):
+ if not isinstance(o, dict) or k not in o: return None
+ o = o[k]
+ return o
+
+
+def main():
+ ap = argparse.ArgumentParser(); ap.add_argument('spec'); ap.add_argument('--strict', action='store_true')
+ a = ap.parse_args()
+ sp = Path(a.spec).resolve(); red, yel = [], []
+ try: spec = json.loads(sp.read_text())
+ except Exception as e: sys.exit(f'🔴 JSON 读不了:{e}')
+ S = json.loads((ENG / 'clip_schema.json').read_text()); C = S['common']
+ g = spec.get('grammar'); G = S['grammars'].get(g)
+ if not G or not (ENG / 'clips' / f'{g}.js').exists():
+ red.append(f'grammar「{g}」不存在。可用:{" / ".join(S["grammars"])}'); report(red, yel, a); return
+ for k in spec:
+ if k.startswith('_'): continue # _note 之类的注释键
+ if k not in C['spec']:
+ hint = '(camera 要写在 data 里:{"data": {"camera": "snap"}})' if k == 'camera' else ''
+ yel.append(f'spec 顶层的「{k}」不认,会被忽略{hint}')
+ d = spec.get('duration')
+ if not isinstance(d, (int, float)) or d <= 0: red.append('duration 要是 >0 的数(秒)'); d = 0
+ elif d > 8: yel.append(f'duration={d}s 超过 8s:单个片段撑太久会读成一页 PPT,拆成几镜')
+ th = spec.get('theme')
+ if isinstance(th, str) and th not in C['themes'] and g != 't3_finance_chart': red.append(f'theme「{th}」不是色板名:{" / ".join(C["themes"])}')
+ fn = spec.get('finish')
+ if fn is not None and not (isinstance(fn, dict) or fn in C['finish']): red.append(f'finish「{fn}」不是预设:{" / ".join(C["finish"])}(或写对象)')
+ sd = spec.get('data') or {}
+ if isinstance(sd, dict):
+ for k in sd:
+ if k not in G['specData']: yel.append(f'spec.data 里的「{k}」不在 {g} 的字段表里(拼错或放错层级?认:{", ".join(G["specData"])})')
+ for need in G.get('specNeeds', []):
+ if get(spec, need) in (None, [], {}, ''): red.append(f'{g} 必须有 {need}')
+ if sd.get('camera') not in (None, 'smooth', 'snap'): red.append(f'data.camera 只认 smooth / snap,写的是「{sd.get("camera")}」')
+ cues = spec.get('cues') or []
+ if not cues: red.append('cues 是空的')
+ prev = -1; seen_at = {}
+ inside = 0
+ for i, q in enumerate(cues):
+ tag = f'cue[{i}]'
+ if not isinstance(q, dict): red.append(f'{tag} 不是对象'); continue
+ at, kind = q.get('at'), q.get('kind')
+ tag = f'cue[{i}] {kind}@{at}'
+ if not isinstance(at, (int, float)): red.append(f'{tag}:at 要是数字'); continue
+ if kind not in G['kinds']: red.append(f'{tag}:{g} 没有这个 kind。可用:{" / ".join(G["kinds"])}'); continue
+ if at < prev - 1e-9: yel.append(f'{tag}:at 比上一条小(cue 会被按时间重排,确认是故意的)')
+ prev = max(prev, at)
+ if d and at > d + 1e-9: yel.append(f'{tag}:超出片段时长 {d}s,看不到,会被丢掉')
+ else: inside += 1
+ key = round(at, 3); seen_at[key] = seen_at.get(key, 0) + 1
+ for k in q:
+ if k not in C['cue']: yel.append(f'{tag}:cue 里的「{k}」不认(认:{", ".join(C["cue"])})')
+ qd = q.get('data') or {}
+ if isinstance(qd, dict):
+ for k in qd:
+ if k == 'camera': yel.append(f'{tag}:camera 写在 cue 的 data 里不生效,要写在 spec 顶层 data 里')
+ elif k not in G['cueData']: yel.append(f'{tag}:data 里的「{k}」不在 {g}/{kind} 的字段表里(拼错?认:{", ".join(G["cueData"])})')
+ for need in (G.get('needs', {}).get(kind) or []):
+ ok = any(get(q, n) not in (None, '', [], {}) for n in need.split('|'))
+ if not ok: red.append(f'{tag}:缺 {need}')
+ for im in ([q.get('image')] if q.get('image') else []) + (q['frames'] if isinstance(q.get('frames'), list) else []):
+ if isinstance(im, str) and not im.startswith(('data:', 'http')) and not (sp.parent / im).exists() and not Path(im).exists():
+ red.append(f'{tag}:图片不存在 {im}(相对 spec 文件)')
+ if cues and d and inside == 0: red.append('所有 cue 都在片段时长之外')
+ if cues and d:
+ ats = [q['at'] for q in cues if isinstance(q, dict) and isinstance(q.get('at'), (int, float)) and q['at'] <= d]
+ if ats:
+ if min(ats) > 1.2: yel.append(f'第一条 cue 在 {min(ats)}s:开头空了 {min(ats)}s(口播管线里可能是故意留的)')
+ if d - max(ats) > 3.0: yel.append(f'最后一条 cue 在 {max(ats)}s,之后还有 {d - max(ats):.1f}s 没有新事件,画面会定住')
+ for k, n in seen_at.items():
+ if n >= 3: yel.append(f'{n} 条 cue 挤在 {k}s 同一刻:只有最后一条看得清')
+ report(red, yel, a)
+
+
+def report(red, yel, a):
+ for r in red: print('🔴', r)
+ for y in yel: print('🟡', y)
+ if not red and not yel: print('✅ spec 没有发现问题')
+ sys.exit(1 if red or (a.strict and yel) else 0)
+
+
+main()
diff --git a/scripts/engine/audit_clip.py b/scripts/engine/audit_clip.py
new file mode 100644
index 0000000..86531fb
--- /dev/null
+++ b/scripts/engine/audit_clip.py
@@ -0,0 +1,46 @@
+"""版面审计:对一个参数化片段每 0.25 秒采一帧,汇总文字版面问题。render.py --spec X --audit 调用。
+红灯(退出码 1):文字出界、被安全区吞掉、两段不同文字互相压住。黄灯:字小于可读下限(不含刻意的脚注字号时请人工判断)。
+"""
+import json
+
+
+def run(pg, spec, grab, step=0.25):
+ W, H, dur = spec.get('width', 1920), spec.get('height', 1080), spec['duration']
+ safe = {'top': 0, 'bottom': 0, 'left': 0, 'right': 0, **(spec.get('safe') or {})}
+ short = min(W, H); floor = 0.0204 * short # 1080 短边 ≈ 22px
+ ts = [round(i * step, 3) for i in range(int(dur / step) + 1)] + [round(dur - 1 / spec.get('fps', 30), 3)]
+ seen, red, yel = {}, [], []
+ for t in ts:
+ pg.evaluate('t => { window.__AUDIT.length = 0; window.__auditT = t; }', t)
+ pg.evaluate(grab, t)
+ items = [i for i in pg.evaluate('window.__AUDIT') if i['a'] > 0.35]
+ for it in items:
+ w, h = it['x1'] - it['x0'], it['y1'] - it['y0']
+ if w < 1 or h < 1: continue
+ vis = max(0, min(it['x1'], W) - max(it['x0'], 0)) * max(0, min(it['y1'], H) - max(it['y0'], 0)) / (w * h)
+ if 0 < vis < 0.97 and it['px'] >= 8: # vis==0:整条在画外(转场/镜头平移里),不算
+ k = ('出界', it['text'][:20]); seen.setdefault(k, [t, t, f'可见 {vis:.0%},字号 {it["px"]:.0f}px', 0]); seen[k][1] = t; seen[k][3] += 1
+ elif (safe['top'] or safe['bottom'] or safe['left'] or safe['right']) and (it['y0'] < safe['top'] - 2 or it['y1'] > H - safe['bottom'] + 2 or it['x0'] < safe['left'] - 2 or it['x1'] > W - safe['right'] + 2) and it['px'] >= 20:
+ k = ('进安全区', it['text'][:20]); seen.setdefault(k, [t, t, f'字号 {it["px"]:.0f}px', 0]); seen[k][1] = t; seen[k][3] += 1
+ if it['px'] < floor and len(it['text']) >= 3 and it['px'] >= 6:
+ k = ('字太小', it['text'][:20]); seen.setdefault(k, [t, t, f'{it["px"]:.0f}px < 下限 {floor:.0f}px', 0]); seen[k][1] = t; seen[k][3] += 1
+ # 互相压住
+ for i in range(len(items)):
+ for j in range(i + 1, len(items)):
+ a, b = items[i], items[j]
+ if a['text'] == b['text'] or a['px'] < 14 or b['px'] < 14 or len(a['text'].strip()) <= 2 or len(b['text'].strip()) <= 2: continue # 单字符多是公式/图标的部件,刻意叠放
+ ox, oy = min(a['x1'], b['x1']) - max(a['x0'], b['x0']), min(a['y1'], b['y1']) - max(a['y0'], b['y0'])
+ if ox <= 2 or oy <= 2: continue
+ sm = min((a['x1'] - a['x0']) * (a['y1'] - a['y0']), (b['x1'] - b['x0']) * (b['y1'] - b['y0']))
+ if sm > 0 and ox * oy / sm > 0.3:
+ k = ('叠字', (a['text'][:10] + ' × ' + b['text'][:10])); seen.setdefault(k, [t, t, f'重叠 {ox * oy / sm:.0%}', 0]); seen[k][1] = t; seen[k][3] += 1
+ for (kind, txt), (t0, t1, note, cnt) in seen.items():
+ if cnt < 2: continue # 只出现一个采样点:多半是转场中的瞬间,不报
+ if kind == '出界' and cnt < 3: continue # 换屏横推约 0.4s:旧画面被推出去是设计动作,出界要持续 3 个采样(≥0.5s)才算
+ row = {'kind': kind, 'text': txt, 't0': t0, 't1': t1, 'note': note}
+ (yel if kind == '字太小' else red).append(row)
+ print(f'版面审计 {W}×{H} {dur}s:红灯 {len(red)} 黄灯 {len(yel)}')
+ for r in red: print(f" 🔴 {r['kind']} 「{r['text']}」 {r['t0']}–{r['t1']}s {r['note']}")
+ for r in yel: print(f" 🟡 {r['kind']} 「{r['text']}」 {r['t0']}–{r['t1']}s {r['note']}")
+ if not red and not yel: print(' ✅ 没有发现版面问题')
+ return {'red': red, 'yellow': yel, 'size': [W, H], 'duration': dur}
diff --git a/scripts/engine/clip.html b/scripts/engine/clip.html
index a2abb1d..cfe53e3 100644
--- a/scripts/engine/clip.html
+++ b/scripts/engine/clip.html
@@ -19,5 +19,6 @@
<script src="lib/collage.js"></script>
<script src="lib/media.js"></script>
<script src="lib/toon.js"></script>
+<script src="lib/finish.js"></script>
<script src="clip.js"></script>
</body></html>
diff --git a/scripts/engine/clip.js b/scripts/engine/clip.js
index 8aabc34..e0536da 100644
--- a/scripts/engine/clip.js
+++ b/scripts/engine/clip.js
@@ -1,6 +1,7 @@
// 参数化片段运行时:一份 spec(JSON)→ 一段时长严格等于 spec.duration 的动画。给口播视频管线当「动画段」用。
// 契约见 references/09-视频动画语法.md「片段契约」。和 engine.js 的区别:没有段落表/转场,一个语法一个 draw(c, t, ctx),画布尺寸从 spec 读(竖屏也行)。
//
+// spec.finish(可选):成片质感层,预设 soft / film / punch / clean 或对象,见 lib/finish.js;alpha 模式忽略。
// spec = { grammar, duration, fps=30, width=1920, height=1080, safe?: {top,bottom,left,right(px,留给字幕/平台 UI), fill?(让开的边涂这个色)}, theme?, alpha?, data?, cues: [{at, kind, text?, sub?, data?, image?, frames?, fps?, dur?}] }
// spec.theme:全片共用的色板(lib/palettes.js)——名字(paper poster ink navy bauhaus snow wood chalk)、{name, 要覆盖的键}、或完整 6 键 {bg, surface, ink, sub, accent, accent2}。
// 解析成 ctx.pal(完整 6 键+name),各语法按它上色;名字写错 / 缺键 → 启动失败。不写 → ctx.pal = null,各语法用自己的默认配色。
@@ -53,6 +54,8 @@ async function boot() {
// 主题色板:在加载素材之前核,写错就别白等图片
let pal = null;
if (!(G.legacyTheme && G.legacyTheme(spec.theme))) { try { pal = PAL.resolve(spec.theme); } catch (e) { return fail(e.message); } }
+ // 成片质感层(spec.finish):写错预设名就别白等图片
+ let fin = null; try { fin = FINISH.resolve(spec.finish); } catch (e) { return fail(e.message); }
// 图片
const IMG = {}, urls = new Set();
for (const q of (spec.cues || [])) {
@@ -90,7 +93,7 @@ async function boot() {
// safe.fill:让开的边涂成这个颜色(竖屏片把图表做成和相邻 contain 素材同一块「卡片」,外面是片子的底色);透明模式下不涂
const band = (safe.fill && !spec.alpha) ? (cc => { cc.fillStyle = safe.fill; const { top: t0, bottom: b0, left: l0, right: r0 } = safe;
if (t0) cc.fillRect(0, 0, W, t0); if (b0) cc.fillRect(0, H - b0, W, b0); if (l0) cc.fillRect(0, 0, l0, H); if (r0) cc.fillRect(W - r0, 0, r0, H); }) : null;
- window.renderFrame = t => { c.setTransform(1, 0, 0, 1, 0, 0); c.clearRect(0, 0, W, H); c.save(); G.draw(c, t, ctx); c.restore(); if (band) band(c); };
+ window.renderFrame = t => { c.setTransform(1, 0, 0, 1, 0, 0); c.clearRect(0, 0, W, H); c.save(); G.draw(c, t, ctx); c.restore(); if (fin && !spec.alpha) FINISH.apply(c, t, fin, W, H, FPS); if (band) band(c); };
window.prepare = async () => {};
window.__ready = true;
window.renderFrame(0);
diff --git a/scripts/engine/clip_schema.json b/scripts/engine/clip_schema.json
new file mode 100644
index 0000000..b16e7e7
--- /dev/null
+++ b/scripts/engine/clip_schema.json
@@ -0,0 +1,19 @@
+{
+ "_说明": "参数化片段 spec 的字段表,clip_lint.py 读它。来源是各 clips/<语法>.js 头注释;改语法时同步改这里。cue.data 里写了表外的键只是告警(语法可能认得更多)。",
+ "common": {
+ "spec": ["grammar", "duration", "fps", "width", "height", "safe", "theme", "alpha", "data", "cues", "finish"],
+ "cue": ["at", "kind", "text", "sub", "data", "image", "frames", "fps", "loop", "dur"],
+ "themes": ["paper", "poster", "ink", "navy", "bauhaus", "snow", "wood", "chalk"],
+ "finish": ["clean", "soft", "film", "punch"]
+ },
+ "grammars": {
+ "t1_3b1b": { "kinds": ["title", "equation", "point", "line", "highlight"], "specData": ["camera"], "cueData": ["tokens", "col", "color", "values", "points", "target", "index", "dur"], "needs": { "equation": ["text|data.tokens"], "point": ["text"], "title": ["text"], "line": ["data.values|data.points"] } },
+ "t2_keynote_ui": { "kinds": ["title", "card", "step", "image", "highlight", "number"], "specData": ["eyebrow", "title", "subtitle", "accent", "frame", "camera"], "cueData": ["step", "fit", "focus", "icon", "value", "prefix", "suffix", "decimals", "label", "rect", "fill", "over", "frame", "text"], "needs": { "number": ["data.value"], "highlight": ["data.rect"] } },
+ "t3_finance_chart": { "kinds": ["title", "bar", "line", "candle", "highlight", "number"], "specData": ["title", "unit", "source", "badge", "chart", "series", "decimals", "prefix", "suffix", "highlight", "colors", "upDown", "theme", "camera"], "cueData": ["index", "value", "prefix", "suffix", "decimals", "text", "sub"], "needs": {}, "specNeeds": ["data.series"] },
+ "y1_kurzgesagt": { "kinds": ["title", "point", "highlight", "enter"], "specData": ["center", "center_style", "image", "flow", "camera"], "cueData": ["color", "index", "style"], "needs": { "point": ["text"], "title": ["text"] } },
+ "y2_vox": { "kinds": ["image", "clip", "title", "point", "highlight"], "specData": ["camera"], "cueData": ["halftone", "fit", "focus", "aspect", "rect"], "needs": { "highlight": ["data.rect"], "title": ["text"], "point": ["text"] } },
+ "y3_whiteboard": { "kinds": ["title", "point", "draw", "image", "highlight"], "specData": ["camera"], "cueData": ["icon", "arrow", "index", "target", "style"], "needs": { "draw": ["data.icon"], "point": ["text"], "title": ["text"] } },
+ "y4_storytime": { "kinds": ["title", "point", "highlight", "react", "insert"], "specData": ["character", "camera"], "cueData": ["pose", "mark", "hit", "count", "unit"], "needs": {}, "specNeeds": ["data.character"] },
+ "y5_kinetic_type": { "kinds": ["title", "point", "number", "highlight"], "specData": ["palette", "camera"], "cueData": ["label", "key", "word", "value", "prefix", "suffix", "decimals", "num"], "needs": { "number": ["data.value"], "point": ["text"], "title": ["text"] } }
+ }
+}
diff --git a/scripts/engine/clips/t2_keynote_ui.js b/scripts/engine/clips/t2_keynote_ui.js
index c7dca6d..2a37bd9 100644
--- a/scripts/engine/clips/t2_keynote_ui.js
+++ b/scripts/engine/clips/t2_keynote_ui.js
@@ -194,13 +194,13 @@ function drawFull(c, s, t, ctx, acc) {
g.save(); g.shadowColor = 'rgba(0,0,0,.5)'; g.shadowBlur = 40 * u; g.shadowOffsetY = 14 * u; g.fillStyle = '#000'; g.fillRect(f.x, f.y, f.w, f.h); g.restore();
if (s.geo.fit === 'cover') MD.cover(g, im, { ...s.geo.box, fx: s.geo.fx, fy: s.geo.fy });
else g.drawImage(im, f.x, f.y, f.w, f.h);
- hlOn(g, cd, f, t, ctx, acc, u, s.next);
+ hlOn(g, cd, f, t, ctx, acc, u, s.next, cam.z * slam);
});
// 标签:屏幕层,不跟镜头;压在内容框左下角(截图自己的标题多在上面,不挡它),at 这一帧出现、12fps 打字
const size = (ctx.portrait ? 54 : 46) * u, ss = size * 0.66, lx = ctx.box.x + 56 * u, yb = ctx.box.y + ctx.box.h - (ctx.portrait ? 110 : 60) * u;
const ySub = yb - ss * 0.75, yMain = q.sub ? ySub - ss * 0.75 - 12 * u - size * 0.75 : yb - size * 0.75;
- if (q.text) MD.label(c, q.text, lx, yMain, { t, at: q.at, size, bg: T.labBg, fg: T.labFg });
- if (q.sub) MD.label(c, q.sub, lx, q.text ? ySub : yb - ss * 0.75, { t, at: q.at + (q.text ? 0.25 : 0), size: ss, fam: 'PuHui-Bold', bg: acc, fg: onAcc(acc) });
+ if (q.text) MD.label(c, q.text, lx, yMain, { t, at: q.at, size, maxW: ctx.box.w - 112 * u, bg: T.labBg, fg: T.labFg });
+ if (q.sub) MD.label(c, q.sub, lx, q.text ? ySub : yb - ss * 0.75, { t, at: q.at + (q.text ? 0.25 : 0), size: ss, maxW: ctx.box.w - 112 * u, fam: 'PuHui-Bold', bg: acc, fg: onAcc(acc) });
for (const qn of s.nums || []) overNumber(c, qn, t, ctx);
c.restore();
}
@@ -215,10 +215,10 @@ function overNumber(c, q, t, ctx) {
c.save(); c.translate(cx, my); c.scale(z, z); c.translate(-cx, -my);
c.font = `600 ${size}px ${SANSB}`; track(c, size, -0.03); c.fillStyle = T.pal ? (PAL.dark(T.pal) ? T.pal.ink : T.pal.surface) : '#ffffff'; c.shadowColor = 'rgba(0,0,0,0.6)'; c.shadowBlur = 30 * u;
TY.tabular(c, fmtNum(nd, k), cx, cy, { align: 'center' }); c.restore();
- if (cap) MD.label(c, cap, cx, cy + 110 * u, { t, at: t0 + 0.2, size: (ctx.portrait ? 54 : 48) * u, align: 'center', bg: T.labBg, fg: T.labFg });
+ if (cap) MD.label(c, cap, cx, cy + 110 * u, { t, at: t0 + 0.2, size: (ctx.portrait ? 54 : 48) * u, maxW: bx.w * 0.92, align: 'center', bg: T.labBg, fg: T.labFg });
}
// 截图上的 highlight:at 这一帧框开始弹出,其余压暗,一道光扫过框内;只认落在这一屏在屏期间的 highlight
-function hlOn(g, cd, f, t, ctx, acc, u, until) {
+function hlOn(g, cd, f, t, ctx, acc, u, until, z = 1) { // z:这一刻相机的放大倍数(满幅模式画在被放大的世界里,标签要按它反算,不然长标签被放大出画)
const q = cd.q;
for (const qh of ctx.of('highlight')) {
if (qh.at < q.at || qh.at >= until || !qh.data || !qh.data.rect) continue;
@@ -228,8 +228,11 @@ function hlOn(g, cd, f, t, ctx, acc, u, until) {
g.save(); g.strokeStyle = acc; g.lineWidth = 5 * u; if (!T.pal) { g.shadowColor = acc; g.shadowBlur = 18 * u * 0.85; } g.globalAlpha = clamp(hl / 0.15); // 全片色板:框不发光
g.beginPath(); g.roundRect(R.x - e, R.y - e, R.w + 2 * e, R.h + 2 * e, 10 * u); g.stroke(); g.restore();
UI.sheen(g, UI.rrPath(R.x, R.y, R.w, R.h, 10 * u), MO.seg(hl, 0.25, 1.0), { x0: R.x, x1: R.x + R.w, width: Math.max(60 * u, R.w * 0.2), alpha: 0.35 });
- if (qh.text) { g.font = `600 ${30 * u}px ${ZHB}`; const lw = g.measureText(qh.text).width + 36 * u, ly = R.y + R.h + 16 * u + 48 * u > f.y + f.h ? R.y - 64 * u : R.y + R.h + 16 * u;
- g.save(); g.globalAlpha = clamp((hl - 0.15) / 0.25); g.fillStyle = acc; g.beginPath(); g.roundRect(clamp(R.x, f.x, f.x + f.w - lw), ly, lw, 48 * u, 24 * u); g.fill(); g.fillStyle = onAcc(acc); g.textBaseline = 'middle'; g.fillText(qh.text, clamp(R.x, f.x, f.x + f.w - lw) + 18 * u, ly + 25 * u); g.restore(); }
+ if (qh.text) {
+ const k = clamp(30 * u * z, 30 * u, 52 * u) / z, sz = k, lh = 48 * u * k / (30 * u), pd = 18 * u * k / (30 * u); // 屏幕上的字大小夹在 30–52u:推近后也不会越放越大
+ const fl = TY.fitFloor(g, qh.text, Math.min(f.w * 0.9, ctx.W * 0.84 / z) - 2 * pd, sz, 'PuHui-Bold', { maxLines: 1, floor: sz * 0.62 }), txt = fl.lines[0] || '';
+ g.font = `600 ${fl.size}px ${ZHB}`; const lw = g.measureText(txt).width + 2 * pd, ly = R.y + R.h + 16 * u / z + lh > f.y + f.h ? R.y - lh - 16 * u / z : R.y + R.h + 16 * u / z, lx = clamp(R.x, f.x, Math.max(f.x, f.x + f.w - lw));
+ g.save(); g.globalAlpha = clamp((hl - 0.15) / 0.25); g.fillStyle = acc; g.beginPath(); g.roundRect(lx, ly, lw, lh, lh / 2); g.fill(); g.fillStyle = onAcc(acc); g.textBaseline = 'middle'; g.fillText(txt, lx + pd, ly + lh / 2 + 1); g.restore(); }
}
}
// 截图卡的屏幕几何
@@ -283,9 +286,9 @@ function imgContent(g, cd, Bw, Bh, t, ctx, acc) {
if (q.sub) { const sl = fitB(g, q.sub, tw, 34 * u, 'PuHui-Medium', { maxLines: tl.lines.length > 1 ? 1 : 2, min: 0.75 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = T.body;
sl.lines.forEach((ln, k) => g.fillText(ln, tx, hp + tl.size * 0.85 + (tl.lines.length - 1) * tl.size * 1.2 + 24 * u + sl.size + k * sl.size * 1.35)); }
} else {
- const tl = TY.fit(g, q.text || '', tw, 46 * u, 'PuHui-Bold', { maxLines: 1, weight: '600 ' });
+ const tl = TY.fitFloor(g, q.text || '', tw, 46 * u, 'PuHui-Bold', { maxLines: 1, weight: '600 ', floor: 30 * u });
g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = T.head; g.fillText(tl.lines[0] || '', tx, hp + (q.sub ? 32 * u : 48 * u));
- if (q.sub) { const sl = TY.fit(g, q.sub, tw, 28 * u, 'PuHui-Medium', { maxLines: 1 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = T.body2; g.fillText(sl.lines[0] || '', tx, hp + 74 * u); }
+ if (q.sub) { const sl = TY.fitFloor(g, q.sub, tw, 28 * u, 'PuHui-Medium', { maxLines: 1, floor: 20 * u }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = T.body2; g.fillText(sl.lines[0] || '', tx, hp + 74 * u); }
}
}
const [iw, ih] = MD.size(cd.im), f = CLIP.fit(iw, ih, I.x, I.y, I.w, I.h);
diff --git a/scripts/engine/clips/y1_kurzgesagt.js b/scripts/engine/clips/y1_kurzgesagt.js
index 95c7c79..c9d322f 100644
--- a/scripts/engine/clips/y1_kurzgesagt.js
+++ b/scripts/engine/clips/y1_kurzgesagt.js
@@ -48,6 +48,7 @@ return {
const y0 = safe.top + (ctx.of('title').length ? (ctx.portrait ? 300 : 210) * u : 60 * u), y1 = H - safe.bottom - 40 * u;
const R = (ctx.portrait ? 160 : 140) * u, cx = W / 2, cy = (y0 + y1) / 2 + (ctx.portrait ? 0 : 30 * u);
S = { cx, cy, R, stars: Array.from({ length: 160 }, () => ({ x: r() * W * 1.4 - W * 0.2, y: r() * H * 1.4 - H * 0.2, r: (0.8 + r() * r() * 3) * u, ph: r() * 6.28, sp: 1 + r() * 2.5 })),
+ bokeh: Array.from({ length: 10 }, () => ({ x: r() * W * 1.3 - W * 0.15, y: r() * H * 1.3 - H * 0.15, r: (60 + r() * 150) * u, ph: r() * 6.28, a: 0.035 + r() * 0.04 })),
motes: Array.from({ length: 24 }, () => ({ x: r() * W, y: r() * H, ph: r() * 6.28, d: 0.8 + r() * 0.5, s: (2 + r() * 3) * u })) };
// 分层:enter 把后面的 point 放进新的一层
const cs0 = styleFor(ctx.data.center || '', ctx.data.center_style || {});
@@ -64,6 +65,7 @@ return {
const rx = ctx.portrait ? W * 0.34 : Math.min(W * 0.32, 640 * u), ryHalf = Math.min(y1 - y0, H) * (ctx.portrait ? 0.3 : 0.42), ryRing = Math.min((y1 - y0) * (ctx.portrait ? 0.34 : 0.36), y1 - cy - lab, cy - y0 - 60 * u);
levels.forEach((L, li) => {
const n = L.pts.length, ring = n >= 4;
+ L.orbit = { rx, ry: ring ? ryRing : ryHalf, ring };
L.nodes = L.pts.map((q, i) => { const ang = ring ? Math.PI + i / n * Math.PI * 2 : Math.PI + (i + 0.5) / n * Math.PI;
const ry = ring ? ryRing : ryHalf; return { q, i, x: cx + Math.cos(ang) * rx, y: cy + Math.sin(ang) * ry, col: (q.data && q.data.color) || ACC[(i + li * 2) % ACC.length] }; });
if (L.exit) { const nd = L.exit.idx != null ? L.nodes[L.exit.idx] : L.nodes.filter(z => z.q.at <= L.exit.at).pop() || L.nodes[L.nodes.length - 1];
@@ -115,12 +117,16 @@ function drawLevel(c, k, t, ctx) {
if (!ctx.alpha) {
c.fillStyle = P.sky.length > 1 ? TOON.vgrad(c, 0, H, P.sky) : P.sky[0]; c.fillRect(0, 0, W, H);
const sa = PL ? 0.35 : 1; // 色板底上星点只是一层很淡的纹理
+ CAM.layer(c, cam, 0.12, g => { for (const b of S.bokeh) { const k = 0.75 + 0.25 * Math.sin(t * 0.5 + b.ph); const bx = b.x + Math.sin(t * 0.2 + b.ph) * 14 * u, a = b.a * k * (PL ? 0.9 : 1.6), rgb = (PL ? PAINT.hex(P.star) : [125, 211, 220]).slice(0, 3).map(Math.round).join(','), gr = g.createRadialGradient(bx, b.y, b.r * 0.15, bx, b.y, b.r); gr.addColorStop(0, `rgba(${rgb},${a * 0.35})`); gr.addColorStop(0.8, `rgba(${rgb},${a * 0.55})`); gr.addColorStop(1, `rgba(${rgb},0)`); g.fillStyle = gr; g.beginPath(); g.arc(bx, b.y, b.r, 0, 7); g.fill(); } });
CAM.layer(c, cam, 0.05, g => { for (const s of S.stars) { g.globalAlpha = sa * (0.45 + 0.55 * (0.5 + 0.5 * Math.sin(t * s.sp + s.ph))); g.fillStyle = P.star; g.beginPath(); g.arc(s.x, s.y, s.r, 0, 7); g.fill(); } g.globalAlpha = 1; });
}
// highlight 生效时:被推近的节点亮,其余节点和标签暗下去
const hNow = [...L.hls].reverse().find(h => t >= h.at && h.node), dimK = hNow ? MO.smooth(clamp((t - hNow.at) / 0.6)) : 0;
const col = L.col, st = L.style, pull = L.from && t < L.end0 ? MO.smooth(clamp(((t - L.start) / (L.end0 - L.start) - 0.45) / 0.45)) : 1; // 刚钻进来:先是满屏纯色,名字和环在拉出后半段才出来
CAM.layer(c, cam, 1, g => {
+ // 节点轨道:一道很淡的虚线椭圆,让点位有「绕着中心」的结构(节点越多越像一圈,≤3 个是上半弧)
+ if (L.orbit && L.nodes.length) { const o = L.orbit, a0 = L.orbit.ring ? 0 : Math.PI, a1 = L.orbit.ring ? Math.PI * 2 : Math.PI * 2, show = MO.cubicOut(clamp(ctx.lt(t, L.nodes[0].q.at) / 0.8));
+ g.save(); g.globalAlpha = 0.5 * show * (1 - 0.6 * dimK); g.strokeStyle = P.line; g.lineWidth = 2 * u; g.setLineDash([2 * u, 14 * u]); g.lineCap = 'round'; g.beginPath(); g.ellipse(cx, cy, o.rx, o.ry, 0, a0, a0 + (a1 - a0) * show); g.stroke(); g.restore(); }
// 连线+信号脉冲(flow:中心→1→2→3 串成链,信号依次流过)
L.nodes.forEach((nd, i) => {
const l = ctx.lt(t, nd.q.at); if (l <= 0) return;
@@ -132,12 +138,12 @@ function drawLevel(c, k, t, ctx) {
for (let kk = 0; kk < 3; kk++) { if (l < 0.4) break; const q = flow ? ((t * 0.7 - i * 0.33 + kk / 3) % 1 + 1) % 1 : ((l * 0.8 + kk / 3) % 1); const x = lerp(from.x, nd.x, q), y = lerp(from.y, nd.y, q); if (!PL) TOON.glow(g, x, y, 20 * u, P.pulse, 0.6 * (1 - 0.7 * dimK)); g.fillStyle = PL ? P.pulse : P.pulseCore; g.beginPath(); g.arc(x, y, (PL ? 7 : 5) * u, 0, 7); g.fill(); }
});
// 中心物:双色分面+柔光(形状、颜色来自 data.center_style 或按名字生成);可选轨道环;有 data.image 就把图裁进形状里
- const shape = shapePath(st.shape, cx, cy, R);
+ const breath = 1 + 0.018 * Math.sin(t * 1.7), shape = shapePath(st.shape, cx, cy, R * breath);
if (!PL) TOON.glow(g, cx, cy, R * 2.4, light(col), 0.28);
TOON.flat(g, shape, col, dark(col), light(col), [-18 * u, 14 * u], [-6 * u, 5 * u]);
if (L.img) { g.save(); g.clip(shapePath(st.shape, cx, cy, R * 0.9)); MD.cover(g, L.img, { x: cx - R, y: cy - R, w: 2 * R, h: 2 * R }); g.restore(); }
if (st.ring) { g.save(); g.globalAlpha = pull; g.strokeStyle = P.ring; g.lineWidth = 6 * u; g.beginPath(); g.ellipse(cx, cy, R * 1.55, R * 0.35, -0.25, Math.PI * 1.05, Math.PI * 1.95); g.stroke(); g.restore(); }
- if (L.center && !L.img) { const f = TY.fit(g, L.center, R * 1.7, 56 * u, 'PuHui-Heavy', { maxLines: 2, min: 0.5, balance: true }); // 名字放进中心物里:先缩字号,再折两行
+ if (L.center && !L.img) { const f = TY.fitFloor(g, L.center, R * 1.7, 56 * u, 'PuHui-Heavy', { maxLines: 3, floor: 30 * u, balance: true }); // 名字放进中心物里:先缩字号到下限,再折行,再截断
g.save(); g.globalAlpha = pull; g.font = `${f.size}px "PuHui-Heavy"`; g.fillStyle = PL ? PAL.on(col, [PL.surface, PL.ink, PL.bg]) : '#fff'; g.textAlign = 'center'; g.textBaseline = 'middle';
f.lines.forEach((ln, i) => g.fillText(ln, cx, cy + (i - (f.lines.length - 1) / 2) * f.size * 1.1)); g.restore(); }
else if (L.center) { const f = TY.fit(g, L.center, R * 3, 44 * u, 'PuHui-Heavy', { maxLines: 1, min: 0.6 }); // 有图:名字放到下方白胶囊里
@@ -147,16 +153,17 @@ function drawLevel(c, k, t, ctx) {
for (const nd of L.nodes) {
const l = ctx.lt(t, nd.q.at); if (l <= 0) continue;
const on = hNow && hNow.node === nd, a = 1 - 0.65 * dimK * (on ? 0 : 1);
- const pop = MO.backOut(clamp(l / 0.5), 1.1), fy = 0, nr = 46 * u * pop * (on ? 1 + 0.15 * dimK : 1);
+ const pop = MO.backOut(clamp(l / 0.5), 1.1), fy = l > 0.5 ? MO.float(t, 7 * u, 3.4, nd.i * 1.9) * clamp((l - 0.5) / 0.6) : 0, nr = 46 * u * pop * (on ? 1 + 0.15 * dimK : 1);
g.save(); g.globalAlpha = a;
if (!PL) TOON.glow(g, nd.x, nd.y + fy, nr * (on ? 4.2 : 2.6), nd.col, on ? 0.7 : 0.45);
TOON.flat(g, TOON.circle(nd.x, nd.y + fy, nr), nd.col, dark(nd.col), PL ? light(nd.col) : '#ffffff', [-8 * u, -8 * u], [-3 * u, -3 * u]);
+ if (l < 1.0) { const rp = clamp(l / 0.9); g.save(); g.globalAlpha = (1 - rp) * 0.55 * a; g.strokeStyle = nd.col; g.lineWidth = 4 * u * (1 - rp); g.beginPath(); g.arc(nd.x, nd.y + fy, nr * (1.1 + rp * 1.5), 0, 7); g.stroke(); g.restore(); }
if (flow) { g.font = `${30 * u * pop}px "PuHui-Heavy"`; g.fillStyle = PL ? PAL.on(nd.col, [PL.surface, PL.ink, PL.bg]) : P.pillInk; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(String(nd.i + 1), nd.x, nd.y + fy + 2 * u); }
const gone = L.exit ? 1 - clamp((t - L.exit.at) / 0.2) : 1; // 钻进去时:推进一开始这一层的标签全收掉(不然被放大成半屏白块,邻居的也会)
const lp = MO.backOut(clamp((l - 0.15) / 0.5), 1.1) * gone; if (lp > 0) {
const sc = lp * (on ? 1 + 0.18 * dimK : 1);
- const lf = TY.fit(g, nd.q.text || '', ctx.W * 0.44 - 56 * u, (ctx.portrait ? 44 : 38) * u, 'PuHui-Medium', { maxLines: 1 }); // 长标签先缩字号
- g.font = `${lf.size}px "PuHui-Medium"`; const tw = g.measureText(nd.q.text || '').width, bw = tw + 56 * u, bh = 70 * u;
+ const lf = TY.fitFloor(g, nd.q.text || '', ctx.W * 0.44 - 56 * u, (ctx.portrait ? 44 : 38) * u, 'PuHui-Medium', { maxLines: 1, floor: 30 * u }), lab = lf.lines[0] || ''; // 长标签先缩到下限,再截断加「…」,不缩到看不清
+ g.font = `${lf.size}px "PuHui-Medium"`; const tw = g.measureText(lab).width, bw = tw + 56 * u, bh = 70 * u;
const ly = nd.y + fy + (nd.y < cy - R * 0.5 && ctx.portrait ? -nr - 70 * u : nr + 70 * u); // 标签放节点下方(竖屏上半圈放上方)
const z = cam.z || 1, vx0 = cam.x - ctx.W / 2 / z, vx1 = cam.x + ctx.W / 2 / z, hw = bw * sc / 2 + 20 * u / z; // 当前镜头里看得见的世界范围(慢推会把边上的标签推出画)
const lx = nd.x > vx0 && nd.x < vx1 ? (vx1 - vx0 > 2 * hw ? clamp(nd.x, vx0 + hw, vx1 - hw) : cam.x) : nd.x; // 节点在画里,标签就夹回画里
@@ -164,7 +171,7 @@ function drawLevel(c, k, t, ctx) {
g.fillStyle = P.shadow; g.beginPath(); g.roundRect(-bw / 2 + 6 * u, -bh / 2 + 8 * u, bw, bh, bh / 2); g.fill();
g.fillStyle = P.pill; g.beginPath(); g.roundRect(-bw / 2, -bh / 2, bw, bh, bh / 2); g.fill();
if (on) { g.strokeStyle = nd.col; g.lineWidth = 5 * u * dimK; g.stroke(); }
- g.fillStyle = P.pillInk; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(nd.q.text || '', 0, 2 * u);
+ g.fillStyle = P.pillInk; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(lab, 0, 2 * u);
}
g.restore();
}
diff --git a/scripts/engine/clips/y5_kinetic_type.js b/scripts/engine/clips/y5_kinetic_type.js
index b3e28be..23d421c 100644
--- a/scripts/engine/clips/y5_kinetic_type.js
+++ b/scripts/engine/clips/y5_kinetic_type.js
@@ -27,7 +27,7 @@ return {
pages = ctx.of('title', 'point', 'number').map((q, i) => {
const num = q.kind === 'number', nd = q.data || {};
const text = num ? (nd.prefix || '') + TY.fmt(nd.value || 0, nd.decimals ?? 0) + (nd.suffix || '') : (q.text || '');
- const S0 = (ctx.portrait ? 250 : 300) * u;
+ const S0 = (ctx.portrait ? 380 : 300) * u;
let f = TY.fit(g, text, W * 0.86, S0, 'PuHui-Black', { maxLines: 1, min: 0.55, soft: true }); // 先缩字号放一行,再不行折两行;单个长英文词再缩也要放得下
if (!f.ok) f = num ? TY.fit(g, text, W * 0.86, S0, 'PuHui-Black', { maxLines: 1 }) // 数字不折行(滚动时逐字变宽,折开会跳):只缩字号
: TY.fit(g, text, W * 0.86, S0, 'PuHui-Black', { maxLines: 2, min: 0.3, balance: true });
@@ -75,7 +75,8 @@ function drawPage(c, P, t, ctx) {
const by0 = ctx.safe.top, by1 = H - ctx.safe.bottom - (ctx.portrait && LIST ? 220 * u : 0), cyB = ctx.portrait ? by0 + (by1 - by0) * 0.44 : (by0 + by1) / 2;
const blockH = lines.length * lh + (sub ? subSz * (0.6 + subL.length * 1.15) : 0), y0 = cyB - blockH / 2 + size * 0.82;
// 标签(左上)
- const label = q.data && q.data.label;
+ let label = q.data && q.data.label;
+ if (label) { const lf = TY.fitFloor(c, label, W * (ctx.portrait ? 0.84 : 0.5) - (ctx.portrait ? 80 : 140) * u, (ctx.portrait ? 56 : 52) * u, 'PuHui-Bold', { maxLines: 1, floor: 34 * u }); label = lf.lines[0] || ''; }
if (label) TY.rise(c, label, (ctx.portrait ? 80 : 140) * u, ctx.safe.top + (ctx.portrait ? 260 : 210) * u, MO.at(lt, 0, 0.3), { size: (ctx.portrait ? 56 : 52) * u, fam: 'PuHui-Bold', color: fg, track: 6 * u, ...(ctx.alpha ? { stroke: '#111', strokeW: 6 * u } : {}) });
// 高亮(画在字后面)
const hq = ctx.of('highlight').filter(h => h.at >= (P.num ? P.show : q.at) - 1e-6).find(h => { const nx = ctx.of('title', 'point', 'number').find(z => z.at > q.at); return !nx || h.at < nx.at; });
diff --git a/scripts/engine/eras_style_studies.js b/scripts/engine/eras_style_studies.js
new file mode 100644
index 0000000..0b20896
--- /dev/null
+++ b/scripts/engine/eras_style_studies.js
@@ -0,0 +1,20 @@
+window.SCENE_LIBS=['lib/three.min.js'];window.PUNCH=0;window.ERAS=[
+{id:"38_giotto",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("乔托",50,1034);c.restore();}}},
+{id:"39_piero",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("皮耶罗",50,1034);c.restore();}}},
+{id:"40_raphael",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("拉斐尔",50,1034);c.restore();}}},
+{id:"41_michelangelo",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("米开朗基罗",50,1034);c.restore();}}},
+{id:"42_guardi",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("瓜尔迪",50,1034);c.restore();}}},
+{id:"43_lorenzetti",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("洛伦采蒂",50,1034);c.restore();}}},
+{id:"44_cortona",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("科尔托纳",50,1034);c.restore();}}},
+{id:"45_renoir",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("雷诺阿",50,1034);c.restore();}}},
+{id:"46_pissarro",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("毕沙罗",50,1034);c.restore();}}},
+{id:"47_sisley",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("西斯莱",50,1034);c.restore();}}},
+{id:"48_gauguin",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("高更",50,1034);c.restore();}}},
+{id:"49_chagall",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("夏加尔",50,1034);c.restore();}}},
+{id:"50_ma_yuan",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("马远",50,1034);c.restore();}}},
+{id:"51_persian_miniature",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("波斯细密画",50,1034);c.restore();}}},
+{id:"52_south_park",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("南方公园",50,1034);c.restore();}}},
+{id:"54_ghibli_lab",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("吉卜力方向",50,1034);c.restore();}}},
+{id:"53_pixar",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("皮克斯方向",50,1034);c.restore();}}},
+{id:"55_dunhuang",dur:6,counter:{draw(c){c.save();c.font='25px sans-serif';c.textAlign='left';c.fillStyle='rgba(25,28,23,.75)';c.fillRect(34,1002,230,46);c.fillStyle='#fff9e9';c.fillText("敦煌壁画",50,1034);c.restore();}}}
+];
diff --git a/scripts/engine/index.html b/scripts/engine/index.html
index c80fabb..016a01f 100644
--- a/scripts/engine/index.html
+++ b/scripts/engine/index.html
@@ -18,6 +18,7 @@ body.render #ui{display:none}
<script src="lib/rig.js"></script>
<script src="lib/rig_huashu.js"></script>
<script src="lib/kit.js"></script>
+<script src="lib/medium.js"></script>
<!-- YouTube 解说语法库(references/09):动效时间、相机、图解形变、文字、图表、发布会界面、拼贴、卡通 -->
<script src="lib/motion.js"></script>
<script src="lib/camera.js"></script>
diff --git a/scripts/engine/lib/THREE_LICENSE.txt b/scripts/engine/lib/THREE_LICENSE.txt
new file mode 100644
index 0000000..d07e209
--- /dev/null
+++ b/scripts/engine/lib/THREE_LICENSE.txt
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright © 2010-2023 three.js authors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/scripts/engine/lib/finish.js b/scripts/engine/lib/finish.js
new file mode 100644
index 0000000..4d711d6
--- /dev/null
+++ b/scripts/engine/lib/finish.js
@@ -0,0 +1,70 @@
+// 成片质感层(spec.finish):画完一帧之后、对整幅统一加的后期。所有语法通用;默认不开(clean)。
+// spec.finish = 预设名 | { vignette, bloom, grain, contrast, saturate, warm }(对象里的键覆盖预设)。
+// soft :轻暗角+极淡泛光+细颗粒——任何深色/浅色底都不显脏,大多数口播片的默认推荐
+// film :暗角更重+泛光+可见颗粒+一点暖——叙事、故事型
+// punch :对比+饱和各抬一点+轻暗角——发布会、财经、需要「抓眼」的段落
+// clean :什么都不做(和不写一样)
+// 键含义:vignette 暗角强度 0–0.6;bloom 泛光强度 0–0.4;grain 颗粒强度 0–0.12(按 24fps 换格,确定性);contrast/saturate 1=不变;warm 0–0.12 暖色罩。
+// alpha 模式(透明背景)一律不加:后期会把透明区域染黑。
+// 确定性:颗粒只由帧序号决定,同一时刻渲两次逐像素一致。
+(() => {
+const { clamp } = U;
+const PRESETS = {
+ clean: {},
+ soft: { vignette: 0.2, bloom: 0.1, grain: 0.035 },
+ film: { vignette: 0.34, bloom: 0.12, grain: 0.07, warm: 0.04 },
+ punch: { vignette: 0.16, bloom: 0.08, contrast: 1.07, saturate: 1.1 },
+};
+const cache = {};
+const scratch = (k, w, h) => { let c = cache[k]; if (!c || c.width !== w || c.height !== h) { c = cache[k] = document.createElement('canvas'); c.width = w; c.height = h; } return c; };
+// 颗粒 tile:3 张 256×256 灰度噪声,种子固定
+function grainTiles() {
+ if (cache.__grain) return cache.__grain;
+ const r = U.rng(20261016), tiles = [];
+ for (let k = 0; k < 3; k++) { const cv = document.createElement('canvas'); cv.width = cv.height = 256; const g = cv.getContext('2d'), im = g.createImageData(256, 256);
+ for (let i = 0; i < 256 * 256; i++) { const v = 128 + (r() + r() + r() - 1.5) * 90; im.data[i * 4] = im.data[i * 4 + 1] = im.data[i * 4 + 2] = v; im.data[i * 4 + 3] = 255; }
+ g.putImageData(im, 0, 0); tiles.push(cv); }
+ return (cache.__grain = tiles);
+}
+const FINISH = window.FINISH = {
+ PRESETS,
+ // 解析 spec.finish:返回完整参数对象或 null(不加)。写错预设名 → 抛错(clip.js 转成启动失败)
+ resolve(f) {
+ if (f == null || f === false || f === 'clean') return null;
+ let o = typeof f === 'string' ? PRESETS[f] : { ...(PRESETS[f.preset] || {}), ...f };
+ if (!o) throw new Error(`spec.finish「${f}」不是预设:${Object.keys(PRESETS).join(' / ')}(或写对象 {vignette, bloom, grain, contrast, saturate, warm})`);
+ const bad = Object.keys(o).filter(k => !['vignette', 'bloom', 'grain', 'contrast', 'saturate', 'warm', 'preset'].includes(k));
+ if (bad.length) throw new Error(`spec.finish 里没有这些键:${bad.join('、')}(可用 vignette bloom grain contrast saturate warm)`);
+ return Object.keys(o).length ? o : null;
+ },
+ apply(c, t, o, W, H, fps = 30) {
+ if (!o) return;
+ const cv = c.canvas;
+ // 对比/饱和:整幅过一遍 CSS filter
+ if ((o.contrast && o.contrast !== 1) || (o.saturate && o.saturate !== 1)) {
+ const s = scratch('fin_cs', W, H), g = s.getContext('2d'); g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, W, H); g.drawImage(cv, 0, 0);
+ c.save(); c.setTransform(1, 0, 0, 1, 0, 0); c.filter = `contrast(${o.contrast || 1}) saturate(${o.saturate || 1})`; c.drawImage(s, 0, 0); c.restore();
+ }
+ // 泛光:缩小糊化后 screen 叠回(亮处晕开一点)
+ if (o.bloom > 0) {
+ const sw = Math.max(64, Math.round(W / 6)), sh = Math.max(64, Math.round(H / 6)), s = scratch('fin_bloom', sw, sh), g = s.getContext('2d');
+ g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, sw, sh); g.filter = 'blur(5px) brightness(1.15)'; g.drawImage(cv, 0, 0, sw, sh); g.filter = 'none';
+ c.save(); c.setTransform(1, 0, 0, 1, 0, 0); c.globalCompositeOperation = 'screen'; c.globalAlpha = clamp(o.bloom, 0, 0.5); c.imageSmoothingQuality = 'high'; c.drawImage(s, 0, 0, W, H); c.restore();
+ }
+ // 暖色罩
+ if (o.warm > 0) { c.save(); c.setTransform(1, 0, 0, 1, 0, 0); c.globalCompositeOperation = 'soft-light'; c.fillStyle = `rgba(255,190,120,${clamp(o.warm, 0, 0.2) * 2})`; c.fillRect(0, 0, W, H); c.restore(); }
+ // 颗粒:24fps 换格,随机偏移;overlay 叠灰度噪声
+ if (o.grain > 0) {
+ const tiles = grainTiles(), f = Math.floor(t * 24 + 1e-6), tile = tiles[f % 3], r = U.rng(f * 7919 + 13), ox = Math.floor(r() * 256), oy = Math.floor(r() * 256);
+ c.save(); c.setTransform(1, 0, 0, 1, 0, 0); c.globalCompositeOperation = 'overlay'; c.globalAlpha = clamp(o.grain, 0, 0.2) * 3.2;
+ c.fillStyle = c.createPattern(tile, 'repeat'); c.translate(-ox, -oy); c.fillRect(ox, oy, W, H); c.restore();
+ }
+ // 暗角
+ if (o.vignette > 0) {
+ const R = Math.hypot(W, H) / 2, g = c.createRadialGradient(W / 2, H / 2, R * 0.45, W / 2, H / 2, R);
+ g.addColorStop(0, 'rgba(0,0,0,0)'); g.addColorStop(1, `rgba(0,0,0,${clamp(o.vignette, 0, 0.7)})`);
+ c.save(); c.setTransform(1, 0, 0, 1, 0, 0); c.fillStyle = g; c.fillRect(0, 0, W, H); c.restore();
+ }
+ },
+};
+})();
diff --git a/scripts/engine/lib/media.js b/scripts/engine/lib/media.js
index 3c680d7..5e24d18 100644
--- a/scripts/engine/lib/media.js
+++ b/scripts/engine/lib/media.js
@@ -15,7 +15,7 @@
// MD.print(c, src, w, h, o) 冲印件:白边+旧纸色+投影+胶带,原点在冲印件中心(调用方先 translate/rotate)
// o = { border=16·u, crop, fx, fy(按焦点 cover 进 w×h), tape=true, caption(白边下方小字), polaroid=false(底边加宽、caption 写在底边里),
// shadow=true, key(给了 key 且素材是静态图就缓存成位图)}
-// MD.label(c, text, x, y, o) 黑底撕边标签:o = { size=48·u, fam='PuHui-Heavy', bg='#191817', fg='#f3efe6', align='left'|'center'|'right',
+// MD.label(c, text, x, y, o) 黑底撕边标签:o = { size=48·u, maxW(限宽,超了先缩后截断), fam='PuHui-Heavy', bg='#191817', fg='#f3efe6', align='left'|'center'|'right',
// t, at(at 这一帧出现:先 1.12 倍一拍再落定,字按 rate 字/秒、12fps 打出;不给 t 就直接画完整的), rate=14, r(旋转)}
// 返回 {w, h}
// MD.frameAt(frames, lt, fps=30, loop=false) 帧序列(图片数组)在片内时间 lt 的那一帧;缺帧 → throw
@@ -83,9 +83,16 @@ MD.print = (c, src, w, h, o = {}) => {
const labCache = {};
MD.label = (c, text, x, y, o = {}) => {
text = String(text ?? ''); if (!text) return { w: 0, h: 0 };
- const u = u0(), size = o.size ?? 48 * u, fam = o.fam || 'PuHui-Heavy', bg = o.bg || '#191817', fg = o.fg || '#f3efe6';
+ const u = u0(), fam = o.fam || 'PuHui-Heavy', bg = o.bg || '#191817', fg = o.fg || '#f3efe6';
+ let size = o.size ?? 48 * u;
if (o.t != null && o.at != null && o.t < o.at) return { w: 0, h: 0 };
c.save(); c.font = `${size}px "${fam}"`;
+ if (o.maxW) { // 限宽:先把字缩到 62% 为止,还放不下就截断加「…」,标签不许比画面宽
+ const full = c.measureText(text).width + size * 0.84;
+ if (full > o.maxW) { size = Math.max(size * 0.62, size * o.maxW / full); c.font = `${size}px "${fam}"`;
+ const cs = [...text]; while (cs.length > 1 && c.measureText(cs.join('')).width + size * 0.84 > o.maxW) cs.pop();
+ if (cs.length < [...text].length) text = cs.join('').trimEnd() + '…'; }
+ }
const tw = c.measureText(text).width, padX = size * 0.42, w = Math.round(tw + padX * 2), h = Math.round(size * 1.5);
const key = `${text}|${size}|${fam}|${bg}`;
const sp = labCache[key] || (labCache[key] = (() => { const cv = document.createElement('canvas'); cv.width = w; cv.height = h; const g = cv.getContext('2d');
diff --git a/scripts/engine/lib/medium.js b/scripts/engine/lib/medium.js
new file mode 100644
index 0000000..4b681f5
--- /dev/null
+++ b/scripts/engine/lib/medium.js
@@ -0,0 +1,258 @@
+// 媒介层:把「干净的形」过一遍真实的画材,而不是在扁平矢量上盖噪点。2026-10-16 新增,新风格演示(38–54)用。
+// MEDIUM.figure(c, o) 有体量的着衣人物:钟形袍+披风褶+袖+手+简化脸(视线是主角)。只给原创平面/壁画/细密画一类明确选择的风格用
+// MEDIUM.plaster(key, o) 灰泥墙底:低频湿干色差+颗粒+针孔+接缝(壁画「一天的活」边),缓存
+// MEDIUM.fresco(c, plate, o) 壁画通道:色粉被石灰吃进去(轻糊+粉白罩)+灰泥相乘+针孔提亮+接缝
+// MEDIUM.silk(key, o) 绢/纸底:经纬丝纹+泛黄晕边,缓存
+// MEDIUM.outline(c, path, o) 轮廓线:可变线宽、颜色可偏(赭褐、群青、墨),不是纯黑
+// MEDIUM.flat(c, path, fill, o) 掐丝珐琅式平涂:同色块里有顺笔向的短条+粗而不均的深群青轮廓(高更)
+// MEDIUM.broken(src, o) 破碎色笔触重绘:把干净的画布重画成一笔一笔的印象派(明处偏暖、暗处偏冷的互补抖动),返回新画布,调用方缓存
+// MEDIUM.hatchFill(c, path, o) 在路径内按方向排线(木刻/铜版/细密画暗部)
+// 约定:所有随机走种子;plate 是画好的 1920×1080 离屏画布;通道函数不改 plate。
+(() => {
+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; });
+const P = window.PAINT, { clamp, lerp, rng, ss } = U, TAU = Math.PI * 2;
+const M = window.MEDIUM = {};
+
+const hex = h => P.hex(h);
+const mixc = (a, b, t) => P.mix(typeof a === 'string' ? hex(a) : a, typeof b === 'string' ? hex(b) : b, t);
+const css = (c, a = 1) => P.rgb(typeof c === 'string' ? hex(c) : c, a);
+M.css = css; M.mix = mixc;
+
+// ---------- 灰泥 ----------
+// 壁画不是纸:石灰层有低频的湿干色差、细颗粒、针孔;一天的活(giornata)之间有一道几乎看不见的接缝。
+M.plaster = (key, { base = '#d9cdb4', seams = [], seed = 7, pits = 1400, mottle = 0.07 } = {}) => P.cached('plaster_' + key, W, H, (g) => {
+ const r = rng(seed), im = g.createImageData(W, H), d = im.data, b = hex(base);
+ for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) {
+ const i = (y * W + x) * 4;
+ const m = P.fbm(x * 0.0035 + seed, y * 0.0035, 4) * mottle * 255 + P.fbm(x * 0.02, y * 0.02 + seed, 3) * 0.035 * 255;
+ const f = (r() - 0.5) * 16; // 细颗粒
+ d[i] = clamp(b[0] + m + f, 0, 255); d[i + 1] = clamp(b[1] + m + f, 0, 255); d[i + 2] = clamp(b[2] + m * 0.9 + f, 0, 255); d[i + 3] = 255;
+ }
+ g.putImageData(im, 0, 0);
+ for (let i = 0; i < pits; i++) { // 针孔:暗点+右下一侧的亮边
+ const x = r() * W, y = r() * H, s = 0.6 + r() * 1.9;
+ g.fillStyle = `rgba(70,55,40,${0.12 + r() * 0.22})`; g.beginPath(); g.arc(x, y, s, 0, TAU); g.fill();
+ g.fillStyle = 'rgba(255,250,235,.28)'; g.beginPath(); g.arc(x + s * 0.7, y + s * 0.7, s * 0.55, 0, TAU); g.fill();
+ }
+ g.lineCap = 'round';
+ for (const sm of seams) { // 接缝:[[x,y],...] 折线;一条亮脊+一条暗线,两侧底色略差
+ g.strokeStyle = 'rgba(80,62,45,.22)'; g.lineWidth = 1.6; g.beginPath(); sm.forEach((p, k) => k ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.stroke();
+ g.strokeStyle = 'rgba(255,248,230,.34)'; g.lineWidth = 1.4; g.beginPath(); sm.forEach((p, k) => k ? g.lineTo(p[0], p[1] + 2) : g.moveTo(p[0], p[1] + 2)); g.stroke();
+ }
+});
+
+// 壁画通道:plate(干净的形)→ 画面。
+// ① 轻糊(色粉被湿灰泥吃进去,边缘不锐)② 石灰粉白罩(screen 低 α,整体粉、哑)③ 灰泥相乘(底色差、颗粒)④ 针孔和接缝提亮
+M.fresco = (c, plate, { ground, chalk = 0.10, soften = 0.8, plasterAlpha = 0.55, sat = 0.9, tone = null } = {}) => {
+ c.save();
+ c.filter = `blur(${soften}px) saturate(${sat})`; c.drawImage(plate, 0, 0); c.filter = 'none';
+ c.globalCompositeOperation = 'screen'; c.fillStyle = `rgba(236,226,206,${chalk})`; c.fillRect(0, 0, W, H);
+ c.globalCompositeOperation = 'multiply'; c.globalAlpha = plasterAlpha; c.drawImage(ground, 0, 0);
+ c.globalCompositeOperation = 'soft-light'; c.globalAlpha = 0.5; c.drawImage(ground, 0, 0);
+ if (tone) { c.globalCompositeOperation = 'multiply'; c.globalAlpha = 1; c.fillStyle = tone; c.fillRect(0, 0, W, H); }
+ c.restore();
+};
+
+// ---------- 绢 / 纸底 ----------
+M.silk = (key, { base = '#c9a85e', seed = 3, warp = 0.5, vig = 0.5, fleck = 1800 } = {}) => P.cached('silk_' + key, W, H, (g) => {
+ const r = rng(seed), b = hex(base);
+ const gr = g.createLinearGradient(0, 0, 0, H); gr.addColorStop(0, css(mixc(b, [255, 240, 200], 0.18))); gr.addColorStop(1, css(mixc(b, [120, 80, 30], 0.12)));
+ g.fillStyle = gr; g.fillRect(0, 0, W, H);
+ g.globalAlpha = 0.5; g.drawImage(P.texture('silk' + key, base, { scale: 0.003, amt: 14, grain: 5, seed }), 0, 0); g.globalAlpha = 1;
+ for (let x = 0; x < W; x += 3) { g.fillStyle = `rgba(90,60,20,${(0.02 + r() * 0.045) * warp})`; g.fillRect(x, 0, 1, H); } // 经线
+ for (let y = 0; y < H; y += 3) { g.fillStyle = `rgba(255,236,170,${(0.015 + r() * 0.04) * warp})`; g.fillRect(0, y, W, 1); } // 纬线
+ for (let i = 0; i < fleck; i++) { g.fillStyle = r() < 0.5 ? 'rgba(80,55,25,.10)' : 'rgba(255,240,200,.14)'; g.fillRect(r() * W, r() * H, 1 + r() * 4, 1); }
+ const v = g.createRadialGradient(W / 2, H / 2, H * 0.45, W / 2, H / 2, W * 0.75); v.addColorStop(0, 'rgba(80,50,15,0)'); v.addColorStop(1, `rgba(80,50,15,${vig * 0.5})`);
+ g.fillStyle = v; g.fillRect(0, 0, W, H);
+});
+
+// ---------- 线 ----------
+// 沿 pts 画变宽线:w 为 [起,中,尾] 宽度,col 颜色。不是纯黑——给素描红土/群青/墨色。
+M.outline = (c, pts, { w = [1, 3, 1], col = '#4a3322', a = 0.9, closed = false, jitter = 0, seed = 1 } = {}) => {
+ const r = rng(seed), n = pts.length;
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round'; c.strokeStyle = typeof col === 'string' ? col : css(col, a); c.globalAlpha = a;
+ const seg = closed ? n : n - 1;
+ for (let i = 0; i < seg; i++) {
+ const A = pts[i], B = pts[(i + 1) % n], q = i / Math.max(1, seg - 1);
+ c.lineWidth = q < 0.5 ? lerp(w[0], w[1], q * 2) : lerp(w[1], w[2], (q - 0.5) * 2);
+ c.beginPath(); c.moveTo(A[0] + (r() - .5) * jitter, A[1] + (r() - .5) * jitter); c.lineTo(B[0] + (r() - .5) * jitter, B[1] + (r() - .5) * jitter); c.stroke();
+ }
+ c.restore();
+};
+
+M.hatchFill = (c, path, { ang = 0.9, gap = 5, col = 'rgba(40,30,20,.35)', lw = 1, bounds = [0, 0, W, H], seed = 1 } = {}) => {
+ const r = rng(seed); c.save(); c.clip(path); c.strokeStyle = col; c.lineWidth = lw; c.beginPath();
+ const [bx, by, bw, bh] = bounds, R = Math.hypot(bw, bh), cx = bx + bw / 2, cy = by + bh / 2, ca = Math.cos(ang), sa = Math.sin(ang);
+ for (let k = -R; k < R; k += gap) { const j = (r() - .5) * 1.2; c.moveTo(cx + ca * -R - sa * (k + j), cy + sa * -R + ca * (k + j)); c.lineTo(cx + ca * R - sa * (k + j), cy + sa * R + ca * (k + j)); }
+ c.stroke(); c.restore();
+};
+
+// ---------- 掐丝珐琅式平涂(高更/综合主义)----------
+// path: Path2D;fill: 色;o.streak: 笔向(弧度),o.vari: 色差幅度;o.line: 轮廓色(深群青/紫黑,不是纯黑),o.lw: 轮廓宽
+// 平涂不等于平:同一色块里有顺笔向的明暗短条(看得见刷子),轮廓粗而不均。每块用 o.seed 固定笔触,确定性。
+M.flat = (c, path, fill, { streak = 0.7, vari = 18, line = '#1d2a52', lw = 6, seed = 1, bounds = [0, 0, W, H], n = 46, la = 0.95 } = {}) => {
+ const r = rng(seed * 131), f = typeof fill === 'string' ? hex(fill) : fill;
+ c.save(); c.fillStyle = css(f); c.fill(path); c.clip(path);
+ const [bx, by, bw, bh] = bounds;
+ c.lineCap = 'round';
+ for (let i = 0; i < n; i++) {
+ const x = bx + r() * bw, y = by + r() * bh, L = 40 + r() * 120, a = streak + (r() - .5) * 0.25, d = (r() - .5) * 2 * vari;
+ c.strokeStyle = css([f[0] + d, f[1] + d * 0.8, f[2] + d * 0.7], 0.55); c.lineWidth = 8 + r() * 22;
+ c.beginPath(); c.moveTo(x, y); c.lineTo(x + Math.cos(a) * L, y + Math.sin(a) * L); c.stroke();
+ }
+ c.restore();
+ if (lw) { c.save(); c.strokeStyle = line; c.globalAlpha = la; c.lineWidth = lw; c.lineJoin = 'round'; c.lineCap = 'round'; c.stroke(path); c.restore(); }
+};
+
+// ---------- 破碎色笔触重绘(印象派:毕沙罗/西斯莱/瓜尔迪/雷诺阿)----------
+// src:画好的干净画布(可比舞台宽,如拖动的天空);返回新画布(调用方缓存)。
+// 每个采样点画一小笔:沿 angleFn(x,y) 方向、两头尖的弯笔,颜色=该点颜色按「明暗+冷暖互补」抖动——
+// 亮处偏暖黄/粉、暗处偏冷紫/蓝(不是单纯明度噪声);随机跳过一些点让底色透出;笔序确定性打乱,所以厚笔压薄笔。
+// o: cell 采样间距, len 笔长, wid 笔宽, passes 遍数(第二遍更小更碎), angle(x,y)→弧度, seed, warm/cool 互补抖动色, sat 饱和度增益
+M.broken = (src, { cell = 9, len = 26, wid = 8, passes = 2, angle = () => 0, seed = 1, warm = [255, 226, 160], cool = [120, 120, 190], jit = 22, skip = 0.1, sat = 1.06, base = true } = {}) => {
+ const w = src.width, h = src.height, out = P.canvas(w, h), g = out.getContext('2d');
+ const sg = src.getContext('2d', { willReadFrequently: true }), d = sg.getImageData(0, 0, w, h).data, r = rng(seed * 977);
+ if (base) { g.filter = 'blur(6px)'; g.drawImage(src, -14, -14, w + 28, h + 28); g.filter = 'none'; } // 外扩 14px 再糊:边缘不留半透明圈(左缘一排缺口小圆点就是这么来的)
+ g.lineCap = 'round';
+ for (let pass = 0; pass < passes; pass++) {
+ const cs = cell * (pass ? 0.62 : 1), L = len * (pass ? 0.6 : 1), Wd = wid * (pass ? 0.6 : 1), pts = [];
+ for (let y = 0; y < h + cs; y += cs) for (let x = 0; x < w + cs; x += cs) pts.push([x + (r() - .5) * cs, y + (r() - .5) * cs]);
+ for (let i = pts.length - 1; i > 0; i--) { const j = (r() * (i + 1)) | 0; [pts[i], pts[j]] = [pts[j], pts[i]]; }
+ for (const [x, y] of pts) {
+ if (r() < skip) continue;
+ const xi = clamp(x | 0, 0, w - 1), yi = clamp(y | 0, 0, h - 1), k = (yi * w + xi) * 4;
+ if (d[k + 3] < 8) continue;
+ let R = d[k], G = d[k + 1], B = d[k + 2];
+ const lum = (R * 0.3 + G * 0.59 + B * 0.11) / 255, t2 = (r() - 0.5) * 2;
+ const tint = lum > 0.55 ? warm : cool, tm = Math.abs(t2) * 0.22 * (lum > 0.55 ? lum : 1 - lum);
+ R = lerp(R, tint[0], tm) + t2 * jit * 0.5; G = lerp(G, tint[1], tm) + t2 * jit * 0.45; B = lerp(B, tint[2], tm) + t2 * jit * 0.4;
+ const mx = (R + G + B) / 3; R = mx + (R - mx) * sat; G = mx + (G - mx) * sat; B = mx + (B - mx) * sat;
+ const a = angle(x, y) + (r() - .5) * 0.35, l = L * (0.6 + r() * 0.8), wd = Wd * (0.6 + r() * 0.7), bend = (r() - .5) * 0.5 * l;
+ const cx = Math.cos(a), sx = Math.sin(a);
+ g.strokeStyle = `rgb(${clamp(R, 0, 255) | 0},${clamp(G, 0, 255) | 0},${clamp(B, 0, 255) | 0})`; g.globalAlpha = 0.9; g.lineWidth = wd;
+ g.beginPath(); g.moveTo(x - cx * l / 2, y - sx * l / 2); g.quadraticCurveTo(x - sx * bend, y + cx * bend, x + cx * l / 2, y + sx * l / 2); g.stroke();
+ }
+ }
+ g.globalAlpha = 1; return out;
+};
+
+// ---------- 有体量的着衣人物 ----------
+// o: x,y(脚底中心), h(全高), robe:[亮,中,暗], under(内衣露出色), mantle(披风色组或 null), skin, hair,
+// face(-1 朝左/1 朝右), lean(髋以上前倾,弧度,朝 face 方向为正), bow(低头 0..1), gaze:[x,y](看向哪,画眼珠),
+// hands:[[x,y],[x,y]](两只手的目标点,null 则自然下垂), sway(衣摆摆动 0..1), halo(金色光环,默认无), line(轮廓色)
+// 画法:袍=钟形多边形+沿宽度的明暗渐变+数条褶线(暗线+相邻亮线);袖=两段式(肩→肘→手)的变宽带;头=椭圆+发+眼(视线)。
+// 不画五官细节:吉卜力式大眼、乔托式「杏仁眼斜视」都靠眼珠偏向 gaze 表达关系。
+M.figure = (c, o) => {
+ const { x, y, h, face = 1, lean = 0, bow = 0, sway = 0, hands = [null, null], gaze = null, halo = false } = o;
+ const robe = (o.robe || ['#d98a78', '#b85a4c', '#7a3a34']).map(hex), under = hex(o.under || '#e7d9b0'), skin = hex(o.skin || '#e0b48c'), hairC = hex(o.hair || '#5a3a24'), line = o.line || '#4a2f22';
+ const mantle = o.mantle ? o.mantle.map(hex) : null, seed = o.seed || 1, r = rng(seed * 97);
+ const hipY = y - h * 0.42, sh = h * 0.2;
+ const cs = Math.cos(lean * face), sn = Math.sin(lean * face);
+ const up = (dx, dy) => [x + dx * cs - dy * sn * face, hipY + dx * sn * face + dy * cs]; // 髋为原点、绕髋前倾
+ const shL = up(-h * 0.15, -h * 0.30), shR = up(h * 0.15, -h * 0.30), neck = up(0, -h * 0.335);
+ const head = [neck[0] + face * h * 0.014 * bow, neck[1] - h * 0.088 + h * 0.025 * bow];
+ const hw = h * 0.078, hh = h * 0.094;
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+
+ // 地面影
+ c.fillStyle = 'rgba(40,28,18,.22)'; c.beginPath(); c.ellipse(x + face * h * 0.03, y + 3, h * 0.22, h * 0.03, 0, 0, TAU); c.fill();
+
+ // --- 袍身 ---
+ const hemW = h * (0.25 * (o.hemK || 1) + 0.012 * sway), waistW = h * 0.115, sw = Math.sin(o.t * 2.3 + seed) * sway * h * 0.012 || 0;
+ const body = new Path2D();
+ body.moveTo(shL[0], shL[1]); body.lineTo(neck[0] - h * 0.03, neck[1] + 4); body.lineTo(neck[0] + h * 0.03, neck[1] + 4); body.lineTo(shR[0], shR[1]);
+ body.quadraticCurveTo(shR[0] + h * 0.02, hipY - h * 0.1, x + waistW, hipY + h * 0.05);
+ body.quadraticCurveTo(x + hemW * 0.9 + sw, y - h * 0.18, x + hemW + sw, y);
+ body.quadraticCurveTo(x, y + h * 0.018, x - hemW + sw, y);
+ body.quadraticCurveTo(x - hemW * 0.9 + sw, y - h * 0.18, x - waistW, hipY + h * 0.05);
+ body.quadraticCurveTo(shL[0] - h * 0.02, hipY - h * 0.1, shL[0], shL[1]); body.closePath();
+ const lx = x - face * h * 0.2, gr = c.createLinearGradient(lx, 0, x + face * h * 0.26, 0); // 光从背后一侧来:亮在 -face 侧
+ gr.addColorStop(0, css(robe[0])); gr.addColorStop(0.3, css(robe[0])); gr.addColorStop(0.52, css(robe[1])); gr.addColorStop(0.82, css(robe[2])); gr.addColorStop(1, css(robe[2]));
+ c.fillStyle = gr; c.fill(body);
+ // 褶:先铺软的明暗大面(模糊),再压一条细硬折痕——乔托的衣褶是「大面渐变+少数硬边」,不是排线
+ const nF = 5, folds = [];
+ for (let i = 0; i < nF; i++) { const q = (i + 0.5) / nF - 0.5; folds.push({ x0: x + q * h * 0.22 + (r() - .5) * h * 0.02, x1: x + q * hemW * 2 * 0.92 + sw * (0.4 + Math.abs(q)), cy: y - h * (0.22 + r() * 0.12), k: 0.7 + r() * 0.6 }); }
+ c.save(); c.clip(body);
+ c.filter = `blur(${Math.max(2, h * 0.012)}px)`;
+ for (const f of folds) { c.strokeStyle = css(robe[2], 0.34 * f.k); c.lineWidth = h * 0.05 * f.k; c.beginPath(); c.moveTo(f.x0, hipY - h * 0.1); c.quadraticCurveTo(f.x0 + (f.x1 - f.x0) * 0.2 + face * h * 0.015, f.cy, f.x1, y - h * 0.01); c.stroke();
+ c.strokeStyle = css(robe[0], 0.3 * f.k); c.lineWidth = h * 0.035 * f.k; c.beginPath(); c.moveTo(f.x0 - face * h * 0.04, hipY - h * 0.1); c.quadraticCurveTo(f.x0 + (f.x1 - f.x0) * 0.2 - face * h * 0.03, f.cy, f.x1 - face * h * 0.045, y - h * 0.01); c.stroke(); }
+ c.filter = 'none';
+ for (const f of folds) { c.strokeStyle = css(robe[2], 0.5); c.lineWidth = h * 0.0065; c.beginPath(); c.moveTo(f.x0, hipY - h * 0.1); c.quadraticCurveTo(f.x0 + (f.x1 - f.x0) * 0.2 + face * h * 0.015, f.cy, f.x1, y - h * 0.01); c.stroke(); }
+ // 膝/腰的受力:两处弧形暗影(衣料被撑起的地方)
+ c.filter = `blur(${h * 0.02}px)`; c.fillStyle = css(robe[2], 0.22); c.beginPath(); c.ellipse(x + face * h * 0.04, hipY + h * 0.12, h * 0.07, h * 0.16, 0.2 * face, 0, TAU); c.fill(); c.filter = 'none';
+ // 腰带/内衣下摆
+ c.fillStyle = css(under, 0.95); c.beginPath(); c.moveTo(x - hemW * 0.5 + sw, y); c.quadraticCurveTo(x + sw, y - h * 0.05, x + hemW * 0.5 + sw, y); c.quadraticCurveTo(x + sw, y + h * 0.015, x - hemW * 0.5 + sw, y); c.fill();
+ c.restore();
+ c.strokeStyle = line; c.globalAlpha = 0.75; c.lineWidth = Math.max(1.6, h * 0.007); c.stroke(body); c.globalAlpha = 1;
+
+ // --- 披风:从背侧肩斜过身体盖到对侧髋,厚重的大褶 ---
+ if (mantle) {
+ const back = face > 0 ? shL : shR, front = face > 0 ? shR : shL, sideX = face;
+ const mp = new Path2D();
+ mp.moveTo(back[0] - sideX * h * 0.03, back[1] - h * 0.03);
+ mp.quadraticCurveTo(neck[0], neck[1] - h * 0.015, front[0] + sideX * h * 0.015, front[1] + h * 0.02);
+ mp.quadraticCurveTo(front[0] - sideX * h * 0.02, hipY, x - sideX * hemW * 0.05 + sw, y - h * 0.01);
+ mp.quadraticCurveTo(x - sideX * hemW * 0.5 + sw, y + h * 0.022, x - sideX * hemW * 1.02 + sw, y);
+ mp.quadraticCurveTo(back[0] - sideX * h * 0.16, hipY, back[0] - sideX * h * 0.03, back[1] - h * 0.03); mp.closePath();
+ const mg = c.createLinearGradient(x - h * 0.2, 0, x + h * 0.26, 0); mg.addColorStop(0, css(mantle[0])); mg.addColorStop(0.5, css(mantle[1])); mg.addColorStop(1, css(mantle[2]));
+ c.fillStyle = mg; c.fill(mp);
+ c.save(); c.clip(mp);
+ for (let i = 0; i < 5; i++) {
+ const q = i / 4, sx = lerp(back[0], front[0], q), ex = x + (q - 0.45) * hemW * 1.8 + sw;
+ c.strokeStyle = css(mantle[2], 0.5); c.lineWidth = h * 0.011; c.beginPath(); c.moveTo(sx, lerp(back[1], front[1], q) + h * 0.03); c.quadraticCurveTo(sx + sideX * h * 0.03, hipY + h * 0.03, ex, y - h * 0.01); c.stroke();
+ c.strokeStyle = css(mantle[0], 0.4); c.lineWidth = h * 0.006; c.beginPath(); c.moveTo(sx - sideX * h * 0.012, lerp(back[1], front[1], q) + h * 0.03); c.quadraticCurveTo(sx + sideX * h * 0.02, hipY + h * 0.03, ex - sideX * h * 0.014, y - h * 0.01); c.stroke();
+ }
+ c.restore(); c.strokeStyle = line; c.globalAlpha = 0.7; c.lineWidth = Math.max(1.6, h * 0.007); c.stroke(mp); c.globalAlpha = 1;
+ }
+
+ // --- 袖与手:肩→肘→手,肘按「向外下方」弯 ---
+ const sleeveCol = mantle ? mantle : robe;
+ const arm = (S, T, k) => {
+ if (!T) T = [S[0] + (k ? 1 : -1) * h * 0.05, S[1] + h * 0.26];
+ const L1 = h * 0.17, L2 = h * 0.16, dx = T[0] - S[0], dy = T[1] - S[1], dist = Math.min(Math.hypot(dx, dy), L1 + L2 - 1), a = Math.atan2(dy, dx);
+ const ca = Math.acos(clamp((L1 * L1 + dist * dist - L2 * L2) / (2 * L1 * dist), -1, 1)), side = (T[0] > x ? 1 : -1) * (k ? 1 : -1) || 1;
+ const el = [S[0] + Math.cos(a + ca * -side) * L1, S[1] + Math.sin(a + ca * -side) * L1];
+ const hd = [S[0] + Math.cos(a) * dist, S[1] + Math.sin(a) * dist];
+ const w0 = h * 0.078, w1 = h * 0.058, w2 = h * 0.04;
+ const pts = [S, el, hd], nx = i => { const A = pts[Math.max(0, i - 1)], B = pts[Math.min(2, i + 1)], d = Math.hypot(B[0] - A[0], B[1] - A[1]) || 1; return [-(B[1] - A[1]) / d, (B[0] - A[0]) / d]; };
+ const W3 = [w0, w1, w2], L = [], R = [];
+ for (let i = 0; i < 3; i++) { const n = nx(i); L.push([pts[i][0] + n[0] * W3[i] / 2, pts[i][1] + n[1] * W3[i] / 2]); R.push([pts[i][0] - n[0] * W3[i] / 2, pts[i][1] - n[1] * W3[i] / 2]); }
+ const sp = new Path2D(); sp.moveTo(...L[0]); sp.quadraticCurveTo(...L[1], ...L[2]); sp.lineTo(...R[2]); sp.quadraticCurveTo(...R[1], ...R[0]); sp.closePath();
+ const sg = c.createLinearGradient(S[0] - h * 0.05, S[1], hd[0] + h * 0.05, hd[1]); sg.addColorStop(0, css(sleeveCol[0])); sg.addColorStop(1, css(sleeveCol[1]));
+ c.fillStyle = sg; c.fill(sp); c.strokeStyle = line; c.globalAlpha = 0.7; c.lineWidth = Math.max(1.4, h * 0.006); c.stroke(sp); c.globalAlpha = 1;
+ c.strokeStyle = css(sleeveCol[2], 0.4); c.lineWidth = h * 0.007; c.beginPath(); c.moveTo(el[0], el[1]); c.quadraticCurveTo(el[0] + h * 0.01, el[1] + h * 0.03, hd[0] - h * 0.005, hd[1] - h * 0.04); c.stroke();
+ c.fillStyle = css(skin); c.strokeStyle = line; c.globalAlpha = 0.8; c.lineWidth = Math.max(1.2, h * 0.005);
+ // 手:掌+拇指+并拢的三指,朝向沿前臂方向(托物时看得出是手,不是圆片)
+ c.save(); c.translate(hd[0], hd[1]); c.rotate(a);
+ c.beginPath(); c.ellipse(h * 0.012, 0, h * 0.028, h * 0.022, 0, 0, TAU); c.fill(); c.stroke();
+ c.beginPath(); c.ellipse(h * 0.04, h * 0.002, h * 0.026, h * 0.012, 0.08, 0, TAU); c.fill(); c.stroke();
+ c.beginPath(); c.ellipse(h * 0.012, -h * 0.022 * (k ? 1 : -1), h * 0.016, h * 0.008, 0.5 * (k ? 1 : -1), 0, TAU); c.fill(); c.stroke();
+ c.restore(); c.globalAlpha = 1;
+ };
+ arm(face > 0 ? shL : shR, hands[0], 0); arm(face > 0 ? shR : shL, hands[1], 1);
+
+ // --- 头 ---
+ if (halo) { c.fillStyle = 'rgba(214,170,70,.95)'; c.beginPath(); c.arc(head[0], head[1], hh * 1.55, 0, TAU); c.fill(); c.strokeStyle = 'rgba(120,80,30,.8)'; c.lineWidth = 2; c.stroke(); }
+ c.fillStyle = css(hairC); c.beginPath(); c.ellipse(head[0] - face * hw * 0.1, head[1] - hh * 0.12, hw * 1.12, hh * 1.06, 0, 0, TAU); c.fill();
+ const fg = c.createLinearGradient(head[0] - hw, head[1], head[0] + hw, head[1]); fg.addColorStop(0, css(mixc(skin, [255, 235, 205], 0.25))); fg.addColorStop(1, css(mixc(skin, [90, 50, 30], 0.35)));
+ c.fillStyle = fg; c.beginPath(); c.ellipse(head[0] + face * hw * 0.1, head[1] + hh * 0.1 + h * 0.008 * bow, hw * 0.92, hh * 0.92, 0, 0, TAU); c.fill();
+ c.strokeStyle = line; c.globalAlpha = 0.65; c.lineWidth = Math.max(1.2, h * 0.005); c.stroke(); c.globalAlpha = 1;
+ // 眼:杏仁形,眼珠偏向 gaze;鼻:一道暗线;口:短线
+ const ey = head[1] + hh * 0.12 + h * 0.01 * bow, ex = head[0] + face * hw * 0.22;
+ let gx = 0, gy = 0; if (gaze) { const dd = Math.hypot(gaze[0] - ex, gaze[1] - ey) || 1; gx = (gaze[0] - ex) / dd; gy = (gaze[1] - ey) / dd; }
+ [-1, 1].forEach(sd => {
+ const px = ex + sd * hw * 0.38 * (face > 0 ? 1 : 1) - 0, ew = hw * 0.26;
+ c.fillStyle = '#f4ead4'; c.beginPath(); c.ellipse(px, ey, ew, ew * 0.5, 0, 0, TAU); c.fill();
+ c.fillStyle = '#2a1c14'; c.beginPath(); c.arc(px + gx * ew * 0.45, ey + gy * ew * 0.25, ew * 0.42, 0, TAU); c.fill();
+ c.strokeStyle = line; c.lineWidth = Math.max(1, h * 0.0045); c.beginPath(); c.ellipse(px, ey, ew, ew * 0.5, 0, Math.PI * 1.05, Math.PI * 1.95); c.stroke();
+ });
+ c.strokeStyle = css(hairC, 0.85); c.lineWidth = Math.max(1.4, h * 0.006); [-1, 1].forEach(sd => { const px = ex + sd * hw * 0.38; c.beginPath(); c.moveTo(px - hw * 0.26, ey - hh * 0.2 + (sd * face > 0 ? 1 : 0) * 2); c.quadraticCurveTo(px, ey - hh * 0.34, px + hw * 0.26, ey - hh * 0.18); c.stroke(); });
+ c.fillStyle = css(mixc(skin, [90, 40, 25], 0.28), 0.5); c.beginPath(); c.ellipse(head[0] + face * hw * 0.5, head[1] + hh * 0.55, hw * 0.3, hh * 0.2, 0, 0, TAU); c.fill(); // 颧红/阴影
+ c.fillStyle = css(skin); c.beginPath(); c.ellipse(head[0] - face * hw * 0.82, head[1] + hh * 0.2, hw * 0.14, hh * 0.24, 0, 0, TAU); c.fill();
+ if (o.beard) { c.fillStyle = css(mixc(hairC, [190, 180, 165], 0.45), 0.96); c.beginPath(); c.moveTo(head[0] - hw * 0.8, head[1] + hh * 0.28); c.quadraticCurveTo(head[0] - hw * 0.7, head[1] + hh * 1.35, head[0], head[1] + hh * 1.55); c.quadraticCurveTo(head[0] + hw * 0.7, head[1] + hh * 1.35, head[0] + hw * 0.8, head[1] + hh * 0.28); c.quadraticCurveTo(head[0] + hw * 0.35, head[1] + hh * 0.62, head[0], head[1] + hh * 0.6); c.quadraticCurveTo(head[0] - hw * 0.35, head[1] + hh * 0.62, head[0] - hw * 0.8, head[1] + hh * 0.28); c.fill(); }
+ c.strokeStyle = css(mixc(skin, [60, 30, 20], 0.5), 0.8); c.lineWidth = Math.max(1, h * 0.0045);
+ c.beginPath(); c.moveTo(ex + face * hw * 0.04, ey + hh * 0.08); c.lineTo(ex + face * hw * 0.08, ey + hh * 0.42); c.lineTo(ex - face * hw * 0.05, ey + hh * 0.46); c.stroke();
+ c.beginPath(); c.moveTo(ex - hw * 0.14, ey + hh * 0.7); c.quadraticCurveTo(ex, ey + hh * 0.74, ex + hw * 0.14, ey + hh * 0.68); c.stroke();
+ c.restore();
+};
+})();
diff --git a/scripts/engine/lib/three.min.js b/scripts/engine/lib/three.min.js
new file mode 100644
index 0000000..0c2f4ba
--- /dev/null
+++ b/scripts/engine/lib/three.min.js
@@ -0,0 +1,7 @@
+console.warn('Scripts "build/three.js" and "build/three.min.js" are deprecated with r150+, and will be removed with r160. Please use ES Modules or alternatives: https://threejs.org/docs/index.html#manual/en/introduction/Installation'),
+/**
+ * @license
+ * Copyright 2010-2023 Three.js Authors
+ * SPDX-License-Identifier: MIT
+ */
+function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).THREE={})}(this,(function(t){"use strict";const e="160",n=1,i=2,r=3,s=0,a=1,o=100,l=204,c=205,h=0,u=1,d=2,p=0,m=1,f=2,g=3,_=4,v=5,x=6,y="attached",M="detached",S=300,b=301,T=302,E=303,w=304,A=306,R=1e3,C=1001,L=1002,P=1003,I=1004,U=1005,D=1006,N=1007,O=1008,F=1009,B=1012,z=1013,G=1014,H=1015,V=1016,k=1017,W=1018,X=1020,j=1023,q=1026,Y=1027,Z=1029,J=1031,K=1033,$=33776,Q=33777,tt=33778,et=33779,nt=35840,it=35841,rt=35842,st=35843,at=36196,ot=37492,lt=37496,ct=37808,ht=37809,ut=37810,dt=37811,pt=37812,mt=37813,ft=37814,gt=37815,_t=37816,vt=37817,xt=37818,yt=37819,Mt=37820,St=37821,bt=36492,Tt=36494,Et=36495,wt=36284,At=36285,Rt=36286,Ct=2300,Lt=2301,Pt=2302,It=2400,Ut=2401,Dt=2402,Nt=2500,Ot=2501,Ft=3e3,Bt=3001,zt="",Gt="srgb",Ht="srgb-linear",Vt="display-p3",kt="display-p3-linear",Wt="linear",Xt="srgb",jt="rec709",qt="p3",Yt=7680,Zt=35044,Jt="300 es",Kt=1035,$t=2e3,Qt=2001;class te{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}}const ee=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let ne=1234567;const ie=Math.PI/180,re=180/Math.PI;function se(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(ee[255&t]+ee[t>>8&255]+ee[t>>16&255]+ee[t>>24&255]+"-"+ee[255&e]+ee[e>>8&255]+"-"+ee[e>>16&15|64]+ee[e>>24&255]+"-"+ee[63&n|128]+ee[n>>8&255]+"-"+ee[n>>16&255]+ee[n>>24&255]+ee[255&i]+ee[i>>8&255]+ee[i>>16&255]+ee[i>>24&255]).toLowerCase()}function ae(t,e,n){return Math.max(e,Math.min(n,t))}function oe(t,e){return(t%e+e)%e}function le(t,e,n){return(1-n)*t+n*e}function ce(t){return 0==(t&t-1)&&0!==t}function he(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function ue(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function de(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const pe={DEG2RAD:ie,RAD2DEG:re,generateUUID:se,clamp:ae,euclideanModulo:oe,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:le,damp:function(t,e,n,i){return le(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(oe(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(ne=t);let e=ne+=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(t){return t*ie},radToDeg:function(t){return t*re},isPowerOfTwo:ce,ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:he,setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*m,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*m,o*c);break;case"ZYZ":t.set(l*m,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:de,denormalize:ue};class me{constructor(t=0,e=0){me.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ae(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fe{constructor(t,e,n,i,r,s,a,o,l){fe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l)}set(t,e,n,i,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],m=i[0],f=i[3],g=i[6],_=i[1],v=i[4],x=i[7],y=i[2],M=i[5],S=i[8];return r[0]=s*m+a*_+o*y,r[3]=s*f+a*v+o*M,r[6]=s*g+a*x+o*S,r[1]=l*m+c*_+h*y,r[4]=l*f+c*v+h*M,r[7]=l*g+c*x+h*S,r[2]=u*m+d*_+p*y,r[5]=u*f+d*v+p*M,r[8]=u*g+d*x+p*S,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=e*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=h*m,t[1]=(i*l-c*n)*m,t[2]=(a*n-i*s)*m,t[3]=u*m,t[4]=(c*e-i*o)*m,t[5]=(i*r-a*e)*m,t[6]=d*m,t[7]=(n*o-l*e)*m,t[8]=(s*e-n*r)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ge.makeScale(t,e)),this}rotate(t){return this.premultiply(ge.makeRotation(-t)),this}translate(t,e){return this.premultiply(ge.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const ge=new fe;function _e(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const ve={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function xe(t,e){return new ve[t](e)}function ye(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Me(){const t=ye("canvas");return t.style.display="block",t}const Se={};function be(t){t in Se||(Se[t]=!0,console.warn(t))}const Te=(new fe).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ee=(new fe).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),we={[Ht]:{transfer:Wt,primaries:jt,toReference:t=>t,fromReference:t=>t},[Gt]:{transfer:Xt,primaries:jt,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[kt]:{transfer:Wt,primaries:qt,toReference:t=>t.applyMatrix3(Ee),fromReference:t=>t.applyMatrix3(Te)},[Vt]:{transfer:Xt,primaries:qt,toReference:t=>t.convertSRGBToLinear().applyMatrix3(Ee),fromReference:t=>t.applyMatrix3(Te).convertLinearToSRGB()}},Ae=new Set([Ht,kt]),Re={enabled:!0,_workingColorSpace:Ht,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!Ae.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(!1===this.enabled||e===n||!e||!n)return t;const i=we[e].toReference;return(0,we[n].fromReference)(i(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return we[t].primaries},getTransfer:function(t){return t===zt?Wt:we[t].transfer}};function Ce(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Le(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let Pe;class Ie{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Pe&&(Pe=ye("canvas")),Pe.width=t.width,Pe.height=t.height;const n=Pe.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Pe}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=ye("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*Ce(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*Ce(e[t]/255)):e[t]=Ce(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Ue=0;class De{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ue++}),this.uuid=se(),this.data=t,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(Ne(i[e].image)):t.push(Ne(i[e]))}else t=Ne(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function Ne(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Ie.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Oe=0;class Fe extends te{constructor(t=Fe.DEFAULT_IMAGE,e=Fe.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=1009,l=Fe.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Oe++}),this.uuid=se(),this.name="",this.source=new De(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new me(0,0),this.repeat=new me(1,1),this.center=new me(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof c?this.colorSpace=c:(be("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=c===Bt?Gt:zt),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==S)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case R:t.x=t.x-Math.floor(t.x);break;case C:t.x=t.x<0?0:1;break;case L:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case R:t.y=t.y-Math.floor(t.y);break;case C:t.y=t.y<0?0:1;break;case L:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return be("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Gt?Bt:Ft}set encoding(t){be("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Bt?Gt:zt}}Fe.DEFAULT_IMAGE=null,Fe.DEFAULT_MAPPING=S,Fe.DEFAULT_ANISOTROPY=1;class Be{constructor(t=0,e=0,n=0,i=1){Be.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-u)<s&&Math.abs(h-m)<s&&Math.abs(p-f)<s){if(Math.abs(c+u)<a&&Math.abs(h+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,_=(g+1)/2,v=(c+u)/4,x=(h+m)/4,y=(p+f)/4;return t>o&&t>_?t<s?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=v/n,r=x/n):o>_?o<s?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=v/i,r=y/i):_<s?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(_),n=x/r,i=y/r),this.set(n,i,r,e),this}let _=Math.sqrt((f-p)*(f-p)+(h-m)*(h-m)+(u-c)*(u-c));return Math.abs(_)<.001&&(_=1),this.x=(f-p)/_,this.y=(h-m)/_,this.z=(u-c)/_,this.w=Math.acos((l+d+g-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ze extends te{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Be(0,0,t,e),this.scissorTest=!1,this.viewport=new Be(0,0,t,e);const i={width:t,height:e,depth:1};void 0!==n.encoding&&(be("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Bt?Gt:zt),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:D,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},n),this.texture=new Fe(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps,this.texture.internalFormat=n.internalFormat,this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}setSize(t,e,n=1){this.width===t&&this.height===e&&this.depth===n||(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new De(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ge extends ze{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class He extends Fe{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=P,this.minFilter=P,this.wrapR=C,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ve extends Fe{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=P,this.minFilter=P,this.wrapR=C,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ke{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,s,a){let o=n[i+0],l=n[i+1],c=n[i+2],h=n[i+3];const u=r[s+0],d=r[s+1],p=r[s+2],m=r[s+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=c,void(t[e+3]=h);if(1===a)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(h!==m||o!==u||l!==d||c!==p){let t=1-a;const e=o*u+l*d+c*p+h*m,n=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*t+u*r,l=l*t+d*r,c=c*t+p*r,h=h*t+m*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*h+o*d-l*u,t[e+1]=o*p+c*u+l*h-a*d,t[e+2]=l*p+c*d+a*u-o*h,t[e+3]=c*p-a*h-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=n+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>h){const t=2*Math.sqrt(1+n-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-n-h);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ae(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=Math.random(),e=Math.sqrt(1-t),n=Math.sqrt(t),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(i),n*Math.sin(r),n*Math.cos(r),e*Math.sin(i))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class We{constructor(t=0,e=0,n=0){We.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(je.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(je.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),c=2*(a*e-r*i),h=2*(r*n-s*e);return this.x=e+o*l+s*h-a*c,this.y=n+o*c+a*l-r*h,this.z=i+o*h+r*c-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Xe.copy(this).projectOnVector(t),this.sub(Xe)}reflect(t){return this.sub(Xe.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ae(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,n=Math.sqrt(1-t**2);return this.x=n*Math.cos(e),this.y=n*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Xe=new We,je=new ke;class qe{constructor(t=new We(1/0,1/0,1/0),e=new We(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Ze.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Ze.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Ze.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,Ze):Ze.fromBufferAttribute(i,e),Ze.applyMatrix4(t.matrixWorld),this.expandByPoint(Ze);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Je.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),Je.copy(n.boundingBox)),Je.applyMatrix4(t.matrixWorld),this.union(Je)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Ze),Ze.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(rn),sn.subVectors(this.max,rn),Ke.subVectors(t.a,rn),$e.subVectors(t.b,rn),Qe.subVectors(t.c,rn),tn.subVectors($e,Ke),en.subVectors(Qe,$e),nn.subVectors(Ke,Qe);let e=[0,-tn.z,tn.y,0,-en.z,en.y,0,-nn.z,nn.y,tn.z,0,-tn.x,en.z,0,-en.x,nn.z,0,-nn.x,-tn.y,tn.x,0,-en.y,en.x,0,-nn.y,nn.x,0];return!!ln(e,Ke,$e,Qe,sn)&&(e=[1,0,0,0,1,0,0,0,1],!!ln(e,Ke,$e,Qe,sn)&&(an.crossVectors(tn,en),e=[an.x,an.y,an.z],ln(e,Ke,$e,Qe,sn)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ze).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Ze).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Ye[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ye[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ye[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ye[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ye[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ye[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ye[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ye[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ye)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Ye=[new We,new We,new We,new We,new We,new We,new We,new We],Ze=new We,Je=new qe,Ke=new We,$e=new We,Qe=new We,tn=new We,en=new We,nn=new We,rn=new We,sn=new We,an=new We,on=new We;function ln(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){on.fromArray(t,s);const a=r.x*Math.abs(on.x)+r.y*Math.abs(on.y)+r.z*Math.abs(on.z),o=e.dot(on),l=n.dot(on),c=i.dot(on);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const cn=new qe,hn=new We,un=new We;class dn{constructor(t=new We,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):cn.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;hn.subVectors(t,this.center);const e=hn.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(hn,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(un.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(hn.copy(t.center).add(un)),this.expandByPoint(hn.copy(t.center).sub(un))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const pn=new We,mn=new We,fn=new We,gn=new We,_n=new We,vn=new We,xn=new We;class yn{constructor(t=new We,e=new We(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,pn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=pn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(pn.copy(this.origin).addScaledVector(this.direction,e),pn.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){mn.copy(t).add(e).multiplyScalar(.5),fn.copy(e).sub(t).normalize(),gn.copy(this.origin).sub(mn);const r=.5*t.distanceTo(e),s=-this.direction.dot(fn),a=gn.dot(this.direction),o=-gn.dot(fn),l=gn.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(mn).addScaledVector(fn,u),d}intersectSphere(t,e){pn.subVectors(t.center,this.origin);const n=pn.dot(this.direction),i=pn.dot(pn)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,i=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,i=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s<i||isNaN(i))&&(i=s),h>=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,pn)}intersectTriangle(t,e,n,i,r){_n.subVectors(e,t),vn.subVectors(n,t),xn.crossVectors(_n,vn);let s,a=this.direction.dot(xn);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}gn.subVectors(this.origin,t);const o=s*this.direction.dot(vn.crossVectors(gn,vn));if(o<0)return null;const l=s*this.direction.dot(_n.cross(gn));if(l<0)return null;if(o+l>a)return null;const c=-s*gn.dot(xn);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Mn{constructor(t,e,n,i,r,s,a,o,l,c,h,u,d,p,m,f){Mn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,m,f)}set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Mn).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/Sn.setFromMatrixColumn(t,0).length(),r=1/Sn.setFromMatrixColumn(t,1).length(),s=1/Sn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=a*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Tn,t,En)}lookAt(t,e,n){const i=this.elements;return Rn.subVectors(t,e),0===Rn.lengthSq()&&(Rn.z=1),Rn.normalize(),wn.crossVectors(n,Rn),0===wn.lengthSq()&&(1===Math.abs(n.z)?Rn.x+=1e-4:Rn.z+=1e-4,Rn.normalize(),wn.crossVectors(n,Rn)),wn.normalize(),An.crossVectors(Rn,wn),i[0]=wn.x,i[4]=An.x,i[8]=Rn.x,i[1]=wn.y,i[5]=An.y,i[9]=Rn.y,i[2]=wn.z,i[6]=An.z,i[10]=Rn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],m=n[6],f=n[10],g=n[14],_=n[3],v=n[7],x=n[11],y=n[15],M=i[0],S=i[4],b=i[8],T=i[12],E=i[1],w=i[5],A=i[9],R=i[13],C=i[2],L=i[6],P=i[10],I=i[14],U=i[3],D=i[7],N=i[11],O=i[15];return r[0]=s*M+a*E+o*C+l*U,r[4]=s*S+a*w+o*L+l*D,r[8]=s*b+a*A+o*P+l*N,r[12]=s*T+a*R+o*I+l*O,r[1]=c*M+h*E+u*C+d*U,r[5]=c*S+h*w+u*L+d*D,r[9]=c*b+h*A+u*P+d*N,r[13]=c*T+h*R+u*I+d*O,r[2]=p*M+m*E+f*C+g*U,r[6]=p*S+m*w+f*L+g*D,r[10]=p*b+m*A+f*P+g*N,r[14]=p*T+m*R+f*I+g*O,r[3]=_*M+v*E+x*C+y*U,r[7]=_*S+v*w+x*L+y*D,r[11]=_*b+v*A+x*P+y*N,r[15]=_*T+v*R+x*I+y*O,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+t[11]*(+e*l*h-e*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+t[15]*(-i*a*c-e*o*h+e*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],_=h*f*l-m*u*l+m*o*d-a*f*d-h*o*g+a*u*g,v=p*u*l-c*f*l-p*o*d+s*f*d+c*o*g-s*u*g,x=c*m*l-p*h*l+p*a*d-s*m*d-c*a*g+s*h*g,y=p*h*o-c*m*o-p*a*u+s*m*u+c*a*f-s*h*f,M=e*_+n*v+i*x+r*y;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/M;return t[0]=_*S,t[1]=(m*u*r-h*f*r-m*i*d+n*f*d+h*i*g-n*u*g)*S,t[2]=(a*f*r-m*o*r+m*i*l-n*f*l-a*i*g+n*o*g)*S,t[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*S,t[4]=v*S,t[5]=(c*f*r-p*u*r+p*i*d-e*f*d-c*i*g+e*u*g)*S,t[6]=(p*o*r-s*f*r-p*i*l+e*f*l+s*i*g-e*o*g)*S,t[7]=(s*u*r-c*o*r+c*i*l-e*u*l-s*i*d+e*o*d)*S,t[8]=x*S,t[9]=(p*h*r-c*m*r-p*n*d+e*m*d+c*n*g-e*h*g)*S,t[10]=(s*m*r-p*a*r+p*n*l-e*m*l-s*n*g+e*a*g)*S,t[11]=(c*a*r-s*h*r-c*n*l+e*h*l+s*n*d-e*a*d)*S,t[12]=y*S,t[13]=(c*m*i-p*h*i+p*n*u-e*m*u-c*n*f+e*h*f)*S,t[14]=(p*a*i-s*m*i-p*n*o+e*m*o+s*n*f-e*a*f)*S,t[15]=(s*h*i-c*a*i+c*n*o-e*h*o-s*n*u+e*a*u)*S,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,m=s*c,f=s*h,g=a*h,_=o*l,v=o*c,x=o*h,y=n.x,M=n.y,S=n.z;return i[0]=(1-(m+g))*y,i[1]=(d+x)*y,i[2]=(p-v)*y,i[3]=0,i[4]=(d-x)*M,i[5]=(1-(u+g))*M,i[6]=(f+_)*M,i[7]=0,i[8]=(p+v)*S,i[9]=(f-_)*S,i[10]=(1-(u+m))*S,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=Sn.set(i[0],i[1],i[2]).length();const s=Sn.set(i[4],i[5],i[6]).length(),a=Sn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],bn.copy(this);const o=1/r,l=1/s,c=1/a;return bn.elements[0]*=o,bn.elements[1]*=o,bn.elements[2]*=o,bn.elements[4]*=l,bn.elements[5]*=l,bn.elements[6]*=l,bn.elements[8]*=c,bn.elements[9]*=c,bn.elements[10]*=c,e.setFromRotationMatrix(bn),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=2e3){const o=this.elements,l=2*r/(e-t),c=2*r/(n-i),h=(e+t)/(e-t),u=(n+i)/(n-i);let d,p;if(a===$t)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Qt)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=2e3){const o=this.elements,l=1/(e-t),c=1/(n-i),h=1/(s-r),u=(e+t)*l,d=(n+i)*c;let p,m;if(a===$t)p=(s+r)*h,m=-2*h;else{if(a!==Qt)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,m=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Sn=new We,bn=new Mn,Tn=new We(0,0,0),En=new We(1,1,1),wn=new We,An=new We,Rn=new We,Cn=new Mn,Ln=new ke;class Pn{constructor(t=0,e=0,n=0,i=Pn.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(ae(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ae(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(ae(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ae(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(ae(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-ae(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Cn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Cn,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ln.setFromEuler(this),this.setFromQuaternion(Ln,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Pn.DEFAULT_ORDER="XYZ";class In{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}isEnabled(t){return 0!=(this.mask&(1<<t|0))}}let Un=0;const Dn=new We,Nn=new ke,On=new Mn,Fn=new We,Bn=new We,zn=new We,Gn=new ke,Hn=new We(1,0,0),Vn=new We(0,1,0),kn=new We(0,0,1),Wn={type:"added"},Xn={type:"removed"};class jn extends te{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Un++}),this.uuid=se(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=jn.DEFAULT_UP.clone();const t=new We,e=new Pn,n=new ke,i=new We(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Mn},normalMatrix:{value:new fe}}),this.matrix=new Mn,this.matrixWorld=new Mn,this.matrixAutoUpdate=jn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=jn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new In,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Nn.setFromAxisAngle(t,e),this.quaternion.multiply(Nn),this}rotateOnWorldAxis(t,e){return Nn.setFromAxisAngle(t,e),this.quaternion.premultiply(Nn),this}rotateX(t){return this.rotateOnAxis(Hn,t)}rotateY(t){return this.rotateOnAxis(Vn,t)}rotateZ(t){return this.rotateOnAxis(kn,t)}translateOnAxis(t,e){return Dn.copy(t).applyQuaternion(this.quaternion),this.position.add(Dn.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Hn,t)}translateY(t){return this.translateOnAxis(Vn,t)}translateZ(t){return this.translateOnAxis(kn,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(On.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Fn.copy(t):Fn.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Bn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?On.lookAt(Bn,Fn,this.up):On.lookAt(Fn,Bn,this.up),this.quaternion.setFromRotationMatrix(On),i&&(On.extractRotation(i.matrixWorld),Nn.setFromRotationMatrix(On),this.quaternion.premultiply(Nn.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Wn)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Xn)),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),On.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),On.multiply(t.parent.matrixWorld)),t.applyMatrix4(On),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Bn,t,zn),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Bn,Gn,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){const i=e[n];!0!==i.matrixWorldAutoUpdate&&!0!==t||i.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){const n=t[e];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=s(t.geometries),i=s(t.materials),r=s(t.textures),a=s(t.images),o=s(t.shapes),l=s(t.skeletons),c=s(t.animations),h=s(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}jn.DEFAULT_UP=new We(0,1,0),jn.DEFAULT_MATRIX_AUTO_UPDATE=!0,jn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const qn=new We,Yn=new We,Zn=new We,Jn=new We,Kn=new We,$n=new We,Qn=new We,ti=new We,ei=new We,ni=new We;let ii=!1;class ri{constructor(t=new We,e=new We,n=new We){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),qn.subVectors(t,e),i.cross(qn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){qn.subVectors(i,e),Yn.subVectors(n,e),Zn.subVectors(t,e);const s=qn.dot(qn),a=qn.dot(Yn),o=qn.dot(Zn),l=Yn.dot(Yn),c=Yn.dot(Zn),h=s*l-a*a;if(0===h)return r.set(0,0,0),null;const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Jn)&&(Jn.x>=0&&Jn.y>=0&&Jn.x+Jn.y<=1)}static getUV(t,e,n,i,r,s,a,o){return!1===ii&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),ii=!0),this.getInterpolation(t,e,n,i,r,s,a,o)}static getInterpolation(t,e,n,i,r,s,a,o){return null===this.getBarycoord(t,e,n,i,Jn)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Jn.x),o.addScaledVector(s,Jn.y),o.addScaledVector(a,Jn.z),o)}static isFrontFacing(t,e,n,i){return qn.subVectors(n,e),Yn.subVectors(t,e),qn.cross(Yn).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return qn.subVectors(this.c,this.b),Yn.subVectors(this.a,this.b),.5*qn.cross(Yn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return ri.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return ri.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,i,r){return!1===ii&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),ii=!0),ri.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}getInterpolation(t,e,n,i,r){return ri.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return ri.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return ri.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,a;Kn.subVectors(i,n),$n.subVectors(r,n),ti.subVectors(t,n);const o=Kn.dot(ti),l=$n.dot(ti);if(o<=0&&l<=0)return e.copy(n);ei.subVectors(t,i);const c=Kn.dot(ei),h=$n.dot(ei);if(c>=0&&h<=c)return e.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(n).addScaledVector(Kn,s);ni.subVectors(t,r);const d=Kn.dot(ni),p=$n.dot(ni);if(p>=0&&d<=p)return e.copy(r);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector($n,a);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return Qn.subVectors(r,i),a=(h-c)/(h-c+(d-p)),e.copy(i).addScaledVector(Qn,a);const g=1/(f+m+u);return s=m*g,a=u*g,e.copy(n).addScaledVector(Kn,s).addScaledVector($n,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const si={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},ai={h:0,s:0,l:0},oi={h:0,s:0,l:0};function li(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class ci{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Gt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,Re.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Re.workingColorSpace){return this.r=t,this.g=e,this.b=n,Re.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Re.workingColorSpace){if(t=oe(t,1),e=ae(e,0,1),n=ae(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=li(r,i,t+1/3),this.g=li(r,i,t),this.b=li(r,i,t-1/3)}return Re.toWorkingColorSpace(this,i),this}setStyle(t,e=Gt){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Gt){const n=si[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ce(t.r),this.g=Ce(t.g),this.b=Ce(t.b),this}copyLinearToSRGB(t){return this.r=Le(t.r),this.g=Le(t.g),this.b=Le(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Gt){return Re.fromWorkingColorSpace(hi.copy(this),t),65536*Math.round(ae(255*hi.r,0,255))+256*Math.round(ae(255*hi.g,0,255))+Math.round(ae(255*hi.b,0,255))}getHexString(t=Gt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Re.workingColorSpace){Re.fromWorkingColorSpace(hi.copy(this),e);const n=hi.r,i=hi.g,r=hi.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=c<=.5?t/(s+a):t/(2-s-a),s){case n:o=(i-r)/t+(i<r?6:0);break;case i:o=(r-n)/t+2;break;case r:o=(n-i)/t+4}o/=6}return t.h=o,t.s=l,t.l=c,t}getRGB(t,e=Re.workingColorSpace){return Re.fromWorkingColorSpace(hi.copy(this),e),t.r=hi.r,t.g=hi.g,t.b=hi.b,t}getStyle(t=Gt){Re.fromWorkingColorSpace(hi.copy(this),t);const e=hi.r,n=hi.g,i=hi.b;return t!==Gt?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(ai),this.setHSL(ai.h+t,ai.s+e,ai.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(ai),t.getHSL(oi);const n=le(ai.h,oi.h,e),i=le(ai.s,oi.s,e),r=le(ai.l,oi.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const hi=new ci;ci.NAMES=si;let ui=0;class di extends te{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ui++}),this.uuid=se(),this.name="",this.type="Material",this.blending=1,this.side=s,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=l,this.blendDst=c,this.blendEquation=o,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ci(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yt,this.stencilZFail=Yt,this.stencilZPass=Yt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),this.side!==s&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==l&&(n.blendSrc=this.blendSrc),this.blendDst!==c&&(n.blendDst=this.blendDst),this.blendEquation!==o&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yt&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Yt&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Yt&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}class pi extends di{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ci(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.combine=h,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const mi=fi();function fi(){const t=new ArrayBuffer(4),e=new Float32Array(t),n=new Uint32Array(t),i=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,r[t]=24,r[256|t]=24):(i[t]=31744,i[256|t]=64512,r[t]=13,r[256|t]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,n=0;for(;0==(8388608&e);)e<<=1,n-=8388608;e&=-8388609,n+=947912704,s[t]=e|n}for(let t=1024;t<2048;++t)s[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function gi(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=ae(t,-65504,65504),mi.floatView[0]=t;const e=mi.uint32View[0],n=e>>23&511;return mi.baseTable[n]+((8388607&e)>>mi.shiftTable[n])}function _i(t){const e=t>>10;return mi.uint32View[0]=mi.mantissaTable[mi.offsetTable[e]+(1023&t)]+mi.exponentTable[e],mi.floatView[0]}const vi={toHalfFloat:gi,fromHalfFloat:_i},xi=new We,yi=new me;class Mi{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=Zt,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=H,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)yi.fromBufferAttribute(this,e),yi.applyMatrix3(t),this.setXY(e,yi.x,yi.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)xi.fromBufferAttribute(this,e),xi.applyMatrix3(t),this.setXYZ(e,xi.x,xi.y,xi.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)xi.fromBufferAttribute(this,e),xi.applyMatrix4(t),this.setXYZ(e,xi.x,xi.y,xi.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)xi.fromBufferAttribute(this,e),xi.applyNormalMatrix(t),this.setXYZ(e,xi.x,xi.y,xi.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)xi.fromBufferAttribute(this,e),xi.transformDirection(t),this.setXYZ(e,xi.x,xi.y,xi.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=ue(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=de(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ue(e,this.array)),e}setX(t,e){return this.normalized&&(e=de(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ue(e,this.array)),e}setY(t,e){return this.normalized&&(e=de(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=ue(e,this.array)),e}setZ(t,e){return this.normalized&&(e=de(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=ue(e,this.array)),e}setW(t,e){return this.normalized&&(e=de(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=de(e,this.array),n=de(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=de(e,this.array),n=de(n,this.array),i=de(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=de(e,this.array),n=de(n,this.array),i=de(i,this.array),r=de(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Zt&&(t.usage=this.usage),t}}class Si extends Mi{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class bi extends Mi{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Ti extends Mi{constructor(t,e,n){super(new Float32Array(t),e,n)}}let Ei=0;const wi=new Mn,Ai=new jn,Ri=new We,Ci=new qe,Li=new qe,Pi=new We;class Ii extends te{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ei++}),this.uuid=se(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(_e(t)?bi:Si)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new fe).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return wi.makeRotationFromQuaternion(t),this.applyMatrix4(wi),this}rotateX(t){return wi.makeRotationX(t),this.applyMatrix4(wi),this}rotateY(t){return wi.makeRotationY(t),this.applyMatrix4(wi),this}rotateZ(t){return wi.makeRotationZ(t),this.applyMatrix4(wi),this}translate(t,e,n){return wi.makeTranslation(t,e,n),this.applyMatrix4(wi),this}scale(t,e,n){return wi.makeScale(t,e,n),this.applyMatrix4(wi),this}lookAt(t){return Ai.lookAt(t),Ai.updateMatrix(),this.applyMatrix4(Ai.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ri).negate(),this.translate(Ri.x,Ri.y,Ri.z),this}setFromPoints(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new Ti(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new qe);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new We(-1/0,-1/0,-1/0),new We(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ci.setFromBufferAttribute(n),this.morphTargetsRelative?(Pi.addVectors(this.boundingBox.min,Ci.min),this.boundingBox.expandByPoint(Pi),Pi.addVectors(this.boundingBox.max,Ci.max),this.boundingBox.expandByPoint(Pi)):(this.boundingBox.expandByPoint(Ci.min),this.boundingBox.expandByPoint(Ci.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new dn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new We,1/0);if(t){const n=this.boundingSphere.center;if(Ci.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Li.setFromBufferAttribute(n),this.morphTargetsRelative?(Pi.addVectors(Ci.min,Li.min),Ci.expandByPoint(Pi),Pi.addVectors(Ci.max,Li.max),Ci.expandByPoint(Pi)):(Ci.expandByPoint(Li.min),Ci.expandByPoint(Li.max))}Ci.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)Pi.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(Pi));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],a=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)Pi.fromBufferAttribute(s,e),a&&(Ri.fromBufferAttribute(t,e),Pi.add(Ri)),i=Math.max(i,n.distanceToSquared(Pi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=t.array,i=e.position.array,r=e.normal.array,s=e.uv.array,a=i.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Mi(new Float32Array(4*a),4));const o=this.getAttribute("tangent").array,l=[],c=[];for(let t=0;t<a;t++)l[t]=new We,c[t]=new We;const h=new We,u=new We,d=new We,p=new me,m=new me,f=new me,g=new We,_=new We;function v(t,e,n){h.fromArray(i,3*t),u.fromArray(i,3*e),d.fromArray(i,3*n),p.fromArray(s,2*t),m.fromArray(s,2*e),f.fromArray(s,2*n),u.sub(h),d.sub(h),m.sub(p),f.sub(p);const r=1/(m.x*f.y-f.x*m.y);isFinite(r)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(r),_.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(r),l[t].add(g),l[e].add(g),l[n].add(g),c[t].add(_),c[e].add(_),c[n].add(_))}let x=this.groups;0===x.length&&(x=[{start:0,count:n.length}]);for(let t=0,e=x.length;t<e;++t){const e=x[t],i=e.start;for(let t=i,r=i+e.count;t<r;t+=3)v(n[t+0],n[t+1],n[t+2])}const y=new We,M=new We,S=new We,b=new We;function T(t){S.fromArray(r,3*t),b.copy(S);const e=l[t];y.copy(e),y.sub(S.multiplyScalar(S.dot(e))).normalize(),M.crossVectors(b,e);const n=M.dot(c[t])<0?-1:1;o[4*t]=y.x,o[4*t+1]=y.y,o[4*t+2]=y.z,o[4*t+3]=n}for(let t=0,e=x.length;t<e;++t){const e=x[t],i=e.start;for(let t=i,r=i+e.count;t<r;t+=3)T(n[t+0]),T(n[t+1]),T(n[t+2])}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new Mi(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new We,r=new We,s=new We,a=new We,o=new We,l=new We,c=new We,h=new We;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),m=t.getX(u+2);i.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),c.subVectors(s,r),h.subVectors(i,r),c.cross(h),a.fromBufferAttribute(n,d),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),a.add(c),o.add(c),l.add(c),n.setXYZ(d,a.x,a.y,a.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let t=0,a=e.count;t<a;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),c.subVectors(s,r),h.subVectors(i,r),c.cross(h),n.setXYZ(t+0,c.x,c.y,c.z),n.setXYZ(t+1,c.x,c.y,c.z),n.setXYZ(t+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Pi.fromBufferAttribute(t,e),Pi.normalize(),t.setXYZ(e,Pi.x,Pi.y,Pi.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,s=new n.constructor(e.length*i);let a=0,o=0;for(let r=0,l=e.length;r<l;r++){a=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)s[o++]=n[a++]}return new Mi(s,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ii,n=this.index.array,i=this.attributes;for(const r in i){const s=t(i[r],n);e.setAttribute(r,s)}const r=this.morphAttributes;for(const i in r){const s=[],a=r[i];for(let e=0,i=a.length;e<i;e++){const i=t(a[e],n);s.push(i)}e.morphAttributes[i]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,n=s.length;t<n;t++){const n=s[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];s.push(i.toJSON(t.data))}s.length>0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ui=new Mn,Di=new yn,Ni=new dn,Oi=new We,Fi=new We,Bi=new We,zi=new We,Gi=new We,Hi=new We,Vi=new me,ki=new me,Wi=new me,Xi=new We,ji=new We,qi=new We,Yi=new We,Zi=new We;class Ji extends jn{constructor(t=new Ii,e=new pi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(r&&a){Hi.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=a[n],o=r[n];0!==i&&(Gi.fromBufferAttribute(o,t),s?Hi.addScaledVector(Gi,i):Hi.addScaledVector(Gi.sub(e),i))}e.add(Hi)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),Ni.copy(n.boundingSphere),Ni.applyMatrix4(r),Di.copy(t.ray).recast(t.near),!1===Ni.containsPoint(Di.origin)){if(null===Di.intersectSphere(Ni,Oi))return;if(Di.origin.distanceToSquared(Oi)>(t.far-t.near)**2)return}Ui.copy(r).invert(),Di.copy(t.ray).applyMatrix4(Ui),null!==n.boundingBox&&!1===Di.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,Di)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;r<o;r++){const o=u[r],p=s[o.materialIndex];for(let r=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<s;r+=3){i=Ki(this,p,t,n,l,c,h,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){i=Ki(this,s,t,n,l,c,h,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==o)if(Array.isArray(s))for(let r=0,a=u.length;r<a;r++){const a=u[r],p=s[a.materialIndex];for(let r=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<s;r+=3){i=Ki(this,p,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){i=Ki(this,s,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function Ki(t,e,n,i,r,o,l,c,h,u){t.getVertexPosition(c,Fi),t.getVertexPosition(h,Bi),t.getVertexPosition(u,zi);const d=function(t,e,n,i,r,o,l,c){let h;if(h=e.side===a?i.intersectTriangle(l,o,r,!0,c):i.intersectTriangle(r,o,l,e.side===s,c),null===h)return null;Zi.copy(c),Zi.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Zi);return u<n.near||u>n.far?null:{distance:u,point:Zi.clone(),object:t}}(t,e,n,i,Fi,Bi,zi,Yi);if(d){r&&(Vi.fromBufferAttribute(r,c),ki.fromBufferAttribute(r,h),Wi.fromBufferAttribute(r,u),d.uv=ri.getInterpolation(Yi,Fi,Bi,zi,Vi,ki,Wi,new me)),o&&(Vi.fromBufferAttribute(o,c),ki.fromBufferAttribute(o,h),Wi.fromBufferAttribute(o,u),d.uv1=ri.getInterpolation(Yi,Fi,Bi,zi,Vi,ki,Wi,new me),d.uv2=d.uv1),l&&(Xi.fromBufferAttribute(l,c),ji.fromBufferAttribute(l,h),qi.fromBufferAttribute(l,u),d.normal=ri.getInterpolation(Yi,Fi,Bi,zi,Xi,ji,qi,new We),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));const t={a:c,b:h,c:u,normal:new We,materialIndex:0};ri.getNormal(Fi,Bi,zi,t.normal),d.face=t}return d}class $i extends Ii{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,n,i,r,s,p,m,f,g,_){const v=s/f,x=p/g,y=s/2,M=p/2,S=m/2,b=f+1,T=g+1;let E=0,w=0;const A=new We;for(let s=0;s<T;s++){const a=s*x-M;for(let o=0;o<b;o++){const u=o*v-y;A[t]=u*i,A[e]=a*r,A[n]=S,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=m>0?1:-1,c.push(A.x,A.y,A.z),h.push(o/f),h.push(1-s/g),E+=1}}for(let t=0;t<g;t++)for(let e=0;e<f;e++){const n=u+e+b*t,i=u+e+b*(t+1),r=u+(e+1)+b*(t+1),s=u+(e+1)+b*t;o.push(n,i,s),o.push(i,r,s),w+=6}a.addGroup(d,w,_),d+=w,u+=E}p("z","y","x",-1,-1,n,e,t,s,r,0),p("z","y","x",1,-1,n,e,-t,s,r,1),p("x","z","y",1,1,t,n,e,i,s,2),p("x","z","y",1,-1,t,n,-e,i,s,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new Ti(l,3)),this.setAttribute("normal",new Ti(c,3)),this.setAttribute("uv",new Ti(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $i(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Qi(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function tr(t){const e={};for(let n=0;n<t.length;n++){const i=Qi(t[n]);for(const t in i)e[t]=i[t]}return e}function er(t){return null===t.getRenderTarget()?t.outputColorSpace:Re.workingColorSpace}const nr={clone:Qi,merge:tr};class ir extends di{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Qi(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class rr extends jn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Mn,this.projectionMatrix=new Mn,this.projectionMatrixInverse=new Mn,this.coordinateSystem=$t}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class sr extends rr{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*re*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*ie*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*re*Math.atan(Math.tan(.5*ie*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*ie*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const ar=-90;class or extends jn{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new sr(ar,1,t,e);i.layers=this.layers,this.add(i);const r=new sr(ar,1,t,e);r.layers=this.layers,this.add(r);const s=new sr(ar,1,t,e);s.layers=this.layers,this.add(s);const a=new sr(ar,1,t,e);a.layers=this.layers,this.add(a);const o=new sr(ar,1,t,e);o.layers=this.layers,this.add(o);const l=new sr(ar,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===$t)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Qt)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,c]=this.children,h=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,s),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=m,t.setRenderTarget(n,5,i),t.render(e,c),t.setRenderTarget(h,u,d),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class lr extends Fe{constructor(t,e,n,i,r,s,a,o,l,c){super(t=void 0!==t?t:[],e=void 0!==e?e:b,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class cr extends Ge{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];void 0!==e.encoding&&(be("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===Bt?Gt:zt),this.texture=new lr(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:D}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new $i(5,5,5),r=new ir({name:"CubemapFromEquirect",uniforms:Qi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:a,blending:0});r.uniforms.tEquirect.value=e;const s=new Ji(i,r),o=e.minFilter;e.minFilter===O&&(e.minFilter=D);return new or(1,10,this).update(t,s),e.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}const hr=new We,ur=new We,dr=new fe;class pr{constructor(t=new We(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=hr.subVectors(n,e).cross(ur.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(hr),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||dr.getNormalMatrix(t),i=this.coplanarPoint(hr).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const mr=new dn,fr=new We;class gr{constructor(t=new pr,e=new pr,n=new pr,i=new pr,r=new pr,s=new pr){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2e3){const n=this.planes,i=t.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],m=i[10],f=i[11],g=i[12],_=i[13],v=i[14],x=i[15];if(n[0].setComponents(o-r,u-l,f-d,x-g).normalize(),n[1].setComponents(o+r,u+l,f+d,x+g).normalize(),n[2].setComponents(o+s,u+c,f+p,x+_).normalize(),n[3].setComponents(o-s,u-c,f-p,x-_).normalize(),n[4].setComponents(o-a,u-h,f-m,x-v).normalize(),e===$t)n[5].setComponents(o+a,u+h,f+m,x+v).normalize();else{if(e!==Qt)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(a,h,m,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),mr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),mr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(mr)}intersectsSprite(t){return mr.center.set(0,0,0),mr.radius=.7071067811865476,mr.applyMatrix4(t.matrixWorld),this.intersectsSphere(mr)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(fr.x=i.normal.x>0?t.max.x:t.min.x,fr.y=i.normal.y>0?t.max.y:t.min.y,fr.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(fr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function _r(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function vr(t,e){const n=e.isWebGL2,i=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),i.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const n=i.get(e);n&&(t.deleteBuffer(n.buffer),i.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=i.get(e);return void((!t||t.version<e.version)&&i.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const s=i.get(e);if(void 0===s)i.set(e,function(e,i){const r=e.array,s=e.usage,a=r.byteLength,o=t.createBuffer();let l;if(t.bindBuffer(i,o),t.bufferData(i,r,s),e.onUploadCallback(),r instanceof Float32Array)l=t.FLOAT;else if(r instanceof Uint16Array)if(e.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");l=t.HALF_FLOAT}else l=t.UNSIGNED_SHORT;else if(r instanceof Int16Array)l=t.SHORT;else if(r instanceof Uint32Array)l=t.UNSIGNED_INT;else if(r instanceof Int32Array)l=t.INT;else if(r instanceof Int8Array)l=t.BYTE;else if(r instanceof Uint8Array)l=t.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);l=t.UNSIGNED_BYTE}return{buffer:o,type:l,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version,size:a}}(e,r));else if(s.version<e.version){if(s.size!==e.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,i,r){const s=i.array,a=i._updateRange,o=i.updateRanges;if(t.bindBuffer(r,e),-1===a.count&&0===o.length&&t.bufferSubData(r,0,s),0!==o.length){for(let e=0,i=o.length;e<i;e++){const i=o[e];n?t.bufferSubData(r,i.start*s.BYTES_PER_ELEMENT,s,i.start,i.count):t.bufferSubData(r,i.start*s.BYTES_PER_ELEMENT,s.subarray(i.start,i.start+i.count))}i.clearUpdateRanges()}-1!==a.count&&(n?t.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s,a.offset,a.count):t.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s.subarray(a.offset,a.offset+a.count)),a.count=-1),i.onUploadCallback()}(s.buffer,e,r),s.version=e.version}}}}class xr extends Ii{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,s=e/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,h=t/a,u=e/o,d=[],p=[],m=[],f=[];for(let t=0;t<c;t++){const e=t*u-s;for(let n=0;n<l;n++){const i=n*h-r;p.push(i,-e,0),m.push(0,0,1),f.push(n/a),f.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<a;e++){const n=e+l*t,i=e+l*(t+1),r=e+1+l*(t+1),s=e+1+l*t;d.push(n,i,s),d.push(i,r,s)}this.setIndex(d),this.setAttribute("position",new Ti(p,3)),this.setAttribute("normal",new Ti(m,3)),this.setAttribute("uv",new Ti(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new xr(t.width,t.height,t.widthSegments,t.heightSegments)}}const yr={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid 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 ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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 ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\treturn color;\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Mr={common:{diffuse:{value:new ci(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fe},alphaMap:{value:null},alphaMapTransform:{value:new fe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fe}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fe},normalScale:{value:new me(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ci(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ci(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fe},alphaTest:{value:0},uvTransform:{value:new fe}},sprite:{diffuse:{value:new ci(16777215)},opacity:{value:1},center:{value:new me(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fe},alphaMap:{value:null},alphaMapTransform:{value:new fe},alphaTest:{value:0}}},Sr={basic:{uniforms:tr([Mr.common,Mr.specularmap,Mr.envmap,Mr.aomap,Mr.lightmap,Mr.fog]),vertexShader:yr.meshbasic_vert,fragmentShader:yr.meshbasic_frag},lambert:{uniforms:tr([Mr.common,Mr.specularmap,Mr.envmap,Mr.aomap,Mr.lightmap,Mr.emissivemap,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.fog,Mr.lights,{emissive:{value:new ci(0)}}]),vertexShader:yr.meshlambert_vert,fragmentShader:yr.meshlambert_frag},phong:{uniforms:tr([Mr.common,Mr.specularmap,Mr.envmap,Mr.aomap,Mr.lightmap,Mr.emissivemap,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.fog,Mr.lights,{emissive:{value:new ci(0)},specular:{value:new ci(1118481)},shininess:{value:30}}]),vertexShader:yr.meshphong_vert,fragmentShader:yr.meshphong_frag},standard:{uniforms:tr([Mr.common,Mr.envmap,Mr.aomap,Mr.lightmap,Mr.emissivemap,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.roughnessmap,Mr.metalnessmap,Mr.fog,Mr.lights,{emissive:{value:new ci(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yr.meshphysical_vert,fragmentShader:yr.meshphysical_frag},toon:{uniforms:tr([Mr.common,Mr.aomap,Mr.lightmap,Mr.emissivemap,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.gradientmap,Mr.fog,Mr.lights,{emissive:{value:new ci(0)}}]),vertexShader:yr.meshtoon_vert,fragmentShader:yr.meshtoon_frag},matcap:{uniforms:tr([Mr.common,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.fog,{matcap:{value:null}}]),vertexShader:yr.meshmatcap_vert,fragmentShader:yr.meshmatcap_frag},points:{uniforms:tr([Mr.points,Mr.fog]),vertexShader:yr.points_vert,fragmentShader:yr.points_frag},dashed:{uniforms:tr([Mr.common,Mr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yr.linedashed_vert,fragmentShader:yr.linedashed_frag},depth:{uniforms:tr([Mr.common,Mr.displacementmap]),vertexShader:yr.depth_vert,fragmentShader:yr.depth_frag},normal:{uniforms:tr([Mr.common,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,{opacity:{value:1}}]),vertexShader:yr.meshnormal_vert,fragmentShader:yr.meshnormal_frag},sprite:{uniforms:tr([Mr.sprite,Mr.fog]),vertexShader:yr.sprite_vert,fragmentShader:yr.sprite_frag},background:{uniforms:{uvTransform:{value:new fe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:yr.background_vert,fragmentShader:yr.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:yr.backgroundCube_vert,fragmentShader:yr.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yr.cube_vert,fragmentShader:yr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yr.equirect_vert,fragmentShader:yr.equirect_frag},distanceRGBA:{uniforms:tr([Mr.common,Mr.displacementmap,{referencePosition:{value:new We},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yr.distanceRGBA_vert,fragmentShader:yr.distanceRGBA_frag},shadow:{uniforms:tr([Mr.lights,Mr.fog,{color:{value:new ci(0)},opacity:{value:1}}]),vertexShader:yr.shadow_vert,fragmentShader:yr.shadow_frag}};Sr.physical={uniforms:tr([Sr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fe},clearcoatNormalScale:{value:new me(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fe},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fe},sheen:{value:0},sheenColor:{value:new ci(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fe},transmissionSamplerSize:{value:new me},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fe},attenuationDistance:{value:0},attenuationColor:{value:new ci(0)},specularColor:{value:new ci(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fe},anisotropyVector:{value:new me},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fe}}]),vertexShader:yr.meshphysical_vert,fragmentShader:yr.meshphysical_frag};const br={r:0,b:0,g:0};function Tr(t,e,n,i,r,o,l){const c=new ci(0);let h,u,d=!0===o?0:1,p=null,m=0,f=null;function g(e,n){e.getRGB(br,er(t)),i.buffers.color.setClear(br.r,br.g,br.b,n,l)}return{getClearColor:function(){return c},setClearColor:function(t,e=1){c.set(t),d=e,g(c,d)},getClearAlpha:function(){return d},setClearAlpha:function(t){d=t,g(c,d)},render:function(o,_){let v=!1,x=!0===_.isScene?_.background:null;if(x&&x.isTexture){x=(_.backgroundBlurriness>0?n:e).get(x)}null===x?g(c,d):x&&x.isColor&&(g(x,1),v=!0);const y=t.xr.getEnvironmentBlendMode();"additive"===y?i.buffers.color.setClear(0,0,0,1,l):"alpha-blend"===y&&i.buffers.color.setClear(0,0,0,0,l),(t.autoClear||v)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),x&&(x.isCubeTexture||x.mapping===A)?(void 0===u&&(u=new Ji(new $i(1,1,1),new ir({name:"BackgroundCubeMaterial",uniforms:Qi(Sr.backgroundCube.uniforms),vertexShader:Sr.backgroundCube.vertexShader,fragmentShader:Sr.backgroundCube.fragmentShader,side:a,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),u.material.uniforms.envMap.value=x,u.material.uniforms.flipEnvMap.value=x.isCubeTexture&&!1===x.isRenderTargetTexture?-1:1,u.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,u.material.toneMapped=Re.getTransfer(x.colorSpace)!==Xt,p===x&&m===x.version&&f===t.toneMapping||(u.material.needsUpdate=!0,p=x,m=x.version,f=t.toneMapping),u.layers.enableAll(),o.unshift(u,u.geometry,u.material,0,0,null)):x&&x.isTexture&&(void 0===h&&(h=new Ji(new xr(2,2),new ir({name:"BackgroundMaterial",uniforms:Qi(Sr.background.uniforms),vertexShader:Sr.background.vertexShader,fragmentShader:Sr.background.fragmentShader,side:s,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=x,h.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,h.material.toneMapped=Re.getTransfer(x.colorSpace)!==Xt,!0===x.matrixAutoUpdate&&x.updateMatrix(),h.material.uniforms.uvTransform.value.copy(x.matrix),p===x&&m===x.version&&f===t.toneMapping||(h.material.needsUpdate=!0,p=x,m=x.version,f=t.toneMapping),h.layers.enableAll(),o.unshift(h,h.geometry,h.material,0,0,null))}}}function Er(t,e,n,i){const r=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),a=i.isWebGL2||null!==s,o={},l=p(null);let c=l,h=!1;function u(e){return i.isWebGL2?t.bindVertexArray(e):s.bindVertexArrayOES(e)}function d(e){return i.isWebGL2?t.deleteVertexArray(e):s.deleteVertexArrayOES(e)}function p(t){const e=[],n=[],i=[];for(let t=0;t<r;t++)e[t]=0,n[t]=0,i[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:i,object:t,attributes:{},index:null}}function m(){const t=c.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function f(t){g(t,0)}function g(n,r){const s=c.newAttributes,a=c.enabledAttributes,o=c.attributeDivisors;if(s[n]=1,0===a[n]&&(t.enableVertexAttribArray(n),a[n]=1),o[n]!==r){(i.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,r),o[n]=r}}function _(){const e=c.newAttributes,n=c.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function v(e,n,i,r,s,a,o){!0===o?t.vertexAttribIPointer(e,n,i,s,a):t.vertexAttribPointer(e,n,i,r,s,a)}function x(){y(),h=!0,c!==l&&(c=l,u(c.object))}function y(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,d,x,y){let M=!1;if(a){const e=function(e,n,r){const a=!0===r.wireframe;let l=o[e.id];void 0===l&&(l={},o[e.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let h=c[a];void 0===h&&(h=p(i.isWebGL2?t.createVertexArray():s.createVertexArrayOES()),c[a]=h);return h}(x,d,l);c!==e&&(c=e,u(c.object)),M=function(t,e,n,i){const r=c.attributes,s=e.attributes;let a=0;const o=n.getAttributes();for(const e in o){if(o[e].location>=0){const n=r[e];let i=s[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}}return c.attributesNum!==a||c.index!==i}(r,x,d,y),M&&function(t,e,n,i){const r={},s=e.attributes;let a=0;const o=n.getAttributes();for(const e in o){if(o[e].location>=0){let n=s[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,a++}}c.attributes=r,c.attributesNum=a,c.index=i}(r,x,d,y)}else{const t=!0===l.wireframe;c.geometry===x.id&&c.program===d.id&&c.wireframe===t||(c.geometry=x.id,c.program=d.id,c.wireframe=t,M=!0)}null!==y&&n.update(y,t.ELEMENT_ARRAY_BUFFER),(M||h)&&(h=!1,function(r,s,a,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;m();const l=o.attributes,c=a.getAttributes(),h=s.defaultAttributeValues;for(const e in c){const s=c[e];if(s.location>=0){let a=l[e];if(void 0===a&&("instanceMatrix"===e&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===e&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const e=a.normalized,l=a.itemSize,c=n.get(a);if(void 0===c)continue;const h=c.buffer,u=c.type,d=c.bytesPerElement,p=!0===i.isWebGL2&&(u===t.INT||u===t.UNSIGNED_INT||a.gpuType===z);if(a.isInterleavedBufferAttribute){const n=a.data,i=n.stride,c=a.offset;if(n.isInstancedInterleavedBuffer){for(let t=0;t<s.locationSize;t++)g(s.location+t,n.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let t=0;t<s.locationSize;t++)f(s.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<s.locationSize;t++)v(s.location+t,l/s.locationSize,u,e,i*d,(c+l/s.locationSize*t)*d,p)}else{if(a.isInstancedBufferAttribute){for(let t=0;t<s.locationSize;t++)g(s.location+t,a.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let t=0;t<s.locationSize;t++)f(s.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<s.locationSize;t++)v(s.location+t,l/s.locationSize,u,e,l*d,l/s.locationSize*t*d,p)}}else if(void 0!==h){const n=h[e];if(void 0!==n)switch(n.length){case 2:t.vertexAttrib2fv(s.location,n);break;case 3:t.vertexAttrib3fv(s.location,n);break;case 4:t.vertexAttrib4fv(s.location,n);break;default:t.vertexAttrib1fv(s.location,n)}}}}_()}(r,l,d,x),null!==y&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(y).buffer))},reset:x,resetDefaultState:y,dispose:function(){x();for(const t in o){const e=o[t];for(const t in e){const n=e[t];for(const t in n)d(n[t].object),delete n[t];delete e[t]}delete o[t]}},releaseStatesOfGeometry:function(t){if(void 0===o[t.id])return;const e=o[t.id];for(const t in e){const n=e[t];for(const t in n)d(n[t].object),delete n[t];delete e[t]}delete o[t.id]},releaseStatesOfProgram:function(t){for(const e in o){const n=o[e];if(void 0===n[t.id])continue;const i=n[t.id];for(const t in i)d(i[t].object),delete i[t];delete n[t.id]}},initAttributes:m,enableAttribute:f,disableUnusedAttributes:_}}function wr(t,e,n,i){const r=i.isWebGL2;let s;this.setMode=function(t){s=t},this.render=function(e,i){t.drawArrays(s,e,i),n.update(i,s,1)},this.renderInstances=function(i,a,o){if(0===o)return;let l,c;if(r)l=t,c="drawArraysInstanced";else if(l=e.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](s,i,a,o),n.update(a,s,o)},this.renderMultiDraw=function(t,i,r){if(0===r)return;const a=e.get("WEBGL_multi_draw");if(null===a)for(let e=0;e<r;e++)this.render(t[e],i[e]);else{a.multiDrawArraysWEBGL(s,t,0,i,0,r);let e=0;for(let t=0;t<r;t++)e+=i[t];n.update(e,s,1)}}}function Ar(t,e,n){let i;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===t.constructor.name;let a=void 0!==n.precision?n.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=s||e.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_TEXTURE_SIZE),p=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),m=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),g=t.getParameter(t.MAX_VARYING_VECTORS),_=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=u>0,x=s||e.has("OES_texture_float");return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:x,floatVertexTextures:v&&x,maxSamples:s?t.getParameter(t.MAX_SAMPLES):0}}function Rr(t){const e=this;let n=null,i=0,r=!1,s=!1;const a=new pr,o=new fe,l={value:null,needsUpdate:!1};function c(t,n,i,r){const s=null!==t?t.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const e=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<e)&&(c=new Float32Array(e));for(let e=0,n=i;e!==s;++e,n+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const n=0!==t.length||e||0!==i||r;return r=e,i=t.length,n},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){n=c(t,e,0)},this.setState=function(a,o,h){const u=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!r||null===u||0===u.length||s&&!p)s?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);e.numPlanes=i,e.numIntersection=0}();else{const t=s?0:i,e=4*t;let r=m.clippingState||null;l.value=r,r=c(u,o,e,h);for(let t=0;t!==e;++t)r[t]=n[t];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Cr(t){let e=new WeakMap;function n(t,e){return e===E?t.mapping=b:e===w&&(t.mapping=T),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===E||s===w){if(e.has(r)){return n(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new cr(s.height/2);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}class Lr extends rr{constructor(t=-1,e=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,s=n+t,a=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const Pr=[.125,.215,.35,.446,.526,.582],Ir=20,Ur=new Lr,Dr=new ci;let Nr=null,Or=0,Fr=0;const Br=(1+Math.sqrt(5))/2,zr=1/Br,Gr=[new We(1,1,1),new We(-1,1,1),new We(1,1,-1),new We(-1,1,-1),new We(0,Br,zr),new We(0,Br,-zr),new We(zr,0,Br),new We(-zr,0,Br),new We(Br,zr,0),new We(-Br,zr,0)];class Hr{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){Nr=this._renderer.getRenderTarget(),Or=this._renderer.getActiveCubeFace(),Fr=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Xr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Wr(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Nr,Or,Fr),t.scissorTest=!1,kr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===b||t.mapping===T?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Nr=this._renderer.getRenderTarget(),Or=this._renderer.getActiveCubeFace(),Fr=this._renderer.getActiveMipmapLevel();const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:D,minFilter:D,generateMipmaps:!1,type:V,format:j,colorSpace:Ht,depthBuffer:!1},i=Vr(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Vr(t,e,n);const{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],n=[],i=[];let r=t;const s=t-4+1+Pr.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);n.push(s);let o=1/s;a>t-4?o=Pr[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,m=3,f=2,g=1,_=new Float32Array(m*p*d),v=new Float32Array(f*p*d),x=new Float32Array(g*p*d);for(let t=0;t<d;t++){const e=t%3*2/3-1,n=t>2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];_.set(i,m*p*t),v.set(u,f*p*t);const r=[t,t,t,t,t,t];x.set(r,g*p*t)}const y=new Ii;y.setAttribute("position",new Mi(_,m)),y.setAttribute("uv",new Mi(v,f)),y.setAttribute("faceIndex",new Mi(x,g)),e.push(y),r>4&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(Ir),r=new We(0,1,0),s=new ir({name:"SphericalGaussianBlur",defines:{n:Ir,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:jr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(i,t,e)}return i}_compileMaterial(t){const e=new Ji(this._lodPlanes[0],t);this._renderer.compile(e,Ur)}_sceneToCubeUV(t,e,n,i){const r=new sr(90,1,e,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,h=l.toneMapping;l.getClearColor(Dr),l.toneMapping=p,l.autoClear=!1;const u=new pi({name:"PMREM.Background",side:a,depthWrite:!1,depthTest:!1}),d=new Ji(new $i,u);let m=!1;const f=t.background;f?f.isColor&&(u.color.copy(f),t.background=null,m=!0):(u.color.copy(Dr),m=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(r.up.set(0,s[e],0),r.lookAt(o[e],0,0)):1===n?(r.up.set(0,0,s[e]),r.lookAt(0,o[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,o[e]));const a=this._cubeSize;kr(i,n*a,e>2?a:0,a,a),l.setRenderTarget(i),m&&l.render(d,r),l.render(t,r)}d.geometry.dispose(),d.material.dispose(),l.toneMapping=h,l.autoClear=c,t.background=f}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===b||t.mapping===T;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Xr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Wr());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ji(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;kr(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(s,Ur)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let e=1;e<this._lodPlanes.length;e++){const n=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),i=Gr[(e-1)%Gr.length];this._blur(t,e-1,e,n,i)}e.autoClear=n}_blur(t,e,n,i,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,n,i,"latitudinal",r),this._halfBlur(s,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new Ji(this._lodPlanes[i],l),h=l.uniforms,u=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,m=isFinite(r)?1+Math.floor(3*p):Ir;m>Ir&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<Ir;++t){const e=t/p,n=Math.exp(-e*e/2);f.push(n),0===t?g+=n:t<m&&(g+=2*n)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;h.envMap.value=t.texture,h.samples.value=m,h.weights.value=f,h.latitudinal.value="latitudinal"===s,a&&(h.poleAxis.value=a);const{_lodMax:_}=this;h.dTheta.value=d,h.mipInt.value=_-n;const v=this._sizeLods[i];kr(e,3*v*(i>_-4?i-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(c,Ur)}}function Vr(t,e,n){const i=new Ge(t,e,n);return i.texture.mapping=A,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function kr(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function Wr(){return new ir({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:jr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Xr(){return new ir({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:jr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function jr(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function qr(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===E||s===w,o=s===b||s===T;if(a||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=e.get(r);return null===n&&(n=new Hr(t)),i=a?n.fromEquirectangular(r,i):n.fromCubemap(r,i),e.set(r,i),i.texture}if(e.has(r))return e.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(t){let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(s)){null===n&&(n=new Hr(t));const s=a?n.fromEquirectangular(r):n.fromCubemap(r);return e.set(r,s),r.addEventListener("dispose",i),s.texture}return null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Yr(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(t){t.isWebGL2?(n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance")):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(t){const e=n(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Zr(t,e,n,i){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);for(const t in o.morphAttributes){const n=o.morphAttributes[t];for(let t=0,i=n.length;t<i;t++)e.remove(n[t])}o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,r=t.attributes.position;let a=0;if(null!==i){const t=i.array;a=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],r=t[e+1],s=t[e+2];n.push(i,r,r,s,s,i)}}else{if(void 0===r)return;{const t=r.array;a=r.version;for(let e=0,i=t.length/3-1;e<i;e+=3){const t=e+0,i=e+1,r=e+2;n.push(t,i,i,r,r,t)}}}const o=new(_e(n)?bi:Si)(n,1);o.version=a;const l=s.get(t);l&&e.remove(l),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,n.memory.geometries++),e},update:function(n){const i=n.attributes;for(const n in i)e.update(i[n],t.ARRAY_BUFFER);const r=n.morphAttributes;for(const n in r){const i=r[n];for(let n=0,r=i.length;n<r;n++)e.update(i[n],t.ARRAY_BUFFER)}},getWireframeAttribute:function(t){const e=s.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&o(t)}else o(t);return s.get(t)}}}function Jr(t,e,n,i){const r=i.isWebGL2;let s,a,o;this.setMode=function(t){s=t},this.setIndex=function(t){a=t.type,o=t.bytesPerElement},this.render=function(e,i){t.drawElements(s,i,a,e*o),n.update(i,s,1)},this.renderInstances=function(i,l,c){if(0===c)return;let h,u;if(r)h=t,u="drawElementsInstanced";else if(h=e.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===h)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[u](s,l,a,i*o,c),n.update(l,s,c)},this.renderMultiDraw=function(t,i,r){if(0===r)return;const l=e.get("WEBGL_multi_draw");if(null===l)for(let e=0;e<r;e++)this.render(t[e]/o,i[e]);else{l.multiDrawElementsWEBGL(s,i,0,a,t,0,r);let e=0;for(let t=0;t<r;t++)e+=i[t];n.update(e,s,1)}}}function Kr(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(n,i,r){switch(e.calls++,i){case t.TRIANGLES:e.triangles+=r*(n/3);break;case t.LINES:e.lines+=r*(n/2);break;case t.LINE_STRIP:e.lines+=r*(n-1);break;case t.LINE_LOOP:e.lines+=r*n;break;case t.POINTS:e.points+=r*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function $r(t,e){return t[0]-e[0]}function Qr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function ts(t,e,n){const i={},r=new Float32Array(8),s=new WeakMap,a=new Be,o=[];for(let t=0;t<8;t++)o[t]=[t,0];return{update:function(l,c,h){const u=l.morphTargetInfluences;if(!0===e.isWebGL2){const d=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,p=void 0!==d?d.length:0;let m=s.get(c);if(void 0===m||m.count!==p){void 0!==m&&m.texture.dispose();const _=void 0!==c.morphAttributes.position,v=void 0!==c.morphAttributes.normal,x=void 0!==c.morphAttributes.color,y=c.morphAttributes.position||[],M=c.morphAttributes.normal||[],S=c.morphAttributes.color||[];let b=0;!0===_&&(b=1),!0===v&&(b=2),!0===x&&(b=3);let T=c.attributes.position.count*b,E=1;T>e.maxTextureSize&&(E=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const w=new Float32Array(T*E*4*p),A=new He(w,T,E,p);A.type=H,A.needsUpdate=!0;const R=4*b;for(let L=0;L<p;L++){const P=y[L],I=M[L],U=S[L],D=T*E*4*L;for(let N=0;N<P.count;N++){const O=N*R;!0===_&&(a.fromBufferAttribute(P,N),w[D+O+0]=a.x,w[D+O+1]=a.y,w[D+O+2]=a.z,w[D+O+3]=0),!0===v&&(a.fromBufferAttribute(I,N),w[D+O+4]=a.x,w[D+O+5]=a.y,w[D+O+6]=a.z,w[D+O+7]=0),!0===x&&(a.fromBufferAttribute(U,N),w[D+O+8]=a.x,w[D+O+9]=a.y,w[D+O+10]=a.z,w[D+O+11]=4===U.itemSize?a.w:1)}}function C(){A.dispose(),s.delete(c),c.removeEventListener("dispose",C)}m={count:p,texture:A,size:new me(T,E)},s.set(c,m),c.addEventListener("dispose",C)}let f=0;for(let F=0;F<u.length;F++)f+=u[F];const g=c.morphTargetsRelative?1:1-f;h.getUniforms().setValue(t,"morphTargetBaseInfluence",g),h.getUniforms().setValue(t,"morphTargetInfluences",u),h.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),h.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}else{const B=void 0===u?0:u.length;let z=i[c.id];if(void 0===z||z.length!==B){z=[];for(let X=0;X<B;X++)z[X]=[X,0];i[c.id]=z}for(let j=0;j<B;j++){const q=z[j];q[0]=j,q[1]=u[j]}z.sort(Qr);for(let Y=0;Y<8;Y++)Y<B&&z[Y][1]?(o[Y][0]=z[Y][0],o[Y][1]=z[Y][1]):(o[Y][0]=Number.MAX_SAFE_INTEGER,o[Y][1]=0);o.sort($r);const G=c.morphAttributes.position,V=c.morphAttributes.normal;let k=0;for(let Z=0;Z<8;Z++){const J=o[Z],K=J[0],$=J[1];K!==Number.MAX_SAFE_INTEGER&&$?(G&&c.getAttribute("morphTarget"+Z)!==G[K]&&c.setAttribute("morphTarget"+Z,G[K]),V&&c.getAttribute("morphNormal"+Z)!==V[K]&&c.setAttribute("morphNormal"+Z,V[K]),r[Z]=$,k+=$):(G&&!0===c.hasAttribute("morphTarget"+Z)&&c.deleteAttribute("morphTarget"+Z),V&&!0===c.hasAttribute("morphNormal"+Z)&&c.deleteAttribute("morphNormal"+Z),r[Z]=0)}const W=c.morphTargetsRelative?1:1-k;h.getUniforms().setValue(t,"morphTargetBaseInfluence",W),h.getUniforms().setValue(t,"morphTargetInfluences",r)}}}}function es(t,e,n,i){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(a){const o=i.render.frame,l=a.geometry,c=e.get(a,l);if(r.get(c)!==o&&(e.update(c),r.set(c,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),r.get(a)!==o&&(n.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&n.update(a.instanceColor,t.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;r.get(t)!==o&&(t.update(),r.set(t,o))}return c},dispose:function(){r=new WeakMap}}}class ns extends Fe{constructor(t,e,n,i,r,s,a,o,l,c){if((c=void 0!==c?c:q)!==q&&c!==Y)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===q&&(n=G),void 0===n&&c===Y&&(n=X),super(null,i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:P,this.minFilter=void 0!==o?o:P,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}const is=new Fe,rs=new ns(1,1);rs.compareFunction=515;const ss=new He,as=new Ve,os=new lr,ls=[],cs=[],hs=new Float32Array(16),us=new Float32Array(9),ds=new Float32Array(4);function ps(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let s=ls[r];if(void 0===s&&(s=new Float32Array(r),ls[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function ms(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function fs(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function gs(t,e){let n=cs[e];void 0===n&&(n=new Int32Array(e),cs[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function _s(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function vs(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ms(n,e))return;t.uniform2fv(this.addr,e),fs(n,e)}}function xs(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ms(n,e))return;t.uniform3fv(this.addr,e),fs(n,e)}}function ys(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ms(n,e))return;t.uniform4fv(this.addr,e),fs(n,e)}}function Ms(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ms(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),fs(n,e)}else{if(ms(n,i))return;ds.set(i),t.uniformMatrix2fv(this.addr,!1,ds),fs(n,i)}}function Ss(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ms(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),fs(n,e)}else{if(ms(n,i))return;us.set(i),t.uniformMatrix3fv(this.addr,!1,us),fs(n,i)}}function bs(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ms(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),fs(n,e)}else{if(ms(n,i))return;hs.set(i),t.uniformMatrix4fv(this.addr,!1,hs),fs(n,i)}}function Ts(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Es(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ms(n,e))return;t.uniform2iv(this.addr,e),fs(n,e)}}function ws(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ms(n,e))return;t.uniform3iv(this.addr,e),fs(n,e)}}function As(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ms(n,e))return;t.uniform4iv(this.addr,e),fs(n,e)}}function Rs(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Cs(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ms(n,e))return;t.uniform2uiv(this.addr,e),fs(n,e)}}function Ls(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ms(n,e))return;t.uniform3uiv(this.addr,e),fs(n,e)}}function Ps(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ms(n,e))return;t.uniform4uiv(this.addr,e),fs(n,e)}}function Is(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r);const s=this.type===t.SAMPLER_2D_SHADOW?rs:is;n.setTexture2D(e||s,r)}function Us(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||as,r)}function Ds(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||os,r)}function Ns(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||ss,r)}function Os(t,e){t.uniform1fv(this.addr,e)}function Fs(t,e){const n=ps(e,this.size,2);t.uniform2fv(this.addr,n)}function Bs(t,e){const n=ps(e,this.size,3);t.uniform3fv(this.addr,n)}function zs(t,e){const n=ps(e,this.size,4);t.uniform4fv(this.addr,n)}function Gs(t,e){const n=ps(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Hs(t,e){const n=ps(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Vs(t,e){const n=ps(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function ks(t,e){t.uniform1iv(this.addr,e)}function Ws(t,e){t.uniform2iv(this.addr,e)}function Xs(t,e){t.uniform3iv(this.addr,e)}function js(t,e){t.uniform4iv(this.addr,e)}function qs(t,e){t.uniform1uiv(this.addr,e)}function Ys(t,e){t.uniform2uiv(this.addr,e)}function Zs(t,e){t.uniform3uiv(this.addr,e)}function Js(t,e){t.uniform4uiv(this.addr,e)}function Ks(t,e,n){const i=this.cache,r=e.length,s=gs(n,r);ms(i,s)||(t.uniform1iv(this.addr,s),fs(i,s));for(let t=0;t!==r;++t)n.setTexture2D(e[t]||is,s[t])}function $s(t,e,n){const i=this.cache,r=e.length,s=gs(n,r);ms(i,s)||(t.uniform1iv(this.addr,s),fs(i,s));for(let t=0;t!==r;++t)n.setTexture3D(e[t]||as,s[t])}function Qs(t,e,n){const i=this.cache,r=e.length,s=gs(n,r);ms(i,s)||(t.uniform1iv(this.addr,s),fs(i,s));for(let t=0;t!==r;++t)n.setTextureCube(e[t]||os,s[t])}function ta(t,e,n){const i=this.cache,r=e.length,s=gs(n,r);ms(i,s)||(t.uniform1iv(this.addr,s),fs(i,s));for(let t=0;t!==r;++t)n.setTexture2DArray(e[t]||ss,s[t])}class ea{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return _s;case 35664:return vs;case 35665:return xs;case 35666:return ys;case 35674:return Ms;case 35675:return Ss;case 35676:return bs;case 5124:case 35670:return Ts;case 35667:case 35671:return Es;case 35668:case 35672:return ws;case 35669:case 35673:return As;case 5125:return Rs;case 36294:return Cs;case 36295:return Ls;case 36296:return Ps;case 35678:case 36198:case 36298:case 36306:case 35682:return Is;case 35679:case 36299:case 36307:return Us;case 35680:case 36300:case 36308:case 36293:return Ds;case 36289:case 36303:case 36311:case 36292:return Ns}}(e.type)}}class na{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Os;case 35664:return Fs;case 35665:return Bs;case 35666:return zs;case 35674:return Gs;case 35675:return Hs;case 35676:return Vs;case 5124:case 35670:return ks;case 35667:case 35671:return Ws;case 35668:case 35672:return Xs;case 35669:case 35673:return js;case 5125:return qs;case 36294:return Ys;case 36295:return Zs;case 36296:return Js;case 35678:case 36198:case 36298:case 36306:case 35682:return Ks;case 35679:case 36299:case 36307:return $s;case 35680:case 36300:case 36308:case 36293:return Qs;case 36289:case 36303:case 36311:case 36292:return ta}}(e.type)}}class ia{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,s=i.length;r!==s;++r){const s=i[r];s.setValue(t,e[s.id],n)}}}const ra=/(\w+)(\])?(\[|\.)?/g;function sa(t,e){t.seq.push(e),t.map[e.id]=e}function aa(t,e,n){const i=t.name,r=i.length;for(ra.lastIndex=0;;){const s=ra.exec(i),a=ra.lastIndex;let o=s[1];const l="]"===s[2],c=s[3];if(l&&(o|=0),void 0===c||"["===c&&a+2===r){sa(n,void 0===c?new ea(o,t,e):new na(o,t,e));break}{let t=n.map[o];void 0===t&&(t=new ia(o),sa(n,t)),n=t}}}class oa{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=t.getActiveUniform(e,i);aa(n,t.getUniformLocation(e,n.name),this)}}setValue(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=n[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const r=t[i];r.id in e&&n.push(r)}return n}}function la(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}const ca=37297;let ha=0;function ua(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),r=t.getShaderInfoLog(e).trim();if(i&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const i=parseInt(s[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const n=t.split("\n"),i=[],r=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let t=r;t<s;t++){const r=t+1;i.push(`${r===e?">":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function da(t,e){const n=function(t){const e=Re.getPrimaries(Re.workingColorSpace),n=Re.getPrimaries(t);let i;switch(e===n?i="":e===qt&&n===jt?i="LinearDisplayP3ToLinearSRGB":e===jt&&n===qt&&(i="LinearSRGBToLinearDisplayP3"),t){case Ht:case kt:return[i,"LinearTransferOETF"];case Gt:case Vt:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[i,"LinearTransferOETF"]}}(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function pa(t,e){let n;switch(e){case m:n="Linear";break;case f:n="Reinhard";break;case g:n="OptimizedCineon";break;case _:n="ACESFilmic";break;case x:n="AgX";break;case v:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function ma(t){return""!==t}function fa(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.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,n).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 ga(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const _a=/^[ \t]*#include +<([\w\d./]+)>/gm;function va(t){return t.replace(_a,ya)}const xa=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function ya(t,e){let n=yr[e];if(void 0===n){const t=xa.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=yr[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return va(n)}const Ma=/#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 Sa(t){return t.replace(Ma,ba)}function ba(t,e,n,i){let r="";for(let t=parseInt(e);t<parseInt(n);t++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function Ta(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Ea(t,e,s,a){const o=t.getContext(),l=s.defines;let c=s.vertexShader,m=s.fragmentShader;const f=function(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===n?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===i?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===r&&(e="SHADOWMAP_TYPE_VSM"),e}(s),g=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case b:case T:e="ENVMAP_TYPE_CUBE";break;case A:e="ENVMAP_TYPE_CUBE_UV"}return e}(s),_=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===T&&(e="ENVMAP_MODE_REFRACTION");return e}(s),v=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case h:e="ENVMAP_BLENDING_MULTIPLY";break;case u:e="ENVMAP_BLENDING_MIX";break;case d:e="ENVMAP_BLENDING_ADD"}return e}(s),x=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(s),y=s.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.normalMapTangentSpace||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ma).join("\n")}(s),M=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(ma).join("\n")}(s),S=function(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(l),E=o.createProgram();let w,R,C=s.glslVersion?"#version "+s.glslVersion+"\n":"";s.isRawShaderMaterial?(w=["#define SHADER_TYPE "+s.shaderType,"#define SHADER_NAME "+s.shaderName,S].filter(ma).join("\n"),w.length>0&&(w+="\n"),R=[y,"#define SHADER_TYPE "+s.shaderType,"#define SHADER_NAME "+s.shaderName,S].filter(ma).join("\n"),R.length>0&&(R+="\n")):(w=[Ta(s),"#define SHADER_TYPE "+s.shaderType,"#define SHADER_NAME "+s.shaderName,S,s.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",s.batching?"#define USE_BATCHING":"",s.instancing?"#define USE_INSTANCING":"",s.instancingColor?"#define USE_INSTANCING_COLOR":"",s.useFog&&s.fog?"#define USE_FOG":"",s.useFog&&s.fogExp2?"#define FOG_EXP2":"",s.map?"#define USE_MAP":"",s.envMap?"#define USE_ENVMAP":"",s.envMap?"#define "+_:"",s.lightMap?"#define USE_LIGHTMAP":"",s.aoMap?"#define USE_AOMAP":"",s.bumpMap?"#define USE_BUMPMAP":"",s.normalMap?"#define USE_NORMALMAP":"",s.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",s.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",s.displacementMap?"#define USE_DISPLACEMENTMAP":"",s.emissiveMap?"#define USE_EMISSIVEMAP":"",s.anisotropy?"#define USE_ANISOTROPY":"",s.anisotropyMap?"#define USE_ANISOTROPYMAP":"",s.clearcoatMap?"#define USE_CLEARCOATMAP":"",s.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",s.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",s.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",s.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",s.specularMap?"#define USE_SPECULARMAP":"",s.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",s.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",s.roughnessMap?"#define USE_ROUGHNESSMAP":"",s.metalnessMap?"#define USE_METALNESSMAP":"",s.alphaMap?"#define USE_ALPHAMAP":"",s.alphaHash?"#define USE_ALPHAHASH":"",s.transmission?"#define USE_TRANSMISSION":"",s.transmissionMap?"#define USE_TRANSMISSIONMAP":"",s.thicknessMap?"#define USE_THICKNESSMAP":"",s.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",s.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",s.mapUv?"#define MAP_UV "+s.mapUv:"",s.alphaMapUv?"#define ALPHAMAP_UV "+s.alphaMapUv:"",s.lightMapUv?"#define LIGHTMAP_UV "+s.lightMapUv:"",s.aoMapUv?"#define AOMAP_UV "+s.aoMapUv:"",s.emissiveMapUv?"#define EMISSIVEMAP_UV "+s.emissiveMapUv:"",s.bumpMapUv?"#define BUMPMAP_UV "+s.bumpMapUv:"",s.normalMapUv?"#define NORMALMAP_UV "+s.normalMapUv:"",s.displacementMapUv?"#define DISPLACEMENTMAP_UV "+s.displacementMapUv:"",s.metalnessMapUv?"#define METALNESSMAP_UV "+s.metalnessMapUv:"",s.roughnessMapUv?"#define ROUGHNESSMAP_UV "+s.roughnessMapUv:"",s.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+s.anisotropyMapUv:"",s.clearcoatMapUv?"#define CLEARCOATMAP_UV "+s.clearcoatMapUv:"",s.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+s.clearcoatNormalMapUv:"",s.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+s.clearcoatRoughnessMapUv:"",s.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+s.iridescenceMapUv:"",s.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+s.iridescenceThicknessMapUv:"",s.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+s.sheenColorMapUv:"",s.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+s.sheenRoughnessMapUv:"",s.specularMapUv?"#define SPECULARMAP_UV "+s.specularMapUv:"",s.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+s.specularColorMapUv:"",s.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+s.specularIntensityMapUv:"",s.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+s.transmissionMapUv:"",s.thicknessMapUv?"#define THICKNESSMAP_UV "+s.thicknessMapUv:"",s.vertexTangents&&!1===s.flatShading?"#define USE_TANGENT":"",s.vertexColors?"#define USE_COLOR":"",s.vertexAlphas?"#define USE_COLOR_ALPHA":"",s.vertexUv1s?"#define USE_UV1":"",s.vertexUv2s?"#define USE_UV2":"",s.vertexUv3s?"#define USE_UV3":"",s.pointsUvs?"#define USE_POINTS_UV":"",s.flatShading?"#define FLAT_SHADED":"",s.skinning?"#define USE_SKINNING":"",s.morphTargets?"#define USE_MORPHTARGETS":"",s.morphNormals&&!1===s.flatShading?"#define USE_MORPHNORMALS":"",s.morphColors&&s.isWebGL2?"#define USE_MORPHCOLORS":"",s.morphTargetsCount>0&&s.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",s.morphTargetsCount>0&&s.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+s.morphTextureStride:"",s.morphTargetsCount>0&&s.isWebGL2?"#define MORPHTARGETS_COUNT "+s.morphTargetsCount:"",s.doubleSided?"#define DOUBLE_SIDED":"",s.flipSided?"#define FLIP_SIDED":"",s.shadowMapEnabled?"#define USE_SHADOWMAP":"",s.shadowMapEnabled?"#define "+f:"",s.sizeAttenuation?"#define USE_SIZEATTENUATION":"",s.numLightProbes>0?"#define USE_LIGHT_PROBES":"",s.useLegacyLights?"#define LEGACY_LIGHTS":"",s.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",s.logarithmicDepthBuffer&&s.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ma).join("\n"),R=[y,Ta(s),"#define SHADER_TYPE "+s.shaderType,"#define SHADER_NAME "+s.shaderName,S,s.useFog&&s.fog?"#define USE_FOG":"",s.useFog&&s.fogExp2?"#define FOG_EXP2":"",s.map?"#define USE_MAP":"",s.matcap?"#define USE_MATCAP":"",s.envMap?"#define USE_ENVMAP":"",s.envMap?"#define "+g:"",s.envMap?"#define "+_:"",s.envMap?"#define "+v:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.maxMip+".0":"",s.lightMap?"#define USE_LIGHTMAP":"",s.aoMap?"#define USE_AOMAP":"",s.bumpMap?"#define USE_BUMPMAP":"",s.normalMap?"#define USE_NORMALMAP":"",s.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",s.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",s.emissiveMap?"#define USE_EMISSIVEMAP":"",s.anisotropy?"#define USE_ANISOTROPY":"",s.anisotropyMap?"#define USE_ANISOTROPYMAP":"",s.clearcoat?"#define USE_CLEARCOAT":"",s.clearcoatMap?"#define USE_CLEARCOATMAP":"",s.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",s.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",s.iridescence?"#define USE_IRIDESCENCE":"",s.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",s.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",s.specularMap?"#define USE_SPECULARMAP":"",s.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",s.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",s.roughnessMap?"#define USE_ROUGHNESSMAP":"",s.metalnessMap?"#define USE_METALNESSMAP":"",s.alphaMap?"#define USE_ALPHAMAP":"",s.alphaTest?"#define USE_ALPHATEST":"",s.alphaHash?"#define USE_ALPHAHASH":"",s.sheen?"#define USE_SHEEN":"",s.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",s.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",s.transmission?"#define USE_TRANSMISSION":"",s.transmissionMap?"#define USE_TRANSMISSIONMAP":"",s.thicknessMap?"#define USE_THICKNESSMAP":"",s.vertexTangents&&!1===s.flatShading?"#define USE_TANGENT":"",s.vertexColors||s.instancingColor?"#define USE_COLOR":"",s.vertexAlphas?"#define USE_COLOR_ALPHA":"",s.vertexUv1s?"#define USE_UV1":"",s.vertexUv2s?"#define USE_UV2":"",s.vertexUv3s?"#define USE_UV3":"",s.pointsUvs?"#define USE_POINTS_UV":"",s.gradientMap?"#define USE_GRADIENTMAP":"",s.flatShading?"#define FLAT_SHADED":"",s.doubleSided?"#define DOUBLE_SIDED":"",s.flipSided?"#define FLIP_SIDED":"",s.shadowMapEnabled?"#define USE_SHADOWMAP":"",s.shadowMapEnabled?"#define "+f:"",s.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",s.numLightProbes>0?"#define USE_LIGHT_PROBES":"",s.useLegacyLights?"#define LEGACY_LIGHTS":"",s.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",s.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",s.logarithmicDepthBuffer&&s.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",s.toneMapping!==p?"#define TONE_MAPPING":"",s.toneMapping!==p?yr.tonemapping_pars_fragment:"",s.toneMapping!==p?pa("toneMapping",s.toneMapping):"",s.dithering?"#define DITHERING":"",s.opaque?"#define OPAQUE":"",yr.colorspace_pars_fragment,da("linearToOutputTexel",s.outputColorSpace),s.useDepthPacking?"#define DEPTH_PACKING "+s.depthPacking:"","\n"].filter(ma).join("\n")),c=va(c),c=fa(c,s),c=ga(c,s),m=va(m),m=fa(m,s),m=ga(m,s),c=Sa(c),m=Sa(m),s.isWebGL2&&!0!==s.isRawShaderMaterial&&(C="#version 300 es\n",w=[M,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+w,R=["precision mediump sampler2DArray;","#define varying in",s.glslVersion===Jt?"":"layout(location = 0) out highp vec4 pc_fragColor;",s.glslVersion===Jt?"":"#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("\n")+"\n"+R);const L=C+w+c,P=C+R+m,I=la(o,o.VERTEX_SHADER,L),U=la(o,o.FRAGMENT_SHADER,P);function D(e){if(t.debug.checkShaderErrors){const n=o.getProgramInfoLog(E).trim(),i=o.getShaderInfoLog(I).trim(),r=o.getShaderInfoLog(U).trim();let s=!0,a=!0;if(!1===o.getProgramParameter(E,o.LINK_STATUS))if(s=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(o,E,I,U);else{const t=ua(o,I,"vertex"),e=ua(o,U,"fragment");console.error("THREE.WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(E,o.VALIDATE_STATUS)+"\n\nProgram Info Log: "+n+"\n"+t+"\n"+e)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==r||(a=!1);a&&(e.diagnostics={runnable:s,programLog:n,vertexShader:{log:i,prefix:w},fragmentShader:{log:r,prefix:R}})}o.deleteShader(I),o.deleteShader(U),N=new oa(o,E),O=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=t.getActiveAttrib(e,r),s=i.name;let a=1;i.type===t.FLOAT_MAT2&&(a=2),i.type===t.FLOAT_MAT3&&(a=3),i.type===t.FLOAT_MAT4&&(a=4),n[s]={type:i.type,location:t.getAttribLocation(e,s),locationSize:a}}return n}(o,E)}let N,O;o.attachShader(E,I),o.attachShader(E,U),void 0!==s.index0AttributeName?o.bindAttribLocation(E,0,s.index0AttributeName):!0===s.morphTargets&&o.bindAttribLocation(E,0,"position"),o.linkProgram(E),this.getUniforms=function(){return void 0===N&&D(this),N},this.getAttributes=function(){return void 0===O&&D(this),O};let F=!1===s.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===F&&(F=o.getProgramParameter(E,ca)),F},this.destroy=function(){a.releaseStatesOfProgram(this),o.deleteProgram(E),this.program=void 0},this.type=s.shaderType,this.name=s.shaderName,this.id=ha++,this.cacheKey=e,this.usedTimes=1,this.program=E,this.vertexShader=I,this.fragmentShader=U,this}let wa=0;class Aa{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),s=this._getShaderCacheForMaterial(t);return!1===s.has(i)&&(s.add(i),i.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new Ra(t),e.set(t,n)),n}}class Ra{constructor(t){this.id=wa++,this.code=t,this.usedTimes=0}}function Ca(t,e,n,i,r,s,o){const l=new In,c=new Aa,h=[],u=r.isWebGL2,d=r.logarithmicDepthBuffer,m=r.vertexTextures;let f=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(t){return 0===t?"uv":`uv${t}`}return{getParameters:function(s,l,h,v,x){const y=v.fog,M=x.geometry,S=s.isMeshStandardMaterial?v.environment:null,b=(s.isMeshStandardMaterial?n:e).get(s.envMap||S),T=b&&b.mapping===A?b.image.height:null,E=g[s.type];null!==s.precision&&(f=r.getMaxPrecision(s.precision),f!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",f,"instead."));const w=M.morphAttributes.position||M.morphAttributes.normal||M.morphAttributes.color,R=void 0!==w?w.length:0;let C,L,P,I,U=0;if(void 0!==M.morphAttributes.position&&(U=1),void 0!==M.morphAttributes.normal&&(U=2),void 0!==M.morphAttributes.color&&(U=3),E){const t=Sr[E];C=t.vertexShader,L=t.fragmentShader}else C=s.vertexShader,L=s.fragmentShader,c.update(s),P=c.getVertexShaderID(s),I=c.getFragmentShaderID(s);const D=t.getRenderTarget(),N=!0===x.isInstancedMesh,O=!0===x.isBatchedMesh,F=!!s.map,B=!!s.matcap,z=!!b,G=!!s.aoMap,H=!!s.lightMap,V=!!s.bumpMap,k=!!s.normalMap,W=!!s.displacementMap,X=!!s.emissiveMap,j=!!s.metalnessMap,q=!!s.roughnessMap,Y=s.anisotropy>0,Z=s.clearcoat>0,J=s.iridescence>0,K=s.sheen>0,$=s.transmission>0,Q=Y&&!!s.anisotropyMap,tt=Z&&!!s.clearcoatMap,et=Z&&!!s.clearcoatNormalMap,nt=Z&&!!s.clearcoatRoughnessMap,it=J&&!!s.iridescenceMap,rt=J&&!!s.iridescenceThicknessMap,st=K&&!!s.sheenColorMap,at=K&&!!s.sheenRoughnessMap,ot=!!s.specularMap,lt=!!s.specularColorMap,ct=!!s.specularIntensityMap,ht=$&&!!s.transmissionMap,ut=$&&!!s.thicknessMap,dt=!!s.gradientMap,pt=!!s.alphaMap,mt=s.alphaTest>0,ft=!!s.alphaHash,gt=!!s.extensions,_t=!!M.attributes.uv1,vt=!!M.attributes.uv2,xt=!!M.attributes.uv3;let yt=p;return s.toneMapped&&(null!==D&&!0!==D.isXRRenderTarget||(yt=t.toneMapping)),{isWebGL2:u,shaderID:E,shaderType:s.type,shaderName:s.name,vertexShader:C,fragmentShader:L,defines:s.defines,customVertexShaderID:P,customFragmentShaderID:I,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:f,batching:O,instancing:N,instancingColor:N&&null!==x.instanceColor,supportsVertexTextures:m,outputColorSpace:null===D?t.outputColorSpace:!0===D.isXRRenderTarget?D.texture.colorSpace:Ht,map:F,matcap:B,envMap:z,envMapMode:z&&b.mapping,envMapCubeUVHeight:T,aoMap:G,lightMap:H,bumpMap:V,normalMap:k,displacementMap:m&&W,emissiveMap:X,normalMapObjectSpace:k&&1===s.normalMapType,normalMapTangentSpace:k&&0===s.normalMapType,metalnessMap:j,roughnessMap:q,anisotropy:Y,anisotropyMap:Q,clearcoat:Z,clearcoatMap:tt,clearcoatNormalMap:et,clearcoatRoughnessMap:nt,iridescence:J,iridescenceMap:it,iridescenceThicknessMap:rt,sheen:K,sheenColorMap:st,sheenRoughnessMap:at,specularMap:ot,specularColorMap:lt,specularIntensityMap:ct,transmission:$,transmissionMap:ht,thicknessMap:ut,gradientMap:dt,opaque:!1===s.transparent&&1===s.blending,alphaMap:pt,alphaTest:mt,alphaHash:ft,combine:s.combine,mapUv:F&&_(s.map.channel),aoMapUv:G&&_(s.aoMap.channel),lightMapUv:H&&_(s.lightMap.channel),bumpMapUv:V&&_(s.bumpMap.channel),normalMapUv:k&&_(s.normalMap.channel),displacementMapUv:W&&_(s.displacementMap.channel),emissiveMapUv:X&&_(s.emissiveMap.channel),metalnessMapUv:j&&_(s.metalnessMap.channel),roughnessMapUv:q&&_(s.roughnessMap.channel),anisotropyMapUv:Q&&_(s.anisotropyMap.channel),clearcoatMapUv:tt&&_(s.clearcoatMap.channel),clearcoatNormalMapUv:et&&_(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:nt&&_(s.clearcoatRoughnessMap.channel),iridescenceMapUv:it&&_(s.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&_(s.iridescenceThicknessMap.channel),sheenColorMapUv:st&&_(s.sheenColorMap.channel),sheenRoughnessMapUv:at&&_(s.sheenRoughnessMap.channel),specularMapUv:ot&&_(s.specularMap.channel),specularColorMapUv:lt&&_(s.specularColorMap.channel),specularIntensityMapUv:ct&&_(s.specularIntensityMap.channel),transmissionMapUv:ht&&_(s.transmissionMap.channel),thicknessMapUv:ut&&_(s.thicknessMap.channel),alphaMapUv:pt&&_(s.alphaMap.channel),vertexTangents:!!M.attributes.tangent&&(k||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!M.attributes.color&&4===M.attributes.color.itemSize,vertexUv1s:_t,vertexUv2s:vt,vertexUv3s:xt,pointsUvs:!0===x.isPoints&&!!M.attributes.uv&&(F||pt),fog:!!y,useFog:!0===s.fog,fogExp2:y&&y.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===x.isSkinnedMesh,morphTargets:void 0!==M.morphAttributes.position,morphNormals:void 0!==M.morphAttributes.normal,morphColors:void 0!==M.morphAttributes.color,morphTargetsCount:R,morphTextureStride:U,numDirLights:l.directional.length,numPointLights:l.point.length,numSpotLights:l.spot.length,numSpotLightMaps:l.spotLightMap.length,numRectAreaLights:l.rectArea.length,numHemiLights:l.hemi.length,numDirLightShadows:l.directionalShadowMap.length,numPointLightShadows:l.pointShadowMap.length,numSpotLightShadows:l.spotShadowMap.length,numSpotLightShadowsWithMaps:l.numSpotLightShadowsWithMaps,numLightProbes:l.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:yt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:F&&!0===s.map.isVideoTexture&&Re.getTransfer(s.map.colorSpace)===Xt,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:s.side===a,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:gt&&!0===s.extensions.derivatives,extensionFragDepth:gt&&!0===s.extensions.fragDepth,extensionDrawBuffers:gt&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:gt&&!0===s.extensions.shaderTextureLOD,extensionClipCullDistance:gt&&s.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:u||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){l.disableAll(),e.isWebGL2&&l.enable(0);e.supportsVertexTextures&&l.enable(1);e.instancing&&l.enable(2);e.instancingColor&&l.enable(3);e.matcap&&l.enable(4);e.envMap&&l.enable(5);e.normalMapObjectSpace&&l.enable(6);e.normalMapTangentSpace&&l.enable(7);e.clearcoat&&l.enable(8);e.iridescence&&l.enable(9);e.alphaTest&&l.enable(10);e.vertexColors&&l.enable(11);e.vertexAlphas&&l.enable(12);e.vertexUv1s&&l.enable(13);e.vertexUv2s&&l.enable(14);e.vertexUv3s&&l.enable(15);e.vertexTangents&&l.enable(16);e.anisotropy&&l.enable(17);e.alphaHash&&l.enable(18);e.batching&&l.enable(19);t.push(l.mask),l.disableAll(),e.fog&&l.enable(0);e.useFog&&l.enable(1);e.flatShading&&l.enable(2);e.logarithmicDepthBuffer&&l.enable(3);e.skinning&&l.enable(4);e.morphTargets&&l.enable(5);e.morphNormals&&l.enable(6);e.morphColors&&l.enable(7);e.premultipliedAlpha&&l.enable(8);e.shadowMapEnabled&&l.enable(9);e.useLegacyLights&&l.enable(10);e.doubleSided&&l.enable(11);e.flipSided&&l.enable(12);e.useDepthPacking&&l.enable(13);e.dithering&&l.enable(14);e.transmission&&l.enable(15);e.sheen&&l.enable(16);e.opaque&&l.enable(17);e.pointsUvs&&l.enable(18);e.decodeVideoTexture&&l.enable(19);t.push(l.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=g[t.type];let n;if(e){const t=Sr[e];n=nr.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=h.length;t<e;t++){const e=h[t];if(e.cacheKey===n){i=e,++i.usedTimes;break}}return void 0===i&&(i=new Ea(t,n,e,s),h.push(i)),i},releaseProgram:function(t){if(0==--t.usedTimes){const e=h.indexOf(t);h[e]=h[h.length-1],h.pop(),t.destroy()}},releaseShaderCache:function(t){c.remove(t)},programs:h,dispose:function(){c.dispose()}}}function La(){let t=new WeakMap;return{get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function Pa(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Ia(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Ua(){const t=[];let e=0;const n=[],i=[],r=[];function s(n,i,r,s,a,o){let l=t[e];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:s,renderOrder:n.renderOrder,z:a,group:o},t[e]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=s,l.renderOrder=n.renderOrder,l.z=a,l.group=o),e++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){e=0,n.length=0,i.length=0,r.length=0},push:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=e,i=t.length;n<i;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||Pa),i.length>1&&i.sort(e||Ia),r.length>1&&r.sort(e||Ia)}}}function Da(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new Ua,t.set(e,[r])):n>=i.length?(r=new Ua,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function Na(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new We,color:new ci};break;case"SpotLight":n={position:new We,direction:new We,color:new ci,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new We,color:new ci,distance:0,decay:0};break;case"HemisphereLight":n={direction:new We,skyColor:new ci,groundColor:new ci};break;case"RectAreaLight":n={color:new ci,position:new We,halfWidth:new We,halfHeight:new We}}return t[e.id]=n,n}}}let Oa=0;function Fa(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Ba(t,e){const n=new Na,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new me};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new me,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),r={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 t=0;t<9;t++)r.probe.push(new We);const s=new We,a=new Mn,o=new Mn;return{setup:function(s,a){let o=0,l=0,c=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let h=0,u=0,d=0,p=0,m=0,f=0,g=0,_=0,v=0,x=0,y=0;s.sort(Fa);const M=!0===a?Math.PI:1;for(let t=0,e=s.length;t<e;t++){const e=s[t],a=e.color,S=e.intensity,b=e.distance,T=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)o+=a.r*S*M,l+=a.g*S*M,c+=a.b*S*M;else if(e.isLightProbe){for(let t=0;t<9;t++)r.probe[t].addScaledVector(e.sh.coefficients[t],S);y++}else if(e.isDirectionalLight){const t=n.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*M),e.castShadow){const t=e.shadow,n=i.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,r.directionalShadow[h]=n,r.directionalShadowMap[h]=T,r.directionalShadowMatrix[h]=e.shadow.matrix,f++}r.directional[h]=t,h++}else if(e.isSpotLight){const t=n.get(e);t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(a).multiplyScalar(S*M),t.distance=b,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,r.spot[d]=t;const s=e.shadow;if(e.map&&(r.spotLightMap[v]=e.map,v++,s.updateMatrices(e),e.castShadow&&x++),r.spotLightMatrix[d]=s.matrix,e.castShadow){const t=i.get(e);t.shadowBias=s.bias,t.shadowNormalBias=s.normalBias,t.shadowRadius=s.radius,t.shadowMapSize=s.mapSize,r.spotShadow[d]=t,r.spotShadowMap[d]=T,_++}d++}else if(e.isRectAreaLight){const t=n.get(e);t.color.copy(a).multiplyScalar(S),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),r.rectArea[p]=t,p++}else if(e.isPointLight){const t=n.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*M),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,n=i.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,n.shadowCameraNear=t.camera.near,n.shadowCameraFar=t.camera.far,r.pointShadow[u]=n,r.pointShadowMap[u]=T,r.pointShadowMatrix[u]=e.shadow.matrix,g++}r.point[u]=t,u++}else if(e.isHemisphereLight){const t=n.get(e);t.skyColor.copy(e.color).multiplyScalar(S*M),t.groundColor.copy(e.groundColor).multiplyScalar(S*M),r.hemi[m]=t,m++}}p>0&&(e.isWebGL2?!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=Mr.LTC_FLOAT_1,r.rectAreaLTC2=Mr.LTC_FLOAT_2):(r.rectAreaLTC1=Mr.LTC_HALF_1,r.rectAreaLTC2=Mr.LTC_HALF_2):!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=Mr.LTC_FLOAT_1,r.rectAreaLTC2=Mr.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Mr.LTC_HALF_1,r.rectAreaLTC2=Mr.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const S=r.hash;S.directionalLength===h&&S.pointLength===u&&S.spotLength===d&&S.rectAreaLength===p&&S.hemiLength===m&&S.numDirectionalShadows===f&&S.numPointShadows===g&&S.numSpotShadows===_&&S.numSpotMaps===v&&S.numLightProbes===y||(r.directional.length=h,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=m,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=_+v-x,r.spotLightMap.length=v,r.numSpotLightShadowsWithMaps=x,r.numLightProbes=y,S.directionalLength=h,S.pointLength=u,S.spotLength=d,S.rectAreaLength=p,S.hemiLength=m,S.numDirectionalShadows=f,S.numPointShadows=g,S.numSpotShadows=_,S.numSpotMaps=v,S.numLightProbes=y,r.version=Oa++)},setupView:function(t,e){let n=0,i=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=r.directional[n];t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),n++}else if(d.isSpotLight){const t=r.spot[l];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),l++}else if(d.isRectAreaLight){const t=r.rectArea[c];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),o.identity(),a.copy(d.matrixWorld),a.premultiply(u),o.extractRotation(a),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(o),t.halfHeight.applyMatrix4(o),c++}else if(d.isPointLight){const t=r.point[i];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),i++}else if(d.isHemisphereLight){const t=r.hemi[h];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(u),h++}}},state:r}}function za(t,e){const n=new Ba(t,e),i=[],r=[];return{init:function(){i.length=0,r.length=0},state:{lightsArray:i,shadowsArray:r,lights:n},setupLights:function(t){n.setup(i,t)},setupLightsView:function(t){n.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){r.push(t)}}}function Ga(t,e){let n=new WeakMap;return{get:function(i,r=0){const s=n.get(i);let a;return void 0===s?(a=new za(t,e),n.set(i,[a])):r>=s.length?(a=new za(t,e),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}class Ha extends di{constructor(t){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(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Va extends di{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function ka(t,e,i){let o=new gr;const l=new me,c=new me,h=new Be,u=new Ha({depthPacking:3201}),d=new Va,p={},m=i.maxTextureSize,f={[s]:a,[a]:s,2:2},g=new ir({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new me},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),_=g.clone();_.defines.HORIZONTAL_PASS=1;const v=new Ii;v.setAttribute("position",new Mi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Ji(v,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=n;let M=this.type;function S(n,i){const r=e.update(x);g.defines.VSM_SAMPLES!==n.blurSamples&&(g.defines.VSM_SAMPLES=n.blurSamples,_.defines.VSM_SAMPLES=n.blurSamples,g.needsUpdate=!0,_.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Ge(l.x,l.y)),g.uniforms.shadow_pass.value=n.map.texture,g.uniforms.resolution.value=n.mapSize,g.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,r,g,x,null),_.uniforms.shadow_pass.value=n.mapPass.texture,_.uniforms.resolution.value=n.mapSize,_.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,r,_,x,null)}function b(e,n,i,s){let a=null;const o=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==o)a=o;else if(a=!0===i.isPointLight?d:u,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=a.uuid,e=n.uuid;let i=p[t];void 0===i&&(i={},p[t]=i);let r=i[e];void 0===r&&(r=a.clone(),i[e]=r,n.addEventListener("dispose",E)),a=r}if(a.visible=n.visible,a.wireframe=n.wireframe,a.side=s===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:f[n.side],a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial){t.properties.get(a).light=i}return a}function T(n,i,s,a,l){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&l===r)&&(!n.frustumCulled||o.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const r=e.update(n),o=n.material;if(Array.isArray(o)){const e=r.groups;for(let c=0,h=e.length;c<h;c++){const h=e[c],u=o[h.materialIndex];if(u&&u.visible){const e=b(n,u,a,l);n.onBeforeShadow(t,n,i,s,r,e,h),t.renderBufferDirect(s,null,r,e,n,h),n.onAfterShadow(t,n,i,s,r,e,h)}}}else if(o.visible){const e=b(n,o,a,l);n.onBeforeShadow(t,n,i,s,r,e,null),t.renderBufferDirect(s,null,r,e,n,null),n.onAfterShadow(t,n,i,s,r,e,null)}}const c=n.children;for(let t=0,e=c.length;t<e;t++)T(c[t],i,s,a,l)}function E(t){t.target.removeEventListener("dispose",E);for(const e in p){const n=p[e],i=t.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(e,n,i){if(!1===y.enabled)return;if(!1===y.autoUpdate&&!1===y.needsUpdate)return;if(0===e.length)return;const s=t.getRenderTarget(),a=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=M!==r&&this.type===r,f=M===r&&this.type!==r;for(let s=0,a=e.length;s<a;s++){const a=e[s],u=a.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",a,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;l.copy(u.mapSize);const g=u.getFrameExtents();if(l.multiply(g),c.copy(u.mapSize),(l.x>m||l.y>m)&&(l.x>m&&(c.x=Math.floor(m/g.x),l.x=c.x*g.x,u.mapSize.x=c.x),l.y>m&&(c.y=Math.floor(m/g.y),l.y=c.y*g.y,u.mapSize.y=c.y)),null===u.map||!0===p||!0===f){const t=this.type!==r?{minFilter:P,magFilter:P}:{};null!==u.map&&u.map.dispose(),u.map=new Ge(l.x,l.y,t),u.map.texture.name=a.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const _=u.getViewportCount();for(let t=0;t<_;t++){const e=u.getViewport(t);h.set(c.x*e.x,c.y*e.y,c.x*e.z,c.y*e.w),d.viewport(h),u.updateMatrices(a,t),o=u.getFrustum(),T(n,i,u.camera,a,this.type)}!0!==u.isPointLightShadow&&this.type===r&&S(u,i),u.needsUpdate=!1}M=this.type,y.needsUpdate=!1,t.setRenderTarget(s,a,u)}}function Wa(t,e,n){const i=n.isWebGL2;const r=new function(){let e=!1;const n=new Be;let i=null;const r=new Be(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,s,a,o){!0===o&&(e*=a,i*=a,s*=a),n.set(e,i,s,a),!1===r.equals(n)&&(t.clearColor(e,i,s,a),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},s=new function(){let e=!1,n=null,i=null,r=null;return{setTest:function(e){e?j(t.DEPTH_TEST):q(t.DEPTH_TEST)},setMask:function(i){n===i||e||(t.depthMask(i),n=i)},setFunc:function(e){if(i!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}i=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,n=null,i=null,r=null}}},h=new function(){let e=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null;return{setTest:function(n){e||(n?j(t.STENCIL_TEST):q(t.STENCIL_TEST))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,a){i===e&&r===n&&s===a||(t.stencilFunc(e,n,a),i=e,r=n,s=a)},setOp:function(e,n,i){a===e&&o===n&&l===i||(t.stencilOp(e,n,i),a=e,o=n,l=i)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null}}},u=new WeakMap,d=new WeakMap;let p={},m={},f=new WeakMap,g=[],_=null,v=!1,x=null,y=null,M=null,S=null,b=null,T=null,E=null,w=new ci(0,0,0),A=0,R=!1,C=null,L=null,P=null,I=null,U=null;const D=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let N=!1,O=0;const F=t.getParameter(t.VERSION);-1!==F.indexOf("WebGL")?(O=parseFloat(/^WebGL (\d)/.exec(F)[1]),N=O>=1):-1!==F.indexOf("OpenGL ES")&&(O=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),N=O>=2);let B=null,z={};const G=t.getParameter(t.SCISSOR_BOX),H=t.getParameter(t.VIEWPORT),V=(new Be).fromArray(G),k=(new Be).fromArray(H);function W(e,n,r,s){const a=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let o=0;o<r;o++)!i||e!==t.TEXTURE_3D&&e!==t.TEXTURE_2D_ARRAY?t.texImage2D(n+o,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,a):t.texImage3D(n,0,t.RGBA,1,1,s,0,t.RGBA,t.UNSIGNED_BYTE,a);return o}const X={};function j(e){!0!==p[e]&&(t.enable(e),p[e]=!0)}function q(e){!1!==p[e]&&(t.disable(e),p[e]=!1)}X[t.TEXTURE_2D]=W(t.TEXTURE_2D,t.TEXTURE_2D,1),X[t.TEXTURE_CUBE_MAP]=W(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(X[t.TEXTURE_2D_ARRAY]=W(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),X[t.TEXTURE_3D]=W(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),r.setClear(0,0,0,1),s.setClear(1),h.setClear(0),j(t.DEPTH_TEST),s.setFunc(3),K(!1),$(1),j(t.CULL_FACE),J(0);const Y={[o]:t.FUNC_ADD,101:t.FUNC_SUBTRACT,102:t.FUNC_REVERSE_SUBTRACT};if(i)Y[103]=t.MIN,Y[104]=t.MAX;else{const t=e.get("EXT_blend_minmax");null!==t&&(Y[103]=t.MIN_EXT,Y[104]=t.MAX_EXT)}const Z={200:t.ZERO,201:t.ONE,202:t.SRC_COLOR,[l]:t.SRC_ALPHA,210:t.SRC_ALPHA_SATURATE,208:t.DST_COLOR,206:t.DST_ALPHA,203:t.ONE_MINUS_SRC_COLOR,[c]:t.ONE_MINUS_SRC_ALPHA,209:t.ONE_MINUS_DST_COLOR,207:t.ONE_MINUS_DST_ALPHA,211:t.CONSTANT_COLOR,212:t.ONE_MINUS_CONSTANT_COLOR,213:t.CONSTANT_ALPHA,214:t.ONE_MINUS_CONSTANT_ALPHA};function J(e,n,i,r,s,a,l,c,h,u){if(0!==e){if(!1===v&&(j(t.BLEND),v=!0),5===e)s=s||n,a=a||i,l=l||r,n===y&&s===b||(t.blendEquationSeparate(Y[n],Y[s]),y=n,b=s),i===M&&r===S&&a===T&&l===E||(t.blendFuncSeparate(Z[i],Z[r],Z[a],Z[l]),M=i,S=r,T=a,E=l),!1!==c.equals(w)&&h===A||(t.blendColor(c.r,c.g,c.b,h),w.copy(c),A=h),x=e,R=!1;else if(e!==x||u!==R){if(y===o&&b===o||(t.blendEquation(t.FUNC_ADD),y=o,b=o),u)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}M=null,S=null,T=null,E=null,w.set(0,0,0),A=0,x=e,R=u}}else!0===v&&(q(t.BLEND),v=!1)}function K(e){C!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),C=e)}function $(e){0!==e?(j(t.CULL_FACE),e!==L&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):q(t.CULL_FACE),L=e}function Q(e,n,i){e?(j(t.POLYGON_OFFSET_FILL),I===n&&U===i||(t.polygonOffset(n,i),I=n,U=i)):q(t.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:s,stencil:h},enable:j,disable:q,bindFramebuffer:function(e,n){return m[e]!==n&&(t.bindFramebuffer(e,n),m[e]=n,i&&(e===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=n),e===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=n)),!0)},drawBuffers:function(i,r){let s=g,a=!1;if(i)if(s=f.get(r),void 0===s&&(s=[],f.set(r,s)),i.isWebGLMultipleRenderTargets){const e=i.texture;if(s.length!==e.length||s[0]!==t.COLOR_ATTACHMENT0){for(let n=0,i=e.length;n<i;n++)s[n]=t.COLOR_ATTACHMENT0+n;s.length=e.length,a=!0}}else s[0]!==t.COLOR_ATTACHMENT0&&(s[0]=t.COLOR_ATTACHMENT0,a=!0);else s[0]!==t.BACK&&(s[0]=t.BACK,a=!0);a&&(n.isWebGL2?t.drawBuffers(s):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(s))},useProgram:function(e){return _!==e&&(t.useProgram(e),_=e,!0)},setBlending:J,setMaterial:function(e,n){2===e.side?q(t.CULL_FACE):j(t.CULL_FACE);let i=e.side===a;n&&(i=!i),K(i),1===e.blending&&!1===e.transparent?J(0):J(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),s.setFunc(e.depthFunc),s.setTest(e.depthTest),s.setMask(e.depthWrite),r.setMask(e.colorWrite);const o=e.stencilWrite;h.setTest(o),o&&(h.setMask(e.stencilWriteMask),h.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),h.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),Q(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?j(t.SAMPLE_ALPHA_TO_COVERAGE):q(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:K,setCullFace:$,setLineWidth:function(e){e!==P&&(N&&t.lineWidth(e),P=e)},setPolygonOffset:Q,setScissorTest:function(e){e?j(t.SCISSOR_TEST):q(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+D-1),B!==e&&(t.activeTexture(e),B=e)},bindTexture:function(e,n,i){void 0===i&&(i=null===B?t.TEXTURE0+D-1:B);let r=z[i];void 0===r&&(r={type:void 0,texture:void 0},z[i]=r),r.type===e&&r.texture===n||(B!==i&&(t.activeTexture(i),B=i),t.bindTexture(e,n||X[e]),r.type=e,r.texture=n)},unbindTexture:function(){const e=z[B];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,n){let i=d.get(n);void 0===i&&(i=new WeakMap,d.set(n,i));let r=i.get(e);void 0===r&&(r=t.getUniformBlockIndex(n,e.name),i.set(e,r))},uniformBlockBinding:function(e,n){const i=d.get(n).get(e);u.get(n)!==i&&(t.uniformBlockBinding(n,i,e.__bindingPointIndex),u.set(n,i))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===V.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),V.copy(e))},viewport:function(e){!1===k.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),k.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),!0===i&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),p={},B=null,z={},m={},f=new WeakMap,g=[],_=null,v=!1,x=null,y=null,M=null,S=null,b=null,T=null,E=null,w=new ci(0,0,0),A=0,R=!1,C=null,L=null,P=null,I=null,U=null,V.set(0,0,t.canvas.width,t.canvas.height),k.set(0,0,t.canvas.width,t.canvas.height),r.reset(),s.reset(),h.reset()}}}function Xa(t,e,n,i,r,s,a){const o=r.isWebGL2,l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),h=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return p?new OffscreenCanvas(t,e):ye("canvas")}function f(t,e,n,i){let r=1;if((t.width>i||t.height>i)&&(r=i/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const i=e?he:Math.floor,s=i(r*t.width),a=i(r*t.height);void 0===u&&(u=m(s,a));const o=n?m(s,a):u;o.width=s,o.height=a;return o.getContext("2d").drawImage(t,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+s+"x"+a+")."),o}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function g(t){return ce(t.width)&&ce(t.height)}function _(t,e){return t.generateMipmaps&&e&&t.minFilter!==P&&t.minFilter!==D}function v(e){t.generateMipmap(e)}function x(n,i,r,s,a=!1){if(!1===o)return i;if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;if(i===t.RED&&(r===t.FLOAT&&(l=t.R32F),r===t.HALF_FLOAT&&(l=t.R16F),r===t.UNSIGNED_BYTE&&(l=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(l=t.R8UI),r===t.UNSIGNED_SHORT&&(l=t.R16UI),r===t.UNSIGNED_INT&&(l=t.R32UI),r===t.BYTE&&(l=t.R8I),r===t.SHORT&&(l=t.R16I),r===t.INT&&(l=t.R32I)),i===t.RG&&(r===t.FLOAT&&(l=t.RG32F),r===t.HALF_FLOAT&&(l=t.RG16F),r===t.UNSIGNED_BYTE&&(l=t.RG8)),i===t.RGBA){const e=a?Wt:Re.getTransfer(s);r===t.FLOAT&&(l=t.RGBA32F),r===t.HALF_FLOAT&&(l=t.RGBA16F),r===t.UNSIGNED_BYTE&&(l=e===Xt?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(l=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(l=t.RGB5_A1)}return l!==t.R16F&&l!==t.R32F&&l!==t.RG16F&&l!==t.RG32F&&l!==t.RGBA16F&&l!==t.RGBA32F||e.get("EXT_color_buffer_float"),l}function y(t,e,n){return!0===_(t,n)||t.isFramebufferTexture&&t.minFilter!==P&&t.minFilter!==D?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function M(e){return e===P||e===I||e===U?t.NEAREST:t.LINEAR}function S(t){const e=t.target;e.removeEventListener("dispose",S),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=d.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&T(t),0===Object.keys(r).length&&d.delete(n)}i.remove(t)}(e),e.isVideoTexture&&h.delete(e)}function b(e){const n=e.target;n.removeEventListener("dispose",b),function(e){const n=e.texture,r=i.get(e),s=i.get(n);void 0!==s.__webglTexture&&(t.deleteTexture(s.__webglTexture),a.memory.textures--);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(r.__webglFramebuffer[e]))for(let n=0;n<r.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(r.__webglFramebuffer[e][n]);else t.deleteFramebuffer(r.__webglFramebuffer[e]);r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[e])}else{if(Array.isArray(r.__webglFramebuffer))for(let e=0;e<r.__webglFramebuffer.length;e++)t.deleteFramebuffer(r.__webglFramebuffer[e]);else t.deleteFramebuffer(r.__webglFramebuffer);if(r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&t.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let e=0;e<r.__webglColorRenderbuffer.length;e++)r.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(r.__webglColorRenderbuffer[e]);r.__webglDepthRenderbuffer&&t.deleteRenderbuffer(r.__webglDepthRenderbuffer)}if(e.isWebGLMultipleRenderTargets)for(let e=0,r=n.length;e<r;e++){const r=i.get(n[e]);r.__webglTexture&&(t.deleteTexture(r.__webglTexture),a.memory.textures--),i.remove(n[e])}i.remove(n),i.remove(e)}(n)}function T(e){const n=i.get(e);t.deleteTexture(n.__webglTexture);const r=e.source;delete d.get(r)[n.__cacheKey],a.memory.textures--}let E=0;function w(e,r){const s=i.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;h.get(t)!==e&&(h.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void J(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const A={[R]:t.REPEAT,[C]:t.CLAMP_TO_EDGE,[L]:t.MIRRORED_REPEAT},z={[P]:t.NEAREST,[I]:t.NEAREST_MIPMAP_NEAREST,[U]:t.NEAREST_MIPMAP_LINEAR,[D]:t.LINEAR,[N]:t.LINEAR_MIPMAP_NEAREST,[O]:t.LINEAR_MIPMAP_LINEAR},k={512:t.NEVER,519:t.ALWAYS,513:t.LESS,515:t.LEQUAL,514:t.EQUAL,518:t.GEQUAL,516:t.GREATER,517:t.NOTEQUAL};function W(n,s,a){if(a?(t.texParameteri(n,t.TEXTURE_WRAP_S,A[s.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,A[s.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,A[s.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,z[s.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,z[s.minFilter])):(t.texParameteri(n,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(n,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),s.wrapS===C&&s.wrapT===C||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(n,t.TEXTURE_MAG_FILTER,M(s.magFilter)),t.texParameteri(n,t.TEXTURE_MIN_FILTER,M(s.minFilter)),s.minFilter!==P&&s.minFilter!==D&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),s.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,k[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){const a=e.get("EXT_texture_filter_anisotropic");if(s.magFilter===P)return;if(s.minFilter!==U&&s.minFilter!==O)return;if(s.type===H&&!1===e.has("OES_texture_float_linear"))return;if(!1===o&&s.type===V&&!1===e.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||i.get(s).__currentAnisotropy)&&(t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy)}}function Z(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",S));const r=n.source;let s=d.get(r);void 0===s&&(s={},d.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&T(n)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return i}function J(e,a,l){let c=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(c=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(c=t.TEXTURE_3D);const h=Z(e,a),u=a.source;n.bindTexture(c,e.__webglTexture,t.TEXTURE0+l);const d=i.get(u);if(u.version!==d.__version||!0===h){n.activeTexture(t.TEXTURE0+l);const e=Re.getPrimaries(Re.workingColorSpace),i=a.colorSpace===zt?null:Re.getPrimaries(a.colorSpace),p=a.colorSpace===zt||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);const m=function(t){return!o&&(t.wrapS!==C||t.wrapT!==C||t.minFilter!==P&&t.minFilter!==D)}(a)&&!1===g(a.image);let M=f(a.image,m,!1,r.maxTextureSize);M=nt(a,M);const S=g(M)||o,b=s.convert(a.format,a.colorSpace);let T,E=s.convert(a.type),w=x(a.internalFormat,b,E,a.colorSpace,a.isVideoTexture);W(c,a,S);const A=a.mipmaps,R=o&&!0!==a.isVideoTexture&&w!==at,L=void 0===d.__version||!0===h,I=y(a,M,S);if(a.isDepthTexture)w=t.DEPTH_COMPONENT,o?w=a.type===H?t.DEPTH_COMPONENT32F:a.type===G?t.DEPTH_COMPONENT24:a.type===X?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT16:a.type===H&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),a.format===q&&w===t.DEPTH_COMPONENT&&a.type!==B&&a.type!==G&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),a.type=G,E=s.convert(a.type)),a.format===Y&&w===t.DEPTH_COMPONENT&&(w=t.DEPTH_STENCIL,a.type!==X&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),a.type=X,E=s.convert(a.type))),L&&(R?n.texStorage2D(t.TEXTURE_2D,1,w,M.width,M.height):n.texImage2D(t.TEXTURE_2D,0,w,M.width,M.height,0,b,E,null));else if(a.isDataTexture)if(A.length>0&&S){R&&L&&n.texStorage2D(t.TEXTURE_2D,I,w,A[0].width,A[0].height);for(let e=0,i=A.length;e<i;e++)T=A[e],R?n.texSubImage2D(t.TEXTURE_2D,e,0,0,T.width,T.height,b,E,T.data):n.texImage2D(t.TEXTURE_2D,e,w,T.width,T.height,0,b,E,T.data);a.generateMipmaps=!1}else R?(L&&n.texStorage2D(t.TEXTURE_2D,I,w,M.width,M.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,M.width,M.height,b,E,M.data)):n.texImage2D(t.TEXTURE_2D,0,w,M.width,M.height,0,b,E,M.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){R&&L&&n.texStorage3D(t.TEXTURE_2D_ARRAY,I,w,A[0].width,A[0].height,M.depth);for(let e=0,i=A.length;e<i;e++)T=A[e],a.format!==j?null!==b?R?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,T.width,T.height,M.depth,b,T.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,w,T.width,T.height,M.depth,0,T.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):R?n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,T.width,T.height,M.depth,b,E,T.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,w,T.width,T.height,M.depth,0,b,E,T.data)}else{R&&L&&n.texStorage2D(t.TEXTURE_2D,I,w,A[0].width,A[0].height);for(let e=0,i=A.length;e<i;e++)T=A[e],a.format!==j?null!==b?R?n.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,T.width,T.height,b,T.data):n.compressedTexImage2D(t.TEXTURE_2D,e,w,T.width,T.height,0,T.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):R?n.texSubImage2D(t.TEXTURE_2D,e,0,0,T.width,T.height,b,E,T.data):n.texImage2D(t.TEXTURE_2D,e,w,T.width,T.height,0,b,E,T.data)}else if(a.isDataArrayTexture)R?(L&&n.texStorage3D(t.TEXTURE_2D_ARRAY,I,w,M.width,M.height,M.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,M.width,M.height,M.depth,b,E,M.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,w,M.width,M.height,M.depth,0,b,E,M.data);else if(a.isData3DTexture)R?(L&&n.texStorage3D(t.TEXTURE_3D,I,w,M.width,M.height,M.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,M.width,M.height,M.depth,b,E,M.data)):n.texImage3D(t.TEXTURE_3D,0,w,M.width,M.height,M.depth,0,b,E,M.data);else if(a.isFramebufferTexture){if(L)if(R)n.texStorage2D(t.TEXTURE_2D,I,w,M.width,M.height);else{let e=M.width,i=M.height;for(let r=0;r<I;r++)n.texImage2D(t.TEXTURE_2D,r,w,e,i,0,b,E,null),e>>=1,i>>=1}}else if(A.length>0&&S){R&&L&&n.texStorage2D(t.TEXTURE_2D,I,w,A[0].width,A[0].height);for(let e=0,i=A.length;e<i;e++)T=A[e],R?n.texSubImage2D(t.TEXTURE_2D,e,0,0,b,E,T):n.texImage2D(t.TEXTURE_2D,e,w,b,E,T);a.generateMipmaps=!1}else R?(L&&n.texStorage2D(t.TEXTURE_2D,I,w,M.width,M.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,b,E,M)):n.texImage2D(t.TEXTURE_2D,0,w,b,E,M);_(a,S)&&v(c),d.__version=u.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function K(e,r,a,o,c,h){const u=s.convert(a.format,a.colorSpace),d=s.convert(a.type),p=x(a.internalFormat,u,d,a.colorSpace);if(!i.get(r).__hasExternalTextures){const e=Math.max(1,r.width>>h),i=Math.max(1,r.height>>h);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,e,i,r.depth,0,u,d,null):n.texImage2D(c,h,p,e,i,0,u,d,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),et(r)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,o,c,i.get(a).__webglTexture,0,tt(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,o,c,i.get(a).__webglTexture,h),n.bindFramebuffer(t.FRAMEBUFFER,null)}function $(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer&&!n.stencilBuffer){let r=!0===o?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(i||et(n)){const e=n.depthTexture;e&&e.isDepthTexture&&(e.type===H?r=t.DEPTH_COMPONENT32F:e.type===G&&(r=t.DEPTH_COMPONENT24));const i=tt(n);et(n)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,i,r,n.width,n.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,i,r,n.width,n.height)}else t.renderbufferStorage(t.RENDERBUFFER,r,n.width,n.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)}else if(n.depthBuffer&&n.stencilBuffer){const r=tt(n);i&&!1===et(n)?t.renderbufferStorageMultisample(t.RENDERBUFFER,r,t.DEPTH24_STENCIL8,n.width,n.height):et(n)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,r,t.DEPTH24_STENCIL8,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)}else{const e=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r<e.length;r++){const a=e[r],o=s.convert(a.format,a.colorSpace),c=s.convert(a.type),h=x(a.internalFormat,o,c,a.colorSpace),u=tt(n);i&&!1===et(n)?t.renderbufferStorageMultisample(t.RENDERBUFFER,u,h,n.width,n.height):et(n)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,u,h,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,h,n.width,n.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Q(e){const r=i.get(e),s=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),w(r.depthTexture,0);const s=i.get(r.depthTexture).__webglTexture,a=tt(r);if(r.depthTexture.format===q)et(r)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,s,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,s,0);else{if(r.depthTexture.format!==Y)throw new Error("Unknown depthTexture format");et(r)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,s,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,s,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),r.__webglDepthbuffer[i]=t.createRenderbuffer(),$(r.__webglDepthbuffer[i],e,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),$(r.__webglDepthbuffer,e,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function tt(t){return Math.min(r.maxSamples,t.samples)}function et(t){const n=i.get(t);return o&&t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function nt(t,n){const i=t.colorSpace,r=t.format,s=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||t.format===Kt||i!==Ht&&i!==zt&&(Re.getTransfer(i)===Xt?!1===o?!0===e.has("EXT_sRGB")&&r===j?(t.format=Kt,t.minFilter=D,t.generateMipmaps=!1):n=Ie.sRGBToLinear(n):r===j&&s===F||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){const t=E;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),E+=1,t},this.resetTextureUnits=function(){E=0},this.setTexture2D=w,this.setTexture2DArray=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?J(s,e,r):n.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?J(s,e,r):n.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const l=i.get(e);e.version>0&&l.__version!==e.version?function(e,a,l){if(6!==a.image.length)return;const c=Z(e,a),h=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+l);const u=i.get(h);if(h.version!==u.__version||!0===c){n.activeTexture(t.TEXTURE0+l);const e=Re.getPrimaries(Re.workingColorSpace),i=a.colorSpace===zt?null:Re.getPrimaries(a.colorSpace),d=a.colorSpace===zt||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const p=a.isCompressedTexture||a.image[0].isCompressedTexture,m=a.image[0]&&a.image[0].isDataTexture,M=[];for(let t=0;t<6;t++)M[t]=p||m?m?a.image[t].image:a.image[t]:f(a.image[t],!1,!0,r.maxCubemapSize),M[t]=nt(a,M[t]);const S=M[0],b=g(S)||o,T=s.convert(a.format,a.colorSpace),E=s.convert(a.type),w=x(a.internalFormat,T,E,a.colorSpace),A=o&&!0!==a.isVideoTexture,R=void 0===u.__version||!0===c;let C,L=y(a,S,b);if(W(t.TEXTURE_CUBE_MAP,a,b),p){A&&R&&n.texStorage2D(t.TEXTURE_CUBE_MAP,L,w,S.width,S.height);for(let e=0;e<6;e++){C=M[e].mipmaps;for(let i=0;i<C.length;i++){const r=C[i];a.format!==j?null!==T?A?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,T,r.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,w,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):A?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,T,E,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,w,r.width,r.height,0,T,E,r.data)}}}else{C=a.mipmaps,A&&R&&(C.length>0&&L++,n.texStorage2D(t.TEXTURE_CUBE_MAP,L,w,M[0].width,M[0].height));for(let e=0;e<6;e++)if(m){A?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,M[e].width,M[e].height,T,E,M[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,w,M[e].width,M[e].height,0,T,E,M[e].data);for(let i=0;i<C.length;i++){const r=C[i].image[e].image;A?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,r.width,r.height,T,E,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,w,r.width,r.height,0,T,E,r.data)}}else{A?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,T,E,M[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,w,T,E,M[e]);for(let i=0;i<C.length;i++){const r=C[i];A?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,T,E,r.image[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,w,T,E,r.image[e])}}}_(a,b)&&v(t.TEXTURE_CUBE_MAP),u.__version=h.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(l,e,a):n.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,n,r){const s=i.get(e);void 0!==n&&K(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&Q(e)},this.setupRenderTarget=function(e){const l=e.texture,c=i.get(e),h=i.get(l);e.addEventListener("dispose",b),!0!==e.isWebGLMultipleRenderTargets&&(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=l.version,a.memory.textures++);const u=!0===e.isWebGLCubeRenderTarget,d=!0===e.isWebGLMultipleRenderTargets,p=g(e)||o;if(u){c.__webglFramebuffer=[];for(let e=0;e<6;e++)if(o&&l.mipmaps&&l.mipmaps.length>0){c.__webglFramebuffer[e]=[];for(let n=0;n<l.mipmaps.length;n++)c.__webglFramebuffer[e][n]=t.createFramebuffer()}else c.__webglFramebuffer[e]=t.createFramebuffer()}else{if(o&&l.mipmaps&&l.mipmaps.length>0){c.__webglFramebuffer=[];for(let e=0;e<l.mipmaps.length;e++)c.__webglFramebuffer[e]=t.createFramebuffer()}else c.__webglFramebuffer=t.createFramebuffer();if(d)if(r.drawBuffers){const n=e.texture;for(let e=0,r=n.length;e<r;e++){const r=i.get(n[e]);void 0===r.__webglTexture&&(r.__webglTexture=t.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&e.samples>0&&!1===et(e)){const i=d?l:[l];c.__webglMultisampledFramebuffer=t.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n<i.length;n++){const r=i[n];c.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,c.__webglColorRenderbuffer[n]);const a=s.convert(r.format,r.colorSpace),o=s.convert(r.type),l=x(r.internalFormat,a,o,r.colorSpace,!0===e.isXRRenderTarget),h=tt(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,h,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,c.__webglColorRenderbuffer[n])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(c.__webglDepthRenderbuffer=t.createRenderbuffer(),$(c.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(u){n.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),W(t.TEXTURE_CUBE_MAP,l,p);for(let n=0;n<6;n++)if(o&&l.mipmaps&&l.mipmaps.length>0)for(let i=0;i<l.mipmaps.length;i++)K(c.__webglFramebuffer[n][i],e,l,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else K(c.__webglFramebuffer[n],e,l,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);_(l,p)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){const r=e.texture;for(let s=0,a=r.length;s<a;s++){const a=r[s],o=i.get(a);n.bindTexture(t.TEXTURE_2D,o.__webglTexture),W(t.TEXTURE_2D,a,p),K(c.__webglFramebuffer,e,a,t.COLOR_ATTACHMENT0+s,t.TEXTURE_2D,0),_(a,p)&&v(t.TEXTURE_2D)}n.unbindTexture()}else{let i=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(o?i=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(i,h.__webglTexture),W(i,l,p),o&&l.mipmaps&&l.mipmaps.length>0)for(let n=0;n<l.mipmaps.length;n++)K(c.__webglFramebuffer[n],e,l,t.COLOR_ATTACHMENT0,i,n);else K(c.__webglFramebuffer,e,l,t.COLOR_ATTACHMENT0,i,0);_(l,p)&&v(i),n.unbindTexture()}e.depthBuffer&&Q(e)},this.updateRenderTargetMipmap=function(e){const r=g(e)||o,s=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let a=0,o=s.length;a<o;a++){const o=s[a];if(_(o,r)){const r=e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,s=i.get(o).__webglTexture;n.bindTexture(r,s),v(r),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(o&&e.samples>0&&!1===et(e)){const r=e.isWebGLMultipleRenderTargets?e.texture:[e.texture],s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=[],h=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,u=i.get(e),d=!0===e.isWebGLMultipleRenderTargets;if(d)for(let e=0;e<r.length;e++)n.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<r.length;n++){l.push(t.COLOR_ATTACHMENT0+n),e.depthBuffer&&l.push(h);const p=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===p&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,u.__webglColorRenderbuffer[n]),!0===p&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[h]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[h])),d){const e=i.get(r[n]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),c&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,l)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){n.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,u.__webglColorRenderbuffer[e]);const s=i.get(r[e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=Q,this.setupFrameBufferTexture=K,this.useMultisampledRTT=et}function ja(t,e,n){const i=n.isWebGL2;return{convert:function(n,r=""){let s;const a=Re.getTransfer(r);if(n===F)return t.UNSIGNED_BYTE;if(n===k)return t.UNSIGNED_SHORT_4_4_4_4;if(n===W)return t.UNSIGNED_SHORT_5_5_5_1;if(1010===n)return t.BYTE;if(1011===n)return t.SHORT;if(n===B)return t.UNSIGNED_SHORT;if(n===z)return t.INT;if(n===G)return t.UNSIGNED_INT;if(n===H)return t.FLOAT;if(n===V)return i?t.HALF_FLOAT:(s=e.get("OES_texture_half_float"),null!==s?s.HALF_FLOAT_OES:null);if(1021===n)return t.ALPHA;if(n===j)return t.RGBA;if(1024===n)return t.LUMINANCE;if(1025===n)return t.LUMINANCE_ALPHA;if(n===q)return t.DEPTH_COMPONENT;if(n===Y)return t.DEPTH_STENCIL;if(n===Kt)return s=e.get("EXT_sRGB"),null!==s?s.SRGB_ALPHA_EXT:null;if(1028===n)return t.RED;if(n===Z)return t.RED_INTEGER;if(1030===n)return t.RG;if(n===J)return t.RG_INTEGER;if(n===K)return t.RGBA_INTEGER;if(n===$||n===Q||n===tt||n===et)if(a===Xt){if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===s)return null;if(n===$)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Q)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===tt)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===et)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(s=e.get("WEBGL_compressed_texture_s3tc"),null===s)return null;if(n===$)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Q)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===tt)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===et)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===nt||n===it||n===rt||n===st){if(s=e.get("WEBGL_compressed_texture_pvrtc"),null===s)return null;if(n===nt)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===it)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===rt)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===st)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===at)return s=e.get("WEBGL_compressed_texture_etc1"),null!==s?s.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===ot||n===lt){if(s=e.get("WEBGL_compressed_texture_etc"),null===s)return null;if(n===ot)return a===Xt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===lt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}if(n===ct||n===ht||n===ut||n===dt||n===pt||n===mt||n===ft||n===gt||n===_t||n===vt||n===xt||n===yt||n===Mt||n===St){if(s=e.get("WEBGL_compressed_texture_astc"),null===s)return null;if(n===ct)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ht)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ut)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===dt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===pt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===mt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ft)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===gt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===_t)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===vt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===xt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===yt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Mt)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===St)return a===Xt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===bt||n===Tt||n===Et){if(s=e.get("EXT_texture_compression_bptc"),null===s)return null;if(n===bt)return a===Xt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Tt)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Et)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===n||n===wt||n===At||n===Rt){if(s=e.get("EXT_texture_compression_rgtc"),null===s)return null;if(n===bt)return s.COMPRESSED_RED_RGTC1_EXT;if(n===wt)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===At)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Rt)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===X?i?t.UNSIGNED_INT_24_8:(s=e.get("WEBGL_depth_texture"),null!==s?s.UNSIGNED_INT_24_8_WEBGL:null):void 0!==t[n]?t[n]:null}}}class qa extends sr{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Ya extends jn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Za={type:"move"};class Ja{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Ya,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Ya,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new We,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new We),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Ya,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new We,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new We),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){s=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n),r=this._getHandJoint(l,i);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=i.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&a>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Za)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new Ya;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class Ka extends te{constructor(t,e){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const m=e.getContextAttributes();let f=null,g=null;const _=[],v=[],x=new me;let y=null;const M=new sr;M.layers.enable(1),M.viewport=new Be;const S=new sr;S.layers.enable(2),S.viewport=new Be;const b=[M,S],T=new qa;T.layers.enable(1),T.layers.enable(2);let E=null,w=null;function A(t){const e=v.indexOf(t.inputSource);if(-1===e)return;const n=_[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||s),n.dispatchEvent({type:t.type,data:t.inputSource}))}function R(){i.removeEventListener("select",A),i.removeEventListener("selectstart",A),i.removeEventListener("selectend",A),i.removeEventListener("squeeze",A),i.removeEventListener("squeezestart",A),i.removeEventListener("squeezeend",A),i.removeEventListener("end",R),i.removeEventListener("inputsourceschange",C);for(let t=0;t<_.length;t++){const e=v[t];null!==e&&(v[t]=null,_[t].disconnect(e))}E=null,w=null,t.setRenderTarget(f),d=null,u=null,h=null,i=null,g=null,D.stop(),n.isPresenting=!1,t.setPixelRatio(y),t.setSize(x.width,x.height,!1),n.dispatchEvent({type:"sessionend"})}function C(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=v.indexOf(n);i>=0&&(v[i]=null,_[i].disconnect(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let i=v.indexOf(n);if(-1===i){for(let t=0;t<_.length;t++){if(t>=v.length){v.push(n),i=t;break}if(null===v[t]){v[t]=n,i=t;break}}if(-1===i)break}const r=_[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=_[t];return void 0===e&&(e=new Ja,_[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=_[t];return void 0===e&&(e=new Ja,_[t]=e),e.getGripSpace()},this.getHand=function(t){let e=_[t];return void 0===e&&(e=new Ja,_[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(f=t.getRenderTarget(),i.addEventListener("select",A),i.addEventListener("selectstart",A),i.addEventListener("selectend",A),i.addEventListener("squeeze",A),i.addEventListener("squeezestart",A),i.addEventListener("squeezeend",A),i.addEventListener("end",R),i.addEventListener("inputsourceschange",C),!0!==m.xrCompatible&&await e.makeXRCompatible(),y=t.getPixelRatio(),t.getSize(x),void 0===i.renderState.layers||!1===t.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),g=new Ge(d.framebufferWidth,d.framebufferHeight,{format:j,type:F,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=m.stencil?Y:q,s=m.stencil?X:G);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,e),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),g=new Ge(u.textureWidth,u.textureHeight,{format:j,type:F,depthTexture:new ns(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0});t.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),D.setContext(i),D.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};const L=new We,P=new We;function I(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;T.near=S.near=M.near=t.near,T.far=S.far=M.far=t.far,E===T.near&&w===T.far||(i.updateRenderState({depthNear:T.near,depthFar:T.far}),E=T.near,w=T.far);const e=t.parent,n=T.cameras;I(T,e);for(let t=0;t<n.length;t++)I(n[t],e);2===n.length?function(t,e,n){L.setFromMatrixPosition(e.matrixWorld),P.setFromMatrixPosition(n.matrixWorld);const i=L.distanceTo(P),r=e.projectionMatrix.elements,s=n.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],h=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=a*h,p=a*u,m=i/(-h+u),f=m*-h;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=a+m,_=o+m,v=d-f,x=p+(i-f),y=l*o/_*g,M=c*o/_*g;t.projectionMatrix.makePerspective(v,x,y,M,g,_),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}(T,M,S):T.projectionMatrix.copy(M.projectionMatrix),function(t,e,n){null===n?t.matrix.copy(e.matrixWorld):(t.matrix.copy(n.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*re*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,T,e)},this.getCamera=function(){return T},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(t){o=t,null!==u&&(u.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)};let U=null;const D=new _r;D.setAnimationLoop((function(e,i){if(c=i.getViewerPose(l||s),p=i,null!==c){const e=c.views;null!==d&&(t.setRenderTargetFramebuffer(g,d.framebuffer),t.setRenderTarget(g));let n=!1;e.length!==T.cameras.length&&(T.cameras.length=0,n=!0);for(let i=0;i<e.length;i++){const r=e[i];let s=null;if(null!==d)s=d.getViewport(r);else{const e=h.getViewSubImage(u,r);s=e.viewport,0===i&&(t.setRenderTargetTextures(g,e.colorTexture,u.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(g))}let a=b[i];void 0===a&&(a=new sr,a.layers.enable(i),a.viewport=new Be,b[i]=a),a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(r.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(T.matrix.copy(a.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),!0===n&&T.cameras.push(a)}}for(let t=0;t<_.length;t++){const e=v[t],n=_[t];null!==e&&void 0!==n&&n.update(e,i,l||s)}U&&U(e,i),i.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:i}),p=null})),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}function $a(t,e){function n(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function i(i,r){i.opacity.value=r.opacity,r.color&&i.diffuse.value.copy(r.color),r.emissive&&i.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(i.map.value=r.map,n(r.map,i.mapTransform)),r.alphaMap&&(i.alphaMap.value=r.alphaMap,n(r.alphaMap,i.alphaMapTransform)),r.bumpMap&&(i.bumpMap.value=r.bumpMap,n(r.bumpMap,i.bumpMapTransform),i.bumpScale.value=r.bumpScale,r.side===a&&(i.bumpScale.value*=-1)),r.normalMap&&(i.normalMap.value=r.normalMap,n(r.normalMap,i.normalMapTransform),i.normalScale.value.copy(r.normalScale),r.side===a&&i.normalScale.value.negate()),r.displacementMap&&(i.displacementMap.value=r.displacementMap,n(r.displacementMap,i.displacementMapTransform),i.displacementScale.value=r.displacementScale,i.displacementBias.value=r.displacementBias),r.emissiveMap&&(i.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,i.emissiveMapTransform)),r.specularMap&&(i.specularMap.value=r.specularMap,n(r.specularMap,i.specularMapTransform)),r.alphaTest>0&&(i.alphaTest.value=r.alphaTest);const s=e.get(r).envMap;if(s&&(i.envMap.value=s,i.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;const e=!0===t._useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*e,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,er(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,s,o,l){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,i){t.metalness.value=i.metalness,i.metalnessMap&&(t.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,t.metalnessMapTransform));t.roughness.value=i.roughness,i.roughnessMap&&(t.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,t.roughnessMapTransform));const r=e.get(i).envMap;r&&(t.envMapIntensity.value=i.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===a&&t.clearcoatNormalScale.value.negate()));e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,l)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,o):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Qa(t,e,n,i){let r={},s={},a=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(t,e,n,i){const r=t.value,s=e+"_"+n;if(void 0===i[s])return i[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const n=e.target;n.removeEventListener("dispose",h);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,u){let d=r[n.id];void 0===d&&(!function(t){const e=t.uniforms;let n=0;const i=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=c(s[t]),a=n%i;0!==a&&i-a<r.boundary&&(n+=i-a),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);t.__size=n,t.__cache={}}(n),d=function(e){const n=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=n;const i=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=d,n.addEventListener("dispose",h));const p=u.program;i.updateUBOMapping(n,p);const m=e.render.frame;s[n.id]!==m&&(!function(e){const n=r[e.id],i=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,n);for(let e=0,n=i.length;e<n;e++){const n=Array.isArray(i[e])?i[e]:[i[e]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,e,i,s)){const e=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let s=0;s<n.length;s++){const a=n[s],o=c(a);"number"==typeof a||"boolean"==typeof a?(r.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+i,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):(a.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(n),s[n.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}class to{constructor(t={}){const{canvas:n=Me(),context:i=null,depth:r=!0,stencil:o=!0,alpha:l=!1,antialias:c=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:m=!1}=t;let f;this.isWebGLRenderer=!0,f=null!==i?i.getContextAttributes().alpha:l;const g=new Uint32Array(4),_=new Int32Array(4);let v=null,x=null;const y=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Gt,this._useLegacyLights=!1,this.toneMapping=p,this.toneMappingExposure=1;const S=this;let b=!1,T=0,E=0,w=null,A=-1,R=null;const C=new Be,L=new Be;let P=null;const I=new ci(0);let U=0,D=n.width,N=n.height,z=1,q=null,Y=null;const $=new Be(0,0,D,N),Q=new Be(0,0,D,N);let tt=!1;const et=new gr;let nt=!1,it=!1,rt=null;const st=new Mn,at=new me,ot=new We,lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ct(){return null===w?z:1}let ht,ut,dt,pt,mt,ft,gt,_t,vt,xt,yt,Mt,St,bt,Tt,Et,wt,At,Rt,Ct,Lt,Pt,It,Ut,Dt=i;function Nt(t,e){for(let i=0;i<t.length;i++){const r=t[i],s=n.getContext(r,e);if(null!==s)return s}return null}try{const t={alpha:!0,depth:r,stencil:o,antialias:c,premultipliedAlpha:h,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:m};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${e}`),n.addEventListener("webglcontextlost",Bt,!1),n.addEventListener("webglcontextrestored",zt,!1),n.addEventListener("webglcontextcreationerror",Vt,!1),null===Dt){const e=["webgl2","webgl","experimental-webgl"];if(!0===S.isWebGL1Renderer&&e.shift(),Dt=Nt(e,t),null===Dt)throw Nt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}"undefined"!=typeof WebGLRenderingContext&&Dt instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===Dt.getShaderPrecisionFormat&&(Dt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Ot(){ht=new Yr(Dt),ut=new Ar(Dt,ht,t),ht.init(ut),Pt=new ja(Dt,ht,ut),dt=new Wa(Dt,ht,ut),pt=new Kr(Dt),mt=new La,ft=new Xa(Dt,ht,dt,mt,ut,Pt,pt),gt=new Cr(S),_t=new qr(S),vt=new vr(Dt,ut),It=new Er(Dt,ht,vt,ut),xt=new Zr(Dt,vt,pt,It),yt=new es(Dt,xt,vt,pt),Rt=new ts(Dt,ut,ft),Et=new Rr(mt),Mt=new Ca(S,gt,_t,ht,ut,It,Et),St=new $a(S,mt),bt=new Da,Tt=new Ga(ht,ut),At=new Tr(S,gt,_t,dt,yt,f,h),wt=new ka(S,yt,ut),Ut=new Qa(Dt,pt,ut,dt),Ct=new wr(Dt,ht,pt,ut),Lt=new Jr(Dt,ht,pt,ut),pt.programs=Mt.programs,S.capabilities=ut,S.extensions=ht,S.properties=mt,S.renderLists=bt,S.shadowMap=wt,S.state=dt,S.info=pt}Ot();const Ft=new Ka(S,Dt);function Bt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function zt(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const t=pt.autoReset,e=wt.enabled,n=wt.autoUpdate,i=wt.needsUpdate,r=wt.type;Ot(),pt.autoReset=t,wt.enabled=e,wt.autoUpdate=n,wt.needsUpdate=i,wt.type=r}function Vt(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function kt(t){const e=t.target;e.removeEventListener("dispose",kt),function(t){(function(t){const e=mt.get(t).programs;void 0!==e&&(e.forEach((function(t){Mt.releaseProgram(t)})),t.isShaderMaterial&&Mt.releaseShaderCache(t))})(t),mt.remove(t)}(e)}function Wt(t,e,n){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=a,t.needsUpdate=!0,Qt(t,e,n),t.side=s,t.needsUpdate=!0,Qt(t,e,n),t.side=2):Qt(t,e,n)}this.xr=Ft,this.getContext=function(){return Dt},this.getContextAttributes=function(){return Dt.getContextAttributes()},this.forceContextLoss=function(){const t=ht.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=ht.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return z},this.setPixelRatio=function(t){void 0!==t&&(z=t,this.setSize(D,N,!1))},this.getSize=function(t){return t.set(D,N)},this.setSize=function(t,e,i=!0){Ft.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(D=t,N=e,n.width=Math.floor(t*z),n.height=Math.floor(e*z),!0===i&&(n.style.width=t+"px",n.style.height=e+"px"),this.setViewport(0,0,t,e))},this.getDrawingBufferSize=function(t){return t.set(D*z,N*z).floor()},this.setDrawingBufferSize=function(t,e,i){D=t,N=e,z=i,n.width=Math.floor(t*i),n.height=Math.floor(e*i),this.setViewport(0,0,t,e)},this.getCurrentViewport=function(t){return t.copy(C)},this.getViewport=function(t){return t.copy($)},this.setViewport=function(t,e,n,i){t.isVector4?$.set(t.x,t.y,t.z,t.w):$.set(t,e,n,i),dt.viewport(C.copy($).multiplyScalar(z).floor())},this.getScissor=function(t){return t.copy(Q)},this.setScissor=function(t,e,n,i){t.isVector4?Q.set(t.x,t.y,t.z,t.w):Q.set(t,e,n,i),dt.scissor(L.copy(Q).multiplyScalar(z).floor())},this.getScissorTest=function(){return tt},this.setScissorTest=function(t){dt.setScissorTest(tt=t)},this.setOpaqueSort=function(t){q=t},this.setTransparentSort=function(t){Y=t},this.getClearColor=function(t){return t.copy(At.getClearColor())},this.setClearColor=function(){At.setClearColor.apply(At,arguments)},this.getClearAlpha=function(){return At.getClearAlpha()},this.setClearAlpha=function(){At.setClearAlpha.apply(At,arguments)},this.clear=function(t=!0,e=!0,n=!0){let i=0;if(t){let t=!1;if(null!==w){const e=w.texture.format;t=e===K||e===J||e===Z}if(t){const t=w.texture.type,e=t===F||t===G||t===B||t===X||t===k||t===W,n=At.getClearColor(),i=At.getClearAlpha(),r=n.r,s=n.g,a=n.b;e?(g[0]=r,g[1]=s,g[2]=a,g[3]=i,Dt.clearBufferuiv(Dt.COLOR,0,g)):(_[0]=r,_[1]=s,_[2]=a,_[3]=i,Dt.clearBufferiv(Dt.COLOR,0,_))}else i|=Dt.COLOR_BUFFER_BIT}e&&(i|=Dt.DEPTH_BUFFER_BIT),n&&(i|=Dt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Dt.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Bt,!1),n.removeEventListener("webglcontextrestored",zt,!1),n.removeEventListener("webglcontextcreationerror",Vt,!1),bt.dispose(),Tt.dispose(),mt.dispose(),gt.dispose(),_t.dispose(),yt.dispose(),It.dispose(),Ut.dispose(),Mt.dispose(),Ft.dispose(),Ft.removeEventListener("sessionstart",jt),Ft.removeEventListener("sessionend",qt),rt&&(rt.dispose(),rt=null),Yt.stop()},this.renderBufferDirect=function(t,e,n,i,r,s){null===e&&(e=lt);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,n,i,r){!0!==e.isScene&&(e=lt);ft.resetTextureUnits();const s=e.fog,a=i.isMeshStandardMaterial?e.environment:null,o=null===w?S.outputColorSpace:!0===w.isXRRenderTarget?w.texture.colorSpace:Ht,l=(i.isMeshStandardMaterial?_t:gt).get(i.envMap||a),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,h=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,m=!!n.morphAttributes.color;let f=p;i.toneMapped&&(null!==w&&!0!==w.isXRRenderTarget||(f=S.toneMapping));const g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=void 0!==g?g.length:0,v=mt.get(i),y=x.state.lights;if(!0===nt&&(!0===it||t!==R)){const e=t===R&&i.id===A;Et.setState(i,t,e)}let M=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?M=!0:r.isBatchedMesh||!0!==v.batching?r.isInstancedMesh&&!1===v.instancing?M=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?M=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||v.envMap!==l||!0===i.fog&&v.fog!==s?M=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===Et.numPlanes&&v.numIntersection===Et.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==d||v.morphColors!==m||v.toneMapping!==f||!0===ut.isWebGL2&&v.morphTargetsCount!==_)&&(M=!0):M=!0:M=!0:M=!0:M=!0:(M=!0,v.__version=i.version);let b=v.currentProgram;!0===M&&(b=Qt(i,e,r));let T=!1,E=!1,C=!1;const L=b.getUniforms(),P=v.uniforms;dt.useProgram(b.program)&&(T=!0,E=!0,C=!0);i.id!==A&&(A=i.id,E=!0);if(T||R!==t){L.setValue(Dt,"projectionMatrix",t.projectionMatrix),L.setValue(Dt,"viewMatrix",t.matrixWorldInverse);const e=L.map.cameraPosition;void 0!==e&&e.setValue(Dt,ot.setFromMatrixPosition(t.matrixWorld)),ut.logarithmicDepthBuffer&&L.setValue(Dt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&L.setValue(Dt,"isOrthographic",!0===t.isOrthographicCamera),R!==t&&(R=t,E=!0,C=!0)}if(r.isSkinnedMesh){L.setOptional(Dt,r,"bindMatrix"),L.setOptional(Dt,r,"bindMatrixInverse");const t=r.skeleton;t&&(ut.floatVertexTextures?(null===t.boneTexture&&t.computeBoneTexture(),L.setValue(Dt,"boneTexture",t.boneTexture,ft)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}r.isBatchedMesh&&(L.setOptional(Dt,r,"batchingTexture"),L.setValue(Dt,"batchingTexture",r._matricesTexture,ft));const I=n.morphAttributes;(void 0!==I.position||void 0!==I.normal||void 0!==I.color&&!0===ut.isWebGL2)&&Rt.update(r,n,b);(E||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,L.setValue(Dt,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);E&&(L.setValue(Dt,"toneMappingExposure",S.toneMappingExposure),v.needsLights&&(D=C,(U=P).ambientLightColor.needsUpdate=D,U.lightProbe.needsUpdate=D,U.directionalLights.needsUpdate=D,U.directionalLightShadows.needsUpdate=D,U.pointLights.needsUpdate=D,U.pointLightShadows.needsUpdate=D,U.spotLights.needsUpdate=D,U.spotLightShadows.needsUpdate=D,U.rectAreaLights.needsUpdate=D,U.hemisphereLights.needsUpdate=D),s&&!0===i.fog&&St.refreshFogUniforms(P,s),St.refreshMaterialUniforms(P,i,z,N,rt),oa.upload(Dt,te(v),P,ft));var U,D;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(oa.upload(Dt,te(v),P,ft),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&L.setValue(Dt,"center",r.center);if(L.setValue(Dt,"modelViewMatrix",r.modelViewMatrix),L.setValue(Dt,"normalMatrix",r.normalMatrix),L.setValue(Dt,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e<n;e++)if(ut.isWebGL2){const n=t[e];Ut.update(n,b),Ut.bind(n,b)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return b}(t,e,n,i,r);dt.setMaterial(i,a);let l=n.index,c=1;if(!0===i.wireframe){if(l=xt.getWireframeAttribute(n),void 0===l)return;c=2}const h=n.drawRange,u=n.attributes.position;let d=h.start*c,m=(h.start+h.count)*c;null!==s&&(d=Math.max(d,s.start*c),m=Math.min(m,(s.start+s.count)*c)),null!==l?(d=Math.max(d,0),m=Math.min(m,l.count)):null!=u&&(d=Math.max(d,0),m=Math.min(m,u.count));const f=m-d;if(f<0||f===1/0)return;let g;It.setup(r,i,o,n,l);let _=Ct;if(null!==l&&(g=vt.get(l),_=Lt,_.setIndex(g)),r.isMesh)!0===i.wireframe?(dt.setLineWidth(i.wireframeLinewidth*ct()),_.setMode(Dt.LINES)):_.setMode(Dt.TRIANGLES);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),dt.setLineWidth(t*ct()),r.isLineSegments?_.setMode(Dt.LINES):r.isLineLoop?_.setMode(Dt.LINE_LOOP):_.setMode(Dt.LINE_STRIP)}else r.isPoints?_.setMode(Dt.POINTS):r.isSprite&&_.setMode(Dt.TRIANGLES);if(r.isBatchedMesh)_.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else if(r.isInstancedMesh)_.renderInstances(d,f,r.count);else if(n.isInstancedBufferGeometry){const t=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,e=Math.min(n.instanceCount,t);_.renderInstances(d,f,e)}else _.render(d,f)},this.compile=function(t,e,n=null){null===n&&(n=t),x=Tt.get(n),x.init(),M.push(x),n.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(x.pushLight(t),t.castShadow&&x.pushShadow(t))})),t!==n&&t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(x.pushLight(t),t.castShadow&&x.pushShadow(t))})),x.setupLights(S._useLegacyLights);const i=new Set;return t.traverse((function(t){const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=e[r];Wt(s,n,t),i.add(s)}else Wt(e,n,t),i.add(e)})),M.pop(),x=null,i},this.compileAsync=function(t,e,n=null){const i=this.compile(t,e,n);return new Promise((e=>{function n(){i.forEach((function(t){mt.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==ht.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Xt=null;function jt(){Yt.stop()}function qt(){Yt.start()}const Yt=new _r;function Zt(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)x.pushLight(t),t.castShadow&&x.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||et.intersectsSprite(t)){i&&ot.setFromMatrixPosition(t.matrixWorld).applyMatrix4(st);const e=yt.update(t),r=t.material;r.visible&&v.push(t,e,r,n,ot.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||et.intersectsObject(t))){const e=yt.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),ot.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),ot.copy(e.boundingSphere.center)),ot.applyMatrix4(t.matrixWorld).applyMatrix4(st)),Array.isArray(r)){const i=e.groups;for(let s=0,a=i.length;s<a;s++){const a=i[s],o=r[a.materialIndex];o&&o.visible&&v.push(t,e,o,n,ot.z,a)}}else r.visible&&v.push(t,e,r,n,ot.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)Zt(r[t],e,n,i)}function Jt(t,e,n,i){const r=t.opaque,s=t.transmissive,o=t.transparent;x.setupLightsView(n),!0===nt&&Et.setGlobalState(S.clippingPlanes,n),s.length>0&&function(t,e,n,i){const r=!0===n.isScene?n.overrideMaterial:null;if(null!==r)return;const s=ut.isWebGL2;null===rt&&(rt=new Ge(1,1,{generateMipmaps:!0,type:ht.has("EXT_color_buffer_half_float")?V:F,minFilter:O,samples:s?4:0}));S.getDrawingBufferSize(at),s?rt.setSize(at.x,at.y):rt.setSize(he(at.x),he(at.y));const o=S.getRenderTarget();S.setRenderTarget(rt),S.getClearColor(I),U=S.getClearAlpha(),U<1&&S.setClearColor(16777215,.5);S.clear();const l=S.toneMapping;S.toneMapping=p,Kt(t,n,i),ft.updateMultisampleRenderTarget(rt),ft.updateRenderTargetMipmap(rt);let c=!1;for(let t=0,r=e.length;t<r;t++){const r=e[t],s=r.object,o=r.geometry,l=r.material,h=r.group;if(2===l.side&&s.layers.test(i.layers)){const t=l.side;l.side=a,l.needsUpdate=!0,$t(s,n,i,o,l,h),l.side=t,l.needsUpdate=!0,c=!0}}!0===c&&(ft.updateMultisampleRenderTarget(rt),ft.updateRenderTargetMipmap(rt));S.setRenderTarget(o),S.setClearColor(I,U),S.toneMapping=l}(r,s,e,n),i&&dt.viewport(C.copy(i)),r.length>0&&Kt(r,e,n),s.length>0&&Kt(s,e,n),o.length>0&&Kt(o,e,n),dt.buffers.depth.setTest(!0),dt.buffers.depth.setMask(!0),dt.buffers.color.setMask(!0),dt.setPolygonOffset(!1)}function Kt(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],a=s.object,o=s.geometry,l=null===i?s.material:i,c=s.group;a.layers.test(n.layers)&&$t(a,e,n,o,l,c)}}function $t(t,e,n,i,r,o){t.onBeforeRender(S,e,n,i,r,o),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(S,e,n,i,t,o),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=a,r.needsUpdate=!0,S.renderBufferDirect(n,e,i,r,t,o),r.side=s,r.needsUpdate=!0,S.renderBufferDirect(n,e,i,r,t,o),r.side=2):S.renderBufferDirect(n,e,i,r,t,o),t.onAfterRender(S,e,n,i,r,o)}function Qt(t,e,n){!0!==e.isScene&&(e=lt);const i=mt.get(t),r=x.state.lights,s=x.state.shadowsArray,a=r.state.version,o=Mt.getParameters(t,r.state,s,e,n),l=Mt.getProgramCacheKey(o);let c=i.programs;i.environment=t.isMeshStandardMaterial?e.environment:null,i.fog=e.fog,i.envMap=(t.isMeshStandardMaterial?_t:gt).get(t.envMap||i.environment),void 0===c&&(t.addEventListener("dispose",kt),c=new Map,i.programs=c);let h=c.get(l);if(void 0!==h){if(i.currentProgram===h&&i.lightsStateVersion===a)return ee(t,o),h}else o.uniforms=Mt.getUniforms(t),t.onBuild(n,o,S),t.onBeforeCompile(o,S),h=Mt.acquireProgram(o,l),c.set(l,h),i.uniforms=o.uniforms;const u=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=Et.uniform),ee(t,o),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=a,i.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=h,i.uniformsList=null,h}function te(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=oa.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function ee(t,e){const n=mt.get(t);n.outputColorSpace=e.outputColorSpace,n.batching=e.batching,n.instancing=e.instancing,n.instancingColor=e.instancingColor,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}Yt.setAnimationLoop((function(t){Xt&&Xt(t)})),"undefined"!=typeof self&&Yt.setContext(self),this.setAnimationLoop=function(t){Xt=t,Ft.setAnimationLoop(t),null===t?Yt.stop():Yt.start()},Ft.addEventListener("sessionstart",jt),Ft.addEventListener("sessionend",qt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===b)return;!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Ft.enabled&&!0===Ft.isPresenting&&(!0===Ft.cameraAutoUpdate&&Ft.updateCamera(e),e=Ft.getCamera()),!0===t.isScene&&t.onBeforeRender(S,t,e,w),x=Tt.get(t,M.length),x.init(),M.push(x),st.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),et.setFromProjectionMatrix(st),it=this.localClippingEnabled,nt=Et.init(this.clippingPlanes,it),v=bt.get(t,y.length),v.init(),y.push(v),Zt(t,e,0,S.sortObjects),v.finish(),!0===S.sortObjects&&v.sort(q,Y),this.info.render.frame++,!0===nt&&Et.beginShadows();const n=x.state.shadowsArray;if(wt.render(n,t,e),!0===nt&&Et.endShadows(),!0===this.info.autoReset&&this.info.reset(),At.render(v,t),x.setupLights(S._useLegacyLights),e.isArrayCamera){const n=e.cameras;for(let e=0,i=n.length;e<i;e++){const i=n[e];Jt(v,t,i,i.viewport)}}else Jt(v,t,e);null!==w&&(ft.updateMultisampleRenderTarget(w),ft.updateRenderTargetMipmap(w)),!0===t.isScene&&t.onAfterRender(S,t,e),It.resetDefaultState(),A=-1,R=null,M.pop(),x=M.length>0?M[M.length-1]:null,y.pop(),v=y.length>0?y[y.length-1]:null},this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(t,e,n){mt.get(t.texture).__webglTexture=e,mt.get(t.depthTexture).__webglTexture=n;const i=mt.get(t);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===ht.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(t,e){const n=mt.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,n=0){w=t,T=e,E=n;let i=!0,r=null,s=!1,a=!1;if(t){const o=mt.get(t);void 0!==o.__useDefaultFramebuffer?(dt.bindFramebuffer(Dt.FRAMEBUFFER,null),i=!1):void 0===o.__webglFramebuffer?ft.setupRenderTarget(t):o.__hasExternalTextures&&ft.rebindTextures(t,mt.get(t.texture).__webglTexture,mt.get(t.depthTexture).__webglTexture);const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=mt.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(c[e])?c[e][n]:c[e],s=!0):r=ut.isWebGL2&&t.samples>0&&!1===ft.useMultisampledRTT(t)?mt.get(t).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,C.copy(t.viewport),L.copy(t.scissor),P=t.scissorTest}else C.copy($).multiplyScalar(z).floor(),L.copy(Q).multiplyScalar(z).floor(),P=tt;if(dt.bindFramebuffer(Dt.FRAMEBUFFER,r)&&ut.drawBuffers&&i&&dt.drawBuffers(t,r),dt.viewport(C),dt.scissor(L),dt.setScissorTest(P),s){const i=mt.get(t.texture);Dt.framebufferTexture2D(Dt.FRAMEBUFFER,Dt.COLOR_ATTACHMENT0,Dt.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=mt.get(t.texture),r=e||0;Dt.framebufferTextureLayer(Dt.FRAMEBUFFER,Dt.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}A=-1},this.readRenderTargetPixels=function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=mt.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){dt.bindFramebuffer(Dt.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(o!==j&&Pt.convert(o)!==Dt.getParameter(Dt.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===V&&(ht.has("EXT_color_buffer_half_float")||ut.isWebGL2&&ht.has("EXT_color_buffer_float"));if(!(l===F||Pt.convert(l)===Dt.getParameter(Dt.IMPLEMENTATION_COLOR_READ_TYPE)||l===H&&(ut.isWebGL2||ht.has("OES_texture_float")||ht.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Dt.readPixels(e,n,i,r,Pt.convert(o),Pt.convert(l),s)}finally{const t=null!==w?mt.get(w).__webglFramebuffer:null;dt.bindFramebuffer(Dt.FRAMEBUFFER,t)}}},this.copyFramebufferToTexture=function(t,e,n=0){const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),s=Math.floor(e.image.height*i);ft.setTexture2D(e,0),Dt.copyTexSubImage2D(Dt.TEXTURE_2D,n,0,0,t.x,t.y,r,s),dt.unbindTexture()},this.copyTextureToTexture=function(t,e,n,i=0){const r=e.image.width,s=e.image.height,a=Pt.convert(n.format),o=Pt.convert(n.type);ft.setTexture2D(n,0),Dt.pixelStorei(Dt.UNPACK_FLIP_Y_WEBGL,n.flipY),Dt.pixelStorei(Dt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Dt.pixelStorei(Dt.UNPACK_ALIGNMENT,n.unpackAlignment),e.isDataTexture?Dt.texSubImage2D(Dt.TEXTURE_2D,i,t.x,t.y,r,s,a,o,e.image.data):e.isCompressedTexture?Dt.compressedTexSubImage2D(Dt.TEXTURE_2D,i,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,a,e.mipmaps[0].data):Dt.texSubImage2D(Dt.TEXTURE_2D,i,t.x,t.y,a,o,e.image),0===i&&n.generateMipmaps&&Dt.generateMipmap(Dt.TEXTURE_2D),dt.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n,i,r=0){if(S.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=t.max.x-t.min.x+1,a=t.max.y-t.min.y+1,o=t.max.z-t.min.z+1,l=Pt.convert(i.format),c=Pt.convert(i.type);let h;if(i.isData3DTexture)ft.setTexture3D(i,0),h=Dt.TEXTURE_3D;else{if(!i.isDataArrayTexture&&!i.isCompressedArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");ft.setTexture2DArray(i,0),h=Dt.TEXTURE_2D_ARRAY}Dt.pixelStorei(Dt.UNPACK_FLIP_Y_WEBGL,i.flipY),Dt.pixelStorei(Dt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Dt.pixelStorei(Dt.UNPACK_ALIGNMENT,i.unpackAlignment);const u=Dt.getParameter(Dt.UNPACK_ROW_LENGTH),d=Dt.getParameter(Dt.UNPACK_IMAGE_HEIGHT),p=Dt.getParameter(Dt.UNPACK_SKIP_PIXELS),m=Dt.getParameter(Dt.UNPACK_SKIP_ROWS),f=Dt.getParameter(Dt.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[r]:n.image;Dt.pixelStorei(Dt.UNPACK_ROW_LENGTH,g.width),Dt.pixelStorei(Dt.UNPACK_IMAGE_HEIGHT,g.height),Dt.pixelStorei(Dt.UNPACK_SKIP_PIXELS,t.min.x),Dt.pixelStorei(Dt.UNPACK_SKIP_ROWS,t.min.y),Dt.pixelStorei(Dt.UNPACK_SKIP_IMAGES,t.min.z),n.isDataTexture||n.isData3DTexture?Dt.texSubImage3D(h,r,e.x,e.y,e.z,s,a,o,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Dt.compressedTexSubImage3D(h,r,e.x,e.y,e.z,s,a,o,l,g.data)):Dt.texSubImage3D(h,r,e.x,e.y,e.z,s,a,o,l,c,g),Dt.pixelStorei(Dt.UNPACK_ROW_LENGTH,u),Dt.pixelStorei(Dt.UNPACK_IMAGE_HEIGHT,d),Dt.pixelStorei(Dt.UNPACK_SKIP_PIXELS,p),Dt.pixelStorei(Dt.UNPACK_SKIP_ROWS,m),Dt.pixelStorei(Dt.UNPACK_SKIP_IMAGES,f),0===r&&i.generateMipmaps&&Dt.generateMipmap(h),dt.unbindTexture()},this.initTexture=function(t){t.isCubeTexture?ft.setTextureCube(t,0):t.isData3DTexture?ft.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?ft.setTexture2DArray(t,0):ft.setTexture2D(t,0),dt.unbindTexture()},this.resetState=function(){T=0,E=0,w=null,dt.reset(),It.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return $t}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Vt?"display-p3":"srgb",e.unpackColorSpace=Re.workingColorSpace===kt?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Gt?Bt:Ft}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===Bt?Gt:Ht}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}}class eo extends to{}eo.prototype.isWebGL1Renderer=!0;class no{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ci(t),this.density=e}clone(){return new no(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class io{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new ci(t),this.near=e,this.far=n}clone(){return new io(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ro extends jn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e}}class so{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Zt,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=se()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return console.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=se()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=se()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ao=new We;class oo{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)ao.fromBufferAttribute(this,e),ao.applyMatrix4(t),this.setXYZ(e,ao.x,ao.y,ao.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ao.fromBufferAttribute(this,e),ao.applyNormalMatrix(t),this.setXYZ(e,ao.x,ao.y,ao.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ao.fromBufferAttribute(this,e),ao.transformDirection(t),this.setXYZ(e,ao.x,ao.y,ao.z);return this}setX(t,e){return this.normalized&&(e=de(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=de(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=de(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=de(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=ue(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=ue(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=ue(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=ue(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=de(e,this.array),n=de(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=de(e,this.array),n=de(n,this.array),i=de(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=de(e,this.array),n=de(n,this.array),i=de(i,this.array),r=de(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new Mi(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new oo(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class lo extends di{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ci(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let co;const ho=new We,uo=new We,po=new We,mo=new me,fo=new me,go=new Mn,_o=new We,vo=new We,xo=new We,yo=new me,Mo=new me,So=new me;class bo extends jn{constructor(t=new lo){if(super(),this.isSprite=!0,this.type="Sprite",void 0===co){co=new Ii;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new so(t,5);co.setIndex([0,1,2,0,2,3]),co.setAttribute("position",new oo(e,3,0,!1)),co.setAttribute("uv",new oo(e,2,3,!1))}this.geometry=co,this.material=t,this.center=new me(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),uo.setFromMatrixScale(this.matrixWorld),go.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),po.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&uo.multiplyScalar(-po.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const s=this.center;To(_o.set(-.5,-.5,0),po,s,uo,i,r),To(vo.set(.5,-.5,0),po,s,uo,i,r),To(xo.set(.5,.5,0),po,s,uo,i,r),yo.set(0,0),Mo.set(1,0),So.set(1,1);let a=t.ray.intersectTriangle(_o,vo,xo,!1,ho);if(null===a&&(To(vo.set(-.5,.5,0),po,s,uo,i,r),Mo.set(0,1),a=t.ray.intersectTriangle(_o,xo,vo,!1,ho),null===a))return;const o=t.ray.origin.distanceTo(ho);o<t.near||o>t.far||e.push({distance:o,point:ho.clone(),uv:ri.getInterpolation(ho,_o,vo,xo,yo,Mo,So,new me),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function To(t,e,n,i,r,s){mo.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(fo.x=s*mo.x-r*mo.y,fo.y=r*mo.x+s*mo.y):fo.copy(mo),t.copy(e),t.x+=fo.x,t.y+=fo.y,t.applyMatrix4(go)}const Eo=new We,wo=new We;class Ao extends jn{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let r;for(r=0;r<i.length&&!(e<i[r].distance);r++);return i.splice(r,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let i=e[n].distance;if(e[n].object.visible&&(i-=i*e[n].hysteresis),t<i)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Eo.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(Eo);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Eo.setFromMatrixPosition(t.matrixWorld),wo.setFromMatrixPosition(this.matrixWorld);const n=Eo.distanceTo(wo)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i<r;i++){let t=e[i].distance;if(e[i].object.visible&&(t-=t*e[i].hysteresis),!(n>=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i<r;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let t=0,i=n.length;t<i;t++){const i=n[t];e.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return e}}const Ro=new We,Co=new Be,Lo=new Be,Po=new We,Io=new Mn,Uo=new We,Do=new dn,No=new Mn,Oo=new yn;class Fo extends Ji{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=y,this.bindMatrix=new Mn,this.bindMatrixInverse=new Mn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new qe),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Uo),this.boundingBox.expandByPoint(Uo)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new dn),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Uo),this.boundingSphere.expandByPoint(Uo)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),Do.copy(this.boundingSphere),Do.applyMatrix4(i),!1!==t.ray.intersectsSphere(Do)&&(No.copy(i).invert(),Oo.copy(t.ray).applyMatrix4(No),null!==this.boundingBox&&!1===Oo.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,Oo)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Be,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===y?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===M?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;Co.fromBufferAttribute(i.attributes.skinIndex,t),Lo.fromBufferAttribute(i.attributes.skinWeight,t),Ro.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=Lo.getComponent(t);if(0!==i){const r=Co.getComponent(t);Io.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(Po.copy(Ro).applyMatrix4(Io),i)}}return e.applyMatrix4(this.bindMatrixInverse)}boneTransform(t,e){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(t,e)}}class Bo extends jn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class zo extends Fe{constructor(t=null,e=1,n=1,i,r,s,a,o,l=1003,c=1003,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Go=new Mn,Ho=new Mn;class Vo{constructor(t=[],e=[]){this.uuid=se(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new Mn)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new Mn;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=t.length;i<r;i++){const r=t[i]?t[i].matrixWorld:Ho;Go.multiplyMatrices(r,e[i]),Go.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new Vo(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new zo(e,t,t,j,H);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const i=t.bones[n];let r=e[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new Bo),this.bones.push(r),this.boneInverses.push((new Mn).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const r=e[i];t.bones.push(r.uuid);const s=n[i];t.boneInverses.push(s.toArray())}return t}}class ko extends Mi{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Wo=new Mn,Xo=new Mn,jo=[],qo=new qe,Yo=new Mn,Zo=new Ji,Jo=new dn;class Ko extends Ji{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ko(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<n;t++)this.setMatrixAt(t,Yo)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new qe),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Wo),qo.copy(t.boundingBox).applyMatrix4(Wo),this.boundingBox.union(qo)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new dn),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Wo),Jo.copy(t.boundingSphere).applyMatrix4(Wo),this.boundingSphere.union(Jo)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Zo.geometry=this.geometry,Zo.material=this.material,void 0!==Zo.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Jo.copy(this.boundingSphere),Jo.applyMatrix4(n),!1!==t.ray.intersectsSphere(Jo)))for(let r=0;r<i;r++){this.getMatrixAt(r,Wo),Xo.multiplyMatrices(n,Wo),Zo.matrixWorld=Xo,Zo.raycast(t,jo);for(let t=0,n=jo.length;t<n;t++){const n=jo[t];n.instanceId=r,n.object=this,e.push(n)}jo.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new ko(new Float32Array(3*this.instanceMatrix.count),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}function $o(t,e){return t.z-e.z}function Qo(t,e){return e.z-t.z}class tl{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e){const n=this.pool,i=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1});const r=n[this.index];i.push(r),this.index++,r.start=t.start,r.count=t.count,r.z=e}reset(){this.list.length=0,this.index=0}}const el="batchId",nl=new Mn,il=new Mn,rl=new Mn,sl=new Mn,al=new gr,ol=new qe,ll=new dn,cl=new We,hl=new tl,ul=new Ji,dl=[];function pl(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let s=0;s<r;s++)for(let r=0;r<i;r++)e.setComponent(s+n,r,t.getComponent(s,r))}else e.array.set(t.array,n*i);e.needsUpdate=!0}class ml extends Ji{get maxGeometryCount(){return this._maxGeometryCount}constructor(t,e,n=2*e,i){super(new Ii,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let t=Math.sqrt(4*this._maxGeometryCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new zo(e,t,t,j,H);this._matricesTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxGeometryCount,r=this._maxIndexCount;if(!1===this._geometryInitialized){for(const i in t.attributes){const r=t.getAttribute(i),{array:s,itemSize:a,normalized:o}=r,l=new s.constructor(n*a),c=new r.constructor(l,a,o);c.setUsage(r.usage),e.setAttribute(i,c)}if(null!==t.getIndex()){const t=n>65536?new Uint32Array(r):new Uint16Array(r);e.setIndex(new Mi(t,1))}const s=i>65536?new Uint32Array(n):new Uint16Array(n);e.setAttribute(el,new Mi(s,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(el))throw new Error(`BatchedMesh: Geometry cannot use attribute "${el}"`);const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(n===el)continue;if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new qe);const t=this._geometryCount,e=this.boundingBox,n=this._active;e.makeEmpty();for(let i=0;i<t;i++)!1!==n[i]&&(this.getMatrixAt(i,nl),this.getBoundingBoxAt(i,ol).applyMatrix4(nl),e.union(ol))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new dn);const t=this._geometryCount,e=this.boundingSphere,n=this._active;e.makeEmpty();for(let i=0;i<t;i++)!1!==n[i]&&(this.getMatrixAt(i,nl),this.getBoundingSphereAt(i,ll).applyMatrix4(nl),e.union(ll))}addGeometry(t,e=-1,n=-1){if(this._initializeGeometry(t),this._validateGeometry(t),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const s=this._reservedRanges,a=this._drawRanges,o=this._bounds;0!==this._geometryCount&&(r=s[s.length-1]),i.vertexCount=-1===e?t.getAttribute("position").count:e,i.vertexStart=null===r?0:r.vertexStart+r.vertexCount;const l=t.getIndex(),c=null!==l;if(c&&(i.indexCount=-1===n?l.count:n,i.indexStart=null===r?0:r.indexStart+r.indexCount),-1!==i.indexStart&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._visibility,u=this._active,d=this._matricesTexture,p=this._matricesTexture.image.data;h.push(!0),u.push(!0);const m=this._geometryCount;this._geometryCount++,rl.toArray(p,16*m),d.needsUpdate=!0,s.push(i),a.push({start:c?i.indexStart:i.vertexStart,count:-1}),o.push({boxInitialized:!1,box:new qe,sphereInitialized:!1,sphere:new dn});const f=this.geometry.getAttribute(el);for(let t=0;t<i.vertexCount;t++)f.setX(i.vertexStart+t,m);return f.needsUpdate=!0,this.setGeometryAt(m,t),m}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),s=e.getIndex(),a=this._reservedRanges[t];if(i&&s.count>a.indexCount||e.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.vertexCount;for(const t in n.attributes){if(t===el)continue;const i=e.getAttribute(t),r=n.getAttribute(t);pl(i,r,o);const s=i.itemSize;for(let t=i.count,e=l;t<e;t++){const e=o+t;for(let t=0;t<s;t++)r.setComponent(e,t,0)}r.needsUpdate=!0}if(i){const t=a.indexStart;for(let e=0;e<s.count;e++)r.setX(t+e,o+s.getX(e));for(let e=s.count,n=a.indexCount;e<n;e++)r.setX(t+e,o);r.needsUpdate=!0}const c=this._bounds[t];null!==e.boundingBox?(c.box.copy(e.boundingBox),c.boxInitialized=!0):c.boxInitialized=!1,null!==e.boundingSphere?(c.sphere.copy(e.boundingSphere),c.sphereInitialized=!0):c.sphereInitialized=!1;const h=this._drawRanges[t],u=e.getAttribute("position");return h.count=i?s.count:u.count,this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._active;return t>=e.length||!1===e[t]||(e[t]=!1,this._visibilityChanged=!0),this}getBoundingBoxAt(t,e){if(!1===this._active[t])return this;const n=this._bounds[t],i=n.box,r=this.geometry;if(!1===n.boxInitialized){i.makeEmpty();const e=r.index,s=r.attributes.position,a=this._drawRanges[t];for(let t=a.start,n=a.start+a.count;t<n;t++){let n=t;e&&(n=e.getX(n)),i.expandByPoint(cl.fromBufferAttribute(s,n))}n.boxInitialized=!0}return e.copy(i),e}getBoundingSphereAt(t,e){if(!1===this._active[t])return this;const n=this._bounds[t],i=n.sphere,r=this.geometry;if(!1===n.sphereInitialized){i.makeEmpty(),this.getBoundingBoxAt(t,ol),ol.getCenter(i.center);const e=r.index,s=r.attributes.position,a=this._drawRanges[t];let o=0;for(let t=a.start,n=a.start+a.count;t<n;t++){let n=t;e&&(n=e.getX(n)),cl.fromBufferAttribute(s,n),o=Math.max(o,i.center.distanceToSquared(cl))}i.radius=Math.sqrt(o),n.sphereInitialized=!0}return e.copy(i),e}setMatrixAt(t,e){const n=this._active,i=this._matricesTexture,r=this._matricesTexture.image.data;return t>=this._geometryCount||!1===n[t]||(e.toArray(r,16*t),i.needsUpdate=!0),this}getMatrixAt(t,e){const n=this._active,i=this._matricesTexture.image.data;return t>=this._geometryCount||!1===n[t]?null:e.fromArray(i,16*t)}setVisibleAt(t,e){const n=this._visibility,i=this._active;return t>=this._geometryCount||!1===i[t]||n[t]===e||(n[t]=e,this._visibilityChanged=!0),this}getVisibleAt(t){const e=this._visibility,n=this._active;return!(t>=this._geometryCount||!1===n[t])&&e[t]}raycast(t,e){const n=this._visibility,i=this._active,r=this._drawRanges,s=this._geometryCount,a=this.matrixWorld,o=this.geometry;ul.material=this.material,ul.geometry.index=o.index,ul.geometry.attributes=o.attributes,null===ul.geometry.boundingBox&&(ul.geometry.boundingBox=new qe),null===ul.geometry.boundingSphere&&(ul.geometry.boundingSphere=new dn);for(let o=0;o<s;o++){if(!n[o]||!i[o])continue;const s=r[o];ul.geometry.setDrawRange(s.start,s.count),this.getMatrixAt(o,ul.matrixWorld).premultiply(a),this.getBoundingBoxAt(o,ul.geometry.boundingBox),this.getBoundingSphereAt(o,ul.geometry.boundingSphere),ul.raycast(t,dl);for(let t=0,n=dl.length;t<n;t++){const n=dl[t];n.object=this,n.batchId=o,e.push(n)}dl.length=0}ul.material=null,ul.geometry.index=null,ul.geometry.attributes={},ul.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._drawRanges=t._drawRanges.map((t=>({...t}))),this._reservedRanges=t._reservedRanges.map((t=>({...t}))),this._visibility=t._visibility.slice(),this._active=t._active.slice(),this._bounds=t._bounds.map((t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()}))),this._maxGeometryCount=t._maxGeometryCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),a=null===s?1:s.array.BYTES_PER_ELEMENT,o=this._visibility,l=this._multiDrawStarts,c=this._multiDrawCounts,h=this._drawRanges,u=this.perObjectFrustumCulled;u&&(sl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),al.setFromProjectionMatrix(sl,t.isWebGPURenderer?Qt:$t));let d=0;if(this.sortObjects){il.copy(this.matrixWorld).invert(),cl.setFromMatrixPosition(n.matrixWorld).applyMatrix4(il);for(let t=0,e=o.length;t<e;t++)if(o[t]){this.getMatrixAt(t,nl),this.getBoundingSphereAt(t,ll).applyMatrix4(nl);let e=!1;if(u&&(e=!al.intersectsSphere(ll)),!e){const e=cl.distanceTo(ll.center);hl.push(h[t],e)}}const t=hl.list,e=this.customSort;null===e?t.sort(r.transparent?Qo:$o):e.call(this,t,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];l[d]=n.start*a,c[d]=n.count,d++}hl.reset()}else for(let t=0,e=o.length;t<e;t++)if(o[t]){let e=!1;if(u&&(this.getMatrixAt(t,nl),this.getBoundingSphereAt(t,ll).applyMatrix4(nl),e=!al.intersectsSphere(ll)),!e){const e=h[t];l[d]=e.start*a,c[d]=e.count,d++}}this._multiDrawCount=d,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,s){this.onBeforeRender(t,null,i,r,s)}}class fl extends di{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ci(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const gl=new We,_l=new We,vl=new Mn,xl=new yn,yl=new dn;class Ml extends jn{constructor(t=new Ii,e=new fl){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)gl.fromBufferAttribute(e,t-1),_l.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=gl.distanceTo(_l);t.setAttribute("lineDistance",new Ti(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),yl.copy(n.boundingSphere),yl.applyMatrix4(i),yl.radius+=r,!1===t.ray.intersectsSphere(yl))return;vl.copy(i).invert(),xl.copy(t.ray).applyMatrix4(vl);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new We,c=new We,h=new We,u=new We,d=this.isLineSegments?2:1,p=n.index,m=n.attributes.position;if(null!==p){for(let n=Math.max(0,s.start),i=Math.min(p.count,s.start+s.count)-1;n<i;n+=d){const i=p.getX(n),r=p.getX(n+1);l.fromBufferAttribute(m,i),c.fromBufferAttribute(m,r);if(xl.distanceSqToSegment(l,c,u,h)>o)continue;u.applyMatrix4(this.matrixWorld);const s=t.ray.origin.distanceTo(u);s<t.near||s>t.far||e.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,s.start),i=Math.min(m.count,s.start+s.count)-1;n<i;n+=d){l.fromBufferAttribute(m,n),c.fromBufferAttribute(m,n+1);if(xl.distanceSqToSegment(l,c,u,h)>o)continue;u.applyMatrix4(this.matrixWorld);const i=t.ray.origin.distanceTo(u);i<t.near||i>t.far||e.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}const Sl=new We,bl=new We;class Tl extends Ml{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)Sl.fromBufferAttribute(e,t),bl.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+Sl.distanceTo(bl);t.setAttribute("lineDistance",new Ti(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class El extends Ml{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class wl extends di{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ci(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Al=new Mn,Rl=new yn,Cl=new dn,Ll=new We;class Pl extends jn{constructor(t=new Ii,e=new wl){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Cl.copy(n.boundingSphere),Cl.applyMatrix4(i),Cl.radius+=r,!1===t.ray.intersectsSphere(Cl))return;Al.copy(i).invert(),Rl.copy(t.ray).applyMatrix4(Al);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);n<r;n++){const r=l.getX(n);Ll.fromBufferAttribute(c,r),Il(Ll,r,o,i,t,e,this)}}else{for(let n=Math.max(0,s.start),r=Math.min(c.count,s.start+s.count);n<r;n++)Ll.fromBufferAttribute(c,n),Il(Ll,n,o,i,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Il(t,e,n,i,r,s,a){const o=Rl.distanceSqToPoint(t);if(o<n){const n=new We;Rl.closestPointToPoint(t,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,object:a})}}class Ul extends Fe{constructor(t,e,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class Dl{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)n=this.getPoint(s/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const r=n.length;let s;s=e||t*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=e||(s.isVector2?new me:new We);return o.copy(a).sub(s).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new We,i=[],r=[],s=[],a=new We,o=new Mn;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new We)}r[0]=new We,s[0]=new We;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ae(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}s[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(ae(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class Nl extends Dl{constructor(t=0,e=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(t,e){const n=e||new me,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=s?0:i),!0!==this.aClockwise||s||(r===i?r=-i:r-=i);const a=this.aStartAngle+t*r;let o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=o-this.aX,i=l-this.aY;o=n*t-i*e+this.aX,l=n*e+i*t+this.aY}return n.set(o,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class Ol extends Nl{constructor(t,e,n,i,r,s){super(t,e,n,n,i,r,s),this.isArcCurve=!0,this.type="ArcCurve"}}function Fl(){let t=0,e=0,n=0,i=0;function r(r,s,a,o){t=r,e=a,n=-3*r+3*s-2*a-o,i=2*r-2*s+a+o}return{initCatmullRom:function(t,e,n,i,s){r(e,n,s*(n-t),s*(i-e))},initNonuniformCatmullRom:function(t,e,n,i,s,a,o){let l=(e-t)/s-(n-t)/(s+a)+(n-e)/a,c=(n-e)/a-(i-e)/(a+o)+(i-n)/o;l*=a,c*=a,r(e,n,l,c)},calc:function(r){const s=r*r;return t+e*r+n*s+i*(s*r)}}}const Bl=new We,zl=new Fl,Gl=new Fl,Hl=new Fl;class Vl extends Dl{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new We){const n=e,i=this.points,r=i.length,s=(r-(this.closed?0:1))*t;let a,o,l=Math.floor(s),c=s-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(Bl.subVectors(i[0],i[1]).add(i[0]),a=Bl);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2<r?o=i[(l+2)%r]:(Bl.subVectors(i[r-1],i[r-2]).add(i[r-1]),o=Bl),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(h),t),n=Math.pow(h.distanceToSquared(u),t),i=Math.pow(u.distanceToSquared(o),t);n<1e-4&&(n=1),e<1e-4&&(e=n),i<1e-4&&(i=n),zl.initNonuniformCatmullRom(a.x,h.x,u.x,o.x,e,n,i),Gl.initNonuniformCatmullRom(a.y,h.y,u.y,o.y,e,n,i),Hl.initNonuniformCatmullRom(a.z,h.z,u.z,o.z,e,n,i)}else"catmullrom"===this.curveType&&(zl.initCatmullRom(a.x,h.x,u.x,o.x,this.tension),Gl.initCatmullRom(a.y,h.y,u.y,o.y,this.tension),Hl.initCatmullRom(a.z,h.z,u.z,o.z,this.tension));return n.set(zl.calc(c),Gl.calc(c),Hl.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new We).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function kl(t,e,n,i,r){const s=.5*(i-e),a=.5*(r-n),o=t*t;return(2*n-2*i+s+a)*(t*o)+(-3*n+3*i-2*s-a)*o+s*t+n}function Wl(t,e,n,i){return function(t,e){const n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,i)}function Xl(t,e,n,i,r){return function(t,e){const n=1-t;return n*n*n*e}(t,e)+function(t,e){const n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,i)+function(t,e){return t*t*t*e}(t,r)}class jl extends Dl{constructor(t=new me,e=new me,n=new me,i=new me){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new me){const n=e,i=this.v0,r=this.v1,s=this.v2,a=this.v3;return n.set(Xl(t,i.x,r.x,s.x,a.x),Xl(t,i.y,r.y,s.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class ql extends Dl{constructor(t=new We,e=new We,n=new We,i=new We){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new We){const n=e,i=this.v0,r=this.v1,s=this.v2,a=this.v3;return n.set(Xl(t,i.x,r.x,s.x,a.x),Xl(t,i.y,r.y,s.y,a.y),Xl(t,i.z,r.z,s.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Yl extends Dl{constructor(t=new me,e=new me){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new me){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new me){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Zl extends Dl{constructor(t=new We,e=new We){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new We){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new We){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Jl extends Dl{constructor(t=new me,e=new me,n=new me){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new me){const n=e,i=this.v0,r=this.v1,s=this.v2;return n.set(Wl(t,i.x,r.x,s.x),Wl(t,i.y,r.y,s.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Kl extends Dl{constructor(t=new We,e=new We,n=new We){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new We){const n=e,i=this.v0,r=this.v1,s=this.v2;return n.set(Wl(t,i.x,r.x,s.x),Wl(t,i.y,r.y,s.y),Wl(t,i.z,r.z,s.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class $l extends Dl{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new me){const n=e,i=this.points,r=(i.length-1)*t,s=Math.floor(r),a=r-s,o=i[0===s?s:s-1],l=i[s],c=i[s>i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(kl(a,o.x,l.x,c.x,h.x),kl(a,o.y,l.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new me).fromArray(n))}return this}}var Ql=Object.freeze({__proto__:null,ArcCurve:Ol,CatmullRomCurve3:Vl,CubicBezierCurve:jl,CubicBezierCurve3:ql,EllipseCurve:Nl,LineCurve:Yl,LineCurve3:Zl,QuadraticBezierCurve:Jl,QuadraticBezierCurve3:Kl,SplineCurve:$l});class tc extends Dl{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Ql[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const t=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-t/a;return s.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const s=r[i],a=s.isEllipseCurve?2*t:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?t*s.points.length:t,o=s.getPoints(a);for(let t=0;t<o.length;t++){const i=o[t];n&&n.equals(i)||(e.push(i),n=i)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new Ql[n.type]).fromJSON(n))}return this}}class ec extends tc{constructor(t){super(),this.type="Path",this.currentPoint=new me,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new Yl(this.currentPoint.clone(),new me(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const r=new Jl(this.currentPoint.clone(),new me(t,e),new me(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,s){const a=new jl(this.currentPoint.clone(),new me(t,e),new me(n,i),new me(r,s));return this.curves.push(a),this.currentPoint.set(r,s),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new $l(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,s){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,n,i,r,s),this}absarc(t,e,n,i,r,s){return this.absellipse(t,e,n,n,i,r,s),this}ellipse(t,e,n,i,r,s,a,o){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+l,e+c,n,i,r,s,a,o),this}absellipse(t,e,n,i,r,s,a,o){const l=new Nl(t,e,n,i,r,s,a,o);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class nc extends Ii{constructor(t=[new me(0,-.5),new me(.5,0),new me(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=ae(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/e,h=new We,u=new me,d=new We,p=new We,m=new We;let f=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let r=0;r<=e;r++){const d=n+r*c*i,p=Math.sin(d),m=Math.cos(d);for(let n=0;n<=t.length-1;n++){h.x=t[n].x*p,h.y=t[n].y,h.z=t[n].x*m,s.push(h.x,h.y,h.z),u.x=r/e,u.y=n/(t.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*m;l.push(i,c,d)}}for(let n=0;n<e;n++)for(let e=0;e<t.length-1;e++){const i=e+n*t.length,s=i,a=i+t.length,o=i+t.length+1,l=i+1;r.push(s,a,l),r.push(o,l,a)}this.setIndex(r),this.setAttribute("position",new Ti(s,3)),this.setAttribute("uv",new Ti(a,2)),this.setAttribute("normal",new Ti(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new nc(t.points,t.segments,t.phiStart,t.phiLength)}}class ic extends nc{constructor(t=1,e=1,n=4,i=8){const r=new ec;r.absarc(0,-e/2,t,1.5*Math.PI,0),r.absarc(0,e/2,t,0,.5*Math.PI),super(r.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:n,radialSegments:i}}static fromJSON(t){return new ic(t.radius,t.length,t.capSegments,t.radialSegments)}}class rc extends Ii{constructor(t=1,e=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],s=[],a=[],o=[],l=new We,c=new me;s.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let r=0,h=3;r<=e;r++,h+=3){const u=n+r/e*i;l.x=t*Math.cos(u),l.y=t*Math.sin(u),s.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(s[h]/t+1)/2,c.y=(s[h+1]/t+1)/2,o.push(c.x,c.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new Ti(s,3)),this.setAttribute("normal",new Ti(a,3)),this.setAttribute("uv",new Ti(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new rc(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class sc extends Ii{constructor(t=1,e=1,n=1,i=32,r=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],h=[],u=[],d=[];let p=0;const m=[],f=n/2;let g=0;function _(n){const r=p,s=new me,m=new We;let _=0;const v=!0===n?t:e,x=!0===n?1:-1;for(let t=1;t<=i;t++)h.push(0,f*x,0),u.push(0,x,0),d.push(.5,.5),p++;const y=p;for(let t=0;t<=i;t++){const e=t/i*o+a,n=Math.cos(e),r=Math.sin(e);m.x=v*r,m.y=f*x,m.z=v*n,h.push(m.x,m.y,m.z),u.push(0,x,0),s.x=.5*n+.5,s.y=.5*r*x+.5,d.push(s.x,s.y),p++}for(let t=0;t<i;t++){const e=r+t,i=y+t;!0===n?c.push(i,i+1,e):c.push(i+1,i,e),_+=3}l.addGroup(g,_,!0===n?1:2),g+=_}!function(){const s=new We,_=new We;let v=0;const x=(e-t)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,v=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*o+a,l=Math.sin(r),m=Math.cos(r);_.x=v*l,_.y=-g*n+f,_.z=v*m,h.push(_.x,_.y,_.z),s.set(l,x,m).normalize(),u.push(s.x,s.y,s.z),d.push(e,1-g),c.push(p++)}m.push(c)}for(let t=0;t<i;t++)for(let e=0;e<r;e++){const n=m[e][t],i=m[e+1][t],r=m[e+1][t+1],s=m[e][t+1];c.push(n,i,s),c.push(i,r,s),v+=6}l.addGroup(g,v,0),g+=v}(),!1===s&&(t>0&&_(!0),e>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new Ti(h,3)),this.setAttribute("normal",new Ti(u,3)),this.setAttribute("uv",new Ti(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new sc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ac extends sc{constructor(t=1,e=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,t,e,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(t){return new ac(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class oc extends Ii{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],s=[];function a(t,e,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)s[i][t]=0===t&&i===r?a:a.clone().lerp(o,t/l)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const n=Math.floor(e/2);e%2==0?(o(s[t][n+1]),o(s[t+1][n]),o(s[t][n])):(o(s[t][n+1]),o(s[t+1][n+1]),o(s[t+1][n]))}}function o(t){r.push(t.x,t.y,t.z)}function l(e,n){const i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function c(t,e,n,i){i<0&&1===t.x&&(s[e]=t.x-1),0===n.x&&0===n.z&&(s[e]=i/2/Math.PI+.5)}function h(t){return Math.atan2(t.z,-t.x)}!function(t){const n=new We,i=new We,r=new We;for(let s=0;s<e.length;s+=3)l(e[s+0],n),l(e[s+1],i),l(e[s+2],r),a(n,i,r,t)}(i),function(t){const e=new We;for(let n=0;n<r.length;n+=3)e.x=r[n+0],e.y=r[n+1],e.z=r[n+2],e.normalize().multiplyScalar(t),r[n+0]=e.x,r[n+1]=e.y,r[n+2]=e.z}(n),function(){const t=new We;for(let n=0;n<r.length;n+=3){t.x=r[n+0],t.y=r[n+1],t.z=r[n+2];const i=h(t)/2/Math.PI+.5,a=(e=t,Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5);s.push(i,1-a)}var e;(function(){const t=new We,e=new We,n=new We,i=new We,a=new me,o=new me,l=new me;for(let u=0,d=0;u<r.length;u+=9,d+=6){t.set(r[u+0],r[u+1],r[u+2]),e.set(r[u+3],r[u+4],r[u+5]),n.set(r[u+6],r[u+7],r[u+8]),a.set(s[d+0],s[d+1]),o.set(s[d+2],s[d+3]),l.set(s[d+4],s[d+5]),i.copy(t).add(e).add(n).divideScalar(3);const p=h(i);c(a,d+0,t,p),c(o,d+2,e,p),c(l,d+4,n,p)}})(),function(){for(let t=0;t<s.length;t+=6){const e=s[t+0],n=s[t+2],i=s[t+4],r=Math.max(e,n,i),a=Math.min(e,n,i);r>.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new Ti(r,3)),this.setAttribute("normal",new Ti(r.slice(),3)),this.setAttribute("uv",new Ti(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new oc(t.vertices,t.indices,t.radius,t.details)}}class lc extends oc{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[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],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new lc(t.radius,t.detail)}}const cc=new We,hc=new We,uc=new We,dc=new ri;class pc extends Ii{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),r=Math.cos(ie*e),s=t.getIndex(),a=t.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let t=0;t<o;t+=3){s?(l[0]=s.getX(t),l[1]=s.getX(t+1),l[2]=s.getX(t+2)):(l[0]=t,l[1]=t+1,l[2]=t+2);const{a:e,b:n,c:o}=dc;if(e.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),dc.getNormal(uc),h[0]=`${Math.round(e.x*i)},${Math.round(e.y*i)},${Math.round(e.z*i)}`,h[1]=`${Math.round(n.x*i)},${Math.round(n.y*i)},${Math.round(n.z*i)}`,h[2]=`${Math.round(o.x*i)},${Math.round(o.y*i)},${Math.round(o.z*i)}`,h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(let t=0;t<3;t++){const e=(t+1)%3,n=h[t],i=h[e],s=dc[c[t]],a=dc[c[e]],o=`${n}_${i}`,p=`${i}_${n}`;p in u&&u[p]?(uc.dot(u[p].normal)<=r&&(d.push(s.x,s.y,s.z),d.push(a.x,a.y,a.z)),u[p]=null):o in u||(u[o]={index0:l[t],index1:l[e],normal:uc.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:n}=u[t];cc.fromBufferAttribute(a,e),hc.fromBufferAttribute(a,n),d.push(cc.x,cc.y,cc.z),d.push(hc.x,hc.y,hc.z)}this.setAttribute("position",new Ti(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class mc extends ec{constructor(t){super(t),this.uuid=se(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new ec).fromJSON(n))}return this}}const fc=function(t,e,n=2){const i=e&&e.length,r=i?e[0]*n:t.length;let s=gc(t,0,r,n,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,h,u,d,p;if(i&&(s=function(t,e,n,i){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*i,l=s<a-1?e[s+1]*i:t.length,c=gc(t,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(Ac(c));for(r.sort(bc),s=0;s<r.length;s++)n=Tc(r[s],n);return n}(t,e,s,n)),t.length>80*n){o=c=t[0],l=h=t[1];for(let e=n;e<r;e+=n)u=t[e],d=t[e+1],u<o&&(o=u),d<l&&(l=d),u>c&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return vc(s,a,n,o,l,p,0),a};function gc(t,e,n,i,r){let s,a;if(r===function(t,e,n,i){let r=0;for(let s=e,a=n-i;s<n;s+=i)r+=(t[a]-t[s])*(t[s+1]+t[a+1]),a=s;return r}(t,e,n,i)>0)for(s=e;s<n;s+=i)a=Fc(s,t[s],t[s+1],a);else for(s=n-i;s>=e;s-=i)a=Fc(s,t[s],t[s+1],a);return a&&Pc(a,a.next)&&(Bc(a),a=a.next),a}function _c(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!Pc(i,i.next)&&0!==Lc(i.prev,i,i.next))i=i.next;else{if(Bc(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function vc(t,e,n,i,r,s,a){if(!t)return;!a&&s&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=wc(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n,i,r,s,a,o,l,c=1;do{for(n=t,t=null,s=null,a=0;n;){for(a++,i=n,o=0,e=0;e<c&&(o++,i=i.nextZ,i);e++);for(l=c;o>0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(t,i,r,s);let o,l,c=t;for(;t.prev!==t.next;)if(o=t.prev,l=t.next,s?yc(t,i,r,s):xc(t))e.push(o.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),Bc(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?vc(t=Mc(_c(t),e,n),e,n,i,r,s,2):2===a&&Sc(t,e,n,i,r,s):vc(_c(t),e,n,i,r,s,1);break}}function xc(t){const e=t.prev,n=t,i=t.next;if(Lc(e,n,i)>=0)return!1;const r=e.x,s=n.x,a=i.x,o=e.y,l=n.y,c=i.y,h=r<s?r<a?r:a:s<a?s:a,u=o<l?o<c?o:c:l<c?l:c,d=r>s?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=p&&Rc(r,o,s,l,a,c,m.x,m.y)&&Lc(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function yc(t,e,n,i){const r=t.prev,s=t,a=t.next;if(Lc(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=o<l?o<c?o:c:l<c?l:c,m=h<u?h<d?h:d:u<d?u:d,f=o>l?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,_=wc(p,m,e,n,i),v=wc(f,g,e,n,i);let x=t.prevZ,y=t.nextZ;for(;x&&x.z>=_&&y&&y.z<=v;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==a&&Rc(o,h,l,u,c,d,x.x,x.y)&&Lc(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==a&&Rc(o,h,l,u,c,d,y.x,y.y)&&Lc(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==a&&Rc(o,h,l,u,c,d,x.x,x.y)&&Lc(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=v;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==a&&Rc(o,h,l,u,c,d,y.x,y.y)&&Lc(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Mc(t,e,n){let i=t;do{const r=i.prev,s=i.next.next;!Pc(r,s)&&Ic(r,i,i.next,s)&&Nc(r,s)&&Nc(s,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(s.i/n|0),Bc(i),Bc(i.next),i=t=s),i=i.next}while(i!==t);return _c(i)}function Sc(t,e,n,i,r,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&Cc(a,t)){let o=Oc(a,t);return a=_c(a,a.next),o=_c(o,o.next),vc(a,e,n,i,r,s,0),void vc(o,e,n,i,r,s,0)}t=t.next}a=a.next}while(a!==t)}function bc(t,e){return t.x-e.x}function Tc(t,e){const n=function(t,e){let n,i=e,r=-1/0;const s=t.x,a=t.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const t=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>r&&(r=t,n=i.x<i.next.x?i:i.next,t===s))return n}i=i.next}while(i!==e);if(!n)return null;const o=n,l=n.x,c=n.y;let h,u=1/0;i=n;do{s>=i.x&&i.x>=l&&s!==i.x&&Rc(a<c?s:r,a,l,c,a<c?r:s,a,i.x,i.y)&&(h=Math.abs(a-i.y)/(s-i.x),Nc(i,t)&&(h<u||h===u&&(i.x>n.x||i.x===n.x&&Ec(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(t,e);if(!n)return e;const i=Oc(n,t);return _c(i,i.next),_c(n,n.next)}function Ec(t,e){return Lc(t.prev,t,e.prev)<0&&Lc(e.next,t,t.next)<0}function wc(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ac(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Rc(t,e,n,i,r,s,a,o){return(r-a)*(e-o)>=(t-a)*(s-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function Cc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Ic(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Nc(t,e)&&Nc(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(Lc(t.prev,t,e.prev)||Lc(t,e.prev,e))||Pc(t,e)&&Lc(t.prev,t,t.next)>0&&Lc(e.prev,e,e.next)>0)}function Lc(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Pc(t,e){return t.x===e.x&&t.y===e.y}function Ic(t,e,n,i){const r=Dc(Lc(t,e,n)),s=Dc(Lc(t,e,i)),a=Dc(Lc(n,i,t)),o=Dc(Lc(n,i,e));return r!==s&&a!==o||(!(0!==r||!Uc(t,n,e))||(!(0!==s||!Uc(t,i,e))||(!(0!==a||!Uc(n,t,i))||!(0!==o||!Uc(n,e,i)))))}function Uc(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Dc(t){return t>0?1:t<0?-1:0}function Nc(t,e){return Lc(t.prev,t,t.next)<0?Lc(t,e,t.next)>=0&&Lc(t,t.prev,e)>=0:Lc(t,e,t.prev)<0||Lc(t,t.next,e)<0}function Oc(t,e){const n=new zc(t.i,t.x,t.y),i=new zc(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function Fc(t,e,n,i){const r=new zc(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Bc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function zc(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Gc{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*n}static isClockWise(t){return Gc.area(t)<0}static triangulateShape(t,e){const n=[],i=[],r=[];Hc(t),Vc(n,t);let s=t.length;e.forEach(Hc);for(let t=0;t<e.length;t++)i.push(s),s+=e[t].length,Vc(n,e[t]);const a=fc(n,i);for(let t=0;t<a.length;t+=3)r.push(a.slice(t,t+3));return r}}function Hc(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Vc(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class kc extends Ii{constructor(t=new mc([new me(.5,.5),new me(-.5,.5),new me(-.5,-.5),new me(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],r=[];for(let e=0,n=t.length;e<n;e++){s(t[e])}function s(t){const s=[],a=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let c=void 0===e.bevelEnabled||e.bevelEnabled,h=void 0!==e.bevelThickness?e.bevelThickness:.2,u=void 0!==e.bevelSize?e.bevelSize:h-.1,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const m=e.extrudePath,f=void 0!==e.UVGenerator?e.UVGenerator:Wc;let g,_,v,x,y,M=!1;m&&(g=m.getSpacedPoints(o),M=!0,c=!1,_=m.computeFrenetFrames(o,!1),v=new We,x=new We,y=new We),c||(p=0,h=0,u=0,d=0);const S=t.extractPoints(a);let b=S.shape;const T=S.holes;if(!Gc.isClockWise(b)){b=b.reverse();for(let t=0,e=T.length;t<e;t++){const e=T[t];Gc.isClockWise(e)&&(T[t]=e.reverse())}}const E=Gc.triangulateShape(b,T),w=b;for(let t=0,e=T.length;t<e;t++){const e=T[t];b=b.concat(e)}function A(t,e,n){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().addScaledVector(e,n)}const R=b.length,C=E.length;function L(t,e,n){let i,r,s;const a=t.x-e.x,o=t.y-e.y,l=n.x-t.x,c=n.y-t.y,h=a*a+o*o,u=a*c-o*l;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=e.x-o/u,m=e.y+a/u,f=((n.x-c/d-p)*c-(n.y+l/d-m)*l)/(a*c-o*l);i=p+a*f-t.x,r=m+o*f-t.y;const g=i*i+r*r;if(g<=2)return new me(i,r);s=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new me(i/s,r/s)}const P=[];for(let t=0,e=w.length,n=e-1,i=t+1;t<e;t++,n++,i++)n===e&&(n=0),i===e&&(i=0),P[t]=L(w[t],w[n],w[i]);const I=[];let U,D=P.concat();for(let t=0,e=T.length;t<e;t++){const e=T[t];U=[];for(let t=0,n=e.length,i=n-1,r=t+1;t<n;t++,i++,r++)i===n&&(i=0),r===n&&(r=0),U[t]=L(e[t],e[i],e[r]);I.push(U),D=D.concat(U)}for(let t=0;t<p;t++){const e=t/p,n=h*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=w.length;t<e;t++){const e=A(w[t],P[t],i);F(e.x,e.y,-n)}for(let t=0,e=T.length;t<e;t++){const e=T[t];U=I[t];for(let t=0,r=e.length;t<r;t++){const r=A(e[t],U[t],i);F(r.x,r.y,-n)}}}const N=u+d;for(let t=0;t<R;t++){const e=c?A(b[t],D[t],N):b[t];M?(x.copy(_.normals[0]).multiplyScalar(e.x),v.copy(_.binormals[0]).multiplyScalar(e.y),y.copy(g[0]).add(x).add(v),F(y.x,y.y,y.z)):F(e.x,e.y,0)}for(let t=1;t<=o;t++)for(let e=0;e<R;e++){const n=c?A(b[e],D[e],N):b[e];M?(x.copy(_.normals[t]).multiplyScalar(n.x),v.copy(_.binormals[t]).multiplyScalar(n.y),y.copy(g[t]).add(x).add(v),F(y.x,y.y,y.z)):F(n.x,n.y,l/o*t)}for(let t=p-1;t>=0;t--){const e=t/p,n=h*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=w.length;t<e;t++){const e=A(w[t],P[t],i);F(e.x,e.y,l+n)}for(let t=0,e=T.length;t<e;t++){const e=T[t];U=I[t];for(let t=0,r=e.length;t<r;t++){const r=A(e[t],U[t],i);M?F(r.x,r.y+g[o-1].y,g[o-1].x+n):F(r.x,r.y,l+n)}}}function O(t,e){let n=t.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=o+2*p;t<n;t++){const n=R*t,s=R*(t+1);z(e+i+n,e+r+n,e+r+s,e+i+s)}}}function F(t,e,n){s.push(t),s.push(e),s.push(n)}function B(t,e,r){G(t),G(e),G(r);const s=i.length/3,a=f.generateTopUV(n,i,s-3,s-2,s-1);H(a[0]),H(a[1]),H(a[2])}function z(t,e,r,s){G(t),G(e),G(s),G(e),G(r),G(s);const a=i.length/3,o=f.generateSideWallUV(n,i,a-6,a-3,a-2,a-1);H(o[0]),H(o[1]),H(o[3]),H(o[1]),H(o[2]),H(o[3])}function G(t){i.push(s[3*t+0]),i.push(s[3*t+1]),i.push(s[3*t+2])}function H(t){r.push(t.x),r.push(t.y)}!function(){const t=i.length/3;if(c){let t=0,e=R*t;for(let t=0;t<C;t++){const n=E[t];B(n[2]+e,n[1]+e,n[0]+e)}t=o+2*p,e=R*t;for(let t=0;t<C;t++){const n=E[t];B(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<C;t++){const e=E[t];B(e[2],e[1],e[0])}for(let t=0;t<C;t++){const e=E[t];B(e[0]+R*o,e[1]+R*o,e[2]+R*o)}}n.addGroup(t,i.length/3-t,0)}(),function(){const t=i.length/3;let e=0;O(w,e),e+=w.length;for(let t=0,n=T.length;t<n;t++){const n=T[t];O(n,e),e+=n.length}n.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new Ti(i,3)),this.setAttribute("uv",new Ti(r,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){const i=t[e];n.shapes.push(i.uuid)}else n.shapes.push(t.uuid);n.options=Object.assign({},e),void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];n.push(r)}const i=t.options.extrudePath;return void 0!==i&&(t.options.extrudePath=(new Ql[i.type]).fromJSON(i)),new kc(n,t.options)}}const Wc={generateTopUV:function(t,e,n,i,r){const s=e[3*n],a=e[3*n+1],o=e[3*i],l=e[3*i+1],c=e[3*r],h=e[3*r+1];return[new me(s,a),new me(o,l),new me(c,h)]},generateSideWallUV:function(t,e,n,i,r,s){const a=e[3*n],o=e[3*n+1],l=e[3*n+2],c=e[3*i],h=e[3*i+1],u=e[3*i+2],d=e[3*r],p=e[3*r+1],m=e[3*r+2],f=e[3*s],g=e[3*s+1],_=e[3*s+2];return Math.abs(o-h)<Math.abs(a-c)?[new me(a,1-l),new me(c,1-u),new me(d,1-m),new me(f,1-_)]:[new me(o,1-l),new me(h,1-u),new me(p,1-m),new me(g,1-_)]}};class Xc extends oc{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Xc(t.radius,t.detail)}}class jc extends oc{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new jc(t.radius,t.detail)}}class qc extends Ii{constructor(t=.5,e=1,n=32,i=1,r=0,s=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:s},n=Math.max(3,n);const a=[],o=[],l=[],c=[];let h=t;const u=(e-t)/(i=Math.max(1,i)),d=new We,p=new me;for(let t=0;t<=i;t++){for(let t=0;t<=n;t++){const i=r+t/n*s;d.x=h*Math.cos(i),d.y=h*Math.sin(i),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,c.push(p.x,p.y)}h+=u}for(let t=0;t<i;t++){const e=t*(n+1);for(let t=0;t<n;t++){const i=t+e,r=i,s=i+n+1,o=i+n+2,l=i+1;a.push(r,s,l),a.push(s,o,l)}}this.setIndex(a),this.setAttribute("position",new Ti(o,3)),this.setAttribute("normal",new Ti(l,3)),this.setAttribute("uv",new Ti(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qc(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class Yc extends Ii{constructor(t=new mc([new me(0,.5),new me(-.5,-.5),new me(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],r=[],s=[];let a=0,o=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(a,o,e),a+=o,o=0;function l(t){const a=i.length/3,l=t.extractPoints(e);let c=l.shape;const h=l.holes;!1===Gc.isClockWise(c)&&(c=c.reverse());for(let t=0,e=h.length;t<e;t++){const e=h[t];!0===Gc.isClockWise(e)&&(h[t]=e.reverse())}const u=Gc.triangulateShape(c,h);for(let t=0,e=h.length;t<e;t++){const e=h[t];c=c.concat(e)}for(let t=0,e=c.length;t<e;t++){const e=c[t];i.push(e.x,e.y,0),r.push(0,0,1),s.push(e.x,e.y)}for(let t=0,e=u.length;t<e;t++){const e=u[t],i=e[0]+a,r=e[1]+a,s=e[2]+a;n.push(i,r,s),o+=3}}this.setIndex(n),this.setAttribute("position",new Ti(i,3)),this.setAttribute("normal",new Ti(r,3)),this.setAttribute("uv",new Ti(s,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,i=t.length;n<i;n++){const i=t[n];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];n.push(r)}return new Yc(n,t.curveSegments)}}class Zc extends Ii{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:s,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const o=Math.min(s+a,Math.PI);let l=0;const c=[],h=new We,u=new We,d=[],p=[],m=[],f=[];for(let d=0;d<=n;d++){const g=[],_=d/n;let v=0;0===d&&0===s?v=.5/e:d===n&&o===Math.PI&&(v=-.5/e);for(let n=0;n<=e;n++){const o=n/e;h.x=-t*Math.cos(i+o*r)*Math.sin(s+_*a),h.y=t*Math.cos(s+_*a),h.z=t*Math.sin(i+o*r)*Math.sin(s+_*a),p.push(h.x,h.y,h.z),u.copy(h).normalize(),m.push(u.x,u.y,u.z),f.push(o+v,1-_),g.push(l++)}c.push(g)}for(let t=0;t<n;t++)for(let i=0;i<e;i++){const e=c[t][i+1],r=c[t][i],a=c[t+1][i],l=c[t+1][i+1];(0!==t||s>0)&&d.push(e,r,l),(t!==n-1||o<Math.PI)&&d.push(r,a,l)}this.setIndex(d),this.setAttribute("position",new Ti(p,3)),this.setAttribute("normal",new Ti(m,3)),this.setAttribute("uv",new Ti(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zc(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Jc extends oc{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Jc(t.radius,t.detail)}}class Kc extends Ii{constructor(t=1,e=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const s=[],a=[],o=[],l=[],c=new We,h=new We,u=new We;for(let s=0;s<=n;s++)for(let d=0;d<=i;d++){const p=d/i*r,m=s/n*Math.PI*2;h.x=(t+e*Math.cos(m))*Math.cos(p),h.y=(t+e*Math.cos(m))*Math.sin(p),h.z=e*Math.sin(m),a.push(h.x,h.y,h.z),c.x=t*Math.cos(p),c.y=t*Math.sin(p),u.subVectors(h,c).normalize(),o.push(u.x,u.y,u.z),l.push(d/i),l.push(s/n)}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+e-1,r=(i+1)*(t-1)+e-1,a=(i+1)*(t-1)+e,o=(i+1)*t+e;s.push(n,r,o),s.push(r,a,o)}this.setIndex(s),this.setAttribute("position",new Ti(a,3)),this.setAttribute("normal",new Ti(o,3)),this.setAttribute("uv",new Ti(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Kc(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class $c extends Ii{constructor(t=1,e=.4,n=64,i=8,r=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],h=new We,u=new We,d=new We,p=new We,m=new We,f=new We,g=new We;for(let a=0;a<=n;++a){const v=a/n*r*Math.PI*2;_(v,r,s,t,d),_(v+.01,r,s,t,p),f.subVectors(p,d),g.addVectors(p,d),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let t=0;t<=i;++t){const r=t/i*Math.PI*2,s=-e*Math.cos(r),p=e*Math.sin(r);h.x=d.x+(s*g.x+p*m.x),h.y=d.y+(s*g.y+p*m.y),h.z=d.z+(s*g.z+p*m.z),o.push(h.x,h.y,h.z),u.subVectors(h,d).normalize(),l.push(u.x,u.y,u.z),c.push(a/n),c.push(t/i)}}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),s=(i+1)*t+e,o=(i+1)*(t-1)+e;a.push(n,r,o),a.push(r,s,o)}function _(t,e,n,i,r){const s=Math.cos(t),a=Math.sin(t),o=n/e*t,l=Math.cos(o);r.x=i*(2+l)*.5*s,r.y=i*(2+l)*a*.5,r.z=i*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new Ti(o,3)),this.setAttribute("normal",new Ti(l,3)),this.setAttribute("uv",new Ti(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $c(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class Qc extends Ii{constructor(t=new Kl(new We(-1,-1,0),new We(-1,1,0),new We(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};const s=t.computeFrenetFrames(e,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const a=new We,o=new We,l=new me;let c=new We;const h=[],u=[],d=[],p=[];function m(r){c=t.getPointAt(r/e,c);const l=s.normals[r],d=s.binormals[r];for(let t=0;t<=i;t++){const e=t/i*Math.PI*2,r=Math.sin(e),s=-Math.cos(e);o.x=s*l.x+r*d.x,o.y=s*l.y+r*d.y,o.z=s*l.z+r*d.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=c.x+n*o.x,a.y=c.y+n*o.y,a.z=c.z+n*o.z,h.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)m(t);m(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let n=0;n<=i;n++)l.x=t/e,l.y=n/i,d.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),s=(i+1)*t+e,a=(i+1)*(t-1)+e;p.push(n,r,a),p.push(r,s,a)}}()}(),this.setIndex(p),this.setAttribute("position",new Ti(h,3)),this.setAttribute("normal",new Ti(u,3)),this.setAttribute("uv",new Ti(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new Qc((new Ql[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class th extends Ii{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],n=new Set,i=new We,r=new We;if(null!==t.index){const s=t.attributes.position,a=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let t=0,l=o.length;t<l;++t){const l=o[t],c=l.start;for(let t=c,o=c+l.count;t<o;t+=3)for(let o=0;o<3;o++){const l=a.getX(t+o),c=a.getX(t+(o+1)%3);i.fromBufferAttribute(s,l),r.fromBufferAttribute(s,c),!0===eh(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}}else{const s=t.attributes.position;for(let t=0,a=s.count/3;t<a;t++)for(let a=0;a<3;a++){const o=3*t+a,l=3*t+(a+1)%3;i.fromBufferAttribute(s,o),r.fromBufferAttribute(s,l),!0===eh(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new Ti(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function eh(t,e,n){const i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var nh=Object.freeze({__proto__:null,BoxGeometry:$i,CapsuleGeometry:ic,CircleGeometry:rc,ConeGeometry:ac,CylinderGeometry:sc,DodecahedronGeometry:lc,EdgesGeometry:pc,ExtrudeGeometry:kc,IcosahedronGeometry:Xc,LatheGeometry:nc,OctahedronGeometry:jc,PlaneGeometry:xr,PolyhedronGeometry:oc,RingGeometry:qc,ShapeGeometry:Yc,SphereGeometry:Zc,TetrahedronGeometry:Jc,TorusGeometry:Kc,TorusKnotGeometry:$c,TubeGeometry:Qc,WireframeGeometry:th});class ih extends di{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ci(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class rh extends ir{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class sh extends di{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ci(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 ci(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class ah extends sh{constructor(t){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 me(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ae(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 ci(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 ci(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ci(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class oh extends di{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ci(16777215),this.specular=new ci(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ci(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=h,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class lh extends di{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ci(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ci(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new me(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class ch extends di{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class hh extends di{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ci(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ci(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=h,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class uh extends di{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ci(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class dh extends fl{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function ph(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function mh(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function fh(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function gh(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[a++]=t[i+n]}return r}function _h(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(e.push(s.time),n.push.apply(n,a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(e.push(s.time),a.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(e.push(s.time),n.push(a)),s=t[r++]}while(void 0!==s)}const vh={convertArray:ph,isTypedArray:mh,getKeyframeOrder:fh,sortedArray:gh,flattenJSON:_h,subclip:function(t,e,n,i,r=30){const s=t.clone();s.name=e;const a=[];for(let t=0;t<s.tracks.length;++t){const e=s.tracks[t],o=e.getValueSize(),l=[],c=[];for(let t=0;t<e.times.length;++t){const s=e.times[t]*r;if(!(s<n||s>=i)){l.push(e.times[t]);for(let n=0;n<o;++n)c.push(e.values[t*o+n])}}0!==l.length&&(e.times=ph(l,e.times.constructor),e.values=ph(c,e.values.constructor),a.push(e))}s.tracks=a;let o=1/0;for(let t=0;t<s.tracks.length;++t)o>s.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t<s.tracks.length;++t)s.tracks[t].shift(-1*o);return s.resetDuration(),s},makeClipAdditive:function(t,e=0,n=t,i=30){i<=0&&(i=30);const r=n.tracks.length,s=e/i;for(let e=0;e<r;++e){const i=n.tracks[e],r=i.ValueTypeName;if("bool"===r||"string"===r)continue;const a=t.tracks.find((function(t){return t.name===i.name&&t.ValueTypeName===r}));if(void 0===a)continue;let o=0;const l=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let c=0;const h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);const u=i.times.length-1;let d;if(s<=i.times[0]){const t=o,e=l-o;d=i.values.slice(t,e)}else if(s>=i.times[u]){const t=u*l+o,e=t+l-o;d=i.values.slice(t,e)}else{const t=i.createInterpolant(),e=o,n=l-o;t.evaluate(s),d=t.resultBuffer.slice(e,n)}if("quaternion"===r){(new ke).fromArray(d).normalize().conjugate().toArray(d)}const p=a.times.length;for(let t=0;t<p;++t){const e=t*h+c;if("quaternion"===r)ke.multiplyQuaternionsFlat(a.values,e,d,0,a.values,e);else{const t=h-2*c;for(let n=0;n<t;++n)a.values[e+n]-=d[n]}}}return t.blendMode=Ot,t}};class xh{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let s;n:{i:if(!(t<i)){for(let s=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(r=i,i=e[++n],t<i)break e}s=e.length;break n}if(t>=r)break t;{const a=e[1];t<a&&(n=2,r=a);for(let s=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===s)break;if(i=r,r=e[--n-1],t>=r)break e}s=n,n=0}}for(;n<s;){const i=n+s>>>1;t<e[i]?s=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=n[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class yh extends xh{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:It,endingEnd:It}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,s=t+1,a=i[r],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case Ut:r=t,a=2*e-n;break;case Dt:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case Ut:s=t,o=2*n-e;break;case Dt:s=1,o=n+i[1]-i[0];break;default:s=t-1,o=e}const l=.5*(n-e),c=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-n),this._offsetPrev=r*c,this._offsetNext=s*c}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(n-e)/(i-e),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,_=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,v=(-1-d)*f+(1.5+d)*m+.5*p,x=d*f-d*m;for(let t=0;t!==a;++t)r[t]=g*s[c+t]+_*s[l+t]+v*s[o+t]+x*s[h+t];return r}}class Mh extends xh{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=(n-e)/(i-e),h=1-c;for(let t=0;t!==a;++t)r[t]=s[l+t]*h+s[o+t]*c;return r}}class Sh extends xh{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class bh{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ph(e,this.TimeBufferType),this.values=ph(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ph(t.times,Array),values:ph(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Sh(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Mh(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new yh(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ct:e=this.InterpolantFactoryMethodDiscrete;break;case Lt:e=this.InterpolantFactoryMethodLinear;break;case Pt:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ct;case this.InterpolantFactoryMethodLinear:return Lt;case this.InterpolantFactoryMethodSmooth:return Pt}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,s=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==s&&n[s]>e;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&mh(i))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Pt,r=t.length-1;let s=1;for(let a=1;a<r;++a){let r=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(i)r=!0;else{const t=a*n,i=t-n,s=t+n;for(let a=0;a!==n;++a){const n=e[t+a];if(n!==e[i+a]||n!==e[s+a]){r=!0;break}}}if(r){if(a!==s){t[s]=t[a];const i=a*n,r=s*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++s}}if(r>0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}bh.prototype.TimeBufferType=Float32Array,bh.prototype.ValueBufferType=Float32Array,bh.prototype.DefaultInterpolation=Lt;class Th extends bh{}Th.prototype.ValueTypeName="bool",Th.prototype.ValueBufferType=Array,Th.prototype.DefaultInterpolation=Ct,Th.prototype.InterpolantFactoryMethodLinear=void 0,Th.prototype.InterpolantFactoryMethodSmooth=void 0;class Eh extends bh{}Eh.prototype.ValueTypeName="color";class wh extends bh{}wh.prototype.ValueTypeName="number";class Ah extends xh{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let t=l+a;l!==t;l+=4)ke.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Rh extends bh{InterpolantFactoryMethodLinear(t){return new Ah(this.times,this.values,this.getValueSize(),t)}}Rh.prototype.ValueTypeName="quaternion",Rh.prototype.DefaultInterpolation=Lt,Rh.prototype.InterpolantFactoryMethodSmooth=void 0;class Ch extends bh{}Ch.prototype.ValueTypeName="string",Ch.prototype.ValueBufferType=Array,Ch.prototype.DefaultInterpolation=Ct,Ch.prototype.InterpolantFactoryMethodLinear=void 0,Ch.prototype.InterpolantFactoryMethodSmooth=void 0;class Lh extends bh{}Lh.prototype.ValueTypeName="vector";class Ph{constructor(t,e=-1,n,i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=se(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(Ih(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(bh.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let t=0;t<r;t++){let a=[],o=[];a.push((t+r-1)%r,t,(t+1)%r),o.push(0,1,0);const l=fh(a);a=gh(a,1,l),o=gh(o,1,l),i||0!==a[0]||(a.push(r),o.push(o[0])),s.push(new wh(".morphTargetInfluences["+e[t].name+"]",a,o).scale(1/n))}return new this(t,-1,s)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.name.match(r);if(s&&s.length>1){const t=s[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const s=[];for(const t in i)s.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],a=[];_h(n,s,a,i),0!==s.length&&r.push(new t(e,s,a))}},i=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const r=l[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let n=0;n<r[e].morphTargets.length;n++)t[r[e].morphTargets[n]]=-1;for(const n in t){const t=[],s=[];for(let i=0;i!==r[e].morphTargets.length;++i){const i=r[e];t.push(i.time),s.push(i.morphTarget===n?1:0)}i.push(new wh(".morphTargetInfluence["+n+"]",t,s))}o=t.length*s}else{const s=".bones["+e[t].name+"]";n(Lh,s+".position",r,"pos",i),n(Rh,s+".quaternion",r,"rot",i),n(Lh,s+".scale",r,"scl",i)}}if(0===i.length)return null;return new this(r,o,i,a)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Ih(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return wh;case"vector":case"vector2":case"vector3":case"vector4":return Lh;case"color":return Eh;case"quaternion":return Rh;case"bool":case"boolean":return Th;case"string":return Ch}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];_h(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const Uh={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class Dh{constructor(t,e,n){const i=this;let r,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){o++,!1===s&&void 0!==i.onStart&&i.onStart(t,a,o),s=!0},this.itemEnd=function(t){a++,void 0!==i.onProgress&&i.onProgress(t,a,o),a===o&&(s=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null}}}const Nh=new Dh;class Oh{constructor(t){this.manager=void 0!==t?t:Nh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Oh.DEFAULT_MATERIAL_NAME="__DEFAULT";const Fh={};class Bh extends Error{constructor(t,e){super(t),this.response=e}}class zh extends Oh{constructor(t){super(t)}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=Uh.get(t);if(void 0!==r)return this.manager.itemStart(t),setTimeout((()=>{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==Fh[t])return void Fh[t].push({onLoad:e,onProgress:n,onError:i});Fh[t]=[],Fh[t].push({onLoad:e,onProgress:n,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=Fh[t],i=e.body.getReader(),r=e.headers.get("Content-Length")||e.headers.get("X-File-Size"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onProgress&&e.onProgress(i)}t.enqueue(r),e()}}))}()}});return new Response(l)}throw new Bh(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{Uh.add(t,e);const n=Fh[t];delete Fh[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onLoad&&i.onLoad(e)}})).catch((e=>{const n=Fh[t];if(void 0===n)throw this.manager.itemError(t),e;delete Fh[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}this.manager.itemError(t)})).finally((()=>{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Gh extends Oh{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Uh.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const a=ye("img");function o(){c(),Uh.add(t,this),e&&e(this),r.manager.itemEnd(t)}function l(e){c(),i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(t),a.src=t,a}}class Hh extends jn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ci(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}class Vh extends Hh{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(jn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ci(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const kh=new Mn,Wh=new We,Xh=new We;class jh{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new me(512,512),this.map=null,this.mapPass=null,this.matrix=new Mn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new gr,this._frameExtents=new me(1,1),this._viewportCount=1,this._viewports=[new Be(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Wh.setFromMatrixPosition(t.matrixWorld),e.position.copy(Wh),Xh.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Xh),e.updateMatrixWorld(),kh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(kh),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(kh)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class qh extends jh{constructor(){super(new sr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,n=2*re*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Yh extends Hh{constructor(t,e,n=0,i=Math.PI/3,r=0,s=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(jn.DEFAULT_UP),this.updateMatrix(),this.target=new jn,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new qh}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Zh=new Mn,Jh=new We,Kh=new We;class $h extends jh{constructor(){super(new sr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new me(4,2),this._viewportCount=6,this._viewports=[new Be(2,1,1,1),new Be(0,1,1,1),new Be(3,1,1,1),new Be(1,1,1,1),new Be(3,0,1,1),new Be(1,0,1,1)],this._cubeDirections=[new We(1,0,0),new We(-1,0,0),new We(0,0,1),new We(0,0,-1),new We(0,1,0),new We(0,-1,0)],this._cubeUps=[new We(0,1,0),new We(0,1,0),new We(0,1,0),new We(0,1,0),new We(0,0,1),new We(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Jh.setFromMatrixPosition(t.matrixWorld),n.position.copy(Jh),Kh.copy(n.position),Kh.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Kh),n.updateMatrixWorld(),i.makeTranslation(-Jh.x,-Jh.y,-Jh.z),Zh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Zh)}}class Qh extends Hh{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new $h}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class tu extends jh{constructor(){super(new Lr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class eu extends Hh{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(jn.DEFAULT_UP),this.updateMatrix(),this.target=new jn,this.shadow=new tu}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class nu extends Hh{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class iu extends Hh{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class ru{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new We)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.282095),e.addScaledVector(s[1],.488603*i),e.addScaledVector(s[2],.488603*r),e.addScaledVector(s[3],.488603*n),e.addScaledVector(s[4],n*i*1.092548),e.addScaledVector(s[5],i*r*1.092548),e.addScaledVector(s[6],.315392*(3*r*r-1)),e.addScaledVector(s[7],n*r*1.092548),e.addScaledVector(s[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.886227),e.addScaledVector(s[1],1.023328*i),e.addScaledVector(s[2],1.023328*r),e.addScaledVector(s[3],1.023328*n),e.addScaledVector(s[4],.858086*n*i),e.addScaledVector(s[5],.858086*i*r),e.addScaledVector(s[6],.743125*r*r-.247708),e.addScaledVector(s[7],.858086*n*r),e.addScaledVector(s[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+3*i);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+3*i);return t}static getBasisAt(t,e){const n=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*n*r,e[8]=.546274*(n*n-i*i)}}class su extends Hh{constructor(t=new ru,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class au extends Oh{constructor(t){super(t),this.textures={}}load(t,e,n,i){const r=this,s=new zh(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=this.textures;function n(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}const i=au.createMaterialFromType(t.type);if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new ci).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.iridescence&&(i.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(i.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(i.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(i.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(i.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(i.depthFunc=t.depthFunc),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(i.blendSrc=t.blendSrc),void 0!==t.blendDst&&(i.blendDst=t.blendDst),void 0!==t.blendEquation&&(i.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(i.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(i.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(i.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(i.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),void 0!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(i.forceSinglePass=t.forceSinglePass),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=n(r.value);break;case"c":i.uniforms[e].value=(new ci).setHex(r.value);break;case"v2":i.uniforms[e].value=(new me).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new We).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new Be).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new fe).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new Mn).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new me).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new me).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){return new{ShadowMaterial:ih,SpriteMaterial:lo,RawShaderMaterial:rh,ShaderMaterial:ir,PointsMaterial:wl,MeshPhysicalMaterial:ah,MeshStandardMaterial:sh,MeshPhongMaterial:oh,MeshToonMaterial:lh,MeshNormalMaterial:ch,MeshLambertMaterial:hh,MeshDepthMaterial:Ha,MeshDistanceMaterial:Va,MeshBasicMaterial:pi,MeshMatcapMaterial:uh,LineDashedMaterial:dh,LineBasicMaterial:fl,Material:di}[t]}}class ou{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(t){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class lu extends Ii{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class cu extends Oh{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new zh(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}parse(t){const e={},n={};function i(t,i){if(void 0!==e[i])return e[i];const r=t.interleavedBuffers[i],s=function(t,e){if(void 0!==n[e])return n[e];const i=t.arrayBuffers,r=i[e],s=new Uint32Array(r).buffer;return n[e]=s,s}(t,r.buffer),a=xe(r.type,s),o=new so(a,r.stride);return o.uuid=r.uuid,e[i]=o,o}const r=t.isInstancedBufferGeometry?new lu:new Ii,s=t.data.index;if(void 0!==s){const t=xe(s.type,s.array);r.setIndex(new Mi(t,1))}const a=t.data.attributes;for(const e in a){const n=a[e];let s;if(n.isInterleavedBufferAttribute){const e=i(t.data,n.data);s=new oo(e,n.itemSize,n.offset,n.normalized)}else{const t=xe(n.type,n.array);s=new(n.isInstancedBufferAttribute?ko:Mi)(t,n.itemSize,n.normalized)}void 0!==n.name&&(s.name=n.name),void 0!==n.usage&&s.setUsage(n.usage),r.setAttribute(e,s)}const o=t.data.morphAttributes;if(o)for(const e in o){const n=o[e],s=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];let a;if(r.isInterleavedBufferAttribute){const e=i(t.data,r.data);a=new oo(e,r.itemSize,r.offset,r.normalized)}else{const t=xe(r.type,r.array);a=new Mi(t,r.itemSize,r.normalized)}void 0!==r.name&&(a.name=r.name),s.push(a)}r.morphAttributes[e]=s}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let t=0,e=l.length;t!==e;++t){const e=l[t];r.addGroup(e.start,e.count,e.materialIndex)}const c=t.data.boundingSphere;if(void 0!==c){const t=new We;void 0!==c.center&&t.fromArray(c.center),r.boundingSphere=new dn(t,c.radius)}return t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}const hu={UVMapping:S,CubeReflectionMapping:b,CubeRefractionMapping:T,EquirectangularReflectionMapping:E,EquirectangularRefractionMapping:w,CubeUVReflectionMapping:A},uu={RepeatWrapping:R,ClampToEdgeWrapping:C,MirroredRepeatWrapping:L},du={NearestFilter:P,NearestMipmapNearestFilter:I,NearestMipmapLinearFilter:U,LinearFilter:D,LinearMipmapNearestFilter:N,LinearMipmapLinearFilter:O};let pu;class mu{static getContext(){return void 0===pu&&(pu=new(window.AudioContext||window.webkitAudioContext)),pu}static setContext(t){pu=t}}const fu=new Mn,gu=new Mn,_u=new Mn;class vu{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=xu(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=xu();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function xu(){return("undefined"==typeof performance?Date:performance).now()}const yu=new We,Mu=new ke,Su=new We,bu=new We;class Tu extends jn{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.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(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}const Eu=new We,wu=new ke,Au=new We,Ru=new We;class Cu{constructor(t,e,n){let i,r,s;switch(this.binding=t,this.valueSize=n,e){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,r=t*i+i;let s=this.cumulativeWeight;if(0===s){for(let t=0;t!==i;++t)n[r+t]=n[t];s=e}else{s+=e;const t=e/s;this._mixBufferRegion(n,r,0,t,i)}this.cumulativeWeight=s}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(n,i,t,1-r,e)}s>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,r=i;t!==r;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,r){if(i>=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){ke.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const s=this._workIndex*r;ke.multiplyQuaternionsFlat(t,s,t,e,t,n),ke.slerpFlat(t,e,t,e,t,s,i)}_lerp(t,e,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*s+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[n+s]*i}}}const Lu="\\[\\]\\.:\\/",Pu=new RegExp("["+Lu+"]","g"),Iu="[^"+Lu+"]",Uu="[^"+Lu.replace("\\.","")+"]",Du=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Iu)+/(WCOD+)?/.source.replace("WCOD",Uu)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Iu)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Iu)+"$"),Nu=["material","materials","bones","map"];class Ou{constructor(t,e,n){this.path=e,this.parsedPath=n||Ou.parseTrackName(e),this.node=Ou.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Ou.Composite(t,e,n):new Ou(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Pu,"")}static parseTrackName(t){const e=Du.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==Nu.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const s=n(r.children);if(s)return s}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=Ou.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==i){if(void 0===t[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const s=t[i];if(void 0===s){const n=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",t)}let a=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Ou.Composite=class{constructor(t,e,n){const i=n||Ou.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Ou.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Ou.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Ou.prototype.GetterByBindingType=[Ou.prototype._getValue_direct,Ou.prototype._getValue_array,Ou.prototype._getValue_arrayElement,Ou.prototype._getValue_toArray],Ou.prototype.SetterByBindingTypeAndVersioning=[[Ou.prototype._setValue_direct,Ou.prototype._setValue_direct_setNeedsUpdate,Ou.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ou.prototype._setValue_array,Ou.prototype._setValue_array_setNeedsUpdate,Ou.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ou.prototype._setValue_arrayElement,Ou.prototype._setValue_arrayElement_setNeedsUpdate,Ou.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ou.prototype._setValue_fromArray,Ou.prototype._setValue_fromArray_setNeedsUpdate,Ou.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Fu{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,s=r.length,a=new Array(s),o={endingStart:It,endingEnd:It};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),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&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,i=t._clip.duration,r=i/n,s=n/i;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=t/s,l[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const s=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Ot)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(s),e[n].accumulateAdditive(a);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(s),e[n].accumulate(i,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const s=2202===n;if(0===t)return-1===r?i:s&&1==(1&r)?e-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&1==(1&r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=Ut,i.endingEnd=Ut):(i.endingStart=t?this.zeroSlopeAtStart?Ut:It:Dt,i.endingEnd=e?this.zeroSlopeAtEnd?Ut:It:Dt)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=n,this}}const Bu=new Float32Array(1);class zu{constructor(t){this.value=t}clone(){return new zu(void 0===this.value.clone?this.value:this.value.clone())}}let Gu=0;function Hu(t,e){return t.distance-e.distance}function Vu(t,e,n,i){if(t.layers.test(e.layers)&&t.raycast(e,n),!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)Vu(i[t],e,n,!0)}}const ku=new me;const Wu=new We,Xu=new We;const ju=new We;const qu=new We,Yu=new Mn,Zu=new Mn;function Ju(t){const e=[];!0===t.isBone&&e.push(t);for(let n=0;n<t.children.length;n++)e.push.apply(e,Ju(t.children[n]));return e}const Ku=new We,$u=new ci,Qu=new ci;const td=new We,ed=new We,nd=new We;const id=new We,rd=new rr;function sd(t,e,n,i,r,s,a){id.set(r,s,a).unproject(i);const o=e[t];if(void 0!==o){const t=n.getAttribute("position");for(let e=0,n=o.length;e<n;e++)t.setXYZ(o[e],id.x,id.y,id.z)}}const ad=new qe;const od=new We;let ld,cd;"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:e}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=e),t.ACESFilmicToneMapping=_,t.AddEquation=o,t.AddOperation=d,t.AdditiveAnimationBlendMode=Ot,t.AdditiveBlending=2,t.AgXToneMapping=x,t.AlphaFormat=1021,t.AlwaysCompare=519,t.AlwaysDepth=1,t.AlwaysStencilFunc=519,t.AmbientLight=nu,t.AnimationAction=Fu,t.AnimationClip=Ph,t.AnimationLoader=class extends Oh{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new zh(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=[];for(let n=0;n<t.length;n++){const i=Ph.parse(t[n]);e.push(i)}return e}},t.AnimationMixer=class extends te{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,s=t._propertyBindings,a=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[t]=h;else{if(h=s[t],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;h=new Cu(Ou.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[t]=h}a[t].resultBuffer=h.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=i.length,i.push(t),s.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,l=o[o.length-1],c=t._byClipCacheIndex;l._byClipCacheIndex=c,o[c]=l,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,r=this._bindings;let s=i[e];void 0===s&&(s={},i[e]=s),s[n]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,a=s[i],o=e[e.length-1],l=t._cacheIndex;o._cacheIndex=l,e[l]=o,e.pop(),delete a[r],0===Object.keys(a).length&&delete s[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return void 0===n&&(n=new Mh(new Float32Array(2),new Float32Array(2),1,Bu),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r}clipAction(t,e,n){const i=e||this._root,r=i.uuid;let s="string"==typeof t?Ph.findByName(i,t):t;const a=null!==s?s.uuid:t,o=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==s?s.blendMode:Nt),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===n)return t;l=o.knownActions[0],null===s&&(s=l._clip)}if(null===s)return null;const c=new Fu(this,s,e,n);return this._bindAction(c,l),this._addInactiveAction(c,a,r),c}existingAction(t,e){const n=e||this._root,i=n.uuid,r="string"==typeof t?Ph.findByName(n,t):t,s=r?r.uuid:t,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[i]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==n;++a){e[a]._update(i,t,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const t=r.knownActions;for(let n=0,i=t.length;n!==i;++n){const i=t[n];this._deactivateAction(i);const r=i._cacheIndex,s=e[e.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const t in n){const i=n[t].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[e];if(void 0!==i)for(const t in i){const e=i[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}},t.AnimationObjectGroup=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=se(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,s=r.length;let a,o=t.length,l=this.nCachedObjects_;for(let c=0,h=arguments.length;c!==h;++c){const h=arguments[c],u=h.uuid;let d=e[u];if(void 0===d){d=o++,e[u]=d,t.push(h);for(let t=0,e=s;t!==e;++t)r[t].push(new Ou(h,n[t],i[t]))}else if(d<l){a=t[d];const o=--l,c=t[o];e[c.uuid]=d,t[d]=c,e[u]=o,t[o]=h;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[o];let a=e[d];e[d]=s,void 0===a&&(a=new Ou(h,n[t],i[t])),e[o]=a}}else t[d]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,l=e[o];if(void 0!==l&&l>=r){const s=r++,c=t[s];e[c.uuid]=l,t[l]=c,e[o]=s,t[s]=a;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[l];e[l]=i,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l<r){const a=--r,o=t[a],c=--s,h=t[c];e[o.uuid]=l,t[l]=o,e[h.uuid]=a,t[a]=h,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[a],r=e[c];e[l]=i,e[a]=r,e.pop()}}else{const r=--s,a=t[r];r>0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,s.push(t),a.push(e),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new Ou(i,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}},t.AnimationUtils=vh,t.ArcCurve=Ol,t.ArrayCamera=qa,t.ArrowHelper=class extends jn{constructor(t=new We(0,0,1),e=new We(0,0,0),n=1,i=16776960,r=.2*n,s=.2*r){super(),this.type="ArrowHelper",void 0===ld&&(ld=new Ii,ld.setAttribute("position",new Ti([0,0,0,0,1,0],3)),cd=new sc(0,.5,1,5,1),cd.translate(0,-.5,0)),this.position.copy(e),this.line=new Ml(ld,new fl({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ji(cd,new pi({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,r,s)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{od.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(od,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},t.AttachedBindMode=y,t.Audio=Tu,t.AudioAnalyser=class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}},t.AudioContext=mu,t.AudioListener=class extends jn{constructor(){super(),this.type="AudioListener",this.context=mu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new vu}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(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(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(yu,Mu,Su),bu.set(0,0,-1).applyQuaternion(Mu),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(yu.x,t),e.positionY.linearRampToValueAtTime(yu.y,t),e.positionZ.linearRampToValueAtTime(yu.z,t),e.forwardX.linearRampToValueAtTime(bu.x,t),e.forwardY.linearRampToValueAtTime(bu.y,t),e.forwardZ.linearRampToValueAtTime(bu.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(yu.x,yu.y,yu.z),e.setOrientation(bu.x,bu.y,bu.z,n.x,n.y,n.z)}},t.AudioLoader=class extends Oh{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new zh(this.manager);function a(e){i?i(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(t){try{const n=t.slice(0);mu.getContext().decodeAudioData(n,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),n,i)}},t.AxesHelper=class extends Tl{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new Ii;n.setAttribute("position",new Ti(e,3)),n.setAttribute("color",new Ti([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new fl({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const i=new ci,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},t.BackSide=a,t.BasicDepthPacking=3200,t.BasicShadowMap=0,t.BatchedMesh=ml,t.Bone=Bo,t.BooleanKeyframeTrack=Th,t.Box2=class{constructor(t=new me(1/0,1/0),e=new me(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=ku.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ku).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},t.Box3=qe,t.Box3Helper=class extends Tl{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Ii;i.setIndex(new Mi(n,1)),i.setAttribute("position",new Ti([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new fl({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},t.BoxGeometry=$i,t.BoxHelper=class extends Tl{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new Ii;r.setIndex(new Mi(n,1)),r.setAttribute("position",new Mi(i,3)),super(r,new fl({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&ad.setFromObject(this.object),ad.isEmpty())return;const e=ad.min,n=ad.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=e.x,r[4]=n.y,r[5]=n.z,r[6]=e.x,r[7]=e.y,r[8]=n.z,r[9]=n.x,r[10]=e.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=e.z,r[15]=e.x,r[16]=n.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=n.x,r[22]=e.y,r[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},t.BufferAttribute=Mi,t.BufferGeometry=Ii,t.BufferGeometryLoader=cu,t.ByteType=1010,t.Cache=Uh,t.Camera=rr,t.CameraHelper=class extends Tl{constructor(t){const e=new Ii,n=new fl({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],s={};function a(t,e){o(t),o(e)}function o(t){i.push(0,0,0),r.push(0,0,0),void 0===s[t]&&(s[t]=[]),s[t].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new Ti(i,3)),e.setAttribute("color",new Ti(r,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const l=new ci(16755200),c=new ci(16711680),h=new ci(43775),u=new ci(16777215),d=new ci(3355443);this.setColors(l,c,h,u,d)}setColors(t,e,n,i,r){const s=this.geometry.getAttribute("color");s.setXYZ(0,t.r,t.g,t.b),s.setXYZ(1,t.r,t.g,t.b),s.setXYZ(2,t.r,t.g,t.b),s.setXYZ(3,t.r,t.g,t.b),s.setXYZ(4,t.r,t.g,t.b),s.setXYZ(5,t.r,t.g,t.b),s.setXYZ(6,t.r,t.g,t.b),s.setXYZ(7,t.r,t.g,t.b),s.setXYZ(8,t.r,t.g,t.b),s.setXYZ(9,t.r,t.g,t.b),s.setXYZ(10,t.r,t.g,t.b),s.setXYZ(11,t.r,t.g,t.b),s.setXYZ(12,t.r,t.g,t.b),s.setXYZ(13,t.r,t.g,t.b),s.setXYZ(14,t.r,t.g,t.b),s.setXYZ(15,t.r,t.g,t.b),s.setXYZ(16,t.r,t.g,t.b),s.setXYZ(17,t.r,t.g,t.b),s.setXYZ(18,t.r,t.g,t.b),s.setXYZ(19,t.r,t.g,t.b),s.setXYZ(20,t.r,t.g,t.b),s.setXYZ(21,t.r,t.g,t.b),s.setXYZ(22,t.r,t.g,t.b),s.setXYZ(23,t.r,t.g,t.b),s.setXYZ(24,e.r,e.g,e.b),s.setXYZ(25,e.r,e.g,e.b),s.setXYZ(26,e.r,e.g,e.b),s.setXYZ(27,e.r,e.g,e.b),s.setXYZ(28,e.r,e.g,e.b),s.setXYZ(29,e.r,e.g,e.b),s.setXYZ(30,e.r,e.g,e.b),s.setXYZ(31,e.r,e.g,e.b),s.setXYZ(32,n.r,n.g,n.b),s.setXYZ(33,n.r,n.g,n.b),s.setXYZ(34,n.r,n.g,n.b),s.setXYZ(35,n.r,n.g,n.b),s.setXYZ(36,n.r,n.g,n.b),s.setXYZ(37,n.r,n.g,n.b),s.setXYZ(38,i.r,i.g,i.b),s.setXYZ(39,i.r,i.g,i.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;rd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),sd("c",e,t,rd,0,0,-1),sd("t",e,t,rd,0,0,1),sd("n1",e,t,rd,-1,-1,-1),sd("n2",e,t,rd,1,-1,-1),sd("n3",e,t,rd,-1,1,-1),sd("n4",e,t,rd,1,1,-1),sd("f1",e,t,rd,-1,-1,1),sd("f2",e,t,rd,1,-1,1),sd("f3",e,t,rd,-1,1,1),sd("f4",e,t,rd,1,1,1),sd("u1",e,t,rd,.7,1.1,-1),sd("u2",e,t,rd,-.7,1.1,-1),sd("u3",e,t,rd,0,2,-1),sd("cf1",e,t,rd,-1,0,1),sd("cf2",e,t,rd,1,0,1),sd("cf3",e,t,rd,0,-1,1),sd("cf4",e,t,rd,0,1,1),sd("cn1",e,t,rd,-1,0,-1),sd("cn2",e,t,rd,1,0,-1),sd("cn3",e,t,rd,0,-1,-1),sd("cn4",e,t,rd,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},t.CanvasTexture=class extends Fe{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},t.CapsuleGeometry=ic,t.CatmullRomCurve3=Vl,t.CineonToneMapping=g,t.CircleGeometry=rc,t.ClampToEdgeWrapping=C,t.Clock=vu,t.Color=ci,t.ColorKeyframeTrack=Eh,t.ColorManagement=Re,t.CompressedArrayTexture=class extends Ul{constructor(t,e,n,i,r,s){super(t,e,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=C}},t.CompressedCubeTexture=class extends Ul{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,b),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},t.CompressedTexture=Ul,t.CompressedTextureLoader=class extends Oh{constructor(t){super(t)}load(t,e,n,i){const r=this,s=[],a=new Ul,o=new zh(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let l=0;function c(c){o.load(t[c],(function(t){const n=r.parse(t,!0);s[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=D),a.image=s,a.format=n.format,a.needsUpdate=!0,e&&e(a))}),n,i)}if(Array.isArray(t))for(let e=0,n=t.length;e<n;++e)c(e);else o.load(t,(function(t){const n=r.parse(t,!0);if(n.isCubemap){const t=n.mipmaps.length/n.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<n.mipmapCount;t++)s[e].mipmaps.push(n.mipmaps[e*n.mipmapCount+t]),s[e].format=n.format,s[e].width=n.width,s[e].height=n.height}a.image=s}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=D),a.format=n.format,a.needsUpdate=!0,e&&e(a)}),n,i);return a}},t.ConeGeometry=ac,t.ConstantAlphaFactor=213,t.ConstantColorFactor=211,t.CubeCamera=or,t.CubeReflectionMapping=b,t.CubeRefractionMapping=T,t.CubeTexture=lr,t.CubeTextureLoader=class extends Oh{constructor(t){super(t)}load(t,e,n,i){const r=new lr;r.colorSpace=Gt;const s=new Gh(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(n){s.load(t[n],(function(t){r.images[n]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))}),void 0,i)}for(let e=0;e<t.length;++e)o(e);return r}},t.CubeUVReflectionMapping=A,t.CubicBezierCurve=jl,t.CubicBezierCurve3=ql,t.CubicInterpolant=yh,t.CullFaceBack=1,t.CullFaceFront=2,t.CullFaceFrontBack=3,t.CullFaceNone=0,t.Curve=Dl,t.CurvePath=tc,t.CustomBlending=5,t.CustomToneMapping=v,t.CylinderGeometry=sc,t.Cylindrical=class{constructor(t=1,e=0,n=0){return this.radius=t,this.theta=e,this.y=n,this}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return(new this.constructor).copy(this)}},t.Data3DTexture=Ve,t.DataArrayTexture=He,t.DataTexture=zo,t.DataTextureLoader=class extends Oh{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new zo,a=new zh(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,(function(t){let n;try{n=r.parse(t)}catch(t){if(void 0===i)return void console.error(t);i(t)}void 0!==n.image?s.image=n.image:void 0!==n.data&&(s.image.width=n.width,s.image.height=n.height,s.image.data=n.data),s.wrapS=void 0!==n.wrapS?n.wrapS:C,s.wrapT=void 0!==n.wrapT?n.wrapT:C,s.magFilter=void 0!==n.magFilter?n.magFilter:D,s.minFilter=void 0!==n.minFilter?n.minFilter:D,s.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace?s.colorSpace=n.colorSpace:void 0!==n.encoding&&(s.encoding=n.encoding),void 0!==n.flipY&&(s.flipY=n.flipY),void 0!==n.format&&(s.format=n.format),void 0!==n.type&&(s.type=n.type),void 0!==n.mipmaps&&(s.mipmaps=n.mipmaps,s.minFilter=O),1===n.mipmapCount&&(s.minFilter=D),void 0!==n.generateMipmaps&&(s.generateMipmaps=n.generateMipmaps),s.needsUpdate=!0,e&&e(s,n)}),n,i),s}},t.DataUtils=vi,t.DecrementStencilOp=7683,t.DecrementWrapStencilOp=34056,t.DefaultLoadingManager=Nh,t.DepthFormat=q,t.DepthStencilFormat=Y,t.DepthTexture=ns,t.DetachedBindMode=M,t.DirectionalLight=eu,t.DirectionalLightHelper=class extends jn{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===e&&(e=1);let i=new Ii;i.setAttribute("position",new Ti([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new fl({fog:!1,toneMapped:!1});this.lightPlane=new Ml(i,r),this.add(this.lightPlane),i=new Ii,i.setAttribute("position",new Ti([0,0,0,0,0,1],3)),this.targetLine=new Ml(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),td.setFromMatrixPosition(this.light.matrixWorld),ed.setFromMatrixPosition(this.light.target.matrixWorld),nd.subVectors(ed,td),this.lightPlane.lookAt(ed),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(ed),this.targetLine.scale.z=nd.length()}},t.DiscreteInterpolant=Sh,t.DisplayP3ColorSpace=Vt,t.DodecahedronGeometry=lc,t.DoubleSide=2,t.DstAlphaFactor=206,t.DstColorFactor=208,t.DynamicCopyUsage=35050,t.DynamicDrawUsage=35048,t.DynamicReadUsage=35049,t.EdgesGeometry=pc,t.EllipseCurve=Nl,t.EqualCompare=514,t.EqualDepth=4,t.EqualStencilFunc=514,t.EquirectangularReflectionMapping=E,t.EquirectangularRefractionMapping=w,t.Euler=Pn,t.EventDispatcher=te,t.ExtrudeGeometry=kc,t.FileLoader=zh,t.Float16BufferAttribute=class extends Mi{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=_i(this.array[t*this.itemSize]);return this.normalized&&(e=ue(e,this.array)),e}setX(t,e){return this.normalized&&(e=de(e,this.array)),this.array[t*this.itemSize]=gi(e),this}getY(t){let e=_i(this.array[t*this.itemSize+1]);return this.normalized&&(e=ue(e,this.array)),e}setY(t,e){return this.normalized&&(e=de(e,this.array)),this.array[t*this.itemSize+1]=gi(e),this}getZ(t){let e=_i(this.array[t*this.itemSize+2]);return this.normalized&&(e=ue(e,this.array)),e}setZ(t,e){return this.normalized&&(e=de(e,this.array)),this.array[t*this.itemSize+2]=gi(e),this}getW(t){let e=_i(this.array[t*this.itemSize+3]);return this.normalized&&(e=ue(e,this.array)),e}setW(t,e){return this.normalized&&(e=de(e,this.array)),this.array[t*this.itemSize+3]=gi(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=de(e,this.array),n=de(n,this.array)),this.array[t+0]=gi(e),this.array[t+1]=gi(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=de(e,this.array),n=de(n,this.array),i=de(i,this.array)),this.array[t+0]=gi(e),this.array[t+1]=gi(n),this.array[t+2]=gi(i),this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=de(e,this.array),n=de(n,this.array),i=de(i,this.array),r=de(r,this.array)),this.array[t+0]=gi(e),this.array[t+1]=gi(n),this.array[t+2]=gi(i),this.array[t+3]=gi(r),this}},t.Float32BufferAttribute=Ti,t.Float64BufferAttribute=class extends Mi{constructor(t,e,n){super(new Float64Array(t),e,n)}},t.FloatType=H,t.Fog=io,t.FogExp2=no,t.FramebufferTexture=class extends Fe{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=P,this.minFilter=P,this.generateMipmaps=!1,this.needsUpdate=!0}},t.FrontSide=s,t.Frustum=gr,t.GLBufferAttribute=class{constructor(t,e,n,i,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},t.GLSL1="100",t.GLSL3=Jt,t.GreaterCompare=516,t.GreaterDepth=6,t.GreaterEqualCompare=518,t.GreaterEqualDepth=5,t.GreaterEqualStencilFunc=518,t.GreaterStencilFunc=516,t.GridHelper=class extends Tl{constructor(t=10,e=10,n=4473924,i=8947848){n=new ci(n),i=new ci(i);const r=e/2,s=t/e,a=t/2,o=[],l=[];for(let t=0,c=0,h=-a;t<=e;t++,h+=s){o.push(-a,0,h,a,0,h),o.push(h,0,-a,h,0,a);const e=t===r?n:i;e.toArray(l,c),c+=3,e.toArray(l,c),c+=3,e.toArray(l,c),c+=3,e.toArray(l,c),c+=3}const c=new Ii;c.setAttribute("position",new Ti(o,3)),c.setAttribute("color",new Ti(l,3));super(c,new fl({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},t.Group=Ya,t.HalfFloatType=V,t.HemisphereLight=Vh,t.HemisphereLightHelper=class extends jn{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new jc(e);i.rotateY(.5*Math.PI),this.material=new pi({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),s=new Float32Array(3*r.count);i.setAttribute("color",new Mi(s,3)),this.add(new Ji(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");$u.copy(this.light.color),Qu.copy(this.light.groundColor);for(let t=0,n=e.count;t<n;t++){const i=t<n/2?$u:Qu;e.setXYZ(t,i.r,i.g,i.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Ku.setFromMatrixPosition(this.light.matrixWorld).negate())}},t.IcosahedronGeometry=Xc,t.ImageBitmapLoader=class extends Oh{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Uh.get(t);if(void 0!==s)return r.manager.itemStart(t),s.then?void s.then((n=>{e&&e(n),r.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return Uh.add(t,n),e&&e(n),r.manager.itemEnd(t),n})).catch((function(e){i&&i(e),Uh.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));Uh.add(t,o),r.manager.itemStart(t)}},t.ImageLoader=Gh,t.ImageUtils=Ie,t.IncrementStencilOp=7682,t.IncrementWrapStencilOp=34055,t.InstancedBufferAttribute=ko,t.InstancedBufferGeometry=lu,t.InstancedInterleavedBuffer=class extends so{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}},t.InstancedMesh=Ko,t.Int16BufferAttribute=class extends Mi{constructor(t,e,n){super(new Int16Array(t),e,n)}},t.Int32BufferAttribute=class extends Mi{constructor(t,e,n){super(new Int32Array(t),e,n)}},t.Int8BufferAttribute=class extends Mi{constructor(t,e,n){super(new Int8Array(t),e,n)}},t.IntType=z,t.InterleavedBuffer=so,t.InterleavedBufferAttribute=oo,t.Interpolant=xh,t.InterpolateDiscrete=Ct,t.InterpolateLinear=Lt,t.InterpolateSmooth=Pt,t.InvertStencilOp=5386,t.KeepStencilOp=Yt,t.KeyframeTrack=bh,t.LOD=Ao,t.LatheGeometry=nc,t.Layers=In,t.LessCompare=513,t.LessDepth=2,t.LessEqualCompare=515,t.LessEqualDepth=3,t.LessEqualStencilFunc=515,t.LessStencilFunc=513,t.Light=Hh,t.LightProbe=su,t.Line=Ml,t.Line3=class{constructor(t=new We,e=new We){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Wu.subVectors(t,this.start),Xu.subVectors(this.end,this.start);const n=Xu.dot(Xu);let i=Xu.dot(Wu)/n;return e&&(i=ae(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},t.LineBasicMaterial=fl,t.LineCurve=Yl,t.LineCurve3=Zl,t.LineDashedMaterial=dh,t.LineLoop=El,t.LineSegments=Tl,t.LinearDisplayP3ColorSpace=kt,t.LinearEncoding=Ft,t.LinearFilter=D,t.LinearInterpolant=Mh,t.LinearMipMapLinearFilter=1008,t.LinearMipMapNearestFilter=1007,t.LinearMipmapLinearFilter=O,t.LinearMipmapNearestFilter=N,t.LinearSRGBColorSpace=Ht,t.LinearToneMapping=m,t.LinearTransfer=Wt,t.Loader=Oh,t.LoaderUtils=ou,t.LoadingManager=Dh,t.LoopOnce=2200,t.LoopPingPong=2202,t.LoopRepeat=2201,t.LuminanceAlphaFormat=1025,t.LuminanceFormat=1024,t.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},t.Material=di,t.MaterialLoader=au,t.MathUtils=pe,t.Matrix3=fe,t.Matrix4=Mn,t.MaxEquation=104,t.Mesh=Ji,t.MeshBasicMaterial=pi,t.MeshDepthMaterial=Ha,t.MeshDistanceMaterial=Va,t.MeshLambertMaterial=hh,t.MeshMatcapMaterial=uh,t.MeshNormalMaterial=ch,t.MeshPhongMaterial=oh,t.MeshPhysicalMaterial=ah,t.MeshStandardMaterial=sh,t.MeshToonMaterial=lh,t.MinEquation=103,t.MirroredRepeatWrapping=L,t.MixOperation=u,t.MultiplyBlending=4,t.MultiplyOperation=h,t.NearestFilter=P,t.NearestMipMapLinearFilter=1005,t.NearestMipMapNearestFilter=1004,t.NearestMipmapLinearFilter=U,t.NearestMipmapNearestFilter=I,t.NeverCompare=512,t.NeverDepth=0,t.NeverStencilFunc=512,t.NoBlending=0,t.NoColorSpace=zt,t.NoToneMapping=p,t.NormalAnimationBlendMode=Nt,t.NormalBlending=1,t.NotEqualCompare=517,t.NotEqualDepth=7,t.NotEqualStencilFunc=517,t.NumberKeyframeTrack=wh,t.Object3D=jn,t.ObjectLoader=class extends Oh{constructor(t){super(t)}load(t,e,n,i){const r=this,s=""===this.path?ou.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const a=new zh(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,(function(n){let s=null;try{s=JSON.parse(n)}catch(e){return void 0!==i&&i(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+t)),void console.error("THREE.ObjectLoader: Can't load "+t);r.parse(s,e)}),n,i)}async loadAsync(t,e){const n=""===this.path?ou.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||n;const i=new zh(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const r=await i.loadAsync(t,e),s=JSON.parse(r),a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(s)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),s=this.parseImages(t.images,(function(){void 0!==e&&e(l)})),a=this.parseTextures(t.textures,s),o=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,r,o,a,n),c=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,c),void 0!==e){let t=!1;for(const e in s)if(s[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),r=await this.parseImagesAsync(t.images),s=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,s),o=this.parseObject(t.object,i,a,s,e),l=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,l),o}parseShapes(t){const e={};if(void 0!==t)for(let n=0,i=t.length;n<i;n++){const i=(new mc).fromJSON(t[n]);e[i.uuid]=i}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse((function(t){t.isBone&&(i[t.uuid]=t)})),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new Vo).fromJSON(t[e],i);n[r.uuid]=r}return n}parseGeometries(t,e){const n={};if(void 0!==t){const i=new cu;for(let r=0,s=t.length;r<s;r++){let s;const a=t[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=i.parse(a);break;default:a.type in nh?s=nh[a.type].fromJSON(a,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),n[a.uuid]=s}}return n}parseMaterials(t,e){const n={},i={};if(void 0!==t){const r=new au;r.setTextures(e);for(let e=0,s=t.length;e<s;e++){const s=t[e];void 0===n[s.uuid]&&(n[s.uuid]=r.parse(s)),i[s.uuid]=n[s.uuid]}}return i}parseAnimations(t){const e={};if(void 0!==t)for(let n=0;n<t.length;n++){const i=t[n],r=Ph.parse(i);e[r.uuid]=r}return e}parseImages(t,e){const n=this,i={};let r;function s(t){if("string"==typeof t){const e=t;return function(t){return n.manager.itemStart(t),r.load(t,(function(){n.manager.itemEnd(t)}),void 0,(function(){n.manager.itemError(t),n.manager.itemEnd(t)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:n.resourcePath+e)}return t.data?{data:xe(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const n=new Dh(e);r=new Gh(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,n=r.length;e<n;e++){const n=s(r[e]);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new zo(n.data,n.width,n.height)))}i[n.uuid]=new De(t)}else{const t=s(n.url);i[n.uuid]=new De(t)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function r(t){if("string"==typeof t){const n=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:e.resourcePath+n;return await i.loadAsync(r)}return t.data?{data:xe(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){i=new Gh(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],s=i.url;if(Array.isArray(s)){const t=[];for(let e=0,n=s.length;e<n;e++){const n=s[e],i=await r(n);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new zo(i.data,i.width,i.height)))}n[i.uuid]=new De(t)}else{const t=await r(i.url);n[i.uuid]=new De(t)}}}return n}parseTextures(t,e){function n(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const i={};if(void 0!==t)for(let r=0,s=t.length;r<s;r++){const s=t[r];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===e[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);const a=e[s.image],o=a.data;let l;Array.isArray(o)?(l=new lr,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new zo:new Fe,o&&(l.needsUpdate=!0)),l.source=a,l.uuid=s.uuid,void 0!==s.name&&(l.name=s.name),void 0!==s.mapping&&(l.mapping=n(s.mapping,hu)),void 0!==s.channel&&(l.channel=s.channel),void 0!==s.offset&&l.offset.fromArray(s.offset),void 0!==s.repeat&&l.repeat.fromArray(s.repeat),void 0!==s.center&&l.center.fromArray(s.center),void 0!==s.rotation&&(l.rotation=s.rotation),void 0!==s.wrap&&(l.wrapS=n(s.wrap[0],uu),l.wrapT=n(s.wrap[1],uu)),void 0!==s.format&&(l.format=s.format),void 0!==s.internalFormat&&(l.internalFormat=s.internalFormat),void 0!==s.type&&(l.type=s.type),void 0!==s.colorSpace&&(l.colorSpace=s.colorSpace),void 0!==s.encoding&&(l.encoding=s.encoding),void 0!==s.minFilter&&(l.minFilter=n(s.minFilter,du)),void 0!==s.magFilter&&(l.magFilter=n(s.magFilter,du)),void 0!==s.anisotropy&&(l.anisotropy=s.anisotropy),void 0!==s.flipY&&(l.flipY=s.flipY),void 0!==s.generateMipmaps&&(l.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(l.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(l.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(l.compareFunction=s.compareFunction),void 0!==s.userData&&(l.userData=s.userData),i[s.uuid]=l}return i}parseObject(t,e,n,i,r){let s,a,o;function l(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function c(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];void 0===n[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),e.push(n[r])}return e}return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),n[t]}}function h(t){return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined texture",t),i[t]}switch(t.type){case"Scene":s=new ro,void 0!==t.background&&(Number.isInteger(t.background)?s.background=new ci(t.background):s.background=h(t.background)),void 0!==t.environment&&(s.environment=h(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?s.fog=new io(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(s.fog=new no(t.fog.color,t.fog.density)),""!==t.fog.name&&(s.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(s.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(s.backgroundIntensity=t.backgroundIntensity);break;case"PerspectiveCamera":s=new sr(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(s.focus=t.focus),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.filmGauge&&(s.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(s.filmOffset=t.filmOffset),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"OrthographicCamera":s=new Lr(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"AmbientLight":s=new nu(t.color,t.intensity);break;case"DirectionalLight":s=new eu(t.color,t.intensity);break;case"PointLight":s=new Qh(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":s=new iu(t.color,t.intensity,t.width,t.height);break;case"SpotLight":s=new Yh(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":s=new Vh(t.color,t.groundColor,t.intensity);break;case"LightProbe":s=(new su).fromJSON(t);break;case"SkinnedMesh":a=l(t.geometry),o=c(t.material),s=new Fo(a,o),void 0!==t.bindMode&&(s.bindMode=t.bindMode),void 0!==t.bindMatrix&&s.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(s.skeleton=t.skeleton);break;case"Mesh":a=l(t.geometry),o=c(t.material),s=new Ji(a,o);break;case"InstancedMesh":a=l(t.geometry),o=c(t.material);const e=t.count,n=t.instanceMatrix,i=t.instanceColor;s=new Ko(a,o,e),s.instanceMatrix=new ko(new Float32Array(n.array),16),void 0!==i&&(s.instanceColor=new ko(new Float32Array(i.array),i.itemSize));break;case"BatchedMesh":a=l(t.geometry),o=c(t.material),s=new ml(t.maxGeometryCount,t.maxVertexCount,t.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=t.perObjectFrustumCulled,s.sortObjects=t.sortObjects,s._drawRanges=t.drawRanges,s._reservedRanges=t.reservedRanges,s._visibility=t.visibility,s._active=t.active,s._bounds=t.bounds.map((t=>{const e=new qe;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const n=new dn;return n.radius=t.sphereRadius,n.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:n}})),s._maxGeometryCount=t.maxGeometryCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=h(t.matricesTexture.uuid);break;case"LOD":s=new Ao;break;case"Line":s=new Ml(l(t.geometry),c(t.material));break;case"LineLoop":s=new El(l(t.geometry),c(t.material));break;case"LineSegments":s=new Tl(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":s=new Pl(l(t.geometry),c(t.material));break;case"Sprite":s=new bo(c(t.material));break;case"Group":s=new Ya;break;case"Bone":s=new Bo;break;default:s=new jn}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)s.add(this.parseObject(a[t],e,n,i,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const n=e[t];s.animations.push(r[n])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(s.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const n=e[t],i=s.getObjectByProperty("uuid",n.object);void 0!==i&&s.addLevel(i,n.distance,n.hysteresis)}}return s}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse((function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const n=e[t.skeleton];void 0===n?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(n,t.bindMatrix)}}))}},t.ObjectSpaceNormalMap=1,t.OctahedronGeometry=jc,t.OneFactor=201,t.OneMinusConstantAlphaFactor=214,t.OneMinusConstantColorFactor=212,t.OneMinusDstAlphaFactor=207,t.OneMinusDstColorFactor=209,t.OneMinusSrcAlphaFactor=c,t.OneMinusSrcColorFactor=203,t.OrthographicCamera=Lr,t.P3Primaries=qt,t.PCFShadowMap=n,t.PCFSoftShadowMap=i,t.PMREMGenerator=Hr,t.Path=ec,t.PerspectiveCamera=sr,t.Plane=pr,t.PlaneGeometry=xr,t.PlaneHelper=class extends Ml{constructor(t,e=1,n=16776960){const i=n,r=new Ii;r.setAttribute("position",new Ti([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new fl({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const s=new Ii;s.setAttribute("position",new Ti([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new Ji(s,new pi({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},t.PointLight=Qh,t.PointLightHelper=class extends Ji{constructor(t,e,n){super(new Zc(e,4,2),new pi({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},t.Points=Pl,t.PointsMaterial=wl,t.PolarGridHelper=class extends Tl{constructor(t=10,e=16,n=8,i=64,r=4473924,s=8947848){r=new ci(r),s=new ci(s);const a=[],o=[];if(e>1)for(let n=0;n<e;n++){const i=n/e*(2*Math.PI),l=Math.sin(i)*t,c=Math.cos(i)*t;a.push(0,0,0),a.push(l,0,c);const h=1&n?r:s;o.push(h.r,h.g,h.b),o.push(h.r,h.g,h.b)}for(let e=0;e<n;e++){const l=1&e?r:s,c=t-t/n*e;for(let t=0;t<i;t++){let e=t/i*(2*Math.PI),n=Math.sin(e)*c,r=Math.cos(e)*c;a.push(n,0,r),o.push(l.r,l.g,l.b),e=(t+1)/i*(2*Math.PI),n=Math.sin(e)*c,r=Math.cos(e)*c,a.push(n,0,r),o.push(l.r,l.g,l.b)}}const l=new Ii;l.setAttribute("position",new Ti(a,3)),l.setAttribute("color",new Ti(o,3));super(l,new fl({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},t.PolyhedronGeometry=oc,t.PositionalAudio=class extends Tu{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Eu,wu,Au),Ru.set(0,0,1).applyQuaternion(wu);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(Eu.x,t),e.positionY.linearRampToValueAtTime(Eu.y,t),e.positionZ.linearRampToValueAtTime(Eu.z,t),e.orientationX.linearRampToValueAtTime(Ru.x,t),e.orientationY.linearRampToValueAtTime(Ru.y,t),e.orientationZ.linearRampToValueAtTime(Ru.z,t)}else e.setPosition(Eu.x,Eu.y,Eu.z),e.setOrientation(Ru.x,Ru.y,Ru.z)}},t.PropertyBinding=Ou,t.PropertyMixer=Cu,t.QuadraticBezierCurve=Jl,t.QuadraticBezierCurve3=Kl,t.Quaternion=ke,t.QuaternionKeyframeTrack=Rh,t.QuaternionLinearInterpolant=Ah,t.RED_GREEN_RGTC2_Format=At,t.RED_RGTC1_Format=36283,t.REVISION=e,t.RGBADepthPacking=3201,t.RGBAFormat=j,t.RGBAIntegerFormat=K,t.RGBA_ASTC_10x10_Format=yt,t.RGBA_ASTC_10x5_Format=_t,t.RGBA_ASTC_10x6_Format=vt,t.RGBA_ASTC_10x8_Format=xt,t.RGBA_ASTC_12x10_Format=Mt,t.RGBA_ASTC_12x12_Format=St,t.RGBA_ASTC_4x4_Format=ct,t.RGBA_ASTC_5x4_Format=ht,t.RGBA_ASTC_5x5_Format=ut,t.RGBA_ASTC_6x5_Format=dt,t.RGBA_ASTC_6x6_Format=pt,t.RGBA_ASTC_8x5_Format=mt,t.RGBA_ASTC_8x6_Format=ft,t.RGBA_ASTC_8x8_Format=gt,t.RGBA_BPTC_Format=bt,t.RGBA_ETC2_EAC_Format=lt,t.RGBA_PVRTC_2BPPV1_Format=st,t.RGBA_PVRTC_4BPPV1_Format=rt,t.RGBA_S3TC_DXT1_Format=Q,t.RGBA_S3TC_DXT3_Format=tt,t.RGBA_S3TC_DXT5_Format=et,t.RGB_BPTC_SIGNED_Format=Tt,t.RGB_BPTC_UNSIGNED_Format=Et,t.RGB_ETC1_Format=at,t.RGB_ETC2_Format=ot,t.RGB_PVRTC_2BPPV1_Format=it,t.RGB_PVRTC_4BPPV1_Format=nt,t.RGB_S3TC_DXT1_Format=$,t.RGFormat=1030,t.RGIntegerFormat=J,t.RawShaderMaterial=rh,t.Ray=yn,t.Raycaster=class{constructor(t,e,n=0,i=1/0){this.ray=new yn(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new In,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,n=[]){return Vu(t,this,n,e),n.sort(Hu),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)Vu(t[i],this,n,e);return n.sort(Hu),n}},t.Rec709Primaries=jt,t.RectAreaLight=iu,t.RedFormat=1028,t.RedIntegerFormat=Z,t.ReinhardToneMapping=f,t.RenderTarget=ze,t.RepeatWrapping=R,t.ReplaceStencilOp=7681,t.ReverseSubtractEquation=102,t.RingGeometry=qc,t.SIGNED_RED_GREEN_RGTC2_Format=Rt,t.SIGNED_RED_RGTC1_Format=wt,t.SRGBColorSpace=Gt,t.SRGBTransfer=Xt,t.Scene=ro,t.ShaderChunk=yr,t.ShaderLib=Sr,t.ShaderMaterial=ir,t.ShadowMaterial=ih,t.Shape=mc,t.ShapeGeometry=Yc,t.ShapePath=class{constructor(){this.type="ShapePath",this.color=new ci,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new ec,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,s){return this.currentPath.bezierCurveTo(t,e,n,i,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let i=!1;for(let r=n-1,s=0;s<n;r=s++){let n=e[r],a=e[s],o=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=e[s],o=-o,a=e[r],l=-l),t.y<n.y||t.y>a.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-o*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return i}const n=Gc.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new mc,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=t?!l:l;const c=[],h=[];let u,d,p=[],m=0;h[m]=void 0,p[m]=[];for(let e=0,a=i.length;e<a;e++)s=i[e],u=s.getPoints(),r=n(u),r=t?!r:r,r?(!l&&h[m]&&m++,h[m]={s:new mc,p:u},h[m].s.curves=s.curves,l&&m++,p[m]=[]):p[m].push({h:s,p:u[0]});if(!h[0])return function(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n],r=new mc;r.curves=i.curves,e.push(r)}return e}(i);if(h.length>1){let t=!1,n=0;for(let t=0,e=h.length;t<e;t++)c[t]=[];for(let i=0,r=h.length;i<r;i++){const r=p[i];for(let s=0;s<r.length;s++){const a=r[s];let o=!0;for(let r=0;r<h.length;r++)e(a.p,h[r].p)&&(i!==r&&n++,o?(o=!1,c[r].push(a)):t=!0);o&&c[i].push(a)}}n>0&&!1===t&&(p=c)}for(let t=0,e=h.length;t<e;t++){a=h[t].s,o.push(a),d=p[t];for(let t=0,e=d.length;t<e;t++)a.holes.push(d[t].h)}return o}},t.ShapeUtils=Gc,t.ShortType=1011,t.Skeleton=Vo,t.SkeletonHelper=class extends Tl{constructor(t){const e=Ju(t),n=new Ii,i=[],r=[],s=new ci(0,0,1),a=new ci(0,1,0);for(let t=0;t<e.length;t++){const n=e[t];n.parent&&n.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(s.r,s.g,s.b),r.push(a.r,a.g,a.b))}n.setAttribute("position",new Ti(i,3)),n.setAttribute("color",new Ti(r,3));super(n,new fl({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,n=this.geometry,i=n.getAttribute("position");Zu.copy(this.root.matrixWorld).invert();for(let t=0,n=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(Yu.multiplyMatrices(Zu,r.matrixWorld),qu.setFromMatrixPosition(Yu),i.setXYZ(n,qu.x,qu.y,qu.z),Yu.multiplyMatrices(Zu,r.parent.matrixWorld),qu.setFromMatrixPosition(Yu),i.setXYZ(n+1,qu.x,qu.y,qu.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}},t.SkinnedMesh=Fo,t.Source=De,t.Sphere=dn,t.SphereGeometry=Zc,t.Spherical=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(ae(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},t.SphericalHarmonics3=ru,t.SplineCurve=$l,t.SpotLight=Yh,t.SpotLightHelper=class extends jn{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new Ii,i=[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 t=0,e=1,n=32;t<n;t++,e++){const r=t/n*Math.PI*2,s=e/n*Math.PI*2;i.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}n.setAttribute("position",new Ti(i,3));const r=new fl({fog:!1,toneMapped:!1});this.cone=new Tl(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),ju.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ju),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},t.Sprite=bo,t.SpriteMaterial=lo,t.SrcAlphaFactor=l,t.SrcAlphaSaturateFactor=210,t.SrcColorFactor=202,t.StaticCopyUsage=35046,t.StaticDrawUsage=Zt,t.StaticReadUsage=35045,t.StereoCamera=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new sr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new sr,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(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,_u.copy(t.projectionMatrix);const n=e.eyeSep/2,i=n*e.near/e.focus,r=e.near*Math.tan(ie*e.fov*.5)/e.zoom;let s,a;gu.elements[12]=-n,fu.elements[12]=n,s=-r*e.aspect+i,a=r*e.aspect+i,_u.elements[0]=2*e.near/(a-s),_u.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(_u),s=-r*e.aspect-i,a=r*e.aspect-i,_u.elements[0]=2*e.near/(a-s),_u.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(_u)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(gu),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(fu)}},t.StreamCopyUsage=35042,t.StreamDrawUsage=35040,t.StreamReadUsage=35041,t.StringKeyframeTrack=Ch,t.SubtractEquation=101,t.SubtractiveBlending=3,t.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},t.TangentSpaceNormalMap=0,t.TetrahedronGeometry=Jc,t.Texture=Fe,t.TextureLoader=class extends Oh{constructor(t){super(t)}load(t,e,n,i){const r=new Fe,s=new Gh(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)}),n,i),r}},t.TorusGeometry=Kc,t.TorusKnotGeometry=$c,t.Triangle=ri,t.TriangleFanDrawMode=2,t.TriangleStripDrawMode=1,t.TrianglesDrawMode=0,t.TubeGeometry=Qc,t.TwoPassDoubleSide=2,t.UVMapping=S,t.Uint16BufferAttribute=Si,t.Uint32BufferAttribute=bi,t.Uint8BufferAttribute=class extends Mi{constructor(t,e,n){super(new Uint8Array(t),e,n)}},t.Uint8ClampedBufferAttribute=class extends Mi{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}},t.Uniform=zu,t.UniformsGroup=class extends te{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Gu++}),this.name="",this.usage=Zt,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,n=e.length;t<n;t++){const n=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<n.length;t++)this.uniforms.push(n[t].clone())}return this}clone(){return(new this.constructor).copy(this)}},t.UniformsLib=Mr,t.UniformsUtils=nr,t.UnsignedByteType=F,t.UnsignedInt248Type=X,t.UnsignedIntType=G,t.UnsignedShort4444Type=k,t.UnsignedShort5551Type=W,t.UnsignedShortType=B,t.VSMShadowMap=r,t.Vector2=me,t.Vector3=We,t.Vector4=Be,t.VectorKeyframeTrack=Lh,t.VideoTexture=class extends Fe{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:D,this.magFilter=void 0!==r?r:D,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},t.WebGL1Renderer=eo,t.WebGL3DRenderTarget=class extends Ge{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Ve(null,t,e,n),this.texture.isRenderTargetTexture=!0}},t.WebGLArrayRenderTarget=class extends Ge{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new He(null,t,e,n),this.texture.isRenderTargetTexture=!0}},t.WebGLCoordinateSystem=$t,t.WebGLCubeRenderTarget=cr,t.WebGLMultipleRenderTargets=class extends Ge{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLMultipleRenderTargets=!0;const r=this.texture;this.texture=[];for(let t=0;t<n;t++)this.texture[t]=r.clone(),this.texture[t].isRenderTargetTexture=!0}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.texture.length;i<r;i++)this.texture[i].image.width=t,this.texture[i].image.height=e,this.texture[i].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}copy(t){this.dispose(),this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.texture.length=0;for(let e=0,n=t.texture.length;e<n;e++)this.texture[e]=t.texture[e].clone(),this.texture[e].isRenderTargetTexture=!0;return this}},t.WebGLRenderTarget=Ge,t.WebGLRenderer=to,t.WebGLUtils=ja,t.WebGPUCoordinateSystem=Qt,t.WireframeGeometry=th,t.WrapAroundEnding=Dt,t.ZeroCurvatureEnding=It,t.ZeroFactor=200,t.ZeroSlopeEnding=Ut,t.ZeroStencilOp=0,t._SRGBAFormat=Kt,t.createCanvasElement=Me,t.sRGBEncoding=Bt}));
diff --git a/scripts/engine/lib/typo.js b/scripts/engine/lib/typo.js
index da397e5..f00d367 100644
--- a/scripts/engine/lib/typo.js
+++ b/scripts/engine/lib/typo.js
@@ -39,6 +39,20 @@ TY.fit = (c, text, maxW, size, fam, { maxLines = 2, min = 0.45, weight = '', sof
return { size: s, lines, ok: good };
};
+// 保底版 fit:字号不低于 floor(px)。放得下就和 TY.fit 一样;放不下就停在 floor,按 maxLines 截断并加「…」,单行过宽的长词也截。
+// 用在「内容长度不可控」的地方(节点标签、卡片说明、图表标签):宁可截断,也不缩到看不清。返回 {size, lines, ok, cut}
+TY.fitFloor = (c, text, maxW, size, fam, { maxLines = 2, floor = size * 0.5, weight = '', balance = false } = {}) => {
+ floor = Math.min(floor, size);
+ const r = TY.fit(c, text, maxW, size, fam, { maxLines, min: Math.max(0.2, floor / size), weight, soft: true, balance });
+ if (r.ok) return { ...r, cut: false };
+ const font = `${weight}${floor}px "${fam}"`; c.save(); c.font = font;
+ const w = s => c.measureText(s).width, ell = line => { if (w(line) <= maxW) return line; let l = line; while (l.length > 1 && w(l + '…') > maxW) l = l.slice(0, -1); return l + '…'; };
+ let lines = TY.wrap(c, text, maxW, font), cut = false;
+ if (lines.length > maxLines) { lines = lines.slice(0, maxLines); lines[maxLines - 1] = lines[maxLines - 1] + '…'; cut = true; }
+ lines = lines.map(l => { const e = ell(l); if (e !== l) cut = true; return e; });
+ c.restore(); return { size: floor, lines, ok: false, cut };
+};
+
// ---------- 入场 ----------
// 逐字错开出现:每字 dur 秒,从 dy 往上、透明→不透明、可带缩放;Kurzgesagt 标题 0.5s/字、错开 45ms。返回总宽。
TY.charsIn = (c, str, x, y, lt, { font, color, dur = 0.35, stagger = 0.04, dy = 24, scale0 = 1, align = 'left', ease = MO.cubicOut, shadow, spacing = 0 } = {}) => {
diff --git a/scripts/engine/render.py b/scripts/engine/render.py
index 4db5be0..1fb5dc1 100644
--- a/scripts/engine/render.py
+++ b/scripts/engine/render.py
@@ -17,7 +17,7 @@ import spec_assets
from playwright.sync_api import sync_playwright
ap = argparse.ArgumentParser()
-ap.add_argument('--out', required=True)
+ap.add_argument('--out', help='输出文件(--audit 时可不写)')
ap.add_argument('--audio')
ap.add_argument('--fps', type=int, default=60)
ap.add_argument('--from', dest='t0', type=float, default=0)
@@ -31,7 +31,9 @@ ap.add_argument('--spec', help='参数化片段 spec.json(走 clip.html,不
ap.add_argument('--alpha', action='store_true', help='--spec 时出 ProRes 4444 带透明(背景不画)')
ap.add_argument('--width', type=int, help='整片模式的画布宽(竖屏 1080);--spec 时宽高从 spec 读,写了这个会覆盖 spec')
ap.add_argument('--height', type=int, help='整片模式的画布高(竖屏 1920)')
+ap.add_argument('--audit', nargs='?', const='-', help='版面审计(只配 --spec):不出视频,每 0.25 秒采一帧,记录主画布上每次 fillText 的位置/字号/透明度,查出界、字太小、文字互相压;可跟一个 JSON 输出路径')
a = ap.parse_args()
+if not a.out and not a.audit: ap.error('--out 必填(除非 --audit)')
root = Path(__file__).parent
spec, ALLOWED = None, set()
@@ -49,6 +51,28 @@ if spec and float(spec.get('duration', 0)) > 8:
'!! 拆成多镜:每镜 2–6 秒、换语法或换做法(scenes、真实素材),再拼接(SKILL.md 轨道档第 3–4 步)。\n'
'!! 口播管线里确实要一段长片段的,可以忽略这条。\n' + '!' * 72 + '\n')
print(LONG_CLIP, file=sys.stderr, flush=True)
+
+AUDIT_JS = r"""
+(() => {
+ window.__AUDIT = []; window.__auditT = 0;
+ const P = CanvasRenderingContext2D.prototype;
+ for (const fn of ['fillText', 'strokeText']) {
+ const orig = P[fn];
+ P[fn] = function (text, x, y) {
+ try {
+ if (fn === 'fillText' && this.canvas === window.__canvas && String(text).trim()) {
+ const m = this.measureText(String(text)), tf = this.getTransform(), l = m.actualBoundingBoxLeft, r = m.actualBoundingBoxRight, as = m.actualBoundingBoxAscent, ds = m.actualBoundingBoxDescent;
+ const pts = [[x - l, y - as], [x + r, y - as], [x + r, y + ds], [x - l, y + ds]].map(q => [tf.a * q[0] + tf.c * q[1] + tf.e, tf.b * q[0] + tf.d * q[1] + tf.f]);
+ const xs = pts.map(q => q[0]), ys = pts.map(q => q[1]), px = parseFloat(this.font) * Math.hypot(tf.a, tf.b);
+ window.__AUDIT.push({ t: window.__auditT, text: String(text), x0: Math.min(...xs), y0: Math.min(...ys), x1: Math.max(...xs), y1: Math.max(...ys), px, a: this.globalAlpha });
+ }
+ } catch (e) {}
+ return orig.apply(this, arguments);
+ };
+ }
+})();
+"""
+
class Q(http.server.SimpleHTTPRequestHandler):
def log_message(self, *x): pass
def translate_path(self, path):
@@ -77,6 +101,7 @@ with sync_playwright() as p:
if spec:
pg.set_viewport_size({'width': spec.get('width', 1920), 'height': spec.get('height', 1080)})
pg.add_init_script('window.CLIP_SPEC = ' + json.dumps(spec, ensure_ascii=False) + ';')
+ if a.audit: pg.add_init_script(AUDIT_JS)
pg.goto(f'http://127.0.0.1:{port}/clip.html?render=1')
else:
if a.width or a.height:
@@ -89,6 +114,14 @@ with sync_playwright() as p:
if a.t1 is None: a.t1 = pg.evaluate('window.__total')
if spec: a.fps = spec.get('fps', 30); a.t0 = 0; a.t1 = spec['duration']
grab = '''async (t)=>{ await window.prepare(t); window.renderFrame(t); return window.__canvas.toDataURL('image/png').split(',')[1]; }'''
+
+ if a.audit:
+ if not spec: raise SystemExit('--audit 只配 --spec')
+ import audit_clip
+ rep = audit_clip.run(pg, spec, grab)
+ if a.audit != '-': Path(a.audit).write_text(json.dumps(rep, ensure_ascii=False, indent=1))
+ b.close(); srv.shutdown(); srv.server_close()
+ sys.exit(1 if rep['red'] else 0)
if a.solo:
grab = '''async (t)=>{ window.renderSolo(%s, t, {counter: %s}); return window.__canvas.toDataURL('image/png').split(',')[1]; }''' % (repr(a.solo), 'false' if a.no_counter else 'true')
if a.stills:
diff --git a/scripts/engine/scenes/38_giotto.js b/scripts/engine/scenes/38_giotto.js
new file mode 100644
index 0000000..6f0c5fd
--- /dev/null
+++ b/scripts/engine/scenes/38_giotto.js
@@ -0,0 +1,133 @@
+// 乔托(斯克罗威尼礼拜堂湿壁画):群青天、重量感的袍、视线连接人物、斜置的建筑体块、灰泥与一天的活接缝。
+// 题材(新构图,不搬名作):码头仓库门口,两位搬运工把一只大木箱交接,第三人低头看着箱角。
+// 原作锚定(scripts/analyze/fetch_reference.py 拉的公版图,色值与签名见 配方卡):群青天 #3a5a9a→#8fa4c8、土红/赭/橄榄绿袍、
+// 灰粉建筑 #c9b9ae、金边装饰带、人物视线互相咬合、衣褶大块明暗;整体粉白哑光。
+// 管线:plate(干净的形:天→岩坡→建筑→人→箱)→ MEDIUM.fresco(轻糊+石灰罩+灰泥相乘+针孔接缝)→ 装饰边框 → 动作。
+SCENES['38_giotto'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ let plate, pg;
+ const ease = x => { x = clamp(x); return x * x * (3 - 2 * x); };
+
+ function sky(g) {
+ const gr = g.createLinearGradient(0, 0, 0, 620); gr.addColorStop(0, '#2347a0'); gr.addColorStop(0.5, '#3f68b8'); gr.addColorStop(1, '#a9c0e6');
+ g.fillStyle = gr; g.fillRect(0, 0, W, H);
+ // 群青是一层层罩的:大尺度斜向软斑(fbm),不是横条
+ const r = rng(11);
+ for (let i = 0; i < 140; i++) { const x = r() * W, y = r() * 600, rx = 90 + r() * 260, ry = 24 + r() * 70; g.save(); g.translate(x, y); g.rotate(-0.25 + (r() - .5) * 0.5); g.filter = 'blur(14px)';
+ g.fillStyle = `rgba(${r() < 0.55 ? '24,52,132' : '170,190,232'},${0.06 + r() * 0.09})`; g.beginPath(); g.ellipse(0, 0, rx, ry, 0, 0, TAU); g.fill(); g.restore(); }
+ g.filter = 'none';
+ // 金星点(原作天幕有星)
+ for (let i = 0; i < 26; i++) { const x = 60 + r() * (W - 120), y = 40 + r() * 330, s = 5 + r() * 4; g.fillStyle = 'rgba(224,190,100,.85)'; g.beginPath();
+ for (let k = 0; k < 8; k++) { const a = k / 8 * TAU, rr = k % 2 ? s * 0.4 : s; g.lineTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr); } g.closePath(); g.fill(); }
+ }
+ function rocks(g) { // 乔托的岩坡:斜向的大块面,亮面朝左上,暗面朝下,边缘有「梯田」台阶
+ const poly = (pts, c0, c1) => { const gr = g.createLinearGradient(pts[0][0], pts[0][1], pts[2][0], pts[2][1] + 120); gr.addColorStop(0, c0); gr.addColorStop(1, c1);
+ g.fillStyle = gr; g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.closePath(); g.fill(); M.outline(g, [...pts, pts[0]], { w: [2, 3.4, 2], col: '#6e5a4a', a: 0.6 }); };
+ poly([[0, 420], [340, 300], [620, 410], [700, 640], [0, 700]], '#c4b79c', '#8e8068');
+ poly([[0, 560], [420, 470], [640, 620], [700, 700], [0, 760]], '#b4a487', '#7f7058');
+ poly([[300, 420], [560, 330], [760, 470], [640, 620], [420, 470]], '#d1c6ac', '#a1937a');
+ g.fillStyle = 'rgba(80,100,50,.55)'; [[60, 640, 120], [250, 600, 90], [470, 640, 80]].forEach(([x, y, w]) => { g.beginPath(); g.ellipse(x, y, w, 20, -0.15, 0, TAU); g.fill(); });
+ g.strokeStyle = 'rgba(70,90,45,.9)'; g.lineWidth = 3; // 一棵小树,几笔叶团
+ g.beginPath(); g.moveTo(520, 440); g.lineTo(522, 360); g.stroke(); g.fillStyle = '#5f7a43'; [[522, 340, 34], [498, 372, 26], [548, 368, 26]].forEach(([x, y, rr]) => { g.beginPath(); g.arc(x, y, rr, 0, TAU); g.fill(); });
+ }
+ function building(g) { // 仓库:两个可见立面(正面+斜侧),透视故意不统一(前期文艺复兴之前的「舞台盒」),带拱门和垛口
+ const front = [[1040, 250], [1620, 250], [1620, 860], [1040, 860]], side = [[1620, 250], [1810, 190], [1810, 820], [1620, 860]];
+ let gr = g.createLinearGradient(1040, 0, 1620, 0); gr.addColorStop(0, '#d9c9bd'); gr.addColorStop(1, '#bcab9f'); g.fillStyle = gr; g.beginPath(); front.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.fill();
+ gr = g.createLinearGradient(1620, 0, 1810, 0); gr.addColorStop(0, '#9c8b82'); gr.addColorStop(1, '#7d6d66'); g.fillStyle = gr; g.beginPath(); side.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.fill();
+ // 檐下装饰带:红白相间的菱格(科斯马蒂式)
+ g.fillStyle = '#8c3d34'; g.fillRect(1040, 262, 580, 30); g.fillStyle = '#ead9aa'; for (let x = 1052; x < 1610; x += 36) { g.beginPath(); g.moveTo(x, 277); g.lineTo(x + 12, 266); g.lineTo(x + 24, 277); g.lineTo(x + 12, 288); g.closePath(); g.fill(); }
+ // 侧面小窗
+ g.fillStyle = '#4a3a30'; [[1685, 380], [1685, 560]].forEach(([x, y]) => { g.beginPath(); g.moveTo(x, y + 80); g.lineTo(x, y + 20); g.arc(x + 24, y + 20, 24, Math.PI, 0); g.lineTo(x + 48, y + 80); g.fill(); });
+ // 垛口
+ for (let i = 0; i < 6; i++) { const x = 1050 + i * 98; g.fillStyle = '#cdbdb0'; g.fillRect(x, 200, 62, 52); M.outline(g, [[x, 252], [x, 200], [x + 62, 200], [x + 62, 252]], { w: [2, 3, 2], col: '#6e5a4a', a: 0.6 }); }
+ // 石砌水平缝(不画方格,画几道长缝,缝处有错位)
+ g.strokeStyle = 'rgba(110,90,78,.28)'; g.lineWidth = 2; for (let y = 300; y < 860; y += 62) { g.beginPath(); g.moveTo(1040, y); g.lineTo(1620, y + (y % 124 ? 2 : -2)); g.stroke(); }
+ // 拱门:金边环+深洞
+ const cx = 1290, top = 330, w = 250;
+ g.fillStyle = '#e4d3aa'; g.beginPath(); g.moveTo(cx - w / 2 - 26, 860); g.lineTo(cx - w / 2 - 26, top + w / 2); g.arc(cx, top + w / 2, w / 2 + 26, Math.PI, 0); g.lineTo(cx + w / 2 + 26, 860); g.closePath(); g.fill();
+ gr = g.createLinearGradient(0, top, 0, 860); gr.addColorStop(0, '#4a3a30'); gr.addColorStop(1, '#7a634e'); g.fillStyle = gr;
+ g.beginPath(); g.moveTo(cx - w / 2, 860); g.lineTo(cx - w / 2, top + w / 2); g.arc(cx, top + w / 2, w / 2, Math.PI, 0); g.lineTo(cx + w / 2, 860); g.closePath(); g.fill();
+ g.strokeStyle = '#c9a24b'; g.lineWidth = 7; g.beginPath(); g.arc(cx, top + w / 2, w / 2 + 14, Math.PI, 0); g.stroke();
+ // 门洞里的暗处有几袋货
+ g.fillStyle = '#6b5846'; [[cx - 70, 800, 54], [cx + 22, 810, 60]].forEach(([x, y, s]) => { g.beginPath(); g.ellipse(x, y, s, s * 0.7, 0, 0, TAU); g.fill(); });
+ M.outline(g, [...front, front[0]], { w: [2.4, 3.6, 2.4], col: '#5f4a3d', a: 0.7 }); M.outline(g, [...side, side[0]], { w: [2.4, 3.6, 2.4], col: '#5f4a3d', a: 0.7 });
+ // 墙脚台阶
+ g.fillStyle = '#b5a592'; g.fillRect(1010, 860, 840, 26); g.fillStyle = '#9a8a78'; g.fillRect(1010, 886, 840, 16);
+ }
+ function ground(g) {
+ const gr = g.createLinearGradient(0, 760, 0, H); gr.addColorStop(0, '#b9a56e'); gr.addColorStop(0.5, '#9a8754'); gr.addColorStop(1, '#6a5a36'); g.fillStyle = gr; g.fillRect(0, 760, W, H - 760);
+ // 远处水带(码头边):一条冷青带,岩坡脚下
+ const wg = g.createLinearGradient(0, 735, 0, 790); wg.addColorStop(0, '#7f9fb4'); wg.addColorStop(1, '#5f8294'); g.fillStyle = wg; g.fillRect(0, 735, 1010, 52);
+ g.strokeStyle = 'rgba(230,240,245,.5)'; g.lineWidth = 2; for (let i = 0; i < 18; i++) { const x = 40 + i * 52, y = 745 + (i % 3) * 14; g.beginPath(); g.moveTo(x, y); g.quadraticCurveTo(x + 14, y - 3, x + 30, y); g.stroke(); }
+ // 土路的亮带与车辙
+ g.fillStyle = 'rgba(214,194,140,.55)'; g.beginPath(); g.moveTo(0, 820); g.quadraticCurveTo(520, 780, 1010, 830); g.lineTo(1010, 930); g.quadraticCurveTo(500, 900, 0, 960); g.fill();
+ const r = rng(5); for (let i = 0; i < 420; i++) { g.fillStyle = `rgba(${r() < 0.5 ? '84,64,36' : '214,198,150'},${0.1 + r() * 0.18})`; g.fillRect(r() * W, 790 + r() * 290, 6 + r() * 44, 2 + r() * 2); }
+ // 草簇与石子
+ g.strokeStyle = '#4d6a36'; g.lineWidth = 2.4; for (let i = 0; i < 26; i++) { const x = r() * W, y = 960 + r() * 100; for (let k = -2; k <= 2; k++) { g.beginPath(); g.moveTo(x, y); g.quadraticCurveTo(x + k * 5, y - 14, x + k * 9, y - 26 - r() * 8); g.stroke(); } }
+ g.fillStyle = '#8c7e66'; for (let i = 0; i < 26; i++) { g.beginPath(); g.ellipse(r() * W, 900 + r() * 170, 7 + r() * 12, 4 + r() * 6, 0, 0, TAU); g.fill(); }
+ // 门边的麻袋和木桶(货)
+ [[1460, 905, 62], [1550, 915, 54]].forEach(([x, y, s2]) => { const sg = g.createLinearGradient(x - s2, 0, x + s2, 0); sg.addColorStop(0, '#d8c79a'); sg.addColorStop(1, '#a89468'); g.fillStyle = sg; g.beginPath(); g.moveTo(x - s2 * 0.8, y); g.quadraticCurveTo(x - s2, y - s2 * 1.1, x, y - s2 * 1.3); g.quadraticCurveTo(x + s2, y - s2 * 1.1, x + s2 * 0.8, y); g.closePath(); g.fill(); g.strokeStyle = 'rgba(90,70,48,.7)'; g.lineWidth = 3; g.stroke(); g.beginPath(); g.moveTo(x - s2 * 0.35, y - s2 * 1.1); g.quadraticCurveTo(x, y - s2 * 0.9, x + s2 * 0.35, y - s2 * 1.1); g.stroke(); });
+ const bgd = g.createLinearGradient(1640, 0, 1760, 0); bgd.addColorStop(0, '#9a6a3c'); bgd.addColorStop(1, '#6e4724'); g.fillStyle = bgd; g.fillRect(1640, 790, 120, 130); g.beginPath(); g.ellipse(1700, 790, 60, 14, 0, 0, TAU); g.fill(); g.strokeStyle = '#3d3a36'; g.lineWidth = 6; [820, 880].forEach(y => { g.beginPath(); g.moveTo(1640, y); g.lineTo(1760, y); g.stroke(); });
+ }
+ function build() {
+ plate = P.canvas(); pg = plate.getContext('2d');
+ sky(pg); rocks(pg); building(pg); ground(pg);
+ }
+ const GROUND = M.plaster('giotto', { base: '#d8cdb6', seed: 9, seams: [[[0, 372], [380, 380], [760, 366], [1120, 378], [1500, 368], [1920, 376]], [[640, 0], [652, 190], [630, 372]]] });
+
+ // 木箱:有体积(正面+顶面),箱角包铁
+ function crate(c, x, y, s, tilt) {
+ c.save(); c.translate(x, y); c.rotate(tilt);
+ const w = 150 * s, h = 110 * s, d = 28 * s;
+ c.fillStyle = '#a77b49'; c.fillRect(-w / 2, -h / 2, w, h);
+ c.fillStyle = '#c59a62'; c.beginPath(); c.moveTo(-w / 2, -h / 2); c.lineTo(-w / 2 + d, -h / 2 - d); c.lineTo(w / 2 + d, -h / 2 - d); c.lineTo(w / 2, -h / 2); c.fill();
+ c.fillStyle = '#7d5a31'; c.beginPath(); c.moveTo(w / 2, -h / 2); c.lineTo(w / 2 + d, -h / 2 - d); c.lineTo(w / 2 + d, h / 2 - d); c.lineTo(w / 2, h / 2); c.fill();
+ c.strokeStyle = 'rgba(70,45,25,.55)'; c.lineWidth = 2 * s; for (let k = 1; k < 4; k++) { c.beginPath(); c.moveTo(-w / 2, -h / 2 + k * h / 4); c.lineTo(w / 2, -h / 2 + k * h / 4); c.stroke(); }
+ c.strokeStyle = '#3f3a36'; c.lineWidth = 7 * s; c.strokeRect(-w / 2 + 4, -h / 2 + 4, w - 8, h - 8);
+ c.beginPath(); c.moveTo(-w / 2, -h / 2); c.lineTo(w / 2, h / 2); c.stroke();
+ M.outline(c, [[-w / 2, -h / 2], [w / 2, -h / 2], [w / 2, h / 2], [-w / 2, h / 2], [-w / 2, -h / 2]], { w: [2.4, 3.2, 2.4], col: '#4a2f22', a: 0.8 });
+ c.restore();
+ }
+
+ function draw(c, lt, t) {
+ if (!plate) build();
+ const tt = clamp(lt, 0, 6);
+ const hand = ease((tt - 0.6) / 3.2); // 箱子从左到右交接(0.6→3.8s),之后右边的人接稳、放下
+ const settle = ease((tt - 3.8) / 1.4);
+ const g = pg;
+ // 动态的形画到 plate 副本:背景 plate 不动,人物每帧画在 live 上
+ const live = P.scratch('giotto_live'), lg = live.getContext('2d'); lg.reset(); lg.drawImage(plate, 0, 0);
+ // 人物:左搬运工(赭红袍+深绿披风)、右搬运工(橄榄绿袍+土红披风)、门边低头者(青灰袍)
+ const bx = lerp(800, 890, hand), by = lerp(735, 748, hand) + Math.sin(hand * Math.PI) * -34 + settle * 38, tilt = Math.sin(hand * Math.PI) * -0.07;
+ const boxTop = [bx, by];
+ M.figure(lg, { hemK: 0.82, halo: true, beard: false, x: 745, y: 905, h: 480, face: 1, lean: 0.10 + 0.07 * (1 - ease(hand * 1.4)), bow: 0.4, t: tt, seed: 1, sway: 0.3,
+ robe: ['#f0a98c', '#cf5f4a', '#8c3430'], mantle: ['#7da07c', '#4f7456', '#2f4f3c'], under: '#ecdcae', skin: '#e2b48a', hair: '#5b3a22',
+ gaze: [bx + 30, by - 20], hands: [[bx - 74, by + 14], [bx - 74, by - 24]] });
+ M.figure(lg, { hemK: 1.12, halo: true, beard: false, x: 1030, y: 915, h: 500, face: -1, lean: 0.06 + 0.1 * ss(0.2, 0.9, hand), bow: 0.5, t: tt, seed: 2, sway: 0.3,
+ robe: ['#bccb8d', '#86a05c', '#4c6a3a'], mantle: ['#d28a6e', '#a8553f', '#6f3329'], under: '#efe2b8', skin: '#d9a97e', hair: '#3b2a1c',
+ gaze: [bx, by - 12], hands: [[bx + 74, by + 16 + settle * 6], [bx + 74, by - 24]] });
+ crate(lg, bx, by, 1, tilt);
+ // 前景手要压在箱前:重画两只手
+ // 第三人:站在左岩坡边,低头
+ M.figure(lg, { hemK: 0.7, halo: true, x: 330, y: 885, h: 430, face: 1, lean: 0.05, bow: 0.9, t: tt, seed: 3, sway: 0.35,
+ robe: ['#b8c6d0', '#8399ab', '#53677d'], under: '#e9dcb4', skin: '#dcae85', hair: '#6b4b30', gaze: [bx - 120, by + 20], hands: [[430, 720], [445, 762]] });
+ // 箱子落地时扬起的一点灰
+ const dust = ss(3.7, 4.0, tt) * (1 - ss(4.0, 5.4, tt));
+ if (dust > 0) { lg.fillStyle = `rgba(210,190,150,${0.35 * dust})`; for (let i = 0; i < 9; i++) { const a = i / 9 * TAU; lg.beginPath(); lg.ellipse(bx + Math.cos(a) * 90 * (0.5 + dust), 868 + Math.sin(a) * 8, 22, 9, 0, 0, TAU); lg.fill(); } }
+ // 一只鸟横过天(慢慢,不抢戏)
+ const bt = ss(0.2, 5.8, tt), bxp = lerp(-60, 1000, bt), byp = 130 + Math.sin(bt * 9) * 14;
+ lg.strokeStyle = 'rgba(240,235,220,.9)'; lg.lineWidth = 3; lg.beginPath(); lg.moveTo(bxp - 16, byp + Math.sin(tt * 11) * 6); lg.quadraticCurveTo(bxp, byp - 8, bxp + 16, byp + Math.sin(tt * 11 + 1) * 6); lg.stroke();
+
+ M.fresco(c, live, { ground: GROUND, chalk: 0.07, soften: 0.7, plasterAlpha: 0.5, sat: 1.12 });
+ // 装饰边框:深红带+金线+菱形 cosmati 纹(原作每幅都被这样一条带框住)
+ c.save(); c.lineWidth = 1;
+ c.fillStyle = '#7b2f2a'; c.fillRect(0, 0, W, 34); c.fillRect(0, H - 34, W, 34); c.fillRect(0, 0, 34, H); c.fillRect(W - 34, 0, 34, H);
+ c.strokeStyle = '#d7b35c'; c.lineWidth = 3; c.strokeRect(34, 34, W - 68, H - 68);
+ c.fillStyle = '#e8d6a0'; for (let x = 60; x < W - 40; x += 44) { [[x, 17], [x, H - 17]].forEach(([a, b]) => { c.beginPath(); c.moveTo(a, b - 8); c.lineTo(a + 10, b); c.lineTo(a, b + 8); c.lineTo(a - 10, b); c.fill(); }); }
+ for (let y = 60; y < H - 40; y += 44) { [[17, y], [W - 17, y]].forEach(([a, b]) => { c.beginPath(); c.moveTo(a, b - 10); c.lineTo(a + 8, b); c.lineTo(a, b + 10); c.lineTo(a - 8, b); c.fill(); }); }
+ c.restore();
+ // 边缘剥落:灰泥外圈略亮、角上几处脱落(只在边框与天空,不碰人物)
+ c.save(); c.globalCompositeOperation = 'screen'; const vg = c.createRadialGradient(W / 2, H / 2, 600, W / 2, H / 2, 1180); vg.addColorStop(0, 'rgba(255,245,225,0)'); vg.addColorStop(1, 'rgba(255,245,225,.12)'); c.fillStyle = vg; c.fillRect(0, 0, W, H); c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/39_piero.js b/scripts/engine/scenes/39_piero.js
new file mode 100644
index 0000000..9d9232b
--- /dev/null
+++ b/scripts/engine/scenes/39_piero.js
@@ -0,0 +1,53 @@
+SCENES['39_piero']=(()=>{
+ const TAU=Math.PI*2; let bg,grain,raw;
+ const rng=(s)=>()=>{s=(Math.imul(s,1664525)+1013904223)|0;return (s>>>0)/4294967296;};
+ function path(c,d,col,st,lw=2){const p=new Path2D(d);if(col){c.fillStyle=col;c.fill(p);}if(st){c.strokeStyle=st;c.lineWidth=lw;c.stroke(p);}return p;}
+ function poly(c,pts,col,st,lw=2){c.beginPath();pts.forEach((p,i)=>i?c.lineTo(...p):c.moveTo(...p));c.closePath();if(col){c.fillStyle=col;c.fill();}if(st){c.strokeStyle=st;c.lineWidth=lw;c.stroke();}}
+ function el(c,x,y,rx,ry,col,st,lw=2){c.beginPath();c.ellipse(x,y,rx,ry,0,0,TAU);if(col){c.fillStyle=col;c.fill();}if(st){c.strokeStyle=st;c.lineWidth=lw;c.stroke();}}
+ function line(c,pts,col,w=2){c.beginPath();pts.forEach((p,i)=>i?c.lineTo(...p):c.moveTo(...p));c.strokeStyle=col;c.lineWidth=w;c.stroke();}
+ function grad(c,x,y,X,Y,colors){const g=c.createLinearGradient(x,y,X,Y);colors.forEach((a,i)=>g.addColorStop(i/(colors.length-1),a));return g;}
+ function layer(fn){let a=document.createElement('canvas');a.width=1920;a.height=1080;fn(a.getContext('2d'));return a;}
+ function finish(c){if(!grain)grain=layer(g=>{let r=rng(7891);for(let i=0;i<21000;i++){g.fillStyle=i%3?'rgba(49,32,22,.045)':'rgba(255,248,220,.08)';let x=r()*1920,y=r()*1080;g.fillRect(x,y,1+r()*2.4,1+r()*1.5);}});c.drawImage(grain,0,0);}
+
+ function back(c){
+ c.fillStyle=grad(c,0,0,0,1080,['#c3d4d3','#e0e0cd']);c.fillRect(0,0,1920,1080);
+ // A contemporary measuring hall, ordered through repeated intervals rather than antique iconography.
+ c.fillStyle='#d9d2b9';c.fillRect(0,80,1920,660);
+ for(let x=100;x<1920;x+=420){c.fillStyle='#718c8c';c.fillRect(x,153,274,451);c.fillStyle=grad(c,0,150,0,610,['#b5cccf','#edf0d8']);c.fillRect(x+14,166,246,424);for(let j=0;j<3;j++)line(c,[[x+15,270+j*105],[x+259,270+j*105]],'#d7d8c4',7);line(c,[[x+138,165],[x+138,590]],'#d6d8c6',9);}
+ poly(c,[[0,0],[1920,0],[1920,84],[0,84]],'#6b827e');c.fillStyle='#eee5cd';c.fillRect(0,78,1920,23);
+ for(let x=20;x<1920;x+=420){c.fillStyle=grad(c,x,0,x+64,0,['#b1b19b','#e8e0c7','#c4bea8']);c.fillRect(x,101,64,620);c.fillStyle='#b3ac97';c.fillRect(x-10,690,85,37);}
+ poly(c,[[0,735],[1920,735],[1920,1080],[0,1080]],'#d2c5a5');
+ const vx=1010,vy=550;for(let x=-1800;x<4200;x+=260)line(c,[[vx+(x-vx)*.38,735],[x,1080]],'#a89e85',2);for(let y of [762,803,861,945,1060])line(c,[[0,y],[1920,y]],'#a89e85',2);
+ // Stacked instruments inhabit different measured planes.
+ poly(c,[[1310,718],[1650,682],[1820,754],[1485,811]],'#d3d0b8','#9a9f90',2);poly(c,[[1485,811],[1820,754],[1820,970],[1485,1042]],'#a6b0a3');poly(c,[[1310,718],[1485,811],[1485,1042],[1310,935]],'#b8b9a3');
+ for(let y=836;y<1010;y+=42)line(c,[[1504,y],[1793,y-60]],'#81968f',3);
+ c.fillStyle='#b7a889';c.fillRect(120,689,375,226);poly(c,[[120,689],[354,638],[535,682],[300,739]],'#e5d5b0');poly(c,[[300,739],[535,682],[535,910],[300,966]],'#8e9d90');
+ let r=rng(391);for(let i=0;i<1400;i++){c.fillStyle=i%2?'rgba(255,255,228,.06)':'rgba(70,91,83,.04)';c.fillRect(r()*1920,r()*1080,1+r()*18,1);}
+ }
+ function sphere(c,x,y,r,col){let g=c.createRadialGradient(x-r*.4,y-r*.45,2,x,y,r);g.addColorStop(0,'#f3ebcc');g.addColorStop(.45,col);g.addColorStop(1,'#647d77');el(c,x,y,r,r,g);}
+ return {draw(dst,lt){if(!raw)raw=layer(()=>{});const c=raw.getContext('2d',{willReadFrequently:true});c.reset();if(!bg)bg=layer(back);c.drawImage(bg,0,0);const t=lt;
+ el(c,878,927,341,62,'rgba(85,100,88,.14)');
+ // Plinth, precisely vertical axis and a suspended mechanical planetary model.
+ poly(c,[[560,868],[898,802],[1180,880],[829,971]],'#ded8bb','#88988a',2);poly(c,[[560,868],[829,971],[829,1053],[560,947]],'#b2b79e');poly(c,[[829,971],[1180,880],[1180,964],[829,1053]],'#8e9c8b');
+ c.fillStyle=grad(c,835,0,902,0,['#7c968b','#d8d9bd','#a4b19c']);c.fillRect(835,533,67,359);el(c,868,893,113,29,'#bec4aa','#819589',3);
+ c.save();c.translate(868,444);
+ // Meridian rings, with alternate back and front arcs around the central orb.
+ c.save();c.rotate(-.35+t*.18);for(let i=0;i<3;i++){c.beginPath();c.ellipse(0,0,287-i*7,310-i*7,0,0,TAU);c.strokeStyle=i===1?'#d9c79a':'#7e8a71';c.lineWidth=i===1?13:3;c.stroke();}for(let j=0;j<64;j++){let a=j*TAU/64;line(c,[[Math.cos(a)*292,Math.sin(a)*315],[Math.cos(a)*(j%4?280:272),Math.sin(a)*(j%4?303:295)]],'#8a8f74',2);}c.restore();
+ const a=t*.43,px=Math.cos(a)*251,py=Math.sin(a)*87;
+ c.beginPath();c.ellipse(0,0,318,111,-.15,Math.PI,TAU);c.strokeStyle='#a89e79';c.lineWidth=10;c.stroke();
+ line(c,[[0,0],[px,py]],'#8f987d',9);if(py<0)sphere(c,px,py,43,'#b87959');
+ sphere(c,0,0,119,'#c5b979');
+ // Very restrained latitude bands maintain rounded, clear volume.
+ c.save();c.beginPath();c.arc(0,0,119,0,TAU);c.clip();for(let y=-80;y<110;y+=40)el(c,0,y,118,25,null,'rgba(100,120,94,.17)',2);c.restore();
+ if(py>=0)sphere(c,px,py,43,'#b87959');
+ c.beginPath();c.ellipse(0,0,318,111,-.15,0,Math.PI);c.strokeStyle='#d0bd8f';c.lineWidth=10;c.stroke();
+ const b=-t*.69+1.4;let qx=Math.cos(b)*173,qy=Math.sin(b)*260;
+ c.save();c.rotate(.68);c.beginPath();c.ellipse(0,0,173,260,0,0,TAU);c.strokeStyle='#9da98d';c.lineWidth=5;c.stroke();sphere(c,qx,qy,20,'#9ab6af');c.restore();
+ el(c,0,-325,10,10,'#a39d76');el(c,0,325,10,10,'#a39d76');c.restore();
+ // Displaced secondary objects form unequal but balanced intervals.
+ sphere(c,1606,640,85,'#9aafa3');el(c,1606,727,91,13,'#8d9a88');
+ c.save();c.translate(327,625);c.rotate(-.12+Math.sin(t*.45)*.045);poly(c,[[-125,-12],[108,-12],[108,16],[-125,16]],'#83988e','#687d76',2);el(c,111,0,14,35,'#5e7877','#c5c8af',7);for(let i=-105;i<100;i+=22)line(c,[[i,-9],[i,4]],'#d9d9be',2);c.restore();
+ for(let i=0;i<24;i++){let y=330+(i*39)%400,x=200+(i*127)%1450;el(c,x+Math.sin(t*.35+i)*6,y-((t*5+i*13)%27),1.2,1.2,'rgba(255,255,230,.32)');}
+ finish(c);dst.drawImage(raw,0,0);dst.save();dst.globalAlpha=0.18;PAINT.strokes(dst,raw,{cell:7,len:9,width:4,jitterCol:5,angle:(x,y)=>-.45,seed:39,boil:0,outline:0});dst.restore();
+ }};
+})();
diff --git a/scripts/engine/scenes/40_raphael.js b/scripts/engine/scenes/40_raphael.js
new file mode 100644
index 0000000..4887be8
--- /dev/null
+++ b/scripts/engine/scenes/40_raphael.js
@@ -0,0 +1,96 @@
+// 拉斐尔(梵蒂冈签字厅湿壁画):半圆楣窗里一座中心透视的筒拱大厅,藻井格逐层退向远端透出的一片天;人成组站在棋盘格地面上,袍色饱和(橙/蓝/玫/绿/丁香),姿势互相呼应,手和视线把一群人缝成一个整体。
+// 题材(新构图,不搬名作):图书馆大厅——中央两位学者指着藻井与手卷争论,左组围着台上的摊开书,右组围着旋转的星盘;远处楼梯上有人走动。
+// 原作锚定(fetch_reference.py:《雅典学院》《圣礼辩论》《帕纳塞斯》):象牙白石+蓝灰影 #e6dcc4/#9aa4b4,远端一片天 #9cc0e8,袍橙 #d2833a、蓝 #4f72b8、玫 #cf7480、绿 #5f9468、丁香 #8a78b8,金褐装饰带 #b08a40,棋盘格大理石地。
+// 管线:形层(墙框→透视拱顶藻井→侧墙壁柱壁龛→棋盘格地→台阶)+人(M.figure)→ MEDIUM.fresco → 楣窗金带与底部灰色浮雕带。
+SCENES['40_raphael'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ const CX = 960, SP = 500, N = 9; // 消失点横坐标、拱起点(视平线)、藻井层数
+ const ring = j => { const k = Math.pow(0.17, j / N); return { k, rx: 860 * k, ry: 400 * k, fl: SP + 500 * k }; };
+ const ROB = { orange: ['#f4bc7e', '#d2833a', '#8c4a22'], blue: ['#9cb8e6', '#4f72b8', '#2a4278'], rose: ['#f4c0c4', '#cf7480', '#8a3e4c'], green: ['#b0d4a6', '#5f9468', '#2f5a3c'], lilac: ['#d0c6ee', '#8a78b8', '#524478'], ivory: ['#faf3de', '#dccfa8', '#9a8c68'], ochre: ['#ecd592', '#c4a050', '#7c6228'] };
+ let plate, built = false, back;
+ const P3 = (j, th) => { const r = ring(j); return [CX + r.rx * Math.cos(th), SP - r.ry * Math.sin(th)]; };
+ const quad = (g, a, b, c2, d, fill) => { g.fillStyle = fill; g.beginPath(); g.moveTo(...a); g.lineTo(...b); g.lineTo(...c2); g.lineTo(...d); g.closePath(); g.fill(); };
+ function build() {
+ plate = P.canvas(); const g = plate.getContext('2d'), rn = rng(6);
+ // 外墙:象牙白,楣窗之外是壁面(带金褐装饰带沿拱走)
+ g.fillStyle = '#e4d8bc'; g.fillRect(0, 0, W, H);
+ // 远端:一片天+更远的小拱门
+ const r8 = ring(N), sg = g.createLinearGradient(0, SP - r8.ry, 0, r8.fl); sg.addColorStop(0, '#7fa8dc'); sg.addColorStop(1, '#cfe0f0');
+ g.fillStyle = sg; g.beginPath(); g.ellipse(CX, SP, r8.rx, r8.ry, 0, Math.PI, TAU); g.lineTo(CX + r8.rx, r8.fl); g.lineTo(CX - r8.rx, r8.fl); g.closePath(); g.fill();
+ // 层层退向远端:从远到近画(近的盖住远的);每层之间是侧墙(壁柱/壁龛)、拱顶(藻井)、地面
+ for (let j = N - 1; j >= 0; j--) {
+ const a = ring(j), b = ring(j + 1), shade = 0.08 * (j % 2);
+ // 地面:棋盘
+ for (let i = 0; i < 16; i++) { const x0a = CX + a.rx * (i / 8 - 1), x1a = CX + a.rx * ((i + 1) / 8 - 1), x0b = CX + b.rx * (i / 8 - 1), x1b = CX + b.rx * ((i + 1) / 8 - 1); quad(g, [x0a, a.fl], [x1a, a.fl], [x1b, b.fl], [x0b, b.fl], (i + j) % 2 ? '#e8dcc0' : '#bfb08c'); }
+ // 侧墙(左右):象牙石+深一档的壁柱
+ [-1, 1].forEach(sd => { const xa = CX + sd * a.rx, xb = CX + sd * b.rx;
+ quad(g, [xa, SP], [xb, SP], [xb, b.fl], [xa, a.fl], sd < 0 ? `rgba(${196 - j * 3},${186 - j * 3},${164 - j * 3},1)` : `rgba(${206 - j * 3},${196 - j * 3},${176 - j * 3},1)`);
+ if (j % 3 === 0) { const wa = a.rx * 0.07, wb = b.rx * 0.07; quad(g, [xa, SP], [xa - sd * wa * 0, SP], [xb, SP], [xb, SP], 'rgba(0,0,0,0)'); quad(g, [xa - sd * wa, SP], [xa, SP], [xa, a.fl], [xa - sd * wa, a.fl], 'rgba(120,108,88,.5)'); }
+ else if (j % 3 === 1) { // 壁龛:深洞+象牙雕像
+ const m = (u, v) => [lerp(xa, xb, u), lerp(lerp(SP, SP, 0), 0, 0) + lerp(lerp(SP + 40 * a.k, SP + 40 * b.k, u), lerp(a.fl - 80 * a.k, b.fl - 80 * b.k, u), v)];
+ const p0 = m(0.18, 0), p1 = m(0.82, 0), p2 = m(0.82, 1), p3 = m(0.18, 1); quad(g, p0, p1, p2, p3, '#6c5f4c');
+ const cx2 = lerp(xa, xb, 0.5), top = lerp(SP + 40 * a.k, SP + 40 * b.k, 0.5), bot = lerp(a.fl - 80 * a.k, b.fl - 80 * b.k, 0.5), hh = bot - top, ww = Math.abs(xb - xa) * 0.18;
+ g.fillStyle = '#f0e8d4'; g.beginPath(); g.ellipse(cx2, top + hh * 0.16, ww * 0.42, hh * 0.09, 0, 0, TAU); g.fill(); g.beginPath(); g.moveTo(cx2 - ww * 0.55, top + hh * 0.24); g.lineTo(cx2 + ww * 0.55, top + hh * 0.24); g.lineTo(cx2 + ww * 0.7, bot); g.lineTo(cx2 - ww * 0.7, bot); g.closePath(); g.fill();
+ } });
+ // 拱顶:沿角度切成藻井格,每格一个亮面+内凹的暗框
+ const nth = 14;
+ for (let i = 0; i < nth; i++) { const t0 = i / nth * Math.PI, t1 = (i + 1) / nth * Math.PI, A0 = P3(j, t0), A1 = P3(j, t1), B0 = P3(j + 1, t0), B1 = P3(j + 1, t1); const lit = 0.5 + 0.5 * Math.cos((t0 + t1) / 2 - Math.PI * 0.35);
+ quad(g, A0, A1, B1, B0, `rgb(${Math.round(214 - 34 * (1 - lit) - j * 2)},${Math.round(202 - 32 * (1 - lit) - j * 2)},${Math.round(176 - 30 * (1 - lit) - j * 2)})`);
+ const m = (p, q, u, v) => [lerp(p[0], q[0], u), lerp(p[1], q[1], u)]; const i0 = [lerp(A0[0], A1[0], 0.2), lerp(A0[1], A1[1], 0.2)], i1 = [lerp(A0[0], A1[0], 0.8), lerp(A0[1], A1[1], 0.8)], i2 = [lerp(B0[0], B1[0], 0.8), lerp(B0[1], B1[1], 0.8)], i3 = [lerp(B0[0], B1[0], 0.2), lerp(B0[1], B1[1], 0.2)];
+ const c0 = [lerp(i0[0], i3[0], 0.2), lerp(i0[1], i3[1], 0.2)], c1 = [lerp(i1[0], i2[0], 0.2), lerp(i1[1], i2[1], 0.2)], c2 = [lerp(i1[0], i2[0], 0.8), lerp(i1[1], i2[1], 0.8)], c3 = [lerp(i0[0], i3[0], 0.8), lerp(i0[1], i3[1], 0.8)];
+ quad(g, c0, c1, c2, c3, `rgba(110,98,78,${0.35 + 0.1 * (1 - lit)})`); }
+ // 拱环:每层交界处一道亮边
+ g.strokeStyle = 'rgba(250,244,226,.7)'; g.lineWidth = Math.max(1.5, 6 * a.k); g.beginPath(); g.ellipse(CX, SP, a.rx, a.ry, 0, Math.PI, TAU); g.stroke();
+ }
+ // 外框:拱外的墙面——楣窗装饰带(金褐+宝石红+群青)沿拱走
+ g.save(); g.beginPath(); g.rect(0, 0, W, H); g.ellipse(CX, SP, 860, 400, 0, 0, TAU); g.clip('evenodd'); g.fillStyle = '#e8dcc2'; g.fillRect(0, 0, W, H);
+ for (let i = 0; i < 90; i++) { g.fillStyle = `rgba(${rn() < 0.5 ? '255,248,230' : '120,100,70'},${0.04 + rn() * 0.05})`; g.beginPath(); g.ellipse(rn() * W, rn() * 480, 60 + rn() * 140, 30 + rn() * 60, 0, 0, TAU); g.fill(); }
+ g.restore();
+ [[900, 430, '#b08a40', 16], [880, 410, '#7a2f3c', 10], [920, 450, '#2f4f8c', 8]].forEach(([rx, ry, col, lw]) => { g.strokeStyle = col; g.lineWidth = lw; g.beginPath(); g.ellipse(CX, SP, rx, ry, 0, Math.PI, TAU); g.stroke(); });
+ g.fillStyle = '#d4a85a'; for (let i = 0; i < 38; i++) { const th = Math.PI + (i + 0.5) / 38 * Math.PI, x = CX + 890 * Math.cos(th), y = SP + 420 * Math.sin(th); g.beginPath(); g.arc(x, y, 7, 0, TAU); g.fill(); }
+ // 拱下左右的壁柱柱头与墙脚
+ [[0, 160], [W - 160, 160]].forEach(([x, w]) => { g.fillStyle = '#d8ccb0'; g.fillRect(x, SP, w, H - SP); g.fillStyle = 'rgba(110,96,72,.35)'; g.fillRect(x + (x ? 0 : w - 14), SP, 14, H - SP); });
+ // 前景台阶:两级,延伸全宽
+ quad(g, [0, 960], [W, 960], [W, 1000], [0, 1000], '#efe4c8'); quad(g, [0, 1000], [W, 1000], [W, 1030], [0, 1030], '#b8aa86'); quad(g, [0, 940], [W, 940], [W, 960], [0, 960], '#d8cba8');
+ // 底部灰色浮雕带(grisaille):四块方框里各一个小浮雕
+ g.fillStyle = '#d2c6aa'; g.fillRect(0, 1030, W, 50); g.fillStyle = '#7b6c50'; g.fillRect(0, 1030, W, 5);
+ for (let i = 0; i < 6; i++) { const x = 90 + i * 300; g.fillStyle = '#a89c80'; g.fillRect(x, 1040, 200, 34); g.fillStyle = '#e2d8be'; g.beginPath(); g.ellipse(x + 100, 1060, 26, 10, 0, 0, TAU); g.fill(); g.fillRect(x + 60, 1052, 80, 4); }
+ built = true;
+ }
+ // 台上摊开的书、星盘
+ function book(g, x, y, t) {
+ g.fillStyle = '#c4b48a'; g.fillRect(x - 130, y, 260, 56); g.fillStyle = '#9a8860'; g.fillRect(x - 130, y + 56, 260, 12);
+ g.fillStyle = '#f6efd6'; g.beginPath(); g.moveTo(x - 110, y - 12); g.lineTo(x, y - 24); g.lineTo(x + 110, y - 12); g.lineTo(x + 110, y + 6); g.lineTo(x, y - 6); g.lineTo(x - 110, y + 6); g.closePath(); g.fill(); g.strokeStyle = '#6a5a3c'; g.lineWidth = 2; g.stroke();
+ g.strokeStyle = 'rgba(80,60,40,.6)'; g.lineWidth = 1.8; for (let k = 0; k < 4; k++) { g.beginPath(); g.moveTo(x - 94, y - 4 + k * 3 - 6 * (1 - k / 4)); g.lineTo(x - 12, y - 14 + k * 3); g.moveTo(x + 12, y - 14 + k * 3); g.lineTo(x + 94, y - 4 + k * 3); g.stroke(); }
+ }
+ function astrolabe(g, x, y, t) {
+ g.fillStyle = '#c4b48a'; g.fillRect(x - 70, y + 150, 140, 18); g.fillRect(x - 12, y + 40, 24, 120);
+ g.strokeStyle = '#a6802c'; g.lineWidth = 7; [0, 1, 2].forEach(k => { const a = t * 0.9 + k * 1.0; g.beginPath(); g.ellipse(x, y, 90 - k * 8, 90 * Math.abs(Math.cos(a)) + 6, k * 0.6 - 0.3, 0, TAU); g.stroke(); });
+ g.fillStyle = '#4f72b8'; g.beginPath(); g.arc(x, y, 22, 0, TAU); g.fill(); g.strokeStyle = '#2a4278'; g.lineWidth = 3; g.stroke();
+ }
+ function fig(g, x, y, h, face, rb, mt, extra, t, seed) { M.figure(g, Object.assign({ x, y, h, face, t, seed, halo: false, robe: ROB[rb], mantle: mt ? ROB[mt] : null, under: '#f4ead0', skin: '#e2b48a', hair: '#5b3a22', sway: 0.3 }, extra)); }
+ function draw(c, lt) {
+ if (!built) build();
+ const t = clamp(lt, 0, 6);
+ const live = P.scratch('raph_live'), g = live.getContext('2d'); g.reset(); g.drawImage(plate, 0, 0);
+ // 远处楼梯上的小人:沿地面走(近大远小的极小人影)
+ [[0.1, 0, ROB.orange], [0.5, 1, ROB.blue], [0.8, 0, ROB.rose]].forEach(([u0, dir, col], i) => { const u = ((u0 + t * 0.03 * (dir ? -1 : 1)) % 1 + 1) % 1, y = 640 + (i % 2) * 22, x = CX - 90 + u * 180, h = 74; M.figure(g, { x, y, h, face: dir ? -1 : 1, t, seed: 40 + i, robe: col, under: '#f4ead0', skin: '#e2b48a', hair: '#5b3a22', sway: 0.6, lean: 0.02 }); });
+ // 左组:石台上的书,三人围看
+ book(g, 560, 772, t);
+ fig(g, 410, 945, 330, 1, 'green', 'ochre', { lean: 0.1, bow: 0.8, gaze: [540, 760], hands: [[500, 800], [505, 786]] }, t, 11);
+ fig(g, 735, 940, 315, -1, 'lilac', 'rose', { lean: 0.07, bow: 0.6, gaze: [600, 760], hands: [[640, 790 + Math.sin(t * 1.3) * 4], null] }, t, 12);
+ fig(g, 250, 950, 300, 1, 'ivory', 'blue', { lean: 0.04, bow: 0.3, gaze: [520, 750], hands: [null, null] }, t, 13);
+ // 右组:星盘,两人看,一人伸手拨环
+ astrolabe(g, 1400, 660, t);
+ fig(g, 1230, 945, 325, -1, 'rose', 'blue', { lean: 0.06, bow: 0.5, gaze: [1380, 660], hands: [[1330, 710 + Math.sin(t * 2) * 6], null] }, t, 21);
+ fig(g, 1590, 945, 335, -1, 'orange', 'green', { lean: 0.08, bow: 0.7, gaze: [1440, 670], hands: [[1490, 720], [1480, 690]] }, t, 22);
+ fig(g, 1730, 940, 295, -1, 'ochre', null, { lean: 0.03, bow: 0.2, gaze: [1440, 730], hands: [null, null] }, t, 23);
+ // 中央两位:左边指向藻井(手臂上下起落),右边展开手卷,视线互相咬合
+ const pt = Math.sin(t * 1.4) * 0.5;
+ fig(g, 870, 990, 385, 1, 'blue', 'orange', { lean: 0.04, bow: 0, gaze: [1000, 580], hands: [[960, 560 - pt * 20], [930, 760]] }, t, 31);
+ fig(g, 1070, 990, 365, -1, 'rose', 'green', { lean: 0.05, bow: 0.2, gaze: [930, 600], hands: [[970, 790], [985, 770]] }, t, 32);
+ g.strokeStyle = '#6a5a3c'; g.lineWidth = 3; g.fillStyle = '#f6efd6'; g.beginPath(); g.moveTo(950, 745); g.quadraticCurveTo(972, 735, 994, 745); g.lineTo(994, 792); g.quadraticCurveTo(972, 802, 950, 792); g.closePath(); g.fill(); g.stroke(); // 手卷
+ M.fresco(c, live, { ground: M.plaster('raphael', { base: '#e0d4b8', seed: 15 }), chalk: 0.05, soften: 0.5, plasterAlpha: 0.45, sat: 1.1 });
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/41_michelangelo.js b/scripts/engine/scenes/41_michelangelo.js
new file mode 100644
index 0000000..b23f33f
--- /dev/null
+++ b/scripts/engine/scenes/41_michelangelo.js
@@ -0,0 +1,112 @@
+// 米开朗基罗(红粉笔人体习作+「未完成」):形体是雕出来的——光从左上来,肩胛、脊沟、背阔肌像石头一样有体积;用红粉笔沿形体走向排线,暗处交叉再压一层,边缘有断续的重轮廓;画面下端不收尾,像雕像还陷在粗石里。
+// 题材(新构图,不搬名作):一张旧素描纸,一个双臂举起、背身扭转的男子习作正在被一笔笔排线画出来;右侧是同一人翻转缩小的旧习作,角落有几行不成字的注记。
+// 原作锚定(fetch_reference.py:《阿特拉斯奴隶》《利比亚女先知习作》《创造亚当》):纸 #dfc79e 偏暖米黄带霉斑、红粉笔 #9c3f26(暗处 #6e2a1a)、亮处不画(留纸)、排线以斜 50° 为主+沿形体转向、边缘粗而断续。
+// 管线:形体图(灰度,用椭圆光暗叠出肌肉)→ 由明暗+梯度方向生成确定性排线笔画 → 缓存成一张「已画完」的红粉笔层 → 按 y 从上到下揭示,笔尖(粉笔)跟着扫。
+SCENES['41_michelangelo'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ const FW = 720, FH = 860; // 形体图局部坐标
+ let paper, big, small, built = false;
+ const smooth = (pts) => { const p = new Path2D(), n = pts.length, m = i => [(pts[i % n][0] + pts[(i + 1) % n][0]) / 2, (pts[i % n][1] + pts[(i + 1) % n][1]) / 2]; p.moveTo(...m(n - 1)); for (let i = 0; i < n; i++) p.quadraticCurveTo(pts[i][0], pts[i][1], ...m(i)); p.closePath(); return p; };
+ const capsule = (pts, ws) => { const L = [], R = []; pts.forEach((p, i) => { const a = pts[Math.max(0, i - 1)], b = pts[Math.min(pts.length - 1, i + 1)], d = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1, nx = -(b[1] - a[1]) / d, ny = (b[0] - a[0]) / d; L.push([p[0] + nx * ws[i] / 2, p[1] + ny * ws[i] / 2]); R.push([p[0] - nx * ws[i] / 2, p[1] - ny * ws[i] / 2]); }); return smooth([...L, ...R.reverse()]); };
+ // ---- 形体:剪影(各部件)与明暗 ----
+ const parts = () => ({
+ torso: smooth([[262, 188], [196, 206], [118, 238], [100, 280], [140, 340], [176, 410], [208, 490], [226, 565], [214, 640], [188, 716], [236, 792], [305, 804], [374, 792], [424, 716], [398, 640], [386, 565], [404, 490], [438, 410], [474, 340], [516, 280], [498, 238], [418, 206], [348, 188]]),
+ armL: capsule([[132, 266], [34, 128], [28, 40], [112, 8]], [128, 104, 70, 44]), armR: capsule([[486, 262], [572, 124], [570, 40], [484, 14]], [128, 104, 70, 44]),
+ head: smooth([[298, 22], [346, 36], [366, 84], [358, 128], [336, 160], [300, 176], [268, 168], [250, 150], [238, 128], [226, 114], [237, 100], [240, 70], [262, 36]]),
+ neck: smooth([[250, 150], [352, 150], [392, 214], [222, 214]]),
+ });
+ const LIGHTS = [ // x, y, rx, ry, 明度, 浓度(光从左上)
+ [300, 240, 112, 62, 0.98, 0.6], [212, 330, 66, 84, 1.0, 0.8], [398, 330, 62, 84, 0.86, 0.6], [214, 420, 64, 18, 0.15, 0.8], [398, 420, 60, 18, 0.12, 0.8], [170, 300, 70, 12, 0.18, 0.7], [250, 318, 10, 70, 0.2, 0.55],
+ [305, 450, 11, 235, 0.12, 0.85], [266, 535, 30, 115, 1.0, 0.65], [346, 535, 30, 115, 0.8, 0.5], [162, 420, 38, 120, 0.22, 0.7], [452, 420, 40, 120, 0.1, 0.8],
+ [205, 600, 28, 74, 0.2, 0.6], [405, 600, 26, 74, 0.1, 0.6], [248, 722, 78, 70, 1.0, 0.75], [364, 722, 78, 70, 0.7, 0.6], [305, 708, 7, 76, 0.1, 0.75],
+ [132, 262, 62, 64, 1.0, 0.85], [150, 330, 14, 50, 0.15, 0.7], [488, 258, 60, 64, 0.5, 0.7], [468, 330, 14, 50, 0.1, 0.7],
+ [96, 180, 40, 92, 1.0, 0.7], [64, 140, 20, 60, 0.2, 0.6], [532, 170, 40, 92, 0.42, 0.65], [566, 130, 20, 60, 0.15, 0.6],
+ [78, 90, 28, 52, 0.95, 0.5], [522, 96, 28, 52, 0.38, 0.55],
+ [270, 100, 34, 62, 1.0, 0.65], [340, 100, 30, 70, 0.28, 0.7], [338, 116, 10, 18, 0.1, 0.8], [300, 40, 66, 32, 0.28, 0.7], [270, 52, 18, 14, 0.2, 0.6], [330, 50, 20, 14, 0.15, 0.6],
+ [160, 345, 12, 70, 0.15, 0.7], [452, 345, 12, 70, 0.1, 0.7], [180, 470, 8, 38, 0.2, 0.6], [196, 500, 8, 34, 0.2, 0.6], [212, 530, 8, 30, 0.2, 0.6], [430, 470, 8, 38, 0.1, 0.7], [414, 500, 8, 34, 0.1, 0.7], [398, 530, 8, 30, 0.1, 0.7],
+ [240, 655, 14, 10, 0.12, 0.8], [370, 655, 14, 10, 0.1, 0.8], [215, 290, 70, 14, 0.2, 0.6], [395, 290, 66, 14, 0.15, 0.6], [150, 215, 70, 24, 0.95, 0.5], [300, 300, 140, 24, 0.95, 0.4],
+ [305, 188, 56, 28, 0.3, 0.6], [270, 176, 10, 40, 0.2, 0.6], [345, 176, 10, 40, 0.15, 0.6],
+ ];
+ const twist = y => 30 * Math.sin((y - 60) / 780 * Math.PI * 1.15 - 0.4) - 6; // 肩胛带与骨盆反向偏移:S 形扭转
+ function warp(cv, bg) { const o = P.canvas(FW, FH), g = o.getContext('2d'); if (bg) { g.fillStyle = bg; g.fillRect(0, 0, FW, FH); } for (let y = 0; y < FH; y++) g.drawImage(cv, 0, y, FW, 1, twist(y), y, FW, 1); return o; }
+ function formMap() {
+ const cv = P.canvas(FW, FH), g = cv.getContext('2d'), pt = parts(); g.fillStyle = '#fff'; g.fillRect(0, 0, FW, FH); g.translate(60, 40);
+ const body = new Path2D(); Object.values(pt).forEach(p => body.addPath(p));
+ g.save(); g.clip(body); g.fillStyle = '#d4d4d4'; g.fillRect(0, 0, FW, FH);
+ LIGHTS.forEach(([x, y, rx, ry, v, a]) => { g.save(); g.translate(x, y); g.scale(rx, ry); const gr = g.createRadialGradient(0, 0, 0, 0, 0, 1), c = Math.round(v * 255); gr.addColorStop(0, `rgba(${c},${c},${c},${a})`); gr.addColorStop(1, `rgba(${c},${c},${c},0)`); g.fillStyle = gr; g.beginPath(); g.arc(0, 0, 1, 0, TAU); g.fill(); g.restore(); });
+ g.filter = 'blur(7px)'; g.strokeStyle = 'rgba(40,40,40,.55)'; g.lineWidth = 16; Object.values(pt).forEach(p => g.stroke(p)); g.filter = 'none'; // 边缘遮挡:体积感
+ g.restore();
+ const wcv = warp(cv, '#fff'), mk = P.canvas(FW, FH), mg = mk.getContext('2d'); mg.translate(60, 40); mg.fillStyle = '#000'; Object.values(pt).forEach(p => mg.fill(p));
+ return { cv: wcv, pt, body, mask: warp(mk) };
+ }
+ // ---- 排线:明暗→笔画;亮处留纸,中调单向斜线,暗处交叉;笔向在斜 50° 与形体等高线之间混合 ----
+ function hatch(f, seed) {
+ const g = f.cv.getContext('2d'), d = g.getImageData(0, 0, FW, FH).data, r = rng(seed), out = [];
+ const v = (x, y) => d[((clamp(y | 0, 0, FH - 1)) * FW + clamp(x | 0, 0, FW - 1)) * 4] / 255;
+ for (let y = 4; y < FH - 4; y += 4.4) for (let x = 4; x < FW - 4; x += 4.4) {
+ const px = x + (r() - .5) * 4, py = y + (r() - .5) * 4, val = v(px, py); if (val > 0.985) continue;
+ const dk = 1 - val, gx = v(px + 3, py) - v(px - 3, py), gy = v(px, py + 3) - v(px, py - 3), cont = Math.atan2(gx, -gy), base = -0.88;
+ const fade = 1 - ss(730, 840, py); // 下端不收尾:越往下越淡,像还陷在石里
+ let a = base + Math.sin(cont - base) * 0.18; const L = 12 + r() * 12;
+ if (r() < dk * 1.55 + 0.05) out.push([px, py, a, L, 0.9 + dk * 0.9, clamp((0.18 + dk * 0.75) * fade, 0, 0.92), dk]);
+ if (dk > 0.42 && r() < (dk - 0.3) * 1.5) out.push([px, py, 0.62 + (r() - .5) * 0.2, L * 0.8, 0.8 + dk * 0.7, clamp((0.15 + dk * 0.6) * fade, 0, 0.85), dk]);
+ }
+ return out;
+ }
+ function renderChalk(f, strokes, key) {
+ const cv = P.canvas(FW, FH), g = cv.getContext('2d'); g.lineCap = 'round';
+ strokes.forEach(([x, y, a, L, w, al, dk]) => { g.strokeStyle = dk > 0.6 ? `rgba(104,38,22,${al})` : `rgba(158,66,40,${al})`; g.lineWidth = w; g.beginPath(); g.moveTo(x - Math.cos(a) * L / 2, y - Math.sin(a) * L / 2); g.lineTo(x + Math.cos(a) * L / 2, y + Math.sin(a) * L / 2); g.stroke(); });
+ // 重轮廓:取整体剪影的边界像素,按背光侧加粗、间断(粉笔在纸上拖出的颗粒线),部件之间的接缝不画
+ const mg = f.mask.getContext('2d');
+ const md = mg.getImageData(0, 0, FW, FH).data, al = (x, y) => md[((clamp(y | 0, 0, FH - 1)) * FW + clamp(x | 0, 0, FW - 1)) * 4 + 3] > 128, rr = rng(77);
+ for (let y = 1; y < FH - 1; y++) for (let x = 1; x < FW - 1; x++) {
+ if (!al(x, y) || (al(x - 1, y) && al(x + 1, y) && al(x, y - 1) && al(x, y + 1))) continue;
+ const nx = (al(x - 1, y) ? 1 : 0) - (al(x + 1, y) ? 1 : 0) * -1, ny = 0; // 外法线粗估(见下)
+ const gx = (al(x + 2, y) ? 1 : 0) - (al(x - 2, y) ? 1 : 0), gy = (al(x, y + 2) ? 1 : 0) - (al(x, y - 2) ? 1 : 0); // 指向内部
+ const shade = clamp(-(gx * 0.6 + gy * 0.8), 0, 1); // 外法线朝右下=背光
+ const dash = Math.sin(x * 0.045 + y * 0.037) + Math.sin(x * 0.011 - y * 0.05) * 0.8; if (dash < -0.7 - shade * 0.7) continue;
+ const fade = 1 - ss(740, 830, y); g.fillStyle = `rgba(96,34,20,${(0.5 + shade * 0.45) * fade})`; g.beginPath(); g.arc(x + (rr() - .5) * 0.8, y + (rr() - .5) * 0.8, 1.0 + shade * 1.5 + rr() * 0.5, 0, TAU); g.fill();
+ }
+ return cv;
+ }
+ function paperPlate() {
+ const cv = P.canvas(), g = cv.getContext('2d'), r = rng(9);
+ const bg = g.createLinearGradient(0, 0, 0, H); bg.addColorStop(0, '#2c2218'); bg.addColorStop(1, '#17110c'); g.fillStyle = bg; g.fillRect(0, 0, W, H);
+ g.strokeStyle = 'rgba(255,230,190,.035)'; g.lineWidth = 2; for (let i = 0; i < 80; i++) { const y = r() * H; g.beginPath(); g.moveTo(0, y); g.bezierCurveTo(500, y + (r() - .5) * 30, 1300, y + (r() - .5) * 30, W, y + (r() - .5) * 20); g.stroke(); }
+ // 纸:不规则撕边+投影
+ const edge = []; const x0 = 120, y0 = 56, x1 = 1800, y1 = 1030;
+ for (let x = x0; x <= x1; x += 40) edge.push([x, y0 + (r() - .5) * 6]); for (let y = y0; y <= y1; y += 40) edge.push([x1 + (r() - .5) * 6, y]); for (let x = x1; x >= x0; x -= 40) edge.push([x, y1 + (r() - .5) * 6]); for (let y = y1; y >= y0; y -= 40) edge.push([x0 + (r() - .5) * 6, y]);
+ const sp = smooth(edge); g.save(); g.shadowColor = 'rgba(0,0,0,.6)'; g.shadowBlur = 40; g.shadowOffsetY = 12; g.fillStyle = '#dcc397'; g.fill(sp); g.restore();
+ g.save(); g.clip(sp);
+ const pg = g.createRadialGradient(960, 520, 200, 960, 540, 1050); pg.addColorStop(0, 'rgba(240,220,170,.35)'); pg.addColorStop(1, 'rgba(120,80,40,.35)'); g.fillStyle = pg; g.fillRect(0, 0, W, H);
+ for (let i = 0; i < 70; i++) { g.fillStyle = `rgba(${r() < 0.5 ? '150,100,50' : '110,80,40'},${0.03 + r() * 0.08})`; g.beginPath(); g.ellipse(x0 + r() * (x1 - x0), y0 + r() * (y1 - y0), 6 + r() * 40, 5 + r() * 30, r() * 3, 0, TAU); g.fill(); } // 霉斑
+ g.strokeStyle = 'rgba(120,90,50,.12)'; g.lineWidth = 1; for (let i = 0; i < 260; i++) { const x = x0 + r() * (x1 - x0), y = y0 + r() * (y1 - y0); g.beginPath(); g.moveTo(x, y); g.lineTo(x + (r() - .5) * 34, y + (r() - .5) * 10); g.stroke(); } // 纸纤维
+ // 注记:几行不成字的手写笔画(右下)
+ g.strokeStyle = 'rgba(90,40,24,.55)'; g.lineWidth = 1.8; g.lineCap = 'round'; for (let ln = 0; ln < 4; ln++) { let x = 1240; const y = 900 + ln * 30; g.beginPath(); g.moveTo(x, y); while (x < 1640 - r() * 100) { x += 6 + r() * 12; g.quadraticCurveTo(x - 4, y - 8 - r() * 8, x, y + (r() - .5) * 3); } g.stroke(); }
+ g.restore();
+ return cv;
+ }
+ function build() {
+ const f = formMap(), st = hatch(f, 5); big = renderChalk(f, st, 'big'); big._f = f;
+ const sm = P.canvas(FW, FH), sg = sm.getContext('2d'); sg.drawImage(big, 0, 0); small = sm; // 旧习作:同一人,翻转缩小,较淡
+ paper = paperPlate(); built = true;
+ }
+ function draw(c, lt) {
+ if (!built) build();
+ const t = clamp(lt, 0, 6);
+ c.drawImage(paper, 0, 0);
+ // 右侧旧习作:翻转、0.46 倍、较淡,画满
+ c.save(); c.globalAlpha = 0.72; c.translate(1560, 90); c.scale(-0.46, 0.46); c.translate(-FW, 0); c.drawImage(small, 0, 0, FW, FH * 0.9, 0, 0, FW, FH * 0.9); c.restore();
+ // 主习作:随笔尖从上往下被画出
+ const OX = 500, OY = 110, S = 1.0, p = ss(0.25, 5.2, t), ry = p * (FH + 30);
+ c.save(); c.beginPath(); c.rect(OX, OY, FW * S, ry * S); c.clip(); c.drawImage(big, OX, OY, FW * S, FH * S); c.restore();
+ c.save(); c.globalAlpha = 1; const edge = c.createLinearGradient(0, OY + ry * S - 26, 0, OY + ry * S); edge.addColorStop(0, 'rgba(220,195,150,0)'); edge.addColorStop(1, 'rgba(220,195,150,.0)'); c.restore();
+ if (p < 0.999) { // 粉笔:笔尖在揭示线上左右扫,笔杆朝右上
+ const tx = OX + FW * S * (0.5 + 0.46 * Math.sin(t * 7.3) * Math.cos(t * 1.9)), ty = OY + ry * S + Math.sin(t * 13) * 3;
+ c.save(); c.translate(tx, ty); c.rotate(-0.95); c.fillStyle = '#7a3a24'; c.fillRect(0, -5, 190, 10); c.fillStyle = '#9c3f26'; c.fillRect(-16, -5, 18, 10); c.fillStyle = '#c9a56a'; c.fillRect(120, -6, 60, 12); c.restore();
+ c.fillStyle = 'rgba(150,70,44,.28)'; for (let i = 0; i < 6; i++) { c.beginPath(); c.arc(tx + (Math.sin(t * 20 + i * 7) * 14), ty + 6 + ((t * 40 + i * 9) % 36), 1.3, 0, TAU); c.fill(); } // 落下的粉屑
+ }
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.18; c.drawImage(P.texture('paper_mich', '#e6d2aa', { scale: 0.006, amt: 12, grain: 8, seed: 3 }), 0, 0); c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/42_guardi.js b/scripts/engine/scenes/42_guardi.js
new file mode 100644
index 0000000..d34ef1e
--- /dev/null
+++ b/scripts/engine/scenes/42_guardi.js
@@ -0,0 +1,70 @@
+// 瓜尔迪(威尼斯晚期):低地平线、银灰绿的巨大空气、细长的舢板和小到只剩几点白的人、笔触干而快、边缘松动,像被风吹散。
+// 题材(新构图):清晨的潟湖,两条细长的小船载着货横过水面,远处一座瘦塔和低矮的岛,天占四分之三。
+// 原作锚定(fetch_reference.py:《威尼斯潟湖》《大运河与里亚托桥》;第三条搜索命中的是现代照片,已弃用,见 16 号「已知的坑」):
+// 天水一色的银灰绿 #9db0b0→#c9cdbd、暖云边 #e2cfa8、塔与岛赭褐 #8a7a62、船黑褐 #2e2a26、人物=黑身+一两点白或红、水面细长横笔。
+// 管线:干净的形(天/水/岛塔)→ MEDIUM.broken(细长干笔,低饱和)→ 缓存;动态:云漂、水面逐行位移、船与撑篙人(小画布重绘)、鸟。
+SCENES['42_guardi'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ const HZ = 700; // 低地平线:天占 65%
+ let sky, land, water, built = false;
+ function skyPlate() {
+ const cv = P.canvas(2500, 720), g = cv.getContext('2d'), r = rng(12);
+ const gr = g.createLinearGradient(0, 0, 0, 720); gr.addColorStop(0, '#8fa3a8'); gr.addColorStop(0.55, '#b4c0bb'); gr.addColorStop(1, '#d9d2b4'); g.fillStyle = gr; g.fillRect(0, 0, 2500, 720);
+ for (let k = 0; k < 26; k++) { const x = r() * 2500, y = 30 + r() * 520, s = 0.6 + r() * 1.3; g.save(); g.filter = 'blur(12px)'; for (let j = 0; j < 7; j++) { const dx = (r() - .5) * 280 * s, dy = (r() - .5) * 40 * s, rx = (50 + r() * 80) * s, ry = (14 + r() * 18) * s;
+ g.fillStyle = `rgba(${r() < 0.5 ? '130,146,152' : '236,222,190'},${0.28 + r() * 0.25})`; g.beginPath(); g.ellipse(x + dx, y + dy, rx, ry, (r() - .5) * 0.1, 0, TAU); g.fill(); } g.restore(); }
+ return M.broken(cv, { cell: 10, len: 70, wid: 6, passes: 2, angle: (x, y) => -0.03 + Math.sin(x * 0.003 + y * 0.01) * 0.04, seed: 21, jit: 14, skip: 0.1, sat: 0.9, warm: [238, 214, 160], cool: [120, 138, 160] });
+ }
+ function landPlate() {
+ const cv = P.canvas(), g = cv.getContext('2d');
+ // 远岛(长而低)
+ g.fillStyle = '#8f8a78'; g.beginPath(); g.moveTo(0, HZ); g.lineTo(0, HZ - 16); g.quadraticCurveTo(200, HZ - 30, 420, HZ - 12); g.quadraticCurveTo(520, HZ - 8, 600, HZ); g.fill();
+ g.fillStyle = '#7d786a'; g.beginPath(); g.moveTo(1000, HZ); g.quadraticCurveTo(1120, HZ - 22, 1300, HZ - 14); g.lineTo(1500, HZ - 24); g.quadraticCurveTo(1780, HZ - 18, 1920, HZ - 34); g.lineTo(1920, HZ); g.fill();
+ // 瘦塔(右)+低屋+木桩
+ g.fillStyle = '#85735c'; g.fillRect(1480, HZ - 230, 70, 230); g.fillStyle = '#6b5a46'; g.fillRect(1480, HZ - 230, 18, 230); g.fillStyle = '#9a8670'; g.fillRect(1470, HZ - 246, 90, 18);
+ g.fillStyle = '#4a4036'; [[1492, HZ - 190], [1518, HZ - 150], [1494, HZ - 110]].forEach(([x, y]) => g.fillRect(x, y, 14, 28));
+ g.fillStyle = '#9a8670'; g.fillRect(1380, HZ - 66, 120, 66); g.fillStyle = '#7a4a3a'; g.beginPath(); g.moveTo(1370, HZ - 66); g.lineTo(1440, HZ - 100); g.lineTo(1510, HZ - 66); g.fill();
+ g.fillStyle = '#3a342e'; for (let i = 0; i < 9; i++) g.fillRect(1560 + i * 34, HZ - 12 - (i % 3) * 8, 5, 24);
+ // 左前景一角:渔人的木桩与网杆
+ g.strokeStyle = '#2e2a26'; g.lineWidth = 7; g.beginPath(); g.moveTo(150, 960); g.lineTo(190, 740); g.stroke(); g.lineWidth = 4; g.beginPath(); g.moveTo(190, 740); g.lineTo(400, 790); g.stroke(); g.beginPath(); g.moveTo(190, 760); g.quadraticCurveTo(260, 900, 400, 800); g.stroke();
+ return M.broken(cv, { cell: 7, len: 26, wid: 6, passes: 2, angle: (x, y) => y > 600 && x > 1400 ? 1.45 : 0.04, seed: 23, jit: 14, skip: 0.04, sat: 0.9 });
+ }
+ function waterPlate() {
+ const cv = P.canvas(), g = cv.getContext('2d'), r = rng(31);
+ const gr = g.createLinearGradient(0, HZ, 0, H); gr.addColorStop(0, '#b7c0b0'); gr.addColorStop(0.35, '#97a89e'); gr.addColorStop(1, '#5f7470'); g.fillStyle = gr; g.fillRect(0, HZ, W, H - HZ);
+ // 天光倒影:长条银色、暖色横带,越近越宽
+ for (let i = 0; i < 120; i++) { const k = Math.pow(r(), 1.4), y = HZ + 6 + k * (H - HZ - 10), w = 60 + r() * 300 * (0.3 + k), x = r() * W; g.fillStyle = `rgba(${r() < 0.55 ? '232,232,214' : '200,170,120'},${0.1 + r() * 0.2})`; g.fillRect(x, y, w, 2 + r() * 5 * (0.4 + k)); }
+ // 塔与岛的倒影
+ g.save(); g.translate(0, HZ * 2); g.scale(1, -1); g.globalAlpha = 0.35; g.filter = 'blur(2px)'; g.drawImage(landCanvas(), 0, 0); g.restore();
+ return M.broken(cv, { cell: 9, len: 80, wid: 5, passes: 2, angle: () => 0, seed: 25, jit: 14, skip: 0.06, sat: 0.9, cool: [100, 126, 140], warm: [230, 212, 168] });
+ }
+ let _landRaw = null; const landCanvas = () => { if (_landRaw) return _landRaw; const cv = P.canvas(), g = cv.getContext('2d'); g.fillStyle = '#6a604e'; g.fillRect(1480, HZ - 230, 70, 230); g.fillRect(1380, HZ - 66, 120, 66); g.fillRect(0, HZ - 16, 600, 16); g.fillRect(1000, HZ - 20, 920, 20); return (_landRaw = cv); };
+ function build() { sky = skyPlate(); land = landPlate(); water = waterPlate(); built = true; }
+ // 细长舢板+撑篙人:小画布(600×220)→ broken → 贴回;face 朝向
+ function gondola(c, x, y, face, t, ph, scale) {
+ const cv = P.scratch('guardi_gon'); if (cv.width !== 640) { cv.width = 640; cv.height = 260; } const g = cv.getContext('2d'); g.reset(); g.clearRect(0, 0, 640, 260);
+ g.save(); g.translate(320, 190); g.scale(face * scale, scale); const roll = Math.sin(t * 1.3 + ph) * 0.015; g.rotate(roll);
+ g.fillStyle = '#2a2622'; g.beginPath(); g.moveTo(-230, -14); g.quadraticCurveTo(-120, 12, 0, 10); g.quadraticCurveTo(130, 12, 236, -26); g.lineTo(210, -22); g.lineTo(-210, -8); g.closePath(); g.fill(); // 船身(弯月)
+ g.fillStyle = '#3a342e'; g.fillRect(-60, -46, 110, 34); g.fillStyle = '#5a2a2a'; g.fillRect(-60, -52, 110, 8); // felze 小舱
+ g.fillStyle = '#2a2622'; g.fillRect(-20, -20, 8, 12);
+ const pole = Math.sin(t * 2.0 + ph); // 撑篙人
+ g.fillStyle = '#2a2622'; g.fillRect(146, -100, 22, 84); g.beginPath(); g.arc(157, -112, 11, 0, TAU); g.fill(); g.fillStyle = '#e8e0cc'; g.fillRect(146, -94, 22, 20); g.fillStyle = '#b8402e'; g.fillRect(142, -126, 30, 8); // 黑身+白衫+红帽(几点颜色)
+ g.strokeStyle = '#2e2a26'; g.lineWidth = 4; g.lineCap = 'round'; g.beginPath(); g.moveTo(160, -88 - pole * 6); g.lineTo(120 + pole * 36, 56); g.stroke(); // 篙
+ g.restore();
+ const rep = M.broken(cv, { cell: 4, len: 13, wid: 3.2, passes: 2, angle: (xx, yy) => (yy > 150 && yy < 215) ? 0.02 : 1.2, seed: 27, jit: 12, skip: 0.02, sat: 0.95 });
+ // 倒影:被拉长压暗
+ c.save(); c.translate(x - 320, y - 190); c.save(); c.translate(0, 380); c.scale(1, -0.55); c.globalAlpha = 0.28; c.drawImage(rep, 0, 0); c.restore(); c.drawImage(rep, 0, 0); c.restore();
+ }
+ function draw(c, lt) {
+ if (!built) build();
+ const t = clamp(lt, 0, 6);
+ c.drawImage(sky, t * 14, 0, W, 720, 0, 0, W, 720);
+ c.drawImage(land, 0, 0);
+ for (let y = HZ; y < H; y += 6) { const k = (y - HZ) / (H - HZ), dx = Math.sin(t * 1.1 + y * 0.07) * (1 + k * 7) + Math.sin(t * 2.4 + y * 0.19) * 1.2 * k; c.drawImage(water, 0, y, W, 6, dx - 24, y, W + 48, 6); }
+ gondola(c, lerp(1280, 760, ss(0, 6, t)), 880, -1, t, 0.0, 1.0);
+ gondola(c, lerp(260, 680, ss(0, 6, t)), 820, 1, t, 2.1, 0.62);
+ // 鸟:几笔
+ for (let i = 0; i < 5; i++) { const u = (t * 0.06 + i * 0.19) % 1, x = lerp(-40, 1960, u), y = 220 + Math.sin(u * 9 + i) * 40 + i * 28, f = Math.sin(t * 8 + i) * 7; c.strokeStyle = 'rgba(46,42,38,.85)'; c.lineWidth = 2.6; c.lineCap = 'round'; c.beginPath(); c.moveTo(x - 12, y + f); c.quadraticCurveTo(x - 4, y - 6, x, y); c.quadraticCurveTo(x + 4, y - 6, x + 12, y + f); c.stroke(); }
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.24; c.drawImage(P.texture('canvas_guardi', '#e8e0cc', { scale: 0.006, amt: 12, grain: 7, seed: 8 }), 0, 0); c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/43_lorenzetti.js b/scripts/engine/scenes/43_lorenzetti.js
new file mode 100644
index 0000000..7e8ecdf
--- /dev/null
+++ b/scripts/engine/scenes/43_lorenzetti.js
@@ -0,0 +1,145 @@
+// 洛伦采蒂(锡耶纳市政厅《良政的效果》城市一幅):建筑占上半、一栋叠一栋,粉/灰/赭的墙,成排小窗,垛口塔;底层拱廊像舞台一样剖开露出作坊;街上是一条带状的小人,人只有楼高的十分之一,各干各的活。
+// 题材(新构图,不搬名作):广场一角——圈舞、驮骡过街、脚手架吊石头、拱廊里的鞋匠,台阶往右上走。
+// 原作锚定(fetch_reference.py:《良政的效果·城市》《良政寓言》;第三条搜索与第一条是同一幅,被去重丢弃,所以只有两幅不同作品,见 16 号协议「已知的坑」):
+// 墙 粉红 #c98f86/灰蓝 #8f98a4/赭 #b39f8c,街 沙土 #b9a37c,天只剩顶上一线群青,窗=深褐小拱,人=土红/靛蓝/芥黄/白,边带深褐。
+// 管线:干净的形层(天→后排建筑→主建筑含剖开的作坊→街→台阶)→ MEDIUM.fresco → 小人每帧画在 fresco 之后再轻糊(人太小,不过重绘)。
+SCENES['43_lorenzetti'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ let plate, built = false;
+ const GROUND = () => M.plaster('lorenz', { base: '#dccfb2', seed: 13, seams: [[[0, 420], [500, 430], [1000, 414], [1500, 426], [1920, 418]]] });
+ const quad = (g, p, fill) => { g.fillStyle = fill; g.beginPath(); p.forEach((q, i) => i ? g.lineTo(q[0], q[1]) : g.moveTo(q[0], q[1])); g.closePath(); g.fill(); };
+ const line = (g, p, col = '#5a463a', a = 0.7) => M.outline(g, p, { w: [1.6, 2.6, 1.6], col, a });
+ // 小窗(深褐拱)
+ const win = (g, x, y, w = 20, h = 34, col = '#4a3a30') => { g.fillStyle = 'rgba(255,240,215,.45)'; g.beginPath(); g.moveTo(x - 3, y + h); g.lineTo(x - 3, y + w / 2); g.arc(x + w / 2, y + w / 2, w / 2 + 3, Math.PI, 0); g.lineTo(x + w + 3, y + h); g.fill(); g.fillStyle = col; g.beginPath(); g.moveTo(x, y + h); g.lineTo(x, y + w / 2); g.arc(x + w / 2, y + w / 2, w / 2, Math.PI, 0); g.lineTo(x + w, y + h); g.fill(); };
+ function block(g, x, y, w, h, c0, c1, rows, cols, o = {}) {
+ const gr = g.createLinearGradient(x, y, x + w, y + h); gr.addColorStop(0, c0); gr.addColorStop(1, c1); g.fillStyle = gr; g.fillRect(x, y, w, h);
+ { const rr = rng((x + y) | 0); g.save(); g.filter = 'blur(10px)'; for (let i = 0; i < 26; i++) { g.fillStyle = rr() < 0.5 ? 'rgba(255,240,220,.07)' : 'rgba(70,40,40,.06)'; g.beginPath(); g.ellipse(x + rr() * w, y + rr() * h, 50 + rr() * 110, 30 + rr() * 60, (rr() - .5) * 0.5, 0, TAU); g.fill(); } g.restore();
+ g.strokeStyle = 'rgba(80,50,44,.16)'; g.lineWidth = 1.4; for (let yy = y + 20; yy < y + h; yy += 36) { g.beginPath(); g.moveTo(x, yy); g.lineTo(x + w, yy + (rr() - .5) * 3); g.stroke(); }
+ g.fillStyle = 'rgba(40,24,24,.22)'; g.fillRect(x, y + h - 14, w, 14); g.fillStyle = 'rgba(255,240,210,.35)'; g.fillRect(x, y, w, 5); }
+ if (o.side) quad(g, [[x + w, y], [x + w + o.side, y - 26], [x + w + o.side, y + h - 30], [x + w, y + h]], o.sideCol || c1);
+ for (let r = 0; r < rows; r++) for (let k = 0; k < cols; k++) win(g, x + 24 + k * ((w - 48) / cols), y + 34 + r * ((h - 90) / rows), 20, 34);
+ if (o.cren) for (let k = 0; k < Math.floor(w / 44); k++) { g.fillStyle = c0; g.fillRect(x + 6 + k * 44, y - 26, 28, 28); }
+ line(g, [[x, y + h], [x, y], [x + w, y], [x + w, y + h]]);
+ }
+ function build() {
+ plate = P.canvas(); const g = plate.getContext('2d'), r = rng(8);
+ // 天:只剩顶上一线群青
+ const sg = g.createLinearGradient(0, 0, 0, 440); sg.addColorStop(0, '#34569e'); sg.addColorStop(0.35, '#8aa2cc'); sg.addColorStop(1, '#d6cdb8'); g.fillStyle = sg; g.fillRect(0, 0, W, 440);
+ // 后排:远处的塔与屋顶,色彩略淡(空气)
+ block(g, 560, 70, 150, 470, '#a9a7ae', '#8a8890', 6, 3, { cren: true });
+ block(g, 330, 190, 250, 360, '#cfa59c', '#b88478', 4, 5);
+ block(g, 740, 150, 330, 400, '#bdb09a', '#a09078', 5, 6, { cren: true });
+ block(g, 1100, 120, 260, 430, '#c99a8f', '#a8766a', 5, 4);
+ // 屋顶瓦(后排):赭红斜面
+ [[330, 190, 250], [1100, 120, 260]].forEach(([x, y, w]) => { quad(g, [[x - 14, y], [x + 40, y - 46], [x + w - 40, y - 46], [x + w + 14, y]], '#a85a44'); line(g, [[x - 14, y], [x + 40, y - 46], [x + w - 40, y - 46], [x + w + 14, y]]); });
+ // 中景:一整排退远的低楼与城墙(填满中间,空气更淡),再往街面收
+ const far = g.createLinearGradient(0, 430, 0, 760); far.addColorStop(0, '#d6cdb8'); far.addColorStop(1, '#bfae96'); g.fillStyle = far; g.fillRect(560, 430, 800, 330);
+ block(g, 600, 400, 210, 360, '#c8a89a', '#a88a7c', 4, 4);
+ block(g, 830, 470, 250, 290, '#c2b6a2', '#a6987f', 3, 5, { cren: true });
+ block(g, 1090, 440, 170, 320, '#bd9c90', '#9c7c70', 4, 3);
+ quad(g, [[586, 400], [640, 360], [790, 360], [826, 400]], '#a85a44'); quad(g, [[1076, 440], [1110, 404], [1230, 404], [1274, 440]], '#9c503c');
+ g.fillStyle = 'rgba(70,50,40,.22)'; g.fillRect(560, 700, 800, 60); // 楼脚的暗带
+ // 主建筑左:粉红大楼,底层拱廊剖开(舞台)
+ block(g, 0, 120, 560, 640, '#d6a199', '#b87d72', 5, 6, { side: 70, sideCol: '#9c6a60', cren: true });
+ // 主建筑右:赭灰带阳台
+ block(g, 1340, 90, 580, 680, '#b7b3b6', '#8f8c94', 5, 6, { cren: true });
+ g.fillStyle = '#8a4a3c'; for (let k = 0; k < 4; k++) g.fillRect(1380 + k * 130, 330 + (k % 2) * 140, 74, 10); // 阳台
+ // 拱廊(剖开的作坊):左楼底层
+ const ax = 70, ay = 500, aw = 360, ah = 260;
+ g.fillStyle = '#3d2f28'; g.beginPath(); g.moveTo(ax, ay + ah); g.lineTo(ax, ay + 70); g.arc(ax + aw / 2, ay + 70, aw / 2, Math.PI, 0); g.lineTo(ax + aw, ay + ah); g.fill();
+ const ig = g.createLinearGradient(0, ay, 0, ay + ah); ig.addColorStop(0, '#9a7d5e'); ig.addColorStop(1, '#c4a97c'); g.fillStyle = ig;
+ g.beginPath(); g.moveTo(ax + 14, ay + ah); g.lineTo(ax + 14, ay + 70); g.arc(ax + aw / 2, ay + 70, aw / 2 - 14, Math.PI, 0); g.lineTo(ax + aw - 14, ay + ah); g.fill();
+ g.fillStyle = '#6a4a34'; g.fillRect(ax + 40, ay + 170, 150, 14); g.fillRect(ax + 50, ay + 184, 10, 76); g.fillRect(ax + 170, ay + 184, 10, 76); // 工作台
+ g.fillStyle = '#b8402e'; [[ax + 230, ay + 120], [ax + 270, ay + 140], [ax + 300, ay + 110]].forEach(([x, y]) => { g.beginPath(); g.ellipse(x, y, 16, 10, 0, 0, TAU); g.fill(); }); // 货架上的鞋
+ g.strokeStyle = '#e4cf8f'; g.lineWidth = 7; g.beginPath(); g.arc(ax + aw / 2, ay + 70, aw / 2 + 4, Math.PI, 0); g.stroke();
+ // 右楼底层:开放的柱廊+布匹
+ for (let k = 0; k < 4; k++) { const x = 1360 + k * 140; g.fillStyle = '#e1d2b4'; g.fillRect(x, 560, 26, 200); g.fillStyle = '#4a3a30'; g.beginPath(); g.moveTo(x + 26, 760); g.lineTo(x + 26, 620); g.arc(x + 83, 620, 57, Math.PI, 0); g.lineTo(x + 140, 760); g.fill(); }
+ [['#b8402e', 1400], ['#2f5d94', 1540], ['#d9b04a', 1680]].forEach(([c, x]) => { quad(g, [[x, 640], [x + 60, 640], [x + 66, 740], [x - 6, 740]], c); });
+ // 脚手架:右楼左侧一排木桩与横梁
+ g.strokeStyle = '#6a4a34'; g.lineWidth = 7; [1250, 1320].forEach(x => { g.beginPath(); g.moveTo(x, 770); g.lineTo(x, 190); g.stroke(); }); [260, 400, 540, 680].forEach(y => { g.beginPath(); g.moveTo(1240, y); g.lineTo(1330, y); g.stroke(); });
+ // 街:沙土,斜向透视,前景暗、远处亮
+ const gr = g.createLinearGradient(0, 740, 0, H); gr.addColorStop(0, '#c9b58a'); gr.addColorStop(0.6, '#b49c70'); gr.addColorStop(1, '#8c7650'); g.fillStyle = gr; g.fillRect(0, 740, W, H - 740);
+ for (let i = 0; i < 380; i++) { g.fillStyle = `rgba(${r() < 0.5 ? '90,70,44' : '224,206,158'},${0.1 + r() * 0.16})`; g.fillRect(r() * W, 760 + r() * 300, 6 + r() * 40, 2 + r() * 2); }
+ // 台阶(往右上):红砖楼梯
+ for (let k = 0; k < 7; k++) { const x = 1080 + k * 40, y = 790 - k * 18; quad(g, [[x, y], [x + 40, y], [x + 40, 800], [x, 800]], k % 2 ? '#a8645a' : '#b8786a'); line(g, [[x, y], [x + 40, y]], '#5a3a30', 0.5); }
+ quad(g, [[0, 760], [560, 760], [420, 1004], [0, 1004]], 'rgba(60,44,60,.18)'); // 左楼的影子落在街上
+ // 前景下缘的深褐边带+「题记」(一行假笔画,不写成真字)
+ g.fillStyle = '#e8dcc0'; g.fillRect(0, 1010, W, 70); g.fillStyle = '#4a3a30'; g.fillRect(0, 1004, W, 8); g.fillRect(0, 1076, W, 4);
+ for (let x = 60; x < W - 60; x += 16 + (r() * 30 | 0)) { g.fillRect(x, 1030 + (r() * 4 | 0), 6 + r() * 8, 20); }
+ built = true;
+ }
+ // 小人(修长的锡耶纳式):头小身长、长袍下摆外撇带褶、肩窄、3/4 侧、袍色左亮右暗;走路时下摆摆动、前脚探出
+ function tiny(g, x, y, s, o) {
+ const { robe = '#b8402e', hat = null, skin = '#e2b48a', face = 1, arm = 0, walk = 0, hair = '#4a3322', under = null, carry = null } = o;
+ s *= 0.95;
+ const dk = M.css(M.mix(robe, '#1c1428', 0.38)), lt = M.css(M.mix(robe, '#fff4dc', 0.3)), mid = M.css(robe);
+ g.fillStyle = 'rgba(60,40,24,.26)'; g.beginPath(); g.ellipse(x, y + 2, 21 * s, 5 * s, 0, 0, TAU); g.fill();
+ g.save(); g.translate(x, y); g.scale(s * face, s);
+ const sw = Math.sin(walk), bob = Math.abs(sw) * 1.6, H0 = -104 - bob;
+ // 前脚探出下摆
+ g.fillStyle = '#3d2a24'; g.beginPath(); g.ellipse(7 + sw * 7, -2, 7, 3.2, 0, 0, TAU); g.ellipse(-6 - sw * 7, -2, 7, 3.2, 0, 0, TAU); g.fill();
+ // 袍:窄肩 → 腰 → 外撇下摆,下摆随步子左右摆
+ const hem = 18, fl = sw * 4;
+ const gr = g.createLinearGradient(-hem, 0, hem, 0); gr.addColorStop(0, lt); gr.addColorStop(0.45, mid); gr.addColorStop(1, dk); g.fillStyle = gr;
+ g.beginPath(); g.moveTo(-8, H0 + 22); g.quadraticCurveTo(-10, -62, -13 + fl * 0.3, -34); g.quadraticCurveTo(-hem - 2 + fl, -14, -hem + fl, -4);
+ g.quadraticCurveTo(0, 2, hem + fl, -4); g.quadraticCurveTo(hem - 1 + fl, -16, 12 + fl * 0.3, -34); g.quadraticCurveTo(10, -62, 8, H0 + 22); g.closePath(); g.fill();
+ // 褶:三条自上而下的弧线,下摆处加深
+ g.strokeStyle = dk; g.globalAlpha = 0.5; g.lineWidth = 1.6; g.lineCap = 'round';
+ [[-4, -2], [2, 4], [8, 9]].forEach(([u, v]) => { g.beginPath(); g.moveTo(u * 0.5, -66); g.quadraticCurveTo(u + v * 0.3, -36, u * 1.8 + fl, -5); g.stroke(); }); g.globalAlpha = 1;
+ // 腰带+下摆镶边
+ g.fillStyle = 'rgba(30,20,20,.35)'; g.fillRect(-10, -66, 20, 3.5);
+ g.strokeStyle = under || lt; g.lineWidth = 2.2; g.beginPath(); g.moveTo(-hem + fl, -4); g.quadraticCurveTo(0, 2, hem + fl, -4); g.stroke();
+ // 袖与手:上臂沿身侧,前臂随 arm 抬起(拉手/持物)
+ const ax = 9, ay = H0 + 26, ex = 13 + arm * 7, ey = -64 + arm * 8, hx = 14 + arm * 11, hy = -52 - arm * 22;
+ g.strokeStyle = mid; g.lineWidth = 6.5; g.beginPath(); g.moveTo(-ax, ay); g.lineTo(-ex, ey); g.lineTo(-hx, hy); g.moveTo(ax, ay); g.lineTo(ex, ey); g.lineTo(hx, hy); g.stroke();
+ g.fillStyle = skin; g.beginPath(); g.arc(-hx, hy, 3, 0, TAU); g.arc(hx, hy, 3, 0, TAU); g.fill();
+ // 颈、头(小,3/4:脸偏一侧,耳后一团头发)
+ g.fillStyle = skin; g.fillRect(-2.6, H0 + 12, 5.2, 7);
+ g.beginPath(); g.ellipse(0.8, H0 + 5, 6.4, 7.6, 0, 0, TAU); g.fill();
+ g.fillStyle = 'rgba(120,60,40,.25)'; g.beginPath(); g.ellipse(-2.8, H0 + 5, 3.2, 6.8, 0, 0, TAU); g.fill();
+ g.fillStyle = hair; g.beginPath(); g.ellipse(-2.4, H0 + 1.5, 6.2, 6.4, 0, Math.PI * 0.55, Math.PI * 1.9); g.fill();
+ g.fillStyle = '#3a2a22'; g.fillRect(3.6, H0 + 4, 1.8, 1.8);
+ if (hat) { g.fillStyle = M.css(hat); g.beginPath(); g.ellipse(-0.6, H0 - 1.5, 7.8, 4.2, 0, Math.PI, TAU); g.fill(); g.fillRect(-7.4, H0 - 3, 14.6, 3); g.fillStyle = 'rgba(0,0,0,.2)'; g.fillRect(-7.4, H0 - 0.5, 14.6, 1.6); }
+ if (carry) { g.fillStyle = carry; g.beginPath(); g.ellipse(hx + 6, hy - 6, 9, 7, 0, 0, TAU); g.fill(); }
+ g.restore();
+ }
+ const COL = [['#b8402e', null], ['#2f5d94', '#2f5d94'], ['#d9b04a', null], ['#f1ead6', '#b8402e'], ['#6e8a52', null], ['#8c3d5a', '#8c3d5a']];
+ function draw(c, lt) {
+ if (!built) build();
+ const t = clamp(lt, 0, 6);
+ const live = P.scratch('lorenz_live'), g = live.getContext('2d'); g.reset(); g.drawImage(plate, 0, 0);
+ // 圈舞:六人绕椭圆,彼此牵手,前后按 y 排序
+ const cx = 760, cy = 850, rx = 150, ry = 36, rot = t * 0.9, ring = [];
+ for (let i = 0; i < 6; i++) { const a = rot + i / 6 * TAU; ring.push({ x: cx + Math.cos(a) * rx, y: cy + Math.sin(a) * ry, i, a }); }
+ g.strokeStyle = '#3d2f28'; g.lineWidth = 3; g.beginPath(); ring.slice().sort((a, b) => a.i - b.i).forEach((p, k, arr) => { const q = arr[(k + 1) % 6]; g.moveTo(p.x, p.y - 44); g.lineTo(q.x, q.y - 44); }); g.stroke();
+ ring.sort((p, q) => p.y - q.y).forEach(p => { tiny(g, p.x, p.y, 1.15, { robe: COL[p.i][0], hat: COL[p.i][1], face: Math.sin(p.a) > 0 ? 1 : -1, arm: 0.5 + Math.sin(t * 4 + p.i) * 0.12, walk: t * 6 + p.i }); });
+ // 满街人流:十几个行人,各自按自己的速度和方向在街上走(循环),按 y 近大远小;两三人一伙并肩,一人带货
+ const WALK = [[0,830,.07,'#b8402e','#2f5d94'],[0,842,.07,'#f1ead6',null],[0,990,.05,'#2f5d94',null],[0,1002,.05,'#8c3d5a','#b8402e'],[0,880,.04,'#6e8a52','#d9b04a'],
+ [1,900,.045,'#d9b04a',null],[1,914,.045,'#b8402e','#2f5d94'],[1,928,.045,'#6e8a52','#8c3d5a'],[0,950,.06,'#f1ead6','#8c3d5a'],[0,800,.035,'#2f5d94','#b8402e'],[1,812,.035,'#d9b04a',null],[1,972,.055,'#6e8a52',null],[0,860,.03,'#8c3d5a',null],
+ [1,820,.04,'#b8402e',null],[1,834,.04,'#f1ead6','#2f5d94'],[0,918,.05,'#2f5d94','#d9b04a'],[0,932,.05,'#d9b04a',null],[1,1000,.03,'#8c3d5a','#2f5d94'],[0,792,.05,'#6e8a52',null],[1,968,.06,'#b8402e','#8c3d5a']];
+ const people = WALK.map((w, i) => { const dir = w[0] ? -1 : 1, u = ((i * 0.137 + t * w[2] * dir) % 1 + 1) % 1; return { x: -60 + u * 2040, y: w[1], s: 0.82 + (w[1] - 790) / 400, dir, c: w[3], h: w[4], ph: t * 6 * (0.6 + w[2] * 8) + i * 1.9, i }; });
+ people.sort((a, b) => a.y - b.y).forEach(q => { if (q.x > 1040 && q.x < 1400 && q.y < 830) return; if (Math.abs(q.x - cx) < rx + 60 && Math.abs(q.y - cy) < ry + 70) return; tiny(g, q.x, q.y, q.s, { robe: q.c, hat: q.h, face: q.dir, walk: q.ph, arm: 0.1, carry: q.i % 5 === 2 ? '#d6c79a' : null }); });
+ // 驮骡过街:左→右,驮两只麻袋,驭者在前
+ const mu = lerp(-300, 1900, ss(0, 6, t)), my = 1002;
+ g.save(); g.translate(mu, my); g.scale(0.85, 0.85); g.fillStyle = '#7a6a5a'; g.beginPath(); g.ellipse(0, -54, 70, 30, 0, 0, TAU); g.fill(); g.fillRect(48, -86, 30, 40); g.beginPath(); g.ellipse(86, -86, 22, 14, -0.3, 0, TAU); g.fill();
+ for (let l = 0; l < 4; l++) { const sw = Math.sin(t * 7 + l * 1.6) * 6; g.fillRect(-50 + l * 32 + sw * (l % 2 ? 1 : -1), -30, 10, 34); }
+ g.fillStyle = '#d6c79a'; g.beginPath(); g.ellipse(-20, -90, 30, 24, 0, 0, TAU); g.ellipse(26, -92, 28, 22, 0, 0, TAU); g.fill(); g.restore();
+ tiny(g, mu + 150, my + 6, 1.3, { robe: '#d9b04a', hat: '#2f5d94', walk: t * 7 });
+ // 作坊里的鞋匠:槌起槌落
+ const hm = Math.abs(Math.sin(t * 6));
+ tiny(g, 190, 688, 1.7, { robe: '#2f5d94', hat: '#b8402e', arm: 0.2 + hm * 0.8 });
+ g.strokeStyle = '#4a3a30'; g.lineWidth = 5; g.beginPath(); g.moveTo(224, 646 - hm * 22); g.lineTo(246, 622 - hm * 30); g.stroke();
+ // 脚手架:吊石头(绳从顶梁下来),上面一人拉绳
+ const up = ss(0.4, 5.6, t), sy = lerp(740, 330, up);
+ g.strokeStyle = '#6a4a34'; g.lineWidth = 3; g.beginPath(); g.moveTo(1285, 260); g.lineTo(1285, sy - 8); g.stroke();
+ g.fillStyle = '#9a9488'; g.beginPath(); g.moveTo(1262, sy); g.lineTo(1308, sy); g.lineTo(1304, sy + 36); g.lineTo(1266, sy + 38); g.closePath(); g.fill();
+ tiny(g, 1290, 262, 1.3, { robe: '#d9b04a', hat: '#8c3d5a', arm: 0.6 + Math.sin(t * 5) * 0.2, face: -1 });
+ tiny(g, 1180, 786, 1.5, { robe: '#b8402e', hat: '#2f5d94', arm: 0.5 + Math.sin(t * 5) * 0.25 }); // 地面拉绳的人
+ // 台阶上下几个行人
+ [[1130, 744, '#6e8a52'], [1250, 672, '#f1ead6']].forEach(([x, y, col], i) => tiny(g, x + Math.sin(t * 0.8 + i) * 8, y, 1.4, { robe: col, hat: i ? '#b8402e' : null, walk: t * 5 + i, face: -1 }));
+ // 塔顶小旗
+ g.fillStyle = '#b8402e'; g.beginPath(); g.moveTo(635, 38); g.lineTo(700 + Math.sin(t * 5) * 6, 52); g.lineTo(635, 70); g.fill(); g.strokeStyle = '#4a3a30'; g.lineWidth = 3; g.beginPath(); g.moveTo(635, 30); g.lineTo(635, 80); g.stroke();
+ M.fresco(c, live, { ground: GROUND(), chalk: 0.06, soften: 0.6, plasterAlpha: 0.5, sat: 1.1 });
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/44_cortona.js b/scripts/engine/scenes/44_cortona.js
new file mode 100644
index 0000000..96dff0b
--- /dev/null
+++ b/scripts/engine/scenes/44_cortona.js
@@ -0,0 +1,86 @@
+// 科尔托纳(巴洛克天顶,巴贝里尼宫《神意的寓言》):画出来的灰泥框和镀金圆章把天顶「打开」,中间是一片从中心往外发暖金光的天;云团堆成体积,人群绕着中心旋转,身体、衣带和云都漫出框外。
+// 题材(新构图,不搬名作):一个仰视的天顶——灰泥画框里的天空开口,一圈人在云上绕着光旋转,红蓝衣带随风绕过画框。
+// 原作锚定(fetch_reference.py:《神意的寓言》天顶、《劫掠萨宾妇女》;第三条搜索与第一条同幅被丢弃,只有两幅不同原作):
+// 框=象牙灰泥 #e4d8be+镀金 #c89a3c+深棕阴影、角上金圆章;天=中心 #fff0c0 → #e8c07a → 边缘群青 #3a4a82;云内亮外暗;袍色猩红 #b83a3a、群青 #3a5ea8、赭 #c89a4a;对角线运动。
+// 管线:形层(暗背景→画框灰泥带+角圆章+蛋形纹→开口天空渐变与光芒→云团)→ 人群与衣带(旋转,漫出框)→ MEDIUM.fresco(轻糊、灰泥颗粒)→ 中心光再叠一层加法光。
+SCENES['44_cortona'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ const CX = 960, CY = 540, RX = 560, RY = 300;
+ const ROB = { red: ['#f08a7c', '#b83a3a', '#6a1c26'], blue: ['#9ab4ea', '#3a5ea8', '#1c2f62'], ochre: ['#f2d896', '#c89a4a', '#7a5a22'], white: ['#fffaf0', '#e8dcc0', '#a89868'], green: ['#a8d0a0', '#5a8a64', '#2c4a3a'], rose: ['#f6c0c0', '#d27a86', '#8a3a4a'] };
+ let plate, built = false;
+ const rr = (g, x, y, w, h, r) => { g.beginPath(); g.moveTo(x + r, y); g.arcTo(x + w, y, x + w, y + h, r); g.arcTo(x + w, y + h, x, y + h, r); g.arcTo(x, y + h, x, y, r); g.arcTo(x, y, x + w, y, r); g.closePath(); };
+ function cloud(g, x, y, r, seed) { // 云团:一个整体的凹凸轮廓,沿朝向中心的方向打光(内亮外暗),外侧弧线勾出团块
+ const rn = rng(seed), dx = CX - x, dy = CY - y, d = Math.hypot(dx, dy) || 1, ux = dx / d, uy = dy / d, cs = [];
+ for (let i = 0; i < 8; i++) cs.push([x + (rn() - .5) * r * 2.0, y + (rn() - .5) * r * 0.9, r * (0.34 + rn() * 0.34)]);
+ const path = new Path2D(); cs.forEach(([px, py, rad]) => { path.moveTo(px + rad, py); path.arc(px, py, rad, 0, TAU); });
+ g.save(); g.clip(path);
+ const gr = g.createLinearGradient(x - ux * r * 1.4, y - uy * r * 1.4, x + ux * r * 1.4, y + uy * r * 1.4); gr.addColorStop(0, '#6e6890'); gr.addColorStop(0.35, '#c3a6a2'); gr.addColorStop(0.7, '#f0cc98'); gr.addColorStop(1, '#fff3d0');
+ g.fillStyle = gr; g.fillRect(x - r * 2.4, y - r * 2, r * 4.8, r * 4);
+ cs.forEach(([px, py, rad]) => { g.strokeStyle = 'rgba(86,76,120,.3)'; g.lineWidth = Math.max(4, rad * 0.14); g.beginPath(); g.arc(px, py, rad * 0.92, Math.atan2(-uy, -ux) - 1.0, Math.atan2(-uy, -ux) + 1.0); g.stroke();
+ g.strokeStyle = 'rgba(255,248,222,.4)'; g.lineWidth = Math.max(3, rad * 0.08); g.beginPath(); g.arc(px, py, rad * 0.9, Math.atan2(uy, ux) - 0.8, Math.atan2(uy, ux) + 0.8); g.stroke(); });
+ g.restore();
+ }
+ function build() {
+ plate = P.canvas(); const g = plate.getContext('2d'), rn = rng(4);
+ g.fillStyle = '#2a1e1c'; g.fillRect(0, 0, W, H);
+ // 开口天空:中心暖金 → 边缘群青,加放射光
+ const ix = 190, iy = 118, iw = 1540, ih = 844, ir = 150;
+ g.save(); rr(g, ix, iy, iw, ih, ir); g.clip();
+ const sg = g.createRadialGradient(CX, CY - 20, 20, CX, CY, 900); sg.addColorStop(0, '#fff6d0'); sg.addColorStop(0.22, '#f4d58e'); sg.addColorStop(0.5, '#c2a0a0'); sg.addColorStop(0.8, '#5a669a'); sg.addColorStop(1, '#2c3a72'); g.fillStyle = sg; g.fillRect(0, 0, W, H);
+ g.globalCompositeOperation = 'screen'; for (let i = 0; i < 28; i++) { const a = i / 28 * TAU, w = 0.04 + (i % 3) * 0.02; g.fillStyle = 'rgba(255,238,190,.09)'; g.beginPath(); g.moveTo(CX, CY); g.lineTo(CX + Math.cos(a - w) * 1100, CY + Math.sin(a - w) * 1100); g.lineTo(CX + Math.cos(a + w) * 1100, CY + Math.sin(a + w) * 1100); g.closePath(); g.fill(); } g.globalCompositeOperation = 'source-over';
+ // 环绕的云团
+ for (let i = 0; i < 16; i++) { const a = i / 16 * TAU + rn() * 0.2, k = 0.9 + rn() * 0.2; cloud(g, CX + Math.cos(a) * RX * k * 1.05, CY + Math.sin(a) * RY * k * 1.12, 90 + rn() * 70, 40 + i); }
+ for (let i = 0; i < 4; i++) { const a = i / 4 * TAU + 0.4; cloud(g, CX + Math.cos(a) * 250, CY + Math.sin(a) * 130, 60 + rn() * 30, 90 + i); }
+ g.restore();
+ // 画框:三层灰泥带,向内一层比一层亮,外层有深色阴影缝;内缘金线;蛋形纹
+ const bands = [[0, '#9c8a6e'], [34, '#e4d8be'], [74, '#cbbd9c'], [112, '#f0e6cc'], [140, '#c89a3c']];
+ bands.forEach(([off, col], k) => { g.fillStyle = col; rr(g, ix - 150 + off, iy - 100 + off * 0.65, iw + 300 - off * 2, ih + 200 - off * 1.3, ir + 150 - off); g.fill(); });
+ g.save(); rr(g, ix, iy, iw, ih, ir); g.clip(); g.fillStyle = 'rgba(0,0,0,.12)'; g.fillRect(0, 0, W, H); g.restore();
+ g.globalCompositeOperation = 'destination-over'; g.globalCompositeOperation = 'source-over';
+ // 重画天空开口(帧压住了),保证「开口」在帧之上
+ g.save(); rr(g, ix, iy, iw, ih, ir); g.clip(); g.drawImage(skyOnly(), 0, 0); g.restore();
+ g.strokeStyle = '#c89a3c'; g.lineWidth = 12; rr(g, ix, iy, iw, ih, ir); g.stroke(); g.strokeStyle = 'rgba(60,40,20,.5)'; g.lineWidth = 4; rr(g, ix - 8, iy - 8, iw + 16, ih + 16, ir + 8); g.stroke();
+ // 蛋形纹沿框走
+ g.fillStyle = '#f6eed8'; for (let i = 0; i < 70; i++) { const q = i / 70, th = q * TAU, x = CX + Math.cos(th) * (iw / 2 + 52), y = CY + Math.sin(th) * (ih / 2 + 52); g.save(); g.translate(x, y); g.rotate(th + Math.PI / 2); g.beginPath(); g.ellipse(0, 0, 6, 11, 0, 0, TAU); g.fill(); g.strokeStyle = 'rgba(120,96,60,.6)'; g.lineWidth = 1.6; g.stroke(); g.restore(); }
+ // 四角金圆章
+ [[ix - 20, iy - 14], [ix + iw + 20, iy - 14], [ix - 20, iy + ih + 14], [ix + iw + 20, iy + ih + 14]].forEach(([x, y]) => { const gr = g.createRadialGradient(x - 14, y - 14, 4, x, y, 76); gr.addColorStop(0, '#fff0b8'); gr.addColorStop(0.5, '#d0a040'); gr.addColorStop(1, '#7a5a1c'); g.fillStyle = gr; g.beginPath(); g.arc(x, y, 76, 0, TAU); g.fill(); g.strokeStyle = '#f6eed8'; g.lineWidth = 9; g.stroke(); g.strokeStyle = 'rgba(80,50,20,.7)'; g.lineWidth = 3; g.beginPath(); g.arc(x, y, 50, 0, TAU); g.stroke(); });
+ // 外缘最深的阴影,把画框「压」进天顶
+ const vg = g.createRadialGradient(CX, CY, 600, CX, CY, 1150); vg.addColorStop(0, 'rgba(30,20,20,0)'); vg.addColorStop(1, 'rgba(30,20,20,.55)'); g.fillStyle = vg; g.fillRect(0, 0, W, H);
+ built = true;
+ }
+ let _sky = null; function skyOnly() { if (_sky) return _sky; const cv = P.canvas(), g = cv.getContext('2d'), rn = rng(4);
+ const sg = g.createRadialGradient(CX, CY - 20, 20, CX, CY, 900); sg.addColorStop(0, '#fff6d0'); sg.addColorStop(0.22, '#f4d58e'); sg.addColorStop(0.5, '#c2a0a0'); sg.addColorStop(0.8, '#5a669a'); sg.addColorStop(1, '#2c3a72'); g.fillStyle = sg; g.fillRect(0, 0, W, H);
+ g.globalCompositeOperation = 'screen'; for (let i = 0; i < 28; i++) { const a = i / 28 * TAU, w = 0.04 + (i % 3) * 0.02; g.fillStyle = 'rgba(255,238,190,.09)'; g.beginPath(); g.moveTo(CX, CY); g.lineTo(CX + Math.cos(a - w) * 1100, CY + Math.sin(a - w) * 1100); g.lineTo(CX + Math.cos(a + w) * 1100, CY + Math.sin(a + w) * 1100); g.closePath(); g.fill(); } g.globalCompositeOperation = 'source-over';
+ for (let i = 0; i < 16; i++) { const a = i / 16 * TAU + rn() * 0.2, k = 0.9 + rn() * 0.2; cloud(g, CX + Math.cos(a) * RX * k * 1.05, CY + Math.sin(a) * RY * k * 1.12, 90 + rn() * 70, 40 + i); }
+ for (let i = 0; i < 4; i++) { const a = i / 4 * TAU + 0.4; cloud(g, CX + Math.cos(a) * 250, CY + Math.sin(a) * 130, 60 + rn() * 30, 90 + i); }
+ return (_sky = cv); }
+ // 衣带:沿螺旋线的一条绸,宽度起伏、两面深浅不同
+ function ribbon(g, t, ph, col, R0, dir) {
+ const N = 60, L = [], Rr = [];
+ for (let i = 0; i <= N; i++) { const q = i / N, a = ph + dir * (t * 0.35 + q * 2.4), r = lerp(0.55, 1.05, q + Math.sin(q * 6 + t) * 0.05), x = CX + Math.cos(a) * RX * r * R0, y = CY + Math.sin(a) * RY * r * R0, w = 46 * Math.sin(q * Math.PI) * (0.6 + 0.4 * Math.cos(q * 9 + t * 2));
+ const nl = Math.hypot(Math.cos(a) * RY, Math.sin(a) * RX) || 1, nx = Math.cos(a) * RY / nl, ny = Math.sin(a) * RX / nl; L.push([x + nx * w, y + ny * w]); Rr.push([x - nx * w, y - ny * w]); }
+ g.fillStyle = col[1]; g.beginPath(); L.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); Rr.reverse().forEach(p => g.lineTo(p[0], p[1])); g.closePath(); g.fill();
+ g.strokeStyle = col[0]; g.lineWidth = 3; g.beginPath(); L.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.stroke();
+ }
+ function draw(c, lt) {
+ if (!built) build();
+ const t = clamp(lt, 0, 6);
+ const live = P.scratch('cort_live'), g = live.getContext('2d'); g.reset(); g.drawImage(plate, 0, 0);
+ ribbon(g, t, 0.5, ROB.red, 0.95, 1); ribbon(g, t, 3.4, ROB.blue, 0.82, 1);
+ // 人群:绕中心旋转,头朝外(徐徐翻转),手臂举向光;半数漫出画框
+ const FIG = [['red', 'ochre', 0.0, 260, 1], ['blue', 'rose', 0.7, 240, -1], ['white', 'blue', 1.4, 250, 1], ['ochre', 'red', 2.1, 230, -1], ['green', 'white', 2.8, 255, 1], ['rose', 'blue', 3.5, 235, -1], ['blue', 'ochre', 4.2, 245, 1], ['red', 'green', 4.9, 240, -1], ['white', 'rose', 5.6, 250, 1]];
+ FIG.forEach(([rb, mt, a0, h, face], i) => {
+ const a = a0 + t * 0.22, k = 0.92 + 0.12 * Math.sin(a0 * 2.1), x = CX + Math.cos(a) * RX * k * 1.04, y = CY + Math.sin(a) * RY * k * 1.1, rot = a + Math.PI / 2 + 0.5 * Math.sin(t * 0.8 + i);
+ g.save(); g.translate(x, y); g.rotate(rot + Math.PI); const sz = h * (0.78 + 0.22 * ((Math.sin(a) + 1) / 2));
+ M.figure(g, { x: 0, y: sz * 0.5, h: sz, face, lean: 0.12 * Math.sin(t * 1.3 + i), bow: 0.1, t, seed: 60 + i, halo: false, robe: ROB[rb], mantle: ROB[mt], under: '#f6ecd0', skin: '#e6b48a', hair: '#5b3a22', sway: 0.9,
+ gaze: [0, -sz * 0.9], hands: [[-sz * 0.34 * face, -sz * 0.34 + Math.sin(t * 2 + i) * 8], [sz * 0.3 * face, -sz * 0.18]] });
+ g.restore();
+ });
+ // 中心:金色圆光里一位白衣者(最亮),光晕呼吸
+ const br = 0.5 + 0.5 * Math.sin(t * 1.6), cg = g.createRadialGradient(CX, CY, 10, CX, CY, 220 + br * 30); cg.addColorStop(0, 'rgba(255,248,214,.95)'); cg.addColorStop(1, 'rgba(255,230,160,0)'); g.fillStyle = cg; g.beginPath(); g.arc(CX, CY, 260, 0, TAU); g.fill();
+ g.save(); g.translate(CX, CY + 10); g.rotate(Math.sin(t * 0.5) * 0.1); M.figure(g, { x: 0, y: 120, h: 240, face: 1, lean: 0.04, t, seed: 99, halo: true, robe: ROB.white, mantle: ROB.ochre, under: '#fffaf0', skin: '#f0c49a', hair: '#8a5a2a', sway: 0.8, gaze: [0, -150], hands: [[-70, -26], [70, -26]] }); g.restore();
+ M.fresco(c, live, { ground: M.plaster('cortona', { base: '#d8c8a8', seed: 17 }), chalk: 0.03, soften: 0.4, plasterAlpha: 0.32, sat: 1.12 });
+ c.save(); c.globalCompositeOperation = 'screen'; const hg = c.createRadialGradient(CX, CY, 0, CX, CY, 520); hg.addColorStop(0, `rgba(255,236,180,${0.28 + br * 0.1})`); hg.addColorStop(1, 'rgba(255,220,150,0)'); c.fillStyle = hg; c.fillRect(0, 0, W, H); c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/45_renoir.js b/scripts/engine/scenes/45_renoir.js
new file mode 100644
index 0000000..20dace3
--- /dev/null
+++ b/scripts/engine/scenes/45_renoir.js
@@ -0,0 +1,86 @@
+// 雷诺阿(印象派,人间的光):树叶筛下的斑驳光——暖黄的亮斑、蓝紫的影;人都是一团团粉彩的色点,脸颊泛红,边缘融进周围;没有黑线,黑色衣服也是深蓝紫。
+// 题材(新构图):午后树下的露天舞场,近处一对舞者旋转,中景桌边人群说笑,光斑缓缓挪动。
+// 原作锚定(风格,非原画):亮斑 #f6e4a0/影 #6f78b8、肤色暖粉 #eab090 带红晕、衣料粉蓝白 #e8c8d0 #a8b8dc #f4f0e4、黑衣=#2c3050、草帽黄 #e6c070、地面碎笔多向;所有边缘被光吃掉。
+// 管线:静底(树冠+地+远景人群+桌)→ MEDIUM.broken → 缓存;光斑层(暖亮/冷影软笔)单独 broken 缓存、两份错位叠加做摇曳;近景舞者每帧小画布重绘;中景人群每个轻微摇摆(小画布)。
+SCENES['45_renoir'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ let base, crowdLayer, lightA, lightB, built = false;
+ // 一个人(色点化):x,y 脚底;s 比例。女:窄肩、收腰、钟形长裙、小头戴帽;男:深蓝紫礼服、礼帽。reach=[dx,dy] 局部坐标,指定一只手去哪(相拥舞)
+ function person(g, x, y, s, o) {
+ const { dress = '#e8c8d0', trim = '#f4f0e4', hat = null, skin = '#eab090', lean = 0, arms = 0, dark = false, hair = '#8a5a3a', reach = null } = o;
+ g.save(); g.translate(x, y); g.scale(s, s); g.rotate(lean);
+ const body = dark ? '#2c3050' : dress, lit = dark ? '#4a4f82' : trim, sh = dark ? '#1c1f38' : 'rgba(110,100,150,.45)';
+ // 裙/下装:女=钟形长裙(左亮右影),男=直筒裤袍
+ if (dark) { g.fillStyle = body; g.beginPath(); g.moveTo(-15, -72); g.lineTo(-17, -4); g.lineTo(-3, -4); g.lineTo(0, -34); g.lineTo(3, -4); g.lineTo(17, -4); g.lineTo(15, -72); g.closePath(); g.fill();
+ g.fillStyle = body; g.beginPath(); g.moveTo(-15, -108); g.quadraticCurveTo(-21, -96, -17, -52); g.lineTo(17, -52); g.quadraticCurveTo(21, -96, 15, -108); g.closePath(); g.fill(); g.fillStyle = lit; g.globalAlpha = 0.5; g.fillRect(-15, -108, 6, 54); g.globalAlpha = 1;
+ g.fillStyle = '#e8e0ea'; g.beginPath(); g.moveTo(-4, -108); g.lineTo(4, -108); g.lineTo(1, -80); g.closePath(); g.fill(); }
+ else { const gr = g.createLinearGradient(-40, 0, 40, 0); gr.addColorStop(0, trim); gr.addColorStop(0.4, body); gr.addColorStop(1, sh);
+ g.fillStyle = gr; g.beginPath(); g.moveTo(-10, -104); g.quadraticCurveTo(-13, -84, -9, -68); g.quadraticCurveTo(-34, -34, -44, -3); g.quadraticCurveTo(0, 6, 44, -3); g.quadraticCurveTo(34, -34, 9, -68); g.quadraticCurveTo(13, -84, 10, -104); g.closePath(); g.fill();
+ g.strokeStyle = sh; g.lineWidth = 3; g.globalAlpha = 0.5; [[-10, -22], [6, -20], [20, -18]].forEach(([u, v]) => { g.beginPath(); g.moveTo(u * 0.3, -66); g.quadraticCurveTo(u + 4, -36, u * 1.7 + 4, v); g.stroke(); }); g.globalAlpha = 1;
+ g.fillStyle = trim; g.fillRect(-10, -72, 20, 5); g.fillStyle = '#c85a6a'; g.fillRect(-10, -70, 20, 2); }
+ // 手臂:上臂下垂,前臂抬到 arms 指定高度;reach 时一只手伸向目标
+ const sl = dark ? body : (dress), hx = 20 + arms * 12, hy = -70 - arms * 18;
+ g.strokeStyle = sl; g.lineCap = 'round'; g.lineWidth = 8; g.beginPath(); g.moveTo(-10, -100); g.lineTo(-20 - arms * 4, -80); g.lineTo(-hx, hy);
+ if (reach) { g.moveTo(10, -100); g.lineTo(22, -84); g.lineTo(reach[0], reach[1]); } else { g.moveTo(10, -100); g.lineTo(20 + arms * 4, -80); g.lineTo(hx, hy); } g.stroke();
+ g.fillStyle = skin; g.beginPath(); g.arc(-hx, hy, 4.2, 0, TAU); g.arc(reach ? reach[0] : hx, reach ? reach[1] : hy, 4.2, 0, TAU); g.fill();
+ // 颈、头(小)、脸颊红晕、发
+ g.fillStyle = skin; g.fillRect(-3.4, -117, 6.8, 11); g.beginPath(); g.ellipse(0, -126, 9.4, 11, 0, 0, TAU); g.fill();
+ g.fillStyle = 'rgba(214,90,84,.38)'; g.beginPath(); g.arc(4.5, -122, 4.4, 0, TAU); g.fill();
+ g.fillStyle = hair; g.beginPath(); g.ellipse(-1.5, -130, 9.6, 8, 0, Math.PI * 0.95, Math.PI * 2.05); g.fill(); if (!dark) { g.beginPath(); g.arc(-8, -122, 5, 0, TAU); g.fill(); }
+ g.fillStyle = '#3a2a30'; g.fillRect(4, -127, 1.8, 1.8); g.fillStyle = '#b05a54'; g.fillRect(3, -120, 4.2, 1.4);
+ if (hat === 'straw') { g.fillStyle = '#e6c070'; g.beginPath(); g.ellipse(0, -136, 21, 5.6, 0, 0, TAU); g.fill(); g.beginPath(); g.ellipse(0, -140, 11, 8, 0, Math.PI, TAU); g.fill(); g.fillStyle = '#c85a6a'; g.fillRect(-11, -140, 22, 3.4); }
+ else if (hat === 'top') { g.fillStyle = '#2c3050'; g.fillRect(-9, -153, 18, 19); g.fillRect(-14, -136, 28, 3.6); }
+ g.restore();
+ }
+ function basePlate() {
+ const cv = P.canvas(), g = cv.getContext('2d'), r = rng(5);
+ // 天光漏口+树冠:大片深绿蓝影+暖绿
+ g.fillStyle = '#9db8a0'; g.fillRect(0, 0, W, H);
+ const gr = g.createLinearGradient(0, 0, 0, 460); gr.addColorStop(0, '#5f7f6a'); gr.addColorStop(1, '#a8b890'); g.fillStyle = gr; g.fillRect(0, 0, W, 460);
+ for (let i = 0; i < 160; i++) { const x = r() * W, y = r() * 420, rx = 70 + r() * 150, ry = 40 + r() * 80; g.fillStyle = r() < 0.5 ? 'rgba(54,86,70,.55)' : r() < 0.7 ? 'rgba(170,196,120,.5)' : 'rgba(236,224,150,.4)'; g.beginPath(); g.ellipse(x, y, rx, ry, r(), 0, TAU); g.fill(); }
+ for (let i = 0; i < 40; i++) { const x = r() * W, y = r() * 330, rx = 12 + r() * 34, ry = 8 + r() * 20; g.fillStyle = 'rgba(190,214,236,.8)'; g.beginPath(); g.ellipse(x, y, rx, ry, r(), 0, TAU); g.fill(); } // 叶隙里透出的天
+ // 树干
+ [[260, 470, 70], [1060, 450, 60], [1700, 470, 80]].forEach(([x, y, w]) => { const tg = g.createLinearGradient(x - w, 0, x + w, 0); tg.addColorStop(0, '#6f6a8a'); tg.addColorStop(0.5, '#a89a8a'); tg.addColorStop(1, '#5c5878'); g.fillStyle = tg; g.fillRect(x - w / 2, 0, w, y + 80); });
+ // 地:沙土色,明暗斑
+ const ggr = g.createLinearGradient(0, 470, 0, H); ggr.addColorStop(0, '#c8b890'); ggr.addColorStop(1, '#b0a07c'); g.fillStyle = ggr; g.fillRect(0, 470, W, H - 470);
+ // 桌与远景人群(色点人)
+ const T = (x, y, w) => { g.fillStyle = '#e8e0d0'; g.beginPath(); g.ellipse(x, y, w, w * 0.22, 0, 0, TAU); g.fill(); g.fillStyle = '#a89a8a'; g.fillRect(x - 3, y, 6, w * 0.5); };
+ [[560, 640, 120], [1180, 620, 110], [1480, 700, 130], [820, 560, 90]].forEach(([x, y, w]) => T(x, y, w));
+ const cv2 = P.canvas(), g2 = cv2.getContext('2d');
+ const crowd = [[430, 640, 0.9, '#a8b8dc', 'straw'], [520, 676, 0.95, '#e8c8d0', null], [620, 650, 0.9, '#f4f0e4', 'straw'], [700, 662, 0.9, '#2c3050', 'top'], [1090, 640, 0.85, '#e8c8d0', 'straw'], [1190, 650, 0.88, '#a8b8dc', null], [1280, 636, 0.85, '#2c3050', 'top'],
+ [1400, 720, 1.0, '#f0d6dc', 'straw'], [1500, 730, 1.02, '#2c3050', 'top'], [1590, 716, 1.0, '#a8c8dc', null], [780, 590, 0.7, '#e8c8d0', 'straw'], [880, 596, 0.7, '#a8b8dc', null], [330, 600, 0.75, '#f4f0e4', null]];
+ crowd.forEach(([x, y, s, c, h], i) => person(g2, x, y, s, { dress: c, hat: h, dark: c === '#2c3050', lean: Math.sin(i * 1.7) * 0.08, arms: (i % 3) * 0.25 }));
+ crowdLayer = M.broken(cv2, { cell: 4, len: 12, wid: 4.2, passes: 2, angle: (x, y) => 1.25 + Math.sin(x * 0.05) * 0.3, seed: 19, jit: 26, skip: 0.02, sat: 1.12, warm: [255, 226, 170], cool: [130, 130, 200] });
+ return M.broken(cv, { cell: 7, len: 22, wid: 7, passes: 2, angle: (x, y) => y < 460 ? 0.7 + Math.sin(x * 0.01 + y * 0.013) * 0.35 : 0.08 + Math.sin(x * 0.012 + y * 0.01) * 0.3, seed: 11, jit: 30, skip: 0.04, warm: [255, 226, 160], cool: [120, 126, 196], sat: 1.12 });
+ }
+ function lightPlate(seed) {
+ const cv = P.canvas(), g = cv.getContext('2d'), r = rng(seed); g.clearRect(0, 0, W, H);
+ for (let i = 0; i < 90; i++) { const x = r() * W, y = 440 + r() * 600, rx = 26 + r() * 80, ry = 12 + r() * 30; g.fillStyle = r() < 0.62 ? 'rgba(252,232,150,.85)' : 'rgba(96,106,176,.6)'; g.beginPath(); g.ellipse(x, y, rx, ry, (r() - .5) * 0.6, 0, TAU); g.fill(); }
+ return M.broken(cv, { cell: 8, len: 24, wid: 8, passes: 1, angle: () => -0.3, seed: seed + 3, jit: 24, skip: 0.1, warm: [255, 238, 170], cool: [96, 110, 190], base: false });
+ }
+ function build() { base = basePlate(); lightA = lightPlate(21); lightB = lightPlate(47); built = true; }
+ // 近景舞者:小画布整体重绘(两人,随旋转交换位置)
+ function dancers(c, t) {
+ const cv = P.scratch('renoir_dance'); if (cv.width !== 760) { cv.width = 760; cv.height = 680; } const g = cv.getContext('2d'); g.reset(); g.clearRect(0, 0, 760, 680);
+ const a = t * 1.6, cx = 380, cy = 660, sway = Math.sin(a) * 0.05, S2 = 2.5;
+ const A = [cx + 18 + Math.sin(a) * 14, cy + Math.cos(a) * 6], B = [cx - 52 + Math.sin(a) * 6, cy - 10]; // 女在前、男在后左:圆舞里她旋出,他半步退后
+ const hold = [(A[0] + B[0]) / 2 + 40, A[1] - 205]; // 两人相握的手
+ const loc = (p, d) => [(hold[0] - p[0]) / S2 + d[0], (hold[1] - p[1]) / S2 + d[1]];
+ const pa = { dress: '#f4d4dc', trim: '#fff8ee', hat: 'straw', lean: 0.12 + sway, arms: 0.1, reach: loc(A, [0, 0]) }, pb = { dress: '#2c3050', dark: true, hat: 'top', lean: -0.06 + sway, arms: 0.1, skin: '#e2a888', hair: '#4a3a2a', reach: loc(B, [-10, 18]) };
+ person(g, B[0], B[1], S2, pb); person(g, A[0], A[1], S2, pa);
+ const rep = M.broken(cv, { cell: 5, len: 15, wid: 5, passes: 2, angle: (x, y) => 1.3 + Math.sin(x * 0.04) * 0.3, seed: 31, jit: 24, skip: 0.02, sat: 1.1, warm: [255, 226, 170], cool: [130, 130, 200] });
+ c.drawImage(rep, 420, 340);
+ }
+ function draw(c, lt) {
+ if (!built) build();
+ const t = clamp(lt, 0, 6);
+ c.drawImage(base, 0, 0);
+ const q = 0.5 + 0.5 * Math.sin(t * 1.3), lights = (k) => { c.save(); c.globalAlpha = k * (0.55 * (1 - q) + 0.1); c.drawImage(lightA, Math.sin(t * 0.7) * 10, Math.cos(t * 0.6) * 6); c.globalAlpha = k * (0.55 * q + 0.1); c.drawImage(lightB, -Math.sin(t * 0.6) * 10, Math.cos(t * 0.8) * 6); c.restore(); };
+ lights(1); // 光斑落在地上
+ c.drawImage(crowdLayer, 0, 0); // 人站在光里
+ lights(0.28); // 少量光斑再落到人身上:衣服上有碎光,但人不被盖没
+ dancers(c, t);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.2; c.drawImage(P.texture('canvas_renoir', '#ece2cc', { scale: 0.006, amt: 12, grain: 7, seed: 12 }), 0, 0); c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/46_pissarro.js b/scripts/engine/scenes/46_pissarro.js
new file mode 100644
index 0000000..25a435c
--- /dev/null
+++ b/scripts/engine/scenes/46_pissarro.js
@@ -0,0 +1,82 @@
+// 毕沙罗(印象派田园):人是环境的一部分——人物融进树影、田垄、小路;笔触比西斯莱更短、更多向,绿色里有大量橙黄与粉的互补跳动;小路把视线带进深处。
+// 题材(新构图):集市日的乡间小路,两位挑着篮子的农妇和一个赶着小推车的人沿路走来,路两边是开着花的果树,远处一座小教堂。
+// 原作锚定(风格,非原画):天占三分之一、云小而碎;树冠=一团团短笔的绿、黄绿、橙、粉、淡紫;地面笔触顺着地势(田垄、小路的方向);人物只有几笔,但有重量与动势。
+// 管线:干净的形(天/远景/树/地)→ MEDIUM.broken(短笔、多向)→ 缓存;动态:行人沿路(小画布→broken→贴回)、树冠风动(顶层细碎小笔漂)、云慢漂。
+SCENES['46_pissarro'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ let sky, ground, trees, built = false;
+ const PATH = [[250, 1100], [520, 880], [820, 700], [1080, 600], [1250, 548]]; // 小路中线(从近到远)
+ const bez = (u) => { const a = PATH, n = a.length - 1, f = u * n, i = Math.min(n - 1, Math.floor(f)), q = f - i; return [lerp(a[i][0], a[i + 1][0], q), lerp(a[i][1], a[i + 1][1], q)]; };
+ const widthAt = (y) => 40 + (y - 540) * 0.55; // 路在近处更宽
+ function skyPlate() {
+ const cv = P.canvas(2400, 560), g = cv.getContext('2d'), r = rng(4);
+ const gr = g.createLinearGradient(0, 0, 0, 560); gr.addColorStop(0, '#7fa6d2'); gr.addColorStop(0.6, '#b4cadc'); gr.addColorStop(1, '#efe3c8'); g.fillStyle = gr; g.fillRect(0, 0, 2400, 560);
+ for (let k = 0; k < 18; k++) { const x = r() * 2400, y = 40 + r() * 330, s = 0.5 + r() * 0.9; g.save(); g.filter = 'blur(7px)'; for (let j = 0; j < 6; j++) { const dx = (r() - .5) * 150 * s, dy = (r() - .5) * 26 * s, rx = (34 + r() * 50) * s, ry = (16 + r() * 18) * s;
+ g.fillStyle = 'rgba(176,176,204,.7)'; g.beginPath(); g.ellipse(x + dx + 6, y + dy + ry * 0.5, rx, ry * 0.9, 0, 0, TAU); g.fill(); g.fillStyle = 'rgba(246,240,226,.95)'; g.beginPath(); g.ellipse(x + dx, y + dy, rx, ry, 0, 0, TAU); g.fill(); g.fillStyle = 'rgba(252,230,184,.5)'; g.beginPath(); g.ellipse(x + dx - rx * 0.2, y + dy - ry * 0.4, rx * 0.55, ry * 0.4, 0, 0, TAU); g.fill(); } g.restore(); }
+ return M.broken(cv, { cell: 9, len: 34, wid: 7, passes: 2, angle: () => -0.12, seed: 8, jit: 20, skip: 0.06 });
+ }
+ function groundPlate() {
+ const cv = P.canvas(), g = cv.getContext('2d'), r = rng(9);
+ // 远景:丘陵、田野带、小教堂与农舍
+ const hg = g.createLinearGradient(0, 430, 0, 560); hg.addColorStop(0, '#9fb4a8'); hg.addColorStop(1, '#8aa27a'); g.fillStyle = hg; g.beginPath(); g.moveTo(0, 520); g.quadraticCurveTo(300, 420, 640, 480); g.quadraticCurveTo(1000, 440, 1300, 470); g.quadraticCurveTo(1640, 420, 1920, 490); g.lineTo(1920, 600); g.lineTo(0, 600); g.fill();
+ g.fillStyle = '#b8a890'; g.fillRect(1250, 440, 70, 80); g.fillStyle = '#c9b8a0'; g.fillRect(1320, 458, 50, 62); g.fillStyle = '#8d5a4a'; g.beginPath(); g.moveTo(1240, 440); g.lineTo(1285, 400); g.lineTo(1330, 440); g.fill(); g.beginPath(); g.moveTo(1316, 458); g.lineTo(1345, 430); g.lineTo(1376, 458); g.fill();
+ g.fillStyle = '#a89a84'; g.fillRect(1280, 380, 26, 62); g.fillStyle = '#6f6a78'; g.beginPath(); g.moveTo(1274, 382); g.lineTo(1293, 346); g.lineTo(1312, 382); g.fill();
+ // 田:两种绿的垄(沿地势:近处宽斜,远处窄横)
+ const gg = g.createLinearGradient(0, 540, 0, H); gg.addColorStop(0, '#9bb87a'); gg.addColorStop(1, '#5f8a42'); g.fillStyle = gg; g.fillRect(0, 540, W, H - 540);
+ const FP = ['#7fa05a', '#b8c070', '#5f8a42', '#d2c47a', '#8aa86a', '#9a8a5a', '#6f9a56'];
+ for (let i = 0; i < 160; i++) { const k = Math.pow(r(), 1.6), y = 556 + k * 540, sc = 0.25 + k * 1.1, x = r() * W, wd = (60 + r() * 220) * sc, ht = (10 + r() * 30) * sc;
+ g.fillStyle = FP[(r() * FP.length) | 0]; g.globalAlpha = 0.55; g.beginPath(); g.ellipse(x, y, wd, ht, (r() - .5) * 0.12, 0, TAU); g.fill(); }
+ g.globalAlpha = 1;
+ // 树影:横过小路与田的淡紫蓝软影
+ [[470, 840, 240, 40], [1500, 930, 300, 50], [900, 690, 150, 22]].forEach(([x, y, rx, ry]) => { g.save(); g.filter = 'blur(10px)'; g.fillStyle = 'rgba(86,86,150,.38)'; g.beginPath(); g.ellipse(x, y, rx, ry, -0.06, 0, TAU); g.fill(); g.restore(); });
+ // 小路:沿 PATH 画变宽的赭色带,路边有草,路面有车辙
+ g.fillStyle = '#c9a778'; g.beginPath(); const L = [], R = [];
+ for (let k = 0; k <= 40; k++) { const [x, y] = bez(k / 40), w = widthAt(y); L.push([x - w, y]); R.push([x + w, y]); } L.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); R.reverse().forEach(p => g.lineTo(p[0], p[1])); g.closePath(); g.fill();
+ g.strokeStyle = 'rgba(120,86,56,.5)'; g.lineWidth = 6; for (const o of [-0.35, 0.35]) { g.beginPath(); for (let k = 0; k <= 40; k++) { const [x, y] = bez(k / 40); const px = x + o * widthAt(y); k ? g.lineTo(px, y) : g.moveTo(px, y); } g.stroke(); }
+ return M.broken(cv, { cell: 9, len: 30, wid: 7, passes: 2, angle: (x, y) => y < 560 ? 0.02 : (Math.abs(x - bez(clamp((1100 - y) / 560))[0]) < widthAt(y) ? -0.75 : 0.1 + Math.sin(x * 0.01) * 0.2), seed: 11, jit: 24, skip: 0.05, warm: [255, 214, 140], cool: [130, 120, 190] });
+ }
+ function treesPlate() {
+ const cv = P.canvas(), g = cv.getContext('2d'), r = rng(31);
+ const tree = (x, y, h, kind, seed) => {
+ const rr = rng(seed); g.fillStyle = '#6b5a4a'; g.beginPath(); g.moveTo(x - h * 0.03, y); g.lineTo(x - h * 0.012, y - h * 0.55); g.lineTo(x + h * 0.012, y - h * 0.55); g.lineTo(x + h * 0.035, y); g.fill();
+ const pal = kind === 'bloom' ? ['#e6b4b0', '#f0d0c0', '#a8c070', '#8aa850', '#f4e4d4', '#c8a8b8'] : ['#86a850', '#b8c060', '#d6a84a', '#5f8a42', '#e0c070', '#4d6b3a'];
+ for (let i = 0; i < 70; i++) { const a = rr() * TAU, d = Math.pow(rr(), 0.7) * h * 0.36, cx = x + Math.cos(a) * d * 1.2, cy = y - h * 0.66 + Math.sin(a) * d * 0.88, rx = h * (0.035 + rr() * 0.05), ry = rx * (0.7 + rr() * 0.3);
+ const low = Math.sin(a) > 0.2, hi = Math.sin(a) < -0.35; // 下沿阴、上沿亮
+ g.fillStyle = low && rr() < 0.7 ? '#4d6b3a' : hi && rr() < 0.6 ? '#f0d878' : pal[(rr() * pal.length) | 0]; g.beginPath(); g.ellipse(cx, cy, rx, ry, rr() * 3, 0, TAU); g.fill(); }
+ };
+ tree(260, 900, 640, 'bloom', 1); tree(560, 760, 380, 'leaf', 2); tree(1560, 880, 620, 'leaf', 3); tree(1780, 780, 400, 'bloom', 4); tree(1040, 580, 200, 'leaf', 5);
+ return M.broken(cv, { cell: 8, len: 22, wid: 7, passes: 2, angle: (x, y) => 0.9 + Math.sin(x * 0.02 + y * 0.017) * 1.1, seed: 13, jit: 34, skip: 0.04, warm: [255, 216, 150], cool: [110, 130, 190], sat: 1.12 });
+ }
+ function build() { sky = skyPlate(); ground = groundPlate(); trees = treesPlate(); built = true; }
+ // 行人(小画布→broken→贴回):u 沿路位置,face 朝向,basket 篮子,kind 类型
+ function walker(c, u, kind, t, ph) {
+ const [x, y] = bez(u), s = lerp(0.34, 1.0, (y - 560) / 540), cv = P.scratch('pis_walker'); if (cv.width !== 360) { cv.width = 360; cv.height = 420; } const g = cv.getContext('2d'); g.reset(); g.clearRect(0, 0, 360, 420);
+ g.save(); g.translate(180, 380); g.scale(s * 1.6, s * 1.6); const step = Math.sin(t * 5 + ph), bob = Math.abs(step) * 3;
+ g.translate(0, -bob);
+ g.fillStyle = '#4a4a5a'; g.fillRect(-14, -38, 10, 38 + step * 4); g.fillRect(4, -38, 10, 38 - step * 4); // 腿
+ const robe = kind === 'a' ? '#5a78a8' : kind === 'b' ? '#a8584a' : '#6f7f4a';
+ g.fillStyle = robe; g.beginPath(); g.moveTo(-26, -40); g.quadraticCurveTo(-30, -96, -14, -128); g.lineTo(14, -128); g.quadraticCurveTo(30, -96, 28, -40); g.closePath(); g.fill(); // 衣
+ g.fillStyle = '#e8d8c0'; g.beginPath(); g.moveTo(-12, -128); g.lineTo(12, -128); g.lineTo(6, -100); g.lineTo(-6, -100); g.fill(); // 围裙/领
+ g.fillStyle = '#d8b090'; g.beginPath(); g.arc(0, -142, 12, 0, TAU); g.fill(); g.fillStyle = kind === 'c' ? '#3a3a3a' : '#efe6d4'; g.beginPath(); g.ellipse(0, -152, 14, 5, 0, 0, TAU); g.fill(); g.beginPath(); g.arc(0, -154, 8, Math.PI, 0); g.fill(); // 头与帽
+ if (kind !== 'c') { g.strokeStyle = '#4a3a2a'; g.lineWidth = 4; g.beginPath(); g.moveTo(-26, -118); g.quadraticCurveTo(-48, -96, -42, -70); g.stroke(); g.fillStyle = '#b88a4a'; g.beginPath(); g.ellipse(-42, -66, 20, 12, 0, 0, TAU); g.fill(); g.fillStyle = '#d6a84a'; for (let k = 0; k < 4; k++) { g.beginPath(); g.arc(-50 + k * 8, -76, 5, 0, TAU); g.fill(); } }
+ else { g.strokeStyle = '#4a3a2a'; g.lineWidth = 5; g.beginPath(); g.moveTo(14, -110); g.lineTo(80, -70); g.stroke(); g.fillStyle = '#8a6a3a'; g.fillRect(60, -64, 70, 36); g.fillStyle = '#6b8a3a'; for (let k = 0; k < 4; k++) { g.beginPath(); g.arc(70 + k * 15, -70, 9, 0, TAU); g.fill(); } g.fillStyle = '#14120f'; g.beginPath(); g.arc(78, -22, 10, 0, TAU); g.arc(120, -22, 10, 0, TAU); g.fill(); }
+ g.restore();
+ const rep = M.broken(cv, { cell: 5, len: 12, wid: 4.5, passes: 2, angle: (xx, yy) => (yy > 330 ? 0.4 : 1.3), seed: 15, jit: 20, skip: 0.02, sat: 1.08 });
+ c.drawImage(rep, x - 180, y - 380);
+ }
+ function draw(c, lt) {
+ if (!built) build();
+ const t = clamp(lt, 0, 6);
+ c.drawImage(sky, t * 12, 0, W, 560, 0, 0, W, 560);
+ c.drawImage(ground, 0, 0);
+ // 远景的行人先画(小),再画树,再画近的人,保证层次
+ walker(c, lerp(0.66, 0.34, ss(0, 6, t)), 'c', t, 2.0);
+ c.drawImage(trees, 0, 0);
+ // 树冠风动:顶层再撒一小把随风漂的叶笔
+ const r = rng(77); c.save(); c.lineCap = 'round'; for (let i = 0; i < 260; i++) { const tx = [260, 560, 1560, 1780][i % 4], ty = [330, 480, 380, 460][i % 4], a = r() * TAU, d = Math.sqrt(r()) * [230, 140, 220, 150][i % 4], ph = r() * 6;
+ const x = tx + Math.cos(a) * d + Math.sin(t * 1.6 + ph) * 5, y = ty + Math.sin(a) * d * 0.8 + Math.cos(t * 1.9 + ph) * 3, col = ['#e9b6b8', '#b8c060', '#f2d2c4', '#86a850', '#d6a84a'][(r() * 5) | 0]; c.strokeStyle = col; c.globalAlpha = 0.85; c.lineWidth = 6; c.beginPath(); c.moveTo(x - 8, y - 3); c.lineTo(x + 8, y + 3); c.stroke(); } c.restore();
+ walker(c, lerp(0.5, 0.06, ss(0, 6, t)), 'a', t, 0.0); walker(c, lerp(0.58, 0.16, ss(0, 6, t)), 'b', t, 1.3);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.2; c.drawImage(P.texture('canvas_pis', '#e8e0cc', { scale: 0.006, amt: 12, grain: 7, seed: 5 }), 0, 0); c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/47_sisley.js b/scripts/engine/scenes/47_sisley.js
new file mode 100644
index 0000000..8306dfe
--- /dev/null
+++ b/scripts/engine/scenes/47_sisley.js
@@ -0,0 +1,94 @@
+// 西斯莱(印象派风景):天占大半、积云有暖白与淡紫灰的阴面、水面把房子拖成碎笔倒影、整幅是一笔一笔短弯笔,没有轮廓线。
+// 题材(新构图):涨水后的村口,一位摆渡人撑船载着一只木箱穿过水面,左边是半淹的客栈,右边是光秃的白杨与电线杆。
+// 原作锚定(fetch_reference.py:《路维希安的雪》《马尔利港的洪水》《塞纳河上的船》):天 #8fb0d0→#e9dcc0、云白 #f2ecde/阴 #aab0c4/暖 #f8e4b8、
+// 水 #9aa89c+倒影、屋墙赭黄 #d6bd86、屋顶石板 #6d7684、近景笔触宽而横、远处窄而碎;暖亮处偏黄粉,阴暗处偏冷紫。
+// 管线:干净的形(天/水/景)→ MEDIUM.broken 各自重画成笔触(缓存)→ 动态:云慢漂、水面逐行位移+涟漪、摆渡船与撑篙。
+SCENES['47_sisley'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ const WL = 540, BASE = 722; // 水面起点(远岸脚)与房脚吃水线
+ let sky, water, scene, built = false;
+ function skyPlate() {
+ const cv = P.canvas(2600, 600), g = cv.getContext('2d');
+ const gr = g.createLinearGradient(0, 0, 0, 600); gr.addColorStop(0, '#6a98c8'); gr.addColorStop(0.55, '#a8c0d8'); gr.addColorStop(1, '#ebdfc2'); g.fillStyle = gr; g.fillRect(0, 0, 2600, 600);
+ const r = rng(17);
+ const cloud = (x, y, s) => {
+ const blobs = Array.from({ length: 9 }, () => [x + (r() - .5) * 300 * s, y + (r() - .5) * 60 * s, (50 + r() * 70) * s, (30 + r() * 36) * s]);
+ g.save(); g.filter = 'blur(10px)';
+ blobs.forEach(([bx, by, rx, ry]) => { g.fillStyle = 'rgba(166,170,196,.75)'; g.beginPath(); g.ellipse(bx + 8 * s, by + ry * 0.55, rx * 1.02, ry * 0.9, 0, 0, TAU); g.fill(); }); // 阴面:淡紫灰,压在下
+ blobs.forEach(([bx, by, rx, ry]) => { g.fillStyle = 'rgba(244,238,224,.95)'; g.beginPath(); g.ellipse(bx, by, rx, ry, 0, 0, TAU); g.fill(); }); // 本体:暖白
+ blobs.forEach(([bx, by, rx, ry]) => { g.fillStyle = 'rgba(252,232,186,.55)'; g.beginPath(); g.ellipse(bx - rx * 0.2, by - ry * 0.45, rx * 0.6, ry * 0.4, 0, 0, TAU); g.fill(); }); // 受光:暖黄
+ g.restore();
+ };
+ [[260, 160, 1.5], [820, 110, 1.2], [1320, 190, 1.7], [1900, 120, 1.3], [2380, 210, 1.5], [620, 330, 0.9], [1560, 380, 0.8], [2100, 400, 0.9], [60, 380, 0.8]].forEach(([x, y, s]) => cloud(x, y, s));
+ return M.broken(cv, { cell: 10, len: 54, wid: 10, passes: 2, angle: (x, y) => -0.06 + Math.sin(x * 0.004) * 0.05, seed: 3, jit: 18, skip: 0.06 });
+ }
+ function above(g) { // 水面之上的东西:远岸、客栈、电线杆、白杨
+ const r = rng(23);
+ // 远岸一带:低矮房屋+灌木,偏雾蓝灰(空气透视)
+ g.fillStyle = '#9fa9a8'; g.fillRect(0, 486, W, 60);
+ [[700, 470, 80, 56, '#b9a58a'], [790, 480, 60, 44, '#a99a86'], [880, 462, 100, 66, '#b7a690'], [1010, 476, 70, 50, '#a99a86'], [1120, 470, 120, 58, '#b9a58a']].forEach(([x, y, w, h, col], i) => { g.fillStyle = col; g.fillRect(x, y, w, h); g.fillStyle = '#7d7f8a'; g.beginPath(); g.moveTo(x - 6, y); g.lineTo(x + w / 2, y - 24); g.lineTo(x + w + 6, y); g.fill(); });
+ g.fillStyle = '#7f8e72'; for (let i = 0; i < 40; i++) { g.beginPath(); g.ellipse(560 + r() * 1300, 520 + r() * 20, 30 + r() * 30, 16 + r() * 14, 0, 0, TAU); g.fill(); }
+ // 客栈(左):两个立面——正面赭黄、侧面阴面更暗;陡屋顶+老虎窗;一层是浅色招牌带(不写字)
+ const fx = 40, fw = 470, top = 250, sideW = 150;
+ g.fillStyle = '#d8bf88'; g.fillRect(fx, top, fw, BASE - top);
+ g.fillStyle = '#b8a070'; g.beginPath(); g.moveTo(fx + fw, top); g.lineTo(fx + fw + sideW, top + 40); g.lineTo(fx + fw + sideW, BASE - 6); g.lineTo(fx + fw, BASE); g.fill();
+ g.fillStyle = '#6a7482'; g.beginPath(); g.moveTo(fx - 20, top + 6); g.lineTo(fx + fw * 0.45, top - 130); g.lineTo(fx + fw + sideW + 20, top + 36); g.lineTo(fx + fw + 8, top + 18); g.lineTo(fx + fw * 0.45, top - 96); g.closePath(); g.fill();
+ g.fillStyle = '#4e5766'; g.beginPath(); g.moveTo(fx + fw * 0.45, top - 130); g.lineTo(fx + fw + sideW + 20, top + 36); g.lineTo(fx + fw + sideW, top + 50); g.lineTo(fx + fw * 0.45, top - 100); g.fill();
+ g.fillStyle = '#6a7482'; g.fillRect(fx + 270, top - 40, 70, 62); g.fillStyle = '#4e5766'; g.beginPath(); g.moveTo(fx + 262, top - 40); g.lineTo(fx + 305, top - 76); g.lineTo(fx + 348, top - 40); g.fill(); g.fillStyle = '#3a4150'; g.fillRect(fx + 286, top - 26, 38, 40);
+ [[fx + 40, top + 60], [fx + 150, top + 60], [fx + 260, top + 60], [fx + 370, top + 60]].forEach(([x, y]) => { g.fillStyle = '#7a8a86'; g.fillRect(x - 10, y, 18, 96); g.fillRect(x + 62, y, 18, 96); g.fillStyle = '#3d4348'; g.fillRect(x + 8, y + 4, 54, 90); g.fillStyle = 'rgba(210,225,235,.55)'; g.fillRect(x + 12, y + 8, 46, 36); });
+ g.fillStyle = '#efe3bd'; g.fillRect(fx, top + 200, fw, 56); g.fillStyle = '#c8b27a'; g.fillRect(fx, top + 256, fw, 6); // 招牌带
+ [[fx + 60, top + 275], [fx + 220, top + 275]].forEach(([x, y]) => { g.fillStyle = '#7a8a86'; g.fillRect(x - 8, y, 14, 150); g.fillRect(x + 58, y, 14, 150); g.fillStyle = '#31373c'; g.fillRect(x + 6, y + 4, 52, 140); }); // 一层的窗
+ g.fillStyle = '#6b4d34'; g.fillRect(fx + 360, top + 290, 70, 132); g.fillStyle = '#2a2420'; g.fillRect(fx + 368, top + 300, 54, 120); // 门(半淹)
+ // 白杨:细长的光秃树,枝丫上挑
+ const poplar = (x, base, hgt, seed) => { const rr = rng(seed); g.strokeStyle = '#7d7566'; g.lineCap = 'round'; g.lineWidth = 11; g.beginPath(); g.moveTo(x, base); g.lineTo(x + 6, base - hgt); g.stroke();
+ for (let k = 0; k < 22; k++) { const y = base - hgt * (0.18 + rr() * 0.8), side = rr() < 0.5 ? -1 : 1, L = 60 + rr() * 110 * (1 - (base - y) / hgt * 0.6); g.lineWidth = 3 + rr() * 3; g.beginPath(); g.moveTo(x + 3, y); g.quadraticCurveTo(x + side * L * 0.4, y - L * 0.5, x + side * L * 0.55, y - L); g.stroke(); } };
+ poplar(1600, BASE + 20, 560, 5); poplar(1740, BASE + 60, 500, 6); poplar(1830, BASE + 30, 430, 7);
+ // 电线杆
+ g.fillStyle = '#6a5d4e'; g.fillRect(1292, 160, 18, BASE - 150); g.fillRect(1250, 190, 102, 10); g.strokeStyle = '#6a5d4e'; g.lineWidth = 3; g.beginPath(); g.moveTo(1250, 194); g.quadraticCurveTo(900, 250, 600, 214); g.moveTo(1352, 194); g.quadraticCurveTo(1650, 240, 1920, 200); g.stroke();
+ }
+ function build() {
+ sky = skyPlate();
+ // 干净的景(透明底)
+ const sp = P.canvas(), sg = sp.getContext('2d'); above(sg);
+ // 水:底色+倒影(景的竖向镜像,压暗压冷)+天光碎片
+ const wp = P.canvas(), wg = wp.getContext('2d'); const gr = wg.createLinearGradient(0, WL, 0, H); gr.addColorStop(0, '#c4cbc0'); gr.addColorStop(0.4, '#9fb0aa'); gr.addColorStop(1, '#788a82'); wg.fillStyle = gr; wg.fillRect(0, WL, W, H - WL);
+ wg.save(); wg.beginPath(); wg.rect(0, WL, W, H - WL); wg.clip(); wg.translate(0, BASE * 2 - 2); wg.scale(1, -1); wg.globalAlpha = 0.62; wg.filter = 'blur(3px) brightness(.82) saturate(.9)'; wg.drawImage(sp, 0, 0); wg.restore();
+ const r = rng(41); wg.globalAlpha = 1; for (let i = 0; i < 90; i++) { const x = r() * W, y = WL + 30 + r() * (H - WL), w = 40 + r() * 190; wg.fillStyle = `rgba(${r() < 0.6 ? '236,236,224' : '150,170,176'},${0.12 + r() * 0.2})`; wg.fillRect(x, y, w, 3 + r() * 5); }
+ water = M.broken(wp, { cell: 11, len: 70, wid: 8, passes: 2, angle: () => 0, seed: 5, jit: 16, skip: 0.04, cool: [96, 120, 156], warm: [236, 222, 176] });
+ scene = M.broken(sp, { cell: 8, len: 26, wid: 8, passes: 2, angle: (x, y) => x < 700 && y < 330 ? (x < 280 ? -0.5 : 0.5) : (x > 1500 ? 1.45 : (x > 1270 && x < 1330 && y < 740 ? 1.57 : (y < 520 ? 0.02 : 1.5))), seed: 9, jit: 18, skip: 0.04 });
+ built = true;
+ }
+ function boat(c, t) {
+ const u = ss(0, 6, t), X = lerp(1380, 840, u), Y = 842 + Math.sin(t * 1.5) * 3, tilt = Math.sin(t * 1.5 + 1) * 0.025, pole = Math.sin(t * 2.2) * 0.5 + 0.5;
+ const cvs = P.scratch('sisley_boat'); if (cvs.width !== 520) { cvs.width = 520; cvs.height = 360; } const cg = cvs.getContext('2d'); cg.reset(); cg.clearRect(0, 0, 520, 360);
+ const x = 260, y = 230, cc = c; c = cg;
+ // 倒影(先画,暗、窄、被水纹打碎)
+ c.save(); c.translate(x, y + 40); c.scale(1, -0.5); c.globalAlpha = 0.28; c.fillStyle = '#2d2a28'; c.beginPath(); c.moveTo(-130, 0); c.quadraticCurveTo(0, 30, 130, 0); c.lineTo(100, -36); c.lineTo(-100, -36); c.fill(); c.fillRect(-8, -150, 16, 114); c.restore();
+ c.save(); c.translate(x, y); c.rotate(tilt);
+ c.fillStyle = '#3a2f2a'; c.beginPath(); c.moveTo(-150, -8); c.quadraticCurveTo(-110, 34, 0, 36); c.quadraticCurveTo(110, 34, 150, -14); c.lineTo(120, -30); c.lineTo(-120, -28); c.closePath(); c.fill();
+ c.fillStyle = '#6d5a42'; c.beginPath(); c.moveTo(-150, -8); c.lineTo(-120, -28); c.lineTo(120, -30); c.lineTo(150, -14); c.lineTo(110, -8); c.lineTo(-110, -4); c.closePath(); c.fill();
+ c.fillStyle = '#c9b88a'; c.beginPath(); c.moveTo(26, -26); c.quadraticCurveTo(20, -88, 70, -96); c.quadraticCurveTo(122, -88, 116, -26); c.closePath(); c.fill(); c.strokeStyle = '#6b5a3a'; c.lineWidth = 4; c.beginPath(); c.moveTo(48, -92); c.quadraticCurveTo(70, -80, 94, -92); c.stroke(); // 麻袋
+ // 摆渡人:深色身形,白帽,竿从右手斜入水
+ c.fillStyle = '#2a3340'; c.beginPath(); c.moveTo(-52, -26); c.quadraticCurveTo(-60, -90, -46, -126); c.lineTo(-18, -126); c.quadraticCurveTo(-8, -90, -14, -26); c.fill();
+ c.fillStyle = '#d9b48c'; c.beginPath(); c.arc(-32, -142, 13, 0, TAU); c.fill(); c.fillStyle = '#e8e0cc'; c.beginPath(); c.ellipse(-32, -152, 20, 7, 0, 0, TAU); c.fill();
+ const px = -14 + pole * 8, ang = -0.5 - pole * 0.15; c.strokeStyle = '#4a3a2a'; c.lineWidth = 6; c.lineCap = 'round'; c.beginPath(); c.moveTo(-18, -104 - pole * 6); c.lineTo(px + Math.cos(ang) * -210 * -1, 30 + pole * 14 + 0); c.stroke();
+ c.restore();
+ const rep = M.broken(cvs, { cell: 7, len: 18, wid: 6, passes: 2, angle: (xx, yy) => (yy > 250 ? 0 : 1.2), seed: 12, jit: 14, skip: 0.02, base: true });
+ cc.drawImage(rep, X - 260, Y - 230);
+ c = cc; const x2 = X, y2 = Y;
+ // 船行水纹:船尾拖出两道渐开的 V
+ c.save(); c.strokeStyle = 'rgba(244,240,226,.55)'; c.lineWidth = 3; c.lineCap = 'round'; for (let k = 0; k < 3; k++) { const q = ((t * 0.5 + k / 3) % 1); c.globalAlpha = (1 - q) * 0.8; c.beginPath(); c.ellipse(x2 + 90 + q * 220, y2 + 34, 40 + q * 110, 6 + q * 14, 0, Math.PI * 0.05, Math.PI * 0.95); c.stroke(); } c.restore();
+ }
+ function draw(c, lt) {
+ if (!built) build();
+ const t = clamp(lt, 0, 6);
+ c.drawImage(sky, t * 18, 0, W, 600, 0, 0, W, 600); // 云慢漂
+ c.fillStyle = '#ebdfc2'; c.fillRect(0, 560, W, WL - 540 + 40);
+ // 水:逐行位移,越近越大(倒影被水纹拉碎)
+ for (let y = WL; y < H; y += 6) { const k = (y - WL) / (H - WL), dx = Math.sin(t * 1.3 + y * 0.09) * (1.5 + k * 9) + Math.sin(t * 2.7 + y * 0.21) * 1.5 * k; c.drawImage(water, 0, y, W, 6, dx - 24, y, W + 48, 6); }
+ c.drawImage(scene, 0, 0);
+ boat(c, t);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.22; c.drawImage(P.texture('canvas_sisley', '#e8e0cc', { scale: 0.006, amt: 12, grain: 7, seed: 3 }), 0, 0); c.restore(); // 画布纹
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/48_gauguin.js b/scripts/engine/scenes/48_gauguin.js
new file mode 100644
index 0000000..9e2e84c
--- /dev/null
+++ b/scripts/engine/scenes/48_gauguin.js
@@ -0,0 +1,107 @@
+// 高更(综合主义/掐丝珐琅):不写实的饱和色场、粗而不均的深群青轮廓、斜线分割画面的树干、被画框裁掉的前景人物、没有投影。
+// 题材(新构图):红色草场上,三位戴白帽的妇人(前景,裁切)看着一个男孩牵山羊横穿画面;一棵斜树把画面劈开。
+// 原作锚定(fetch_reference.py:《布道后的幻象》《黄色基督》《我们从哪里来》):朱红 #d63a1c 色场、黄赭 #e0a526 地、
+// 紫褐树干 #5b2c48、白帽 #efece2+蓝灰影 #a9b4cf、黑裙 #1b1a22、轮廓深群青 #1d2a52;没有透视收束,远近靠重叠和裁切。
+// 管线:色场(缓存,顺笔向短条)→ 斜树(缓存)→ 黄地 → 动态:山羊与男孩(走)、前景妇人(风吹帽翼)、叶团摇 → 无投影,不加光效。
+SCENES['48_gauguin'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ const LINE = '#1d2a52';
+ let layer;
+ const poly = (pts, close = true) => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); if (close) p.closePath(); return p; };
+ // Catmull 式平滑闭合/开放曲线:高更什么都是圆的,不要折线
+ const smooth = (pts, close = true) => { const p = new Path2D(), n = pts.length; if (close) { const m = i => [(pts[i % n][0] + pts[(i + 1) % n][0]) / 2, (pts[i % n][1] + pts[(i + 1) % n][1]) / 2]; p.moveTo(...m(n - 1)); for (let i = 0; i < n; i++) p.quadraticCurveTo(pts[i][0], pts[i][1], ...m(i)); p.closePath(); }
+ else { p.moveTo(...pts[0]); for (let i = 1; i < n - 1; i++) p.quadraticCurveTo(pts[i][0], pts[i][1], (pts[i][0] + pts[i + 1][0]) / 2, (pts[i][1] + pts[i + 1][1]) / 2); p.lineTo(...pts[n - 1]); } return p; };
+ const blob = (cx, cy, rx, ry, rot = 0) => { const p = new Path2D(); p.ellipse(cx, cy, rx, ry, rot, 0, TAU); return p; };
+ function build() {
+ layer = P.canvas(); const g = layer.getContext('2d');
+ // 朱红色场:整幅铺满,笔向斜 30°,同色里有橙红/深红的条
+ M.flat(g, poly([[0, 0], [W, 0], [W, H], [0, H]]), '#d63a1c', { streak: 0.5, vari: 34, lw: 0, seed: 1, n: 520 });
+ // 黄赭地:右下一块大而圆的坡,波浪形上缘
+ const ground = new Path2D(); ground.moveTo(520, H); ground.bezierCurveTo(700, 820, 980, 700, 1280, 730); ground.bezierCurveTo(1560, 760, 1740, 700, W, 640); ground.lineTo(W, H); ground.closePath();
+ M.flat(g, ground, '#e0a526', { streak: -0.15, vari: 26, lw: 7, seed: 2, n: 300, line: LINE });
+ // 紫褐小径:沿地面斜向的一条
+ M.flat(g, poly([[900, 1010], [1260, 840], [1420, 860], [1060, 1060]]), '#7a3a5a', { streak: -0.45, vari: 20, lw: 5, seed: 3, n: 80, line: LINE });
+ // 斜树干:从左上劈向右下,上粗下细再略弯,把画面分成两半
+ const trunk = smooth([[620, -40], [830, -40], [970, 150], [1100, 330], [1300, 490], [1480, 590], [1580, 730], [1450, 760], [1350, 690], [1170, 620], [1090, 520], [930, 340], [770, 200], [670, 90]]);
+ M.flat(g, trunk, '#5b2c48', { streak: 0.8, vari: 26, lw: 8, seed: 4, n: 180, line: LINE, bounds: [500, 0, 1120, 780] });
+ M.flat(g, smooth([[640, -30], [760, -30], [940, 170], [1120, 360], [1300, 520], [1420, 600], [1330, 600], [1160, 480], [940, 300], [720, 120]]), '#8d4a66', { streak: 0.8, vari: 14, lw: 0, seed: 5, n: 50, bounds: [500, 0, 1100, 760] });
+ // (树干上原有三个暗斑,读成笛孔,已去掉)
+ // 枝:树干中段向右上分出两枝,叶团另画(动态)
+ M.flat(g, smooth([[1200, 400], [1380, 250], [1560, 140], [1630, 190], [1500, 330], [1310, 480]]), '#5b2c48', { streak: -0.7, vari: 20, lw: 7, seed: 6, n: 70, line: LINE, bounds: [1200, 140, 460, 340] });
+ M.flat(g, smooth([[980, 280], [1090, 150], [1190, 30], [1250, 70], [1170, 220], [1090, 340]]), '#5b2c48', { streak: -1.0, vari: 20, lw: 7, seed: 7, n: 40, line: LINE, bounds: [980, 30, 280, 300] });
+ }
+ function leaves(c, t) { // 叶团:深绿大圆块,叠几个黄点(果),整团微摇
+ [[1590, 150, 190, 120, 0.2], [1250, 70, 150, 100, -0.3], [1460, 300, 120, 80, 0.1]].forEach(([x, y, rx, ry, rot], i) => {
+ const sw = Math.sin(t * 1.6 + i * 1.7) * 7, ox = x + sw, oy = y + Math.sin(t * 2.1 + i) * 3, rr = rng(70 + i), p = smooth(Array.from({ length: 11 }, (_, k) => { const a = k / 11 * TAU, j = 0.82 + rr() * 0.3; return [ox + Math.cos(a) * rx * j, oy + Math.sin(a) * ry * j]; }));
+ M.flat(c, p, '#2f5a3a', { streak: 0.2, vari: 22, lw: 7, seed: 10 + i, n: 90, line: LINE, bounds: [x - rx, y - ry, rx * 2, ry * 2] });
+ const r = rng(30 + i); for (let k = 0; k < 6; k++) { const a = r() * TAU, d = r() * 0.7; M.flat(c, blob(x + sw + Math.cos(a) * rx * d, y + Math.sin(a) * ry * d, 15, 13), '#f2c335', { vari: 8, lw: 3.5, seed: 40 + k, n: 6, line: LINE, bounds: [x - rx, y - ry, rx * 2, ry * 2] }); }
+ });
+ }
+ // 戴白帽的妇人(布列塔尼):黑裙大圆块+肩上白披领;侧脸朝右(前额—鼻—唇—下巴一条干净的曲线);高白帽冠立在头顶、帽翼垂在脑后随风;back=true 背对
+ function woman(c, x, y, s, t, seed, bow, back) {
+ const sw = Math.sin(t * 2.2 + seed) * 8 * s;
+ c.save(); c.translate(x, y); c.scale(s, s);
+ M.flat(c, smooth([[-170, 0], [-190, -200], [-150, -360], [-60, -430], [60, -430], [150, -340], [190, -190], [175, 0]]), '#1b1a22', { streak: 1.2, vari: 12, lw: 8, seed: seed, n: 60, line: LINE, bounds: [-190, -440, 380, 440] });
+ // 白披领:肩上一圈,前襟 V 形,蓝灰影在一侧
+ M.flat(c, smooth([[-120, -420], [-30, -470], [80, -462], [150, -400], [90, -350], [10, -330], [-70, -350]]), '#efece2', { streak: 0.3, vari: 8, lw: 7, seed: seed + 1, n: 16, line: LINE, bounds: [-130, -475, 290, 150] });
+ M.flat(c, smooth([[-40, -352], [10, -332], [80, -352], [40, -380]]), '#a9b4cf', { vari: 6, lw: 0, seed: seed + 8, n: 6, bounds: [-40, -380, 130, 50] });
+ const hy = -560 + bow * 14;
+ // 帽翼(脑后垂下,随风)
+ M.flat(c, smooth([[-10, hy + 30], [-70 - sw, hy + 20], [-150 - sw * 1.6, hy + 90], [-120 - sw, hy + 170], [-50, hy + 140], [-10, hy + 90]]), '#efece2', { streak: 0.5, vari: 8, lw: 7, seed: seed + 2, n: 16, line: LINE, bounds: [-160, hy + 10, 160, 170] });
+ M.flat(c, smooth([[-100 - sw, hy + 110], [-60, hy + 130], [-40, hy + 100]]), '#a9b4cf', { vari: 6, lw: 0, seed: seed + 5, n: 4, bounds: [-110, hy + 90, 80, 50] });
+ if (!back) {
+ // 脸:侧向右,一条连续的曲线;颈接到披领
+ M.flat(c, smooth([[-10, hy + 0], [52, hy - 6], [92, hy + 22], [96, hy + 56], [126, hy + 90], [100, hy + 98], [104, hy + 118], [94, hy + 134], [98, hy + 160], [60, hy + 188], [10, hy + 176], [-20, hy + 140], [-24, hy + 70]]), '#e8b078', { streak: 1.2, vari: 10, lw: 7, seed: seed + 6, n: 14, line: LINE, bounds: [-30, hy - 10, 160, 200] });
+ c.strokeStyle = LINE; c.lineWidth = 5.5; c.lineCap = 'round';
+ c.beginPath(); c.moveTo(56, hy + 52); c.quadraticCurveTo(76, hy + 64, 96, hy + 52); c.stroke(); // 闭眼
+ c.beginPath(); c.moveTo(50, hy + 34); c.quadraticCurveTo(76, hy + 24, 98, hy + 34); c.stroke(); // 眉
+ c.strokeStyle = '#8a3a30'; c.lineWidth = 6; c.beginPath(); c.moveTo(74, hy + 138); c.quadraticCurveTo(90, hy + 144, 102, hy + 134); c.stroke(); // 唇:平静
+ M.flat(c, smooth([[8, hy + 90], [40, hy + 120], [30, hy + 160], [-6, hy + 120]]), '#d49a66', { vari: 6, lw: 0, seed: seed + 9, n: 4, bounds: [-6, hy + 90, 50, 70] }); // 颊下影
+ }
+ // 帽冠:高、圆顶、正面略宽,压在额头之上(不盖脸)
+ M.flat(c, smooth([[-26, hy + 70], [-34, hy - 40], [-4, hy - 120], [58, hy - 150], [108, hy - 100], [112, hy - 20], [86, hy + 6], [20, hy + 12]]), '#efece2', { streak: 1.3, vari: 8, lw: 8, seed: seed + 4, n: 26, line: LINE, bounds: [-40, hy - 160, 160, 180] });
+ M.flat(c, smooth([[-26, hy - 30], [-4, hy - 110], [20, hy - 100], [0, hy + 20]]), '#a9b4cf', { vari: 6, lw: 0, seed: seed + 3, n: 6, bounds: [-30, hy - 120, 60, 150] });
+ c.restore();
+ }
+ // 男孩和山羊:向左走。羊在后,绳牵在男孩手里;步态用腿相位摆
+ function boyGoat(c, t) {
+ const u = ss(0.0, 6, t), x = lerp(1830, 1420, u), step = Math.sin(t * 7), bob = Math.abs(step) * 4, y = 808 + lerp(0, 22, u);
+ c.save(); c.translate(x, y - bob); c.scale(0.58, 0.58);
+ // 羊(朝左):长躯干+粗颈+楔形头+后弯角+细腿带膝;远侧两腿先画,近侧后画;肚下蓝灰影
+ const leg = (dx, ph, near) => { const sw = Math.sin(t * 7 + ph) * 26, kx = dx + sw * 0.4, fx = dx + sw; return smooth([[dx - 10, -70], [dx + 10, -70], [kx + 8, -36], [fx + 7, 6], [fx + 10, 20], [fx - 14, 20], [fx - 8, 4], [kx - 8, -34]]); };
+ [[-62, 3.1, 0], [58, 0, 0]].forEach(([dx, ph], i) => M.flat(c, leg(dx, ph), '#c9c8c4', { vari: 6, lw: 6, seed: 60 + i, n: 4, line: LINE, bounds: [dx - 30, -74, 70, 110] }));
+ M.flat(c, smooth([[-96, -126], [-40, -156], [50, -158], [120, -138], [134, -100], [104, -66], [30, -58], [-50, -60], [-98, -82]]), '#efece2', { streak: 0.05, vari: 10, lw: 8, seed: 66, n: 40, line: LINE, bounds: [-100, -160, 240, 100] });
+ M.flat(c, smooth([[-100, -86], [-30, -62], [60, -64], [118, -86], [100, -66], [30, -58], [-50, -60]]), '#a9b4cf', { vari: 6, lw: 0, seed: 65, n: 8, bounds: [-110, -90, 240, 40] });
+ [[-30, -110, 34, 22], [40, -130, 30, 20], [70, -90, 24, 16]].forEach(([x, y, rx, ry], i) => M.flat(c, blob(x, y, rx, ry, 0.3), '#6a3a2a', { vari: 8, lw: 5, seed: 80 + i, n: 6, line: LINE, bounds: [x - rx, y - ry, rx * 2, ry * 2] }));
+ M.flat(c, smooth([[-96, -128], [-100, -198], [-140, -242], [-196, -236], [-224, -200], [-216, -152], [-170, -148], [-130, -110]]), '#efece2', { streak: 0.6, vari: 8, lw: 8, seed: 67, n: 22, line: LINE, bounds: [-250, -232, 160, 130] }); // 颈+头
+ M.flat(c, smooth([[-176, -232], [-150, -262], [-130, -226], [-150, -216]]), '#efece2', { vari: 4, lw: 6, seed: 68, n: 2, line: LINE }); // 耳
+ c.strokeStyle = LINE; c.lineWidth = 9; c.lineCap = 'round'; c.beginPath(); c.moveTo(-196, -232); c.quadraticCurveTo(-190, -290, -128, -296); c.stroke(); // 角(向后弯)
+ c.lineWidth = 6; c.beginPath(); c.moveTo(-244, -166); c.quadraticCurveTo(-254, -134, -240, -110); c.stroke(); // 胡须
+ M.flat(c, blob(-208, -172, 22, 17, 0.2), '#c7a591', { vari: 6, lw: 5, seed: 90, n: 4, line: LINE, bounds: [-258, -186, 44, 32] });
+ c.fillStyle = LINE; c.beginPath(); c.arc(-184, -208, 6.5, 0, TAU); c.fill();
+ [[-34, 0, 0], [86, 3.1, 0]].forEach(([dx, ph], i) => M.flat(c, leg(dx, ph), '#efece2', { vari: 6, lw: 7, seed: 62 + i, n: 4, line: LINE, bounds: [dx - 30, -74, 70, 110] }));
+ // 男孩:侧身朝左,蓝衣、黄裤、赭色头发小帽,拉绳
+ const bx = -380, sw = Math.sin(t * 7) * 20;
+ [0, 3.1].forEach((ph, i) => { const s2 = Math.sin(t * 7 + ph) * 22; M.flat(c, smooth([[bx - 16, -104], [bx + 18, -104], [bx + 14 + s2 * 0.5, -40], [bx + 14 + s2, 22], [bx - 20 + s2, 22], [bx - 12 + s2 * 0.5, -40]]), i ? '#1d2a52' : '#2f3f7a', { lw: 6, seed: 70 + i, n: 8, line: LINE, bounds: [bx - 30, -104, 60, 130] }); });
+ M.flat(c, smooth([[bx - 46, -270], [bx + 4, -290], [bx + 48, -250], [bx + 56, -96], [bx - 54, -96]]), '#2f5f9a', { streak: 1.3, vari: 16, lw: 7, seed: 71, n: 30, line: LINE, bounds: [bx - 58, -290, 118, 200] });
+ M.flat(c, smooth([[bx - 30, -330], [bx + 10, -352], [bx + 46, -320], [bx + 40, -276], [bx - 8, -262], [bx - 36, -290]]), '#e8b078', { vari: 10, lw: 6, seed: 72, n: 10, line: LINE, bounds: [bx - 40, -352, 90, 90] });
+ M.flat(c, smooth([[bx - 40, -318], [bx - 8, -366], [bx + 40, -352], [bx + 52, -322], [bx + 4, -334]]), '#8a2f24', { vari: 6, lw: 6, seed: 73, n: 8, line: LINE, bounds: [bx - 44, -368, 100, 50] }); // 红帽
+ c.strokeStyle = LINE; c.lineWidth = 4.5; c.beginPath(); c.moveTo(bx - 22, -312); c.quadraticCurveTo(bx - 14, -306, bx - 6, -312); c.stroke(); // 眼
+ c.strokeStyle = LINE; c.lineWidth = 6; c.beginPath(); c.moveTo(bx - 44, -230); c.quadraticCurveTo(bx - 120, -170, bx - 90, -150 + sw * 0.3); c.stroke(); // 左臂向前
+ c.lineWidth = 4; c.beginPath(); c.moveTo(bx + 40, -214 + sw * 0.2); c.quadraticCurveTo(-60, -100, -186, -190); c.stroke(); // 绳从男孩右手到羊颈
+ c.restore();
+ }
+ function draw(c, lt) {
+ if (!layer) build();
+ const t = clamp(lt, 0, 6);
+ c.save(); c.translate(W, 0); c.scale(-1, 1); // 水平镜像:不复刻名作的左右布局
+ c.drawImage(layer, 0, 0);
+ leaves(c, t); boyGoat(c, t);
+ // 前景妇人:被画框裁掉(脚在画外),两个并排朝右,一个在最左背对
+ woman(c, 230, 1190 + Math.sin(t * 1.4) * 2, 1.0, t, 100, 0.2, true);
+ woman(c, 560, 1250, 0.86, t, 200, 0.5, false);
+ woman(c, 820, 1310, 0.72, t, 300, 0.3, false);
+ c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/49_chagall.js b/scripts/engine/scenes/49_chagall.js
new file mode 100644
index 0000000..8df4273
--- /dev/null
+++ b/scripts/engine/scenes/49_chagall.js
@@ -0,0 +1,60 @@
+// Original scene; fixed pigment seed, continuous object motion, arbitrary-seek safe.
+SCENES['49_chagall'] = (() => {
+ const W=1920,H=1080,TAU=Math.PI*2;
+ const rng=(seed)=>()=>{seed=(Math.imul(seed,1664525)+1013904223)>>>0;return seed/4294967296;};
+ const canvas=(w=W,h=H)=>{const a=document.createElement('canvas');a.width=w;a.height=h;return a;};
+ const poly=(g,pts,col)=>{g.fillStyle=col;g.beginPath();pts.forEach((p,i)=>i?g.lineTo(...p):g.moveTo(...p));g.closePath();g.fill();};
+ const shape=(g,d,col,stroke=null,width=2)=>{const p=new Path2D(d);g.fillStyle=col;g.fill(p);if(stroke){g.strokeStyle=stroke;g.lineWidth=width;g.stroke(p);}return p;};
+ const oval=(g,x,y,rx,ry,col,a=0)=>{g.fillStyle=col;g.beginPath();g.ellipse(x,y,rx,ry,a,0,TAU);g.fill();};
+ const line=(g,pts,col,w=2)=>{g.strokeStyle=col;g.lineWidth=w;g.lineCap='round';g.beginPath();pts.forEach((p,i)=>i?g.lineTo(...p):g.moveTo(...p));g.stroke();};
+ function paint(src,seed,cell,len,angle,amount=17){
+ const out=canvas(src.width,src.height),g=out.getContext('2d'),s=src.getContext('2d',{willReadFrequently:true}),ww=src.width,hh=src.height,data=s.getImageData(0,0,ww,hh).data,r=rng(seed);
+ g.drawImage(src,0,0);g.lineCap='butt';
+ for(let yy=0;yy<hh+cell;yy+=cell)for(let xx=0;xx<ww+cell;xx+=cell){
+ const x=xx+(r()-.5)*cell*1.8,y=yy+(r()-.5)*cell*1.8,ix=Math.min(ww-1,Math.max(0,x|0)),iy=Math.min(hh-1,Math.max(0,y|0)),i=(iy*ww+ix)*4;if(data[i+3]<200)continue;
+ const a=angle(x,y)+(r()-.5)*.45,l=len*(.5+r()),q=(r()-.5)*amount,rr=data[i]+q,gg=data[i+1]+q*.8,bb=data[i+2]+q*.65;
+ g.strokeStyle=`rgba(${rr|0},${gg|0},${bb|0},.68)`;g.lineWidth=cell*(.55+r()*.65);g.beginPath();g.moveTo(x-Math.cos(a)*l/2,y-Math.sin(a)*l/2);g.quadraticCurveTo(x,y+(r()-.5)*3,x+Math.cos(a)*l/2,y+Math.sin(a)*l/2);g.stroke();
+ if(r()<.22){g.strokeStyle=`rgba(${(rr+17)|0},${(gg+15)|0},${(bb+10)|0},.3)`;g.lineWidth=.7;g.stroke();}
+ }
+ // Fine weave remains stationary in the object coordinate system.
+ g.globalAlpha=.035;g.strokeStyle='#fff4d6';g.lineWidth=.6;for(let y=1;y<hh;y+=3){g.beginPath();g.moveTo(0,y);g.lineTo(ww,y);g.stroke();}g.globalAlpha=1;return out;
+ }
+ let bg,bouquet,caseBase,lid,letter;
+ function house(g,x,y,w,h,a,wall,roof){g.save();g.translate(x,y);g.rotate(a);shape(g,`M${-w/2} 0 L${-w/2} ${-h} L${w/2} ${-h-8} L${w/2} 0Z`,wall,'#3c426c',3);shape(g,`M${-w/2-15} ${-h} L-4 ${-h-w*.55} L${w/2+18} ${-h-7}Z`,roof,'#54405d',3);const n=w>140?3:2;for(let j=0;j<2;j++)for(let i=0;i<n;i++){const xx=-w/2+18+i*(w-32)/n,yy=-h+24+j*(h-36)/2;g.fillStyle=j%2?'#e2cb8a':'#a1c8bf';g.fillRect(xx,yy,w/n*.38,h*.19);line(g,[[xx+w/n*.18,yy],[xx+w/n*.18,yy+h*.19]],'#78616d',2);}line(g,[[-w/2+3,-h+5],[-w/2+3,-5]],'#b8c4b4',2);g.restore();}
+ function init(){if(bg)return;const a=canvas(),g=a.getContext('2d',{willReadFrequently:true}),r=rng(491);
+ let gr=g.createLinearGradient(0,0,1700,1000);gr.addColorStop(0,'#153f81');gr.addColorStop(.45,'#2a4a93');gr.addColorStop(1,'#66517e');g.fillStyle=gr;g.fillRect(0,0,W,H);
+ // Translucent emotional colour zones, full of stationary dry pigment.
+ shape(g,'M0 0 L770 0 Q650 230 791 482 Q387 463 0 870Z','#224f8b');shape(g,'M1323 0 L1920 0 L1920 666 Q1590 587 1438 358 Q1263 230 1323 0Z','#4d7d8555');shape(g,'M0 857 Q380 719 751 848 Q1098 995 1455 769 Q1700 608 1920 764 L1920 1080 L0 1080Z','#625480');
+ for(let i=0;i<18000;i++){const x=r()*W,y=r()*H,aa=r()*TAU;line(g,[[x,y],[x+Math.cos(aa)*(3+r()*23),y+Math.sin(aa)*(3+r()*23)]],['#7d93b31b','#142d681a','#596eae22','#b381a419'][i%4],1+r()*5);}
+ oval(g,1547,185,80,87,'#c9d6ac',-.15);shape(g,'M1536 99 Q1460 159 1524 242 Q1465 220 1465 165 Q1472 115 1536 99Z','#8fbdab');
+ for(let i=0;i<120;i++){const x=60+r()*1800,y=35+r()*580;oval(g,x,y,1+r()*2,1+r()*2,['#c7d3bb88','#d4b78b77','#8cc2c0aa'][i%3]);}
+ // A street bends upward into remembered architecture; each roof has a different axis.
+ for(let i=0;i<9;i++){const x=890+i*122,y=1000-Math.sin(i*.35)*170;house(g,x,y,116+r()*62,140+r()*90,-.12+i*.07,['#73918d','#b9a1a0','#8b95af','#b29a82'][i%4],['#9a5365','#c66e6d','#597d91'][i%3]);}
+ house(g,1535,561,268,229,-.34,'#a2bdaf','#b95369');house(g,1840,409,179,170,.28,'#96b6aa','#9d5d77');
+ // A door hangs in memory above its own pavement; no borrowed character symbols.
+ shape(g,'M1140 719 L1165 477 L1297 485 L1283 735Z','#517993','#283e6b',4);shape(g,'M1160 704 L1178 491 L1282 498 L1272 716Z','#87a2a3');shape(g,'M1193 689 L1195 511 L1267 510 L1257 702Z','#d5b998');oval(g,1244,613,4,5,'#755e72');
+ // Fine chalk/pigment traces do not move independently of the houses.
+ line(g,[[1010,1040],[1168,930],[1430,928],[1628,879],[1920,972]],'#a69ea155',4);
+ for(let i=0;i<60;i++){let x=850+r()*1060,y=880+r()*200;line(g,[[x,y],[x+8+r()*26,y-8]],['#9e8b9f77','#b4a8a966','#574b7a66'][i%3],2);}
+ bg=paint(a,4901,6,19,(x,y)=>y>800?-.2:Math.sin(x*.003+y*.004)*.8,16);
+ const b=canvas(700,900),q=b.getContext('2d',{willReadFrequently:true}),rr=rng(494);
+ // An oversized bouquet is the memory of a garden, distinct from literal village scale.
+ const flowers=[[195,240,67,'#d7b7c3'],[382,127,92,'#b85e86'],[501,334,74,'#e8cfb5'],[268,440,74,'#bd6387'],[419,464,63,'#b4ccd0'],[125,416,61,'#e1c9bf']];
+ for(const [x,y,sz,col] of flowers){line(q,[[341,885],[329+(x-330)*.3,610],[x,y]],'#668b8a',7);line(q,[[342,881],[332+(x-330)*.3,610],[x+4,y]],'#96a497',2);for(let j=0;j<11;j++){const aa=j*TAU/11+rr()*.25,rx=x+Math.cos(aa)*sz*.48,ry=y+Math.sin(aa)*sz*.43;oval(q,rx,ry,sz*(.3+rr()*.2),sz*(.18+rr()*.17),col,aa);line(q,[[x,y],[rx+Math.cos(aa)*sz*.2,ry+Math.sin(aa)*sz*.2]],'#f0d7c23c',2);}oval(q,x,y,sz*.2,sz*.17,'#a78568');for(let k=0;k<30;k++){const aa=rr()*TAU,ra=rr()*sz*.2;oval(q,x+Math.cos(aa)*ra,y+Math.sin(aa)*ra,2,2,k%2?'#dec89d':'#706b76');}}
+ for(let i=0;i<18;i++){const y=520+i*18,x=330+Math.sin(i*1.4)*60,dir=i%2?-1:1;shape(q,`M${x} ${y} Q${x+dir*105} ${y-83} ${x+dir*104} ${y-26} Q${x+dir*72} ${y+29} ${x} ${y}Z`,['#567d80','#7c9d92','#3e7079'][i%3]);line(q,[[x,y],[x+dir*87,y-34]],'#99b09b',2);}
+ bouquet=paint(b,4904,4,12,(x,y)=>Math.atan2(y-450,x-335)+.6,17);
+ const cb=canvas(640,260),v=cb.getContext('2d',{willReadFrequently:true});shape(v,'M16 43 Q310 20 610 54 L626 194 Q327 246 30 197Z','#7b4f62','#463e63',5);shape(v,'M25 49 Q316 27 600 59 L586 106 Q311 156 40 105Z','#b88f85');shape(v,'M36 57 Q316 40 590 68 L577 94 Q310 134 49 98Z','#524763');for(const x of [116,486]){shape(v,`M${x} 104 L${x+29} 105 L${x+37} 209 L${x+8} 213Z`,'#bba18d');g.fillStyle='#fff';}shape(v,'M266 174 Q272 143 355 154 L362 183 L347 185 L344 168 L283 167 L281 184Z','#b6a28a');for(let i=0;i<100;i++){const xx=45+rr()*540,yy=123+rr()*68;line(v,[[xx,yy],[xx+4+rr()*12,yy]],'#bd8f801f',2);}caseBase=paint(cb,4905,4,11,()=>.05,12);
+ const ld=canvas(640,330),z=ld.getContext('2d',{willReadFrequently:true});shape(z,'M25 300 L42 38 Q318 0 590 40 L612 303Z','#976c79','#453f66',5);shape(z,'M45 286 L58 55 Q317 20 575 56 L593 287Z','#b89a98');shape(z,'M65 272 L74 70 Q317 41 560 70 L576 271Z','#b4a2a5');for(let j=0;j<12;j++)line(z,[[75,78+j*16],[562,77+j*16]],'#897b911f',3);shape(z,'M159 104 L482 109 L478 228 L165 233Z','#a58297','#c6b0a9',3);shape(z,'M215 118 L428 127 L420 211 L211 202Z','#c2c5b2');shape(z,'M213 179 L259 151 L301 168 L337 146 L423 181 L420 211 L211 202Z','#788f9c');shape(z,'M213 190 Q292 169 420 192 L420 211 L211 202Z','#94ac92');for(let j=0;j<30;j++){line(z,[[165+j*10,110],[168+j*10,114]],'#d8c0b0',1);line(z,[[165+j*10,226],[168+j*10,230]],'#d8c0b0',1);}lid=paint(ld,4906,4,12,()=>0,12);
+ const e=canvas(118,86),u=e.getContext('2d',{willReadFrequently:true});shape(u,'M5 9 L111 3 L116 76 L9 82Z','#dfc9ad','#ab8996',1.5);line(u,[[7,10],[61,46],[109,5]],'#9c8c98',2);line(u,[[10,80],[47,39]],'#baa8a3',1.5);line(u,[[113,76],[74,39]],'#baa8a3',1.5);letter=paint(e,4907,2.8,7,()=>.1,9);
+ }
+ function pos(p){const u=1-p;return [u*u*u*530+3*u*u*p*880+3*u*p*p*900+p*p*p*1255,u*u*u*890+3*u*u*p*200+3*u*p*p*170+p*p*p*575];}
+ return {draw(c,lt){init();const t=Math.max(0,lt);c.drawImage(bg,0,0);
+ // The bouquet grows out of the open case as its lid lifts, then breathes in the wind.
+ const open=.56+.32*(.5-.5*Math.cos(Math.min(t/2.2,1)*Math.PI));c.save();c.translate(255,920);c.transform(1,-.08,-.13,open,0,0);c.drawImage(lid,0,-300);c.restore();
+ c.save();c.translate(625,1000);c.rotate(-.14+Math.sin(t*.75)*.016);c.scale(.94,.94);c.drawImage(bouquet,-350,-890);c.restore();
+ for(let i=0;i<7;i++){const p=(t*.135+i/7)%1,[x,y]=pos(p),sc=.48+Math.sin(p*Math.PI)*.32;c.save();c.translate(x,y);c.rotate(-.35+Math.sin(p*9+i)*.5);c.scale(sc,sc);c.drawImage(letter,-59,-43);c.restore();}
+ c.save();c.translate(258,877);c.rotate(-.07);c.drawImage(caseBase,0,0);c.restore();
+ // Petals are independent light fragments; their motion never re-seeds the canvas.
+ for(let i=0;i<11;i++){const p=(t*.1+i*.091)%1,xx=590+p*570+Math.sin(p*7+i)*28,yy=370+p*540;oval(c,xx,yy,5+i%3*2,2.5,['#d9b1c6','#bca5c2','#e5ccbd'][i%3],p*5+i);}
+ }};
+})();
diff --git a/scripts/engine/scenes/50_ma_yuan.js b/scripts/engine/scenes/50_ma_yuan.js
new file mode 100644
index 0000000..f23f62f
--- /dev/null
+++ b/scripts/engine/scenes/50_ma_yuan.js
@@ -0,0 +1,131 @@
+// 马远(南宋院体,「一角」构图):绢底泛金、重心压在左下一角、斧劈皴+大片留白、垂柳长枝、渺小的人看向空处。
+// 题材(新构图):雨后,书生立在岸角老柳下,风把柳枝吹向水面,一只小船在远处雾里。
+// 原作锚定(fetch_reference.py 实拉并核对为三幅不同的马远作品:《山径春行》《月下赏梅》《华灯侍宴图》):绢 #c9a65a 偏金褐、墨分五色(焦/浓/重/淡/清)、
+// 岩石=短促侧锋斧劈(宽扁笔,边硬面湿)、枝干=顿挫的线、垂条=细而长的淡墨、远山=清墨渲而无轮廓、人=极小、一笔衣纹。
+// 管线:绢(缓存)→ 远山渲染(缓存)→ 岩石斧劈(缓存)→ 老柳干(缓存)→ 动态:柳条摆(逐条毛笔)、书生、舟、鸟、水纹 → 绢纹相乘罩一遍。
+SCENES['50_ma_yuan'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ const INK = [22, 24, 22];
+ let layer;
+ const silk = () => M.silk('mayuan', { base: '#bfa46c', seed: 4, warp: 0.55, vig: 0.62, fleck: 2400 });
+
+ function wash(g, poly, a0, a1, y0, y1, blur) { // 清墨渲:上浓下淡的渐变面,无轮廓,边缘糊
+ g.save(); g.filter = `blur(${blur}px)`; const gr = g.createLinearGradient(0, y0, 0, y1); gr.addColorStop(0, `rgba(60,62,56,${a0})`); gr.addColorStop(1, `rgba(60,62,56,${a1})`);
+ g.fillStyle = gr; g.beginPath(); poly.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.closePath(); g.fill(); g.restore();
+ }
+ function mountains(g) {
+ wash(g, [[1020, 560], [1130, 440], [1210, 480], [1330, 360], [1440, 470], [1560, 410], [1700, 520], [1920, 470], [1920, 640], [1020, 640]], 0.26, 0.0, 360, 620, 9);
+ wash(g, [[1250, 600], [1380, 520], [1470, 560], [1600, 500], [1760, 580], [1920, 560], [1920, 680], [1250, 680]], 0.16, 0.0, 500, 680, 7);
+ g.save(); g.translate(1420, 610); g.scale(1, 0.16); const mg = g.createRadialGradient(0, 0, 0, 0, 0, 760); mg.addColorStop(0, 'rgba(226,210,160,.55)'); mg.addColorStop(1, 'rgba(226,210,160,0)'); g.fillStyle = mg; g.beginPath(); g.arc(0, 0, 760, 0, TAU); g.fill(); g.restore(); // 雾带压住山脚
+ }
+ // 斧劈岩:多边形轮廓作剪裁,里面按岩势方向排宽扁侧锋;先渲后皴,最后硬边
+ function rock(g, poly, { seed = 1, ang = 0.95, n = 90, wmin = 12, wmax = 30, wash0 = 0.34 } = {}) {
+ const r = rng(seed), xs = poly.map(p => p[0]), ys = poly.map(p => p[1]), bx = Math.min(...xs), by = Math.min(...ys), bw = Math.max(...xs) - bx, bh = Math.max(...ys) - by;
+ const path = new Path2D(); poly.forEach((p, i) => i ? path.lineTo(p[0], p[1]) : path.moveTo(p[0], p[1])); path.closePath();
+ g.save(); g.clip(path);
+ const gr = g.createLinearGradient(0, by, 0, by + bh); gr.addColorStop(0, `rgba(70,66,52,${wash0})`); gr.addColorStop(0.6, `rgba(60,58,46,${wash0 * 0.7})`); gr.addColorStop(1, `rgba(36,36,30,${wash0 * 1.5})`); g.fillStyle = gr; g.fillRect(bx, by, bw, bh);
+ for (let i = 0; i < n; i++) { // 斧劈:短、宽、起笔重收笔飞白,沿 ang 方向(用毛笔库;楔形多边形读成箭头,试过,弃用)
+ const x = bx + r() * bw, y = by + r() * bh, L = 40 + r() * 90, a = ang + (r() - .5) * 0.35, w = lerp(wmin, wmax, r()) * 0.55;
+ const q = (y - by) / bh;
+ P.brush(g, [[x, y], [x + Math.cos(a) * L * 0.5, y + Math.sin(a) * L * 0.5 + (r() - .5) * 8], [x + Math.cos(a) * L, y + Math.sin(a) * L]], { w, tone: 0.1 + q * 0.26 + r() * 0.08, dry: 0.85, seed: seed * 100 + i, bristles: 12, head: 0.05, tail: 0.5, col: INK });
+ }
+ for (let i = 0; i < n * 0.8; i++) { // 硬皴:细、直、顿挫,勾出斧劈的棱
+ const x = bx + r() * bw, y = by + r() * bh, L = 26 + r() * 60, a = ang + (r() - .5) * 0.25;
+ P.brush(g, [[x, y], [x + Math.cos(a) * L, y + Math.sin(a) * L]], { w: 2.6 + r() * 3, tone: 0.5 + r() * 0.3, dry: 0.5, seed: seed * 77 + i, bristles: 3, head: 0.05, tail: 0.5, col: INK });
+ }
+ g.restore();
+ // 轮廓:只描受光棱和水边,断续,一笔一顿
+ for (let i = 0; i < poly.length; i++) { const A = poly[i], B = poly[(i + 1) % poly.length]; if (r() < 0.25) continue;
+ P.brush(g, [A, [lerp(A[0], B[0], .5) + (r() - .5) * 8, lerp(A[1], B[1], .5) + (r() - .5) * 8], B], { w: 6 + r() * 6, tone: 0.62, dry: 0.5, seed: seed * 31 + i, bristles: 6, head: 0.1, tail: 0.3, col: INK }); }
+ }
+ // 干:从岸角向上斜出,两折,分叉
+ const TRUNK = [[250, 1000], [210, 820], [260, 640], [350, 500], [470, 410], [610, 340]];
+ const LIMBS = [ // 长枝的锚点(沿干的第 i 点)与走势:向右、向下垂
+ { a: [350, 500], p: [[350, 500], [520, 440], [720, 470], [890, 560]], tw: 12, ph: 0.0 },
+ { a: [470, 410], p: [[470, 410], [650, 350], [880, 380], [1080, 480]], tw: 15, ph: 1.4 },
+ { a: [610, 340], p: [[610, 340], [790, 300], [1010, 330], [1200, 420]], tw: 14, ph: 2.6 },
+ { a: [260, 640], p: [[260, 640], [400, 620], [560, 670], [690, 760]], tw: 9, ph: 3.7 },
+ ];
+ function build() {
+ layer = P.canvas(); const g = layer.getContext('2d');
+ g.drawImage(silk(), 0, 0); mountains(g);
+ // 近岸岩:左下一角,前高后低两三块,错落
+ rock(g, [[0, 1080], [0, 700], [90, 640], [210, 690], [330, 800], [470, 860], [620, 940], [800, 1010], [900, 1080]], { seed: 3, ang: 1.0, n: 130, wmin: 14, wmax: 34 });
+ rock(g, [[420, 880], [520, 820], [640, 850], [760, 930], [980, 1000], [1120, 1080], [700, 1080]], { seed: 8, ang: 0.8, n: 70, wmin: 10, wmax: 24, wash0: 0.28 });
+ rock(g, [[1480, 1080], [1560, 1010], [1700, 990], [1860, 1040], [1920, 1080]], { seed: 15, ang: 2.2, n: 40, wmin: 8, wmax: 18, wash0: 0.22 }); // 对岸一撮(右下,平衡)
+ // 老干:一气呵成的粗线(分段画读成竹节,试过,弃用),再补树皮的顿挫短笔
+ P.brush(g, TRUNK, { w: 54, tone: 0.84, dry: 0.5, seed: 21, bristles: 16, head: 0.04, tail: 0.5, col: INK });
+ P.brush(g, TRUNK.map(p => [p[0] + 14, p[1] + 4]), { w: 20, tone: 0.55, dry: 0.8, seed: 22, bristles: 8, col: INK });
+ for (let i = 0; i < 40; i++) { const r = rng(40 + i), q = r(), y = lerp(990, 420, q), x = lerp(236, 480, 1 - q) + (r() - .5) * 46, h = 20 + r() * 40;
+ P.brush(g, [[x - 5, y], [x + 2, y + h * 0.5], [x + 6, y + h]], { w: 5 + r() * 5, tone: 0.3 + r() * 0.3, dry: 0.8, seed: 50 + i, bristles: 4, col: INK }); }
+ // 钤印
+ g.fillStyle = 'rgba(176,40,34,.88)'; g.fillRect(1760, 880, 46, 46); g.fillStyle = 'rgba(201,168,94,.9)'; g.fillRect(1768, 888, 14, 14); g.fillRect(1786, 906, 14, 14); g.fillRect(1768, 910, 8, 10);
+ }
+ function willow(c, t) {
+ LIMBS.forEach((L, li) => {
+ const sw = (k) => Math.sin(t * 1.5 + L.ph + k * 1.1) * (10 + k * 14) + Math.sin(t * 3.1 + L.ph * 2) * 3 * k;
+ const pts = L.p.map((p, k) => [p[0] + (k ? sw(k) * 0.6 : 0), p[1] + (k ? Math.sin(t * 1.7 + L.ph + k) * 6 * k : 0)]);
+ P.brush(c, pts, { w: L.tw, tone: 0.8, dry: 0.5, seed: 90 + li, bristles: 8, head: 0.04, tail: 0.5, col: INK });
+ // 垂条:沿枝取点,每条下垂,末端随风向右
+ const D = KIT.resample(KIT.densify(pts, 5), 34), n = D.length;
+ for (let k = 2; k < n; k++) {
+ const [x, y] = D[k], r = rng(li * 500 + k * 13);
+ if (r() < 0.3) continue; // 成簇:随机缺条,留出透气的缝
+ const cnt = 1 + (r() * 3 | 0);
+ for (let m = 0; m < cnt; m++) {
+ const x0 = x + (r() - .5) * 22, len = 40 + Math.pow(r(), 1.6) * 250, ph = r() * 6, wind = (Math.sin(t * 1.7 + ph + k * 0.35) * 0.5 + 0.5) * 38 + 8;
+ const bend = (r() - 0.3) * 40, tw = [[x0, y], [x0 + wind * 0.15 + bend * 0.3, y + len * 0.35], [x0 + wind * 0.5 + bend, y + len * 0.7], [x0 + wind + bend * 0.8, y + len]];
+ P.brush(c, tw, { w: 1.8 + r() * 1.8, tone: 0.18 + r() * 0.34, dry: 0.5, seed: li * 700 + k * 5 + m, bristles: 3, head: 0.05, tail: 0.65, col: INK });
+ if (r() < 0.35) P.leaf(c, tw[3][0], tw[3][1], 1.35 + Math.sin(t * 2.2 + ph) * 0.2, 14 + r() * 10, 4, 0.45, INK);
+ }
+ }
+ });
+ }
+ function scholar(c, t) { // 立在岸角看向空处:背影,宽袖,高冠;一笔衣纹,袍不填满(留绢)
+ const x = 760, y = 972, bob = Math.sin(t * 1.3) * 1.0, fl = Math.sin(t * 2.1) * 5, look = ss(0.5, 3.5, t);
+ c.save(); c.translate(x, y + bob);
+ c.fillStyle = 'rgba(236,224,184,.5)';
+ c.beginPath(); c.moveTo(-14, -128); c.quadraticCurveTo(-34, -60, -30, 0); c.lineTo(26, 0); c.quadraticCurveTo(28 + fl * 0.4, -64, 14, -128); c.closePath(); c.fill();
+ P.brush(c, [[-16, -126], [-34, -56], [-30, 0]], { w: 4, tone: 0.85, dry: 0.2, seed: 201, bristles: 4, col: INK });
+ P.brush(c, [[14, -126], [28, -60], [26 + fl * 0.5, 0]], { w: 3.4, tone: 0.75, dry: 0.3, seed: 202, bristles: 4, col: INK });
+ P.brush(c, [[-30, 2], [-2, 8], [26, 2]], { w: 3.6, tone: 0.6, dry: 0.3, seed: 203, bristles: 3, col: INK });
+ P.brush(c, [[-4, -120], [-8, -70], [0, -20]], { w: 2.6, tone: 0.5, dry: 0.5, seed: 204, bristles: 3, col: INK });
+ // 右袖抬起指向远处(随 look 抬起)
+ const ah = lerp(-30, -96, look);
+ c.fillStyle = 'rgba(236,224,184,.5)'; c.beginPath(); c.moveTo(14, -118); c.quadraticCurveTo(52, ah + 10, 72 + fl * 0.4, ah); c.quadraticCurveTo(54, ah + 30, 20, -88); c.closePath(); c.fill();
+ P.brush(c, [[14, -118], [52, ah + 8], [72 + fl * 0.4, ah]], { w: 3.4, tone: 0.8, dry: 0.3, seed: 205, bristles: 4, col: INK });
+ P.brush(c, [[20, -88], [54, ah + 30], [72 + fl * 0.4, ah]], { w: 2.6, tone: 0.6, dry: 0.3, seed: 206, bristles: 3, col: INK });
+ c.fillStyle = 'rgba(40,38,34,.95)'; c.beginPath(); c.ellipse(-2, -142, 14, 15, 0, 0, TAU); c.fill(); // 头
+ c.beginPath(); c.moveTo(-14, -150); c.lineTo(-10, -178); c.lineTo(10, -178); c.lineTo(14, -150); c.closePath(); c.fill(); // 高冠
+ P.brush(c, [[8, -168], [34 + fl, -164], [52 + fl * 1.4, -140]], { w: 3.6, tone: 0.8, dry: 0.3, seed: 207, bristles: 3, col: INK }); // 冠带随风
+ c.restore();
+ }
+ function boat(c, t) { // 远处小舟:一笔船身+一笔蓑笠人,随水轻荡
+ const x = lerp(1620, 1420, ss(0, 6, t)), y = 790 + Math.sin(t * 1.1) * 4, r2 = Math.sin(t * 1.1) * 0.02;
+ c.save(); c.translate(x, y); c.rotate(r2); c.globalAlpha = 0.9;
+ P.brush(c, [[-60, 0], [-20, 12], [30, 10], [74, -6]], { w: 11, tone: 0.78, dry: 0.45, seed: 301, bristles: 6, head: 0.1, tail: 0.3, col: INK });
+ c.fillStyle = 'rgba(40,40,34,.85)'; c.beginPath(); c.moveTo(-6, -4); c.quadraticCurveTo(-6, -40, 4, -48); c.quadraticCurveTo(14, -40, 12, -4); c.fill();
+ P.brush(c, [[-18, -44], [4, -56], [26, -44]], { w: 6, tone: 0.8, dry: 0.3, seed: 302, bristles: 4, col: INK });
+ P.brush(c, [[14, -30], [40, -10], [66, 22]], { w: 2.4, tone: 0.7, dry: 0.2, seed: 303, bristles: 2, col: INK }); // 篙
+ c.restore();
+ c.save(); c.globalAlpha = 0.28; P.brush(c, [[x - 70, y + 22], [x - 10, y + 26], [x + 80, y + 22]], { w: 4, tone: 0.5, dry: 0.8, seed: 304, bristles: 3, col: INK }); c.restore();
+ }
+ function bird(c, t) {
+ const u = ss(0.3, 5.7, t), x = lerp(1860, 1180, u), y = 250 + Math.sin(u * 7) * 26 - u * 40, f = Math.sin(t * 9) * 12;
+ c.save(); c.translate(x, y); P.brush(c, [[-22, -f * 0.4], [-6, -8 - f], [0, 0]], { w: 5, tone: 0.8, dry: 0.2, seed: 401, bristles: 3, col: INK }); P.brush(c, [[22, -f * 0.4], [6, -8 - f], [0, 0]], { w: 5, tone: 0.8, dry: 0.2, seed: 402, bristles: 3, col: INK });
+ c.fillStyle = 'rgba(30,30,28,.85)'; c.beginPath(); c.ellipse(0, 2, 7, 4, 0, 0, TAU); c.fill(); c.restore();
+ }
+ function ripples(c, t) { // 水面只有几道极淡的横线,加岸边涟漪
+ c.save(); for (let i = 0; i < 9; i++) { const y = 700 + i * 36, x0 = 980 + (i % 3) * 170 + Math.sin(t * 0.6 + i) * 18; c.strokeStyle = `rgba(58,60,52,${0.05 + i * 0.008})`; c.lineWidth = 1.4; c.beginPath(); c.moveTo(x0, y); c.bezierCurveTo(x0 + 60, y - 2, x0 + 150, y + 2, x0 + 230, y); c.stroke(); }
+ for (let k = 0; k < 3; k++) { const q = ((t * 0.28 + k / 3) % 1); c.strokeStyle = `rgba(58,60,52,${(1 - q) * 0.2})`; c.lineWidth = 1.4; c.beginPath(); c.ellipse(1010, 905, 24 + q * 150, 3 + q * 15, 0, 0, TAU); c.stroke(); }
+ c.restore();
+ }
+ function draw(c, lt) {
+ if (!layer) build();
+ const t = clamp(lt, 0, 6);
+ c.drawImage(layer, 0, 0);
+ ripples(c, t); boat(c, t); bird(c, t); willow(c, t); scholar(c, t);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.35; c.drawImage(silk(), 0, 0); c.restore(); // 绢纹罩在墨上:墨是渗进绢里的
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/51_persian_miniature.js b/scripts/engine/scenes/51_persian_miniature.js
new file mode 100644
index 0000000..1be77ed
--- /dev/null
+++ b/scripts/engine/scenes/51_persian_miniature.js
@@ -0,0 +1,149 @@
+// 波斯细密画(赫拉特/萨法维):没有透视收束,地面像一张竖起的挂毯;建筑被切开让人看见里面;每一寸都有纹样;金、青金石蓝、朱、孔雀绿;文字块进画。
+// 题材(新构图):庭院里的汲水轮——一位园丁摇轮,水顺渠流进八角水池,旁边两人在亭下读书;上方书页式文字块。
+// 原作锚定(fetch_reference.py:赫拉特 Bustan《尤素福与祖莱哈》、花园浴女页、沙赫塔赫马斯普《列王纪》页):
+// 纸/羊皮 #d9bf88、青金石 #1f4f8f、朱 #b7372b、孔雀绿 #2a8a7a、金 #d6a93c、玫粉 #d98a7a;砖红/青瓷砖满铺几何;
+// 树=平涂树干+点叶团+花;人=小、侧身、大头巾、袍上暗纹;地面一律「俯视平铺」,远处靠叠高不靠缩小。
+// 管线:纸底(缓存)→ 外框金线+蓝带 → 文字块 → 建筑切面(砖+瓷砖满铺)→ 庭院平铺地面(草+花点)→ 水池(八角,几何瓷砖边)
+// → 树 → 动态:汲水轮转、水沿渠流、人物动作、花瓣飘、水纹 → 极薄的纸纤维相乘。
+SCENES['51_persian_miniature'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, M = MEDIUM, TAU = Math.PI * 2;
+ const C = { paper: '#dcc38c', lapis: '#1f4f8f', lapis2: '#2f6fb0', red: '#b7372b', teal: '#2a8a7a', gold: '#d6a93c', rose: '#d98a7a', brick: '#c0643f', cream: '#efe0b4', green: '#6f9a4a', dgreen: '#3f6e3a', ink: '#2b2118' };
+ let layer;
+ const poly = (pts, close = true) => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); if (close) p.closePath(); return p; };
+ const fillPoly = (g, pts, col, o = {}) => { g.fillStyle = col; g.fill(poly(pts)); if (o.line !== false) { g.strokeStyle = o.line || C.ink; g.lineWidth = o.lw || 2.4; g.stroke(poly(pts)); } };
+ // 满铺几何:星/十字瓷砖,周期取模,两色交替
+ function tiles(g, x, y, w, h, size, a, b, c2, seed = 1) {
+ g.save(); g.beginPath(); g.rect(x, y, w, h); g.clip(); g.fillStyle = a; g.fillRect(x, y, w, h);
+ const r = rng(seed);
+ for (let j = 0; y + j * size < y + h + size; j++) for (let i = 0; x + i * size < x + w + size; i++) {
+ const cx = x + i * size + size / 2, cy = y + j * size + size / 2, k = (i + j) % 2;
+ g.fillStyle = k ? b : c2; g.beginPath(); for (let q = 0; q < 8; q++) { const ang = q / 8 * TAU + Math.PI / 8, rr = q % 2 ? size * 0.2 : size * 0.38; g.lineTo(cx + Math.cos(ang) * rr, cy + Math.sin(ang) * rr); } g.closePath(); g.fill();
+ g.fillStyle = k ? c2 : b; g.beginPath(); g.arc(cx, cy, size * 0.1, 0, TAU); g.fill();
+ }
+ g.strokeStyle = 'rgba(30,24,16,.5)'; g.lineWidth = 1.4; for (let i = 0; i <= w / size + 1; i++) { g.beginPath(); g.moveTo(x + i * size, y); g.lineTo(x + i * size, y + h); g.stroke(); } for (let j = 0; j <= h / size + 1; j++) { g.beginPath(); g.moveTo(x, y + j * size); g.lineTo(x + w, y + j * size); g.stroke(); }
+ g.restore();
+ }
+ function border(g) { // 金线+青金石蓝带+金色细花
+ g.fillStyle = C.lapis; g.fillRect(0, 0, W, H); g.fillStyle = C.gold; g.fillRect(22, 22, W - 44, H - 44); g.fillStyle = C.paper; g.fillRect(30, 30, W - 60, H - 60);
+ g.fillStyle = C.lapis; g.fillRect(44, 44, W - 88, H - 88); g.fillStyle = C.gold; g.fillRect(52, 52, W - 104, H - 104); g.fillStyle = C.paper; g.fillRect(58, 58, W - 116, H - 116);
+ g.fillStyle = 'rgba(214,169,60,.9)'; for (let x = 70; x < W - 70; x += 38) { [34, H - 34].forEach(y => { g.beginPath(); g.arc(x, y, 6, 0, TAU); g.fill(); }); } for (let y = 70; y < H - 70; y += 38) { [34, W - 34].forEach(x => { g.beginPath(); g.arc(x, y, 6, 0, TAU); g.fill(); }); }
+ }
+ function textBlock(g, x, y, w, h) { // 书法文字块:金边朱框内一行行「连笔」——用折线笔画模拟,不写具体字
+ fillPoly(g, [[x, y], [x + w, y], [x + w, y + h], [x, y + h]], '#efe3bd', { lw: 3, line: C.gold });
+ const r = rng(7); g.strokeStyle = C.ink; g.lineCap = 'round'; g.lineWidth = 2.4;
+ for (let row = 0; row < Math.floor(h / 34); row++) { const yy = y + 28 + row * 34; let xx = x + w - 20; g.beginPath(); g.moveTo(xx, yy); while (xx > x + 24) { const st = 8 + r() * 18; xx -= st; g.quadraticCurveTo(xx + st / 2, yy - 8 - r() * 10, xx, yy + (r() - .5) * 6); if (r() < 0.12) { g.moveTo(xx - 10, yy); xx -= 10; } } g.stroke();
+ g.fillStyle = C.red; if (row % 3 === 0) { g.beginPath(); g.arc(x + w - 14, yy - 6, 4, 0, TAU); g.fill(); } }
+ }
+ function build() {
+ layer = P.canvas(); const g = layer.getContext('2d');
+ g.fillStyle = C.paper; g.fillRect(0, 0, W, H); border(g);
+ // 顶部:建筑切面(被切开:里面看得到人)
+ g.save(); g.beginPath(); g.rect(60, 60, W - 120, H - 120); g.clip();
+ // 外墙大面:砖红+瓷砖腰线;门楣蓝釉
+ fillPoly(g, [[900, 60], [1860, 60], [1860, 520], [900, 520]], C.brick, { lw: 3 });
+ for (let y = 80; y < 500; y += 26) { g.strokeStyle = 'rgba(80,30,20,.35)'; g.lineWidth = 1.5; g.beginPath(); g.moveTo(900, y); g.lineTo(1860, y); g.stroke(); for (let x = 900 + ((y / 26) % 2) * 20; x < 1860; x += 40) { g.beginPath(); g.moveTo(x, y); g.lineTo(x, y + 26); g.stroke(); } }
+ tiles(g, 900, 60, 960, 90, 30, C.lapis, C.cream, C.teal, 3);
+ // 切开的房间:亭(拱形开口),里面有地毯、两位读书人
+ const arch = new Path2D(); arch.moveTo(1040, 520); arch.lineTo(1040, 250); arch.quadraticCurveTo(1040, 170, 1260, 170); arch.quadraticCurveTo(1480, 170, 1480, 250); arch.lineTo(1480, 520); arch.closePath();
+ g.fillStyle = C.gold; g.fill(arch); g.save(); g.translate(0, 0); g.scale(1, 1); g.restore();
+ const inner = new Path2D(); inner.moveTo(1060, 520); inner.lineTo(1060, 256); inner.quadraticCurveTo(1060, 192, 1260, 192); inner.quadraticCurveTo(1460, 192, 1460, 256); inner.lineTo(1460, 520); inner.closePath();
+ g.save(); g.clip(inner); tiles(g, 1060, 180, 400, 340, 36, '#e7d6a6', C.lapis2, C.red, 5);
+ // 地毯:红地,边带,中央大八角菱形
+ fillPoly(g, [[1060, 420], [1460, 420], [1460, 520], [1060, 520]], C.red, { lw: 2.4 });
+ for (let x = 1076; x < 1460; x += 34) { g.fillStyle = C.gold; g.beginPath(); g.moveTo(x, 470); g.lineTo(x + 12, 456); g.lineTo(x + 24, 470); g.lineTo(x + 12, 484); g.fill(); }
+ g.restore(); g.strokeStyle = C.ink; g.lineWidth = 3; g.stroke(arch);
+ // 左侧塔楼+窗;右侧小窗格
+ fillPoly(g, [[1520, 150], [1840, 150], [1840, 500], [1520, 500]], C.cream, { lw: 3 }); tiles(g, 1520, 150, 320, 350, 32, C.cream, C.teal, C.lapis, 9);
+ [[1560, 200], [1700, 200], [1560, 340], [1700, 340]].forEach(([x, y]) => { fillPoly(g, [[x, y + 100], [x, y + 40], [x + 20, y], [x + 60, y], [x + 80, y + 40], [x + 80, y + 100]], C.lapis, { lw: 3, line: C.gold }); });
+ g.restore();
+ textBlock(g, 120, 120, 640, 200); textBlock(g, 120, 340, 640, 120);
+ // 下半:庭院平铺地面(竖起的挂毯)
+ g.save(); g.beginPath(); g.rect(60, 520, W - 120, H - 580); g.clip();
+ fillPoly(g, [[60, 520], [W - 60, 520], [W - 60, H - 60], [60, H - 60]], C.green, { line: false });
+ const r = rng(11); for (let i = 0; i < 1400; i++) { const x = 70 + r() * (W - 140), y = 530 + r() * (H - 600), k = r(); g.fillStyle = k < 0.5 ? '#86b05a' : k < 0.8 ? '#4d7c3a' : (r() < 0.5 ? '#f0e6c8' : C.rose); g.beginPath(); g.ellipse(x, y, 3 + r() * 5, 2 + r() * 3, r(), 0, TAU); g.fill(); }
+ // 水渠:从左上角的汲水轮底座流向八角水池,铺青瓷砖,几何边
+ g.lineCap = 'butt'; g.lineJoin = 'round'; [['#2b2118', 78], [C.gold, 72], [C.teal, 58]].forEach(([col, w]) => { g.strokeStyle = col; g.lineWidth = w; g.beginPath(); g.moveTo(260, 670); g.lineTo(790, 670); g.lineTo(930, 800); g.stroke(); });
+ // 八角水池:中央偏右
+ const cx = 1160, cy = 790, R = 230, oct = Array.from({ length: 8 }, (_, k) => [cx + Math.cos(k / 8 * TAU + Math.PI / 8) * R * 1.08, cy + Math.sin(k / 8 * TAU + Math.PI / 8) * R * 0.74]);
+ fillPoly(g, oct.map(p => [cx + (p[0] - cx) * 1.14, cy + (p[1] - cy) * 1.2]), C.gold, { lw: 3 });
+ fillPoly(g, oct.map(p => [cx + (p[0] - cx) * 1.06, cy + (p[1] - cy) * 1.1]), C.lapis, { lw: 3, line: C.gold });
+ fillPoly(g, oct, '#2c7e8a', { lw: 3, line: C.gold });
+ // 周围铺小道:奶油色菱格
+ for (let i = 0; i < 16; i++) { const x = 300 + i * 36, y = 760 + (i % 2) * 14; g.fillStyle = C.cream; g.beginPath(); g.moveTo(x, y); g.lineTo(x + 14, y - 10); g.lineTo(x + 28, y); g.lineTo(x + 14, y + 10); g.fill(); }
+ g.restore();
+ // 树:左右各一,直干+圆叶团+花点+果(树冠超出画面边缘上探,细密画常见)
+ function tree(x, y, hgt, seed, bloom) {
+ g.fillStyle = '#7a4a2a'; g.fillRect(x - 11, y - hgt, 22, hgt); g.strokeStyle = C.ink; g.lineWidth = 2.4; g.strokeRect(x - 11, y - hgt, 22, hgt);
+ const rr = rng(seed); for (let k = 0; k < 9; k++) { const a = rr() * TAU, d = rr() * 70, cx2 = x + Math.cos(a) * d, cy2 = y - hgt - 30 + Math.sin(a) * d * 0.7; g.fillStyle = k % 2 ? C.dgreen : '#4f8a3f'; g.beginPath(); g.ellipse(cx2, cy2, 58, 46, 0, 0, TAU); g.fill(); g.strokeStyle = C.ink; g.lineWidth = 1.8; g.stroke(); }
+ for (let k = 0; k < 40; k++) { const a = rr() * TAU, d = rr() * 100; g.fillStyle = bloom; g.beginPath(); g.arc(x + Math.cos(a) * d, y - hgt - 30 + Math.sin(a) * d * 0.6, 5, 0, TAU); g.fill(); }
+ }
+ tree(140, 720, 220, 31, '#f4d3d0'); tree(1790, 760, 240, 32, '#f4e6a0'); tree(700, 560, 120, 33, '#f4d3d0');
+ }
+ // 汲水轮:转;水斗按周期取模;水沿渠流
+ function wheel(c, t) {
+ const cx = 340, cy = 580, R = 120, a0 = t * 0.8;
+ c.save(); c.translate(cx, cy);
+ c.strokeStyle = C.ink; c.lineWidth = 3; c.fillStyle = '#9a6a3a'; c.beginPath(); c.arc(0, 0, R, 0, TAU); c.arc(0, 0, R - 14, 0, TAU, true); c.fill('evenodd'); c.stroke(); c.beginPath(); c.arc(0, 0, R - 14, 0, TAU); c.stroke();
+ for (let k = 0; k < 12; k++) { const a = a0 + k / 12 * TAU; c.save(); c.rotate(a); c.fillStyle = '#7a4a2a'; c.fillRect(-4, 0, 8, R - 14); c.strokeRect(-4, 0, 8, R - 14); c.fillStyle = C.gold; c.fillRect(-14, R - 6, 28, 16); c.strokeRect(-14, R - 6, 28, 16); c.restore(); }
+ c.fillStyle = C.red; c.beginPath(); c.arc(0, 0, 18, 0, TAU); c.fill(); c.stroke();
+ c.restore();
+ }
+ function water(c, t) {
+ // 渠水:沿折线 (260,670)→(790,670)→(930,800) 的金色小波,向右下流
+ const seg = [[260, 670, 790, 670], [790, 670, 930, 800]], Ls = seg.map(q => Math.hypot(q[2] - q[0], q[3] - q[1])), tot = Ls[0] + Ls[1];
+ for (let i = 0; i < 16; i++) { let d = ((i * tot / 16 + t * 90) % tot), k = d < Ls[0] ? 0 : 1; if (k) d -= Ls[0]; const q = seg[k], u = d / Ls[k], x = lerp(q[0], q[2], u), y = lerp(q[1], q[3], u) + ((i % 3) - 1) * 12;
+ c.strokeStyle = 'rgba(244,224,160,.85)'; c.lineWidth = 2.4; c.beginPath(); c.moveTo(x - 12, y); c.quadraticCurveTo(x, y - 7, x + 12, y); c.stroke(); }
+ // 水池:同心波+金鱼
+ const cx = 1160, cy = 790;
+ c.save(); c.beginPath(); for (let k = 0; k < 8; k++) { const ang = k / 8 * TAU + Math.PI / 8; c.lineTo(cx + Math.cos(ang) * 230 * 1.08, cy + Math.sin(ang) * 230 * 0.74); } c.closePath(); c.clip();
+ for (let i = 0; i < 6; i++) { const q = ((t * 0.35 + i / 6) % 1); c.strokeStyle = `rgba(244,230,180,${(1 - q) * 0.8})`; c.lineWidth = 2.6; c.beginPath(); c.ellipse(cx - 130 + Math.sin(i) * 40, cy - 20, 20 + q * 150, 8 + q * 50, 0, 0, TAU); c.stroke(); }
+ [[0, 1.0, C.red], [2.2, -0.8, C.gold], [4.1, 0.7, C.cream]].forEach(([ph, dir, col], i) => { const a = t * 0.6 * dir + ph, x = cx + Math.cos(a) * 140, y = cy + Math.sin(a) * 70 + 10, ang = Math.atan2(Math.cos(a) * 70 * dir, -Math.sin(a) * 140 * dir);
+ c.save(); c.translate(x, y); c.rotate(ang); c.fillStyle = col; c.strokeStyle = C.ink; c.lineWidth = 2; c.beginPath(); c.ellipse(0, 0, 30, 12, 0, 0, TAU); c.fill(); c.stroke(); c.beginPath(); c.moveTo(-28, 0); c.lineTo(-48, -12 + Math.sin(t * 8 + i) * 4); c.lineTo(-48, 12 + Math.sin(t * 8 + i) * 4); c.closePath(); c.fill(); c.stroke(); c.fillStyle = C.ink; c.beginPath(); c.arc(16, -3, 2.4, 0, TAU); c.fill(); c.restore(); });
+ c.restore();
+ }
+ // 人(萨法维式):修长,头小,高头巾+红色冠杆,束腰长袍下摆外展,腰带垂一端,鞋尖朝前;扁平填色+粗线描边,袍上小花散点。
+ function person(c, x, y, s, face, col, turban, t, o = {}) {
+ c.save(); c.translate(x, y); c.scale(s * face, s); c.lineJoin = 'round'; c.lineCap = 'round'; c.strokeStyle = C.ink; c.lineWidth = 2.6 / s;
+ const bob = o.bob || 0, sw = Math.sin(t * 1.7 + (o.ph || 0)) * 3;
+ // 鞋:尖头
+ c.fillStyle = C.red; [[-14, 0], [16, 0]].forEach(([dx]) => { c.beginPath(); c.moveTo(dx - 9, -4); c.quadraticCurveTo(dx + 10, -10, dx + 24, -2); c.quadraticCurveTo(dx + 12, 5, dx - 9, 4); c.closePath(); c.fill(); c.stroke(); });
+ // 长袍:窄肩 → 束腰 → 下摆外展,前襟交叠一道线
+ c.fillStyle = col; c.beginPath(); c.moveTo(-20, -152 + bob); c.quadraticCurveTo(-26, -118, -18, -96 + bob); c.quadraticCurveTo(-34, -52, -52 + sw, -6); c.quadraticCurveTo(0, 3, 52 + sw, -6); c.quadraticCurveTo(34, -52, 18, -96 + bob); c.quadraticCurveTo(26, -118, 20, -152 + bob); c.closePath(); c.fill(); c.stroke();
+ c.save(); c.clip(); c.fillStyle = 'rgba(244,224,160,.8)'; for (let k = 0; k < 24; k++) { const px = -44 + (k % 6) * 17 + (Math.floor(k / 6) % 2) * 8, py = -140 + Math.floor(k / 6) * 34; c.beginPath(); for (let q = 0; q < 5; q++) { const aa = q / 5 * TAU; c.moveTo(px, py); c.arc(px + Math.cos(aa) * 4.4, py + Math.sin(aa) * 4.4, 2.6, 0, TAU); } c.fill(); }
+ c.strokeStyle = 'rgba(43,33,24,.55)'; c.lineWidth = 1.6; c.beginPath(); c.moveTo(4, -148 + bob); c.quadraticCurveTo(10, -80, 30 + sw, -6); c.stroke(); c.restore();
+ c.strokeStyle = C.ink; c.lineWidth = 2.6 / s; c.strokeStyle = C.gold; c.lineWidth = 4; c.beginPath(); c.moveTo(-52 + sw, -6); c.quadraticCurveTo(0, 3, 52 + sw, -6); c.stroke(); c.strokeStyle = C.ink; c.lineWidth = 2.6 / s;
+ // 腰带+垂端
+ c.fillStyle = C.gold; c.fillRect(-19, -100 + bob * 0.5, 38, 9); c.strokeRect(-19, -100 + bob * 0.5, 38, 9);
+ c.fillStyle = C.cream; c.beginPath(); c.moveTo(10, -92 + bob * 0.5); c.lineTo(22, -60 + sw * 0.4); c.lineTo(10, -64 + sw * 0.4); c.closePath(); c.fill(); c.stroke();
+ // 手臂:默认一只垂袖,另一只抬到胸前持物
+ if (o.arm) o.arm(c, bob); else { c.strokeStyle = col; c.lineWidth = 11; c.beginPath(); c.moveTo(16, -144 + bob); c.lineTo(34, -108 + bob); c.lineTo(22, -90 + bob); c.stroke(); c.strokeStyle = C.ink; c.lineWidth = 2.6 / s; c.fillStyle = '#e8c298'; c.beginPath(); c.arc(22, -88 + bob, 5, 0, TAU); c.fill(); c.stroke(); }
+ // 颈与头:小,3/4,弯眉连成一道,杏仁眼,胡须一线
+ c.fillStyle = '#e8c298'; c.fillRect(-4, -160 + bob, 9, 12);
+ c.beginPath(); c.ellipse(3, -172 + bob, 15, 18, 0, 0, TAU); c.fill(); c.stroke();
+ c.fillStyle = C.ink; c.beginPath(); c.ellipse(10, -174 + bob, 3.8, 2.4, 0, 0, TAU); c.fill();
+ c.beginPath(); c.moveTo(-1, -181 + bob); c.quadraticCurveTo(7, -186 + bob, 17, -180 + bob); c.stroke();
+ c.beginPath(); c.moveTo(6, -161 + bob); c.quadraticCurveTo(13, -159 + bob, 17, -163 + bob); c.stroke();
+ // 头巾:白裹布+高耸的红冠杆(向前微倾),顶端一小簇羽
+ c.fillStyle = turban; c.beginPath(); c.ellipse(1, -188 + bob, 22, 11, 0, 0, TAU); c.fill(); c.stroke();
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(-9, -192 + bob); c.quadraticCurveTo(-4, -226 + bob, 6 + sw * 0.3, -246 + bob); c.lineTo(12 + sw * 0.3, -244 + bob); c.quadraticCurveTo(12, -216 + bob, 14, -192 + bob); c.closePath(); c.fill(); c.stroke();
+ c.strokeStyle = C.gold; c.lineWidth = 3; c.beginPath(); c.moveTo(-8, -202 + bob); c.lineTo(13, -202 + bob); c.stroke(); c.strokeStyle = C.ink; c.lineWidth = 2.6 / s;
+ c.fillStyle = C.cream; c.beginPath(); c.ellipse(9 + sw * 0.3, -250 + bob, 4, 9, 0.4, 0, TAU); c.fill(); c.stroke();
+ c.restore();
+ }
+ function draw(c, lt) {
+ if (!layer) build();
+ const t = clamp(lt, 0, 6);
+ c.drawImage(layer, 0, 0);
+ wheel(c, t); water(c, t);
+ // 园丁:站在汲水轮旁摇杆
+ const crank = Math.sin(t * 0.8 * 3.0);
+ person(c, 530, 706, 1.05, 1, C.lapis2, C.cream, t, { bob: Math.sin(t * 2.4) * 2, arm: (cc, bob) => { const hx = -70 - crank * 20, hy = -104 - crank * 14; cc.strokeStyle = C.ink; cc.lineWidth = 14; cc.beginPath(); cc.moveTo(14, -144 + bob); cc.lineTo(-24 - crank * 8, -118 + bob); cc.lineTo(hx, hy); cc.stroke(); cc.strokeStyle = C.lapis2; cc.lineWidth = 10; cc.beginPath(); cc.moveTo(14, -144 + bob); cc.lineTo(-24 - crank * 8, -118 + bob); cc.lineTo(hx, hy); cc.stroke(); cc.strokeStyle = C.ink; cc.lineWidth = 2.6; cc.fillStyle = '#e8c298'; cc.beginPath(); cc.arc(hx, hy, 5.5, 0, TAU); cc.fill(); cc.stroke(); } });
+ // 亭下读书人(在建筑切面里):两人对坐,一个翻页
+ person(c, 1180, 520, 0.92, 1, C.red, C.cream, t, { ph: 0, bob: Math.sin(t * 1.4) * 1.5 });
+ person(c, 1370, 520, 0.92, -1, C.teal, C.cream, t, { ph: 2, bob: Math.sin(t * 1.4 + 2) * 1.5 });
+ // 花瓣与落叶:从树冠飘到池面
+ const r = rng(3); for (let i = 0; i < 22; i++) { const ph = r() * 6, sp = 0.4 + r() * 0.4, x0 = 160 + r() * 1600, q = ((t * sp * 0.2 + ph) % 1), x = x0 + Math.sin(t * 1.4 + i) * 24 + q * 80, y = 560 + q * 480; c.fillStyle = i % 2 ? '#f4d3d0' : '#f4e6a0'; c.strokeStyle = 'rgba(43,33,24,.5)'; c.lineWidth = 1.2; c.beginPath(); c.ellipse(x, y, 7, 4, t + i, 0, TAU); c.fill(); c.stroke(); }
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.28; c.drawImage(P.texture('paper_pm', '#d6bf8a', { scale: 0.004, amt: 14, grain: 6, seed: 9 }), 0, 0); c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/52_south_park.js b/scripts/engine/scenes/52_south_park.js
new file mode 100644
index 0000000..367c8b2
--- /dev/null
+++ b/scripts/engine/scenes/52_south_park.js
@@ -0,0 +1,105 @@
+// 南方公园式数字剪纸:一切都是被剪刀剪出来的色纸——圆头、梯形身体、直边、没有曲线细节;眼睛是两个白椭圆加黑点;
+// 动画是「纸片绕枢轴转、整块平移」,嘴是一个黑色半椭圆开合;背景是几块粗糙的平涂纸。
+// 题材(新构图):小镇雪地里的公交站,四个小孩缩着脖子等车,校车慢吞吞滑进来、车门啪地打开,孩子们一块一块地跳上去。
+// 原作锚定(风格特征,非角色):①纸片感——每块形状边缘有轻微的剪刀抖动,表面有纸纤维 ②眼睛贴脸、黑点在白椭圆里
+// ③身体是梯形/方块,手是单纯的圆头短棒,腿是两根黑短柱 ④色块平涂、只有一道细黑轮廓 ⑤镜头永远正对,层叠为主,不透视
+// 管线:纸块(每块 P.cut 出抖动边缘)→ 纸纹相乘 → 枢轴动画。不使用任何具名角色的服装或配色组合。
+SCENES['52_south_park'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, TAU = Math.PI * 2;
+ const OUT = '#14120f';
+ const E = { lin: x => x, io: x => { x = clamp(x); return x * x * (3 - 2 * x); } };
+ // 剪纸:多边形(顶点)→ 抖动边缘,填色,细黑线。seed 固定所以确定性
+ function paper(c, pts, fill, { seed = 1, lw = 3, amp = 2.4, step = 18, shade = null } = {}) {
+ const p = P.cut(pts, seed, step, amp);
+ c.fillStyle = fill; c.fill(p);
+ if (shade) { c.save(); c.clip(p); c.fillStyle = shade; c.globalAlpha = 0.18; c.fillRect(-9999, -9999, 99999, 99999); c.restore(); c.globalAlpha = 1; }
+ if (lw) { c.strokeStyle = OUT; c.lineWidth = lw; c.lineJoin = 'round'; c.stroke(p); }
+ return p;
+ }
+ function circle(c, x, y, r, fill, seed, lw = 3) { const pts = Array.from({ length: 28 }, (_, i) => [x + Math.cos(i / 28 * TAU) * r, y + Math.sin(i / 28 * TAU) * r]); return paper(c, pts, fill, { seed, lw, amp: 1.2, step: 12 }); }
+ function ell(c, x, y, rx, ry, fill, seed, lw = 3) { const pts = Array.from({ length: 24 }, (_, i) => [x + Math.cos(i / 24 * TAU) * rx, y + Math.sin(i / 24 * TAU) * ry]); return paper(c, pts, fill, { seed, lw, amp: 0.8, step: 10 }); }
+ const tex = () => P.cached('sp_paper', W, H, g => {
+ g.fillStyle = '#fff'; g.fillRect(0, 0, W, H); const r = rng(5);
+ for (let i = 0; i < 9000; i++) { const x = r() * W, y = r() * H, a = r() * TAU, l = 3 + r() * 12; g.strokeStyle = r() < 0.5 ? 'rgba(140,130,115,.16)' : 'rgba(255,255,255,.5)'; g.lineWidth = 0.8; g.beginPath(); g.moveTo(x, y); g.lineTo(x + Math.cos(a) * l, y + Math.sin(a) * l); g.stroke(); }
+ });
+
+ // 小孩:head 圆、眼、嘴;parka 梯形;帽子;手;腿。o: x,y(脚底) s(缩放) skin parka hat tilt(头倾) talk(0..1 嘴开) armL armR(弧度,0=下垂) hop face
+ function kid(c, o) {
+ const { x, y, s = 1, skin = '#f5cfa8', parka, hat, band, tilt = 0, talk = 0, armL = 0, armR = 0, hop = 0, seed = 1, lookx = 0.5 } = o;
+ c.save(); c.translate(x, y - hop); c.scale(s, s);
+ // 腿
+ paper(c, [[-34, -52], [-10, -52], [-10, 0], [-34, 0]], '#1c1a18', { seed: seed + 1, lw: 0, amp: 1 }); paper(c, [[10, -52], [34, -52], [34, 0], [10, 0]], '#1c1a18', { seed: seed + 2, lw: 0, amp: 1 });
+ // 手臂(绕肩枢轴)
+ const arm = (sx, ang, k) => { c.save(); c.translate(sx, -150); c.rotate(ang); paper(c, [[-12, 0], [12, 0], [11, 84], [-11, 84]], parka, { seed: seed + 3 + k, lw: 3, amp: 1.2 }); circle(c, 0, 90, 17, '#f2ede0', seed + 5 + k, 3); c.restore(); };
+ arm(-70, armL, 0); arm(70, armR, 1);
+ // 身体:梯形,小孩缩着脖子
+ paper(c, [[-72, -170], [72, -170], [92, -52], [-92, -52]], parka, { seed: seed + 6, lw: 3.4, amp: 1.6 });
+ paper(c, [[-10, -170], [10, -170], [10, -52], [-10, -52]], 'rgba(0,0,0,.18)', { seed: seed + 7, lw: 0 }); // 拉链缝
+ // 头:绕颈枢轴倾斜
+ c.save(); c.translate(0, -168); c.rotate(tilt);
+ circle(c, 0, -62, 66, skin, seed + 8, 3.4);
+ // 帽:半个纸球+边带+绒球
+ paper(c, [[-66, -68], [-56, -112], [-30, -134], [0, -142], [30, -134], [56, -112], [66, -68]], hat, { seed: seed + 9, lw: 3.4, amp: 1.6 });
+ paper(c, [[-68, -66], [68, -66], [68, -86], [-68, -86]], band, { seed: seed + 10, lw: 3.4, amp: 1.2 });
+ circle(c, 0, -150, 18, band, seed + 11, 3);
+ // 眼:两个白椭圆紧贴,黑点在里面朝向 lookx
+ const ex = 15, ey = -62; ell(c, -ex, ey, 17, 21, '#fff', seed + 12, 3); ell(c, ex, ey, 17, 21, '#fff', seed + 13, 3);
+ const px = (lookx - 0.5) * 12; c.fillStyle = OUT; [-ex, ex].forEach(xx => { c.beginPath(); c.arc(xx + px, ey + 2, 3.8, 0, TAU); c.fill(); });
+ // 嘴:黑色半椭圆,开合
+ const m = 4 + talk * 20; c.fillStyle = OUT; c.beginPath(); c.ellipse(0, -22, 14 + talk * 6, m, 0, 0, Math.PI); c.fill(); if (talk > 0.4) { c.fillStyle = '#c4412f'; c.beginPath(); c.ellipse(0, -22 + m * 0.5, 9, m * 0.4, 0, 0, Math.PI); c.fill(); }
+ c.restore(); c.restore();
+ }
+
+ function draw(c, lt, t) {
+ const T = clamp(lt, 0, 6), r = rng(2);
+ // 天与远山:平涂纸块
+ c.fillStyle = '#c9dce6'; c.fillRect(0, 0, W, H);
+ paper(c, [[0, 0], [W, 0], [W, 330], [0, 330]], '#bcd3e0', { seed: 21, lw: 0, amp: 3 });
+ paper(c, [[-20, 520], [260, 300], [520, 440], [860, 250], [1260, 460], [1560, 330], [1960, 520]], '#e9eef0', { seed: 22, lw: 3.4, amp: 4, step: 30 });
+ paper(c, [[260, 300], [330, 360], [300, 410], [380, 400], [330, 460], [420, 460], [520, 440]], '#a9b9c6', { seed: 23, lw: 0, amp: 3 });
+ paper(c, [[860, 250], [920, 330], [880, 350], [960, 380], [900, 440], [1000, 450], [1260, 460]], '#a9b9c6', { seed: 24, lw: 0, amp: 3 });
+ // 松树:三角叠三层
+ [[1440, 560, 1.1], [1560, 580, 0.9], [200, 560, 1.0], [320, 580, 0.8]].forEach(([x, y, s], i) => { paper(c, [[x - 8 * s, y], [x + 8 * s, y], [x + 8 * s, y + 60 * s], [x - 8 * s, y + 60 * s]], '#6b4a30', { seed: 30 + i, lw: 3 }); [[0, 70], [-26, 120], [-52, 170]].forEach(([dy, hw], k) => paper(c, [[x, y - 40 * s - dy * s * 0.2 + k * -20 * s], [x - (50 + k * 18) * s, y + 20 * s - k * 0 - (2 - k) * -20 * s + 0], [x + (50 + k * 18) * s, y + 20 * s + (2 - k) * 20 * s * 0]], '#2f5d3c', { seed: 40 + i * 3 + k, lw: 3.4, amp: 2 })); });
+ // 雪地:两层白纸,前面一层带灰蓝阴影块
+ paper(c, [[-20, 600], [W + 20, 600], [W + 20, H + 20], [-20, H + 20]], '#f4f7f8', { seed: 50, lw: 3.4, amp: 3, step: 40 });
+ paper(c, [[-20, 840], [600, 800], [1300, 830], [W + 20, 810], [W + 20, H + 20], [-20, H + 20]], '#e6edf0', { seed: 51, lw: 0, amp: 4, step: 30 });
+ // 公路(灰纸)+黄虚线
+ paper(c, [[-20, 700], [W + 20, 700], [W + 20, 800], [-20, 800]], '#6c7378', { seed: 52, lw: 3.4, amp: 2.4, step: 30 });
+ for (let i = 0; i < 12; i++) paper(c, [[i * 170 + 20, 744], [i * 170 + 110, 744], [i * 170 + 110, 758], [i * 170 + 20, 758]], '#e8c13a', { seed: 60 + i, lw: 0, amp: 1.2 });
+ // 站牌:灰杆+红八角形牌(不写字,画一个 ■ 示意)
+ paper(c, [[470, 520], [490, 520], [490, 840], [470, 840]], '#8c9296', { seed: 70, lw: 3.4 });
+ paper(c, [[420, 400], [470, 372], [540, 372], [590, 400], [590, 468], [540, 496], [470, 496], [420, 468]], '#c8402e', { seed: 71, lw: 3.6, amp: 1.6 });
+ paper(c, [[470, 420], [540, 420], [540, 450], [470, 450]], '#f6efe0', { seed: 72, lw: 0 });
+
+ // 校车:从右滑入,停在 x≈1210,车门在 3.7 秒啪地打开;车轮不转(剪纸整块平移)
+ const bx = lerp(2300, 1230, E.io(ss(0.2, 3.2, T))), by = 760;
+ c.save(); c.translate(bx, by);
+ paper(c, [[-420, -250], [330, -250], [350, -210], [350, 60], [-420, 60]], '#f0b92a', { seed: 80, lw: 4, amp: 2 });
+ paper(c, [[-420, -250], [330, -250], [350, -210], [350, -190], [-420, -190]], '#f6cc55', { seed: 81, lw: 0 });
+ for (let i = 0; i < 5; i++) paper(c, [[-380 + i * 110, -170], [-300 + i * 110, -170], [-300 + i * 110, -90], [-380 + i * 110, -90]], '#bcd3e0', { seed: 90 + i, lw: 3.4, amp: 1.2 });
+ paper(c, [[-420, -20], [350, -20], [350, 0], [-420, 0]], '#14120f', { seed: 100, lw: 0 }); // 黑杠
+ const door = E.io(ss(3.6, 3.9, T)); paper(c, [[130, -190], [130 + 76 * (1 - door), -190], [130 + 76 * (1 - door), 40], [130, 40]], '#bcd3e0', { seed: 101, lw: 3.4, amp: 1 }); paper(c, [[130 + 76 * (1 - door), -190], [206, -190], [206, 40], [130 + 76 * (1 - door), 40]], '#2a2622', { seed: 102, lw: 3.4, amp: 1 });
+ [-250, 200].forEach((wx, i) => { circle(c, wx, 62, 62, '#14120f', 110 + i, 0); circle(c, wx, 62, 30, '#8c9296', 112 + i, 3); });
+ c.restore();
+
+ // 四个孩子(原创配色,不借具名角色的服装组合):站在站牌右侧等车;车停后单列依次走到车门、进门(进门=消失在车厢里)
+ const talkPhase = (k) => (Math.sin(T * 14 + k * 1.7) > 0.1 && T < 3.4 && (Math.floor(T * 1.3 + k) % 4 === k % 4)) ? 1 : 0;
+ const DOOR = 1400, STARTX = [720, 860, 1000, 1140];
+ const board = (k) => { const t0 = 3.9 + k * 0.5, q = clamp((T - t0) / 0.8); return { q, x: lerp(0, DOOR - STARTX[k], E.io(q)), hop: Math.abs(Math.sin(q * Math.PI * 3)) * 22 * (q > 0 && q < 1 ? 1 : 0) }; };
+ [
+ { parka: '#d65a7a', hat: '#4a4a52', band: '#f0d34a', seed: 200, s: 1.12 },
+ { parka: '#5a78c8', hat: '#d6803a', band: '#f2ece0', seed: 300, s: 1.04 },
+ { parka: '#8a8f3a', hat: '#8a3a5a', band: '#e8d9a0', seed: 400, s: 1.16 },
+ { parka: '#d9d2c0', hat: '#2f6a58', band: '#3a3a3a', seed: 500, s: 1.0 },
+ ].forEach((k, i) => {
+ const j = board(i); if (j.q >= 1) return; // 进了车厢
+ const shiver = (T < 3.6) ? Math.sin(T * 30 + i) * 1.4 : 0, boarding = j.q > 0;
+ kid(c, { ...k, x: STARTX[i] + j.x + shiver, y: 842 + i % 2 * 10, hop: j.hop, tilt: Math.sin(T * 1.8 + i) * 0.07 + (T > 3.4 ? -0.1 : 0), talk: talkPhase(i), armL: Math.sin(T * 6 + i) * 0.05 + (boarding ? 0.5 : 0), armR: -0.05 + Math.sin(T * 5 + i) * 0.05 + (boarding ? -0.5 : 0), lookx: T > 1 ? 0.9 : 0.4 });
+ });
+ // 落雪:纸圆片,12fps 一格格往下掉(剪纸的步进感)
+ const st = Math.floor(T * 12) / 12; c.fillStyle = '#fff'; c.strokeStyle = 'rgba(100,110,120,.5)'; c.lineWidth = 1.4;
+ for (let i = 0; i < 130; i++) { const rr = rng(i * 7 + 1), x = (rr() * W + st * 40 * (0.5 + rr() * 0.6)) % W, y = ((rr() * H) + st * (90 + rr() * 90)) % H, s = 3 + rr() * 5; c.beginPath(); c.arc(x, y, s, 0, TAU); c.fill(); c.stroke(); }
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.55; c.drawImage(tex(), 0, 0); c.restore();
+ }
+ return { draw };
+})();
diff --git a/scripts/engine/scenes/53_pixar.js b/scripts/engine/scenes/53_pixar.js
new file mode 100644
index 0000000..98b765e
--- /dev/null
+++ b/scripts/engine/scenes/53_pixar.js
@@ -0,0 +1,60 @@
+/* Original un-faced laundry appliance. Programmed 3D geometry and acting; no film assets. */
+SCENES['53_pixar']=(()=>{
+ let R,S,C,washer,drum,door,loose,clothGeo,clothes=[],bubbles=[],towelMeshes=[];
+ const T=()=>window.THREE, clamp=x=>Math.max(0,Math.min(1,x)),smooth=x=>{x=clamp(x);return x*x*(3-2*x)},mix=(a,b,u)=>a+(b-a)*u;
+ function mat(color,rough=.65,metal=0){return new THREE.MeshStandardMaterial({color,roughness:rough,metalness:metal});}
+ function box(x,y,z,w,h,d,m,parent=S){let o=new THREE.Mesh(new THREE.BoxGeometry(w,h,d),m);o.position.set(x,y,z);o.castShadow=o.receiveShadow=true;parent.add(o);return o;}
+ function sphere(x,y,z,rx,ry,rz,m,parent=S){let o=new THREE.Mesh(new THREE.SphereGeometry(1,24,16),m);o.position.set(x,y,z);o.scale.set(rx,ry,rz);o.castShadow=true;parent.add(o);return o;}
+ function cylinder(x,y,z,r,h,m,parent=S){let o=new THREE.Mesh(new THREE.CylinderGeometry(r,r,h,48),m);o.position.set(x,y,z);o.castShadow=o.receiveShadow=true;parent.add(o);return o;}
+ function tube(points,r,m,parent=S){let curve=new THREE.CatmullRomCurve3(points.map(p=>new THREE.Vector3(...p)));let o=new THREE.Mesh(new THREE.TubeGeometry(curve,48,r,8,false),m);parent.add(o);return o;}
+ function rounded(w,h,d,r,m,parent){let s=new THREE.Shape(),x=-w/2,y=-h/2;s.moveTo(x+r,y);s.lineTo(x+w-r,y);s.quadraticCurveTo(x+w,y,x+w,y+r);s.lineTo(x+w,y+h-r);s.quadraticCurveTo(x+w,y+h,x+w-r,y+h);s.lineTo(x+r,y+h);s.quadraticCurveTo(x,y+h,x,y+h-r);s.lineTo(x,y+r);s.quadraticCurveTo(x,y,x+r,y);let g=new THREE.ExtrudeGeometry(s,{depth:d,bevelEnabled:true,bevelThickness:r/3,bevelSize:r/3,bevelSegments:3,steps:1,curveSegments:12});g.translate(0,0,-d/2);let o=new THREE.Mesh(g,m);o.castShadow=o.receiveShadow=true;parent.add(o);return o;}
+ function fabricMat(color){const cv=document.createElement('canvas');cv.width=cv.height=256;let g=cv.getContext('2d');g.fillStyle=color;g.fillRect(0,0,256,256);for(let i=0;i<256;i+=2){g.fillStyle=i%4?'rgba(255,255,255,.08)':'rgba(40,25,10,.10)';g.fillRect(i,0,1,256);g.fillRect(0,i,256,1)}let tx=new THREE.CanvasTexture(cv);tx.wrapS=tx.wrapT=THREE.RepeatWrapping;tx.repeat.set(3,3);tx.colorSpace=THREE.SRGBColorSpace;return new THREE.MeshStandardMaterial({map:tx,roughness:.95,side:THREE.DoubleSide,bumpMap:tx,bumpScale:.012})}
+ function fabricGeometry(){const nx=24,ny=16,g=new THREE.BufferGeometry(),a=[],idx=[],uv=[];for(let j=0;j<=ny;j++)for(let i=0;i<=nx;i++){a.push(i/nx,j/ny,0);uv.push(i/nx,j/ny)}for(let j=0;j<ny;j++)for(let i=0;i<nx;i++){let k=j*(nx+1)+i;idx.push(k,k+1,k+nx+1,k+1,k+nx+2,k+nx+1)}g.setAttribute('position',new THREE.Float32BufferAttribute(a,3));g.setAttribute('uv',new THREE.Float32BufferAttribute(uv,2));g.setIndex(idx);g.computeVertexNormals();return g;}
+ function init(){if(R)return;const THREE=T();if(!THREE)throw Error('53_pixar requires lib/three.min.js');
+ R=new THREE.WebGLRenderer({alpha:false,antialias:true,preserveDrawingBuffer:true});R.setSize(1280,720);R.setPixelRatio(1);R.shadowMap.enabled=true;R.shadowMap.type=THREE.PCFSoftShadowMap;R.outputColorSpace=THREE.SRGBColorSpace;R.toneMapping=THREE.ACESFilmicToneMapping;R.toneMappingExposure=1.05;
+ S=new THREE.Scene();S.background=new THREE.Color('#bed1bd');C=new THREE.PerspectiveCamera(37,16/9,.1,100);C.position.set(7.3,5.1,10.4);C.lookAt(.25,1.75,0);
+ S.add(new THREE.HemisphereLight('#fff1d5','#527674',1.15));let key=new THREE.DirectionalLight('#ffedcc',3.1);key.position.set(-4,8,6);key.castShadow=true;key.shadow.mapSize.set(2048,2048);key.shadow.camera.left=-9;key.shadow.camera.right=9;key.shadow.camera.top=9;key.shadow.camera.bottom=-9;key.shadow.normalBias=.035;S.add(key);let fill=new THREE.DirectionalLight('#bde4dc',.55);fill.position.set(6,4,-1);S.add(fill);
+ const tile=mat('#94b7ab'),grout=mat('#d5ddce'),cream=mat('#efdfbd'),wood=mat('#ae6a3d'),orange=mat('#c76e42'),steel=mat('#b2bdb9',.27,.7),dark=mat('#243e3d',.45,.25),rubber=mat('#4d5953',.9),linen=mat('#eadfca');
+ box(0,-.16,0,24,.25,18,mat('#d2c8ad'));for(let i=-8;i<=8;i++)for(let j=-5;j<=4;j++){let m=((i+j)%2)?mat('#d3cbb7'):mat('#c9bda3');box(i*.85,-.025,j*.85,.823,.025,.823,m)}
+ box(0,3.5,-3.1,18,7,.25,grout);box(-5.6,3.5,1.2,.2,7,8.4,mat('#b8c5ae'));
+ for(let i=-9;i<10;i++)for(let j=0;j<7;j++)box(i*.66,.37+j*.64,-2.945,.64,.615,.035,tile);
+ // sunlit window and sill
+ box(3.4,4.5,-2.8,3.5,2.65,.12,cream);box(3.4,4.5,-2.68,3.15,2.32,.12,mat('#d7eddd'));box(3.4,4.5,-2.57,.09,2.38,.1,wood);box(3.4,4.5,-2.57,3.2,.09,.1,wood);box(3.4,3.22,-2.45,3.8,.18,.72,cream);
+ for(let k=0;k<4;k++){let pot=cylinder(2.3+k*.65,3.48,-2.25,.19,.38,orange);for(let v=0;v<5;v++){let leaf=sphere(2.3+k*.65+(v-2)*.1,3.9+.1*Math.sin(v),-2.25,.08,.32,.045,mat('#517c52'));leaf.rotation.z=(v-2)*.35}}
+ // washing-machine body with rounded enamel, separate rubber and chrome
+ washer=new THREE.Group();washer.position.set(-.7,1.95,.45);S.add(washer);rounded(3.25,3.65,2.55,.18,mat('#e8dfc8',.36),washer);box(0,1.33,1.35,2.94,.62,.13,cream,washer);
+ for(let x of [-1.18,1.18])for(let z of [-.88,.88])cylinder(x,-1.84,z,.17,.24,rubber,washer);
+ let dial=cylinder(.96,1.34,1.47,.19,.19,steel,washer);dial.rotation.x=Math.PI/2;box(-.7,1.35,1.46,.96,.25,.065,dark,washer);box(-.75,1.35,1.504,.5,.035,.01,mat('#d7c36a'),washer);
+ let rim=new THREE.Mesh(new THREE.TorusGeometry(1.06,.12,20,72),steel);rim.position.set(0,-.12,1.4);washer.add(rim);let seal=new THREE.Mesh(new THREE.TorusGeometry(.91,.08,16,72),rubber);seal.position.set(0,-.12,1.43);washer.add(seal);
+ let cavity=cylinder(0,-.12,1.32,.93,.18,dark,washer);cavity.rotation.x=Math.PI/2;
+ drum=new THREE.Group();drum.position.set(0,-.12,1.47);washer.add(drum);for(let i=0;i<28;i++){let a=i*Math.PI*2/28;let hole=sphere(Math.cos(a)*.78,Math.sin(a)*.78,0,.035,.035,.025,steel,drum)}
+ for(let i=0;i<8;i++){const col=['#cb6b47','#b9d4c1','#cfaf65','#e3d4b9'][i%4];let m=sphere(Math.cos(i*1.7)*.48,Math.sin(i*1.7)*.48,.035,.33,.20,.09,fabricMat(col),drum);m.rotation.z=i*.8;clothes.push(m)}
+ door=new THREE.Group();door.position.set(-1.02,-.12,1.49);washer.add(door);let ring=new THREE.Mesh(new THREE.TorusGeometry(.99,.075,16,80),mat('#e5eee5',.2,.35));ring.position.set(1.02,0,0);door.add(ring);let glass=cylinder(1.02,0,-.015,.92,.045,new THREE.MeshPhysicalMaterial({color:'#d1e6de',transparent:true,opacity:.14,roughness:.08,metalness:.1,side:THREE.DoubleSide}),door);glass.rotation.x=Math.PI/2;
+ box(1.85,.08,.09,.1,.4,.14,steel,door);
+ // a trapped orange sleeve; cloth topology deforms continuously around the clamped edge
+ clothGeo=fabricGeometry();loose=new THREE.Mesh(clothGeo,fabricMat('#c86239'));loose.castShadow=true;washer.add(loose);
+ // Basket and lived-in room detail
+ cylinder(2.35,.54,1.25,.82,1.05,mat('#9e7450'));for(let k=0;k<10;k++){let rr=new THREE.Mesh(new THREE.TorusGeometry(.83,.018,5,64),cream);rr.rotation.x=Math.PI/2;rr.position.set(2.35,.08+k*.1,1.25);S.add(rr)}
+ for(let k=0;k<12;k++)sphere(2.35+Math.sin(k*4)*.51,1.03+Math.sin(k*1.2)*.09,1.25+Math.cos(k*4)*.4,.33,.19,.28,fabricMat(k%2?'#e5c67b':'#b8c6b5'));
+ box(-3.7,1.13,-1.3,2.2,.14,2,wood);for(let x of [-4.6,-2.8])box(x,.55,-1.3,.12,1.1,1.7,cream);for(let k=0;k<4;k++)box(-3.7,1.3+k*.13,-1.3,1.5,.12,1.2,mat(['#adbdad','#e1cfb2','#be7957','#d8bea0'][k]));
+ tube([[-4.8,4,-2],[-2.8,3.91,-2],[0,3.92,-2],[2,4,-2]],.025,wood);
+ for(let k=0;k<3;k++){const g=fabricGeometry(),m=new THREE.Mesh(g,new THREE.MeshStandardMaterial({color:['#dcbd88','#b7ccc1','#cf8465'][k],roughness:1,side:THREE.DoubleSide}));S.add(m);towelMeshes.push({m,g,x:-4.5+k*1.03})}
+ // Feet shadow and restrained machine details.
+ let cv=document.createElement('canvas');cv.width=cv.height=128;let cg=cv.getContext('2d');let sg=cg.createRadialGradient(64,64,5,64,64,62);sg.addColorStop(0,'rgba(23,39,32,.48)');sg.addColorStop(1,'rgba(23,39,32,0)');cg.fillStyle=sg;cg.fillRect(0,0,128,128);let sh=new THREE.Mesh(new THREE.PlaneGeometry(5,4),new THREE.MeshBasicMaterial({map:new THREE.CanvasTexture(cv),transparent:true,depthWrite:false}));sh.rotation.x=-Math.PI/2;sh.position.set(-.7,.015,.4);S.add(sh);
+ for(let k=0;k<6;k++)box(-.95+k*.15,-1.4,1.35,.085,.018,.018,rubber,washer);
+ let tc=document.createElement('canvas');tc.width=512;tc.height=128;let tg=tc.getContext('2d');tg.fillStyle='#eee4cc';tg.fillRect(0,0,512,128);tg.fillStyle='#52675e';tg.font='bold 38px sans-serif';tg.fillText('MORNING / 06',28,80);let tm=new THREE.Mesh(new THREE.PlaneGeometry(1.18,.29),new THREE.MeshBasicMaterial({map:new THREE.CanvasTexture(tc)}));tm.position.set(-.55,.91,1.45);washer.add(tm);
+ // Small scuffs, seams, baseboards avoid an empty toy stage.
+ box(0,.17,-2.78,18,.18,.12,wood);for(let k=0;k<9;k++)box(-5+1.1*k,.45,-2.73,.22,.025,.015,mat('#638e82'));
+ }
+ function draw(c,lt){init();const t=Math.max(0,Math.min(6,lt));
+ let jam=smooth((t-.9)/.5)*(1-smooth((t-3.5)/.5));let release=smooth((t-3.7)/.7);
+ washer.rotation.z=(Math.sin(t*31)*.028+Math.sin(t*17)*.016)*jam;washer.position.y=1.95+Math.abs(Math.sin(t*31))*.035*jam;washer.position.x=-.7+Math.sin(t*26)*.035*jam;
+ drum.rotation.z=t<1.4?t*4.5:6.3+Math.sin((t-1.4)*18)*.07*jam-(smooth((t-3.2)/1.2))*2.5+(t>4.5?(t-4.5)*1.4:0);
+ door.rotation.y=-smooth((t-3.25)/.65)*.68;
+ let a=clothGeo.attributes.position,nx=24,ny=16;for(let j=0;j<=ny;j++)for(let i=0;i<=nx;i++){let u=i/nx,v=j/ny,idx=j*(nx+1)+i;let tug=Math.sin(t*24-v*3)*.07*jam*(v+.1);let xx=.45+(u-.5)*.48+Math.sin(v*5+t*3)*.06*v;let yy=Math.max(-1.928+.006*Math.sin(u*24+v*8),-.99-v*1.12-release*2.05);let zz=1.59+v*.7+Math.sin(u*16+v*9)*.045+Math.sin(v*7-t*4)*v*.075+tug; a.setXYZ(idx,xx,yy,zz)}a.needsUpdate=true;clothGeo.computeVertexNormals();
+ for(const {g,x} of towelMeshes){let a=g.attributes.position;for(let j=0;j<=16;j++)for(let i=0;i<=24;i++){let u=i/24,v=j/16,idx=j*25+i;a.setXYZ(idx,x+u*.75,3.9-v*1.35,-2+Math.sin(u*15)*.045+Math.sin(t*1.9+v*3+x)*v*.08)}a.needsUpdate=true;g.computeVertexNormals()}
+ // Deliberately held camera: movement is in the machine, drum and cloth.
+ R.render(S,C);c.drawImage(R.domElement,0,0,1920,1080);
+ }
+ return {draw};
+})();
diff --git a/scripts/engine/scenes/54_ghibli_lab.js b/scripts/engine/scenes/54_ghibli_lab.js
new file mode 100644
index 0000000..ec61d94
--- /dev/null
+++ b/scripts/engine/scenes/54_ghibli_lab.js
@@ -0,0 +1,68 @@
+/* Original urban bicycle-repair kiosk. Hand-painted environment + mechanical contact. */
+SCENES['54_ghibli_lab']=(()=>{
+ const T=Math.PI*2;let back,front;
+ const rng=n=>()=>((n=(n*1664525+1013904223)>>>0)/4294967296);
+ function P(g,p,col,stroke='#4e6158',w=2){g.beginPath();p.forEach((v,i)=>i?g.lineTo(...v):g.moveTo(...v));g.closePath();if(col){g.fillStyle=col;g.fill();}if(stroke){g.strokeStyle=stroke;g.lineWidth=w;g.stroke();}}
+ function L(g,p,col='#4e6158',w=2){g.beginPath();p.forEach((v,i)=>i?g.lineTo(...v):g.moveTo(...v));g.strokeStyle=col;g.lineWidth=w;g.lineCap='round';g.stroke();}
+ function R(g,x,y,w,h,col,stroke='#607363'){g.fillStyle=col;g.fillRect(x,y,w,h);if(stroke){g.strokeStyle=stroke;g.lineWidth=2;g.strokeRect(x,y,w,h);}}
+ function E(g,x,y,rx,ry,col){g.fillStyle=col;g.beginPath();g.ellipse(x,y,rx,ry,0,0,T);g.fill();}
+ function speck(g,x,y,w,h,n,seed,cols){const r=rng(seed);g.save();for(let i=0;i<n;i++){g.fillStyle=cols[i%cols.length];g.globalAlpha=.04+r()*.12;let xx=x+r()*w,yy=y+r()*h;g.beginPath();g.ellipse(xx,yy,2+r()*13,1+r()*4,r()*.4,0,T);g.fill();}g.restore();}
+ function pigment(canvas,seed){const g=canvas.getContext('2d'),r=rng(seed),src=g.getImageData(0,0,1920,1080),d=src.data;for(let i=0;i<72000;i++){let x=r()*1920,y=r()*1080,k=(Math.floor(y)*1920+Math.floor(x))*4;if(d[k+3]<180)continue;let delta=(r()-.5)*35;g.strokeStyle=`rgba(${d[k]+delta},${d[k+1]+delta},${d[k+2]+delta*.8},${.06+r()*.10})`;g.lineWidth=.6+r()*2.5;g.beginPath();g.moveTo(x,y);g.lineTo(x+3+r()*14,y+(r()-.5)*4);g.stroke();}const p=g.getImageData(0,0,1920,1080),a=p.data;for(let i=0;i<a.length;i+=4){if(a[i+3]<180)continue;let n=(r()-.5)*7;a[i]+=n;a[i+1]+=n;a[i+2]+=n;}g.putImageData(p,0,0);}
+ function window(g,x,y,w,h){R(g,x-5,y-5,w+10,h+10,'#c3ba8c');R(g,x,y,w,h,'#657f80');R(g,x+5,y+4,w-10,h*.44,'#94b2ac');L(g,[[x+w*.5,y],[x+w*.5,y+h]],'#e8ddb1',5);L(g,[[x,y+h*.5],[x+w,y+h*.5]],'#e8ddb1',5);L(g,[[x+4,y+h-4],[x+w-5,y+6]],'#d8dfbd55',4);}
+ function plant(g,x,y,s,seed){const r=rng(seed);P(g,[[x-30*s,y],[x+30*s,y],[x+23*s,y+48*s],[x-21*s,y+48*s]],'#a86f51');E(g,x,y,32*s,9*s,'#694e37');for(let i=0;i<20;i++){let a=r()*T,len=(30+r()*65)*s,xx=x+Math.cos(a)*len,yy=y-40*s-r()*60*s;L(g,[[x,y],[xx,yy]],'#4e7957',2*s);g.save();g.translate(xx,yy);g.rotate(a);E(g,0,0,17*s,6*s,i%3?'#60875a':'#9aaa62');L(g,[[-13*s,0],[14*s,0]],'#c2c77d',.7*s);g.restore();}}
+ function make(){if(back)return;back=document.createElement('canvas');back.width=1920;back.height=1080;let g=back.getContext('2d');let sky=g.createLinearGradient(0,0,0,620);sky.addColorStop(0,'#9dbeb8');sky.addColorStop(.7,'#d6d6ac');sky.addColorStop(1,'#efe2af');g.fillStyle=sky;g.fillRect(0,0,1920,1080);
+ // Hills and connected city blocks, observed roofs, wires and masonry.
+ P(g,[[0,270],[150,170],[300,208],[450,123],[620,210],[770,140],[950,258],[1250,177],[1510,242],[1920,120],[1920,650],[0,650]],'#95aa93',null);
+ for(let i=0;i<9;i++){let x=i*171-25,y=190+(i%3)*55,w=155;R(g,x,y,w,340,['#c9c8a4','#d0bba0','#adbcb0'][i%3]);P(g,[[x-8,y],[x+70,y-62],[x+w+10,y],[x+w,y+14],[x,y+14]],['#6c8e80','#ad7b64','#7f9a8b'][i%3]);P(g,[[x,y+14],[x+w,y+14],[x+w,y+38],[x,y+30]],'#516d6033',null);for(let row=0;row<2;row++)for(let j=0;j<2;j++){let wx=x+20+j*75,wy=y+45+row*113;window(g,wx,wy,42,70);if(i%2){R(g,wx-13,wy,9,70,'#788b71');for(let k=0;k<8;k++)L(g,[[wx-12,wy+k*9],[wx-5,wy+k*9]],'#566b58',1);}R(g,wx-7,wy+72,56,8,'#c1b78c');if(row===1&&i%3===0){R(g,wx-5,wy+65,51,15,'#a77b5a');for(let k=0;k<9;k++){E(g,wx+k*5,wy+60-(k%3)*5,6,7,'#6c8c5e');E(g,wx+k*5,wy+56-(k%3)*5,3,3,'#d69b7f');}}}L(g,[[x+w-8,y+20],[x+w-8,y+330],[x+w-21,y+337]],'#7d8e78',4);R(g,x+65,y-62,21,35,'#a39275');R(g,x+60,y-64,30,7,'#657c6c');if(i%3===1){R(g,x+18,y+277,120,55,'#5d8279');for(let k=0;k<6;k++)P(g,[[x+10+k*23,y+265],[x+33+k*23,y+265],[x+40+k*23,y+292],[x+17+k*23,y+292]],k%2?'#d3ba8b':'#b87859');}speck(g,x,y,w,330,130,i+54,['#7e9b85','#fff2b3','#9e8e73']);}
+ R(g,0,547,1920,183,'#b2b4a0');L(g,[[0,643],[1920,643]],'#e0d6ac',5);L(g,[[0,678],[1920,678]],'#6f857a',4);L(g,[[0,695],[1920,695]],'#e0d6ac',3);
+ for(let i=0;i<50;i++){let x=(i*127)%1920,y=562+(i*43)%140;L(g,[[x,y],[x+42,y-2]],'#859b8b44',2);}
+ // A plane tree's irregular leaf masses interrupt the repetitive street rhythm.
+ L(g,[[1258,572],[1255,437],[1215,339]],'#6d8066',18);L(g,[[1251,451],[1320,355]],'#6d8066',10);const treeR=rng(558);for(let i=0;i<620;i++){let a=treeR()*T,rad=Math.sqrt(treeR())*127,xx=1250+Math.cos(a)*rad,yy=329+Math.sin(a)*rad*.7;E(g,xx,yy,8+treeR()*17,5+treeR()*10,['#678b6b','#7e9b70','#a4b77d','#88a575','#bbbf89'][i%5]);}
+ // Overhead cable follows the rail direction and powers the tram's pantograph.
+ L(g,[[-20,158],[490,186],[980,179],[1510,164]],'#677e72',3);L(g,[[74,0],[74,562]],'#76846e',9);L(g,[[60,154],[380,154]],'#76846e',5);
+ speck(g,0,0,1920,1080,2900,545,['#fff0bd','#6c927f','#b5b28b']);
+ pigment(back,555);
+ front=document.createElement('canvas');front.width=1920;front.height=1080;g=front.getContext('2d');
+ // Open kiosk structure leaves most of the street unobstructed.
+ P(g,[[1415,0],[1920,0],[1920,1080],[1550,1080],[1435,716]],'#d8ccaa');speck(g,1415,0,505,1080,1700,549,['#a3ac91','#fff0bd','#b29976']);
+ R(g,1432,0,42,754,'#526e65');R(g,1474,0,14,754,'#d4d0a2');R(g,0,0,1440,64,'#54796b');R(g,0,64,1440,12,'#a9b28b');
+ P(g,[[0,720],[1448,702],[1920,1080],[0,1080]],'#b9b99b');speck(g,0,720,1920,360,1300,550,['#718d7c','#e9dcb0','#a89d78']);
+ for(let i=-4;i<11;i++)L(g,[[100+i*170,720],[50+i*256,1080]],'#83948155',2);for(let y=778;y<1080;y+=70)L(g,[[0,y],[1920,y]],'#81968044',2);
+ // Strong, coherent morning light, tied to the aperture and objects.
+ P(g,[[118,720],[846,713],[1290,1080],[367,1080]],'#f5e8af66',null);P(g,[[1435,716],[1484,716],[1747,1080],[1670,1080]],'#5a75642d',null);
+ // Wall tools with handles, hooks and tiny marks instead of ornamental symbols.
+ R(g,1557,129,313,344,'#a88f68');R(g,1567,139,293,324,'#c6b68b');for(let y=160;y<455;y+=25)for(let x=1582;x<1850;x+=25)E(g,x,y,1.4,1.4,'#957d5b');
+ for(let i=0;i<4;i++){let x=1610+i*65;L(g,[[x,179],[x,191]],'#71684c',3);if(i%2){L(g,[[x,195],[x,330]],'#737f70',11);E(g,x,208,17,22,'#7c8b7b');E(g,x,207,8,14,'#c6b68b');R(g,x-9,307,18,66,'#a05c45');}else{L(g,[[x,195],[x,336]],'#6e7f71',10);L(g,[[x-19,195],[x-14,221],[x+14,221],[x+19,195]],'#667c70',7);R(g,x-8,319,16,47,'#637d69');}}
+ // Long well-used repair bench, a perspective volume with imperfect wood grain.
+ P(g,[[1025,688],[1687,674],[1830,747],[1128,779]],'#b39061');P(g,[[1128,779],[1830,747],[1830,785],[1128,815]],'#8c704e');P(g,[[1025,688],[1128,779],[1128,815],[1025,726]],'#857556');for(let i=0;i<14;i++)L(g,[[1061+i*22,704+i*3],[1720+i*3,701+i*3]],'#dec18c66',1.4);
+ R(g,1150,809,24,271,'#7a7451');R(g,1763,783,30,297,'#7a7451');R(g,1180,947,580,18,'#8c805a');R(g,1224,831,277,67,'#ad9065');R(g,1235,839,254,48,'#bd9f70');L(g,[[1338,858],[1380,858]],'#6f795b',6);P(g,[[1450,927],[1651,927],[1674,947],[1475,947]],'#c6ab78');R(g,1475,897,199,50,'#ad9164');for(let j=0;j<5;j++)L(g,[[1490+j*38,900],[1490+j*38,942]],'#927e59',2);
+ // Two tins, packed parts tray, oil can, rag and bicycle pump.
+ E(g,1632,711,61,15,'#536655');R(g,1573,650,118,60,'#9cae91');E(g,1632,650,59,14,'#c9ccb0');E(g,1632,648,47,9,'#697d68');for(let i=0;i<8;i++){let x=1594+i*11;L(g,[[x,646],[x+6,604-i%3*13]],'#566f66',3);}
+ P(g,[[1395,727],[1528,724],[1570,743],[1433,753]],'#687c6e');for(let i=0;i<12;i++)E(g,1417+(i*37)%123,733+(i%3)*4,8,3,'#c1c8a6');
+ P(g,[[1691,671],[1738,665],[1750,708],[1698,712]],'#b4774d');L(g,[[1717,669],[1725,635],[1776,621]],'#b4774d',7);R(g,1705,656,22,13,'#647667');
+ // A bicycle at the open edge; tubes, spokes, chain and cast shadow agree.
+ E(g,586,1025,381,26,'#5a79602b');for(const x of [358,815]){g.beginPath();g.arc(x,908,123,0,T);g.strokeStyle='#455a52';g.lineWidth=13;g.stroke();g.strokeStyle='#bec7a5';g.lineWidth=3;g.beginPath();g.arc(x,908,111,0,T);g.stroke();for(let i=0;i<32;i++){let a=i*T/32;L(g,[[x,908],[x+Math.cos(a)*111,908+Math.sin(a)*111]],'#8a9f8d',1.2);}E(g,x,908,9,9,'#516d61');}
+ const red='#9c6254';L(g,[[358,908],[493,733],[574,908],[358,908]],red,10);L(g,[[493,733],[735,744],[574,908],[735,744],[815,908]],red,10);L(g,[[493,733],[478,691]],'#576f62',9);L(g,[[438,686],[507,686]],'#4e6052',16);L(g,[[735,744],[719,666],[773,643],[795,652]],'#536e63',9);E(g,574,908,31,31,'#66816c');E(g,574,908,23,23,'#9cae8c');L(g,[[574,908],[604,931],[633,930]],'#4c675c',6);L(g,[[360,908],[574,934],[574,882],[360,908]],'#718773',2);R(g,292,765,138,14,'#7b8e74');L(g,[[315,778],[336,888]],'#788974',3);L(g,[[420,778],[373,888]],'#788974',3);
+ plant(g,102,892,1.35,547);plant(g,945,787,.85,548);plant(g,1832,662,.8,551);
+ // Blue enamel kettle on an actual burner, cup and detached bicycle lamp.
+ E(g,1285,750,82,19,'#53695b44');R(g,1214,712,137,34,'#75816b');E(g,1284,714,50,13,'#435b50');
+ E(g,1283,672,59,58,'#4d8587');g.save();g.beginPath();g.ellipse(1283,672,59,58,0,0,T);g.clip();E(g,1308,696,52,51,'#396f78');E(g,1268,652,35,42,'#6caaa3');g.restore();P(g,[[1238,683],[1192,643],[1198,633],[1252,654]],'#6e9e99');E(g,1284,629,42,10,'#89b1a3');E(g,1284,621,13,8,'#4e6861');g.beginPath();g.arc(1288,649,51,Math.PI,0);g.strokeStyle='#566b58';g.lineWidth=10;g.stroke();L(g,[[1247,661],[1243,685]],'#adc6ac',5);
+ E(g,1396,711,35,9,'#526d5933');R(g,1371,667,48,44,'#e3d0a0');E(g,1395,667,24,7,'#eae0b8');E(g,1395,668,18,4,'#856c4c');g.beginPath();g.arc(1422,686,14,-1.6,1.6);g.strokeStyle='#c9b68b';g.lineWidth=6;g.stroke();
+ pigment(front,556);
+ }
+ function tram(g,x,t){g.save();g.translate(x,0);E(g,475,691,534,23,'#506d6830');for(let xx of [140,785]){E(g,xx,657,47,47,'#3e5b56');E(g,xx,657,31,31,'#86978a');for(let i=0;i<8;i++){let a=i*T/8-t*4;L(g,[[xx,657],[xx+Math.cos(a)*27,657+Math.sin(a)*27]],'#485f56',3);}}
+ P(g,[[-40,389],[-17,343],[49,325],[905,325],[959,354],[978,624],[947,664],[-13,664]],'#b76543','#556b5d',3);R(g,-20,459,979,104,'#e0bd7c');P(g,[[-25,350],[944,350],[936,392],[-28,392]],'#d7c8a0');
+ for(let i=0;i<7;i++){let xx=24+i*125;R(g,xx,376,103,145,'#465e5a');R(g,xx+5,381,93,105,'#8fb5ad');P(g,[[xx+5,381],[xx+35,381],[xx+93,461],[xx+93,486],[xx+70,486]],'#d6dfbe55',null);R(g,xx+5,491,93,25,'#5d7770');L(g,[[xx+52,381],[xx+52,486]],'#d6c89f',3);}
+ R(g,850,365,98,263,'#b7754d');R(g,860,380,76,134,'#7ea099');L(g,[[899,380],[899,626]],'#e6bf7f',3);L(g,[[859,592],[939,592]],'#9f6341',3);E(g,944,586,12,17,'#f1d393');L(g,[[2,628],[946,628]],'#e3b777',4);
+ // Roof pantograph stays in contact with the overhead wire.
+ L(g,[[450,323],[410,260],[486,194],[570,260],[523,323]],'#5d7568',5);L(g,[[460,193],[520,193]],'#526e62',6);R(g,353,313,280,16,'#688276');
+ speck(g,-10,535,952,112,180,554,['#f4c58a','#8b5b41']);g.restore();}
+ return {draw(c,lt){let t=Math.max(0,lt);make();c.drawImage(back,0,0);c.save();c.beginPath();c.rect(0,75,1435,645);c.clip();tram(c,1270-t*390,t);c.restore();c.drawImage(front,0,0);
+ // Steam rises continuously from the spout; translucent curls are attached to it.
+ for(let i=0;i<5;i++){let q=(t*.35+i*.2)%1,x=1193-24*q+Math.sin(t*1.8+i)*10,y=636-q*150;c.beginPath();c.moveTo(x,y);c.bezierCurveTo(x-23,y-22,x+31,y-34,x+5,y-57);c.strokeStyle=`rgba(240,237,207,${(1-q)*.47})`;c.lineWidth=4+q*9;c.stroke();}
+ // A hanging shop cloth responds to the tram's wake, with a fixed top seam.
+ let wind=Math.sin(t*2)*10+18*Math.exp(-Math.pow((t-3)/1.5,2));c.beginPath();c.moveTo(57,84);c.lineTo(256,84);c.bezierCurveTo(244,161,270+wind,235,248+wind,312);c.quadraticCurveTo(153+wind,333,65+wind*.7,310);c.bezierCurveTo(74+wind,217,54,144,57,84);c.closePath();c.fillStyle='#839c8fe8';c.fill();c.strokeStyle='#5a7a6d';c.lineWidth=2;c.stroke();for(let i=0;i<6;i++){c.beginPath();c.moveTo(78+i*30,85);c.quadraticCurveTo(65+i*30+wind*.5,196,78+i*30+wind,315);c.strokeStyle='#b8c4a078';c.lineWidth=2;c.stroke();}
+ // Dust only where morning light catches it, not a whole-frame particle layer.
+ for(let i=0;i<23;i++){let x=525+(i*47)%510+Math.sin(t*.4+i)*8,y=703+(i*73)%280-Math.sin(t*.3+i)*9;E(c,x,y,1.2,1.2,'#fff0c0aa');}
+ }};
+})();
diff --git a/scripts/engine/scenes/55_dunhuang.js b/scripts/engine/scenes/55_dunhuang.js
new file mode 100644
index 0000000..29c688d
--- /dev/null
+++ b/scripts/engine/scenes/55_dunhuang.js
@@ -0,0 +1,161 @@
+// 敦煌壁画(北朝:257 窟鹿王本生 · 285 窟西魏飞天):土红地上的白色走兽和锯齿山,奶白地上的青绿风叶和长飘带飞天;
+// 不是「中国风插画」——它是干燥的泥壁画:矿物色粉上墙、铅白氧化发暗、墙皮龟裂起甲、盐碱泛白,线是红褐的铁线/兰叶描。
+// 题材(新构图):上栏一位飞天托莲横空而过,风叶和散花从身边向后翻;下栏一只白鹿领着一只小鹿穿过三角形的山奔跑。
+// 原作锚定(fetch_reference.py:257 窟鹿王本生、285 窟西魏飞天、428 窟北周飞天、盛唐 112 窟):
+// 土红地 #92342d/#9b4745;白鹿 #efe6d2;青绿 #3e919c/#577f7a;奶白地 #e8dcc5;赭 #b89d7d;深褐线 #3a1812;
+// 山=一排排锯齿三角、各自涂青/白/黑/绿;动物=平涂白身+极少内部线;飞天=水平横飞、下身化成一条飘到身后的长裙;
+// 上下两栏之间有一道多色横带;窟顶下沿垂幔三角纹;整面墙龟裂、起甲、泛盐。
+// 管线:墙底(泥+色差,缓存)→ 上栏奶白地+下栏土红地+多色分隔带+顶部菱格带+底部垂幔 → 锯齿山(缓存)
+// → 动态:鹿群奔跑、风叶后掠、飞天、散花、尘埃 → 龟裂/起甲/盐碱覆盖层(盖在画上面,裂缝穿过人和鹿)→ 泥壁颗粒相乘。
+SCENES['55_dunhuang'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ss } = U, P = PAINT, TAU = Math.PI * 2;
+ const C = { sky: '#e6d9bf', red: '#92342d', red2: '#7c2a24', white: '#efe6d2', teal: '#3e919c', teal2: '#1f5f6a', green: '#577f7a', ochre: '#c58a3e', ink: '#3a1812', line: '#6b2a1c', skin: '#e6cfae', flush: '#df8d74', dark: '#241512', lapis: '#35597c' };
+ const TOP = 64, SPLIT = 478, GROUND = 930, BOT = 986;
+ let base, over;
+ const sh = (h, k) => { const q = P.hex(h); return `rgb(${Math.round(q[0] * k)},${Math.round(q[1] * k)},${Math.round(q[2] * k)})`; };
+ const poly = (g, pts) => { g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.closePath(); };
+
+ // ---- 静态:墙与两栏 ----
+ function band(g) { // 顶部:菱格带(青/白/红/黑)
+ g.fillStyle = C.dark; g.fillRect(0, 0, W, TOP);
+ const cols = [C.teal, C.white, C.red, C.ochre];
+ for (let i = 0, x = 0; x < W + 60; i++, x += 56) { g.fillStyle = cols[i % 4]; poly(g, [[x, TOP / 2], [x + 28, 8], [x + 56, TOP / 2], [x + 28, TOP - 8]]); g.fill(); g.strokeStyle = C.dark; g.lineWidth = 2; g.stroke(); g.fillStyle = cols[(i + 2) % 4]; g.beginPath(); g.arc(x + 28, TOP / 2, 5, 0, TAU); g.fill(); }
+ }
+ function divider(g) { // 上下栏之间的多色横带+联珠
+ const rows = [[C.dark, 8], [C.white, 14], [C.teal, 20], [C.ochre, 14], [C.white, 12], [C.dark, 8]]; let y = SPLIT;
+ rows.forEach(([col, h]) => { g.fillStyle = col; g.fillRect(0, y, W, h); y += h; });
+ g.fillStyle = C.white; g.strokeStyle = C.dark; g.lineWidth = 1.6; for (let x = 14; x < W; x += 28) { g.beginPath(); g.arc(x, SPLIT + 8 + 14 + 10, 5, 0, TAU); g.fill(); g.stroke(); }
+ }
+ function drapery(g) { // 底部:垂幔三角纹,每片垂一粒珠
+ g.fillStyle = C.dark; g.fillRect(0, BOT, W, H - BOT);
+ const cols = [C.teal, C.ochre, C.white, C.red2, C.green];
+ for (let i = 0, x = -10; x < W + 80; i++, x += 84) { g.fillStyle = cols[i % 5]; poly(g, [[x, BOT], [x + 84, BOT], [x + 42, BOT + 70]]); g.fill(); g.strokeStyle = C.dark; g.lineWidth = 2.4; g.stroke();
+ g.fillStyle = cols[(i + 2) % 5]; poly(g, [[x + 20, BOT], [x + 64, BOT], [x + 42, BOT + 38]]); g.fill(); g.fillStyle = C.white; g.beginPath(); g.arc(x + 42, BOT + 82, 6, 0, TAU); g.fill(); g.stroke(); }
+ }
+ function mountains(g) { // 257 窟式的山:窄高、倾斜、参差的三角碎片,一排排叠在红地上,红地大面积露出来;每片一色,一侧压暗,内部几道斜向地层线
+ const r = rng(257), rows = [[790, 150, 250, [C.teal2, C.dark, C.green, C.lapis], 1.18], [905, 90, 160, [C.white, C.teal, C.ochre, C.white], 1.0]];
+ rows.forEach(([bs, h0, h1, pal, step], ri) => { let x = -60 + ri * 90; while (x < W + 100) { const w = 130 + r() * 150, hh = h0 + r() * (h1 - h0), c0 = pal[Math.floor(r() * pal.length)], ap = x + w * (0.5 + (r() - .5) * 1.5);
+ g.fillStyle = c0; poly(g, [[x, bs], [ap, bs - hh], [x + w, bs]]); g.fill();
+ g.fillStyle = sh(c0, 0.6); poly(g, [[ap, bs - hh], [x + w, bs], [ap - (ap - x) * 0.05, bs - hh * 0.0]]); g.fill();
+ g.save(); poly(g, [[x, bs], [ap, bs - hh], [x + w, bs]]); g.clip(); g.strokeStyle = 'rgba(58,24,18,.5)'; g.lineWidth = 2; for (let k = 1; k < 6; k++) { const yy = bs - hh * k / 6.4; g.beginPath(); g.moveTo(x - 10, yy + 26); g.lineTo(x + w + 10, yy - 14); g.stroke(); } g.restore();
+ g.strokeStyle = C.ink; g.lineWidth = 3; g.lineJoin = 'round'; poly(g, [[x, bs], [ap, bs - hh], [x + w, bs]]); g.stroke();
+ x += w * (step + r() * 0.25); } });
+ }
+ function ground(g) { // 山脚地面:赭土+青绿三叶草+碎石点
+ g.fillStyle = C.ochre; g.fillRect(0, GROUND, W, BOT - GROUND); g.fillStyle = C.ink; g.fillRect(0, GROUND - 3, W, 5);
+ const r = rng(11); for (let i = 0; i < 70; i++) { const x = r() * W, y = GROUND + 10 + r() * (BOT - GROUND - 20); g.strokeStyle = r() < 0.6 ? C.teal2 : C.ink; g.lineWidth = 2.2; g.beginPath(); g.moveTo(x, y); g.lineTo(x - 7, y - 12); g.moveTo(x, y); g.lineTo(x + 1, y - 15); g.moveTo(x, y); g.lineTo(x + 8, y - 11); g.stroke(); }
+ }
+ function build() {
+ base = P.canvas(); const g = base.getContext('2d');
+ g.drawImage(P.texture('dh_sky', C.sky, { scale: 0.003, amt: 22, grain: 8, seed: 4 }), 0, TOP, W, SPLIT - TOP, 0, TOP, W, SPLIT - TOP);
+ g.drawImage(P.texture('dh_red', C.red, { scale: 0.0034, amt: 26, grain: 9, dark: '#5a1d1a', seed: 9 }), 0, SPLIT, W, BOT - SPLIT, 0, SPLIT, W, BOT - SPLIT);
+ g.save(); g.beginPath(); g.rect(0, SPLIT + 76, W, GROUND - SPLIT - 76); g.clip(); mountains(g); g.restore();
+ // 红地上撒几只远处的小白兽剪影(257 窟满地走兽的感觉)
+ const rs = rng(77); for (let i = 0; i < 7; i++) { const x = 120 + i * 270 + rs() * 80, y = SPLIT + 120 + rs() * 90; g.fillStyle = 'rgba(239,230,210,.92)'; g.strokeStyle = C.ink; g.lineWidth = 2; g.beginPath(); g.ellipse(x, y, 26, 11, 0, 0, TAU); g.fill(); g.stroke(); g.beginPath(); g.ellipse(x + 26, y - 14, 8, 6, 0.3, 0, TAU); g.fill(); g.stroke(); [-14, 14].forEach(dx => { g.beginPath(); g.moveTo(x + dx, y + 8); g.lineTo(x + dx - 3, y + 26); g.stroke(); }); }
+ ground(g); band(g); divider(g); drapery(g);
+ // 上栏底部一圈淡淡的熏黑(油灯与岁月)
+ const gr = g.createLinearGradient(0, TOP, 0, SPLIT); gr.addColorStop(0, 'rgba(60,34,20,.26)'); gr.addColorStop(0.22, 'rgba(60,34,20,0)'); gr.addColorStop(1, 'rgba(60,34,20,.12)'); g.fillStyle = gr; g.fillRect(0, TOP, W, SPLIT - TOP);
+ // 覆盖层:龟裂、起甲露底、盐碱
+ over = P.canvas(); const o = over.getContext('2d'), r = rng(1999);
+ for (let k = 0; k < 18; k++) { let x = r() * W, y = TOP + r() * (BOT - TOP), a = r() * TAU; o.strokeStyle = 'rgba(30,14,10,.5)'; o.lineWidth = 1.2 + r() * 1.2; o.lineJoin = 'round'; o.beginPath(); o.moveTo(x, y);
+ const n = 10 + Math.floor(r() * 22); for (let i = 0; i < n; i++) { a += (r() - .5) * 0.9; x += Math.cos(a) * (12 + r() * 20); y += Math.sin(a) * (12 + r() * 20); o.lineTo(x, y); if (r() < 0.12) { o.stroke(); o.beginPath(); o.moveTo(x, y); a += (r() < 0.5 ? 1 : -1) * 0.9; } } o.stroke(); }
+ for (let k = 0; k < 22; k++) { const cx = r() * W, cy = TOP + r() * (BOT - TOP), n = 9 + Math.floor(r() * 6), R = 6 + r() * 22; o.fillStyle = r() < 0.6 ? 'rgba(206,176,136,.34)' : 'rgba(96,60,40,.26)'; o.beginPath();
+ for (let i = 0; i < n; i++) { const aa = i / n * TAU, rr = R * (0.45 + r() * 0.75); o.lineTo(cx + Math.cos(aa) * rr, cy + Math.sin(aa) * rr * 0.7); } o.closePath(); o.fill(); o.strokeStyle = 'rgba(40,20,12,.3)'; o.lineWidth = 1.4; o.stroke(); }
+ for (let k = 0; k < 260; k++) { o.fillStyle = `rgba(245,238,225,${0.1 + r() * 0.3})`; o.beginPath(); o.ellipse(r() * W, TOP + r() * (BOT - TOP), 1.5 + r() * 4.5, 1 + r() * 2.5, r() * 3, 0, TAU); o.fill(); }
+ }
+
+ // ---- 动态件 ----
+ const lineStroke = (c, w = 2.6) => { c.strokeStyle = C.line; c.lineWidth = w; c.lineJoin = 'round'; c.lineCap = 'round'; };
+ function ribbon(c, pts, w0, w1, fill, edge = C.line, hi = null) { // 变宽飘带:两侧沿法线展开,铁线描边
+ const L = [], R = [];
+ pts.forEach((p, i) => { const a = pts[Math.max(0, i - 1)], b = pts[Math.min(pts.length - 1, i + 1)], dx = b[0] - a[0], dy = b[1] - a[1], d = Math.hypot(dx, dy) || 1, nx = -dy / d, ny = dx / d, w = lerp(w0, w1, i / (pts.length - 1)) / 2; L.push([p[0] + nx * w, p[1] + ny * w]); R.push([p[0] - nx * w, p[1] - ny * w]); });
+ c.beginPath(); L.forEach((p, i) => i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); R.reverse().forEach(p => c.lineTo(p[0], p[1])); c.closePath(); c.fillStyle = fill; c.fill(); lineStroke(c, 2.2); c.strokeStyle = edge; c.stroke();
+ if (hi) { c.strokeStyle = hi; c.lineWidth = 2; c.beginPath(); pts.forEach((p, i) => i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); c.stroke(); }
+ }
+ function leaf(c, x, y, ang, len, col, col2, k) { // 西魏「风叶」:一撮向后翻卷的逗号形青绿叶,三尖
+ c.save(); c.translate(x, y); c.rotate(ang); c.scale(1, k);
+ c.beginPath(); c.moveTo(0, 0); c.bezierCurveTo(len * 0.25, -len * 0.5, len * 0.8, -len * 0.45, len, -len * 0.12); c.bezierCurveTo(len * 0.7, -len * 0.18, len * 0.5, -len * 0.1, len * 0.42, len * 0.06); c.bezierCurveTo(len * 0.3, len * 0.18, len * 0.1, len * 0.14, 0, 0); c.closePath();
+ c.fillStyle = col; c.fill(); lineStroke(c, 2); c.strokeStyle = col2; c.stroke();
+ c.strokeStyle = 'rgba(255,250,235,.8)'; c.lineWidth = 2.2; c.beginPath(); c.moveTo(len * 0.1, -len * 0.06); c.bezierCurveTo(len * 0.3, -len * 0.3, len * 0.6, -len * 0.3, len * 0.84, -len * 0.14); c.stroke();
+ c.restore();
+ }
+ function bloom(c, x, y, s, rot, col) { // 散花:四瓣白花,红心
+ c.save(); c.translate(x, y); c.rotate(rot); c.scale(s, s); c.fillStyle = col; lineStroke(c, 1.8 / s);
+ for (let i = 0; i < 4; i++) { c.save(); c.rotate(i * TAU / 4); c.beginPath(); c.ellipse(0, -9, 5.5, 9, 0, 0, TAU); c.fill(); c.stroke(); c.restore(); }
+ c.fillStyle = C.red; c.beginPath(); c.arc(0, 0, 3.2, 0, TAU); c.fill(); c.restore();
+ }
+ function lotus(c, x, y, s) {
+ c.save(); c.translate(x, y); c.scale(s, s); lineStroke(c, 2.2 / s);
+ [[-1.0, '#f1d9d0'], [1.0, '#f1d9d0'], [-0.5, '#f6e4dc'], [0.5, '#f6e4dc'], [0, '#fbeee8']].forEach(([a, col]) => { c.save(); c.rotate(a * 0.9 - 0.2); c.beginPath(); c.moveTo(0, 0); c.bezierCurveTo(-11, -14, -9, -32, 0, -40); c.bezierCurveTo(9, -32, 11, -14, 0, 0); c.fillStyle = col; c.fill(); c.stroke(); c.restore(); });
+ c.fillStyle = C.ochre; c.beginPath(); c.arc(0, -4, 5, 0, TAU); c.fill(); c.restore();
+ }
+ // 飞天(西魏式):水平横飞,头在前,披帛后扬,躯干与长裙是一条连贯的 S 形;脸小、眉眼细长、颊上一点红晕;红褐铁线勾边,肤色铅丹淡赭
+ function apsara(c, x, y, s, flip, t, ph = 0) {
+ c.save(); c.translate(x, y + Math.sin(t * 1.15 + ph) * 12); c.rotate(-0.07 + Math.sin(t * 0.9 + ph) * 0.03); c.scale(s * flip, s);
+ const w = (i, k) => Math.sin(t * 2.6 - i * 0.55 + ph + k), SK = '#eab894';
+ const sa = []; for (let i = 0; i <= 18; i++) sa.push([30 - i * 22, -30 - Math.sin(i * 0.22) * 34 + w(i, 0) * (3 + i * 1.5)]); ribbon(c, sa, 17, 3, C.teal, C.teal2, 'rgba(255,255,240,.75)');
+ const sb = []; for (let i = 0; i <= 12; i++) sb.push([24 - i * 20, 12 + w(i, 2) * (3 + i * 1.2) + i * 5]); ribbon(c, sb, 14, 3, C.ochre, C.line);
+ const sk = [[-16, 2]]; for (let i = 1; i <= 15; i++) sk.push([-16 - i * 23, 4 + Math.sin(i * 0.42 + t * 2.2 + ph) * (4 + i * 1.8) - i * 2.4]); // 长裙:从腰接出,越飘越尖
+ ribbon(c, sk, 52, 4, '#79b2a6', C.line, 'rgba(255,255,240,.5)'); c.strokeStyle = 'rgba(31,95,106,.7)'; c.lineWidth = 2; for (let k = -1; k <= 1; k += 2) { c.beginPath(); sk.slice(1, 13).forEach((p, i) => { const yy = p[1] + k * (12 - i * 0.8); i ? c.lineTo(p[0], yy) : c.moveTo(p[0], yy); }); c.stroke(); }
+ c.fillStyle = 'rgba(240,226,190,.8)'; for (let i = 2; i < 12; i += 2) { c.beginPath(); c.arc(sk[i][0], sk[i][1] - 2, 3.2, 0, TAU); c.fill(); }
+ ribbon(c, [[52, -28], [26, -18], [2, -6], [-22, 2]], 36, 30, SK, C.line); // 躯干:由肩向腰收
+ c.fillStyle = C.red; ribbon(c, [[-6, -14], [-8, -2], [-12, 10]], 10, 10, C.red, C.line); // 腰带
+ c.strokeStyle = C.teal; c.lineWidth = 4; c.beginPath(); c.arc(56, -34, 16, 0.4, 2.2); c.stroke(); c.fillStyle = C.ochre; c.beginPath(); c.arc(56, -17, 4, 0, TAU); c.fill(); lineStroke(c, 1.6); c.stroke(); // 璎珞
+ ribbon(c, [[40, -34], [24, -58], [0, -72]], 14, 10, SK, C.line); c.fillStyle = SK; c.beginPath(); c.arc(-6, -74, 7.5, 0, TAU); c.fill(); lineStroke(c, 2.2); c.stroke();
+ ribbon(c, [[52, -28], [84, -2 + w(0, 1) * 3], [112, -20]], 15, 11, SK, C.line); c.fillStyle = SK; c.beginPath(); c.arc(116, -22, 8, 0, TAU); c.fill(); lineStroke(c, 2.2); c.stroke(); lotus(c, 120, -26, 0.95);
+ const hr = []; for (let i = 0; i <= 8; i++) hr.push([62 - i * 12, -78 + i * 2.5 + w(i, 4) * (2 + i)]); ribbon(c, hr, 18, 3, C.dark, C.line); // 发尾后扬
+ c.fillStyle = SK; c.beginPath(); c.ellipse(80, -54, 20, 23, 0.12, 0, TAU); c.fill(); lineStroke(c, 2.6); c.stroke();
+ c.fillStyle = C.dark; c.beginPath(); c.moveTo(60, -58); c.bezierCurveTo(60, -86, 100, -88, 100, -60); c.bezierCurveTo(92, -72, 72, -72, 60, -58); c.fill(); c.beginPath(); c.arc(70, -86, 11, 0, TAU); c.fill(); c.strokeStyle = C.line; c.stroke();
+ c.fillStyle = C.ochre; [[78, -82], [86, -78], [92, -72]].forEach(([px, py]) => { c.beginPath(); c.arc(px, py, 2.8, 0, TAU); c.fill(); }); c.fillStyle = C.teal; c.beginPath(); c.arc(70, -97, 3.6, 0, TAU); c.fill();
+ c.fillStyle = 'rgba(223,120,96,.8)'; c.beginPath(); c.ellipse(92, -45, 7, 5.5, 0, 0, TAU); c.fill(); c.beginPath(); c.ellipse(68, -45, 6, 5, 0, 0, TAU); c.fill();
+ c.strokeStyle = C.line; c.lineWidth = 2.2; c.beginPath(); c.moveTo(80, -64); c.quadraticCurveTo(90, -69, 99, -62); c.moveTo(62, -63); c.quadraticCurveTo(68, -68, 77, -64); c.stroke();
+ c.lineWidth = 2.6; c.beginPath(); c.moveTo(83, -57); c.quadraticCurveTo(91, -60, 98, -56); c.moveTo(62, -57); c.quadraticCurveTo(69, -60, 76, -57); c.stroke(); c.fillStyle = C.dark; c.beginPath(); c.arc(91, -57, 2, 0, TAU); c.arc(69, -57, 1.8, 0, TAU); c.fill();
+ c.strokeStyle = C.line; c.lineWidth = 1.8; c.beginPath(); c.moveTo(82, -54); c.quadraticCurveTo(86, -46, 82, -43); c.stroke(); c.fillStyle = C.red; c.beginPath(); c.ellipse(80, -36, 4.6, 2.3, 0, 0, TAU); c.fill();
+ c.restore();
+ }
+ // 白鹿(鹿王本生式):侧身,身子是一整块白,只有轮廓与脊背一线赭点;奔跑用「腾空伸展—收拢」的两拍,前后腿成对错开
+ function deer(c, x, y, s, t, ph, col = C.white) {
+ const f = t * 5.2 + ph, g = Math.sin(f), jump = Math.max(0, Math.sin(f + 1.1)) * 20;
+ c.save(); c.translate(x, y - jump * s); c.rotate(-g * 0.03); c.scale(s, s); c.lineJoin = 'round'; c.lineCap = 'round';
+ const leg = (hx, hy, a, front) => { // a∈[-1,1]:前摆为正;前腿膝向前弯、后腿膝向后弯
+ const th = a * 0.95, kn = [hx + Math.sin(th) * 52, hy + Math.cos(th) * 52], th2 = th + (front ? -1 : 1) * (0.55 + 0.45 * (1 - a * (front ? 1 : -1)) * 0.5), fo = [kn[0] + Math.sin(th2 + (front ? 0.25 : -0.1)) * 56, kn[1] + Math.cos(th2) * 56];
+ ribbon(c, [[hx, hy], [kn[0], kn[1]], [fo[0], fo[1]]], 22, 8, col, C.line); c.fillStyle = C.ochre; c.beginPath(); c.ellipse(fo[0] + 3, fo[1] - 2, 8, 4.5, 0.2, 0, TAU); c.fill(); c.strokeStyle = C.line; c.lineWidth = 2; c.stroke(); };
+ leg(-56, -78, -g * 0.9, false); leg(-40, -76, g * 0.9 + 0.2, false); leg(50, -80, g * 0.9, true); leg(64, -78, -g * 0.9 + 0.2, true);
+ c.beginPath(); c.moveTo(-90, -92); c.bezierCurveTo(-70, -132, 30, -138, 68, -114); c.bezierCurveTo(90, -126, 100, -150, 112, -172); c.bezierCurveTo(124, -190, 150, -190, 160, -174); c.bezierCurveTo(150, -158, 130, -156, 120, -146); c.bezierCurveTo(116, -118, 100, -90, 70, -76); c.bezierCurveTo(28, -56, -30, -56, -64, -66); c.bezierCurveTo(-84, -70, -98, -82, -90, -92); c.closePath();
+ c.fillStyle = col; c.fill(); lineStroke(c, 3.4); c.stroke();
+ c.fillStyle = C.ochre; for (let i = 0; i < 12; i++) { const q = i / 11, px = lerp(-70, 66, q), py = lerp(-100, -114, Math.sin(q * 2.2)) - 4; c.beginPath(); c.arc(px, py + (q > 0.8 ? (q - 0.8) * 40 : 0), 3.6, 0, TAU); c.fill(); }
+ c.strokeStyle = 'rgba(58,24,18,.55)'; c.lineWidth = 1.8; [[-22, -96, -8, -78], [10, -98, 22, -80], [-52, -90, -42, -74]].forEach(([a1, b1, a2, b2]) => { c.beginPath(); c.moveTo(a1, b1); c.quadraticCurveTo((a1 + a2) / 2 + 6, (b1 + b2) / 2, a2, b2); c.stroke(); });
+ c.fillStyle = col; lineStroke(c, 3); c.beginPath(); c.moveTo(110, -172); c.quadraticCurveTo(100, -204, 124, -214); c.quadraticCurveTo(124, -192, 124, -172); c.closePath(); c.fill(); c.stroke(); c.fillStyle = C.teal; c.beginPath(); c.moveTo(114, -184); c.quadraticCurveTo(112, -200, 121, -206); c.quadraticCurveTo(120, -194, 120, -184); c.fill();
+ c.strokeStyle = C.ochre; c.lineWidth = 5; c.beginPath(); c.moveTo(136, -186); c.quadraticCurveTo(148, -222, 176, -230); c.moveTo(152, -212); c.lineTo(150, -240); c.moveTo(160, -222); c.lineTo(184, -220); c.stroke();
+ c.fillStyle = C.ink; c.beginPath(); c.arc(138, -172, 3.4, 0, TAU); c.fill(); c.strokeStyle = C.red; c.lineWidth = 1.8; c.beginPath(); c.arc(138, -172, 6, 0, TAU); c.stroke(); c.fillStyle = C.ink; c.beginPath(); c.ellipse(158, -173, 3, 2.2, 0, 0, TAU); c.fill();
+ c.fillStyle = col; c.beginPath(); c.moveTo(-88, -94); c.quadraticCurveTo(-116, -108, -112, -80); c.quadraticCurveTo(-100, -86, -88, -84); c.fill(); lineStroke(c, 2.6); c.stroke();
+ c.restore();
+ }
+
+ function draw(c, lt) {
+ if (!base) build();
+ const t = clamp(lt, 0, 6);
+ c.drawImage(base, 0, 0);
+ // 上栏:风叶(远处小的在前面,带浅色;大的青绿深色)整体向后(左)翻,速度分层
+ const rl = rng(285);
+ for (let i = 0; i < 26; i++) {
+ const sp = 70 + rl() * 120, y0 = TOP + 40 + rl() * (SPLIT - TOP - 100), ln = 60 + rl() * 80, x0 = rl() * (W + 300), k = 0.8 + rl() * 0.4, rot = (rl() - .5) * 0.7, col = rl() < 0.62 ? C.teal : rl() < 0.8 ? C.green : '#c9a23a';
+ const x = ((x0 - t * sp) % (W + 300) + (W + 300)) % (W + 300) - 150, y = y0 + Math.sin(t * 1.3 + i) * 10;
+ leaf(c, x, y, Math.PI + rot + Math.sin(t * 1.1 + i) * 0.1, ln, col, i % 5 === 0 ? C.line : C.teal2, k);
+ }
+ apsara(c, 1060, 262, 1.72, 1, t, 0); // 主飞天
+ apsara(c, 560, 150, 0.82, -1, t, 2.2); // 远处的小飞天,反向飞
+ const rb = rng(31); for (let i = 0; i < 16; i++) { const sp = 60 + rb() * 90, x = (((rb() * (W + 200)) - t * sp * 0.9) % (W + 200) + W + 200) % (W + 200) - 100, y = TOP + 30 + ((rb() * (SPLIT - TOP - 80)) + t * 28 * (0.5 + rb())) % (SPLIT - TOP - 60); bloom(c, x, y, 0.8 + rb() * 0.7, t * (0.6 + rb()) + i, C.white); }
+ // 下栏:白鹿领队,小鹿稍后;前后各一个相位
+ const run = (t / 6), x1 = 360 + run * 1000, x2 = 160 + run * 940;
+ deer(c, x2, GROUND + 22, 0.95, t, 1.6, '#e8dcc2'); deer(c, x1, GROUND + 32, 1.5, t, 0);
+ // 奔跑扬起的尘(鹿蹄后面)
+ for (let i = 0; i < 12; i++) { const q = ((t * 1.6 + i / 12) % 1), px = x1 - 60 - q * 150 - i * 4, py = GROUND + 30 - q * 40 - (i % 3) * 6; c.fillStyle = `rgba(214,190,150,${(1 - q) * 0.55})`; c.beginPath(); c.arc(px, py, 6 + q * 18, 0, TAU); c.fill(); }
+ // 覆盖层+泥壁相乘
+ c.drawImage(over, 0, 0);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.42; c.drawImage(P.texture('dh_mud', '#d9c6a6', { scale: 0.006, amt: 30, grain: 14, dark: '#9a7a54', seed: 21 }), 0, 0); c.restore();
+ // 漂在光里的尘
+ const rd = rng(5); for (let i = 0; i < 40; i++) { const x = (rd() * W + t * (6 + rd() * 10)) % W, y = TOP + rd() * (BOT - TOP) + Math.sin(t * 0.6 + i) * 6; c.fillStyle = `rgba(255,244,214,${0.1 + rd() * 0.14})`; c.beginPath(); c.arc(x, y, 1 + rd() * 1.8, 0, TAU); c.fill(); }
+ }
+ return { draw };
+})();
diff --git a/scripts/storyboard_lint.py b/scripts/storyboard_lint.py
index 8031606..07c8e2e 100644
--- a/scripts/storyboard_lint.py
+++ b/scripts/storyboard_lint.py
@@ -12,6 +12,7 @@
画风:一句话(一张风格卡或一种画法,全片只用这一种)
色板:色板名(paper/poster/ink/navy/bauhaus/snow/wood/chalk,或中文名)或 3–6 个色值
角色:无 / 只出手和背影 / 帧库 <路径>(AI 生帧)
+ 平面卡通窄例外:画风以37_rick_morty或52_south_park开头,角色写「原创语义SVG…」
允许蓝紫:<理由>(可选,只在用户点名要蓝紫时写)
然后是一张 markdown 表(模板与示例见 references/镜头表模板.md),每行一镜,列:
时间段 | 画面里的物 | 它在做什么 | 镜头 | 屏上字 | 做法(可选,建议写)| 标签(可选)
@@ -75,6 +76,7 @@ LOCK = re.compile(r"^\s*[-*]?\s*(?:\*\*)?(画风|色板|角色|允许蓝紫)(?:\
PALETTES = {"paper", "poster", "ink", "navy", "bauhaus", "snow", "wood", "chalk",
"纸本", "海报黄", "深墨", "海军", "包豪斯", "雪原", "暖木", "黑板"}
HEX = re.compile(r"#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b")
+FLAT_STYLE = re.compile(r"^(?:37_rick_morty|52_south_park)(?=$|[\s::,,;;·((])", re.I)
CHAR_BAD = re.compile(r"代码画|手写|svg|SVG|Q\s*版|q\s*版|小人|机器人|火柴人|卡通人")
CHAR_FRAMES = re.compile(r"帧库|frames|\.png|/")
CHAR_NONE = re.compile(r"无|没有|不出人|不出脸|只出手|手|背影|剪影")
@@ -433,10 +435,14 @@ def lint(text, script=None):
table.append((YELLOW, "⑬色板", f"色板「{pal}」不是色板名也没写色值", "写 references/色板.md 里的名字,或 3–6 个 #色值"))
ch = lock.get("角色", "")
frames = bool(ch and CHAR_FRAMES.search(ch))
- if ch and CHAR_BAD.search(ch) and not frames:
+ # Only the explicitly selected, documented flat-character routes; y4 still needs frames.
+ flat_svg = bool(FLAT_STYLE.search(lock.get("画风", ""))
+ and ch.startswith("原创语义SVG")
+ and not re.search(r"真人|写实", ch))
+ if ch and CHAR_BAD.search(ch) and not (frames or flat_svg):
table.append((RED, "⑭角色", f"角色写的是「{ch}」:代码画的小人和机器人已停用", "有生图能力就 AI 生帧(references/10-角色.md),没有就只出手、背影、剪影,或干脆不出人"))
for r in rows:
- if OBJ_CHAR.search(r["obj"]) and not frames:
+ if OBJ_CHAR.search(r["obj"]) and not (frames or flat_svg):
r["issues"].append((RED, "⑭角色", f"物列里有「{OBJ_CHAR.search(r['obj']).group(0)}」,角色却不是帧库",
"这一镜换成手、背影或一个物;要出角色先按 references/角色精细度.md 做帧库"))
if OBJ_FACE.search(r["obj"] + r["act"]):
diff --git a/scripts/voice_review.py b/scripts/voice_review.py
new file mode 100644
index 0000000..c85d27c
--- /dev/null
+++ b/scripts/voice_review.py
@@ -0,0 +1,42 @@
+"""读取安装目录外的模型检查记录;不联网、不更换默认模型。"""
+import json
+from datetime import datetime, timezone
+from pathlib import Path
+
+
+def review_status(provider, model, config_file=None, now=None):
+ if config_file is None:
+ from capabilities import config_path
+ config_file = config_path()
+ path = Path(config_file).expanduser().resolve().parent / 'voice-model-review.json'
+ result = {'provider': provider, 'selected_model': model,
+ 'last_checked_at': None, 'needs_check': True, 'record': str(path)}
+ try:
+ record = json.loads(path.read_text()).get('providers', {}).get(provider, {})
+ selection = record.get('selection', {})
+ result['selected_model'] = model or selection.get('model')
+ result['user_selection'] = selection
+ checked = record.get('checked_at')
+ stamp = datetime.fromisoformat(checked)
+ if stamp.tzinfo is None:
+ raise ValueError('检查时间需要时区')
+ age = ((now or datetime.now(timezone.utc)) - stamp).total_seconds()
+ result.update(last_checked_at=checked, needs_check=not 0 <= age < 7 * 86400,
+ candidates=record.get('models', []), findings=record.get('findings', ''))
+ except (OSError, ValueError, TypeError, AttributeError):
+ result['record_status'] = 'missing_or_invalid'
+ return result
+
+
+if __name__ == '__main__':
+ import argparse
+ p = argparse.ArgumentParser(description=__doc__)
+ p.add_argument('--provider', choices=['volcengine', 'qwen'], default='volcengine')
+ p.add_argument('--model')
+ p.add_argument('--config')
+ a = p.parse_args()
+ from capabilities import effective
+ model = a.model
+ if not model and a.provider == 'volcengine':
+ model = effective(a.config)[0]['provider_options']['volcengine']['model']
+ print(json.dumps(review_status(a.provider, model, a.config), ensure_ascii=False, indent=2))
diff --git a/tests/test_storyboard_lint.py b/tests/test_storyboard_lint.py
index 55c3843..211ae80 100644
--- a/tests/test_storyboard_lint.py
+++ b/tests/test_storyboard_lint.py
@@ -307,3 +307,30 @@ class CameraRhythm(unittest.TestCase):
def test_inward_synonyms(self):
self.assertIn("⑮推近", self.issues(self.lint(["慢推", "推进", "zoom in", "停", "拉远", "横移"])))
+
+
+class FlatStyleCharacters(unittest.TestCase):
+ HEAD = StyleLock.HEAD
+ ROWS = "| 0–3 | 原创卡通人 | 推开门 | 停 | | scenes/a.js |\n| 3–6 | 工具箱 | 被放到地上 | 横移 | | scenes/a.js |\n"
+
+ def role_errors(self, style, role, rows=None):
+ result = SL.lint(f"画风:{style}\n色板:paper\n角色:{role}\n\n" + self.HEAD + (rows or self.ROWS))
+ issues = result["table"] + [issue for row in result["rows"] for issue in row["issues"]]
+ return [i for i in issues if i[0] == SL.RED and i[1] == "⑭角色"]
+
+ def test_explicit_flat_svg_routes(self):
+ for style in ("52_south_park 南方公园式数字剪纸", "37_rick_morty Rick & Morty式平面卡通"):
+ with self.subTest(style=style):
+ self.assertFalse(self.role_errors(style, "原创语义SVG纸片角色"))
+
+ def test_other_styles_and_realistic_roles_still_blocked(self):
+ for style, role in (("雷诺阿", "原创语义SVG角色"),
+ ("52_south_park_extra", "原创语义SVG角色"),
+ ("52_south_park", "代码画Q版小人"),
+ ("52_south_park", "原创语义SVG写实真人")):
+ with self.subTest(style=style, role=role):
+ self.assertTrue(self.role_errors(style, role))
+
+ def test_y4_still_requires_frames(self):
+ rows = self.ROWS.replace("scenes/a.js", "y4 片段 a.json")
+ self.assertTrue(self.role_errors("52_south_park", "原创语义SVG纸片角色", rows))
diff --git a/tests/test_voice_review.py b/tests/test_voice_review.py
new file mode 100644
index 0000000..d70ac9d
--- /dev/null
+++ b/tests/test_voice_review.py
@@ -0,0 +1,34 @@
+import json
+from datetime import datetime, timezone
+from pathlib import Path
+import sys
+import tempfile
+import unittest
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'scripts'))
+from voice_review import review_status
+
+
+class ReviewTests(unittest.TestCase):
+ def test_missing_corrupt_stale_future_and_fresh(self):
+ with tempfile.TemporaryDirectory() as d:
+ config = Path(d) / 'media.json'
+ record = config.with_name('voice-model-review.json')
+ now = datetime(2026, 10, 15, tzinfo=timezone.utc)
+ def check():
+ return review_status('qwen', 'requested-model', config, now)
+ self.assertTrue(check()['needs_check'])
+ record.write_text('invalid json')
+ self.assertTrue(check()['needs_check'])
+ for stamp, stale in [('2026-10-15T00:00:00+00:00', False),
+ ('2026-10-08T00:00:00+00:00', True),
+ ('2026-10-16T00:00:00+00:00', True),
+ ('2026-10-15T00:00:00', True)]:
+ record.write_text(json.dumps({'providers': {'qwen': {'checked_at': stamp}}}))
+ self.assertEqual(check()['needs_check'], stale)
+ self.assertEqual(check()['selected_model'], 'requested-model')
+ self.assertTrue(review_status('volcengine', 'other', config, now)['needs_check'])
+
+
+if __name__ == '__main__':
+ unittest.main()