@guilhermebkel/scenec 0.1.2 → 0.2.1

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 (554) hide show
  1. package/README.md +34 -31
  2. package/dist/Adapters/FileReaderAdapter.d.ts +4 -0
  3. package/dist/Adapters/FileReaderAdapter.js +21 -0
  4. package/dist/Adapters/FontAdapter.d.ts +5 -0
  5. package/dist/Adapters/FontAdapter.js +13 -0
  6. package/dist/Adapters/ResvgAdapter.d.ts +11 -0
  7. package/dist/Adapters/ResvgAdapter.js +18 -0
  8. package/dist/Commands/BaseCommand.d.ts +11 -0
  9. package/dist/Commands/BaseCommand.js +13 -0
  10. package/dist/Commands/BestCommand.d.ts +11 -0
  11. package/dist/Commands/BestCommand.js +73 -0
  12. package/dist/Commands/CatalogCommand.d.ts +6 -0
  13. package/dist/Commands/CatalogCommand.js +24 -0
  14. package/dist/Commands/CheckCommand.d.ts +5 -0
  15. package/dist/Commands/CheckCommand.js +8 -0
  16. package/dist/Commands/RenderCommand.d.ts +7 -0
  17. package/dist/Commands/RenderCommand.js +15 -0
  18. package/dist/Commands/SceneCommand.d.ts +11 -0
  19. package/dist/Commands/SceneCommand.js +70 -0
  20. package/dist/Commands/SchemaCommand.d.ts +5 -0
  21. package/dist/Commands/SchemaCommand.js +12 -0
  22. package/dist/Data/cities.json +312 -0
  23. package/dist/Data/europe.json +1 -0
  24. package/dist/Errors/SceneError.d.ts +4 -0
  25. package/dist/Errors/SceneError.js +11 -0
  26. package/dist/Errors/UnsafeSvgError.d.ts +3 -0
  27. package/dist/Errors/UnsafeSvgError.js +9 -0
  28. package/dist/Modules/BestModule.d.ts +41 -0
  29. package/dist/Modules/BestModule.js +159 -0
  30. package/dist/Modules/CheckModule.d.ts +8 -0
  31. package/dist/Modules/CheckModule.js +16 -0
  32. package/dist/Modules/CompilationModule.d.ts +23 -0
  33. package/dist/Modules/CompilationModule.js +210 -0
  34. package/dist/Modules/CritiqueModule.d.ts +9 -0
  35. package/dist/Modules/CritiqueModule.js +98 -0
  36. package/dist/Modules/MapModule.d.ts +24 -0
  37. package/dist/Modules/MapModule.js +99 -0
  38. package/dist/Modules/ParsingModule.d.ts +17 -0
  39. package/dist/Modules/ParsingModule.js +88 -0
  40. package/dist/Modules/PlaneModule.d.ts +19 -0
  41. package/dist/Modules/PlaneModule.js +98 -0
  42. package/dist/Protocols/AssetProtocol.d.ts +67 -0
  43. package/dist/Protocols/AssetProtocol.js +109 -0
  44. package/dist/Protocols/CommandProtocol.d.ts +8 -0
  45. package/dist/Protocols/CommandProtocol.js +0 -0
  46. package/dist/Protocols/CompilationProtocol.d.ts +136 -0
  47. package/dist/Protocols/CompilationProtocol.js +0 -0
  48. package/dist/Protocols/CritiqueProtocol.d.ts +58 -0
  49. package/dist/Protocols/CritiqueProtocol.js +14 -0
  50. package/dist/Protocols/CustomAssetProtocol.d.ts +24 -0
  51. package/dist/Protocols/CustomAssetProtocol.js +0 -0
  52. package/dist/Protocols/GroupProtocol.d.ts +17 -0
  53. package/dist/Protocols/GroupProtocol.js +12 -0
  54. package/dist/Protocols/KitProtocol.d.ts +32 -0
  55. package/dist/Protocols/KitProtocol.js +23 -0
  56. package/dist/Protocols/MapProtocol.d.ts +77 -0
  57. package/dist/Protocols/MapProtocol.js +4 -0
  58. package/dist/Protocols/OptionsProtocol.js +0 -0
  59. package/dist/Protocols/PersonProtocol.d.ts +68 -0
  60. package/dist/Protocols/PersonProtocol.js +42 -0
  61. package/dist/Protocols/PlaneProtocol.d.ts +140 -0
  62. package/dist/Protocols/PlaneProtocol.js +4 -0
  63. package/dist/{pipeline/index.d.ts → Protocols/ResultProtocol.d.ts} +0 -2
  64. package/dist/Protocols/ResultProtocol.js +0 -0
  65. package/dist/Protocols/SceneProtocol.d.ts +824 -0
  66. package/dist/Protocols/SceneProtocol.js +357 -0
  67. package/dist/{protocols/theme.d.ts → Protocols/ThemeProtocol.d.ts} +4 -0
  68. package/dist/Protocols/ThemeProtocol.js +28 -0
  69. package/dist/Resources/Assets/BackpackAsset.d.ts +10 -0
  70. package/dist/Resources/Assets/BackpackAsset.js +31 -0
  71. package/dist/Resources/Assets/BallAsset.d.ts +10 -0
  72. package/dist/Resources/Assets/BallAsset.js +15 -0
  73. package/dist/Resources/Assets/BalloonsAsset.d.ts +10 -0
  74. package/dist/Resources/Assets/BalloonsAsset.js +26 -0
  75. package/dist/Resources/Assets/BaseAsset.d.ts +17 -0
  76. package/dist/Resources/Assets/BaseAsset.js +11 -0
  77. package/dist/Resources/Assets/BeachTowelAsset.d.ts +10 -0
  78. package/dist/Resources/Assets/BeachTowelAsset.js +14 -0
  79. package/dist/Resources/Assets/BedAsset.d.ts +12 -0
  80. package/dist/Resources/Assets/BedAsset.js +25 -0
  81. package/dist/Resources/Assets/BenchAsset.d.ts +11 -0
  82. package/dist/Resources/Assets/BenchAsset.js +24 -0
  83. package/dist/Resources/Assets/BicycleAsset.d.ts +10 -0
  84. package/dist/Resources/Assets/BicycleAsset.js +18 -0
  85. package/dist/Resources/Assets/BigPlantAsset.d.ts +10 -0
  86. package/dist/Resources/Assets/BigPlantAsset.js +26 -0
  87. package/dist/Resources/Assets/BirdAsset.d.ts +10 -0
  88. package/dist/Resources/Assets/BirdAsset.js +14 -0
  89. package/dist/Resources/Assets/BlackboardAsset.d.ts +11 -0
  90. package/dist/Resources/Assets/BlackboardAsset.js +20 -0
  91. package/dist/Resources/Assets/BoardAsset.d.ts +12 -0
  92. package/dist/Resources/Assets/BoardAsset.js +44 -0
  93. package/dist/Resources/Assets/BoatAsset.d.ts +10 -0
  94. package/dist/Resources/Assets/BoatAsset.js +15 -0
  95. package/dist/Resources/Assets/BooksAsset.d.ts +10 -0
  96. package/dist/Resources/Assets/BooksAsset.js +35 -0
  97. package/dist/Resources/Assets/BookshelfAsset.d.ts +10 -0
  98. package/dist/Resources/Assets/BookshelfAsset.js +33 -0
  99. package/dist/Resources/Assets/BuildingAsset.d.ts +14 -0
  100. package/dist/Resources/Assets/BuildingAsset.js +34 -0
  101. package/dist/Resources/Assets/BurgerAsset.d.ts +9 -0
  102. package/dist/Resources/Assets/BurgerAsset.js +23 -0
  103. package/dist/Resources/Assets/BushAsset.d.ts +10 -0
  104. package/dist/Resources/Assets/BushAsset.js +17 -0
  105. package/dist/Resources/Assets/CabinetAsset.d.ts +14 -0
  106. package/dist/Resources/Assets/CabinetAsset.js +49 -0
  107. package/dist/Resources/Assets/CablesAsset.d.ts +10 -0
  108. package/dist/Resources/Assets/CablesAsset.js +16 -0
  109. package/dist/Resources/Assets/CakeAsset.d.ts +10 -0
  110. package/dist/Resources/Assets/CakeAsset.js +29 -0
  111. package/dist/Resources/Assets/CapAsset.d.ts +10 -0
  112. package/dist/Resources/Assets/CapAsset.js +18 -0
  113. package/dist/Resources/Assets/CarAsset.d.ts +10 -0
  114. package/dist/Resources/Assets/CarAsset.js +29 -0
  115. package/dist/Resources/Assets/CatAsset.d.ts +10 -0
  116. package/dist/Resources/Assets/CatAsset.js +17 -0
  117. package/dist/Resources/Assets/ChairAsset.d.ts +16 -0
  118. package/dist/Resources/Assets/ChairAsset.js +55 -0
  119. package/dist/Resources/Assets/ChatBubbleAsset.d.ts +11 -0
  120. package/dist/Resources/Assets/ChatBubbleAsset.js +18 -0
  121. package/dist/Resources/Assets/ClockAsset.d.ts +11 -0
  122. package/dist/Resources/Assets/ClockAsset.js +22 -0
  123. package/dist/Resources/Assets/CloudAsset.d.ts +10 -0
  124. package/dist/Resources/Assets/CloudAsset.js +17 -0
  125. package/dist/Resources/Assets/CoffeeMachineAsset.d.ts +10 -0
  126. package/dist/Resources/Assets/CoffeeMachineAsset.js +23 -0
  127. package/dist/Resources/Assets/ConfettiAsset.d.ts +10 -0
  128. package/dist/Resources/Assets/ConfettiAsset.js +18 -0
  129. package/dist/Resources/Assets/CounterAsset.d.ts +11 -0
  130. package/dist/Resources/Assets/CounterAsset.js +29 -0
  131. package/dist/Resources/Assets/CupAsset.d.ts +10 -0
  132. package/dist/Resources/Assets/CupAsset.js +17 -0
  133. package/dist/Resources/Assets/CursorAsset.d.ts +11 -0
  134. package/dist/Resources/Assets/CursorAsset.js +17 -0
  135. package/dist/Resources/Assets/CustomAsset.d.ts +25 -0
  136. package/dist/Resources/Assets/CustomAsset.js +58 -0
  137. package/dist/Resources/Assets/DeskAsset.d.ts +11 -0
  138. package/dist/Resources/Assets/DeskAsset.js +40 -0
  139. package/dist/Resources/Assets/DeskSlabAsset.d.ts +18 -0
  140. package/dist/Resources/Assets/DeskSlabAsset.js +43 -0
  141. package/dist/Resources/Assets/DiplomaAsset.d.ts +10 -0
  142. package/dist/Resources/Assets/DiplomaAsset.js +23 -0
  143. package/dist/Resources/Assets/DogAsset.d.ts +10 -0
  144. package/dist/Resources/Assets/DogAsset.js +24 -0
  145. package/dist/Resources/Assets/DrawerUnitAsset.d.ts +14 -0
  146. package/dist/Resources/Assets/DrawerUnitAsset.js +35 -0
  147. package/dist/Resources/Assets/FenceAsset.d.ts +10 -0
  148. package/dist/Resources/Assets/FenceAsset.js +26 -0
  149. package/dist/Resources/Assets/FigurineAsset.d.ts +10 -0
  150. package/dist/Resources/Assets/FigurineAsset.js +24 -0
  151. package/dist/Resources/Assets/FinishFlagAsset.d.ts +10 -0
  152. package/dist/Resources/Assets/FinishFlagAsset.js +21 -0
  153. package/dist/Resources/Assets/FirstAidKitAsset.d.ts +10 -0
  154. package/dist/Resources/Assets/FirstAidKitAsset.js +19 -0
  155. package/dist/Resources/Assets/FloorLampAsset.d.ts +10 -0
  156. package/dist/Resources/Assets/FloorLampAsset.js +22 -0
  157. package/dist/Resources/Assets/FlowersAsset.d.ts +10 -0
  158. package/dist/Resources/Assets/FlowersAsset.js +37 -0
  159. package/dist/Resources/Assets/FrameAsset.d.ts +11 -0
  160. package/dist/Resources/Assets/FrameAsset.js +24 -0
  161. package/dist/Resources/Assets/FruitBowlAsset.d.ts +10 -0
  162. package/dist/Resources/Assets/FruitBowlAsset.js +16 -0
  163. package/dist/Resources/Assets/GlassShelfAsset.d.ts +17 -0
  164. package/dist/Resources/Assets/GlassShelfAsset.js +25 -0
  165. package/dist/Resources/Assets/GlobeAsset.d.ts +10 -0
  166. package/dist/Resources/Assets/GlobeAsset.js +18 -0
  167. package/dist/Resources/Assets/HeadphonesAsset.d.ts +10 -0
  168. package/dist/Resources/Assets/HeadphonesAsset.js +23 -0
  169. package/dist/Resources/Assets/HouseAsset.d.ts +10 -0
  170. package/dist/Resources/Assets/HouseAsset.js +58 -0
  171. package/dist/Resources/Assets/LabAsset.d.ts +10 -0
  172. package/dist/Resources/Assets/LabAsset.js +52 -0
  173. package/dist/Resources/Assets/LampAsset.d.ts +10 -0
  174. package/dist/Resources/Assets/LampAsset.js +16 -0
  175. package/dist/Resources/Assets/LaptopAsset.d.ts +10 -0
  176. package/dist/Resources/Assets/LaptopAsset.js +27 -0
  177. package/dist/Resources/Assets/LaptopOpenAsset.d.ts +10 -0
  178. package/dist/Resources/Assets/LaptopOpenAsset.js +29 -0
  179. package/dist/Resources/Assets/LightSwitchAsset.d.ts +11 -0
  180. package/dist/Resources/Assets/LightSwitchAsset.js +24 -0
  181. package/dist/Resources/Assets/MonitorAsset.d.ts +10 -0
  182. package/dist/Resources/Assets/MonitorAsset.js +40 -0
  183. package/dist/Resources/Assets/MoonAsset.d.ts +10 -0
  184. package/dist/Resources/Assets/MoonAsset.js +16 -0
  185. package/dist/Resources/Assets/MountainAsset.d.ts +10 -0
  186. package/dist/Resources/Assets/MountainAsset.js +15 -0
  187. package/dist/Resources/Assets/OfficeChairAsset.d.ts +10 -0
  188. package/dist/Resources/Assets/OfficeChairAsset.js +45 -0
  189. package/dist/Resources/Assets/PalmAsset.d.ts +10 -0
  190. package/dist/Resources/Assets/PalmAsset.js +32 -0
  191. package/dist/Resources/Assets/PaperCupAsset.d.ts +10 -0
  192. package/dist/Resources/Assets/PaperCupAsset.js +17 -0
  193. package/dist/Resources/Assets/PendantLampAsset.d.ts +10 -0
  194. package/dist/Resources/Assets/PendantLampAsset.js +16 -0
  195. package/dist/Resources/Assets/PennantAsset.d.ts +10 -0
  196. package/dist/Resources/Assets/PennantAsset.js +15 -0
  197. package/dist/Resources/Assets/PersonAsset.d.ts +10 -0
  198. package/dist/Resources/Assets/PersonAsset.js +15 -0
  199. package/dist/Resources/Assets/PhotoFrameAsset.d.ts +15 -0
  200. package/dist/Resources/Assets/PhotoFrameAsset.js +68 -0
  201. package/dist/Resources/Assets/PineAsset.d.ts +10 -0
  202. package/dist/Resources/Assets/PineAsset.js +21 -0
  203. package/dist/Resources/Assets/PizzaAsset.d.ts +10 -0
  204. package/dist/Resources/Assets/PizzaAsset.js +17 -0
  205. package/dist/Resources/Assets/PlantAsset.d.ts +10 -0
  206. package/dist/Resources/Assets/PlantAsset.js +17 -0
  207. package/dist/Resources/Assets/PlasticBagAsset.d.ts +10 -0
  208. package/dist/Resources/Assets/PlasticBagAsset.js +15 -0
  209. package/dist/Resources/Assets/PlateAsset.d.ts +10 -0
  210. package/dist/Resources/Assets/PlateAsset.js +17 -0
  211. package/dist/Resources/Assets/PodiumAsset.d.ts +11 -0
  212. package/dist/Resources/Assets/PodiumAsset.js +20 -0
  213. package/dist/Resources/Assets/RefrigeratorAsset.d.ts +11 -0
  214. package/dist/Resources/Assets/RefrigeratorAsset.js +21 -0
  215. package/dist/Resources/Assets/RollingCartAsset.d.ts +11 -0
  216. package/dist/Resources/Assets/RollingCartAsset.js +34 -0
  217. package/dist/Resources/Assets/RugAsset.d.ts +10 -0
  218. package/dist/Resources/Assets/RugAsset.js +19 -0
  219. package/dist/Resources/Assets/SandcastleAsset.d.ts +10 -0
  220. package/dist/Resources/Assets/SandcastleAsset.js +30 -0
  221. package/dist/Resources/Assets/SchoolAsset.d.ts +10 -0
  222. package/dist/Resources/Assets/SchoolAsset.js +32 -0
  223. package/dist/Resources/Assets/ShelfWallAsset.d.ts +11 -0
  224. package/dist/Resources/Assets/ShelfWallAsset.js +23 -0
  225. package/dist/Resources/Assets/SinkAsset.d.ts +11 -0
  226. package/dist/Resources/Assets/SinkAsset.js +21 -0
  227. package/dist/Resources/Assets/SofaAsset.d.ts +16 -0
  228. package/dist/Resources/Assets/SofaAsset.js +66 -0
  229. package/dist/Resources/Assets/StageAsset.d.ts +10 -0
  230. package/dist/Resources/Assets/StageAsset.js +44 -0
  231. package/dist/Resources/Assets/StarAsset.d.ts +10 -0
  232. package/dist/Resources/Assets/StarAsset.js +14 -0
  233. package/dist/Resources/Assets/StarsAsset.d.ts +17 -0
  234. package/dist/Resources/Assets/StarsAsset.js +55 -0
  235. package/dist/Resources/Assets/StethoscopeAsset.d.ts +10 -0
  236. package/dist/Resources/Assets/StethoscopeAsset.js +18 -0
  237. package/dist/Resources/Assets/StoveAsset.d.ts +11 -0
  238. package/dist/Resources/Assets/StoveAsset.js +20 -0
  239. package/dist/Resources/Assets/StreetlightAsset.d.ts +10 -0
  240. package/dist/Resources/Assets/StreetlightAsset.js +20 -0
  241. package/dist/Resources/Assets/SuitcaseAsset.d.ts +10 -0
  242. package/dist/Resources/Assets/SuitcaseAsset.js +42 -0
  243. package/dist/Resources/Assets/SunAsset.d.ts +10 -0
  244. package/dist/Resources/Assets/SunAsset.js +22 -0
  245. package/dist/Resources/Assets/TableAsset.d.ts +15 -0
  246. package/dist/Resources/Assets/TableAsset.js +21 -0
  247. package/dist/Resources/Assets/ToggleAsset.d.ts +11 -0
  248. package/dist/Resources/Assets/ToggleAsset.js +21 -0
  249. package/dist/Resources/Assets/TrashCanAsset.d.ts +10 -0
  250. package/dist/Resources/Assets/TrashCanAsset.js +31 -0
  251. package/dist/Resources/Assets/TreeAsset.d.ts +15 -0
  252. package/dist/Resources/Assets/TreeAsset.js +48 -0
  253. package/dist/Resources/Assets/TrophyAsset.d.ts +10 -0
  254. package/dist/Resources/Assets/TrophyAsset.js +16 -0
  255. package/dist/Resources/Assets/TumblerAsset.d.ts +10 -0
  256. package/dist/Resources/Assets/TumblerAsset.js +17 -0
  257. package/dist/Resources/Assets/TvAsset.d.ts +10 -0
  258. package/dist/Resources/Assets/TvAsset.js +29 -0
  259. package/dist/Resources/Assets/TvStandAsset.d.ts +11 -0
  260. package/dist/Resources/Assets/TvStandAsset.js +34 -0
  261. package/dist/Resources/Assets/UmbrellaAsset.d.ts +10 -0
  262. package/dist/Resources/Assets/UmbrellaAsset.js +17 -0
  263. package/dist/Resources/Assets/UniversityAsset.d.ts +10 -0
  264. package/dist/Resources/Assets/UniversityAsset.js +22 -0
  265. package/dist/Resources/Assets/VaseFlowersAsset.d.ts +10 -0
  266. package/dist/Resources/Assets/VaseFlowersAsset.js +16 -0
  267. package/dist/Resources/Assets/WaterCoolerAsset.d.ts +11 -0
  268. package/dist/Resources/Assets/WaterCoolerAsset.js +20 -0
  269. package/dist/Resources/Assets/WhiteboardAsset.d.ts +10 -0
  270. package/dist/Resources/Assets/WhiteboardAsset.js +18 -0
  271. package/dist/Resources/Assets/WindowAsset.d.ts +11 -0
  272. package/dist/Resources/Assets/WindowAsset.js +32 -0
  273. package/dist/Resources/Groups/BaseGroup.d.ts +7 -0
  274. package/dist/Resources/Groups/BaseGroup.js +5 -0
  275. package/dist/Resources/Groups/CelebrationGroup.d.ts +8 -0
  276. package/dist/Resources/Groups/CelebrationGroup.js +19 -0
  277. package/dist/Resources/Groups/ConversationGroup.d.ts +9 -0
  278. package/dist/Resources/Groups/ConversationGroup.js +17 -0
  279. package/dist/Resources/Groups/DiningGroup.d.ts +8 -0
  280. package/dist/Resources/Groups/DiningGroup.js +21 -0
  281. package/dist/Resources/Groups/MeetingGroup.d.ts +8 -0
  282. package/dist/Resources/Groups/MeetingGroup.js +22 -0
  283. package/dist/Resources/Groups/ParkBenchGroup.d.ts +8 -0
  284. package/dist/Resources/Groups/ParkBenchGroup.js +17 -0
  285. package/dist/Resources/Groups/ReadingCornerGroup.d.ts +8 -0
  286. package/dist/Resources/Groups/ReadingCornerGroup.js +17 -0
  287. package/dist/Resources/Groups/WorkspaceGroup.d.ts +10 -0
  288. package/dist/Resources/Groups/WorkspaceGroup.js +25 -0
  289. package/dist/Resources/Kits/BaseKit.d.ts +13 -0
  290. package/dist/Resources/Kits/BaseKit.js +12 -0
  291. package/dist/Resources/Kits/ClayKit.d.ts +9 -0
  292. package/dist/Resources/Kits/ClayKit.js +11 -0
  293. package/dist/Resources/Kits/DuotoneKit.d.ts +16 -0
  294. package/dist/Resources/Kits/DuotoneKit.js +18 -0
  295. package/dist/Resources/Kits/FlatKit.d.ts +5 -0
  296. package/dist/Resources/Kits/FlatKit.js +8 -0
  297. package/dist/Resources/Kits/HatchKit.d.ts +15 -0
  298. package/dist/Resources/Kits/HatchKit.js +12 -0
  299. package/dist/Resources/Kits/IsometricKit.d.ts +8 -0
  300. package/dist/Resources/Kits/IsometricKit.js +10 -0
  301. package/dist/Resources/Kits/OutlineKit.d.ts +15 -0
  302. package/dist/Resources/Kits/OutlineKit.js +10 -0
  303. package/dist/Resources/Kits/PaperKit.d.ts +13 -0
  304. package/dist/Resources/Kits/PaperKit.js +12 -0
  305. package/dist/Resources/Kits/PosterKit.d.ts +14 -0
  306. package/dist/Resources/Kits/PosterKit.js +16 -0
  307. package/dist/Resources/Kits/RisoKit.d.ts +16 -0
  308. package/dist/Resources/Kits/RisoKit.js +11 -0
  309. package/dist/Resources/Kits/SketchKit.d.ts +10 -0
  310. package/dist/Resources/Kits/SketchKit.js +12 -0
  311. package/dist/Resources/Themes/BaseTheme.d.ts +5 -0
  312. package/dist/Resources/Themes/BaseTheme.js +5 -0
  313. package/dist/Resources/Themes/BeachTheme.d.ts +6 -0
  314. package/dist/Resources/Themes/BeachTheme.js +31 -0
  315. package/dist/Resources/Themes/FlatAutumnTheme.d.ts +6 -0
  316. package/dist/Resources/Themes/FlatAutumnTheme.js +29 -0
  317. package/dist/Resources/Themes/FlatCoolTheme.d.ts +6 -0
  318. package/dist/Resources/Themes/FlatCoolTheme.js +29 -0
  319. package/dist/Resources/Themes/NightTheme.d.ts +6 -0
  320. package/dist/Resources/Themes/NightTheme.js +29 -0
  321. package/dist/Resources/Themes/WarmCafeTheme.d.ts +6 -0
  322. package/dist/Resources/Themes/WarmCafeTheme.js +29 -0
  323. package/dist/Services/AssetService.d.ts +12 -0
  324. package/dist/Services/AssetService.js +232 -0
  325. package/dist/Services/BackgroundService.d.ts +41 -0
  326. package/dist/Services/BackgroundService.js +177 -0
  327. package/dist/Services/BalanceCritiqueService.d.ts +13 -0
  328. package/dist/Services/BalanceCritiqueService.js +64 -0
  329. package/dist/Services/CameraService.d.ts +21 -0
  330. package/dist/Services/CameraService.js +121 -0
  331. package/dist/Services/CatalogService.d.ts +30 -0
  332. package/dist/Services/CatalogService.js +56 -0
  333. package/dist/Services/ColorCritiqueService.d.ts +42 -0
  334. package/dist/Services/ColorCritiqueService.js +232 -0
  335. package/dist/Services/ContextService.d.ts +21 -0
  336. package/dist/Services/ContextService.js +98 -0
  337. package/dist/Services/CoverageCritiqueService.d.ts +16 -0
  338. package/dist/Services/CoverageCritiqueService.js +84 -0
  339. package/dist/Services/CustomAssetService.d.ts +31 -0
  340. package/dist/Services/CustomAssetService.js +184 -0
  341. package/dist/Services/DependencyOrderService.d.ts +12 -0
  342. package/dist/Services/DependencyOrderService.js +73 -0
  343. package/dist/Services/DescriptionService.d.ts +10 -0
  344. package/dist/Services/DescriptionService.js +33 -0
  345. package/dist/Services/DetailService.d.ts +7 -0
  346. package/dist/Services/DetailService.js +18 -0
  347. package/dist/Services/FocusCritiqueService.d.ts +23 -0
  348. package/dist/Services/FocusCritiqueService.js +166 -0
  349. package/dist/Services/FramingCheckService.d.ts +15 -0
  350. package/dist/Services/FramingCheckService.js +93 -0
  351. package/dist/Services/FramingService.d.ts +31 -0
  352. package/dist/Services/FramingService.js +108 -0
  353. package/dist/Services/GazeService.d.ts +6 -0
  354. package/dist/Services/GazeService.js +45 -0
  355. package/dist/Services/GroundDetailService.d.ts +50 -0
  356. package/dist/Services/GroundDetailService.js +115 -0
  357. package/dist/Services/GroupService.d.ts +17 -0
  358. package/dist/Services/GroupService.js +152 -0
  359. package/dist/Services/KitService.d.ts +32 -0
  360. package/dist/Services/KitService.js +131 -0
  361. package/dist/Services/LightingService.d.ts +39 -0
  362. package/dist/Services/LightingService.js +237 -0
  363. package/dist/Services/MapBaseService.d.ts +24 -0
  364. package/dist/Services/MapBaseService.js +104 -0
  365. package/dist/Services/MapLabelService.d.ts +26 -0
  366. package/dist/Services/MapLabelService.js +185 -0
  367. package/dist/Services/MapLegService.d.ts +23 -0
  368. package/dist/Services/MapLegService.js +87 -0
  369. package/dist/Services/MapPanelService.d.ts +16 -0
  370. package/dist/Services/MapPanelService.js +89 -0
  371. package/dist/Services/MapPinService.d.ts +11 -0
  372. package/dist/Services/MapPinService.js +56 -0
  373. package/dist/Services/MapProjectionService.d.ts +14 -0
  374. package/dist/Services/MapProjectionService.js +70 -0
  375. package/dist/Services/MapRouteService.d.ts +17 -0
  376. package/dist/Services/MapRouteService.js +79 -0
  377. package/dist/Services/PaletteService.d.ts +108 -0
  378. package/dist/Services/PaletteService.js +282 -0
  379. package/dist/Services/PieceService.d.ts +47 -0
  380. package/dist/Services/PieceService.js +175 -0
  381. package/dist/Services/PlacementService.d.ts +60 -0
  382. package/dist/Services/PlacementService.js +421 -0
  383. package/dist/Services/PlaneBackgroundService.d.ts +28 -0
  384. package/dist/Services/PlaneBackgroundService.js +209 -0
  385. package/dist/Services/PlaneBoxService.d.ts +27 -0
  386. package/dist/Services/PlaneBoxService.js +209 -0
  387. package/dist/Services/PlaneDepthService.d.ts +18 -0
  388. package/dist/Services/PlaneDepthService.js +146 -0
  389. package/dist/Services/PlaneLabelService.d.ts +13 -0
  390. package/dist/Services/PlaneLabelService.js +115 -0
  391. package/dist/Services/PlaneObjectService.d.ts +17 -0
  392. package/dist/Services/PlaneObjectService.js +147 -0
  393. package/dist/Services/PlanePathService.d.ts +15 -0
  394. package/dist/Services/PlanePathService.js +98 -0
  395. package/dist/Services/PlaneProjectionService.d.ts +20 -0
  396. package/dist/Services/PlaneProjectionService.js +119 -0
  397. package/dist/Services/PlaneRoadService.d.ts +13 -0
  398. package/dist/Services/PlaneRoadService.js +105 -0
  399. package/dist/Services/PlaneScatterService.d.ts +11 -0
  400. package/dist/Services/PlaneScatterService.js +48 -0
  401. package/dist/Services/PlaneSpaceService.d.ts +27 -0
  402. package/dist/Services/PlaneSpaceService.js +96 -0
  403. package/dist/Services/PlaneSpriteService.d.ts +29 -0
  404. package/dist/Services/PlaneSpriteService.js +95 -0
  405. package/dist/Services/PlaneTitleService.d.ts +17 -0
  406. package/dist/Services/PlaneTitleService.js +126 -0
  407. package/dist/Services/PlaneZoneService.d.ts +20 -0
  408. package/dist/Services/PlaneZoneService.js +121 -0
  409. package/dist/Services/RasterService.d.ts +10 -0
  410. package/dist/Services/RasterService.js +85 -0
  411. package/dist/Services/RidgeService.d.ts +31 -0
  412. package/dist/Services/RidgeService.js +85 -0
  413. package/dist/Services/ScaleCritiqueService.d.ts +11 -0
  414. package/dist/Services/ScaleCritiqueService.js +57 -0
  415. package/dist/Services/SchemaService.d.ts +3 -0
  416. package/dist/Services/SchemaService.js +10 -0
  417. package/dist/Services/SilhouetteCritiqueService.d.ts +32 -0
  418. package/dist/Services/SilhouetteCritiqueService.js +155 -0
  419. package/dist/Services/SkyDetailService.d.ts +39 -0
  420. package/dist/Services/SkyDetailService.js +95 -0
  421. package/dist/Services/TangentCritiqueService.d.ts +23 -0
  422. package/dist/Services/TangentCritiqueService.js +136 -0
  423. package/dist/Services/TextService.d.ts +87 -0
  424. package/dist/Services/TextService.js +434 -0
  425. package/dist/Services/ThemeService.d.ts +5 -0
  426. package/dist/Services/ThemeService.js +18 -0
  427. package/dist/Services/ThumbnailCritiqueService.d.ts +30 -0
  428. package/dist/Services/ThumbnailCritiqueService.js +130 -0
  429. package/dist/Utils/BoxUtil.d.ts +4 -0
  430. package/dist/Utils/BoxUtil.js +8 -0
  431. package/dist/Utils/ColorUtil.d.ts +34 -0
  432. package/dist/Utils/ColorUtil.js +114 -0
  433. package/dist/Utils/CurveUtil.d.ts +6 -0
  434. package/dist/Utils/CurveUtil.js +35 -0
  435. package/dist/Utils/DetailUtil.d.ts +7 -0
  436. package/dist/Utils/DetailUtil.js +15 -0
  437. package/dist/Utils/FallbackUtil.d.ts +3 -0
  438. package/dist/Utils/FallbackUtil.js +8 -0
  439. package/dist/Utils/FontMetricsUtil.d.ts +7 -0
  440. package/dist/Utils/FontMetricsUtil.js +694 -0
  441. package/dist/Utils/FormatUtil.d.ts +4 -0
  442. package/dist/Utils/FormatUtil.js +9 -0
  443. package/dist/Utils/IdUtil.d.ts +4 -0
  444. package/dist/Utils/IdUtil.js +11 -0
  445. package/dist/Utils/NormalizeUtil.d.ts +4 -0
  446. package/dist/Utils/NormalizeUtil.js +9 -0
  447. package/dist/Utils/OklabUtil.d.ts +41 -0
  448. package/dist/Utils/OklabUtil.js +151 -0
  449. package/dist/Utils/PersonArmUtil.d.ts +31 -0
  450. package/dist/Utils/PersonArmUtil.js +132 -0
  451. package/dist/Utils/PersonHeadUtil.d.ts +31 -0
  452. package/dist/Utils/PersonHeadUtil.js +156 -0
  453. package/dist/Utils/PersonOutfitUtil.d.ts +64 -0
  454. package/dist/Utils/PersonOutfitUtil.js +254 -0
  455. package/dist/Utils/PersonUtil.d.ts +41 -0
  456. package/dist/Utils/PersonUtil.js +216 -0
  457. package/dist/Utils/PixelUtil.d.ts +3 -0
  458. package/dist/Utils/PixelUtil.js +8 -0
  459. package/dist/Utils/RecolorUtil.d.ts +40 -0
  460. package/dist/Utils/RecolorUtil.js +155 -0
  461. package/dist/Utils/RegistryUtil.d.ts +8 -0
  462. package/dist/Utils/RegistryUtil.js +19 -0
  463. package/dist/Utils/RequireUtil.d.ts +3 -0
  464. package/dist/Utils/RequireUtil.js +11 -0
  465. package/dist/Utils/SanitizeUtil.d.ts +25 -0
  466. package/dist/Utils/SanitizeUtil.js +211 -0
  467. package/dist/Utils/SeedUtil.d.ts +6 -0
  468. package/dist/Utils/SeedUtil.js +15 -0
  469. package/dist/Utils/ShapeUtil.d.ts +40 -0
  470. package/dist/Utils/ShapeUtil.js +73 -0
  471. package/dist/Utils/SuggestUtil.d.ts +7 -0
  472. package/dist/Utils/SuggestUtil.js +25 -0
  473. package/dist/Utils/SvgUtil.d.ts +9 -0
  474. package/dist/Utils/SvgUtil.js +21 -0
  475. package/dist/Utils/ThemeUtil.d.ts +4 -0
  476. package/dist/Utils/ThemeUtil.js +13 -0
  477. package/dist/Utils/TransportUtil.d.ts +24 -0
  478. package/dist/Utils/TransportUtil.js +108 -0
  479. package/dist/Utils/TypesettingUtil.d.ts +17 -0
  480. package/dist/Utils/TypesettingUtil.js +92 -0
  481. package/dist/cli.js +52 -96
  482. package/dist/index.d.ts +10 -6
  483. package/dist/index.js +14 -2
  484. package/dist/render.d.ts +10 -5
  485. package/dist/render.js +26 -3
  486. package/dist/schema.d.ts +9 -2
  487. package/dist/schema.js +29 -5
  488. package/fonts/DMSerifDisplay-Regular.ttf +0 -0
  489. package/fonts/OFL.txt +2 -0
  490. package/fonts/PatrickHand-Regular.ttf +0 -0
  491. package/package.json +3 -2
  492. package/skills/{scenec → draw-scene}/SKILL.md +17 -20
  493. package/skills/{scenec/recipes/carrossel.yaml → draw-scene/recipes/carousel.yaml} +1 -1
  494. package/skills/draw-scene/recipes/conference-keynote.yaml +43 -0
  495. package/skills/draw-scene/recipes/product-feature.yaml +41 -0
  496. package/skills/{scenec/recipes/ilustracoes-produto.yaml → draw-scene/recipes/product-illustration.yaml} +2 -1
  497. package/skills/{scenec → draw-scene}/references/catalog.md +33 -15
  498. package/skills/{scenec → draw-scene}/references/dsl.md +32 -8
  499. package/dist/catalog.d.ts +0 -21
  500. package/dist/catalog.js +0 -35
  501. package/dist/data/europe.json +0 -1
  502. package/dist/drawing/assets.d.ts +0 -8
  503. package/dist/drawing/assets.js +0 -612
  504. package/dist/drawing/kits.d.ts +0 -7
  505. package/dist/drawing/kits.js +0 -92
  506. package/dist/drawing/person.d.ts +0 -18
  507. package/dist/drawing/person.js +0 -287
  508. package/dist/drawing/themes.d.ts +0 -4
  509. package/dist/drawing/themes.js +0 -45
  510. package/dist/modes/map.d.ts +0 -5
  511. package/dist/modes/map.js +0 -365
  512. package/dist/modes/plane.d.ts +0 -5
  513. package/dist/modes/plane.js +0 -716
  514. package/dist/pipeline/compile.d.ts +0 -2
  515. package/dist/pipeline/compile.js +0 -581
  516. package/dist/pipeline/custom.d.ts +0 -2
  517. package/dist/pipeline/custom.js +0 -120
  518. package/dist/pipeline/groups.d.ts +0 -2
  519. package/dist/pipeline/groups.js +0 -189
  520. package/dist/pipeline/index.js +0 -7
  521. package/dist/pipeline/parse.d.ts +0 -10
  522. package/dist/pipeline/parse.js +0 -80
  523. package/dist/protocols/options.js +0 -1
  524. package/dist/protocols/scene.d.ts +0 -299
  525. package/dist/protocols/scene.js +0 -118
  526. package/dist/protocols/theme.js +0 -1
  527. package/dist/render/check.d.ts +0 -6
  528. package/dist/render/check.js +0 -10
  529. package/dist/render/critic.d.ts +0 -1
  530. package/dist/render/critic.js +0 -235
  531. package/dist/render/files.d.ts +0 -2
  532. package/dist/render/files.js +0 -16
  533. package/dist/render/fonts.d.ts +0 -2
  534. package/dist/render/fonts.js +0 -4
  535. package/dist/render/png.d.ts +0 -9
  536. package/dist/render/png.js +0 -13
  537. package/dist/utils/color.d.ts +0 -5
  538. package/dist/utils/color.js +0 -35
  539. package/dist/utils/recolor.d.ts +0 -1
  540. package/dist/utils/recolor.js +0 -56
  541. package/dist/utils/sanitize.d.ts +0 -5
  542. package/dist/utils/sanitize.js +0 -169
  543. package/dist/utils/suggest.d.ts +0 -1
  544. package/dist/utils/suggest.js +0 -22
  545. package/dist/utils/svg.d.ts +0 -2
  546. package/dist/utils/svg.js +0 -11
  547. package/skills/scenec/references/fontes.md +0 -8
  548. /package/dist/{protocols/options.d.ts → Protocols/OptionsProtocol.d.ts} +0 -0
  549. /package/skills/{scenec/recipes/anuncios-variacoes.yaml → draw-scene/recipes/ad-variations.yaml} +0 -0
  550. /package/skills/{scenec/recipes/elearning.yaml → draw-scene/recipes/e-learning.yaml} +0 -0
  551. /package/skills/{scenec/recipes/reels-explicativo.yaml → draw-scene/recipes/explainer-reel.yaml} +0 -0
  552. /package/skills/{scenec/recipes/historia-ilustrada.yaml → draw-scene/recipes/illustrated-story.yaml} +0 -0
  553. /package/skills/{scenec/recipes/mapas-jornadas.yaml → draw-scene/recipes/journey-map.yaml} +0 -0
  554. /package/skills/{scenec/recipes/wrapped-personalizado.yaml → draw-scene/recipes/personalized-wrapped.yaml} +0 -0
@@ -0,0 +1,152 @@
1
+ import { WorkspaceGroup } from "../Resources/Groups/WorkspaceGroup.js";
2
+ import { ReadingCornerGroup } from "../Resources/Groups/ReadingCornerGroup.js";
3
+ import { DiningGroup } from "../Resources/Groups/DiningGroup.js";
4
+ import { ConversationGroup } from "../Resources/Groups/ConversationGroup.js";
5
+ import { ParkBenchGroup } from "../Resources/Groups/ParkBenchGroup.js";
6
+ import { CelebrationGroup } from "../Resources/Groups/CelebrationGroup.js";
7
+ import { MeetingGroup } from "../Resources/Groups/MeetingGroup.js";
8
+ import { GROUP_IDS } from "../Protocols/GroupProtocol.js";
9
+ import { IdUtil } from "../Utils/IdUtil.js";
10
+ import { RegistryUtil } from "../Utils/RegistryUtil.js";
11
+ class GroupService {
12
+ // Why: these are the keys that name another object, so a group has to prefix them with its own id.
13
+ static REFERENCE_KEYS = [
14
+ "left_of",
15
+ "right_of",
16
+ "behind",
17
+ "in_front_of",
18
+ "on",
19
+ "under",
20
+ "above",
21
+ "holds",
22
+ "look"
23
+ ];
24
+ static SIZE_NAME_TO_FACTOR = {
25
+ tiny: 0.5,
26
+ small: 0.75,
27
+ medium: 1,
28
+ large: 1.3,
29
+ huge: 1.7
30
+ };
31
+ static FACING_TO_OPPOSITE = { left: "right", right: "left" };
32
+ static GROUP_ID_TO_GROUP = RegistryUtil.indexById(
33
+ [
34
+ new WorkspaceGroup(),
35
+ new ReadingCornerGroup(),
36
+ new DiningGroup(),
37
+ new ConversationGroup(),
38
+ new ParkBenchGroup(),
39
+ new CelebrationGroup(),
40
+ new MeetingGroup()
41
+ ]
42
+ );
43
+ static expandGroups(idToObject, warnings) {
44
+ const idToExpanded = {};
45
+ const groupIdToAnchorId = {};
46
+ for (const [id, object] of Object.entries(idToObject)) {
47
+ if (!object.group) {
48
+ idToExpanded[id] = object;
49
+ continue;
50
+ }
51
+ const group = IdUtil.isOneOf(GROUP_IDS, object.group) ? GroupService.GROUP_ID_TO_GROUP[object.group] : void 0;
52
+ if (!group) {
53
+ const available = Object.keys(GroupService.GROUP_ID_TO_GROUP).join(", ");
54
+ warnings.push(`group '${object.group}' (in '${id}') does not exist; available: ${available}`);
55
+ continue;
56
+ }
57
+ const { partIdToPart, removed } = GroupService.buildParts(group, object);
58
+ for (const [partId, part] of Object.entries(partIdToPart)) {
59
+ idToExpanded[`${id}_${partId}`] = GroupService.placePart(part, { groupId: id, partIdToPart, removed, object });
60
+ }
61
+ groupIdToAnchorId[id] = `${id}_${group.anchor}`;
62
+ }
63
+ GroupService.pointReferencesAtAnchors(idToExpanded, groupIdToAnchorId);
64
+ return idToExpanded;
65
+ }
66
+ static buildParts(group, object) {
67
+ const partIdToPart = group.build({ ...object, at: object.at ?? 0.5 });
68
+ const removed = /* @__PURE__ */ new Set();
69
+ for (const [partId, override] of Object.entries(object.parts ?? {})) {
70
+ if (override === false) {
71
+ Reflect.deleteProperty(partIdToPart, partId);
72
+ removed.add(partId);
73
+ } else {
74
+ partIdToPart[partId] = { ...partIdToPart[partId], ...override };
75
+ }
76
+ }
77
+ return { partIdToPart, removed };
78
+ }
79
+ static placePart(part, context) {
80
+ const { groupId, partIdToPart, removed, object } = context;
81
+ const prefixed = (reference) => {
82
+ if (typeof reference === "string" && partIdToPart[reference]) {
83
+ return `${groupId}_${reference}`;
84
+ }
85
+ return typeof reference === "string" && removed.has(reference) ? void 0 : reference;
86
+ };
87
+ const placed = { ...part };
88
+ for (const key of GroupService.REFERENCE_KEYS) {
89
+ const reference = placed[key];
90
+ if (reference != null) {
91
+ placed[key] = Array.isArray(reference) ? reference.map(prefixed) : prefixed(reference);
92
+ }
93
+ }
94
+ GroupService.deleteUndefined(placed);
95
+ if (object.depth && !placed.on && !placed.depth) {
96
+ placed.depth = object.depth;
97
+ }
98
+ if (object.size != null && !placed.on && !placed.holds) {
99
+ placed.size = GroupService.sizeFactor(placed.size) * GroupService.sizeFactor(object.size);
100
+ }
101
+ if (object.flip) {
102
+ GroupService.flip(placed);
103
+ }
104
+ return placed;
105
+ }
106
+ static sizeFactor(size) {
107
+ if (typeof size === "number") {
108
+ return size;
109
+ }
110
+ return IdUtil.lookup(GroupService.SIZE_NAME_TO_FACTOR, size) ?? 1;
111
+ }
112
+ static flip(part) {
113
+ if (part.left_of || part.right_of) {
114
+ [part.left_of, part.right_of] = [part.right_of, part.left_of];
115
+ }
116
+ part.facing = GroupService.opposite(part.facing);
117
+ part.align = typeof part.align === "number" ? -part.align : GroupService.opposite(part.align);
118
+ if (typeof part.offset === "number") {
119
+ part.offset = -part.offset;
120
+ }
121
+ GroupService.deleteUndefined(part);
122
+ for (const key of ["facing", "align"]) {
123
+ if (part[key] == null) {
124
+ Reflect.deleteProperty(part, key);
125
+ }
126
+ }
127
+ }
128
+ static opposite(side) {
129
+ return IdUtil.lookup(GroupService.FACING_TO_OPPOSITE, side) ?? side;
130
+ }
131
+ static deleteUndefined(part) {
132
+ for (const key of Object.keys(part)) {
133
+ if (part[key] === void 0) {
134
+ Reflect.deleteProperty(part, key);
135
+ }
136
+ }
137
+ }
138
+ static pointReferencesAtAnchors(idToExpanded, groupIdToAnchorId) {
139
+ for (const part of Object.values(idToExpanded)) {
140
+ const fields = part;
141
+ for (const key of GroupService.REFERENCE_KEYS) {
142
+ const reference = fields[key];
143
+ if (typeof reference === "string" && groupIdToAnchorId[reference]) {
144
+ fields[key] = groupIdToAnchorId[reference];
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ export {
151
+ GroupService
152
+ };
@@ -0,0 +1,32 @@
1
+ import type { KitId, KitSceneName, KitTextureName } from "../Protocols/KitProtocol.js";
2
+ import { BaseKit } from "../Resources/Kits/BaseKit.js";
3
+ import type { CompilationContext } from "../Protocols/CompilationProtocol.js";
4
+ import type { CompileResult } from "../Protocols/ResultProtocol.js";
5
+ export interface OutlineFilterOptions {
6
+ shadeX?: number;
7
+ shadeY?: number;
8
+ wobble?: number;
9
+ }
10
+ export declare class KitService {
11
+ static readonly KIT_ID_TO_KIT: Record<KitId, BaseKit>;
12
+ private static readonly WHOLE_KIT_HEIGHT;
13
+ private static readonly LIGHT_MODE_TO_IS_HATCHED;
14
+ private static readonly DIGITS;
15
+ private static readonly WOBBLE_FREQUENCY;
16
+ private static readonly WOBBLE_SEED;
17
+ private static readonly SMALL_SHAPE;
18
+ private static readonly DROP_BLUR;
19
+ private static readonly DROP_OFFSET_X;
20
+ private static readonly DROP_OFFSET_Y;
21
+ private static readonly SCENE_TO_FILTER;
22
+ private static readonly TEXTURE_TO_FILTER;
23
+ private static fixed;
24
+ static outlineFilter(id: string, radius: number, ink: string, options?: OutlineFilterOptions): string;
25
+ static dropFilter(id: string, scale: number): string;
26
+ static innerStroke(art: string, width: number, ink: string, detailRatio?: number): string;
27
+ private static isSmallShape;
28
+ static hatchDefs(ink: string): string;
29
+ static sceneFilter(kind: KitSceneName): string;
30
+ static texture(kind: KitTextureName | undefined, width: number, height: number): string;
31
+ static applyWholeKit(result: CompileResult, context: CompilationContext): CompileResult;
32
+ }
@@ -0,0 +1,131 @@
1
+ import { FlatKit } from "../Resources/Kits/FlatKit.js";
2
+ import { OutlineKit } from "../Resources/Kits/OutlineKit.js";
3
+ import { HatchKit } from "../Resources/Kits/HatchKit.js";
4
+ import { RisoKit } from "../Resources/Kits/RisoKit.js";
5
+ import { PaperKit } from "../Resources/Kits/PaperKit.js";
6
+ import { SketchKit } from "../Resources/Kits/SketchKit.js";
7
+ import { ClayKit } from "../Resources/Kits/ClayKit.js";
8
+ import { DuotoneKit } from "../Resources/Kits/DuotoneKit.js";
9
+ import { PosterKit } from "../Resources/Kits/PosterKit.js";
10
+ import { IsometricKit } from "../Resources/Kits/IsometricKit.js";
11
+ import { RegistryUtil } from "../Utils/RegistryUtil.js";
12
+ import { IdUtil } from "../Utils/IdUtil.js";
13
+ import { SvgUtil } from "../Utils/SvgUtil.js";
14
+ class KitService {
15
+ static KIT_ID_TO_KIT = RegistryUtil.indexById([
16
+ new FlatKit(),
17
+ new OutlineKit(),
18
+ new HatchKit(),
19
+ new RisoKit(),
20
+ new PaperKit(),
21
+ new SketchKit(),
22
+ new ClayKit(),
23
+ new DuotoneKit(),
24
+ new PosterKit(),
25
+ new IsometricKit()
26
+ ]);
27
+ static WHOLE_KIT_HEIGHT = 900;
28
+ static LIGHT_MODE_TO_IS_HATCHED = { none: false, hatch: true };
29
+ static DIGITS = 3;
30
+ static WOBBLE_FREQUENCY = 0.035;
31
+ static WOBBLE_SEED = 9;
32
+ static SMALL_SHAPE = 5;
33
+ static DROP_BLUR = 2.2;
34
+ static DROP_OFFSET_X = 2.5;
35
+ static DROP_OFFSET_Y = 4;
36
+ static SCENE_TO_FILTER = {
37
+ // Why: posterize to flat ink, misregister accent ink on darkest plate, mask speckle by ink amount and simulate halftone.
38
+ riso: `<filter id="kitScene" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB"><feComponentTransfer in="SourceGraphic" result="post"><feFuncR type="discrete" tableValues="0.1 0.35 0.6 0.85 1"/><feFuncG type="discrete" tableValues="0.1 0.35 0.6 0.85 1"/><feFuncB type="discrete" tableValues="0.12 0.38 0.62 0.86 1"/></feComponentTransfer><feOffset in="post" dx="2.2" dy="1.4" result="off"/><feColorMatrix in="off" type="matrix" values="0 0 0 0 1 0 0 0 0 0.28 0 0 0 0 0.69 -1.8 -1.8 -1.8 0 0.85" result="tint"/><feBlend in="post" in2="tint" mode="multiply" result="reg"/><feColorMatrix in="post" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.3 -0.59 -0.11 0 0.94" result="ink"/><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="1" seed="7" result="grain"/><feComposite in="grain" in2="ink" operator="arithmetic" k1="0" k2="0.6" k3="1.2" k4="-0.5" result="dotSum"/><feComponentTransfer in="dotSum" result="dots"><feFuncA type="linear" slope="3.0" intercept="-0.6"/></feComponentTransfer><feColorMatrix in="dots" type="matrix" values="0 0 0 0 0.1 0 0 0 0 0.12 0 0 0 0 0.25 0 0 0 0.35 0" result="spk"/><feComposite in="spk" in2="ink" operator="in" result="spk2"/><feBlend in="reg" in2="spk2" mode="multiply" result="final"/></filter>`,
39
+ // Why: pencil edge lines, saturated watercolor wash with grayscale turbulence (colored noise reads as speckle), darker edge band pooling and offset color wash.
40
+ sketch: `<filter id="kitScene" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB"><feColorMatrix in="SourceGraphic" type="matrix" values="0.3 0.59 0.11 0 0 0.3 0.59 0.11 0 0 0.3 0.59 0.11 0 0 0 0 0 1 0" result="g"/><feConvolveMatrix in="g" order="3" kernelMatrix="-1 -1 -1 -1 8 -1 -1 -1 -1" preserveAlpha="true" result="e1"/><feConvolveMatrix in="g" order="3" kernelMatrix="1 1 1 1 -8 1 1 1 1" preserveAlpha="true" result="e2"/><feComposite in="e1" in2="e2" operator="arithmetic" k2="1" k3="1" result="e"/><feColorMatrix in="e" type="matrix" values="0 0 0 0 0.22 0 0 0 0 0.22 0 0 0 0 0.26 2.2 2.2 2.2 0 0" result="lines"/><feMorphology in="lines" operator="dilate" radius="0.6" result="lines2"/><feColorMatrix in="SourceGraphic" type="saturate" values="0.8" result="sat"/><feComponentTransfer in="sat" result="washBase"><feFuncR type="linear" slope="0.75" intercept="0.22"/><feFuncG type="linear" slope="0.75" intercept="0.22"/><feFuncB type="linear" slope="0.75" intercept="0.20"/></feComponentTransfer><feTurbulence type="fractalNoise" baseFrequency="0.018" numOctaves="2" seed="4" result="washNoiseColor"/><feColorMatrix in="washNoiseColor" type="matrix" values="0.3 0.59 0.11 0 0 0.3 0.59 0.11 0 0 0.3 0.59 0.11 0 0 0 0 0 0 1" result="washNoise"/><feBlend in="washBase" in2="washNoise" mode="soft-light" result="washUneven"/><feMorphology in="SourceAlpha" operator="erode" radius="1.4" result="eroded"/><feComposite in="SourceAlpha" in2="eroded" operator="out" result="edgeBand"/><feColorMatrix in="edgeBand" type="matrix" values="0 0 0 -0.32 1 0 0 0 -0.32 1 0 0 0 -0.32 1 0 0 0 0 1" result="edgeDarken"/><feBlend in="washUneven" in2="edgeDarken" mode="multiply" result="washWithEdges"/><feComposite in="washWithEdges" in2="SourceGraphic" operator="in" result="washClipped"/><feOffset in="washClipped" dx="1.6" dy="1.2" result="washOffset"/><feMerge><feMergeNode in="washOffset"/><feMergeNode in="lines2"/></feMerge></filter>`,
41
+ // Why: soft 3D bevel and rim lighting with diffuse contact shading.
42
+ clay: `<filter id="kitScene" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB"><feGaussianBlur in="SourceAlpha" stdDeviation="3.0" result="b1"/><feOffset in="b1" dx="-2.5" dy="-3.0" result="hiOffset"/><feOffset in="b1" dx="2.5" dy="3.0" result="shOffset"/><feComposite in="hiOffset" in2="shOffset" operator="arithmetic" k2="1.2" k3="-0.9" result="rimRaw"/><feColorMatrix in="rimRaw" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.2 -0.1" result="rim"/><feComposite in="shOffset" in2="hiOffset" operator="arithmetic" k2="0.8" k3="-0.6" result="shRaw"/><feColorMatrix in="shRaw" type="matrix" values="0 0 0 0 0.15 0 0 0 0 0.15 0 0 0 0 0.2 0 0 0 0.7 0" result="sh"/><feBlend in="SourceGraphic" in2="sh" mode="multiply" result="shaded"/><feBlend in="shaded" in2="rim" mode="screen" result="lit"/><feComposite in="lit" in2="SourceGraphic" operator="in" result="final"/></filter>`,
43
+ // Why: luminance mapped across two inks (navy and paper) with fine halftone texture.
44
+ duotone: `<filter id="kitScene" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB"><feColorMatrix in="SourceGraphic" type="matrix" values="0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0" result="lum"/><feComponentTransfer in="lum" result="map"><feFuncR type="table" tableValues="0.114 0.22 0.55 0.82 0.957"/><feFuncG type="table" tableValues="0.176 0.32 0.62 0.85 0.922"/><feFuncB type="table" tableValues="0.314 0.45 0.71 0.86 0.851"/></feComponentTransfer><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="1" seed="11" result="nz"/><feColorMatrix in="nz" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.18 0" result="ht"/><feBlend in="map" in2="ht" mode="multiply" result="final"/></filter>`,
45
+ // Why: 4-5 color posterization, sun-faded grade and coarse shadow halftone.
46
+ poster: `<filter id="kitScene" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB"><feComponentTransfer in="SourceGraphic" result="post"><feFuncR type="discrete" tableValues="0.12 0.35 0.58 0.82 1.0"/><feFuncG type="discrete" tableValues="0.12 0.35 0.58 0.82 1.0"/><feFuncB type="discrete" tableValues="0.14 0.36 0.59 0.83 1.0"/></feComponentTransfer><feColorMatrix in="post" type="matrix" values="1.04 0 0 0 0.03 0 0.98 0 0 0.02 0 0 0.88 0 -0.01 0 0 0 1 0" result="faded"/><feColorMatrix in="post" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.5 -1.5 -1.5 0 0.8" result="shMask"/><feTurbulence type="fractalNoise" baseFrequency="0.4" numOctaves="1" seed="17" result="coarseNz"/><feComposite in="coarseNz" in2="shMask" operator="in" result="coarseDots"/><feColorMatrix in="coarseDots" type="matrix" values="0 0 0 0 0.17 0 0 0 0 0.13 0 0 0 0 0.10 0 0 0 0.35 0" result="shDots"/><feBlend in="faded" in2="shDots" mode="multiply" result="final"/></filter>`
47
+ };
48
+ static TEXTURE_TO_FILTER = {
49
+ paper: {
50
+ defs: `<filter id="kitTex" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="2" seed="3"/><feColorMatrix type="matrix" values="0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0 0.33 0 0 0 -1.6 1.05"/></filter>`,
51
+ opacity: "0.05"
52
+ },
53
+ fiber: {
54
+ defs: `<filter id="kitTex" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2" seed="5" result="f"/><feTurbulence type="fractalNoise" baseFrequency="0.02" numOctaves="3" seed="11" result="m"/><feComposite in="f" in2="m" operator="arithmetic" k2="0.6" k3="0.4" result="mix"/><feColorMatrix in="mix" type="matrix" values="0 0 0 0 0.42 0 0 0 0 0.36 0 0 0 0 0.28 0.5 0 0 0 -0.12"/></filter>`,
55
+ opacity: "0.55"
56
+ }
57
+ };
58
+ static fixed(value) {
59
+ return value.toFixed(KitService.DIGITS);
60
+ }
61
+ static outlineFilter(id, radius, ink, options = {}) {
62
+ const { shadeX = 0, shadeY = 0, wobble = 0 } = options;
63
+ const isWeighted = shadeX !== 0 || shadeY !== 0;
64
+ const weighted = isWeighted ? `<feOffset in="d" dx="${KitService.fixed(shadeX)}" dy="${KitService.fixed(shadeY)}" result="d2"/><feMerge result="dm"><feMergeNode in="d"/><feMergeNode in="d2"/></feMerge>` : `<feOffset in="d" dx="0" dy="0" result="dm"/>`;
65
+ const wobbled = wobble > 0 ? `<feTurbulence type="fractalNoise" baseFrequency="${KitService.WOBBLE_FREQUENCY}" numOctaves="2" seed="${KitService.WOBBLE_SEED}" result="n"/><feDisplacementMap in="dm" in2="n" scale="${KitService.fixed(wobble)}" xChannelSelector="R" yChannelSelector="G" result="dw"/>` : `<feOffset in="dm" dx="0" dy="0" result="dw"/>`;
66
+ return `<filter id="${id}" x="-15%" y="-15%" width="130%" height="130%"><feMorphology in="SourceAlpha" operator="dilate" radius="${KitService.fixed(radius)}" result="d"/>` + weighted + wobbled + `<feFlood flood-color="${ink}"/><feComposite in2="dw" operator="in" result="o"/><feMerge><feMergeNode in="o"/><feMergeNode in="SourceGraphic"/></feMerge></filter>`;
67
+ }
68
+ static dropFilter(id, scale) {
69
+ const blur = KitService.fixed(KitService.DROP_BLUR / scale);
70
+ const offsetX = KitService.fixed(KitService.DROP_OFFSET_X / scale);
71
+ const offsetY = KitService.fixed(KitService.DROP_OFFSET_Y / scale);
72
+ return `<filter id="${id}" x="-20%" y="-20%" width="140%" height="150%"><feGaussianBlur in="SourceAlpha" stdDeviation="${blur}"/><feOffset dx="${offsetX}" dy="${offsetY}" result="b"/><feFlood flood-color="#2B1D10" flood-opacity="0.42"/><feComposite in2="b" operator="in" result="sh"/><feMerge><feMergeNode in="sh"/><feMergeNode in="SourceGraphic"/></feMerge></filter>`;
73
+ }
74
+ static innerStroke(art, width, ink, detailRatio = 1) {
75
+ const shapes = art.replace(/<(rect|path|circle|ellipse|polygon)\b([^>]*?)\/>/g, (match, tag, attrs) => {
76
+ const hasStroke = /\bstroke=/.test(attrs);
77
+ const isUnpainted = /\bopacity=|fill-opacity=|fill="none"|fill="url\(/.test(attrs);
78
+ if (isUnpainted && !hasStroke) {
79
+ return `<${tag}${attrs} stroke="none"/>`;
80
+ }
81
+ const isDetail = !hasStroke && KitService.isSmallShape(attrs);
82
+ return isDetail ? `<${tag}${attrs} stroke-width="${KitService.fixed(width * detailRatio)}"/>` : match;
83
+ });
84
+ return `<g stroke="${ink}" stroke-width="${KitService.fixed(width)}" stroke-linejoin="round">${shapes}</g>`;
85
+ }
86
+ static isSmallShape(attrs) {
87
+ const sizes = [...attrs.matchAll(/\b(?:r|rx|ry)="([\d.]+)"/g)].map((match) => Number(match[1]) * 2).concat([...attrs.matchAll(/\b(?:width|height)="([\d.]+)"/g)].map((match) => Number(match[1])));
88
+ return sizes.length > 0 && Math.min(...sizes) <= KitService.SMALL_SHAPE;
89
+ }
90
+ static hatchDefs(ink) {
91
+ return `<pattern id="hatchP" width="7" height="7" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect x="0" y="0" width="1.5" height="7" fill="${ink}" fill-opacity="0.5"/></pattern><pattern id="hatchC" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(-35)"><rect x="0" y="0" width="1.4" height="6" fill="${ink}" fill-opacity="0.42"/><rect x="0" y="0" width="6" height="1.2" fill="${ink}" fill-opacity="0.22"/></pattern>`;
92
+ }
93
+ static sceneFilter(kind) {
94
+ return KitService.SCENE_TO_FILTER[kind];
95
+ }
96
+ static texture(kind, width, height) {
97
+ const filter = IdUtil.lookup(KitService.TEXTURE_TO_FILTER, kind);
98
+ if (!filter) {
99
+ return "";
100
+ }
101
+ return `${filter.defs}<rect width="${width}" height="${height}" filter="url(#kitTex)" opacity="${filter.opacity}"/>`;
102
+ }
103
+ static applyWholeKit(result, context) {
104
+ const { canvas, kit, width } = context;
105
+ const isHatched = IdUtil.lookup(KitService.LIGHT_MODE_TO_IS_HATCHED, kit.light?.mode) === true;
106
+ if (kit.outline || isHatched) {
107
+ result.warnings.push(
108
+ `in ${canvas.mode} mode, kit '${canvas.kit}' applies only filter and texture; per-object outline and hatching exist in classic mode`
109
+ );
110
+ }
111
+ if (!kit.scene && !kit.texture) {
112
+ return result;
113
+ }
114
+ const height = canvas.height ?? KitService.WHOLE_KIT_HEIGHT;
115
+ const svg = result.svg.replace(/(<svg[^>]*>)([\s\S]*)(<\/svg>\s*)$/, (_match, open, body, close) => {
116
+ const texts = [];
117
+ const art = body.replace(/<text\b[\s\S]*?<\/text>/g, (text) => {
118
+ texts.push(text);
119
+ return "";
120
+ });
121
+ const defs = kit.scene ? KitService.sceneFilter(kit.scene) : "";
122
+ const filter = kit.scene ? ' filter="url(#kitScene)"' : "";
123
+ const texture = KitService.texture(kit.texture, width, height);
124
+ return `${open}<defs>${defs}</defs><g${filter}>${art}</g>${texture}${texts.join("")}${close}`;
125
+ });
126
+ return { ...result, svg: SvgUtil.flattenOpacity(svg) };
127
+ }
128
+ }
129
+ export {
130
+ KitService
131
+ };
@@ -0,0 +1,39 @@
1
+ import type { Background, Camera, CompilationContext, LightState, Placement } from "../Protocols/CompilationProtocol.js";
2
+ import type { TimeName } from "../Protocols/SceneProtocol.js";
3
+ export declare class LightingService {
4
+ private static readonly DIRECTION_TO_FRACTION;
5
+ private static readonly MODE_TO_TRAITS;
6
+ private static readonly TIME_TO_LIGHT_COLOR;
7
+ private static readonly TIME_TO_GRADE;
8
+ private static readonly PANE_BOXES;
9
+ private static readonly SHAFT_WIDTH_RATIO;
10
+ private static readonly FLOOR_PATCH_START;
11
+ private static readonly FLOOR_PATCH_SPAN;
12
+ private static readonly FLOOR_LEFT_FAR;
13
+ private static readonly FLOOR_LEFT_NEAR;
14
+ private static readonly FLOOR_PANE_OPACITY;
15
+ private static readonly INDOOR_LIGHT;
16
+ private static readonly OPEN_LIGHT;
17
+ private static readonly SETTING_TO_LIGHT;
18
+ private static readonly DEFAULT_SOURCE;
19
+ private static readonly DEFAULT_STRENGTH;
20
+ private static readonly LIGHT_LEFT_LIMIT;
21
+ private static readonly LIGHT_RIGHT_LIMIT;
22
+ private static readonly NIGHT_LUMINANCE;
23
+ private static readonly NIGHT_LIGHT;
24
+ private static readonly DAY_LIGHT;
25
+ private static readonly SOURCE_ASSETS;
26
+ static resolve(context: CompilationContext, list: Placement[], background: Background): LightState | null;
27
+ private static resolveShaft;
28
+ static timeGradeFilter(time: TimeName): string;
29
+ private static settingLightOf;
30
+ private static directionOf;
31
+ private static sourceOf;
32
+ static lightColorOf(light: LightState): string;
33
+ static applyToBackground(svg: string, light: LightState, context: CompilationContext, camera: Camera): string;
34
+ private static vignetteDef;
35
+ private static defs;
36
+ private static sunGlowDef;
37
+ private static shaftGradDef;
38
+ private static indoorShaftSvg;
39
+ }
@@ -0,0 +1,237 @@
1
+ import { IdUtil } from "../Utils/IdUtil.js";
2
+ import { KitService } from "./KitService.js";
3
+ import { ColorUtil } from "../Utils/ColorUtil.js";
4
+ class LightingService {
5
+ static DIRECTION_TO_FRACTION = {
6
+ left: 0.05,
7
+ right: 0.95,
8
+ front: 0.5,
9
+ top: 0.5
10
+ };
11
+ static MODE_TO_TRAITS = {
12
+ none: { isOff: true, isHatch: false },
13
+ hatch: { isOff: false, isHatch: true }
14
+ };
15
+ static TIME_TO_LIGHT_COLOR = {
16
+ golden: "#FFAE42",
17
+ noon: "#FFFFF0",
18
+ overcast: "#D8DFE8",
19
+ dusk: "#E8A0BF",
20
+ night: "#9BB8ED"
21
+ };
22
+ static TIME_TO_GRADE = {
23
+ golden: `<filter id="timeGrade" color-interpolation-filters="sRGB"><feColorMatrix type="matrix" values="1.08 0 0 0 0.04 0 1.02 0 0 0.02 0 0 0.88 0 -0.02 0 0 0 1 0"/></filter>`,
24
+ noon: `<filter id="timeGrade" color-interpolation-filters="sRGB"><feComponentTransfer><feFuncR type="linear" slope="1.05" intercept="-0.025"/><feFuncG type="linear" slope="1.05" intercept="-0.025"/><feFuncB type="linear" slope="1.05" intercept="-0.025"/></feComponentTransfer></filter>`,
25
+ overcast: `<filter id="timeGrade" color-interpolation-filters="sRGB"><feColorMatrix type="saturate" values="0.75"/><feComponentTransfer><feFuncR type="linear" slope="0.95" intercept="0.04"/><feFuncG type="linear" slope="0.95" intercept="0.04"/><feFuncB type="linear" slope="0.98" intercept="0.05"/></feComponentTransfer></filter>`,
26
+ dusk: `<filter id="timeGrade" color-interpolation-filters="sRGB"><feColorMatrix type="matrix" values="1.05 0 0 0 0.05 0 0.92 0 0 0.01 0 0 1.08 0 0.06 0 0 0 1 0"/></filter>`,
27
+ night: `<filter id="timeGrade" color-interpolation-filters="sRGB"><feColorMatrix type="matrix" values="0.65 0 0 0 0.01 0 0.72 0 0 0.02 0 0 0.92 0 0.08 0 0 0 1 0"/></filter>`
28
+ };
29
+ static PANE_BOXES = [
30
+ [0.08, 0.08, 0.46, 0.46],
31
+ [0.54, 0.08, 0.92, 0.46],
32
+ [0.08, 0.54, 0.46, 0.92],
33
+ [0.54, 0.54, 0.92, 0.92]
34
+ ];
35
+ static SHAFT_WIDTH_RATIO = 0.4;
36
+ static FLOOR_PATCH_START = 0.15;
37
+ static FLOOR_PATCH_SPAN = 0.7;
38
+ static FLOOR_LEFT_FAR = 2.2;
39
+ static FLOOR_LEFT_NEAR = 0.4;
40
+ static FLOOR_PANE_OPACITY = 0.2;
41
+ static INDOOR_LIGHT = {
42
+ surface: "wall",
43
+ blur: 6e-3,
44
+ glowY: 0.25,
45
+ extraSourceAsset: "window",
46
+ glowLayers: (defs, { width, height, horizonY, light }) => {
47
+ const shaftLayer = light.shaft ? LightingService.indoorShaftSvg(light.shaft, light, { width, height, horizonY }) : "";
48
+ return `${defs}<rect width="${width}" height="${horizonY}" fill="url(#glow)" style="mix-blend-mode: screen;"/><rect width="${width}" height="${height}" fill="url(#falloff)" style="mix-blend-mode: multiply;"/>` + shaftLayer;
49
+ }
50
+ };
51
+ static OPEN_LIGHT = {
52
+ surface: "skyTop",
53
+ blur: 3e-3,
54
+ glowY: 0.15,
55
+ extraSourceAsset: null,
56
+ glowLayers: (defs, { width, height, light }) => {
57
+ const sunLayer = light.celestialGlow ? `<rect width="${width}" height="${height}" fill="url(#sunGlow)" style="mix-blend-mode: screen;"/>` : "";
58
+ return `${defs}<rect width="${width}" height="${height * 0.75}" fill="url(#glow)" style="mix-blend-mode: screen;"/>${sunLayer}`;
59
+ }
60
+ };
61
+ static SETTING_TO_LIGHT = {
62
+ indoor: LightingService.INDOOR_LIGHT
63
+ };
64
+ static DEFAULT_SOURCE = 0.15;
65
+ static DEFAULT_STRENGTH = 0.6;
66
+ static LIGHT_LEFT_LIMIT = 0.4;
67
+ static LIGHT_RIGHT_LIMIT = 0.6;
68
+ static NIGHT_LUMINANCE = 0.12;
69
+ static NIGHT_LIGHT = "#C9D8FF";
70
+ static DAY_LIGHT = "#FFF4DE";
71
+ static SOURCE_ASSETS = ["sun", "moon"];
72
+ static resolve(context, list, background) {
73
+ const { canvas, kit, setting, width, theme } = context;
74
+ const kitLight = kit.light ?? {};
75
+ const modeTraits = IdUtil.lookup(LightingService.MODE_TO_TRAITS, kitLight.mode);
76
+ const isDisabled = canvas.light === false || modeTraits?.isOff === true && canvas.light == null;
77
+ if (isDisabled) {
78
+ return null;
79
+ }
80
+ const requested = typeof canvas.light === "object" ? canvas.light : {};
81
+ const settingLight = LightingService.settingLightOf(setting);
82
+ const { extraSourceAsset } = settingLight;
83
+ const source = LightingService.sourceOf(requested.from, { list, width, extraSourceAsset });
84
+ const isNight = canvas.time === "night" || ColorUtil.luminance(theme[settingLight.surface]) < LightingService.NIGHT_LUMINANCE;
85
+ const [red, green, blue] = background.shadowRgba;
86
+ const celestial = list.find((placement) => IdUtil.isOneOf(LightingService.SOURCE_ASSETS, placement.asset));
87
+ const celestialGlow = celestial ? { cx: celestial.x / width, cy: celestial.y / context.height } : null;
88
+ const shaft = LightingService.resolveShaft(setting, list, requested, width);
89
+ return {
90
+ source,
91
+ strength: requested.strength ?? kitLight.strength ?? LightingService.DEFAULT_STRENGTH,
92
+ direction: LightingService.directionOf(source),
93
+ isNight,
94
+ shadowColor: `rgb(${red},${green},${blue})`,
95
+ shadowRgb: [red, green, blue],
96
+ isHatch: modeTraits?.isHatch === true,
97
+ time: canvas.time,
98
+ shaft,
99
+ celestialGlow
100
+ };
101
+ }
102
+ static resolveShaft(setting, list, requested, width) {
103
+ if (setting !== "indoor" || requested.shafts === false) {
104
+ return null;
105
+ }
106
+ const windowPlacement = list.find((placement) => placement.asset === "window");
107
+ if (!windowPlacement) {
108
+ return null;
109
+ }
110
+ const winX = windowPlacement.x;
111
+ const winY = windowPlacement.y;
112
+ const winW = windowPlacement.width * windowPlacement.scale;
113
+ const winH = windowPlacement.height * windowPlacement.scale;
114
+ const isRight = winX > width * 0.5;
115
+ const floorLeft = isRight ? winX - winW * LightingService.FLOOR_LEFT_FAR : winX + winW * LightingService.FLOOR_LEFT_NEAR;
116
+ const floorRight = isRight ? winX - winW * LightingService.FLOOR_LEFT_NEAR : winX + winW * LightingService.FLOOR_LEFT_FAR;
117
+ return {
118
+ windowX: winX,
119
+ windowY: winY,
120
+ windowWidth: winW,
121
+ windowHeight: winH,
122
+ floorLeft,
123
+ floorRight
124
+ };
125
+ }
126
+ static timeGradeFilter(time) {
127
+ return LightingService.TIME_TO_GRADE[time];
128
+ }
129
+ static settingLightOf(setting) {
130
+ return IdUtil.lookup(LightingService.SETTING_TO_LIGHT, setting) ?? LightingService.OPEN_LIGHT;
131
+ }
132
+ static directionOf(source) {
133
+ if (source < LightingService.LIGHT_LEFT_LIMIT) {
134
+ return 1;
135
+ }
136
+ return source > LightingService.LIGHT_RIGHT_LIMIT ? -1 : 0;
137
+ }
138
+ static sourceOf(from, scene) {
139
+ if (typeof from === "number") {
140
+ return from;
141
+ }
142
+ const named = IdUtil.lookup(LightingService.DIRECTION_TO_FRACTION, from);
143
+ if (named != null) {
144
+ return named;
145
+ }
146
+ const isSource = (placement) => IdUtil.isOneOf(LightingService.SOURCE_ASSETS, placement.asset);
147
+ const isExtra = (placement) => placement.asset === scene.extraSourceAsset;
148
+ const sourcePlacement = scene.list.find(isSource) ?? (scene.extraSourceAsset ? scene.list.find(isExtra) : void 0);
149
+ return sourcePlacement ? sourcePlacement.x / scene.width : LightingService.DEFAULT_SOURCE;
150
+ }
151
+ static lightColorOf(light) {
152
+ if (light.time != null) {
153
+ const timeColor = IdUtil.lookup(LightingService.TIME_TO_LIGHT_COLOR, light.time);
154
+ if (timeColor != null) {
155
+ return timeColor;
156
+ }
157
+ }
158
+ return light.isNight ? LightingService.NIGHT_LIGHT : LightingService.DAY_LIGHT;
159
+ }
160
+ static applyToBackground(svg, light, context, camera) {
161
+ const { setting, width, height, lines, theme } = context;
162
+ const hatchDefs = light.isHatch ? KitService.hatchDefs(theme.ink) : "";
163
+ const lightDefs = `${LightingService.defs(light, context, camera)}${hatchDefs}${LightingService.vignetteDef(light)}`;
164
+ const defs = svg.replace("</defs>", `${lightDefs}</defs>`);
165
+ if (light.isHatch) {
166
+ return defs;
167
+ }
168
+ const horizonY = height * lines.horizon;
169
+ return LightingService.settingLightOf(setting).glowLayers(defs, { width, height, horizonY, light });
170
+ }
171
+ static vignetteDef(light) {
172
+ const { shadowColor, strength } = light;
173
+ return `<radialGradient id="vignette" cx="0.5" cy="0.5" r="0.75"><stop offset="0.6" stop-color="${shadowColor}" stop-opacity="0"/><stop offset="1" stop-color="${shadowColor}" stop-opacity="${(0.17 * strength).toFixed(3)}"/></radialGradient>`;
174
+ }
175
+ static defs(light, context, camera) {
176
+ const { setting, height, width, lines } = context;
177
+ const { source, strength, direction, shadowColor, shadowRgb } = light;
178
+ const lightColor = LightingService.lightColorOf(light);
179
+ const [fromX, toX] = direction >= 0 ? [0, 1] : [1, 0];
180
+ const horizonY = height * lines.horizon;
181
+ const settingLight = LightingService.settingLightOf(setting);
182
+ const blur = (height * settingLight.blur).toFixed(1);
183
+ const rgb = shadowRgb.map((channel) => (channel / 255).toFixed(3));
184
+ const fade = (factor) => (factor * strength).toFixed(3);
185
+ const falloffOpacity = direction ? fade(0.13) : 0;
186
+ return `<linearGradient id="lgLight" x1="${direction ? fromX : 0.5}" y1="0" x2="${direction ? toX : 0.5}" y2="${direction ? 0.35 : 1}"><stop offset="0" stop-color="${lightColor}" stop-opacity="${fade(0.26)}"/><stop offset="0.42" stop-color="${lightColor}" stop-opacity="0"/></linearGradient><linearGradient id="lgShade" x1="${direction ? fromX : 0.5}" y1="0" x2="${direction ? toX : 0.5}" y2="${direction ? 0.35 : 1}"><stop offset="0.6" stop-color="${shadowColor}" stop-opacity="0"/><stop offset="1" stop-color="${shadowColor}" stop-opacity="${fade(0.5)}"/></linearGradient><linearGradient id="lgAO" x1="0" y1="0" x2="0" y2="1"><stop offset="0.72" stop-color="${shadowColor}" stop-opacity="0"/><stop offset="1" stop-color="${shadowColor}" stop-opacity="${fade(0.32)}"/></linearGradient><filter id="toWhite" color-interpolation-filters="sRGB"><feColorMatrix values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/></filter><filter id="castF" x="-30%" y="-30%" width="160%" height="160%" color-interpolation-filters="sRGB"><feColorMatrix values="0 0 0 0 ${rgb[0]} 0 0 0 0 ${rgb[1]} 0 0 0 0 ${rgb[2]} 0 0 0 1 0"/><feGaussianBlur stdDeviation="${blur}"/></filter><clipPath id="groundClip"><rect y="${(horizonY * camera.zoom + camera.translateY).toFixed(1)}" width="${width}" height="${height}"/></clipPath><radialGradient id="glow" cx="${source}" cy="${settingLight.glowY}" r="0.75"><stop offset="0" stop-color="${lightColor}" stop-opacity="${fade(0.55)}"/><stop offset="1" stop-color="${lightColor}" stop-opacity="0"/></radialGradient><linearGradient id="falloff" x1="${fromX}" y1="0" x2="${toX}" y2="0"><stop offset="0.35" stop-color="${shadowColor}" stop-opacity="0"/><stop offset="1" stop-color="${shadowColor}" stop-opacity="${falloffOpacity}"/></linearGradient>` + LightingService.sunGlowDef(light, lightColor, fade) + LightingService.shaftGradDef(light, lightColor, fade, { width, height });
187
+ }
188
+ static sunGlowDef(light, lightColor, fade) {
189
+ if (!light.celestialGlow) {
190
+ return "";
191
+ }
192
+ return `<radialGradient id="sunGlow" cx="${light.celestialGlow.cx.toFixed(3)}" cy="${light.celestialGlow.cy.toFixed(3)}" r="0.32"><stop offset="0" stop-color="${lightColor}" stop-opacity="${fade(0.38)}"/><stop offset="0.45" stop-color="${lightColor}" stop-opacity="${fade(0.14)}"/><stop offset="1" stop-color="${lightColor}" stop-opacity="0"/></radialGradient>`;
193
+ }
194
+ static shaftGradDef(light, lightColor, fade, bounds) {
195
+ if (!light.shaft) {
196
+ return "";
197
+ }
198
+ const { width, height } = bounds;
199
+ const shaftX = (light.shaft.windowX / width).toFixed(3);
200
+ const shaftY = (light.shaft.windowY / height).toFixed(3);
201
+ const targetX = ((light.shaft.floorLeft + light.shaft.floorRight) / 2 / width).toFixed(3);
202
+ return `<linearGradient id="shaftGrad" x1="${shaftX}" y1="${shaftY}" x2="${targetX}" y2="1"><stop offset="0" stop-color="${lightColor}" stop-opacity="${fade(0.22)}"/><stop offset="0.75" stop-color="${lightColor}" stop-opacity="${fade(0.06)}"/><stop offset="1" stop-color="${lightColor}" stop-opacity="0"/></linearGradient>`;
203
+ }
204
+ static indoorShaftSvg(shaft, light, bounds) {
205
+ const { height, horizonY } = bounds;
206
+ const halfWidth = shaft.windowWidth * LightingService.SHAFT_WIDTH_RATIO;
207
+ const winLeft = shaft.windowX - halfWidth;
208
+ const winRight = shaft.windowX + halfWidth;
209
+ const winBottom = shaft.windowY;
210
+ const shaftPoints = `${winLeft.toFixed(1)},${winBottom.toFixed(1)} ${winRight.toFixed(1)},${winBottom.toFixed(1)} ${shaft.floorRight.toFixed(1)},${height.toFixed(1)} ${shaft.floorLeft.toFixed(1)},${height.toFixed(1)}`;
211
+ const shaftPolygon = `<polygon points="${shaftPoints}" fill="url(#shaftGrad)" style="mix-blend-mode: screen;"/>`;
212
+ const lightColor = LightingService.lightColorOf(light);
213
+ const paneOpacity = (LightingService.FLOOR_PANE_OPACITY * light.strength).toFixed(3);
214
+ const floorHeight = height - horizonY;
215
+ let panesSvg = "";
216
+ LightingService.PANE_BOXES.forEach(([u0, v0, u1, v1]) => {
217
+ const mapPoint = (coordU, coordV) => {
218
+ const spanRatio = LightingService.FLOOR_PATCH_START + coordV * LightingService.FLOOR_PATCH_SPAN;
219
+ const paneY = horizonY + spanRatio * floorHeight;
220
+ const progress = (paneY - horizonY) / floorHeight;
221
+ const leftAtY = winLeft + (shaft.floorLeft - winLeft) * progress;
222
+ const rightAtY = winRight + (shaft.floorRight - winRight) * progress;
223
+ const paneX = leftAtY + coordU * (rightAtY - leftAtY);
224
+ return `${paneX.toFixed(1)},${paneY.toFixed(1)}`;
225
+ };
226
+ const p1 = mapPoint(u0, v0);
227
+ const p2 = mapPoint(u1, v0);
228
+ const p3 = mapPoint(u1, v1);
229
+ const p4 = mapPoint(u0, v1);
230
+ panesSvg += `<polygon points="${p1} ${p2} ${p3} ${p4}" fill="${lightColor}" opacity="${paneOpacity}" style="mix-blend-mode: screen;"/>`;
231
+ });
232
+ return shaftPolygon + panesSvg;
233
+ }
234
+ }
235
+ export {
236
+ LightingService
237
+ };
@@ -0,0 +1,24 @@
1
+ import type { MapCountry, MapFrame, Projector, RouteStop } from "../Protocols/MapProtocol.js";
2
+ import type { MapOptions } from "../Protocols/SceneProtocol.js";
3
+ interface Palette {
4
+ sea: string;
5
+ land: string;
6
+ }
7
+ export declare class MapBaseService {
8
+ private static readonly DEFAULT_PALETTE;
9
+ private static readonly BORDER;
10
+ private static readonly OFF_FRAME_MARGIN;
11
+ private static readonly VISIBLE_MARGIN;
12
+ private static readonly WAVE_ROW_STEP;
13
+ private static readonly WAVE_COLUMN_STEP;
14
+ private static readonly WAVE_FIRST_ROW;
15
+ static paletteOf(frame: MapFrame): Palette;
16
+ static visitedCountries(stops: readonly RouteStop[], options: MapOptions): MapCountry[];
17
+ static countryColors(visited: readonly MapCountry[], options: MapOptions): Map<MapCountry, string>;
18
+ static draw(frame: MapFrame, project: Projector, countryToColor: ReadonlyMap<MapCountry, string>): string;
19
+ private static waves;
20
+ private static graticule;
21
+ private static graticuleLine;
22
+ private static pathOf;
23
+ }
24
+ export {};