@guilhermebkel/scenec 0.1.1 → 0.2.0
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 +15 -22
- 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 +9 -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/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 +5 -0
- package/dist/Commands/RenderCommand.js +8 -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/CheckModule.d.ts +8 -0
- package/dist/Modules/CheckModule.js +16 -0
- package/dist/Modules/CompilationModule.d.ts +18 -0
- package/dist/Modules/CompilationModule.js +137 -0
- package/dist/Modules/CritiqueModule.d.ts +6 -0
- package/dist/Modules/CritiqueModule.js +43 -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 +62 -0
- package/dist/Protocols/AssetProtocol.js +93 -0
- package/dist/Protocols/CommandProtocol.d.ts +6 -0
- package/dist/Protocols/CommandProtocol.js +0 -0
- package/dist/Protocols/CompilationProtocol.d.ts +110 -0
- package/dist/Protocols/CompilationProtocol.js +0 -0
- package/dist/Protocols/CritiqueProtocol.d.ts +42 -0
- package/dist/Protocols/CritiqueProtocol.js +4 -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 +26 -0
- package/dist/Protocols/KitProtocol.js +17 -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 +64 -0
- package/dist/Protocols/PersonProtocol.js +40 -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 +625 -0
- package/dist/Protocols/SceneProtocol.js +304 -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 +16 -0
- package/dist/Resources/Assets/BaseAsset.js +10 -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 +19 -0
- package/dist/Resources/Assets/BirdAsset.d.ts +10 -0
- package/dist/Resources/Assets/BirdAsset.js +14 -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 +11 -0
- package/dist/Resources/Assets/ChairAsset.js +32 -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 +15 -0
- package/dist/Resources/Assets/CoffeeMachineAsset.d.ts +10 -0
- package/dist/Resources/Assets/CoffeeMachineAsset.js +23 -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/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 +35 -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/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/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 +42 -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 +23 -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/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/SofaAsset.d.ts +11 -0
- package/dist/Resources/Assets/SofaAsset.js +38 -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 +11 -0
- package/dist/Resources/Assets/StarsAsset.js +42 -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/TrashCanAsset.d.ts +10 -0
- package/dist/Resources/Assets/TrashCanAsset.js +31 -0
- package/dist/Resources/Assets/TreeAsset.d.ts +10 -0
- package/dist/Resources/Assets/TreeAsset.js +23 -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/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 +12 -0
- package/dist/Resources/Kits/BaseKit.js +11 -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/OutlineKit.d.ts +12 -0
- package/dist/Resources/Kits/OutlineKit.js +10 -0
- package/dist/Resources/Kits/PaperKit.d.ts +11 -0
- package/dist/Resources/Kits/PaperKit.js +11 -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 +9 -0
- package/dist/Resources/Kits/SketchKit.js +11 -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 +204 -0
- package/dist/Services/BackgroundService.d.ts +33 -0
- package/dist/Services/BackgroundService.js +136 -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 +29 -0
- package/dist/Services/CatalogService.js +51 -0
- package/dist/Services/ContactCritiqueService.d.ts +19 -0
- package/dist/Services/ContactCritiqueService.js +101 -0
- package/dist/Services/ContextService.d.ts +21 -0
- package/dist/Services/ContextService.js +94 -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 +9 -0
- package/dist/Services/DescriptionService.js +27 -0
- package/dist/Services/FramingCheckService.d.ts +15 -0
- package/dist/Services/FramingCheckService.js +93 -0
- package/dist/Services/GazeService.d.ts +6 -0
- package/dist/Services/GazeService.js +43 -0
- package/dist/Services/GroupService.d.ts +17 -0
- package/dist/Services/GroupService.js +152 -0
- package/dist/Services/KitService.d.ts +23 -0
- package/dist/Services/KitService.js +96 -0
- package/dist/Services/LightingService.d.ts +24 -0
- package/dist/Services/LightingService.js +119 -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/PieceService.d.ts +43 -0
- package/dist/Services/PieceService.js +154 -0
- package/dist/Services/PlacementService.d.ts +60 -0
- package/dist/Services/PlacementService.js +415 -0
- package/dist/Services/PlaneBackgroundService.d.ts +24 -0
- package/dist/Services/PlaneBackgroundService.js +170 -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 +16 -0
- package/dist/Services/PlaneProjectionService.js +90 -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 +68 -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/TextService.d.ts +47 -0
- package/dist/Services/TextService.js +178 -0
- package/dist/Services/ThemeService.d.ts +5 -0
- package/dist/Services/ThemeService.js +18 -0
- package/dist/Utils/BoxUtil.d.ts +4 -0
- package/dist/Utils/BoxUtil.js +8 -0
- package/dist/Utils/ColorUtil.d.ts +20 -0
- package/dist/Utils/ColorUtil.js +51 -0
- package/dist/Utils/CurveUtil.d.ts +6 -0
- package/dist/Utils/CurveUtil.js +35 -0
- package/dist/Utils/FallbackUtil.d.ts +3 -0
- package/dist/Utils/FallbackUtil.js +8 -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 +23 -0
- package/dist/Utils/OklabUtil.js +62 -0
- package/dist/Utils/PersonArmUtil.d.ts +19 -0
- package/dist/Utils/PersonArmUtil.js +84 -0
- package/dist/Utils/PersonHeadUtil.d.ts +31 -0
- package/dist/Utils/PersonHeadUtil.js +154 -0
- package/dist/Utils/PersonOutfitUtil.d.ts +48 -0
- package/dist/Utils/PersonOutfitUtil.js +178 -0
- package/dist/Utils/PersonUtil.d.ts +39 -0
- package/dist/Utils/PersonUtil.js +206 -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 +210 -0
- package/dist/Utils/SeedUtil.d.ts +6 -0
- package/dist/Utils/SeedUtil.js +15 -0
- package/dist/Utils/ShapeUtil.d.ts +31 -0
- package/dist/Utils/ShapeUtil.js +47 -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/cli.js +24 -97
- package/dist/index.d.ts +10 -6
- package/dist/index.js +14 -2
- package/dist/render.d.ts +8 -5
- package/dist/render.js +21 -3
- package/dist/schema.d.ts +9 -2
- package/dist/schema.js +29 -5
- package/package.json +3 -2
- package/skills/{scenec → draw-scene}/SKILL.md +15 -19
- package/skills/{scenec → draw-scene}/references/catalog.md +14 -14
- package/skills/{scenec → draw-scene}/references/dsl.md +9 -3
- 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/carrossel.yaml → draw-scene/recipes/carousel.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
- /package/skills/{scenec/recipes/ilustracoes-produto.yaml → draw-scene/recipes/product-illustration.yaml} +0 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { BoxUtil } from "../Utils/BoxUtil.js";
|
|
2
|
+
import { FormatUtil } from "../Utils/FormatUtil.js";
|
|
3
|
+
import { IdUtil } from "../Utils/IdUtil.js";
|
|
4
|
+
import { RequireUtil } from "../Utils/RequireUtil.js";
|
|
5
|
+
import { SvgUtil } from "../Utils/SvgUtil.js";
|
|
6
|
+
import { ThemeUtil } from "../Utils/ThemeUtil.js";
|
|
7
|
+
const FONT = "Poppins";
|
|
8
|
+
class PlaneLabelService {
|
|
9
|
+
static MIN_FONT = 13;
|
|
10
|
+
static FRAME_MARGIN = 6;
|
|
11
|
+
static OUT_OF_FRAME_PENALTY = 1e6;
|
|
12
|
+
static TOLERATED_OVERLAP = 0.15;
|
|
13
|
+
static BLOCKER_MIN_HEIGHT = 40;
|
|
14
|
+
static PERSON_REACH = 20;
|
|
15
|
+
// Why: the candidate index each `label_side` moves to the front of the list.
|
|
16
|
+
static SIDE_TO_CANDIDATE = { left: 2, right: 1, below: 5 };
|
|
17
|
+
static place(world) {
|
|
18
|
+
const minHeight = PlaneLabelService.BLOCKER_MIN_HEIGHT;
|
|
19
|
+
const isBlocking = (sprite) => !sprite.isDecor || sprite.height > minHeight;
|
|
20
|
+
const blockers = world.ground.filter(isBlocking).map((sprite) => sprite.bounds);
|
|
21
|
+
const labels = [];
|
|
22
|
+
world.road.checkpoints.forEach((checkpoint, index) => {
|
|
23
|
+
if (checkpoint.label === void 0 || checkpoint.label === "") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const label = PlaneLabelService.placeOne(world, checkpoint, index, { blockers, placed: labels });
|
|
27
|
+
labels.push(label);
|
|
28
|
+
});
|
|
29
|
+
return labels;
|
|
30
|
+
}
|
|
31
|
+
static draw(world, labels) {
|
|
32
|
+
const { theme } = world;
|
|
33
|
+
const num = FormatUtil.oneDecimal;
|
|
34
|
+
return labels.map((label) => {
|
|
35
|
+
const { box } = label;
|
|
36
|
+
const anchorX = Math.min(Math.max(label.centerX, box.x0 + 8), box.x1 - 8);
|
|
37
|
+
const anchorY = box.y1 < label.centerY ? box.y1 : box.y0;
|
|
38
|
+
const boxWidth = box.x1 - box.x0;
|
|
39
|
+
const boxHeight = box.y1 - box.y0;
|
|
40
|
+
const middle = (box.y0 + box.y1) / 2;
|
|
41
|
+
const textY = num(middle + label.fontSize * 0.36);
|
|
42
|
+
const size = num(label.fontSize);
|
|
43
|
+
const leader = SvgUtil.segment([anchorX, anchorY], [label.centerX, label.centerY]);
|
|
44
|
+
const numberText = SvgUtil.escapeXml(label.number);
|
|
45
|
+
const titleText = SvgUtil.escapeXml(label.title);
|
|
46
|
+
const titleColor = theme.text === theme.paper ? theme.ink : theme.text;
|
|
47
|
+
return `<path d="${leader}" stroke="${theme.ink}" stroke-width="1.5" opacity="0.45" stroke-dasharray="3 3"/><rect x="${num(box.x0 + 2)}" y="${num(box.y0 + 3)}" width="${num(boxWidth)}" height="${num(boxHeight)}" rx="${num(boxHeight / 2)}" fill="${theme.ink}" opacity="0.15"/><rect x="${num(box.x0)}" y="${num(box.y0)}" width="${num(boxWidth)}" height="${num(boxHeight)}" rx="${num(boxHeight / 2)}" fill="${theme.paper}"/><circle cx="${num(box.x0 + boxHeight / 2)}" cy="${num(middle)}" r="${num(boxHeight / 2 - 3)}" fill="${label.color}"/><text x="${num(box.x0 + boxHeight / 2)}" y="${textY}" font-family="${FONT}" font-weight="700" font-size="${size}" fill="${theme.paper}" text-anchor="middle">${numberText}</text><text x="${num(box.x0 + boxHeight + label.fontSize * 0.35)}" y="${textY}" font-family="${FONT}" font-weight="600" font-size="${size}" fill="${titleColor}">${titleText}</text>`;
|
|
48
|
+
}).join("");
|
|
49
|
+
}
|
|
50
|
+
static placeOne(world, checkpoint, index, others) {
|
|
51
|
+
const { blockers, placed } = others;
|
|
52
|
+
const title = checkpoint.label ?? "";
|
|
53
|
+
const { camera, theme, road } = world;
|
|
54
|
+
const [groundX, groundZ] = checkpoint.at;
|
|
55
|
+
const centerX = camera.screenX(groundX, groundZ);
|
|
56
|
+
const centerY = camera.screenY(groundZ);
|
|
57
|
+
const shrink = camera.shrink(groundZ);
|
|
58
|
+
const fontSize = Math.max(PlaneLabelService.MIN_FONT, camera.height * 0.024 * (0.75 + 0.25 * shrink / 1));
|
|
59
|
+
const number = checkpoint.isFinish ? "\u2605" : String(index + 1);
|
|
60
|
+
const width = `${number} ${title}`.length * fontSize * 0.56 + fontSize * 1.4;
|
|
61
|
+
const height = fontSize * 1.8;
|
|
62
|
+
const nearEdge = camera.screenY(groundZ - road.checkpointRadius);
|
|
63
|
+
const radiusY = (nearEdge - camera.screenY(groundZ + road.checkpointRadius)) / 2;
|
|
64
|
+
const reach = PlaneLabelService.PERSON_REACH;
|
|
65
|
+
const person = world.ground.find((sprite) => sprite.isPerson && Math.abs(sprite.screenX - centerX) < reach && Math.abs(sprite.screenY - centerY) < reach);
|
|
66
|
+
const up = person ? person.height + fontSize * 0.6 : fontSize * 2.4;
|
|
67
|
+
const corners = [
|
|
68
|
+
[centerX - width / 2, centerY - up - height],
|
|
69
|
+
[centerX + radiusY * 2.2, centerY - height * 0.5],
|
|
70
|
+
[centerX - radiusY * 2.2 - width, centerY - height * 0.5],
|
|
71
|
+
[centerX + radiusY * 1.6, centerY - up * 0.7 - height],
|
|
72
|
+
[centerX - radiusY * 1.6 - width, centerY - up * 0.7 - height],
|
|
73
|
+
[centerX - width / 2, centerY + radiusY * 2]
|
|
74
|
+
];
|
|
75
|
+
const preferred = IdUtil.lookup(PlaneLabelService.SIDE_TO_CANDIDATE, checkpoint.labelSide);
|
|
76
|
+
if (preferred !== void 0) {
|
|
77
|
+
corners.unshift(RequireUtil.defined(corners[preferred], "label candidate"));
|
|
78
|
+
}
|
|
79
|
+
let best = null;
|
|
80
|
+
let bestScore = Infinity;
|
|
81
|
+
for (const [left, top] of corners) {
|
|
82
|
+
const box = { x0: left, x1: left + width, y0: top, y1: top + height };
|
|
83
|
+
let score = 0;
|
|
84
|
+
if (box.x0 < PlaneLabelService.FRAME_MARGIN || box.x1 > camera.width - PlaneLabelService.FRAME_MARGIN || box.y0 < PlaneLabelService.FRAME_MARGIN || box.y1 > camera.height - PlaneLabelService.FRAME_MARGIN) {
|
|
85
|
+
score += PlaneLabelService.OUT_OF_FRAME_PENALTY;
|
|
86
|
+
}
|
|
87
|
+
for (const blocker of blockers) {
|
|
88
|
+
score += BoxUtil.overlapArea(box, blocker);
|
|
89
|
+
}
|
|
90
|
+
for (const other of placed) {
|
|
91
|
+
score += BoxUtil.overlapArea(box, other.box) * 3;
|
|
92
|
+
}
|
|
93
|
+
if (score < bestScore) {
|
|
94
|
+
bestScore = score;
|
|
95
|
+
best = box;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (bestScore > width * height * PlaneLabelService.TOLERATED_OVERLAP) {
|
|
99
|
+
const percent = Math.round(bestScore / (width * height) * 100);
|
|
100
|
+
world.warnings.push(`label '${title}' overlaps other elements (${percent}% of its area); adjust 'label_side' or the point position`);
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
box: RequireUtil.defined(best ?? void 0, "label position"),
|
|
104
|
+
centerX,
|
|
105
|
+
centerY,
|
|
106
|
+
number,
|
|
107
|
+
title,
|
|
108
|
+
fontSize,
|
|
109
|
+
color: checkpoint.isFinish ? theme.accent : ThemeUtil.resolve(theme, checkpoint.color, theme.primary)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
PlaneLabelService
|
|
115
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PlaneWorld } from "../Protocols/PlaneProtocol.js";
|
|
2
|
+
export declare class PlaneObjectService {
|
|
3
|
+
private static readonly PASSES;
|
|
4
|
+
private static readonly DEFAULT_ALTITUDE;
|
|
5
|
+
private static readonly SKY_UNIT;
|
|
6
|
+
private static readonly ROAD_SIDE_GAP;
|
|
7
|
+
private static readonly SPOT_NUDGE;
|
|
8
|
+
private static readonly FALLBACK_OFFSET;
|
|
9
|
+
private static readonly BOX_EDGE_TOLERANCE;
|
|
10
|
+
private static readonly SIDE_TO_SIGN;
|
|
11
|
+
private static readonly SKY_KIND;
|
|
12
|
+
static place(world: PlaneWorld): void;
|
|
13
|
+
private static target;
|
|
14
|
+
private static nearTarget;
|
|
15
|
+
private static placeSky;
|
|
16
|
+
private static placeGround;
|
|
17
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { PlacementService } from "./PlacementService.js";
|
|
2
|
+
import { PlanePathService } from "./PlanePathService.js";
|
|
3
|
+
import { PlaneSpaceService } from "./PlaneSpaceService.js";
|
|
4
|
+
import { PlaneSpriteService } from "./PlaneSpriteService.js";
|
|
5
|
+
import { IdUtil } from "../Utils/IdUtil.js";
|
|
6
|
+
import { RequireUtil } from "../Utils/RequireUtil.js";
|
|
7
|
+
const WAIT = /* @__PURE__ */ Symbol("wait");
|
|
8
|
+
class PlaneObjectService {
|
|
9
|
+
// Why: an object can sit near another one that comes later in the file, so unresolved anchors get a few more passes.
|
|
10
|
+
static PASSES = 4;
|
|
11
|
+
static DEFAULT_ALTITUDE = 0.12;
|
|
12
|
+
static SKY_UNIT = 17e-4;
|
|
13
|
+
static ROAD_SIDE_GAP = 0.05;
|
|
14
|
+
static SPOT_NUDGE = 5e-3;
|
|
15
|
+
static FALLBACK_OFFSET = 0.1;
|
|
16
|
+
static BOX_EDGE_TOLERANCE = 5e-3;
|
|
17
|
+
static SIDE_TO_SIGN = { left: 1, right: -1 };
|
|
18
|
+
static SKY_KIND = "sky";
|
|
19
|
+
static place(world) {
|
|
20
|
+
const objects = world.scene.objects ?? {};
|
|
21
|
+
const pending = new Set(Object.keys(objects));
|
|
22
|
+
for (let pass = 0; pass < PlaneObjectService.PASSES && pending.size > 0; pass++) {
|
|
23
|
+
for (const id of [...pending]) {
|
|
24
|
+
const object = RequireUtil.defined(objects[id], `object '${id}'`);
|
|
25
|
+
const target = PlaneObjectService.target(world, id, object, pass);
|
|
26
|
+
if (target === WAIT) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
pending.delete(id);
|
|
30
|
+
if (target === null) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (target.groundZ === null) {
|
|
34
|
+
PlaneObjectService.placeSky(world, id, object, target.groundX);
|
|
35
|
+
} else {
|
|
36
|
+
PlaneObjectService.placeGround(world, id, object, [target.groundX, target.groundZ]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
static target(world, id, object, pass) {
|
|
42
|
+
const { warnings, road } = world;
|
|
43
|
+
if (Array.isArray(object.at)) {
|
|
44
|
+
return { groundX: object.at[0], groundZ: object.at[1] };
|
|
45
|
+
}
|
|
46
|
+
if (object.along !== void 0) {
|
|
47
|
+
if (road.samples.length === 0) {
|
|
48
|
+
warnings.push(`'${id}' uses 'along', but the scene has no path`);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const { point, normal } = PlanePathService.pointAt(road, object.along);
|
|
52
|
+
const side = IdUtil.lookup(PlaneObjectService.SIDE_TO_SIGN, object.side) ?? 0;
|
|
53
|
+
const distance = object.dist ?? (side === 0 ? 0 : road.width / 2 + PlaneObjectService.ROAD_SIDE_GAP);
|
|
54
|
+
return { groundX: point[0] + normal[0] * distance * side, groundZ: point[1] + normal[1] * distance * side };
|
|
55
|
+
}
|
|
56
|
+
if (object.near !== void 0 && object.near !== "") {
|
|
57
|
+
return PlaneObjectService.nearTarget(world, id, object, pass);
|
|
58
|
+
}
|
|
59
|
+
const isSkyAsset = PlaneSpriteService.find(world, PlaneSpriteService.assetName(id, object))?.asset.kind === "sky";
|
|
60
|
+
if (typeof object.at === "string" && isSkyAsset) {
|
|
61
|
+
const slot = IdUtil.lookup(PlacementService.SLOT_TO_FRACTION, object.at.replace("top-", "")) ?? 0.5;
|
|
62
|
+
return { groundX: slot, groundZ: null };
|
|
63
|
+
}
|
|
64
|
+
warnings.push(`'${id}' has no position: use at: [x, z], near, or along`);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
static nearTarget(world, id, object, pass) {
|
|
68
|
+
const near = object.near ?? "";
|
|
69
|
+
const anchor = world.pointIdToPosition.get(near);
|
|
70
|
+
if (!anchor) {
|
|
71
|
+
if (pass === PlaneObjectService.PASSES - 1) {
|
|
72
|
+
world.warnings.push(`'${id}' has 'near: ${near}', which does not exist`);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return WAIT;
|
|
76
|
+
}
|
|
77
|
+
const [anchorX, anchorZ] = anchor;
|
|
78
|
+
if (Array.isArray(object.offset)) {
|
|
79
|
+
return { groundX: anchorX + object.offset[0], groundZ: anchorZ + object.offset[1] };
|
|
80
|
+
}
|
|
81
|
+
const name = PlaneSpriteService.assetName(id, object);
|
|
82
|
+
if (name === "person" || object.on_spot === true) {
|
|
83
|
+
return { groundX: anchorX, groundZ: anchorZ - PlaneObjectService.SPOT_NUDGE };
|
|
84
|
+
}
|
|
85
|
+
const found = PlaneSpriteService.find(world, name);
|
|
86
|
+
const widthUnits = found ? PlaneSpriteService.dimensions(found.asset, object).w : 0;
|
|
87
|
+
const factor = PlaneSpriteService.sizeFactor(object.size);
|
|
88
|
+
const spot = found && PlaneSpaceService.findSpot(world, { anchor, widthUnits, factor });
|
|
89
|
+
if (!spot) {
|
|
90
|
+
world.warnings.push(`no free space found near '${near}' for '${id}'; use 'offset: [dx, dz]'`);
|
|
91
|
+
const nudge = PlaneObjectService.FALLBACK_OFFSET;
|
|
92
|
+
return { groundX: anchorX + nudge, groundZ: anchorZ + nudge };
|
|
93
|
+
}
|
|
94
|
+
return { groundX: spot[0], groundZ: spot[1] };
|
|
95
|
+
}
|
|
96
|
+
static placeSky(world, id, object, slot) {
|
|
97
|
+
const found = PlaneSpriteService.find(world, PlaneSpriteService.assetName(id, object));
|
|
98
|
+
if (!found) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const { camera, theme } = world;
|
|
102
|
+
const scale = camera.height * PlaneObjectService.SKY_UNIT * PlaneSpriteService.sizeFactor(object.size);
|
|
103
|
+
const drawn = found.asset.draw({ ...object }, theme);
|
|
104
|
+
const altitude = object.altitude ?? PlaneObjectService.DEFAULT_ALTITUDE;
|
|
105
|
+
world.sky.push({
|
|
106
|
+
id,
|
|
107
|
+
screenX: slot * camera.width,
|
|
108
|
+
screenY: camera.height * altitude + found.asset.height * scale / 2,
|
|
109
|
+
scale,
|
|
110
|
+
svg: typeof drawn === "string" ? drawn : drawn.svg,
|
|
111
|
+
width: found.asset.width * scale,
|
|
112
|
+
height: found.asset.height * scale
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
static placeGround(world, id, object, at) {
|
|
116
|
+
const { warnings, road } = world;
|
|
117
|
+
const [groundX, groundZ] = at;
|
|
118
|
+
let lift;
|
|
119
|
+
if (object.on !== void 0 && object.on !== "") {
|
|
120
|
+
const box = world.boxes.find((candidate) => candidate.id === object.on);
|
|
121
|
+
if (box) {
|
|
122
|
+
lift = box.height;
|
|
123
|
+
const tolerance = PlaneObjectService.BOX_EDGE_TOLERANCE;
|
|
124
|
+
const isOutsideX = groundX < box.x0 - tolerance || groundX > box.x1 + tolerance;
|
|
125
|
+
const isOutsideZ = groundZ < box.z0 - tolerance || groundZ > box.z1 + tolerance;
|
|
126
|
+
if (isOutsideX || isOutsideZ) {
|
|
127
|
+
warnings.push(`'${id}' has 'on: ${object.on}', but position [${groundX}, ${groundZ}] is outside the top of the box`);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
warnings.push(`'${id}' has 'on: ${object.on}', which is not a box`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const sprite = PlaneSpriteService.add(world, { id, object, groundX, groundZ, lift });
|
|
134
|
+
if (!sprite) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
world.protectedSprites.push(sprite);
|
|
138
|
+
const roadDistance = PlanePathService.distanceToRoad(road, groundX, groundZ);
|
|
139
|
+
const isOnRoad = road.samples.length > 0 && roadDistance < road.width / 2;
|
|
140
|
+
if (isOnRoad && !sprite.isPerson && sprite.kind !== PlaneObjectService.SKY_KIND && object.on_path !== true) {
|
|
141
|
+
warnings.push(`'${id}' is on top of the path; move it or use 'on_path: true' if intended`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
PlaneObjectService
|
|
147
|
+
};
|