@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.
- package/README.md +34 -31
- package/dist/Adapters/FileReaderAdapter.d.ts +4 -0
- package/dist/Adapters/FileReaderAdapter.js +21 -0
- package/dist/Adapters/FontAdapter.d.ts +5 -0
- package/dist/Adapters/FontAdapter.js +13 -0
- package/dist/Adapters/ResvgAdapter.d.ts +11 -0
- package/dist/Adapters/ResvgAdapter.js +18 -0
- package/dist/Commands/BaseCommand.d.ts +11 -0
- package/dist/Commands/BaseCommand.js +13 -0
- package/dist/Commands/BestCommand.d.ts +11 -0
- package/dist/Commands/BestCommand.js +73 -0
- package/dist/Commands/CatalogCommand.d.ts +6 -0
- package/dist/Commands/CatalogCommand.js +24 -0
- package/dist/Commands/CheckCommand.d.ts +5 -0
- package/dist/Commands/CheckCommand.js +8 -0
- package/dist/Commands/RenderCommand.d.ts +7 -0
- package/dist/Commands/RenderCommand.js +15 -0
- package/dist/Commands/SceneCommand.d.ts +11 -0
- package/dist/Commands/SceneCommand.js +70 -0
- package/dist/Commands/SchemaCommand.d.ts +5 -0
- package/dist/Commands/SchemaCommand.js +12 -0
- package/dist/Data/cities.json +312 -0
- package/dist/Data/europe.json +1 -0
- package/dist/Errors/SceneError.d.ts +4 -0
- package/dist/Errors/SceneError.js +11 -0
- package/dist/Errors/UnsafeSvgError.d.ts +3 -0
- package/dist/Errors/UnsafeSvgError.js +9 -0
- package/dist/Modules/BestModule.d.ts +41 -0
- package/dist/Modules/BestModule.js +159 -0
- package/dist/Modules/CheckModule.d.ts +8 -0
- package/dist/Modules/CheckModule.js +16 -0
- package/dist/Modules/CompilationModule.d.ts +23 -0
- package/dist/Modules/CompilationModule.js +210 -0
- package/dist/Modules/CritiqueModule.d.ts +9 -0
- package/dist/Modules/CritiqueModule.js +98 -0
- package/dist/Modules/MapModule.d.ts +24 -0
- package/dist/Modules/MapModule.js +99 -0
- package/dist/Modules/ParsingModule.d.ts +17 -0
- package/dist/Modules/ParsingModule.js +88 -0
- package/dist/Modules/PlaneModule.d.ts +19 -0
- package/dist/Modules/PlaneModule.js +98 -0
- package/dist/Protocols/AssetProtocol.d.ts +67 -0
- package/dist/Protocols/AssetProtocol.js +109 -0
- package/dist/Protocols/CommandProtocol.d.ts +8 -0
- package/dist/Protocols/CommandProtocol.js +0 -0
- package/dist/Protocols/CompilationProtocol.d.ts +136 -0
- package/dist/Protocols/CompilationProtocol.js +0 -0
- package/dist/Protocols/CritiqueProtocol.d.ts +58 -0
- package/dist/Protocols/CritiqueProtocol.js +14 -0
- package/dist/Protocols/CustomAssetProtocol.d.ts +24 -0
- package/dist/Protocols/CustomAssetProtocol.js +0 -0
- package/dist/Protocols/GroupProtocol.d.ts +17 -0
- package/dist/Protocols/GroupProtocol.js +12 -0
- package/dist/Protocols/KitProtocol.d.ts +32 -0
- package/dist/Protocols/KitProtocol.js +23 -0
- package/dist/Protocols/MapProtocol.d.ts +77 -0
- package/dist/Protocols/MapProtocol.js +4 -0
- package/dist/Protocols/OptionsProtocol.js +0 -0
- package/dist/Protocols/PersonProtocol.d.ts +68 -0
- package/dist/Protocols/PersonProtocol.js +42 -0
- package/dist/Protocols/PlaneProtocol.d.ts +140 -0
- package/dist/Protocols/PlaneProtocol.js +4 -0
- package/dist/{pipeline/index.d.ts → Protocols/ResultProtocol.d.ts} +0 -2
- package/dist/Protocols/ResultProtocol.js +0 -0
- package/dist/Protocols/SceneProtocol.d.ts +824 -0
- package/dist/Protocols/SceneProtocol.js +357 -0
- package/dist/{protocols/theme.d.ts → Protocols/ThemeProtocol.d.ts} +4 -0
- package/dist/Protocols/ThemeProtocol.js +28 -0
- package/dist/Resources/Assets/BackpackAsset.d.ts +10 -0
- package/dist/Resources/Assets/BackpackAsset.js +31 -0
- package/dist/Resources/Assets/BallAsset.d.ts +10 -0
- package/dist/Resources/Assets/BallAsset.js +15 -0
- package/dist/Resources/Assets/BalloonsAsset.d.ts +10 -0
- package/dist/Resources/Assets/BalloonsAsset.js +26 -0
- package/dist/Resources/Assets/BaseAsset.d.ts +17 -0
- package/dist/Resources/Assets/BaseAsset.js +11 -0
- package/dist/Resources/Assets/BeachTowelAsset.d.ts +10 -0
- package/dist/Resources/Assets/BeachTowelAsset.js +14 -0
- package/dist/Resources/Assets/BedAsset.d.ts +12 -0
- package/dist/Resources/Assets/BedAsset.js +25 -0
- package/dist/Resources/Assets/BenchAsset.d.ts +11 -0
- package/dist/Resources/Assets/BenchAsset.js +24 -0
- package/dist/Resources/Assets/BicycleAsset.d.ts +10 -0
- package/dist/Resources/Assets/BicycleAsset.js +18 -0
- package/dist/Resources/Assets/BigPlantAsset.d.ts +10 -0
- package/dist/Resources/Assets/BigPlantAsset.js +26 -0
- package/dist/Resources/Assets/BirdAsset.d.ts +10 -0
- package/dist/Resources/Assets/BirdAsset.js +14 -0
- package/dist/Resources/Assets/BlackboardAsset.d.ts +11 -0
- package/dist/Resources/Assets/BlackboardAsset.js +20 -0
- package/dist/Resources/Assets/BoardAsset.d.ts +12 -0
- package/dist/Resources/Assets/BoardAsset.js +44 -0
- package/dist/Resources/Assets/BoatAsset.d.ts +10 -0
- package/dist/Resources/Assets/BoatAsset.js +15 -0
- package/dist/Resources/Assets/BooksAsset.d.ts +10 -0
- package/dist/Resources/Assets/BooksAsset.js +35 -0
- package/dist/Resources/Assets/BookshelfAsset.d.ts +10 -0
- package/dist/Resources/Assets/BookshelfAsset.js +33 -0
- package/dist/Resources/Assets/BuildingAsset.d.ts +14 -0
- package/dist/Resources/Assets/BuildingAsset.js +34 -0
- package/dist/Resources/Assets/BurgerAsset.d.ts +9 -0
- package/dist/Resources/Assets/BurgerAsset.js +23 -0
- package/dist/Resources/Assets/BushAsset.d.ts +10 -0
- package/dist/Resources/Assets/BushAsset.js +17 -0
- package/dist/Resources/Assets/CabinetAsset.d.ts +14 -0
- package/dist/Resources/Assets/CabinetAsset.js +49 -0
- package/dist/Resources/Assets/CablesAsset.d.ts +10 -0
- package/dist/Resources/Assets/CablesAsset.js +16 -0
- package/dist/Resources/Assets/CakeAsset.d.ts +10 -0
- package/dist/Resources/Assets/CakeAsset.js +29 -0
- package/dist/Resources/Assets/CapAsset.d.ts +10 -0
- package/dist/Resources/Assets/CapAsset.js +18 -0
- package/dist/Resources/Assets/CarAsset.d.ts +10 -0
- package/dist/Resources/Assets/CarAsset.js +29 -0
- package/dist/Resources/Assets/CatAsset.d.ts +10 -0
- package/dist/Resources/Assets/CatAsset.js +17 -0
- package/dist/Resources/Assets/ChairAsset.d.ts +16 -0
- package/dist/Resources/Assets/ChairAsset.js +55 -0
- package/dist/Resources/Assets/ChatBubbleAsset.d.ts +11 -0
- package/dist/Resources/Assets/ChatBubbleAsset.js +18 -0
- package/dist/Resources/Assets/ClockAsset.d.ts +11 -0
- package/dist/Resources/Assets/ClockAsset.js +22 -0
- package/dist/Resources/Assets/CloudAsset.d.ts +10 -0
- package/dist/Resources/Assets/CloudAsset.js +17 -0
- package/dist/Resources/Assets/CoffeeMachineAsset.d.ts +10 -0
- package/dist/Resources/Assets/CoffeeMachineAsset.js +23 -0
- package/dist/Resources/Assets/ConfettiAsset.d.ts +10 -0
- package/dist/Resources/Assets/ConfettiAsset.js +18 -0
- package/dist/Resources/Assets/CounterAsset.d.ts +11 -0
- package/dist/Resources/Assets/CounterAsset.js +29 -0
- package/dist/Resources/Assets/CupAsset.d.ts +10 -0
- package/dist/Resources/Assets/CupAsset.js +17 -0
- package/dist/Resources/Assets/CursorAsset.d.ts +11 -0
- package/dist/Resources/Assets/CursorAsset.js +17 -0
- package/dist/Resources/Assets/CustomAsset.d.ts +25 -0
- package/dist/Resources/Assets/CustomAsset.js +58 -0
- package/dist/Resources/Assets/DeskAsset.d.ts +11 -0
- package/dist/Resources/Assets/DeskAsset.js +40 -0
- package/dist/Resources/Assets/DeskSlabAsset.d.ts +18 -0
- package/dist/Resources/Assets/DeskSlabAsset.js +43 -0
- package/dist/Resources/Assets/DiplomaAsset.d.ts +10 -0
- package/dist/Resources/Assets/DiplomaAsset.js +23 -0
- package/dist/Resources/Assets/DogAsset.d.ts +10 -0
- package/dist/Resources/Assets/DogAsset.js +24 -0
- package/dist/Resources/Assets/DrawerUnitAsset.d.ts +14 -0
- package/dist/Resources/Assets/DrawerUnitAsset.js +35 -0
- package/dist/Resources/Assets/FenceAsset.d.ts +10 -0
- package/dist/Resources/Assets/FenceAsset.js +26 -0
- package/dist/Resources/Assets/FigurineAsset.d.ts +10 -0
- package/dist/Resources/Assets/FigurineAsset.js +24 -0
- package/dist/Resources/Assets/FinishFlagAsset.d.ts +10 -0
- package/dist/Resources/Assets/FinishFlagAsset.js +21 -0
- package/dist/Resources/Assets/FirstAidKitAsset.d.ts +10 -0
- package/dist/Resources/Assets/FirstAidKitAsset.js +19 -0
- package/dist/Resources/Assets/FloorLampAsset.d.ts +10 -0
- package/dist/Resources/Assets/FloorLampAsset.js +22 -0
- package/dist/Resources/Assets/FlowersAsset.d.ts +10 -0
- package/dist/Resources/Assets/FlowersAsset.js +37 -0
- package/dist/Resources/Assets/FrameAsset.d.ts +11 -0
- package/dist/Resources/Assets/FrameAsset.js +24 -0
- package/dist/Resources/Assets/FruitBowlAsset.d.ts +10 -0
- package/dist/Resources/Assets/FruitBowlAsset.js +16 -0
- package/dist/Resources/Assets/GlassShelfAsset.d.ts +17 -0
- package/dist/Resources/Assets/GlassShelfAsset.js +25 -0
- package/dist/Resources/Assets/GlobeAsset.d.ts +10 -0
- package/dist/Resources/Assets/GlobeAsset.js +18 -0
- package/dist/Resources/Assets/HeadphonesAsset.d.ts +10 -0
- package/dist/Resources/Assets/HeadphonesAsset.js +23 -0
- package/dist/Resources/Assets/HouseAsset.d.ts +10 -0
- package/dist/Resources/Assets/HouseAsset.js +58 -0
- package/dist/Resources/Assets/LabAsset.d.ts +10 -0
- package/dist/Resources/Assets/LabAsset.js +52 -0
- package/dist/Resources/Assets/LampAsset.d.ts +10 -0
- package/dist/Resources/Assets/LampAsset.js +16 -0
- package/dist/Resources/Assets/LaptopAsset.d.ts +10 -0
- package/dist/Resources/Assets/LaptopAsset.js +27 -0
- package/dist/Resources/Assets/LaptopOpenAsset.d.ts +10 -0
- package/dist/Resources/Assets/LaptopOpenAsset.js +29 -0
- package/dist/Resources/Assets/LightSwitchAsset.d.ts +11 -0
- package/dist/Resources/Assets/LightSwitchAsset.js +24 -0
- package/dist/Resources/Assets/MonitorAsset.d.ts +10 -0
- package/dist/Resources/Assets/MonitorAsset.js +40 -0
- package/dist/Resources/Assets/MoonAsset.d.ts +10 -0
- package/dist/Resources/Assets/MoonAsset.js +16 -0
- package/dist/Resources/Assets/MountainAsset.d.ts +10 -0
- package/dist/Resources/Assets/MountainAsset.js +15 -0
- package/dist/Resources/Assets/OfficeChairAsset.d.ts +10 -0
- package/dist/Resources/Assets/OfficeChairAsset.js +45 -0
- package/dist/Resources/Assets/PalmAsset.d.ts +10 -0
- package/dist/Resources/Assets/PalmAsset.js +32 -0
- package/dist/Resources/Assets/PaperCupAsset.d.ts +10 -0
- package/dist/Resources/Assets/PaperCupAsset.js +17 -0
- package/dist/Resources/Assets/PendantLampAsset.d.ts +10 -0
- package/dist/Resources/Assets/PendantLampAsset.js +16 -0
- package/dist/Resources/Assets/PennantAsset.d.ts +10 -0
- package/dist/Resources/Assets/PennantAsset.js +15 -0
- package/dist/Resources/Assets/PersonAsset.d.ts +10 -0
- package/dist/Resources/Assets/PersonAsset.js +15 -0
- package/dist/Resources/Assets/PhotoFrameAsset.d.ts +15 -0
- package/dist/Resources/Assets/PhotoFrameAsset.js +68 -0
- package/dist/Resources/Assets/PineAsset.d.ts +10 -0
- package/dist/Resources/Assets/PineAsset.js +21 -0
- package/dist/Resources/Assets/PizzaAsset.d.ts +10 -0
- package/dist/Resources/Assets/PizzaAsset.js +17 -0
- package/dist/Resources/Assets/PlantAsset.d.ts +10 -0
- package/dist/Resources/Assets/PlantAsset.js +17 -0
- package/dist/Resources/Assets/PlasticBagAsset.d.ts +10 -0
- package/dist/Resources/Assets/PlasticBagAsset.js +15 -0
- package/dist/Resources/Assets/PlateAsset.d.ts +10 -0
- package/dist/Resources/Assets/PlateAsset.js +17 -0
- package/dist/Resources/Assets/PodiumAsset.d.ts +11 -0
- package/dist/Resources/Assets/PodiumAsset.js +20 -0
- package/dist/Resources/Assets/RefrigeratorAsset.d.ts +11 -0
- package/dist/Resources/Assets/RefrigeratorAsset.js +21 -0
- package/dist/Resources/Assets/RollingCartAsset.d.ts +11 -0
- package/dist/Resources/Assets/RollingCartAsset.js +34 -0
- package/dist/Resources/Assets/RugAsset.d.ts +10 -0
- package/dist/Resources/Assets/RugAsset.js +19 -0
- package/dist/Resources/Assets/SandcastleAsset.d.ts +10 -0
- package/dist/Resources/Assets/SandcastleAsset.js +30 -0
- package/dist/Resources/Assets/SchoolAsset.d.ts +10 -0
- package/dist/Resources/Assets/SchoolAsset.js +32 -0
- package/dist/Resources/Assets/ShelfWallAsset.d.ts +11 -0
- package/dist/Resources/Assets/ShelfWallAsset.js +23 -0
- package/dist/Resources/Assets/SinkAsset.d.ts +11 -0
- package/dist/Resources/Assets/SinkAsset.js +21 -0
- package/dist/Resources/Assets/SofaAsset.d.ts +16 -0
- package/dist/Resources/Assets/SofaAsset.js +66 -0
- package/dist/Resources/Assets/StageAsset.d.ts +10 -0
- package/dist/Resources/Assets/StageAsset.js +44 -0
- package/dist/Resources/Assets/StarAsset.d.ts +10 -0
- package/dist/Resources/Assets/StarAsset.js +14 -0
- package/dist/Resources/Assets/StarsAsset.d.ts +17 -0
- package/dist/Resources/Assets/StarsAsset.js +55 -0
- package/dist/Resources/Assets/StethoscopeAsset.d.ts +10 -0
- package/dist/Resources/Assets/StethoscopeAsset.js +18 -0
- package/dist/Resources/Assets/StoveAsset.d.ts +11 -0
- package/dist/Resources/Assets/StoveAsset.js +20 -0
- package/dist/Resources/Assets/StreetlightAsset.d.ts +10 -0
- package/dist/Resources/Assets/StreetlightAsset.js +20 -0
- package/dist/Resources/Assets/SuitcaseAsset.d.ts +10 -0
- package/dist/Resources/Assets/SuitcaseAsset.js +42 -0
- package/dist/Resources/Assets/SunAsset.d.ts +10 -0
- package/dist/Resources/Assets/SunAsset.js +22 -0
- package/dist/Resources/Assets/TableAsset.d.ts +15 -0
- package/dist/Resources/Assets/TableAsset.js +21 -0
- package/dist/Resources/Assets/ToggleAsset.d.ts +11 -0
- package/dist/Resources/Assets/ToggleAsset.js +21 -0
- package/dist/Resources/Assets/TrashCanAsset.d.ts +10 -0
- package/dist/Resources/Assets/TrashCanAsset.js +31 -0
- package/dist/Resources/Assets/TreeAsset.d.ts +15 -0
- package/dist/Resources/Assets/TreeAsset.js +48 -0
- package/dist/Resources/Assets/TrophyAsset.d.ts +10 -0
- package/dist/Resources/Assets/TrophyAsset.js +16 -0
- package/dist/Resources/Assets/TumblerAsset.d.ts +10 -0
- package/dist/Resources/Assets/TumblerAsset.js +17 -0
- package/dist/Resources/Assets/TvAsset.d.ts +10 -0
- package/dist/Resources/Assets/TvAsset.js +29 -0
- package/dist/Resources/Assets/TvStandAsset.d.ts +11 -0
- package/dist/Resources/Assets/TvStandAsset.js +34 -0
- package/dist/Resources/Assets/UmbrellaAsset.d.ts +10 -0
- package/dist/Resources/Assets/UmbrellaAsset.js +17 -0
- package/dist/Resources/Assets/UniversityAsset.d.ts +10 -0
- package/dist/Resources/Assets/UniversityAsset.js +22 -0
- package/dist/Resources/Assets/VaseFlowersAsset.d.ts +10 -0
- package/dist/Resources/Assets/VaseFlowersAsset.js +16 -0
- package/dist/Resources/Assets/WaterCoolerAsset.d.ts +11 -0
- package/dist/Resources/Assets/WaterCoolerAsset.js +20 -0
- package/dist/Resources/Assets/WhiteboardAsset.d.ts +10 -0
- package/dist/Resources/Assets/WhiteboardAsset.js +18 -0
- package/dist/Resources/Assets/WindowAsset.d.ts +11 -0
- package/dist/Resources/Assets/WindowAsset.js +32 -0
- package/dist/Resources/Groups/BaseGroup.d.ts +7 -0
- package/dist/Resources/Groups/BaseGroup.js +5 -0
- package/dist/Resources/Groups/CelebrationGroup.d.ts +8 -0
- package/dist/Resources/Groups/CelebrationGroup.js +19 -0
- package/dist/Resources/Groups/ConversationGroup.d.ts +9 -0
- package/dist/Resources/Groups/ConversationGroup.js +17 -0
- package/dist/Resources/Groups/DiningGroup.d.ts +8 -0
- package/dist/Resources/Groups/DiningGroup.js +21 -0
- package/dist/Resources/Groups/MeetingGroup.d.ts +8 -0
- package/dist/Resources/Groups/MeetingGroup.js +22 -0
- package/dist/Resources/Groups/ParkBenchGroup.d.ts +8 -0
- package/dist/Resources/Groups/ParkBenchGroup.js +17 -0
- package/dist/Resources/Groups/ReadingCornerGroup.d.ts +8 -0
- package/dist/Resources/Groups/ReadingCornerGroup.js +17 -0
- package/dist/Resources/Groups/WorkspaceGroup.d.ts +10 -0
- package/dist/Resources/Groups/WorkspaceGroup.js +25 -0
- package/dist/Resources/Kits/BaseKit.d.ts +13 -0
- package/dist/Resources/Kits/BaseKit.js +12 -0
- package/dist/Resources/Kits/ClayKit.d.ts +9 -0
- package/dist/Resources/Kits/ClayKit.js +11 -0
- package/dist/Resources/Kits/DuotoneKit.d.ts +16 -0
- package/dist/Resources/Kits/DuotoneKit.js +18 -0
- package/dist/Resources/Kits/FlatKit.d.ts +5 -0
- package/dist/Resources/Kits/FlatKit.js +8 -0
- package/dist/Resources/Kits/HatchKit.d.ts +15 -0
- package/dist/Resources/Kits/HatchKit.js +12 -0
- package/dist/Resources/Kits/IsometricKit.d.ts +8 -0
- package/dist/Resources/Kits/IsometricKit.js +10 -0
- package/dist/Resources/Kits/OutlineKit.d.ts +15 -0
- package/dist/Resources/Kits/OutlineKit.js +10 -0
- package/dist/Resources/Kits/PaperKit.d.ts +13 -0
- package/dist/Resources/Kits/PaperKit.js +12 -0
- package/dist/Resources/Kits/PosterKit.d.ts +14 -0
- package/dist/Resources/Kits/PosterKit.js +16 -0
- package/dist/Resources/Kits/RisoKit.d.ts +16 -0
- package/dist/Resources/Kits/RisoKit.js +11 -0
- package/dist/Resources/Kits/SketchKit.d.ts +10 -0
- package/dist/Resources/Kits/SketchKit.js +12 -0
- package/dist/Resources/Themes/BaseTheme.d.ts +5 -0
- package/dist/Resources/Themes/BaseTheme.js +5 -0
- package/dist/Resources/Themes/BeachTheme.d.ts +6 -0
- package/dist/Resources/Themes/BeachTheme.js +31 -0
- package/dist/Resources/Themes/FlatAutumnTheme.d.ts +6 -0
- package/dist/Resources/Themes/FlatAutumnTheme.js +29 -0
- package/dist/Resources/Themes/FlatCoolTheme.d.ts +6 -0
- package/dist/Resources/Themes/FlatCoolTheme.js +29 -0
- package/dist/Resources/Themes/NightTheme.d.ts +6 -0
- package/dist/Resources/Themes/NightTheme.js +29 -0
- package/dist/Resources/Themes/WarmCafeTheme.d.ts +6 -0
- package/dist/Resources/Themes/WarmCafeTheme.js +29 -0
- package/dist/Services/AssetService.d.ts +12 -0
- package/dist/Services/AssetService.js +232 -0
- package/dist/Services/BackgroundService.d.ts +41 -0
- package/dist/Services/BackgroundService.js +177 -0
- package/dist/Services/BalanceCritiqueService.d.ts +13 -0
- package/dist/Services/BalanceCritiqueService.js +64 -0
- package/dist/Services/CameraService.d.ts +21 -0
- package/dist/Services/CameraService.js +121 -0
- package/dist/Services/CatalogService.d.ts +30 -0
- package/dist/Services/CatalogService.js +56 -0
- package/dist/Services/ColorCritiqueService.d.ts +42 -0
- package/dist/Services/ColorCritiqueService.js +232 -0
- package/dist/Services/ContextService.d.ts +21 -0
- package/dist/Services/ContextService.js +98 -0
- package/dist/Services/CoverageCritiqueService.d.ts +16 -0
- package/dist/Services/CoverageCritiqueService.js +84 -0
- package/dist/Services/CustomAssetService.d.ts +31 -0
- package/dist/Services/CustomAssetService.js +184 -0
- package/dist/Services/DependencyOrderService.d.ts +12 -0
- package/dist/Services/DependencyOrderService.js +73 -0
- package/dist/Services/DescriptionService.d.ts +10 -0
- package/dist/Services/DescriptionService.js +33 -0
- package/dist/Services/DetailService.d.ts +7 -0
- package/dist/Services/DetailService.js +18 -0
- package/dist/Services/FocusCritiqueService.d.ts +23 -0
- package/dist/Services/FocusCritiqueService.js +166 -0
- package/dist/Services/FramingCheckService.d.ts +15 -0
- package/dist/Services/FramingCheckService.js +93 -0
- package/dist/Services/FramingService.d.ts +31 -0
- package/dist/Services/FramingService.js +108 -0
- package/dist/Services/GazeService.d.ts +6 -0
- package/dist/Services/GazeService.js +45 -0
- package/dist/Services/GroundDetailService.d.ts +50 -0
- package/dist/Services/GroundDetailService.js +115 -0
- package/dist/Services/GroupService.d.ts +17 -0
- package/dist/Services/GroupService.js +152 -0
- package/dist/Services/KitService.d.ts +32 -0
- package/dist/Services/KitService.js +131 -0
- package/dist/Services/LightingService.d.ts +39 -0
- package/dist/Services/LightingService.js +237 -0
- package/dist/Services/MapBaseService.d.ts +24 -0
- package/dist/Services/MapBaseService.js +104 -0
- package/dist/Services/MapLabelService.d.ts +26 -0
- package/dist/Services/MapLabelService.js +185 -0
- package/dist/Services/MapLegService.d.ts +23 -0
- package/dist/Services/MapLegService.js +87 -0
- package/dist/Services/MapPanelService.d.ts +16 -0
- package/dist/Services/MapPanelService.js +89 -0
- package/dist/Services/MapPinService.d.ts +11 -0
- package/dist/Services/MapPinService.js +56 -0
- package/dist/Services/MapProjectionService.d.ts +14 -0
- package/dist/Services/MapProjectionService.js +70 -0
- package/dist/Services/MapRouteService.d.ts +17 -0
- package/dist/Services/MapRouteService.js +79 -0
- package/dist/Services/PaletteService.d.ts +108 -0
- package/dist/Services/PaletteService.js +282 -0
- package/dist/Services/PieceService.d.ts +47 -0
- package/dist/Services/PieceService.js +175 -0
- package/dist/Services/PlacementService.d.ts +60 -0
- package/dist/Services/PlacementService.js +421 -0
- package/dist/Services/PlaneBackgroundService.d.ts +28 -0
- package/dist/Services/PlaneBackgroundService.js +209 -0
- package/dist/Services/PlaneBoxService.d.ts +27 -0
- package/dist/Services/PlaneBoxService.js +209 -0
- package/dist/Services/PlaneDepthService.d.ts +18 -0
- package/dist/Services/PlaneDepthService.js +146 -0
- package/dist/Services/PlaneLabelService.d.ts +13 -0
- package/dist/Services/PlaneLabelService.js +115 -0
- package/dist/Services/PlaneObjectService.d.ts +17 -0
- package/dist/Services/PlaneObjectService.js +147 -0
- package/dist/Services/PlanePathService.d.ts +15 -0
- package/dist/Services/PlanePathService.js +98 -0
- package/dist/Services/PlaneProjectionService.d.ts +20 -0
- package/dist/Services/PlaneProjectionService.js +119 -0
- package/dist/Services/PlaneRoadService.d.ts +13 -0
- package/dist/Services/PlaneRoadService.js +105 -0
- package/dist/Services/PlaneScatterService.d.ts +11 -0
- package/dist/Services/PlaneScatterService.js +48 -0
- package/dist/Services/PlaneSpaceService.d.ts +27 -0
- package/dist/Services/PlaneSpaceService.js +96 -0
- package/dist/Services/PlaneSpriteService.d.ts +29 -0
- package/dist/Services/PlaneSpriteService.js +95 -0
- package/dist/Services/PlaneTitleService.d.ts +17 -0
- package/dist/Services/PlaneTitleService.js +126 -0
- package/dist/Services/PlaneZoneService.d.ts +20 -0
- package/dist/Services/PlaneZoneService.js +121 -0
- package/dist/Services/RasterService.d.ts +10 -0
- package/dist/Services/RasterService.js +85 -0
- package/dist/Services/RidgeService.d.ts +31 -0
- package/dist/Services/RidgeService.js +85 -0
- package/dist/Services/ScaleCritiqueService.d.ts +11 -0
- package/dist/Services/ScaleCritiqueService.js +57 -0
- package/dist/Services/SchemaService.d.ts +3 -0
- package/dist/Services/SchemaService.js +10 -0
- package/dist/Services/SilhouetteCritiqueService.d.ts +32 -0
- package/dist/Services/SilhouetteCritiqueService.js +155 -0
- package/dist/Services/SkyDetailService.d.ts +39 -0
- package/dist/Services/SkyDetailService.js +95 -0
- package/dist/Services/TangentCritiqueService.d.ts +23 -0
- package/dist/Services/TangentCritiqueService.js +136 -0
- package/dist/Services/TextService.d.ts +87 -0
- package/dist/Services/TextService.js +434 -0
- package/dist/Services/ThemeService.d.ts +5 -0
- package/dist/Services/ThemeService.js +18 -0
- package/dist/Services/ThumbnailCritiqueService.d.ts +30 -0
- package/dist/Services/ThumbnailCritiqueService.js +130 -0
- package/dist/Utils/BoxUtil.d.ts +4 -0
- package/dist/Utils/BoxUtil.js +8 -0
- package/dist/Utils/ColorUtil.d.ts +34 -0
- package/dist/Utils/ColorUtil.js +114 -0
- package/dist/Utils/CurveUtil.d.ts +6 -0
- package/dist/Utils/CurveUtil.js +35 -0
- package/dist/Utils/DetailUtil.d.ts +7 -0
- package/dist/Utils/DetailUtil.js +15 -0
- package/dist/Utils/FallbackUtil.d.ts +3 -0
- package/dist/Utils/FallbackUtil.js +8 -0
- package/dist/Utils/FontMetricsUtil.d.ts +7 -0
- package/dist/Utils/FontMetricsUtil.js +694 -0
- package/dist/Utils/FormatUtil.d.ts +4 -0
- package/dist/Utils/FormatUtil.js +9 -0
- package/dist/Utils/IdUtil.d.ts +4 -0
- package/dist/Utils/IdUtil.js +11 -0
- package/dist/Utils/NormalizeUtil.d.ts +4 -0
- package/dist/Utils/NormalizeUtil.js +9 -0
- package/dist/Utils/OklabUtil.d.ts +41 -0
- package/dist/Utils/OklabUtil.js +151 -0
- package/dist/Utils/PersonArmUtil.d.ts +31 -0
- package/dist/Utils/PersonArmUtil.js +132 -0
- package/dist/Utils/PersonHeadUtil.d.ts +31 -0
- package/dist/Utils/PersonHeadUtil.js +156 -0
- package/dist/Utils/PersonOutfitUtil.d.ts +64 -0
- package/dist/Utils/PersonOutfitUtil.js +254 -0
- package/dist/Utils/PersonUtil.d.ts +41 -0
- package/dist/Utils/PersonUtil.js +216 -0
- package/dist/Utils/PixelUtil.d.ts +3 -0
- package/dist/Utils/PixelUtil.js +8 -0
- package/dist/Utils/RecolorUtil.d.ts +40 -0
- package/dist/Utils/RecolorUtil.js +155 -0
- package/dist/Utils/RegistryUtil.d.ts +8 -0
- package/dist/Utils/RegistryUtil.js +19 -0
- package/dist/Utils/RequireUtil.d.ts +3 -0
- package/dist/Utils/RequireUtil.js +11 -0
- package/dist/Utils/SanitizeUtil.d.ts +25 -0
- package/dist/Utils/SanitizeUtil.js +211 -0
- package/dist/Utils/SeedUtil.d.ts +6 -0
- package/dist/Utils/SeedUtil.js +15 -0
- package/dist/Utils/ShapeUtil.d.ts +40 -0
- package/dist/Utils/ShapeUtil.js +73 -0
- package/dist/Utils/SuggestUtil.d.ts +7 -0
- package/dist/Utils/SuggestUtil.js +25 -0
- package/dist/Utils/SvgUtil.d.ts +9 -0
- package/dist/Utils/SvgUtil.js +21 -0
- package/dist/Utils/ThemeUtil.d.ts +4 -0
- package/dist/Utils/ThemeUtil.js +13 -0
- package/dist/Utils/TransportUtil.d.ts +24 -0
- package/dist/Utils/TransportUtil.js +108 -0
- package/dist/Utils/TypesettingUtil.d.ts +17 -0
- package/dist/Utils/TypesettingUtil.js +92 -0
- package/dist/cli.js +52 -96
- package/dist/index.d.ts +10 -6
- package/dist/index.js +14 -2
- package/dist/render.d.ts +10 -5
- package/dist/render.js +26 -3
- package/dist/schema.d.ts +9 -2
- package/dist/schema.js +29 -5
- package/fonts/DMSerifDisplay-Regular.ttf +0 -0
- package/fonts/OFL.txt +2 -0
- package/fonts/PatrickHand-Regular.ttf +0 -0
- package/package.json +3 -2
- package/skills/{scenec → draw-scene}/SKILL.md +17 -20
- package/skills/{scenec/recipes/carrossel.yaml → draw-scene/recipes/carousel.yaml} +1 -1
- package/skills/draw-scene/recipes/conference-keynote.yaml +43 -0
- package/skills/draw-scene/recipes/product-feature.yaml +41 -0
- package/skills/{scenec/recipes/ilustracoes-produto.yaml → draw-scene/recipes/product-illustration.yaml} +2 -1
- package/skills/{scenec → draw-scene}/references/catalog.md +33 -15
- package/skills/{scenec → draw-scene}/references/dsl.md +32 -8
- package/dist/catalog.d.ts +0 -21
- package/dist/catalog.js +0 -35
- package/dist/data/europe.json +0 -1
- package/dist/drawing/assets.d.ts +0 -8
- package/dist/drawing/assets.js +0 -612
- package/dist/drawing/kits.d.ts +0 -7
- package/dist/drawing/kits.js +0 -92
- package/dist/drawing/person.d.ts +0 -18
- package/dist/drawing/person.js +0 -287
- package/dist/drawing/themes.d.ts +0 -4
- package/dist/drawing/themes.js +0 -45
- package/dist/modes/map.d.ts +0 -5
- package/dist/modes/map.js +0 -365
- package/dist/modes/plane.d.ts +0 -5
- package/dist/modes/plane.js +0 -716
- package/dist/pipeline/compile.d.ts +0 -2
- package/dist/pipeline/compile.js +0 -581
- package/dist/pipeline/custom.d.ts +0 -2
- package/dist/pipeline/custom.js +0 -120
- package/dist/pipeline/groups.d.ts +0 -2
- package/dist/pipeline/groups.js +0 -189
- package/dist/pipeline/index.js +0 -7
- package/dist/pipeline/parse.d.ts +0 -10
- package/dist/pipeline/parse.js +0 -80
- package/dist/protocols/options.js +0 -1
- package/dist/protocols/scene.d.ts +0 -299
- package/dist/protocols/scene.js +0 -118
- package/dist/protocols/theme.js +0 -1
- package/dist/render/check.d.ts +0 -6
- package/dist/render/check.js +0 -10
- package/dist/render/critic.d.ts +0 -1
- package/dist/render/critic.js +0 -235
- package/dist/render/files.d.ts +0 -2
- package/dist/render/files.js +0 -16
- package/dist/render/fonts.d.ts +0 -2
- package/dist/render/fonts.js +0 -4
- package/dist/render/png.d.ts +0 -9
- package/dist/render/png.js +0 -13
- package/dist/utils/color.d.ts +0 -5
- package/dist/utils/color.js +0 -35
- package/dist/utils/recolor.d.ts +0 -1
- package/dist/utils/recolor.js +0 -56
- package/dist/utils/sanitize.d.ts +0 -5
- package/dist/utils/sanitize.js +0 -169
- package/dist/utils/suggest.d.ts +0 -1
- package/dist/utils/suggest.js +0 -22
- package/dist/utils/svg.d.ts +0 -2
- package/dist/utils/svg.js +0 -11
- package/skills/scenec/references/fontes.md +0 -8
- /package/dist/{protocols/options.d.ts → Protocols/OptionsProtocol.d.ts} +0 -0
- /package/skills/{scenec/recipes/anuncios-variacoes.yaml → draw-scene/recipes/ad-variations.yaml} +0 -0
- /package/skills/{scenec/recipes/elearning.yaml → draw-scene/recipes/e-learning.yaml} +0 -0
- /package/skills/{scenec/recipes/reels-explicativo.yaml → draw-scene/recipes/explainer-reel.yaml} +0 -0
- /package/skills/{scenec/recipes/historia-ilustrada.yaml → draw-scene/recipes/illustrated-story.yaml} +0 -0
- /package/skills/{scenec/recipes/mapas-jornadas.yaml → draw-scene/recipes/journey-map.yaml} +0 -0
- /package/skills/{scenec/recipes/wrapped-personalizado.yaml → draw-scene/recipes/personalized-wrapped.yaml} +0 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { GroundDetailService } from "./GroundDetailService.js";
|
|
2
|
+
import { PlaneBoxService } from "./PlaneBoxService.js";
|
|
3
|
+
import { RidgeService } from "./RidgeService.js";
|
|
4
|
+
import { SkyDetailService } from "./SkyDetailService.js";
|
|
5
|
+
import { ColorUtil } from "../Utils/ColorUtil.js";
|
|
6
|
+
import { FormatUtil } from "../Utils/FormatUtil.js";
|
|
7
|
+
import { SvgUtil } from "../Utils/SvgUtil.js";
|
|
8
|
+
import { ThemeUtil } from "../Utils/ThemeUtil.js";
|
|
9
|
+
class PlaneBackgroundService {
|
|
10
|
+
static DEFAULT_HORIZON_Z = 1.45;
|
|
11
|
+
static HEX_RADIX = 16;
|
|
12
|
+
static DEFAULT_SHADOW = [0, 0, 0, 0.15];
|
|
13
|
+
static NUMBER = /[\d.]+/g;
|
|
14
|
+
static MIN_PLANK_WIDTH = 1e-4;
|
|
15
|
+
static OFF_FRAME_MARGIN = 40;
|
|
16
|
+
static JOINT_SPACING = 0.55;
|
|
17
|
+
static DEFAULT_RIDGES = 2;
|
|
18
|
+
static DEFAULT_SEED = 1;
|
|
19
|
+
static PATH_TUFT_MARGIN = 30;
|
|
20
|
+
static draw(world) {
|
|
21
|
+
const { camera, scene } = world;
|
|
22
|
+
const horizonZ = scene.canvas?.horizon_z ?? PlaneBackgroundService.DEFAULT_HORIZON_Z;
|
|
23
|
+
const svg = camera.isRoom ? PlaneBackgroundService.room(world) : PlaneBackgroundService.outdoors(world, camera.screenY(horizonZ));
|
|
24
|
+
return { defs: PlaneBackgroundService.defs(world), svg: svg + PlaneBackgroundService.zoneTints(world) };
|
|
25
|
+
}
|
|
26
|
+
static defs(world) {
|
|
27
|
+
const { theme, camera, tints } = world;
|
|
28
|
+
const shadowChannels = theme.shadow.match(PlaneBackgroundService.NUMBER) ?? PlaneBackgroundService.DEFAULT_SHADOW;
|
|
29
|
+
const [red = 0, green = 0, blue = 0, alpha = 0.15] = shadowChannels.map(Number);
|
|
30
|
+
const shadow = `rgb(${red},${green},${blue})`;
|
|
31
|
+
let defs = `<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">${SkyDetailService.skyGradientStops(theme)}</linearGradient><filter id="dither"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="1" stitchTiles="stitch" result="nz"/><feColorMatrix in="nz" type="matrix" values="0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.012 0" result="d"/><feBlend in="SourceGraphic" in2="d" mode="soft-light"/></filter><linearGradient id="ground" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${ColorUtil.sh(theme.ground, 0.18)}"/><stop offset="1" stop-color="${theme.ground}"/></linearGradient>`;
|
|
32
|
+
defs += `<radialGradient id="cshadow"><stop offset="0" stop-color="${shadow}" stop-opacity="${alpha * 1.5}"/><stop offset="0.55" stop-color="${shadow}" stop-opacity="${alpha * 1.1}"/><stop offset="1" stop-color="${shadow}" stop-opacity="0"/></radialGradient>`;
|
|
33
|
+
const [airRed = 0, airGreen = 0, airBlue = 0] = [1, 3, 5].map((start) => {
|
|
34
|
+
const channel = theme.skyBottom.slice(start, start + 2);
|
|
35
|
+
return parseInt(channel, PlaneBackgroundService.HEX_RADIX) / 255;
|
|
36
|
+
});
|
|
37
|
+
camera.hazeSteps?.forEach((step, index) => {
|
|
38
|
+
const keep = 1 - step.strength;
|
|
39
|
+
defs += `<filter id="haze${index + 1}" color-interpolation-filters="sRGB"><feColorMatrix type="matrix" values="${keep} 0 0 0 ${(airRed * step.strength).toFixed(3)} 0 ${keep} 0 0 ${(airGreen * step.strength).toFixed(3)} 0 0 ${keep} 0 ${(airBlue * step.strength).toFixed(3)} 0 0 0 1 0"/></filter>`;
|
|
40
|
+
});
|
|
41
|
+
tints.forEach((tint, index) => {
|
|
42
|
+
defs += `<radialGradient id="zone${index}"><stop offset="0" stop-color="${tint.color}" stop-opacity="1"/><stop offset="0.62" stop-color="${tint.color}" stop-opacity="0.9"/><stop offset="1" stop-color="${tint.color}" stop-opacity="0"/></radialGradient>`;
|
|
43
|
+
});
|
|
44
|
+
return defs;
|
|
45
|
+
}
|
|
46
|
+
static outdoors(world, horizonY) {
|
|
47
|
+
const { theme, camera, scene } = world;
|
|
48
|
+
const { width, height } = camera;
|
|
49
|
+
const num = FormatUtil.oneDecimal;
|
|
50
|
+
const hill = ColorUtil.sh(theme.groundDark || theme.ground, 0.25);
|
|
51
|
+
const ridges = RidgeService.draw({
|
|
52
|
+
count: scene.canvas?.ridges ?? PlaneBackgroundService.DEFAULT_RIDGES,
|
|
53
|
+
seed: scene.canvas?.seed ?? PlaneBackgroundService.DEFAULT_SEED,
|
|
54
|
+
width,
|
|
55
|
+
horizonY,
|
|
56
|
+
groundColor: hill,
|
|
57
|
+
airColor: theme.skyBottom,
|
|
58
|
+
bottomY: height
|
|
59
|
+
});
|
|
60
|
+
const groundDetail = GroundDetailService.draw({
|
|
61
|
+
detail: scene.canvas?.ground_detail ?? "low",
|
|
62
|
+
seed: scene.canvas?.seed ?? PlaneBackgroundService.DEFAULT_SEED,
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
horizonY,
|
|
66
|
+
theme,
|
|
67
|
+
isPathBlocked: (posX, posY) => PlaneBackgroundService.isNearPath(world, posX, posY)
|
|
68
|
+
});
|
|
69
|
+
return `<rect width="${width}" height="${height}" fill="url(#sky)" filter="url(#dither)"/>` + ridges + `<path d="M0 ${num(horizonY + 2)} Q${width * 0.25} ${num(horizonY - height * 0.035)} ${width * 0.5} ${num(horizonY)} T${width} ${num(horizonY - height * 0.02)} L${width} ${height} L0 ${height} Z" fill="url(#ground)"/>` + groundDetail;
|
|
70
|
+
}
|
|
71
|
+
static isNearPath(world, posX, posY) {
|
|
72
|
+
const points = world.scene.path?.points;
|
|
73
|
+
if (!points || points.length === 0) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return points.some((point) => {
|
|
77
|
+
const at = point.at;
|
|
78
|
+
if (!at) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const [screenX, screenY] = world.camera.project(at[0], at[1]);
|
|
82
|
+
const distance = Math.hypot(posX - screenX, posY - screenY);
|
|
83
|
+
return distance < PlaneBackgroundService.PATH_TUFT_MARGIN;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
static room(world) {
|
|
87
|
+
const { theme, camera, scene } = world;
|
|
88
|
+
const walls = scene.walls ?? {};
|
|
89
|
+
const floor = scene.floor ?? {};
|
|
90
|
+
const project = camera.project;
|
|
91
|
+
const backZ = walls.back?.z ?? 1;
|
|
92
|
+
const rightX = walls.right === false ? 3 : walls.right?.x ?? 1;
|
|
93
|
+
const leftX = walls.left?.x ?? -3;
|
|
94
|
+
const wallHeight = walls.height ?? 320;
|
|
95
|
+
const nearZ = floor.from_z ?? -0.8;
|
|
96
|
+
const rightWall = walls.right === false ? void 0 : walls.right;
|
|
97
|
+
const backColor = ThemeUtil.resolve(theme, walls.back?.color, theme.wall);
|
|
98
|
+
const rightColor = ThemeUtil.resolve(theme, rightWall?.color, ColorUtil.sh(backColor, -0.07));
|
|
99
|
+
const leftColor = ThemeUtil.resolve(theme, walls.left?.color, ColorUtil.sh(backColor, -0.04));
|
|
100
|
+
const floorColor = ThemeUtil.resolve(theme, floor.color, theme.floor);
|
|
101
|
+
const xSpan = [leftX, rightX];
|
|
102
|
+
const skirting = [0, 4];
|
|
103
|
+
const fullHeight = [0, wallHeight];
|
|
104
|
+
let svg = `<rect width="${camera.width}" height="${camera.height}" fill="${backColor}"/>`;
|
|
105
|
+
svg += PlaneBackgroundService.floorPolygon(project, xSpan, [nearZ, backZ], floorColor);
|
|
106
|
+
if (floor.planks !== false) {
|
|
107
|
+
const plankWidth = floor.plank_width ?? 0.05;
|
|
108
|
+
svg += PlaneBackgroundService.planks(world, { xSpan, nearZ, backZ, floorColor, plankWidth });
|
|
109
|
+
}
|
|
110
|
+
const backWall = { groundZ: backZ, heightSpan: fullHeight, fill: backColor };
|
|
111
|
+
const backSkirting = { groundZ: backZ, heightSpan: skirting, fill: ColorUtil.sh(backColor, -0.08) };
|
|
112
|
+
svg += PlaneBackgroundService.backPolygon(project, xSpan, backWall);
|
|
113
|
+
svg += PlaneBackgroundService.backPolygon(project, xSpan, backSkirting);
|
|
114
|
+
const zSpan = [nearZ, backZ];
|
|
115
|
+
if (rightX < 2) {
|
|
116
|
+
const seamBottom = project(rightX, backZ, 0);
|
|
117
|
+
const seamTop = project(rightX, backZ, wallHeight);
|
|
118
|
+
const seam = SvgUtil.segment(seamBottom, seamTop);
|
|
119
|
+
const rightWall2 = { zSpan, heightSpan: fullHeight, fill: rightColor };
|
|
120
|
+
const rightSkirting = { zSpan, heightSpan: skirting, fill: ColorUtil.sh(rightColor, -0.08) };
|
|
121
|
+
svg += PlaneBackgroundService.sidePolygon(project, rightX, rightWall2);
|
|
122
|
+
svg += PlaneBackgroundService.sidePolygon(project, rightX, rightSkirting);
|
|
123
|
+
svg += `<path d="${seam}" stroke="${ColorUtil.sh(backColor, -0.12)}" stroke-width="1.2"/>`;
|
|
124
|
+
}
|
|
125
|
+
if (leftX > -2) {
|
|
126
|
+
svg += PlaneBackgroundService.sidePolygon(project, leftX, { zSpan, heightSpan: fullHeight, fill: leftColor });
|
|
127
|
+
}
|
|
128
|
+
const margin = 0.012;
|
|
129
|
+
for (const box of world.boxes.filter((candidate) => PlaneBoxService.castsFloorShadow(candidate))) {
|
|
130
|
+
const xRange = [box.x0 - margin, box.x1 + margin];
|
|
131
|
+
svg += PlaneBackgroundService.floorPolygon(project, xRange, [box.z0 - margin, box.z1], theme.shadow);
|
|
132
|
+
}
|
|
133
|
+
return svg;
|
|
134
|
+
}
|
|
135
|
+
static floorPolygon(project, xSpan, zSpan, fill) {
|
|
136
|
+
const [left, right] = xSpan;
|
|
137
|
+
const [near, far] = zSpan;
|
|
138
|
+
const corners = [project(left, near), project(right, near), project(right, far), project(left, far)];
|
|
139
|
+
return SvgUtil.polygon(corners, fill);
|
|
140
|
+
}
|
|
141
|
+
static backPolygon(project, xSpan, shape) {
|
|
142
|
+
const { groundZ, heightSpan, fill } = shape;
|
|
143
|
+
return SvgUtil.polygon([
|
|
144
|
+
project(xSpan[0], groundZ, heightSpan[0]),
|
|
145
|
+
project(xSpan[1], groundZ, heightSpan[0]),
|
|
146
|
+
project(xSpan[1], groundZ, heightSpan[1]),
|
|
147
|
+
project(xSpan[0], groundZ, heightSpan[1])
|
|
148
|
+
], fill);
|
|
149
|
+
}
|
|
150
|
+
static sidePolygon(project, groundX, shape) {
|
|
151
|
+
const { zSpan, heightSpan, fill } = shape;
|
|
152
|
+
return SvgUtil.polygon([
|
|
153
|
+
project(groundX, zSpan[0], heightSpan[0]),
|
|
154
|
+
project(groundX, zSpan[1], heightSpan[0]),
|
|
155
|
+
project(groundX, zSpan[1], heightSpan[1]),
|
|
156
|
+
project(groundX, zSpan[0], heightSpan[1])
|
|
157
|
+
], fill);
|
|
158
|
+
}
|
|
159
|
+
static planks(world, room) {
|
|
160
|
+
const { camera } = world;
|
|
161
|
+
const { xSpan, nearZ, backZ, floorColor, plankWidth } = room;
|
|
162
|
+
const project = camera.project;
|
|
163
|
+
const margin = PlaneBackgroundService.OFF_FRAME_MARGIN;
|
|
164
|
+
let svg = "";
|
|
165
|
+
for (let plankX = xSpan[0], index = 0; plankX < xSpan[1]; plankX += plankWidth, index++) {
|
|
166
|
+
const from = Math.max(plankX, xSpan[0]);
|
|
167
|
+
const to = Math.min(plankX + plankWidth, xSpan[1]);
|
|
168
|
+
if (to - from < PlaneBackgroundService.MIN_PLANK_WIDTH) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const edges = [project(from, nearZ)[0], project(to, nearZ)[0], project(from, backZ)[0]];
|
|
172
|
+
if (Math.max(...edges) < -margin || Math.min(...edges) > camera.width + margin) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const grain = ColorUtil.sh(floorColor, index * 7 % 3 * 0.025 - 0.02);
|
|
176
|
+
const seam = SvgUtil.segment(project(from, nearZ), project(from, backZ));
|
|
177
|
+
svg += PlaneBackgroundService.floorPolygon(project, [from, to], [nearZ, backZ], grain) + `<path d="${seam}" stroke="${ColorUtil.sh(floorColor, -0.3)}" stroke-width="1" opacity="0.55"/>`;
|
|
178
|
+
const spacing = PlaneBackgroundService.JOINT_SPACING;
|
|
179
|
+
const firstJoint = nearZ + index * 0.37 % 0.5;
|
|
180
|
+
for (let jointZ = firstJoint; jointZ < backZ; jointZ += spacing) {
|
|
181
|
+
const start = project(from, jointZ);
|
|
182
|
+
const end = project(to, jointZ);
|
|
183
|
+
const half = Math.max(0.6, 1.2 * camera.shrink(jointZ)) / 2;
|
|
184
|
+
const strip = [
|
|
185
|
+
[start[0], start[1] - half],
|
|
186
|
+
[end[0], end[1] - half],
|
|
187
|
+
[end[0], end[1] + half],
|
|
188
|
+
[start[0], start[1] + half]
|
|
189
|
+
];
|
|
190
|
+
svg += SvgUtil.polygon(strip, ColorUtil.sh(floorColor, -0.3), 'opacity="0.4"');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return svg;
|
|
194
|
+
}
|
|
195
|
+
static zoneTints(world) {
|
|
196
|
+
const { camera, tints } = world;
|
|
197
|
+
const num = FormatUtil.oneDecimal;
|
|
198
|
+
return tints.map((tint, index) => {
|
|
199
|
+
const centerX = camera.screenX(tint.x, tint.z);
|
|
200
|
+
const centerY = camera.screenY(tint.z);
|
|
201
|
+
const radiusX = tint.radius * camera.width * 0.98 * camera.spread(tint.z);
|
|
202
|
+
const radiusY = (camera.screenY(tint.z - tint.radius) - camera.screenY(tint.z + tint.radius)) / 2;
|
|
203
|
+
return `<ellipse cx="${num(centerX)}" cy="${num(centerY)}" rx="${num(radiusX)}" ry="${num(radiusY)}" fill="url(#zone${index})"/>`;
|
|
204
|
+
}).join("");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
export {
|
|
208
|
+
PlaneBackgroundService
|
|
209
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PlaneBox, PlaneWorld } from "../Protocols/PlaneProtocol.js";
|
|
2
|
+
export declare class PlaneBoxService {
|
|
3
|
+
private static readonly DEFAULT_HEIGHT;
|
|
4
|
+
private static readonly OVERLAP_MIN;
|
|
5
|
+
private static readonly OVERLAP_HEIGHT_MIN;
|
|
6
|
+
private static readonly FLOOR_SHADOW_ELEVATION;
|
|
7
|
+
private static readonly DEFAULT_PLINTH;
|
|
8
|
+
private static readonly DEFAULT_DOORS;
|
|
9
|
+
private static readonly FRONT_TO_DEFAULT_COUNT;
|
|
10
|
+
private static readonly FACE_TO_VISIBLE;
|
|
11
|
+
private static readonly FACE_TO_DEPTH;
|
|
12
|
+
static read(world: PlaneWorld): void;
|
|
13
|
+
static castsFloorShadow(box: PlaneBox): boolean;
|
|
14
|
+
static draw(world: PlaneWorld, box: PlaneBox): string;
|
|
15
|
+
private static faces;
|
|
16
|
+
private static body;
|
|
17
|
+
private static countOf;
|
|
18
|
+
private static frontDetails;
|
|
19
|
+
private static warnInterpenetration;
|
|
20
|
+
private static drawDetails;
|
|
21
|
+
private static readonly line;
|
|
22
|
+
private static readonly drawers;
|
|
23
|
+
private static readonly doors;
|
|
24
|
+
private static readonly open;
|
|
25
|
+
private static handleAcross;
|
|
26
|
+
private static readonly FRONT_TO_DETAIL;
|
|
27
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { ColorUtil } from "../Utils/ColorUtil.js";
|
|
2
|
+
import { FormatUtil } from "../Utils/FormatUtil.js";
|
|
3
|
+
import { IdUtil } from "../Utils/IdUtil.js";
|
|
4
|
+
import { SvgUtil } from "../Utils/SvgUtil.js";
|
|
5
|
+
import { ThemeUtil } from "../Utils/ThemeUtil.js";
|
|
6
|
+
class PlaneBoxService {
|
|
7
|
+
static DEFAULT_HEIGHT = 40;
|
|
8
|
+
static OVERLAP_MIN = 2e-3;
|
|
9
|
+
static OVERLAP_HEIGHT_MIN = 0.5;
|
|
10
|
+
static FLOOR_SHADOW_ELEVATION = 8;
|
|
11
|
+
static DEFAULT_PLINTH = 2;
|
|
12
|
+
static DEFAULT_DOORS = 2;
|
|
13
|
+
static FRONT_TO_DEFAULT_COUNT = { drawers: 4, doors: 2, open: 2 };
|
|
14
|
+
static FACE_TO_VISIBLE = {
|
|
15
|
+
front: () => true,
|
|
16
|
+
left: (eyeX, box) => eyeX < box.x0,
|
|
17
|
+
right: (eyeX, box) => eyeX > box.x1
|
|
18
|
+
};
|
|
19
|
+
static FACE_TO_DEPTH = {
|
|
20
|
+
front: (box) => box.z0,
|
|
21
|
+
left: (box) => (box.z0 + box.z1) / 2,
|
|
22
|
+
right: (box) => (box.z0 + box.z1) / 2
|
|
23
|
+
};
|
|
24
|
+
static read(world) {
|
|
25
|
+
const { warnings, theme } = world;
|
|
26
|
+
for (const [id, options] of Object.entries(world.scene.boxes ?? {})) {
|
|
27
|
+
if (options.from === void 0 || options.to === void 0) {
|
|
28
|
+
warnings.push(`box '${id}' needs from: [x, z] and to: [x, z]`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const x0 = Math.min(options.from[0], options.to[0]);
|
|
32
|
+
const x1 = Math.max(options.from[0], options.to[0]);
|
|
33
|
+
const z0 = Math.min(options.from[1], options.to[1]);
|
|
34
|
+
const z1 = Math.max(options.from[1], options.to[1]);
|
|
35
|
+
const height = options.height ?? PlaneBoxService.DEFAULT_HEIGHT;
|
|
36
|
+
const elevation = options.elevation ?? (options.thickness ? height - options.thickness : 0);
|
|
37
|
+
if (elevation >= height) {
|
|
38
|
+
warnings.push(`box '${id}': elevation (${elevation}) must be less than height (${height})`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const color = ThemeUtil.resolve(theme, options.color, theme.wood);
|
|
42
|
+
world.boxes.push({ id, x0, x1, z0, z1, elevation, height, options, color });
|
|
43
|
+
world.pointIdToPosition.set(id, [(x0 + x1) / 2, (z0 + z1) / 2]);
|
|
44
|
+
}
|
|
45
|
+
PlaneBoxService.warnInterpenetration(world.boxes, warnings);
|
|
46
|
+
}
|
|
47
|
+
static castsFloorShadow(box) {
|
|
48
|
+
return box.elevation < PlaneBoxService.FLOOR_SHADOW_ELEVATION && box.options.shadow !== false;
|
|
49
|
+
}
|
|
50
|
+
static draw(world, box) {
|
|
51
|
+
const { options } = box;
|
|
52
|
+
const faceToCorners = PlaneBoxService.faces(world.camera.project, box);
|
|
53
|
+
const details = options.details ?? PlaneBoxService.frontDetails(options);
|
|
54
|
+
const detailFace = details?.face ?? "front";
|
|
55
|
+
let svg = PlaneBoxService.body(world, box, faceToCorners, detailFace);
|
|
56
|
+
if (details && PlaneBoxService.FACE_TO_VISIBLE[detailFace](world.camera.eyeX, box)) {
|
|
57
|
+
const depthZ = PlaneBoxService.FACE_TO_DEPTH[detailFace](box);
|
|
58
|
+
svg += PlaneBoxService.drawDetails(world, box, details, { face: faceToCorners[detailFace], depthZ });
|
|
59
|
+
}
|
|
60
|
+
return `<g id="${box.id}"${options.opacity === void 0 ? "" : ` opacity="${options.opacity}"`}>${svg}</g>`;
|
|
61
|
+
}
|
|
62
|
+
static faces(project, box) {
|
|
63
|
+
const { x0, x1, z0, z1, elevation, height } = box;
|
|
64
|
+
return {
|
|
65
|
+
front: [project(x0, z0, elevation), project(x1, z0, elevation), project(x1, z0, height), project(x0, z0, height)],
|
|
66
|
+
left: [project(x0, z1, elevation), project(x0, z0, elevation), project(x0, z0, height), project(x0, z1, height)],
|
|
67
|
+
right: [project(x1, z0, elevation), project(x1, z1, elevation), project(x1, z1, height), project(x1, z0, height)]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
static body(world, box, faceToCorners, detailFace) {
|
|
71
|
+
const { camera, theme } = world;
|
|
72
|
+
const project = camera.project;
|
|
73
|
+
const { x0, x1, z0, z1, elevation, height, color, options } = box;
|
|
74
|
+
const paint = (face, other) => face === detailFace ? color : other;
|
|
75
|
+
const topColor = ThemeUtil.resolve(theme, options.top_color, ColorUtil.sh(color, 0.1));
|
|
76
|
+
const sideColor = ColorUtil.sh(color, -0.12);
|
|
77
|
+
let svg = "";
|
|
78
|
+
if (elevation > 0 && project(x0, z1, elevation)[1] > project(x0, z0, elevation)[1]) {
|
|
79
|
+
const underside = [
|
|
80
|
+
project(x0, z0, elevation),
|
|
81
|
+
project(x1, z0, elevation),
|
|
82
|
+
project(x1, z1, elevation),
|
|
83
|
+
project(x0, z1, elevation)
|
|
84
|
+
];
|
|
85
|
+
svg += SvgUtil.polygon(underside, ColorUtil.sh(color, -0.32));
|
|
86
|
+
}
|
|
87
|
+
if (camera.eyeX < x0) {
|
|
88
|
+
svg += SvgUtil.polygon(faceToCorners.left, paint("left", sideColor));
|
|
89
|
+
}
|
|
90
|
+
if (camera.eyeX > x1) {
|
|
91
|
+
svg += SvgUtil.polygon(faceToCorners.right, paint("right", sideColor));
|
|
92
|
+
}
|
|
93
|
+
const top = [
|
|
94
|
+
project(x0, z0, height),
|
|
95
|
+
project(x1, z0, height),
|
|
96
|
+
project(x1, z1, height),
|
|
97
|
+
project(x0, z1, height)
|
|
98
|
+
];
|
|
99
|
+
if (top[3][1] < top[0][1] - 0.3) {
|
|
100
|
+
svg += SvgUtil.polygon(top, topColor);
|
|
101
|
+
}
|
|
102
|
+
const frontColor = paint("front", ColorUtil.sh(color, -0.04));
|
|
103
|
+
svg += SvgUtil.polygon(faceToCorners.front, frontColor);
|
|
104
|
+
const edge = SvgUtil.segment(top[0], top[1]);
|
|
105
|
+
return svg + `<path d="${edge}" stroke="${ColorUtil.sh(color, 0.3)}" stroke-width="1"/>`;
|
|
106
|
+
}
|
|
107
|
+
static countOf(details) {
|
|
108
|
+
if (details.count !== void 0 && details.count !== 0) {
|
|
109
|
+
return details.count;
|
|
110
|
+
}
|
|
111
|
+
return IdUtil.lookup(PlaneBoxService.FRONT_TO_DEFAULT_COUNT, details.type) ?? PlaneBoxService.DEFAULT_DOORS;
|
|
112
|
+
}
|
|
113
|
+
static frontDetails(options) {
|
|
114
|
+
return options.front ? { type: options.front, count: options.count, face: "front" } : null;
|
|
115
|
+
}
|
|
116
|
+
static warnInterpenetration(boxes, warnings) {
|
|
117
|
+
boxes.forEach((first, index) => {
|
|
118
|
+
for (const second of boxes.slice(index + 1)) {
|
|
119
|
+
const acrossX = Math.min(first.x1, second.x1) - Math.max(first.x0, second.x0);
|
|
120
|
+
const acrossZ = Math.min(first.z1, second.z1) - Math.max(first.z0, second.z0);
|
|
121
|
+
const acrossHeight = Math.min(first.height, second.height) - Math.max(first.elevation, second.elevation);
|
|
122
|
+
const isOverlapping = acrossX > PlaneBoxService.OVERLAP_MIN && acrossZ > PlaneBoxService.OVERLAP_MIN;
|
|
123
|
+
if (isOverlapping && acrossHeight > PlaneBoxService.OVERLAP_HEIGHT_MIN) {
|
|
124
|
+
warnings.push(`boxes '${first.id}' and '${second.id}' interpenetrate; adjust from/to or elevation`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
static drawDetails(world, box, details, target) {
|
|
130
|
+
const { camera, theme } = world;
|
|
131
|
+
const { color, height, elevation } = box;
|
|
132
|
+
const { face, depthZ } = target;
|
|
133
|
+
const [bottomLeft, bottomRight, topRight, topLeft] = face;
|
|
134
|
+
const corner = (across, up) => {
|
|
135
|
+
const bottomX = bottomLeft[0] + (bottomRight[0] - bottomLeft[0]) * across;
|
|
136
|
+
const bottomY = bottomLeft[1] + (bottomRight[1] - bottomLeft[1]) * across;
|
|
137
|
+
const topX = topLeft[0] + (topRight[0] - topLeft[0]) * across;
|
|
138
|
+
const topY = topLeft[1] + (topRight[1] - topLeft[1]) * across;
|
|
139
|
+
return [bottomX + (topX - bottomX) * up, bottomY + (topY - bottomY) * up];
|
|
140
|
+
};
|
|
141
|
+
const stroke = Math.max(0.7, camera.unit * camera.shrink(depthZ) * 0.16);
|
|
142
|
+
const plinth = (details.plinth ?? PlaneBoxService.DEFAULT_PLINTH) / (height - elevation);
|
|
143
|
+
const context = {
|
|
144
|
+
corner,
|
|
145
|
+
stroke,
|
|
146
|
+
plinth,
|
|
147
|
+
color,
|
|
148
|
+
details,
|
|
149
|
+
count: PlaneBoxService.countOf(details),
|
|
150
|
+
gap: ColorUtil.sh(color, -0.3),
|
|
151
|
+
metal: ThemeUtil.resolve(theme, details.handle, theme.metal)
|
|
152
|
+
};
|
|
153
|
+
const base = plinth > 0 ? SvgUtil.polygon([corner(0, 0), corner(1, 0), corner(1, plinth), corner(0, plinth)], ColorUtil.sh(color, -0.28)) : "";
|
|
154
|
+
return details.type === void 0 ? base : base + PlaneBoxService.FRONT_TO_DETAIL[details.type](context);
|
|
155
|
+
}
|
|
156
|
+
static line = (from, to, color, width) => `<path d="${SvgUtil.segment(from, to)}" stroke="${color}" stroke-width="${FormatUtil.oneDecimal(width)}" stroke-linecap="round"/>`;
|
|
157
|
+
static drawers = (context) => {
|
|
158
|
+
const { corner, stroke, count, plinth, gap, metal } = context;
|
|
159
|
+
const line = PlaneBoxService.line;
|
|
160
|
+
let svg = "";
|
|
161
|
+
for (let index = 0; index < count; index++) {
|
|
162
|
+
const top = 1 - index * (1 - plinth) / count;
|
|
163
|
+
const bottom = top - (1 - plinth) / count;
|
|
164
|
+
const middle = (bottom + top) / 2 + (top - bottom) * 0.08;
|
|
165
|
+
if (index > 0) {
|
|
166
|
+
svg += line(corner(0.02, top), corner(0.98, top), gap, stroke);
|
|
167
|
+
}
|
|
168
|
+
const shade = middle - (top - bottom) * 0.06;
|
|
169
|
+
svg += line(corner(0.28, middle), corner(0.72, middle), metal, stroke * 1.8) + line(corner(0.28, shade), corner(0.72, shade), ColorUtil.sh(metal, -0.35), stroke * 0.6);
|
|
170
|
+
}
|
|
171
|
+
return svg;
|
|
172
|
+
};
|
|
173
|
+
static doors = (context) => {
|
|
174
|
+
const { corner, stroke, count, plinth, gap, metal } = context;
|
|
175
|
+
const line = PlaneBoxService.line;
|
|
176
|
+
let svg = "";
|
|
177
|
+
for (let index = 1; index < count; index++) {
|
|
178
|
+
svg += line(corner(index / count, plinth), corner(index / count, 0.99), gap, stroke);
|
|
179
|
+
}
|
|
180
|
+
for (let index = 0; index < count; index++) {
|
|
181
|
+
const across = PlaneBoxService.handleAcross(index, count);
|
|
182
|
+
svg += line(corner(across, 0.42), corner(across, 0.74), metal, stroke * 1.8);
|
|
183
|
+
}
|
|
184
|
+
return svg;
|
|
185
|
+
};
|
|
186
|
+
static open = (context) => {
|
|
187
|
+
const { corner, stroke, plinth, color, details } = context;
|
|
188
|
+
const inside = [corner(0.05, plinth + 0.04), corner(0.95, plinth + 0.04), corner(0.95, 0.95), corner(0.05, 0.95)];
|
|
189
|
+
let svg = SvgUtil.polygon(inside, ColorUtil.sh(color, -0.38));
|
|
190
|
+
for (const shelf of details.shelves ?? [0.5]) {
|
|
191
|
+
svg += PlaneBoxService.line(corner(0.05, shelf), corner(0.95, shelf), color, stroke * 2.2);
|
|
192
|
+
}
|
|
193
|
+
return svg;
|
|
194
|
+
};
|
|
195
|
+
static handleAcross(index, count) {
|
|
196
|
+
if (count === 1) {
|
|
197
|
+
return 0.88;
|
|
198
|
+
}
|
|
199
|
+
return index < count / 2 ? (index + 1) / count - 0.045 : index / count + 0.045;
|
|
200
|
+
}
|
|
201
|
+
static FRONT_TO_DETAIL = {
|
|
202
|
+
drawers: PlaneBoxService.drawers,
|
|
203
|
+
doors: PlaneBoxService.doors,
|
|
204
|
+
open: PlaneBoxService.open
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export {
|
|
208
|
+
PlaneBoxService
|
|
209
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PlaneWorld } from "../Protocols/PlaneProtocol.js";
|
|
2
|
+
export declare class PlaneDepthService {
|
|
3
|
+
private static readonly EPSILON;
|
|
4
|
+
private static readonly HEIGHT_TOLERANCE;
|
|
5
|
+
private static readonly FAR_WEIGHT;
|
|
6
|
+
private static readonly LOW_WEIGHT;
|
|
7
|
+
static draw(world: PlaneWorld): string;
|
|
8
|
+
private static nodes;
|
|
9
|
+
private static overlaps;
|
|
10
|
+
private static xRange;
|
|
11
|
+
private static isBehind;
|
|
12
|
+
private static farness;
|
|
13
|
+
private static order;
|
|
14
|
+
private static pickReady;
|
|
15
|
+
private static pickGuess;
|
|
16
|
+
private static isFarther;
|
|
17
|
+
private static isBetterGuess;
|
|
18
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { PlaneBoxService } from "./PlaneBoxService.js";
|
|
2
|
+
import { PlaneSpriteService } from "./PlaneSpriteService.js";
|
|
3
|
+
class PlaneDepthService {
|
|
4
|
+
static EPSILON = 1e-4;
|
|
5
|
+
static HEIGHT_TOLERANCE = 0.5;
|
|
6
|
+
static FAR_WEIGHT = 1e3;
|
|
7
|
+
static LOW_WEIGHT = 1e-3;
|
|
8
|
+
static draw(world) {
|
|
9
|
+
const nodes = PlaneDepthService.nodes(world);
|
|
10
|
+
nodes.forEach((first, index) => {
|
|
11
|
+
for (const second of nodes.slice(index + 1)) {
|
|
12
|
+
if (!PlaneDepthService.overlaps(first.screen, second.screen)) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const isFirstBehind = PlaneDepthService.isBehind(first, second, world.camera.eyeX);
|
|
16
|
+
const [before, after] = isFirstBehind ? [first, second] : [second, first];
|
|
17
|
+
before.next.push(after);
|
|
18
|
+
after.indegree++;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return PlaneDepthService.order(nodes, world.warnings).map((node) => node.render()).join("\n");
|
|
22
|
+
}
|
|
23
|
+
static nodes(world) {
|
|
24
|
+
const { camera } = world;
|
|
25
|
+
const sprites = world.ground.map((sprite) => ({
|
|
26
|
+
id: sprite.id,
|
|
27
|
+
isSprite: true,
|
|
28
|
+
centerX: sprite.x,
|
|
29
|
+
x0: sprite.x - sprite.halfFootWidth,
|
|
30
|
+
x1: sprite.x + sprite.halfFootWidth,
|
|
31
|
+
z0: sprite.z,
|
|
32
|
+
z1: sprite.z,
|
|
33
|
+
bottom: sprite.lift,
|
|
34
|
+
top: sprite.lift + sprite.heightUnits,
|
|
35
|
+
screen: sprite.bounds,
|
|
36
|
+
render: () => PlaneSpriteService.draw(world, sprite),
|
|
37
|
+
next: [],
|
|
38
|
+
indegree: 0,
|
|
39
|
+
isDone: false
|
|
40
|
+
}));
|
|
41
|
+
const boxes = world.boxes.map((box) => {
|
|
42
|
+
const corners = [box.x0, box.x1].flatMap((groundX) => [box.z0, box.z1].flatMap((groundZ) => [box.elevation, box.height].map((up) => camera.project(groundX, groundZ, up))));
|
|
43
|
+
const xs = corners.map((corner) => corner[0]);
|
|
44
|
+
const ys = corners.map((corner) => corner[1]);
|
|
45
|
+
return {
|
|
46
|
+
id: box.id,
|
|
47
|
+
isSprite: false,
|
|
48
|
+
centerX: (box.x0 + box.x1) / 2,
|
|
49
|
+
x0: box.x0,
|
|
50
|
+
x1: box.x1,
|
|
51
|
+
z0: box.z0,
|
|
52
|
+
z1: box.z1,
|
|
53
|
+
bottom: box.elevation,
|
|
54
|
+
top: box.height,
|
|
55
|
+
screen: { x0: Math.min(...xs), y0: Math.min(...ys), x1: Math.max(...xs), y1: Math.max(...ys) },
|
|
56
|
+
render: () => PlaneBoxService.draw(world, box),
|
|
57
|
+
next: [],
|
|
58
|
+
indegree: 0,
|
|
59
|
+
isDone: false
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
return [...sprites, ...boxes];
|
|
63
|
+
}
|
|
64
|
+
static overlaps(first, second) {
|
|
65
|
+
return first.x0 < second.x1 && second.x0 < first.x1 && first.y0 < second.y1 && second.y0 < first.y1;
|
|
66
|
+
}
|
|
67
|
+
static xRange(node, other) {
|
|
68
|
+
const isOutside = node.isSprite && !other.isSprite && (node.centerX > other.x1 || node.centerX < other.x0);
|
|
69
|
+
return isOutside ? [node.centerX, node.centerX] : [node.x0, node.x1];
|
|
70
|
+
}
|
|
71
|
+
static isBehind(first, second, eyeX) {
|
|
72
|
+
const epsilon = PlaneDepthService.EPSILON;
|
|
73
|
+
const isSameZ = first.z0 === first.z1 && second.z0 === second.z1 && Math.abs(first.z0 - second.z0) < epsilon;
|
|
74
|
+
if (!isSameZ) {
|
|
75
|
+
if (first.z0 >= second.z1 - epsilon) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (second.z0 >= first.z1 - epsilon) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const [firstX0, firstX1] = PlaneDepthService.xRange(first, second);
|
|
83
|
+
const [secondX0, secondX1] = PlaneDepthService.xRange(second, first);
|
|
84
|
+
if (firstX1 <= secondX0 + epsilon) {
|
|
85
|
+
return eyeX >= (firstX1 + secondX0) / 2;
|
|
86
|
+
}
|
|
87
|
+
if (secondX1 <= firstX0 + epsilon) {
|
|
88
|
+
return eyeX <= (secondX1 + firstX0) / 2;
|
|
89
|
+
}
|
|
90
|
+
if (first.top <= second.bottom + PlaneDepthService.HEIGHT_TOLERANCE) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if (second.top <= first.bottom + PlaneDepthService.HEIGHT_TOLERANCE) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return (first.z0 + first.z1) / 2 > (second.z0 + second.z1) / 2;
|
|
97
|
+
}
|
|
98
|
+
static farness(node) {
|
|
99
|
+
return -((node.z0 + node.z1) / 2) * PlaneDepthService.FAR_WEIGHT + node.bottom * PlaneDepthService.LOW_WEIGHT;
|
|
100
|
+
}
|
|
101
|
+
static order(nodes, warnings) {
|
|
102
|
+
const ordered = [];
|
|
103
|
+
while (ordered.length < nodes.length) {
|
|
104
|
+
const pick = PlaneDepthService.pickReady(nodes) ?? PlaneDepthService.pickGuess(nodes);
|
|
105
|
+
if (pick === void 0) {
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
if (pick.indegree > 0) {
|
|
109
|
+
warnings.push(`ambiguous depth order involving '${pick.id}' (intersecting volumes); move the objects apart or adjust from/to`);
|
|
110
|
+
}
|
|
111
|
+
pick.isDone = true;
|
|
112
|
+
ordered.push(pick);
|
|
113
|
+
for (const following of pick.next) {
|
|
114
|
+
following.indegree--;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return ordered;
|
|
118
|
+
}
|
|
119
|
+
static pickReady(nodes) {
|
|
120
|
+
let pick;
|
|
121
|
+
for (const node of nodes) {
|
|
122
|
+
if (!node.isDone && node.indegree === 0 && (pick === void 0 || PlaneDepthService.isFarther(node, pick))) {
|
|
123
|
+
pick = node;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return pick;
|
|
127
|
+
}
|
|
128
|
+
static pickGuess(nodes) {
|
|
129
|
+
let pick;
|
|
130
|
+
for (const node of nodes) {
|
|
131
|
+
if (!node.isDone && (pick === void 0 || PlaneDepthService.isBetterGuess(node, pick))) {
|
|
132
|
+
pick = node;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return pick;
|
|
136
|
+
}
|
|
137
|
+
static isFarther(node, other) {
|
|
138
|
+
return PlaneDepthService.farness(node) < PlaneDepthService.farness(other);
|
|
139
|
+
}
|
|
140
|
+
static isBetterGuess(node, current) {
|
|
141
|
+
return node.indegree < current.indegree || node.indegree === current.indegree && PlaneDepthService.isFarther(node, current);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
PlaneDepthService
|
|
146
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PlaneLabel, PlaneWorld } from "../Protocols/PlaneProtocol.js";
|
|
2
|
+
export declare class PlaneLabelService {
|
|
3
|
+
private static readonly MIN_FONT;
|
|
4
|
+
private static readonly FRAME_MARGIN;
|
|
5
|
+
private static readonly OUT_OF_FRAME_PENALTY;
|
|
6
|
+
private static readonly TOLERATED_OVERLAP;
|
|
7
|
+
private static readonly BLOCKER_MIN_HEIGHT;
|
|
8
|
+
private static readonly PERSON_REACH;
|
|
9
|
+
private static readonly SIDE_TO_CANDIDATE;
|
|
10
|
+
static place(world: PlaneWorld): PlaneLabel[];
|
|
11
|
+
static draw(world: PlaneWorld, labels: readonly PlaneLabel[]): string;
|
|
12
|
+
private static placeOne;
|
|
13
|
+
}
|