sera-code 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +9 -1
  2. package/bin/sera.mjs +31 -0
  3. package/dist/bundle/chunks/{chunk-LOMPDCMP.js → chunk-DFRGGJWV.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-AZC5WTED.js → chunk-EMXTNOOJ.js} +5 -5
  5. package/dist/bundle/chunks/{chunk-KXU77PUU.js → chunk-ET2ARYK4.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-ZNCN2NGY.js → chunk-G5BGS7HZ.js} +2 -2
  7. package/dist/bundle/chunks/{chunk-HODJBMOY.js → chunk-GSGPISRE.js} +3 -4
  8. package/dist/bundle/chunks/{chunk-46WGNYIE.js → chunk-NMUS7OCP.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-HQBQWHLD.js → chunk-RCQXVPCE.js} +1 -1
  10. package/dist/bundle/chunks/{cli-MML2DU4A.js → cli-NOCFT7AL.js} +1 -1
  11. package/dist/bundle/chunks/{execute-HXDNZ26B.js → execute-S2O3RL6V.js} +1 -1
  12. package/dist/bundle/chunks/github-copilot.js +1 -1
  13. package/dist/bundle/chunks/{runtime-JAH75CB5.js → runtime-BRT7AUXY.js} +1 -1
  14. package/dist/bundle/chunks/{virtual-modules-Z2V3PTLI.js → virtual-modules-QR2XYBMY.js} +1 -1
  15. package/dist/bundle/cli-runtime.js +1 -1
  16. package/dist/bundle/index.js +1 -1
  17. package/dist/bundle/rpc-entry.js +1 -1
  18. package/lib/postinstall.js +16 -0
  19. package/lib/update.js +85 -0
  20. package/lib/win-setup.js +96 -0
  21. package/package.json +4 -1
  22. package/sera-core/skills/ambalaj-tasarim/NOTICE +1 -0
  23. package/sera-core/skills/ambalaj-tasarim/SKILL.md +34 -0
  24. package/sera-core/skills/ambalaj-tasarim/dieline.mjs +17 -0
  25. package/sera-core/skills/ambalaj-tasarim/sera-pack.js +535 -0
  26. package/sera-core/skills/animasyonlu-site/NOTICE +1 -0
  27. package/sera-core/skills/animasyonlu-site/SKILL.md +26 -0
  28. package/sera-core/skills/animasyonlu-site/sera-motion.js +310 -0
  29. package/sera-core/skills/animate/LICENSE +21 -0
  30. package/sera-core/skills/animate/NOTICE +2 -0
  31. package/sera-core/skills/animate/RECIPES.md +324 -0
  32. package/sera-core/skills/animate/SKILL.md +209 -0
  33. package/sera-core/skills/astryx-ui/SKILL.md +37 -0
  34. package/sera-core/skills/awwwards/LICENSE +21 -0
  35. package/sera-core/skills/awwwards/NOTICE +5 -0
  36. package/sera-core/skills/awwwards/SKILL.md +357 -0
  37. package/sera-core/skills/awwwards/references/anatomy.md +103 -0
  38. package/sera-core/skills/awwwards/references/art-direction.md +114 -0
  39. package/sera-core/skills/awwwards/references/astro.md +235 -0
  40. package/sera-core/skills/awwwards/references/concepts.md +110 -0
  41. package/sera-core/skills/awwwards/references/content.md +88 -0
  42. package/sera-core/skills/awwwards/references/engine.md +751 -0
  43. package/sera-core/skills/awwwards/references/layout.md +81 -0
  44. package/sera-core/skills/awwwards/references/motion.md +463 -0
  45. package/sera-core/skills/awwwards/references/nextjs.md +386 -0
  46. package/sera-core/skills/awwwards/references/patterns.md +123 -0
  47. package/sera-core/skills/awwwards/references/quality-bar.md +151 -0
  48. package/sera-core/skills/awwwards/references/quality.md +91 -0
  49. package/sera-core/skills/awwwards/references/ship.md +36 -0
  50. package/sera-core/skills/awwwards/references/typography.md +135 -0
  51. package/sera-core/skills/awwwards/references/webgl.md +430 -0
  52. package/sera-core/skills/awwwards/scripts/audit.mjs +243 -0
  53. package/sera-core/skills/awwwards/scripts/browser.mjs +54 -0
  54. package/sera-core/skills/awwwards/scripts/font.mjs +87 -0
  55. package/sera-core/skills/awwwards/scripts/og.mjs +20 -0
  56. package/sera-core/skills/awwwards/scripts/photos.mjs +65 -0
  57. package/sera-core/skills/awwwards/scripts/serve.mjs +48 -0
  58. package/sera-core/skills/awwwards/scripts/shoot.mjs +675 -0
  59. package/sera-core/skills/beceri-yaz/SKILL.md +39 -0
  60. package/sera-core/skills/brag-slim/LICENSE +21 -0
  61. package/sera-core/skills/brag-slim/NOTICE +2 -0
  62. package/sera-core/skills/brag-slim/SKILL.md +108 -0
  63. package/sera-core/skills/brainstorming/LICENSE +21 -0
  64. package/sera-core/skills/brainstorming/NOTICE +5 -0
  65. package/sera-core/skills/brainstorming/SKILL.md +298 -0
  66. package/sera-core/skills/brainstorming/builder-check-prompt.md +23 -0
  67. package/sera-core/skills/copywriting/LICENSE +21 -0
  68. package/sera-core/skills/copywriting/NOTICE +5 -0
  69. package/sera-core/skills/copywriting/SKILL.md +343 -0
  70. package/sera-core/skills/copywriting/references/ai-tells.md +309 -0
  71. package/sera-core/skills/copywriting/references/copy-frameworks.md +432 -0
  72. package/sera-core/skills/copywriting/references/natural-transitions.md +256 -0
  73. package/sera-core/skills/cro/LICENSE +21 -0
  74. package/sera-core/skills/cro/NOTICE +5 -0
  75. package/sera-core/skills/cro/SKILL.md +198 -0
  76. package/sera-core/skills/cro/references/experiments.md +248 -0
  77. package/sera-core/skills/cro/references/form.md +422 -0
  78. package/sera-core/skills/derin-arastirma/referanslar/arastirma-yontem.md +11 -0
  79. package/sera-core/skills/emil-design-eng/LICENSE +21 -0
  80. package/sera-core/skills/emil-design-eng/NOTICE +2 -0
  81. package/sera-core/skills/emil-design-eng/SKILL.md +684 -0
  82. package/sera-core/skills/frontend-design/LICENSE.txt +177 -0
  83. package/sera-core/skills/frontend-design/NOTICE +2 -0
  84. package/sera-core/skills/frontend-design/SKILL.md +71 -0
  85. package/sera-core/skills/gorsel-denetim/SKILL.md +30 -0
  86. package/sera-core/skills/hallmark/LICENSE +21 -0
  87. package/sera-core/skills/hallmark/NOTICE +5 -0
  88. package/sera-core/skills/hallmark/SKILL.md +154 -0
  89. package/sera-core/skills/hallmark/references/anatomy.md +71 -0
  90. package/sera-core/skills/hallmark/references/brand-truth.md +40 -0
  91. package/sera-core/skills/hallmark/references/comp.md +104 -0
  92. package/sera-core/skills/hallmark/references/craft.md +116 -0
  93. package/sera-core/skills/hallmark/references/dark-mode.md +49 -0
  94. package/sera-core/skills/hallmark/references/data-viz.md +48 -0
  95. package/sera-core/skills/hallmark/references/design-md.md +53 -0
  96. package/sera-core/skills/hallmark/references/direction.md +52 -0
  97. package/sera-core/skills/hallmark/references/export-formats.md +80 -0
  98. package/sera-core/skills/hallmark/references/flow.md +131 -0
  99. package/sera-core/skills/hallmark/references/fonts.md +58 -0
  100. package/sera-core/skills/hallmark/references/gates.md +243 -0
  101. package/sera-core/skills/hallmark/references/genres/atmospheric.md +24 -0
  102. package/sera-core/skills/hallmark/references/genres/editorial.md +24 -0
  103. package/sera-core/skills/hallmark/references/genres/modern-minimal.md +24 -0
  104. package/sera-core/skills/hallmark/references/genres/playful.md +24 -0
  105. package/sera-core/skills/hallmark/references/imagery.md +99 -0
  106. package/sera-core/skills/hallmark/references/interaction-and-states.md +89 -0
  107. package/sera-core/skills/hallmark/references/layout.md +104 -0
  108. package/sera-core/skills/hallmark/references/macrostructures/01-bento-grid.md +21 -0
  109. package/sera-core/skills/hallmark/references/macrostructures/02-long-document.md +35 -0
  110. package/sera-core/skills/hallmark/references/macrostructures/03-marquee-hero.md +21 -0
  111. package/sera-core/skills/hallmark/references/macrostructures/04-stat-led.md +21 -0
  112. package/sera-core/skills/hallmark/references/macrostructures/05-workbench.md +21 -0
  113. package/sera-core/skills/hallmark/references/macrostructures/06-conversational-faq.md +28 -0
  114. package/sera-core/skills/hallmark/references/macrostructures/07-manifesto.md +28 -0
  115. package/sera-core/skills/hallmark/references/macrostructures/08-photographic.md +21 -0
  116. package/sera-core/skills/hallmark/references/macrostructures/09-quote-led.md +21 -0
  117. package/sera-core/skills/hallmark/references/macrostructures/10-specimen.md +21 -0
  118. package/sera-core/skills/hallmark/references/macrostructures/11-catalogue.md +21 -0
  119. package/sera-core/skills/hallmark/references/macrostructures/12-letter.md +21 -0
  120. package/sera-core/skills/hallmark/references/macrostructures/13-index-first.md +21 -0
  121. package/sera-core/skills/hallmark/references/macrostructures/14-narrative-workflow.md +21 -0
  122. package/sera-core/skills/hallmark/references/macrostructures/15-split-studio.md +21 -0
  123. package/sera-core/skills/hallmark/references/macrostructures/16-feature-stack.md +23 -0
  124. package/sera-core/skills/hallmark/references/macrostructures/17-type-specimen.md +19 -0
  125. package/sera-core/skills/hallmark/references/macrostructures/18-portfolio-grid.md +21 -0
  126. package/sera-core/skills/hallmark/references/macrostructures/19-map-diagram.md +21 -0
  127. package/sera-core/skills/hallmark/references/macrostructures/20-ecosystem-index.md +19 -0
  128. package/sera-core/skills/hallmark/references/macrostructures/21-component-playground.md +21 -0
  129. package/sera-core/skills/hallmark/references/macrostructures.md +119 -0
  130. package/sera-core/skills/hallmark/references/microinteractions.md +80 -0
  131. package/sera-core/skills/hallmark/references/patterns.md +202 -0
  132. package/sera-core/skills/hallmark/references/redesign.md +88 -0
  133. package/sera-core/skills/hallmark/references/responsive.md +46 -0
  134. package/sera-core/skills/hallmark/references/review-finish.md +19 -0
  135. package/sera-core/skills/hallmark/references/review-hero.md +20 -0
  136. package/sera-core/skills/hallmark/references/scroll-choreography.md +110 -0
  137. package/sera-core/skills/hallmark/references/texture.md +90 -0
  138. package/sera-core/skills/hallmark/references/themes/README.md +58 -0
  139. package/sera-core/skills/hallmark/references/themes/almanac.md +103 -0
  140. package/sera-core/skills/hallmark/references/themes/arcade.md +102 -0
  141. package/sera-core/skills/hallmark/references/themes/atelier.md +98 -0
  142. package/sera-core/skills/hallmark/references/themes/bloom.md +102 -0
  143. package/sera-core/skills/hallmark/references/themes/blueprint.md +103 -0
  144. package/sera-core/skills/hallmark/references/themes/broadside.md +108 -0
  145. package/sera-core/skills/hallmark/references/themes/brutal.md +95 -0
  146. package/sera-core/skills/hallmark/references/themes/carnival.md +104 -0
  147. package/sera-core/skills/hallmark/references/themes/cobalt.md +101 -0
  148. package/sera-core/skills/hallmark/references/themes/console.md +99 -0
  149. package/sera-core/skills/hallmark/references/themes/coral.md +102 -0
  150. package/sera-core/skills/hallmark/references/themes/darkroom.md +99 -0
  151. package/sera-core/skills/hallmark/references/themes/dose.md +98 -0
  152. package/sera-core/skills/hallmark/references/themes/dusk.md +105 -0
  153. package/sera-core/skills/hallmark/references/themes/editorial.md +97 -0
  154. package/sera-core/skills/hallmark/references/themes/formwork.md +107 -0
  155. package/sera-core/skills/hallmark/references/themes/furrow.md +98 -0
  156. package/sera-core/skills/hallmark/references/themes/garden.md +97 -0
  157. package/sera-core/skills/hallmark/references/themes/grid.md +101 -0
  158. package/sera-core/skills/hallmark/references/themes/halftone.md +106 -0
  159. package/sera-core/skills/hallmark/references/themes/hedgerow.md +104 -0
  160. package/sera-core/skills/hallmark/references/themes/hum.md +99 -0
  161. package/sera-core/skills/hallmark/references/themes/ink.md +106 -0
  162. package/sera-core/skills/hallmark/references/themes/kiln.md +108 -0
  163. package/sera-core/skills/hallmark/references/themes/loom.md +106 -0
  164. package/sera-core/skills/hallmark/references/themes/lumen.md +103 -0
  165. package/sera-core/skills/hallmark/references/themes/manifesto.md +101 -0
  166. package/sera-core/skills/hallmark/references/themes/midnight.md +97 -0
  167. package/sera-core/skills/hallmark/references/themes/newsprint.md +102 -0
  168. package/sera-core/skills/hallmark/references/themes/overprint.md +101 -0
  169. package/sera-core/skills/hallmark/references/themes/pasteup.md +100 -0
  170. package/sera-core/skills/hallmark/references/themes/piste.md +99 -0
  171. package/sera-core/skills/hallmark/references/themes/refract.md +101 -0
  172. package/sera-core/skills/hallmark/references/themes/ribbon.md +106 -0
  173. package/sera-core/skills/hallmark/references/themes/rim.md +96 -0
  174. package/sera-core/skills/hallmark/references/themes/riso.md +98 -0
  175. package/sera-core/skills/hallmark/references/themes/solstice.md +104 -0
  176. package/sera-core/skills/hallmark/references/themes/specimen.md +100 -0
  177. package/sera-core/skills/hallmark/references/themes/spore.md +104 -0
  178. package/sera-core/skills/hallmark/references/themes/sport.md +101 -0
  179. package/sera-core/skills/hallmark/references/themes/squeeze.md +99 -0
  180. package/sera-core/skills/hallmark/references/themes/sticker.md +106 -0
  181. package/sera-core/skills/hallmark/references/themes/studio.md +99 -0
  182. package/sera-core/skills/hallmark/references/themes/terminal.md +96 -0
  183. package/sera-core/skills/hallmark/references/themes/terrazzo.md +106 -0
  184. package/sera-core/skills/hallmark/references/themes/ultraviolet.md +106 -0
  185. package/sera-core/skills/hallmark/references/themes/vantage.md +99 -0
  186. package/sera-core/skills/hallmark/references/themes/vellum.md +105 -0
  187. package/sera-core/skills/hallmark/references/themes/wayfind.md +105 -0
  188. package/sera-core/skills/hallmark/references/themes/werkstatt.md +105 -0
  189. package/sera-core/skills/hallmark/scripts/capture.mjs +132 -0
  190. package/sera-core/skills/hallmark/scripts/refcheck.mjs +405 -0
  191. package/sera-core/skills/hallmark/scripts/sloplint-render.mjs +1283 -0
  192. package/sera-core/skills/hallmark/scripts/sloplint.mjs +4426 -0
  193. package/sera-core/skills/hallmark/scripts/theme.mjs +660 -0
  194. package/sera-core/skills/kurum-ici-iletisim/SKILL.md +40 -0
  195. package/sera-core/skills/launch/LICENSE +21 -0
  196. package/sera-core/skills/launch/NOTICE +5 -0
  197. package/sera-core/skills/launch/SKILL.md +385 -0
  198. package/sera-core/skills/launch/references/shipped-changes.md +84 -0
  199. package/sera-core/skills/launch/references/site-launch-qa.md +57 -0
  200. package/sera-core/skills/marka-kimligi/SKILL.md +30 -0
  201. package/sera-core/skills/mcp-yaz/SKILL.md +41 -0
  202. package/sera-core/skills/mobil-arayuz/SKILL.md +12 -0
  203. package/sera-core/skills/mvp-scoping/LICENSE +21 -0
  204. package/sera-core/skills/mvp-scoping/NOTICE +5 -0
  205. package/sera-core/skills/mvp-scoping/SKILL.md +95 -0
  206. package/sera-core/skills/ortak-yazarlik/SKILL.md +32 -0
  207. package/sera-core/skills/oyun-turleri/SKILL.md +176 -0
  208. package/sera-core/skills/paralel-sadelestirme/SKILL.md +33 -0
  209. package/sera-core/skills/phaser-core/LICENSE +201 -0
  210. package/sera-core/skills/phaser-core/NOTICE +5 -0
  211. package/sera-core/skills/phaser-core/NOTICE-UPSTREAM +15 -0
  212. package/sera-core/skills/phaser-core/SKILL.md +245 -0
  213. package/sera-core/skills/phaser-core/references/scene-flow.md +177 -0
  214. package/sera-core/skills/pitch-deck/LICENSE +21 -0
  215. package/sera-core/skills/pitch-deck/NOTICE +5 -0
  216. package/sera-core/skills/pitch-deck/SKILL.md +103 -0
  217. package/sera-core/skills/sera-3d-oyun/NOTICE +1 -0
  218. package/sera-core/skills/sera-3d-oyun/SKILL.md +12 -0
  219. package/sera-core/skills/sera-3d-oyun/sera-3d.js +3697 -0
  220. package/sera-core/skills/sera-diyagram/SKILL.md +43 -0
  221. package/sera-core/skills/sera-ofis-dosya/SKILL.md +3 -0
  222. package/sera-core/skills/sera-ofis-dosya/referanslar/ofis-ileri.md +46 -0
  223. package/sera-core/skills/sera-ui-site/NOTICE +1 -0
  224. package/sera-core/skills/sera-ui-site/SKILL.md +10 -0
  225. package/sera-core/skills/sera-ui-site/sera-ui.js +83 -0
  226. package/sera-core/skills/sera-veri-gorsel/SKILL.md +3 -0
  227. package/sera-core/skills/sera-veri-gorsel/referanslar/palet-dogrula.mjs +80 -0
  228. package/sera-core/skills/sistem-tarama/SKILL.md +49 -0
  229. package/sera-core/skills/sistem-tarama/referanslar/komutlar.md +78 -0
  230. package/sera-core/skills/tasarim-stilleri/SKILL.md +113 -0
  231. package/sera-core/skills/teardown/LICENSE +22 -0
  232. package/sera-core/skills/teardown/NOTICE +3 -0
  233. package/sera-core/skills/teardown/SKILL.md +144 -0
  234. package/sera-core/skills/teardown/package-lock.json +545 -0
  235. package/sera-core/skills/teardown/package.json +18 -0
  236. package/sera-core/skills/teardown/paths.mjs +30 -0
  237. package/sera-core/skills/teardown/run_sfx.py +10 -0
  238. package/sera-core/skills/teardown/sfx/__init__.py +10 -0
  239. package/sera-core/skills/teardown/sfx/__main__.py +64 -0
  240. package/sera-core/skills/teardown/sfx/dsp.py +453 -0
  241. package/sera-core/skills/teardown/sfx/loudness.py +72 -0
  242. package/sera-core/skills/teardown/sfx/mix.py +111 -0
  243. package/sera-core/skills/teardown/sfx/samples/SOURCES.md +23 -0
  244. package/sera-core/skills/teardown/sfx/samples/fs-258269-mouth-pop.ogg +0 -0
  245. package/sera-core/skills/teardown/sfx/samples/fs-323432-typing.ogg +0 -0
  246. package/sera-core/skills/teardown/sfx/samples/fs-329533-room-tone-in-an-apartment-livi.ogg +0 -0
  247. package/sera-core/skills/teardown/sfx/samples/fs-329569-roomtone-bedroom-yew.ogg +0 -0
  248. package/sera-core/skills/teardown/sfx/samples/fs-339521-vhs-rewind-forward-and-eject.ogg +0 -0
  249. package/sera-core/skills/teardown/sfx/samples/fs-349504-triangle-open-04.ogg +0 -0
  250. package/sera-core/skills/teardown/sfx/samples/fs-416777-digital-typing-wav.ogg +0 -0
  251. package/sera-core/skills/teardown/sfx/samples/fs-426767-apartment-room-tone-wav.ogg +0 -0
  252. package/sera-core/skills/teardown/sfx/samples/fs-447909-keyboard-typing.ogg +0 -0
  253. package/sera-core/skills/teardown/sfx/samples/fs-447910-plop.ogg +0 -0
  254. package/sera-core/skills/teardown/sfx/samples/fs-79388-keyboard-typing-wav.ogg +0 -0
  255. package/sera-core/skills/teardown/sfx/samples/fs-824189-pop-in-sfx.ogg +0 -0
  256. package/sera-core/skills/teardown/sfx/score_kit.py +206 -0
  257. package/sera-core/skills/teardown/sfx/synth.py +294 -0
  258. package/sera-core/skills/teardown/sheet.mjs +127 -0
  259. package/sera-core/skills/teardown/sims/beats.py +212 -0
  260. package/sera-core/skills/teardown/sims/build.mjs +141 -0
  261. package/sera-core/skills/teardown/sims/capture.mjs +211 -0
  262. package/sera-core/skills/teardown/sims/cessna-film/main.js +4 -0
  263. package/sera-core/skills/teardown/sims/cessna-film/timeline.json +1 -0
  264. package/sera-core/skills/teardown/sims/cessna-live/main.js +5 -0
  265. package/sera-core/skills/teardown/sims/cessna-shared/console.js +288 -0
  266. package/sera-core/skills/teardown/sims/cessna-shared/film.js +254 -0
  267. package/sera-core/skills/teardown/sims/cessna-shared/flight.js +53 -0
  268. package/sera-core/skills/teardown/sims/cessna-shared/gear.js +364 -0
  269. package/sera-core/skills/teardown/sims/cessna-shared/live.js +351 -0
  270. package/sera-core/skills/teardown/sims/cessna-shared/score.py +41 -0
  271. package/sera-core/skills/teardown/sims/cessna-shared/stage.js +248 -0
  272. package/sera-core/skills/teardown/sims/kit/director.js +300 -0
  273. package/sera-core/skills/teardown/sims/kit/hud.js +194 -0
  274. package/sera-core/skills/teardown/sims/kit/runtime.js +168 -0
  275. package/sera-core/skills/teardown/sims/kit/stage3d.js +114 -0
  276. package/sera-core/skills/teardown/sims/kit/style.css +137 -0
  277. package/sera-core/skills/teardown/sims/kit/util.js +79 -0
  278. package/sera-core/skills/teardown/sims/kit/warm.js +66 -0
  279. package/sera-core/skills/teardown/sims/strandbeest-film/main.js +4 -0
  280. package/sera-core/skills/teardown/sims/strandbeest-film/timeline.json +1 -0
  281. package/sera-core/skills/teardown/sims/strandbeest-live/main.js +5 -0
  282. package/sera-core/skills/teardown/sims/strandbeest-shared/beast.js +419 -0
  283. package/sera-core/skills/teardown/sims/strandbeest-shared/console.js +375 -0
  284. package/sera-core/skills/teardown/sims/strandbeest-shared/film.js +352 -0
  285. package/sera-core/skills/teardown/sims/strandbeest-shared/jansen.js +67 -0
  286. package/sera-core/skills/teardown/sims/strandbeest-shared/live.js +420 -0
  287. package/sera-core/skills/teardown/sims/strandbeest-shared/score.py +85 -0
  288. package/sera-core/skills/teardown/sims/strandbeest-shared/stage.js +463 -0
  289. package/sera-core/skills/teardown/sims/v8-film/main.js +4 -0
  290. package/sera-core/skills/teardown/sims/v8-film/timeline.json +1 -0
  291. package/sera-core/skills/teardown/sims/v8-live/main.js +5 -0
  292. package/sera-core/skills/teardown/sims/v8-shared/console.js +339 -0
  293. package/sera-core/skills/teardown/sims/v8-shared/engine.js +624 -0
  294. package/sera-core/skills/teardown/sims/v8-shared/film.js +239 -0
  295. package/sera-core/skills/teardown/sims/v8-shared/kin.js +86 -0
  296. package/sera-core/skills/teardown/sims/v8-shared/live.js +374 -0
  297. package/sera-core/skills/teardown/sims/v8-shared/score.py +60 -0
  298. package/sera-core/skills/teardown/sims/v8-shared/stage.js +173 -0
  299. package/sera-core/skills/teardown/wave.mjs +67 -0
  300. package/sera-core/skills/toplu-degisiklik/SKILL.md +39 -0
  301. package/sera-core/skills/ui-ux-pro-max/LICENSE +21 -0
  302. package/sera-core/skills/ui-ux-pro-max/NOTICE +5 -0
  303. package/sera-core/skills/ui-ux-pro-max/SKILL.md +13 -0
  304. package/sera-core/skills/ui-ux-pro-max/references/pro-rules.md +117 -0
  305. package/sera-core/skills/ui-ux-pro-max/references/quick-reference.md +266 -0
  306. package/sera-core/skills/unslop/LICENSE.md +410 -0
  307. package/sera-core/skills/unslop/SKILL.md +217 -0
  308. package/sera-core/skills/unslop/references/effects.md +113 -0
  309. package/sera-core/skills/unslop/references/refs/unslop-dashboard-after.webp +0 -0
  310. package/sera-core/skills/unslop/references/refs/unslop-hero-after.webp +0 -0
  311. package/sera-core/skills/unslop/references/refs.md +16 -0
  312. package/sera-core/skills/unslop/references/rtl.md +72 -0
  313. package/sera-core/skills/unslop/references/signs.md +125 -0
  314. package/sera-core/skills/unslop/references/tokens.md +137 -0
  315. package/sera-core/skills/unslop/references/visuals.md +84 -0
  316. package/sera-core/skills/unslop/scripts/snapshot.mjs +197 -0
  317. package/sera-core/skills/uretken-sanat/SKILL.md +42 -0
  318. package/sera-core/skills/verification-before-completion/LICENSE +21 -0
  319. package/sera-core/skills/verification-before-completion/NOTICE +5 -0
  320. package/sera-core/skills/verification-before-completion/SKILL.md +120 -0
  321. package/sera-core/skills/web-yayin-listesi/SKILL.md +3 -0
  322. package/sera-core/src/app-master.ts +2 -2
  323. package/sera-core/src/app-verify.ts +33 -0
  324. package/sera-core/src/auto-memory.ts +249 -0
  325. package/sera-core/src/extension.ts +69 -3
  326. package/sera-core/src/generated/build-rules.ts +81 -17
  327. package/sera-core/src/generated/quality-probe.ts +2 -0
  328. package/sera-core/src/generated/zero-knowledge.ts +36 -9
  329. package/sera-core/src/image-tool.ts +124 -7
  330. package/sera-core/src/link-data-tools.ts +411 -0
  331. package/sera-core/src/skills.ts +54 -18
  332. package/sera-core/src/video-tool.ts +51 -0
  333. package/sera-core/src/zk.ts +7 -3
@@ -0,0 +1,624 @@
1
+ // The V8 itself, built from code in millimetres in the look of a clean study model: a gloss-black open block of
2
+ // V-shaped bulkheads, glass cylinder liners with the charge inside them, polished pistons, black rods, a cross-plane
3
+ // crank with counterweights, two valves per cylinder with coil springs under a black rocker cage and a camshaft per
4
+ // bank, white spark plugs, black exhaust bends, helical timing gears and a pulley at the front, the flywheel at the
5
+ // back, and red overlay arrows. update(th, ops) poses everything for crank angle th (degrees).
6
+ import * as THREE from 'three';
7
+ import {BANK, chargeOf, CYL, E, FIRE, liftEx, liftIn, piston, pinXY, psi, PIN_PHASE, pressure, VALVE} from './kin.js';
8
+
9
+ const V3 = THREE.Vector3;
10
+ const D2R = Math.PI / 180;
11
+ const DECK = E.deck;
12
+ const smoother = (x) => {
13
+ const u = Math.min(1, Math.max(0, x));
14
+ return u * u * u * (u * (u * 6 - 15) + 10);
15
+ };
16
+
17
+ // ------------------------------------------------------------ geometry helpers
18
+ function gearGeo(teeth, rOut, rRoot, width, helix = 0, holeR = 0) {
19
+ const sh = new THREE.Shape();
20
+ for (let i = 0; i < teeth; i++) {
21
+ const a0 = (i / teeth) * Math.PI * 2;
22
+ const da = (Math.PI * 2) / teeth;
23
+ const pts = [
24
+ [rRoot, a0],
25
+ [rRoot, a0 + da * 0.2],
26
+ [rOut, a0 + da * 0.33],
27
+ [rOut, a0 + da * 0.62],
28
+ [rRoot, a0 + da * 0.75],
29
+ ];
30
+ pts.forEach(([r, a], k) => (i === 0 && k === 0 ? sh.moveTo(r * Math.cos(a), r * Math.sin(a)) : sh.lineTo(r * Math.cos(a), r * Math.sin(a))));
31
+ }
32
+ sh.closePath();
33
+ if (holeR) {
34
+ const h = new THREE.Path();
35
+ h.absarc(0, 0, holeR, 0, Math.PI * 2, true);
36
+ sh.holes.push(h);
37
+ }
38
+ const g = new THREE.ExtrudeGeometry(sh, {depth: width, bevelEnabled: true, bevelThickness: 1.2, bevelSize: 1.0, bevelSegments: 1, curveSegments: 4});
39
+ g.translate(0, 0, -width / 2);
40
+ if (helix) {
41
+ const p = g.attributes.position;
42
+ for (let i = 0; i < p.count; i++) {
43
+ const a = (p.getZ(i) / width) * helix;
44
+ const x = p.getX(i);
45
+ const y = p.getY(i);
46
+ p.setXY(i, x * Math.cos(a) - y * Math.sin(a), x * Math.sin(a) + y * Math.cos(a));
47
+ }
48
+ }
49
+ g.computeVertexNormals();
50
+ return g;
51
+ }
52
+ // a gear's blank: a plain disc at the pitch radius, the same width, bevel and bore, no teeth
53
+ function discGeo(r, width, holeR = 0, seg = 48) {
54
+ const sh = new THREE.Shape();
55
+ sh.absarc(0, 0, r, 0, Math.PI * 2, false);
56
+ if (holeR) {
57
+ const h = new THREE.Path();
58
+ h.absarc(0, 0, holeR, 0, Math.PI * 2, true);
59
+ sh.holes.push(h);
60
+ }
61
+ const g = new THREE.ExtrudeGeometry(sh, {depth: width, bevelEnabled: true, bevelThickness: 1.2, bevelSize: 1.0, bevelSegments: 1, curveSegments: seg});
62
+ g.translate(0, 0, -width / 2);
63
+ return g;
64
+ }
65
+ function helixGeo(r, wire, turns, len, seg = 220) {
66
+ const pts = [];
67
+ for (let i = 0; i <= seg; i++) {
68
+ const u = i / seg;
69
+ const a = u * turns * Math.PI * 2;
70
+ pts.push(new V3(Math.cos(a) * r, u * len, Math.sin(a) * r));
71
+ }
72
+ return new THREE.TubeGeometry(new THREE.CatmullRomCurve3(pts), seg, wire, 8, false);
73
+ }
74
+ // a crank web: the main boss, the pin boss and a counterweight sector opposite the pin, in the XY plane
75
+ function webGeo(thick, cs = 28) {
76
+ const sh = new THREE.Shape();
77
+ const R = 76;
78
+ // the counterweight: a fat sector below the axis, flanks running up to the pin boss
79
+ sh.moveTo(-R * Math.sin(1.05), -R * Math.cos(1.05));
80
+ sh.absarc(0, 0, R, -Math.PI / 2 - 1.05, -Math.PI / 2 + 1.05, false);
81
+ sh.lineTo(30, 10);
82
+ sh.absarc(0, E.r, 31, 0, Math.PI, false);
83
+ sh.lineTo(-30, 10);
84
+ sh.closePath();
85
+ const g = new THREE.ExtrudeGeometry(sh, {depth: thick, bevelEnabled: true, bevelThickness: 2, bevelSize: 2, bevelSegments: 2, curveSegments: cs});
86
+ g.translate(0, 0, -thick / 2);
87
+ return g;
88
+ }
89
+ // a V bulkhead: the crank bore, two arms up to each bank's deck
90
+ function bulkheadGeo(thick, cs = 24) {
91
+ const sh = new THREE.Shape();
92
+ const W = 54; // arm half width across the bank
93
+ const pts = [];
94
+ const arm = (bank, w, d) => {
95
+ const B = BANK[bank];
96
+ return [d * B.b[0] + w * B.p[0], d * B.b[1] + w * B.p[1]];
97
+ };
98
+ pts.push([-95, -70], [95, -70]);
99
+ pts.push(arm('L', W + 20, 40), arm('L', W, DECK - 10), arm('L', -W, DECK - 10), [0, 120]);
100
+ pts.push(arm('R', -W, DECK - 10), arm('R', W, DECK - 10), arm('R', W + 20, 40));
101
+ // the R arm's outward side is the -x side; walk the outline in order
102
+ const ordered = [[-95, -70], [95, -70], arm('L', W + 18, 40), arm('L', W, DECK - 12), arm('L', -W, DECK - 12), [0, 118], arm('R', -W, DECK - 12), arm('R', W, DECK - 12), arm('R', W + 18, 40)];
103
+ void pts;
104
+ ordered.forEach(([x, y], i) => (i ? sh.lineTo(x, y) : sh.moveTo(x, y)));
105
+ sh.closePath();
106
+ const hole = new THREE.Path();
107
+ hole.absarc(0, 0, 44, 0, Math.PI * 2, true);
108
+ sh.holes.push(hole);
109
+ const g = new THREE.ExtrudeGeometry(sh, {depth: thick, bevelEnabled: true, bevelThickness: 2, bevelSize: 2, bevelSegments: 2, curveSegments: cs});
110
+ g.translate(0, 0, -thick / 2);
111
+ return g;
112
+ }
113
+
114
+ /** opts.plain: the same engine a notch simpler (the A/B film's version B): gears as toothless discs, each valve's
115
+ * two coil springs as one plain sleeve, no piston rings, no pulley bolts. Absent, the engine is built as before.
116
+ * opts.lo: the teardown A/B's version B, clearly cheaper: everything plain drops, plus flat-shaded Lambert for every
117
+ * material, opaque liners, a sixth of the segments on every round part, polygon discs for gears, boxes for lobes.
118
+ * opts.caps: a colour; with a section on, the cut gets a flat face of it wherever it passes through a solid. */
119
+ export function buildEngine(opts = {}) {
120
+ const lo = !!opts.lo;
121
+ const plain = !!opts.plain || lo;
122
+ // segment counts: the film's, or a sixth of them in the low build
123
+ const N = (n, min = 6) => (lo ? Math.max(min, Math.round(n / 6)) : n);
124
+ const gear = (teeth, rOut, rRoot, width, helix = 0, holeR = 0) =>
125
+ plain ? discGeo((rOut + rRoot) / 2, width, holeR, lo ? Math.max(8, Math.round((rOut + rRoot) / 24)) : 48) : gearGeo(teeth, rOut, rRoot, width, helix, holeR);
126
+ const root = new THREE.Group();
127
+ const M = {
128
+ black: new THREE.MeshPhysicalMaterial({color: '#141518', roughness: 0.3, metalness: 0.2, clearcoat: 0.7, clearcoatRoughness: 0.18}),
129
+ blackMatte: new THREE.MeshPhysicalMaterial({color: '#1b1c1f', roughness: 0.55, metalness: 0.15, clearcoat: 0.25}),
130
+ steel: new THREE.MeshStandardMaterial({color: '#cfd2d6', roughness: 0.22, metalness: 1}),
131
+ alu: new THREE.MeshStandardMaterial({color: '#d9dbdf', roughness: 0.3, metalness: 0.85}),
132
+ bronze: new THREE.MeshStandardMaterial({color: '#b98a55', roughness: 0.3, metalness: 0.9}),
133
+ ceramic: new THREE.MeshPhysicalMaterial({color: '#f3f0ea', roughness: 0.35, metalness: 0, clearcoat: 0.6}),
134
+ glass: new THREE.MeshPhysicalMaterial({color: '#ffffff', roughness: 0.05, metalness: 0, transparent: true, opacity: 0.16, depthWrite: false, side: THREE.DoubleSide, envMapIntensity: 1.6}),
135
+ red: new THREE.MeshBasicMaterial({color: '#e3172c', transparent: true, opacity: 0.9, depthWrite: false}),
136
+ };
137
+ if (lo) {
138
+ // flat Lambert: no gloss, nothing to reflect; the blacks lift to graphite so the facets still read without the
139
+ // studio's highlights, and the liners turn opaque
140
+ const flat = (color) => new THREE.MeshLambertMaterial({color, flatShading: true});
141
+ Object.assign(M, {black: flat('#66696f'), blackMatte: flat('#717479'), steel: flat('#b9bdc3'), alu: flat('#cfd2d6'), bronze: flat('#a37b4d'), ceramic: flat('#ece8e0'), glass: flat('#86898f')});
142
+ }
143
+ const add = (parent, geo, mat, cast = true) => {
144
+ const m = new THREE.Mesh(geo, mat);
145
+ m.castShadow = cast;
146
+ m.receiveShadow = true;
147
+ parent.add(m);
148
+ return m;
149
+ };
150
+
151
+ // ------------------------------------------------------------ block: bulkheads, rails, pan
152
+ const block = new THREE.Group();
153
+ root.add(block);
154
+ const bh = bulkheadGeo(16, N(24));
155
+ for (const z of [236, 112, 0, -112, -236]) add(block, bh, M.black).position.z = z;
156
+ for (const bank of ['L', 'R']) {
157
+ const B = BANK[bank];
158
+ // deck rails along the bank, both sides of the bores
159
+ for (const w of [-60, 60]) {
160
+ const r = add(block, new THREE.BoxGeometry(14, 16, 488), M.black);
161
+ const [x, y] = [(DECK - 18) * B.b[0] + w * B.p[0], (DECK - 18) * B.b[1] + w * B.p[1]];
162
+ r.position.set(x, y, 0);
163
+ r.rotation.z = Math.atan2(B.b[1], B.b[0]) - Math.PI / 2;
164
+ }
165
+ }
166
+ const pan = add(block, new THREE.BoxGeometry(200, 40, 470), M.blackMatte);
167
+ pan.position.set(0, -92, 0);
168
+ const rail = add(block, new THREE.BoxGeometry(220, 12, 500), M.black);
169
+ rail.position.set(0, -68, 0);
170
+
171
+ // ------------------------------------------------------------ cylinders: liner, flange, head pieces, valvetrain, plug, exhaust
172
+ const cyl = CYL.map((cy) => {
173
+ const B = BANK[cy.bank];
174
+ const g = new THREE.Group();
175
+ g.position.z = cy.z;
176
+ g.rotation.z = Math.atan2(B.b[1], B.b[0]) - Math.PI / 2;
177
+ root.add(g);
178
+ // local x points across the bank; the outer side is +x on the left bank, -x on the right
179
+ const out = cy.bank === 'L' ? 1 : -1;
180
+ const liner = add(g, new THREE.CylinderGeometry(E.bore / 2 + 3, E.bore / 2 + 3, 118, N(48), 1, true), M.glass, false);
181
+ liner.position.y = DECK - 59;
182
+ liner.renderOrder = 3;
183
+ for (const y of [DECK - 118, DECK]) {
184
+ const ring = add(g, new THREE.TorusGeometry(E.bore / 2 + 4, 3.2, N(10, 4), N(48)), M.black);
185
+ ring.rotation.x = Math.PI / 2;
186
+ ring.position.y = y;
187
+ }
188
+ // the head: a black flange over the bore with a raised valve block; one group with its valves, plug and exhaust
189
+ const head = new THREE.Group();
190
+ g.add(head);
191
+ const flange = add(head, new THREE.TorusGeometry(64, 10, N(16, 4), N(56)), M.black);
192
+ flange.rotation.x = Math.PI / 2;
193
+ flange.position.y = DECK + 6;
194
+ const cap = add(head, new THREE.CylinderGeometry(60, 64, 12, N(56)), M.black);
195
+ cap.position.y = DECK + 14;
196
+ const vblock = add(head, new THREE.BoxGeometry(70, 14, 46), M.black);
197
+ vblock.position.y = DECK + 27;
198
+ // the charge: a column of gas between the crown and the head
199
+ const charge = new THREE.Mesh(new THREE.CylinderGeometry(E.bore / 2 - 1, E.bore / 2 - 1, 1, N(40)), new THREE.MeshBasicMaterial({color: '#4a90e2', transparent: true, opacity: 0.35, depthWrite: false}));
200
+ charge.renderOrder = 2;
201
+ g.add(charge);
202
+ // valves: intake on the valley side, exhaust outboard
203
+ const valves = [
204
+ {x: -out * 21, kind: 'in'},
205
+ {x: out * 21, kind: 'ex'},
206
+ ].map((v) => {
207
+ const vg = new THREE.Group();
208
+ head.add(vg);
209
+ vg.position.x = v.x;
210
+ const stem = add(vg, new THREE.CylinderGeometry(3.5, 3.5, 120, N(12)), M.steel);
211
+ stem.position.y = DECK + 54;
212
+ const disc = add(vg, new THREE.CylinderGeometry(18, 7, 6, N(28)), M.steel);
213
+ disc.position.y = DECK - 3;
214
+ const spring = new THREE.Group();
215
+ head.add(spring);
216
+ spring.position.set(v.x, DECK + 34, 0);
217
+ if (plain) {
218
+ // a plain sleeve where the coils were, squeezed with the lift the same way
219
+ const sleeve = new THREE.CylinderGeometry(15.5, 15.5, 48, N(24));
220
+ sleeve.translate(0, 24, 0);
221
+ add(spring, sleeve, M.steel);
222
+ } else {
223
+ add(spring, helixGeo(15.5, 2.6, 8, 48), M.steel);
224
+ add(spring, helixGeo(10.5, 1.8, 10, 48), M.bronze);
225
+ }
226
+ const ret = add(vg, new THREE.CylinderGeometry(18, 18, 4, N(24)), M.black);
227
+ ret.position.y = DECK + 84;
228
+ return {...v, vg, spring};
229
+ });
230
+ // the rocker cage: an open black frame over the springs, the camshaft running through it
231
+ const cage = new THREE.Group();
232
+ g.add(cage);
233
+ for (const zz of [-30, 30]) {
234
+ for (const xx of [-44, 44]) {
235
+ const post = add(cage, new THREE.BoxGeometry(6, 100, 6), M.black);
236
+ post.position.set(xx, DECK + 86, zz);
237
+ }
238
+ const bar = add(cage, new THREE.BoxGeometry(94, 6, 6), M.black);
239
+ bar.position.set(0, DECK + 136, zz);
240
+ }
241
+ // the rocker arms: one bar per valve from the cam over the stem
242
+ for (const xx of [-21, 21]) {
243
+ const arm = add(cage, new THREE.BoxGeometry(10, 7, 66), M.black);
244
+ arm.position.set(xx, DECK + 124, 0);
245
+ }
246
+ // spark plug: out of the head between the valves, leaning outboard
247
+ const plug = new THREE.Group();
248
+ head.add(plug);
249
+ plug.position.set(out * 46, DECK + 18, 18);
250
+ plug.rotation.z = -out * 0.62;
251
+ add(plug, new THREE.CylinderGeometry(6.5, 6.5, 40, N(16)), M.ceramic).position.y = 30;
252
+ add(plug, new THREE.CylinderGeometry(8.5, 8.5, 10, 6), M.steel).position.y = 6;
253
+ add(plug, new THREE.CylinderGeometry(2.2, 2.2, 10, N(8, 4)), M.steel).position.y = 55;
254
+ // exhaust: a black bend out of the outboard port, down along the block
255
+ const pts = [new V3(out * 50, DECK + 12, -20), new V3(out * 92, DECK + 6, -24), new V3(out * 122, DECK - 30, -24), new V3(out * 126, DECK - 90, -24)];
256
+ add(head, new THREE.TubeGeometry(new THREE.CatmullRomCurve3(pts), N(32), 15, N(18), false), M.black);
257
+ return {cy, g, out, charge, valves, liner, head, cage};
258
+ });
259
+
260
+ // camshafts: one per bank through the cages, lobes over every valve
261
+ const cams = ['L', 'R'].map((bank) => {
262
+ const B = BANK[bank];
263
+ const g = new THREE.Group();
264
+ const [x, y] = [(DECK + 112) * B.b[0], (DECK + 112) * B.b[1]];
265
+ g.position.set(x, y, 0);
266
+ root.add(g);
267
+ add(g, new THREE.CylinderGeometry(9, 9, 520, N(20)), M.black).rotation.x = Math.PI / 2;
268
+ const lobes = [];
269
+ for (const c of cyl.filter((c) => c.cy.bank === bank)) {
270
+ for (const v of c.valves) {
271
+ const lg = new THREE.Group();
272
+ // two lobes per cylinder on the shaft, phased so each peaks when its valve is fully open
273
+ lg.position.set(0, 0, c.cy.z + (v.kind === 'in' ? -18 : 18));
274
+ const peak = FIRE[c.cy.c] + (v.kind === 'in' ? (VALVE.in[0] + VALVE.in[1]) / 2 : (VALVE.ex[0] + VALVE.ex[1]) / 2);
275
+ lg.rotation.z = (peak / 2) * D2R;
276
+ g.add(lg);
277
+ const sh = new THREE.Shape();
278
+ sh.absellipse(0, 4, 15, 19, 0, Math.PI * 2, false, 0);
279
+ // the low build turns each lobe into a box of the same footprint
280
+ const lobeGeo = lo ? new THREE.BoxGeometry(30, 38, 14).translate(0, 4, 7) : new THREE.ExtrudeGeometry(sh, {depth: 14, bevelEnabled: true, bevelSize: 1, bevelThickness: 1, bevelSegments: 1, curveSegments: 24});
281
+ const lobe = add(lg, lobeGeo, M.black);
282
+ lobe.position.z = -7;
283
+ lobes.push({lg, c, v});
284
+ }
285
+ }
286
+ return {bank, g, lobes};
287
+ });
288
+
289
+ // ------------------------------------------------------------ crankshaft
290
+ const crank = new THREE.Group();
291
+ root.add(crank);
292
+ const webG = webGeo(18, N(28));
293
+ const webs = [];
294
+ E.pinZ.forEach((z, p) => {
295
+ for (const dz of [-34, 34]) {
296
+ const w = add(crank, webG, M.black);
297
+ w.position.z = z + dz;
298
+ webs.push({w, p});
299
+ }
300
+ });
301
+ const journals = [236, 112, 0, -112, -236].map((z) => {
302
+ const j = add(crank, new THREE.CylinderGeometry(30, 30, 42, N(32)), M.steel);
303
+ j.rotation.x = Math.PI / 2;
304
+ j.position.z = z;
305
+ return j;
306
+ });
307
+ const pins = E.pinZ.map((z) => {
308
+ const m = add(root, new THREE.CylinderGeometry(25, 25, 52, N(28)), M.steel);
309
+ m.rotation.x = Math.PI / 2;
310
+ m.position.z = z;
311
+ return m;
312
+ });
313
+
314
+ // ------------------------------------------------------------ pistons and rods
315
+ const pistonGeo = new THREE.CylinderGeometry(E.bore / 2 - 1.5, E.bore / 2 - 1.5, 62, N(48));
316
+ const ringGeo = new THREE.TorusGeometry(E.bore / 2 - 1.2, 1.6, 8, 48);
317
+ const pist = CYL.map((cy, i) => {
318
+ const g = new THREE.Group();
319
+ cyl[i].g.add(g);
320
+ const body = add(g, pistonGeo, M.alu);
321
+ body.position.y = E.comp - 31;
322
+ for (let k = 0; k < (plain ? 0 : 3); k++) {
323
+ const r = add(g, ringGeo, M.blackMatte);
324
+ r.rotation.x = Math.PI / 2;
325
+ r.position.y = E.comp - 8 - k * 7;
326
+ }
327
+ const pinM = add(g, new THREE.CylinderGeometry(11, 11, E.bore - 10, N(16)), M.steel);
328
+ pinM.rotation.z = Math.PI / 2;
329
+ pinM.rotation.y = Math.PI / 2;
330
+ const rod = new THREE.Group();
331
+ root.add(rod);
332
+ const beam = add(rod, new THREE.BoxGeometry(18, 1, 12), M.black);
333
+ const big = add(rod, new THREE.CylinderGeometry(33, 33, 20, N(32)), M.black);
334
+ big.rotation.x = Math.PI / 2;
335
+ const small = add(rod, new THREE.CylinderGeometry(17, 17, 20, N(24)), M.black);
336
+ small.rotation.x = Math.PI / 2;
337
+ // the red arrow riding beside the liner, pointing the way the piston moves
338
+ const arrow = new THREE.Group();
339
+ cyl[i].g.add(arrow);
340
+ const shaft = new THREE.Mesh(new THREE.CylinderGeometry(4, 4, 46, 12), M.red);
341
+ shaft.position.y = -10;
342
+ const tip = new THREE.Mesh(new THREE.ConeGeometry(11, 26, 18), M.red);
343
+ tip.position.y = 23;
344
+ arrow.add(shaft, tip);
345
+ arrow.position.set(cyl[i].out * 78, 0, 0);
346
+ arrow.renderOrder = 5;
347
+ return {g, rod, beam, big, small, arrow};
348
+ });
349
+
350
+ // ------------------------------------------------------------ front: timing gears and the pulley; rear: the flywheel
351
+ const front = 268;
352
+ const crankGear = add(root, gear(24, 37, 33, 22, 0.35, 10), M.black);
353
+ crankGear.position.z = front;
354
+ const camGears = [];
355
+ // a big helical idler per bank, meshing the crank gear below and the cam gear above
356
+ const idlers = ['L', 'R'].map((bank) => {
357
+ const B = BANK[bank];
358
+ const gg = add(root, gear(72, 111, 106, 24, 0.35, 16), M.black);
359
+ gg.position.set(150 * B.b[0], 150 * B.b[1], front - 2);
360
+ return {gg, bank};
361
+ });
362
+ const pulley = new THREE.Group();
363
+ pulley.position.z = front + 44;
364
+ root.add(pulley);
365
+ add(pulley, new THREE.CylinderGeometry(84, 84, 34, N(64)), M.black).rotation.x = Math.PI / 2;
366
+ const groove = add(pulley, new THREE.TorusGeometry(84, 4, N(8, 4), N(64)), M.blackMatte);
367
+ groove.position.z = 0;
368
+ for (let k = 0; k < (plain ? 0 : 6); k++) {
369
+ const b = add(pulley, new THREE.CylinderGeometry(6, 6, 6, 12), M.steel);
370
+ const a = (k / 6) * Math.PI * 2;
371
+ b.rotation.x = Math.PI / 2;
372
+ b.position.set(Math.cos(a) * 52, Math.sin(a) * 52, 18);
373
+ }
374
+ const hub = add(pulley, gear(18, 26, 23, 50, 0, 8), M.steel);
375
+ hub.position.z = 30;
376
+ const flywheel = new THREE.Group();
377
+ flywheel.position.z = -290;
378
+ root.add(flywheel);
379
+ add(flywheel, new THREE.CylinderGeometry(150, 150, 22, N(72)), M.black).rotation.x = Math.PI / 2;
380
+ add(flywheel, gear(120, 166, 158, 20, 0, 140), M.black);
381
+ // red arcs around the pulley, turning with the crank
382
+ const arcs = new THREE.Group();
383
+ arcs.position.z = front + 66;
384
+ root.add(arcs);
385
+ for (const a0 of [0, Math.PI]) {
386
+ const arc = new THREE.Mesh(new THREE.TorusGeometry(108, 5, 8, 48, Math.PI * 0.62), M.red);
387
+ arc.rotation.z = a0;
388
+ const tip = new THREE.Mesh(new THREE.ConeGeometry(13, 30, 16), M.red);
389
+ const ta = a0 + Math.PI * 0.62;
390
+ tip.position.set(Math.cos(ta) * 108, Math.sin(ta) * 108, 0);
391
+ tip.rotation.z = ta;
392
+ arcs.add(arc, tip);
393
+ }
394
+ arcs.renderOrder = 5;
395
+
396
+ const CHARGE_COL = [new THREE.Color('#3f8de0'), new THREE.Color('#5d6670'), new THREE.Color('#ff6a1f'), new THREE.Color('#8b8f95')];
397
+ const tmp = new V3();
398
+ // cutaway: 'glass' (clear liners), 'solid' (opaque liners), 'section' (everything on the far side of the plane cut
399
+ // away: ahead of z by default, or past any plane given by its normal); refract: the glass catches the studio or goes
400
+ // nearly clear
401
+ const CLIP = new THREE.Plane(new V3(0, 0, -1), 0);
402
+ const Z_CUT = new V3(0, 0, -1);
403
+
404
+ // the isolate fade: a see-through twin of every material, worn by the parts solo puts away while they go
405
+ const GHOST = new Map(
406
+ Object.values(M).map((m) => {
407
+ const g = m.clone();
408
+ g.transparent = true;
409
+ g.depthWrite = false;
410
+ return [m, g];
411
+ }),
412
+ );
413
+ root.traverse((m) => m.isMesh && (m.userData.mat0 = m.material));
414
+ const ghosted = new Set();
415
+
416
+ // section caps (opts.caps): every solid part gets two stencil twins that count its faces beyond the cut, and a
417
+ // plane lying on the cut paints the cap colour wherever that count says the cut runs through metal
418
+ let cap = null;
419
+ const helpers = [];
420
+ if (opts.caps) {
421
+ const inc = THREE.IncrementWrapStencilOp;
422
+ const dec = THREE.DecrementWrapStencilOp;
423
+ const count = (side, op) =>
424
+ new THREE.MeshBasicMaterial({side, colorWrite: false, depthWrite: false, depthTest: false, stencilWrite: true, stencilFunc: THREE.AlwaysStencilFunc, stencilFail: op, stencilZFail: op, stencilZPass: op, clippingPlanes: [CLIP]});
425
+ helpers.push(count(THREE.BackSide, inc), count(THREE.FrontSide, dec));
426
+ const solid = new Set([M.black, M.blackMatte, M.steel, M.alu, M.bronze, M.ceramic]);
427
+ const parts = [];
428
+ root.traverse((m) => m.isMesh && solid.has(m.material) && parts.push(m));
429
+ for (const m of parts) {
430
+ for (const mat of helpers) {
431
+ const h = new THREE.Mesh(m.geometry, mat);
432
+ h.renderOrder = 1;
433
+ m.add(h);
434
+ }
435
+ }
436
+ const rep = THREE.ReplaceStencilOp;
437
+ cap = new THREE.Mesh(
438
+ new THREE.PlaneGeometry(2.4, 2.4),
439
+ new THREE.MeshStandardMaterial({color: opts.caps, roughness: 0.55, metalness: 0, side: THREE.DoubleSide, stencilWrite: true, stencilRef: 0, stencilFunc: THREE.NotEqualStencilFunc, stencilFail: rep, stencilZFail: rep, stencilZPass: rep}),
440
+ );
441
+ cap.renderOrder = 1.1;
442
+ cap.onAfterRender = (r) => r.clearStencil();
443
+ for (const mat of [...helpers, cap.material]) mat.visible = false;
444
+ }
445
+ // the cap lies on the cut, centred on the engine, facing the side that was cut away
446
+ const C0 = new V3(0, 0.1, 0);
447
+ const placeCap = () => {
448
+ if (!cap) return;
449
+ cap.position.copy(C0).addScaledVector(CLIP.normal, -CLIP.distanceToPoint(C0));
450
+ cap.quaternion.setFromUnitVectors(new V3(0, 0, 1), tmp.copy(CLIP.normal).negate());
451
+ };
452
+
453
+ const clipMats = () => [...Object.values(M), ...GHOST.values(), ...cyl.map((c) => c.charge.material)];
454
+ let cutNow = 'glass';
455
+ const setCut = (mode, zWorld = 0, normal = Z_CUT) => {
456
+ CLIP.normal.copy(normal);
457
+ CLIP.constant = zWorld;
458
+ placeCap();
459
+ if (mode === cutNow) return;
460
+ cutNow = mode;
461
+ for (const m of clipMats()) {
462
+ m.clippingPlanes = mode === 'section' ? [CLIP] : null;
463
+ m.needsUpdate = true;
464
+ }
465
+ if (cap) for (const mat of [...helpers, cap.material]) mat.visible = mode === 'section';
466
+ if (lo) {
467
+ // the low build has no caps: cut parts show their insides, so both faces draw while the section is on
468
+ for (const m of [...Object.values(M), ...GHOST.values()]) m.side = mode === 'section' ? THREE.DoubleSide : THREE.FrontSide;
469
+ return;
470
+ }
471
+ const solid = mode === 'solid';
472
+ M.glass.color.set(solid ? '#2b2d31' : '#ffffff');
473
+ M.glass.opacity = solid ? 0.94 : glassOpacity;
474
+ M.glass.depthWrite = solid;
475
+ };
476
+ let glassOpacity = 0.16;
477
+ const setRefract = (on) => {
478
+ glassOpacity = on ? 0.16 : 0.05;
479
+ M.glass.envMapIntensity = on ? 1.6 : 0.3;
480
+ if (cutNow !== 'solid') M.glass.opacity = glassOpacity;
481
+ };
482
+ /** ops: charge (0..1 visibility), arrows (0..1), solo (cylinder index or -1), glass (liner opacity), fire (0..1: with
483
+ * the charge off, the burn alone still lights the bore for the first 60° of every power stroke), fade (0..1, with
484
+ * solo: how far the rest has gone; 1, the default, hides it as before, below 1 it stays see-through), explode
485
+ * (0..1: the engine apart along its axes) */
486
+ const update = (th, ops = {}) => {
487
+ for (const m of ghosted) m.material = m.userData.mat0;
488
+ ghosted.clear();
489
+ const solo = ops.solo ?? -1;
490
+ const all = solo < 0;
491
+ const aRest = all ? 1 : 1 - Math.min(1, Math.max(0, ops.fade ?? 1));
492
+ // explode: each layer leaves on its own stretch of the move, the outermost first, so nothing passes through
493
+ // anything on the way out or back in: the rocker cage, the camshaft, the head with its valves, the pistons with
494
+ // their rods out along each bank; the sump, then the crank with its gear, pulley and flywheel down. The engine
495
+ // rises with the sump so the dropped parts stay clear of the floor.
496
+ const ex = ops.explode ?? 0;
497
+ const lay = (a) => smoother((ex - a) / 0.45);
498
+ const eSump = lay(0);
499
+ const eCrank = lay(0.12);
500
+ const DG = 390 * lay(0.25);
501
+ const DC = 300 * lay(0.33);
502
+ const DH = 200 * lay(0.42);
503
+ const DP = 110 * lay(0.55);
504
+ const DK = 110 * eCrank;
505
+ const DS = 190 * eSump;
506
+ root.position.y = 0.17 * eSump;
507
+ pan.position.y = -92 - DS;
508
+ rail.position.y = -68 - DS;
509
+
510
+ const cAng = -th * D2R; // the crank turns clockwise seen from the front
511
+ crank.rotation.z = 0;
512
+ crank.position.y = -DK;
513
+ for (const {w, p} of webs) w.rotation.z = -(th + PIN_PHASE[p]) * D2R;
514
+ E.pinZ.forEach((z, p) => {
515
+ const [x, y] = pinXY(p, th);
516
+ pins[p].position.set(x, y - DK, z);
517
+ });
518
+ const chargeOn = ops.charge ?? 1;
519
+ const arrowsOn = ops.arrows ?? 1;
520
+ const fireOn = ops.fire ?? 0;
521
+ CYL.forEach((cy, i) => {
522
+ const B = BANK[cy.bank];
523
+ const {s, P, pin} = piston(i, th);
524
+ const pp = pist[i];
525
+ pp.g.position.y = s + DP;
526
+ // the rod: crank pin to piston pin
527
+ const a = new V3(P[0], P[1], cy.z);
528
+ const b = new V3(pin[0], pin[1], cy.z);
529
+ tmp.subVectors(b, a);
530
+ const len = tmp.length();
531
+ pp.rod.position.copy(a).add(b).multiplyScalar(0.5);
532
+ pp.rod.position.x += DP * B.b[0];
533
+ pp.rod.position.y += DP * B.b[1];
534
+ pp.rod.rotation.set(0, 0, Math.atan2(tmp.y, tmp.x) - Math.PI / 2);
535
+ pp.beam.scale.y = len - 30;
536
+ pp.big.position.y = -len / 2;
537
+ pp.small.position.y = len / 2;
538
+ // the charge column and its colour by stroke
539
+ const ps = psi(cy.c, th);
540
+ const crown = s + E.comp;
541
+ const col = cyl[i];
542
+ col.head.position.y = DH;
543
+ col.cage.position.y = DG;
544
+ col.charge.position.y = (crown + DECK) / 2;
545
+ col.charge.scale.y = Math.max(1, DECK - crown);
546
+ const key = chargeOf(ps);
547
+ col.charge.material.color.copy(CHARGE_COL[key]);
548
+ const glow = key === 2 ? Math.min(1, pressure(ps) / 40) : 0;
549
+ col.charge.material.opacity = chargeOn * (key === 2 ? 0.35 + 0.45 * glow : key === 0 ? 0.32 : 0.22);
550
+ col.charge.visible = chargeOn > 0.01;
551
+ if (fireOn > 0 && chargeOn <= 0.01 && key === 2) {
552
+ col.charge.material.opacity = fireOn * (0.35 + 0.45 * glow);
553
+ col.charge.visible = true;
554
+ }
555
+ if (!all && i !== solo) col.charge.material.opacity *= aRest;
556
+ if (ex > 0) col.charge.visible = false;
557
+ // valves open by their lift, springs squeeze with them
558
+ for (const v of col.valves) {
559
+ const L = (v.kind === 'in' ? liftIn(ps) : liftEx(ps)) * VALVE.lift;
560
+ v.vg.position.y = -L;
561
+ v.spring.scale.y = (48 - L) / 48;
562
+ }
563
+ // the arrow: along the bore, the way the piston is heading, strongest mid-stroke
564
+ const {s: s2} = piston(i, th + 2);
565
+ const vel = s2 - s;
566
+ pp.arrow.position.y = DECK - 70;
567
+ pp.arrow.rotation.z = vel > 0 ? 0 : Math.PI;
568
+ pp.arrow.scale.setScalar(arrowsOn * Math.min(1, Math.abs(vel) / 1.2));
569
+ pp.arrow.visible = arrowsOn * Math.abs(vel) > 0.05;
570
+ });
571
+ // cams at half speed, gears in ratio, pulley and flywheel with the crank
572
+ for (const c of cams) {
573
+ const B = BANK[c.bank];
574
+ c.g.position.set((DECK + 112 + DC) * B.b[0], (DECK + 112 + DC) * B.b[1], 0);
575
+ c.g.rotation.z = cAng / 2;
576
+ }
577
+ crankGear.rotation.z = cAng;
578
+ crankGear.position.y = -DK;
579
+ camGears.forEach((g) => (g.rotation.z = cAng / 2));
580
+ idlers.forEach(({gg}) => (gg.rotation.z = -cAng * (24 / 72)));
581
+ pulley.rotation.z = cAng;
582
+ pulley.position.set(0, -DK, front + 44 + 90 * eCrank);
583
+ flywheel.rotation.z = cAng;
584
+ flywheel.position.set(0, -DK, -290 - 90 * eCrank);
585
+ arcs.rotation.z = cAng * 0.25;
586
+ arcs.position.set(0, -DK, front + 66 + 90 * eCrank);
587
+
588
+ // solo: one cylinder with its crank and cam, everything else away
589
+ block.visible = all;
590
+ for (const g of [crankGear, pulley, flywheel, arcs, ...idlers.map((x) => x.gg)]) g.visible = all;
591
+ cyl.forEach((c, i) => {
592
+ const on = all || i === solo;
593
+ c.g.visible = on;
594
+ pist[i].rod.visible = on;
595
+ });
596
+ for (const c of cams) c.g.visible = all || CYL[solo].bank === c.bank;
597
+ const soloPin = all ? -1 : CYL[solo].pin;
598
+ for (const {w, p} of webs) w.visible = all || p === soloPin;
599
+ pins.forEach((m, p) => (m.visible = all || p === soloPin));
600
+ for (const j of journals) j.visible = all;
601
+ arcs.visible = all && (ops.arrows ?? 1) > 0.01;
602
+ // while solo fades the rest (fade below 1), it stays in place in the see-through twins
603
+ if (!all && aRest > 0.001) {
604
+ const rest = [block, crankGear, pulley, flywheel, ...idlers.map((x) => x.gg), ...journals];
605
+ cyl.forEach((c, i) => i !== solo && rest.push(c.g, pist[i].rod));
606
+ for (const c of cams) if (CYL[solo].bank !== c.bank) rest.push(c.g);
607
+ for (const {w, p} of webs) if (p !== soloPin) rest.push(w);
608
+ pins.forEach((m, p) => p !== soloPin && rest.push(m));
609
+ for (const [m, g] of GHOST) g.opacity = (m.transparent ? m.opacity : 1) * aRest;
610
+ for (const o of rest) {
611
+ o.visible = true;
612
+ o.traverse((m) => {
613
+ if (m.isMesh && GHOST.has(m.userData.mat0)) {
614
+ m.material = GHOST.get(m.userData.mat0);
615
+ ghosted.add(m);
616
+ }
617
+ });
618
+ }
619
+ }
620
+ };
621
+ // the engine is modelled in mm; one world unit is a metre (the cap lives in world units, outside the root)
622
+ root.scale.setScalar(0.001);
623
+ return {root, update, M, cyl, pist, cams, crank, pulley, flywheel, crankGear, camGears, setCut, setRefract, CLIP, cap};
624
+ }