Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Units: code-built 1948 unit miniatures at gameplay03 (art slice)

eyalgolan4076f67b1d5d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d00bb3152..1f3faa7a4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
- A runtime quality fallback for slow machines in the browser: when frames stay slower than 30 fps, the game lowers its
render scale (to 0.9, then 0.8) and then turns the tilt-shift off, and steps back up when frames are comfortably fast
again. Presentation only; `?nofallback` turns it off (#44).
+- The unit art slice (a showcase for the art track, not gameplay): a 1948 IDF rifle trio with a selection ring, an IAF
+ Spitfire flying a loop with its shadow, and the corvette INS Haganah, built from code as painted miniatures at the
+ promo's symbolic scale. Shown only with `?units`, in `?shot` screenshots and in editor renders (docs/units.md).
### Changed
- The historical AI no longer sends an order the turn's attention cannot cover (the rule the UI's order queue applies),
diff --git a/LICENSING.md b/LICENSING.md
index 7662472e2..d817b31f6 100644
--- a/LICENSING.md
+++ b/LICENSING.md
@@ -6,7 +6,7 @@ Different parts of this repository are under different licences. Where a file is
|---|---|---|
| Code | `sim/`, `tools/` (Python), `scripts/`, `.github/`, `.gitignore`, `unity/Assets/Scripts/`, `unity/Assets/Editor/`, `unity/Assets/Tests/`, `promo/*.py`, `spikes/` code, and everything else under `unity/Assets/` not listed below (scenes such as `Map.unity`, `WebGLTemplates/`, `link.xml`, `*.inputactions`, `.meta` files) | [MIT](LICENSE) |
| Game content (text and data) | `content/` (events, people, offices, model, rules, map YAML/JSON), except the third-party map data below | [CC BY-SA 4.0](LICENSES/CC-BY-SA-4.0.txt), credit "Statecraft: Israel contributors". The text paraphrases its cited sources, many from Wikipedia (CC BY-SA), so share-alike applies; each entry lists its sources |
-| Original docs, art and UI assets | `docs/`, the root `*.md` files (except `LICENSE`), `ASSETS.yaml`, `ASSETS.portraits.yaml`, `promo/shots.json`, `promo/CREDITS.md`, `tools/README.md`, `reports/` (our own text), `research_notes/` (our own text), `unity/Assets/UI/*.uxml`, `*.uss`, `strings.en.yaml`, `unity/Assets/Materials/`, `unity/Assets/Shaders/`, `unity/Assets/UI/*.asset`, `promo/ref/geo-reference.png` | [CC BY 4.0](LICENSES/CC-BY-4.0.txt), credit "Statecraft: Israel contributors" |
+| Original docs, art and UI assets | `docs/`, the root `*.md` files (except `LICENSE`), `ASSETS.yaml`, `ASSETS.portraits.yaml`, `promo/shots.json`, `promo/CREDITS.md`, `tools/README.md`, `reports/` (our own text), `research_notes/` (our own text), `unity/Assets/UI/*.uxml`, `*.uss`, `strings.en.yaml`, `unity/Assets/Materials/`, `unity/Assets/Resources/Units/` (materials), `unity/Assets/Shaders/`, `unity/Assets/UI/*.asset`, `promo/ref/geo-reference.png` | [CC BY 4.0](LICENSES/CC-BY-4.0.txt), credit "Statecraft: Israel contributors" |
| Unity template-derived files | `unity/Assets/Settings/` (URP assets, renderers, volume profiles), `spikes/m0/unity/Assets/Settings/`, `spikes/m0/unity/Assets/UI Toolkit/UnityThemes/`, and any Shader Graph generated from a Unity template (for example `unity/Assets/Shaders/StatecraftTerrain.shadergraph`, from "Terrain Simple") | Created from Unity's project or graph templates and edited; under the [Unity Companion License](https://unity.com/legal/licenses/unity-companion-license) (use with Unity), not MIT |
| AI-generated images | `promo/final/01`–`08`, `promo/ref/*-src.jpg`, `docs/images/hero-concept-1936.jpg` | Marked [CC0 1.0](LICENSES/CC0-1.0.txt). No rights are claimed. Purely AI-generated output may not be copyrightable. Made with the ElevenLabs Image API (see `promo/CREDITS.md`). |
| In-engine captures | `promo/final/09`, `10`, `docs/images/build-*.jpg`, `docs/images/social-preview.jpg`, `spikes/m0/evidence/*.jpg`, `spikes/m0/evidence/*.txt` (logs) | CC BY 4.0. They show the Copernicus-derived terrain; see below. |
diff --git a/docs/units.md b/docs/units.md
new file mode 100644
index 000000000..db8bc5a85
--- /dev/null
+++ b/docs/units.md
@@ -0,0 +1,109 @@
+# Unit miniatures: the art slice
+
+The owner's target for units (2026-10-11) is the promo: `promo/final/03-gameplay-1936.png` and the demo trailer
+(`promo/demo/out/demo-16x9.mp4`, 0:06–0:30). It shows Civ-style miniatures standing on hexes at symbolic scale: a trio of
+era-correct riflemen with a selection ring, a mounted rider, and aircraft with Israeli roundels flying low with a shadow.
+This page records the slice that matches it, the pipeline choice behind it, the scale, and the sources for every uniform,
+aircraft and ship.
+
+The slice is a **showcase only**. It reads nothing from the sim and changes no game state. Where units stand, move and
+fight is war mode's job (#104, with the sim side in #21). The golden hashes do not move.
+
+## How to see it
+
+- **WebGL:** add `units` to the page URL (`index.html?units`). The art checkpoint's `?shot` shows it too, with the aircraft
+ held at a fixed point so screenshots repeat. Normal play never shows it.
+- **Desktop player:** run with `-units`.
+- **Editor:** `MapCapture.Promo` (run by `tools/art_checkpoint.sh`) renders it.
+- **Frame cost:** `?vprofile&units` prices it as the `units` toggle (`median(all) - median(-units)`).
+
+Code: `unity/Assets/Scripts/Map/Units/`. The materials are made by `UnitMaterialAssets.Create` in
+`unity/Assets/Resources/Units/`. Tests: `UnitShowcaseTests`.
+
+## What is in the slice
+
+| Piece | Model | Where (PromoPose.Gameplay03) |
+|---|---|---|
+| Rifle trio | three 1948 IDF riflemen: bush hat with rifle held ready, Mk II steel helmet with rifle grounded, Palmach stocking cap with rifle slung | on the coastal plain south-east of Jaffa (34.84 E, 31.93 N), inside a white selection ring |
+| Aircraft | Supermarine Spitfire LF Mk IX in IAF service, 1948 | a 16 km loop over Tel Aviv and the coast, 4.2 km above the highest ground under it, banked 28 degrees, its shadow cast on the ground by the sun |
+| Navy | modified Flower-class corvette INS Haganah (K-20), 1948 | off Jaffa (34.63 E, 32.02 N) |
+
+Not in the slice:
+- **The mounted rider.** No 1948 IDF mounted unit was sourced for this slice. The promo's rider belongs to 1936, so it
+ waits for the Yishuv era (#49) and a source.
+- **Civilian boats.** The owner ruled them out of scope; navy ships are units.
+
+## Pipeline choice: code-built miniatures
+
+Three pipelines were tried on this Mac (Apple M5 Pro, 48 GB) on 2026-10-11. Each was placed on the map at the same scale
+and rendered at the gameplay zoom and close up. The evidence is in the spike report (agent scratchpad, `units-report.md`).
+
+| Pipeline | Result | Licence |
+|---|---|---|
+| (a) Image-to-3D, run locally: TripoSR (MIT code and weights), CPU, about 3.5 s per mesh | Inputs were a promo crop and a 1948 photograph. Out came a blurry blob of about 45,700 triangles with baked vertex colours: the head and rifle were lost to the background cut-out, the side view was a flat card for the rider, and there was no rig. It would need clean, sharp turnaround references, which we cannot make locally, plus manual retopology. | MIT; fine. |
+| (a) Hunyuan3D-2, TRELLIS | Not run. Hunyuan3D-2's community licence excludes the EU, the UK and South Korea, which is not compatible with an open project. TRELLIS needs an NVIDIA GPU with CUDA. | Hunyuan3D-2: not compatible. TRELLIS: MIT. |
+| (b) CC0 base meshes: Quaternius Universal Base Characters (free "Standard" kit, CC0) | A clean, rigged body, but a stylised "superhero" figure in underwear, in a T-pose. Every uniform, hat, belt and rifle would have to be modelled by hand in Blender. Kenney's characters are blocky, low-poly figures, which the spec rules out (§6, "no low-poly packs mixed in"). | CC0; fine. |
+| **(c) Code-built from primitives (chosen)** | Lathed limbs and torsos, ellipsoids, boxes and plates, painted from one palette texture with a dark wash at the feet and a dry-brushed highlight on top. One URP Lit material, made at runtime, with no texture file. About 3,600 triangles per figure. Real silhouettes for each headgear and rifle pose. The figures cast and receive shadows. | Our own code, MIT. |
+
+**Why (c):** at the gameplay zoom a figure is about 100 px tall. What reads at that size is the silhouette (hat brim,
+rifle, stance), the colour blocks (khaki shirt, dark trousers, pale webbing) and the shadow, and the code-built figures
+match the promo on all three. They are exact to the sources: each part is a sourced item, and a change is a reviewed line
+of code. Era variants (1956 helmets, 1967 Uzis, 1973 flak vests) are parameters. Builds are deterministic, there is no
+licence question, and the build-size cost is code only.
+
+**Their limit:** close up (the 6 km hero zoom) they look like wooden mannequins, with faceted limbs and no faces or
+folds. The promo's close shots (0:21) show sculpted miniatures. The path past that limit, when the art track gets to it:
+hand-sculpted figures in Blender over a CC0 base (b), in the same palette and silhouettes, with the code-built figures kept
+as the far LOD.
+
+## Scale
+
+Measured on the promo at the gameplay zoom, a rifleman stands about 0.38 of a hex's screen width tall. Our gameplay03 pose
+frames the same hex count as the promo (about 9 across: see `PromoPose`). With 5 km hexes, a 50-degree camera pitch and a
+35-degree field of view at 60 km, that is a figure about 5.5 km tall: `UnitShowcase.FigureScale = 2600` times a real man.
+The aircraft (x520) and the ship (x105) are sized against the figures, as Civ sizes them, not against each other.
+
+**Open question for the owner.** This is far above the "10–25x real" ruling for buildings and trees. At 10–25x a man is
+18–45 m tall, which is under one pixel at 60 km. The promo (which wins over strict scale, by the owner's ruling) draws
+units as tokens. Options:
+1. Keep units as tokens at about 2,600x, as now.
+2. Scale units with the zoom, Civ-style, so they keep a constant size on screen.
+3. Make them smaller and accept that they only read at the hero zoom.
+
+The slice does (1), and the scale is one constant.
+
+## Sources (checked 2026-10-11)
+
+Uniform and equipment, 1948:
+- Palmach (Negev Brigade) soldiers briefed before an operation, 1948: khaki shirts and trousers, web belts with pouches,
+ knitted stocking caps, rifles. Public domain.
+ https://commons.wikimedia.org/wiki/File:Palmach-negev-instructed2operation.jpg
+- Negev Brigade soldiers, 20 October 1948: Mk II steel helmets, khaki drill, field gun. Public domain.
+ https://commons.wikimedia.org/wiki/File:Negev_Brigade_soldiers_1948.jpg
+- Beersheba, 21 October 1948: brimmed bush hats, khaki shirts and shorts, belts. CC BY 4.0 (National Library of Israel).
+ https://commons.wikimedia.org/wiki/File:1948_Arab-Israeli_War_997008137085905171.jpg
+- An IDF soldier, about March 1948: khaki shirt and trousers, web belt, a Lee-Enfield rifle. CC BY 2.5 (PikiWiki).
+ https://commons.wikimedia.org/wiki/File:PikiWiki_Israel_38816_Israel_Defense_Forces.jpg
+
+Aircraft:
+- Israel bought 59 Spitfire Mk IXs from Czechoslovakia in 1948–49; IAF Spitfires fought in the 1948 war (the last air
+ combat was on 7 January 1949). https://en.wikipedia.org/wiki/Supermarine_Spitfire_operational_history
+- Ferry flights of the Czech Spitfires to Israel (Operation Velvetta, 1948). https://en.wikipedia.org/wiki/Operation_Velvetta
+- The Avia S-199 flew first, on 29 May 1948 (Operation Pleshet). https://en.wikipedia.org/wiki/Avia_S-199
+ The Spitfire was chosen over it because the promo shows a Spitfire (promo beats era, and both are 1948-correct).
+- Spitfire Mk IX shape (an elliptical wing, a four-blade propeller): the IAF Museum airframe at Hatzerim. CC BY 2.5.
+ https://commons.wikimedia.org/wiki/File:Spitfire-MkIX-hatzerim-1-1.jpg
+- Early IAF roundel: a blue Star of David on a white disc ringed in blue. Public domain.
+ https://commons.wikimedia.org/wiki/File:IAF_roundel_(early_variant).svg
+- **Unverified (single source: the promo):** the two-tone camouflage. The Czech Mk IXs were ex-RAF airframes, but no
+ source for the scheme they flew in Israel in 1948 has been checked yet. The museum airframe is bare metal in post-war
+ markings.
+
+Navy:
+- INS Haganah (K-20), ex-HMCS Norsyd, a modified Flower-class corvette, taken over and rearmed by the Israeli Navy in 1948.
+ The modified Flowers had an upright funnel. https://en.wikipedia.org/wiki/HMCS_Norsyd
+- Photograph of K-20 in Haifa harbour, 1948: light grey, mast at the bridge, funnel aft of it. Public domain.
+ https://commons.wikimedia.org/wiki/File:Hagana_K-20_ship_Israel.jpg
+- Photograph of INS Haganah, about 1949. Public domain. https://commons.wikimedia.org/wiki/File:INSHaganah.jpg
+
+The photographs are references only: no image file is copied into the repository.
diff --git a/unity/Assets/Editor/MapCapture.cs b/unity/Assets/Editor/MapCapture.cs
index e71272c51..cdfeba7e6 100644
--- a/unity/Assets/Editor/MapCapture.cs
+++ b/unity/Assets/Editor/MapCapture.cs
@@ -112,6 +112,7 @@ public static class MapCapture
int at = System.Array.IndexOf(args, "-captureDir");
var dir = at >= 0 && at + 1 < args.Length ? args[at + 1] : Path.Combine(CaptureDir, "visual", "editor");
var map = OpenAndBuild();
+ Statecraft.Game.Map.Units.UnitShowcase.Spawn(map, still: true); // the unit art slice, as the ?shot screenshots show it
var rig = Camera.main.GetComponent<CameraRig>();
int saved = QualitySettings.GetQualityLevel();
try
diff --git a/unity/Assets/Editor/UnitMaterialAssets.cs b/unity/Assets/Editor/UnitMaterialAssets.cs
new file mode 100644
index 000000000..d59ce27c0
--- /dev/null
+++ b/unity/Assets/Editor/UnitMaterialAssets.cs
@@ -0,0 +1,37 @@
+using Statecraft.Game.Map;
+using Statecraft.Game.Map.Units;
+using UnityEditor;
+using UnityEngine;
+
+namespace Statecraft.Game.EditorTools
+{
+ /// <summary>Creates the unit materials in Resources (UnitMaterials). Idempotent.
+ /// Run headless: Unity -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -executeMethod Statecraft.Game.EditorTools.UnitMaterialAssets.Create</summary>
+ public static class UnitMaterialAssets
+ {
+ public static void Create()
+ {
+ if (!AssetDatabase.IsValidFolder("Assets/Resources")) AssetDatabase.CreateFolder("Assets", "Resources");
+ if (!AssetDatabase.IsValidFolder(UnitMaterials.Folder)) AssetDatabase.CreateFolder("Assets/Resources", "Units");
+ // Painted miniatures: URP Lit, nearly matte (a satin varnish's faint sheen); the base map is set at runtime.
+ var paint = Make(UnitMaterials.MiniatureResource, "Universal Render Pipeline/Lit", Color.white);
+ paint.SetFloat("_Smoothness", 0.18f); paint.SetFloat("_Metallic", 0f);
+ EditorUtility.SetDirty(paint);
+ Make(UnitMaterials.RingResource, "Statecraft/HexSelection", MapScene.SelectionColour);
+ AssetDatabase.SaveAssets();
+ }
+
+ static Material Make(string resource, string shaderName, Color colour)
+ {
+ var path = "Assets/Resources/" + resource + ".mat";
+ var shader = Shader.Find(shaderName) ?? throw new System.InvalidOperationException($"shader not found: {shaderName}"); // editor only
+ var mat = AssetDatabase.LoadAssetAtPath<Material>(path);
+ if (mat == null) { mat = new Material(shader); AssetDatabase.CreateAsset(mat, path); }
+ else mat.shader = shader;
+ mat.enableInstancing = true;
+ mat.color = colour;
+ EditorUtility.SetDirty(mat);
+ return mat;
+ }
+ }
+}
diff --git a/unity/Assets/Editor/UnitMaterialAssets.cs.meta b/unity/Assets/Editor/UnitMaterialAssets.cs.meta
new file mode 100644
index 000000000..6ef9505dc
--- /dev/null
+++ b/unity/Assets/Editor/UnitMaterialAssets.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: aa8f9b50bd9534660b5eb293a3cc968c
\ No newline at end of file
diff --git a/unity/Assets/Resources.meta b/unity/Assets/Resources.meta
new file mode 100644
index 000000000..28bf40332
--- /dev/null
+++ b/unity/Assets/Resources.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a989701d41691425e87478ca5ad1c288
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/Units.meta b/unity/Assets/Resources/Units.meta
new file mode 100644
index 000000000..09a962aeb
--- /dev/null
+++ b/unity/Assets/Resources/Units.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b1e511bdf2dea41559949eb2dbc36321
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/Units/UnitMiniature.mat b/unity/Assets/Resources/Units/UnitMiniature.mat
new file mode 100644
index 000000000..b460aa709
--- /dev/null
+++ b/unity/Assets/Resources/Units/UnitMiniature.mat
@@ -0,0 +1,137 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &-3494563539334966472
+MonoBehaviour:
+ m_ObjectHideFlags: 11
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
+ version: 10
+--- !u!21 &2100000
+Material:
+ serializedVersion: 8
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: UnitMiniature
+ m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
+ m_Parent: {fileID: 0}
+ m_ModifiedSerializedProperties: 0
+ m_ValidKeywords: []
+ m_InvalidKeywords: []
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 1
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: -1
+ stringTagMap:
+ RenderType: Opaque
+ disabledShaderPasses:
+ - MOTIONVECTORS
+ m_LockedProperties:
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs:
+ - _BaseMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _BumpMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailAlbedoMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailMask:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailNormalMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _EmissionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MainTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MetallicGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _OcclusionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _ParallaxMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _SpecGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_Lightmaps:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_LightmapsInd:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_ShadowMasks:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ m_Ints: []
+ m_Floats:
+ - _AddPrecomputedVelocity: 0
+ - _AlphaClip: 0
+ - _AlphaToMask: 0
+ - _Blend: 0
+ - _BlendModePreserveSpecular: 1
+ - _BumpScale: 1
+ - _ClearCoatMask: 0
+ - _ClearCoatSmoothness: 0
+ - _Cull: 2
+ - _Cutoff: 0.5
+ - _DetailAlbedoMapScale: 1
+ - _DetailNormalMapScale: 1
+ - _DstBlend: 0
+ - _DstBlendAlpha: 0
+ - _EnvironmentReflections: 1
+ - _GlossMapScale: 0
+ - _Glossiness: 0
+ - _GlossyReflections: 0
+ - _Metallic: 0
+ - _OcclusionStrength: 1
+ - _Parallax: 0.005
+ - _QueueOffset: 0
+ - _ReceiveShadows: 1
+ - _Smoothness: 0.18
+ - _SmoothnessTextureChannel: 0
+ - _SpecularHighlights: 1
+ - _SrcBlend: 1
+ - _SrcBlendAlpha: 1
+ - _Surface: 0
+ - _WorkflowMode: 1
+ - _XRMotionVectorsPass: 1
+ - _ZWrite: 1
+ m_Colors:
+ - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
+ - _Color: {r: 1, g: 1, b: 1, a: 1}
+ - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+ - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
+ m_BuildTextureStacks: []
+ m_AllowLocking: 1
diff --git a/unity/Assets/Resources/Units/UnitMiniature.mat.meta b/unity/Assets/Resources/Units/UnitMiniature.mat.meta
new file mode 100644
index 000000000..be3796fc0
--- /dev/null
+++ b/unity/Assets/Resources/Units/UnitMiniature.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 022a0bb75fbd94fc58317b54ef6f6d9d
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/Units/UnitRing.mat b/unity/Assets/Resources/Units/UnitRing.mat
new file mode 100644
index 000000000..52f425a84
--- /dev/null
+++ b/unity/Assets/Resources/Units/UnitRing.mat
@@ -0,0 +1,31 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+ serializedVersion: 8
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: UnitRing
+ m_Shader: {fileID: 4800000, guid: 6e20d5043e2fd4f698101a4fd55cefaf, type: 3}
+ m_Parent: {fileID: 0}
+ m_ModifiedSerializedProperties: 0
+ m_ValidKeywords: []
+ m_InvalidKeywords: []
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 1
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: -1
+ stringTagMap: {}
+ disabledShaderPasses: []
+ m_LockedProperties:
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs: []
+ m_Ints: []
+ m_Floats: []
+ m_Colors:
+ - _BaseColor: {r: 1, g: 0.95, b: 0.8, a: 1}
+ m_BuildTextureStacks: []
+ m_AllowLocking: 1
diff --git a/unity/Assets/Resources/Units/UnitRing.mat.meta b/unity/Assets/Resources/Units/UnitRing.mat.meta
new file mode 100644
index 000000000..0058951ea
--- /dev/null
+++ b/unity/Assets/Resources/Units/UnitRing.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: e60c2b1a79a2a47b2b46baeb3e80c94b
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/Units.meta b/unity/Assets/Scripts/Map/Units.meta
new file mode 100644
index 000000000..a930d10b9
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: fd56de5c82fd34f4db903a1369d7247f
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/Units/MiniatureMesh.cs b/unity/Assets/Scripts/Map/Units/MiniatureMesh.cs
new file mode 100644
index 000000000..74fb6b53e
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/MiniatureMesh.cs
@@ -0,0 +1,203 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.Game.Map.Units
+{
+ /// <summary>Builds one painted-miniature mesh from code: lathed solids (limbs, torsos, hulls, fuselages), ellipsoids,
+ /// boxes, flat plates and thin wings, each placed by a matrix and painted with one <see cref="UnitPalette"/> slot. The
+ /// paint is a palette texture: u picks the slot's column, v the shading row (<see cref="Build"/>), so one URP Lit
+ /// material draws every unit and no texture file ships. Pure geometry: the same calls give the same mesh, vertex for
+ /// vertex (no randomness, no time).</summary>
+ public sealed class MiniatureMesh
+ {
+ readonly List<Vector3> verts = new List<Vector3>();
+ readonly List<Vector3> normals = new List<Vector3>();
+ readonly List<int> slots = new List<int>();
+ readonly List<float> shadeOverride = new List<float>(); // NaN: shade by height
+ readonly List<int> tris = new List<int>();
+
+ public int VertexCount => verts.Count;
+ public int TriangleCount => tris.Count / 3;
+
+ static Vector3 N(Matrix4x4 m, Vector3 n) => m.inverse.transpose.MultiplyVector(n).normalized;
+
+ int Add(Matrix4x4 m, Vector3 p, Vector3 n, int slot, float shade)
+ {
+ verts.Add(m.MultiplyPoint3x4(p)); normals.Add(N(m, n)); slots.Add(slot); shadeOverride.Add(shade);
+ return verts.Count - 1;
+ }
+
+ /// <summary>A solid of revolution about the local +Y axis: <paramref name="profile"/> lists (y, radius) from bottom to
+ /// top; an end with a radius above zero is closed with a flat cap. <paramref name="segments"/> around.</summary>
+ public MiniatureMesh Lathe(Matrix4x4 m, IReadOnlyList<Vector2> profile, int slot, int segments = 14, float shade = float.NaN)
+ {
+ if (profile.Count < 2) throw new ArgumentException("a lathe needs two profile points", nameof(profile));
+ int rings = profile.Count, start = verts.Count;
+ for (int i = 0; i < rings; i++)
+ {
+ // The profile's slope gives the normal's vertical part (central differences).
+ var a = profile[Math.Max(0, i - 1)]; var b = profile[Math.Min(rings - 1, i + 1)];
+ float dy = b.x - a.x, dr = b.y - a.y;
+ var side = new Vector2(dy, -dr).normalized; // (radial, vertical)
+ for (int s = 0; s <= segments; s++)
+ {
+ float ang = 2f * Mathf.PI * s / segments;
+ float c = Mathf.Cos(ang), sn = Mathf.Sin(ang);
+ Add(m, new Vector3(c * profile[i].y, profile[i].x, sn * profile[i].y), new Vector3(c * side.x, side.y, sn * side.x), slot, shade);
+ }
+ }
+ int stride = segments + 1;
+ for (int i = 0; i < rings - 1; i++)
+ for (int s = 0; s < segments; s++)
+ {
+ int a = start + i * stride + s, b = a + 1, c = a + stride, d = c + 1;
+ tris.AddRange(new[] { a, c, b, b, c, d });
+ }
+ if (profile[0].y > 0f) Cap(m, profile[0].x, profile[0].y, segments, slot, down: true, shade);
+ if (profile[rings - 1].y > 0f) Cap(m, profile[rings - 1].x, profile[rings - 1].y, segments, slot, down: false, shade);
+ return this;
+ }
+
+ void Cap(Matrix4x4 m, float y, float r, int segments, int slot, bool down, float shade)
+ {
+ var n = down ? Vector3.down : Vector3.up;
+ int centre = Add(m, new Vector3(0, y, 0), n, slot, shade);
+ int first = verts.Count;
+ for (int s = 0; s <= segments; s++)
+ {
+ float ang = 2f * Mathf.PI * s / segments;
+ Add(m, new Vector3(Mathf.Cos(ang) * r, y, Mathf.Sin(ang) * r), n, slot, shade);
+ }
+ for (int s = 0; s < segments; s++)
+ {
+ if (down) tris.AddRange(new[] { centre, first + s, first + s + 1 });
+ else tris.AddRange(new[] { centre, first + s + 1, first + s });
+ }
+ }
+
+ /// <summary>A tapered rod from <paramref name="a"/> to <paramref name="b"/> (limbs, barrels, masts), radius
+ /// <paramref name="ra"/> at a and <paramref name="rb"/> at b, rounded at both ends by half-spheres when
+ /// <paramref name="rounded"/>.</summary>
+ public MiniatureMesh Rod(Vector3 a, Vector3 b, float ra, float rb, int slot, int segments = 12, bool rounded = true, float shade = float.NaN)
+ {
+ var axis = b - a; float len = axis.magnitude;
+ if (len <= 0f) throw new ArgumentException("a rod needs two distinct ends");
+ var m = Matrix4x4.TRS(a, Quaternion.FromToRotation(Vector3.up, axis / len), Vector3.one);
+ var profile = new List<Vector2>();
+ if (rounded)
+ {
+ for (int k = 0; k <= 3; k++) { float t = -Mathf.PI / 2 + k * Mathf.PI / 6; profile.Add(new Vector2(ra * Mathf.Sin(t), ra * Mathf.Cos(t))); }
+ for (int k = 0; k <= 3; k++) { float t = k * Mathf.PI / 6; profile.Add(new Vector2(len + rb * Mathf.Sin(t), rb * Mathf.Cos(t))); }
+ profile[0] = new Vector2(profile[0].x, 0f); profile[profile.Count - 1] = new Vector2(profile[profile.Count - 1].x, 0f);
+ }
+ else { profile.Add(new Vector2(0f, ra)); profile.Add(new Vector2(len, rb)); }
+ return Lathe(m, profile, slot, segments, shade);
+ }
+
+ /// <summary>A unit sphere placed by <paramref name="m"/> (its scale gives the three radii).</summary>
+ public MiniatureMesh Ellipsoid(Matrix4x4 m, int slot, int segments = 14, int rings = 8, float shade = float.NaN)
+ {
+ var profile = new List<Vector2>(rings + 1);
+ for (int i = 0; i <= rings; i++) { float t = -Mathf.PI / 2 + Mathf.PI * i / rings; profile.Add(new Vector2(Mathf.Sin(t), Mathf.Cos(t))); }
+ profile[0] = new Vector2(-1f, 0f); profile[rings] = new Vector2(1f, 0f);
+ return Lathe(m, profile, slot, segments, shade);
+ }
+
+ /// <summary>A unit cube centred on the origin, placed by <paramref name="m"/>, flat-shaded.</summary>
+ public MiniatureMesh Box(Matrix4x4 m, int slot, float shade = float.NaN)
+ {
+ for (int f = 0; f < 6; f++)
+ {
+ var n = f switch { 0 => Vector3.right, 1 => Vector3.left, 2 => Vector3.up, 3 => Vector3.down, 4 => Vector3.forward, _ => Vector3.back };
+ var u = Mathf.Abs(n.y) > 0.5f ? Vector3.right : Vector3.up;
+ var v = Vector3.Cross(n, u);
+ int b0 = verts.Count;
+ foreach (var (su, sv) in new[] { (-1, -1), (1, -1), (1, 1), (-1, 1) })
+ Add(m, 0.5f * (n + su * u + sv * v), n, slot, shade);
+ tris.AddRange(new[] { b0, b0 + 1, b0 + 2, b0, b0 + 2, b0 + 3 });
+ }
+ return this;
+ }
+
+ /// <summary>A flat two-sided polygon (a roundel, a star) in the local XZ plane, placed by <paramref name="m"/>;
+ /// <paramref name="outline"/> is convex or a fan from its first point.</summary>
+ public MiniatureMesh Plate(Matrix4x4 m, IReadOnlyList<Vector2> outline, int slot, float shade = float.NaN)
+ {
+ foreach (var side in new[] { 1, -1 })
+ {
+ int b0 = verts.Count;
+ foreach (var p in outline) Add(m, new Vector3(p.x, 0f, p.y), Vector3.up * side, slot, shade);
+ for (int i = 1; i < outline.Count - 1; i++)
+ tris.AddRange(side > 0 ? new[] { b0, b0 + i + 1, b0 + i } : new[] { b0, b0 + i, b0 + i + 1 });
+ }
+ return this;
+ }
+
+ /// <summary>A thin lifting surface along local +X (span) with chord along Z: the leading edge at z = +lead(s), the
+ /// trailing edge at z = -trail(s) for s in [0, 1] from root to tip, thickness <paramref name="thickness"/> times the
+ /// local chord. <paramref name="topSlot"/> paints each upper panel (by its span and chord index), the lower surface is
+ /// <paramref name="bottomSlot"/>. Flat-shaded panels, so the camouflage reads as painted patches.</summary>
+ public MiniatureMesh Wing(Matrix4x4 m, Func<float, float> lead, Func<float, float> trail, float span, float thickness,
+ Func<int, int, int> topSlot, int bottomSlot, int spanSteps = 8, int chordSteps = 3)
+ {
+ Vector3 P(int i, int j, float side)
+ {
+ float s = (float)i / spanSteps, x = s * span;
+ float le = lead(s), te = -trail(s), t = (float)j / chordSteps;
+ float z = Mathf.Lerp(le, te, t), chord = le - te;
+ float camber = Mathf.Sin(Mathf.PI * t) * thickness * chord;
+ return new Vector3(x, side * camber, z);
+ }
+ for (int i = 0; i < spanSteps; i++)
+ for (int j = 0; j < chordSteps; j++)
+ {
+ Quad(m, P(i, j, 1), P(i + 1, j, 1), P(i + 1, j + 1, 1), P(i, j + 1, 1), topSlot(i, j), up: true);
+ Quad(m, P(i, j, -1), P(i, j + 1, -1), P(i + 1, j + 1, -1), P(i + 1, j, -1), bottomSlot, up: false);
+ }
+ return this;
+ }
+
+ void Quad(Matrix4x4 m, Vector3 a, Vector3 b, Vector3 c, Vector3 d, int slot, bool up)
+ {
+ var n = Vector3.Cross(c - a, b - a).normalized;
+ if (n.sqrMagnitude < 0.5f) n = up ? Vector3.up : Vector3.down;
+ if (up && n.y < 0f || !up && n.y > 0f) n = -n;
+ int b0 = verts.Count;
+ Add(m, a, n, slot, float.NaN); Add(m, b, n, slot, float.NaN); Add(m, c, n, slot, float.NaN); Add(m, d, n, slot, float.NaN);
+ tris.AddRange(new[] { b0, b0 + 1, b0 + 2, b0, b0 + 2, b0 + 3 }); // Build orients it
+ }
+
+ /// <summary>The mesh. Each vertex's v is its shade row: by default its height within the whole model (0 at the lowest
+ /// vertex, 1 at the highest), so the palette darkens feet and lifts shoulders like a painted miniature's wash and
+ /// highlight; a part built with an explicit shade keeps it. Every triangle is wound here to face along its vertices'
+ /// normals (Unity's front face: Cross(p1 - p0, p2 - p0) points out), so the builders above need not track winding
+ /// through mirrored or rotated matrices.</summary>
+ public Mesh Build(string name)
+ {
+ float lo = float.MaxValue, hi = float.MinValue;
+ foreach (var p in verts) { lo = Mathf.Min(lo, p.y); hi = Mathf.Max(hi, p.y); }
+ float range = Mathf.Max(hi - lo, 1e-6f);
+ var uv = new List<Vector2>(verts.Count);
+ for (int i = 0; i < verts.Count; i++)
+ {
+ float v = float.IsNaN(shadeOverride[i]) ? (verts[i].y - lo) / range : shadeOverride[i];
+ uv.Add(new Vector2(UnitPalette.U(slots[i]), Mathf.Clamp01(v)));
+ }
+ var flipped = new int[tris.Count];
+ for (int i = 0; i < tris.Count; i += 3)
+ {
+ int a = tris[i], b = tris[i + 1], c = tris[i + 2];
+ var face = Vector3.Cross(verts[b] - verts[a], verts[c] - verts[a]);
+ bool keep = Vector3.Dot(face, normals[a] + normals[b] + normals[c]) >= 0f;
+ flipped[i] = a; flipped[i + 1] = keep ? b : c; flipped[i + 2] = keep ? c : b;
+ }
+ var mesh = new Mesh { name = name };
+ if (verts.Count > 65535) mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
+ mesh.SetVertices(verts); mesh.SetNormals(normals); mesh.SetUVs(0, uv); mesh.SetTriangles(flipped, 0);
+ mesh.RecalculateBounds();
+ return mesh;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/Units/MiniatureMesh.cs.meta b/unity/Assets/Scripts/Map/Units/MiniatureMesh.cs.meta
new file mode 100644
index 000000000..f97c4a9c6
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/MiniatureMesh.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: d7ffd0db4f52647bfa2537a13b749c09
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/Units/ShowcaseFlight.cs b/unity/Assets/Scripts/Map/Units/ShowcaseFlight.cs
new file mode 100644
index 000000000..0037bf5c3
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/ShowcaseFlight.cs
@@ -0,0 +1,37 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.Game.Map.Units
+{
+ /// <summary>Flies its object round a horizontal circle, banked into the turn, nose along the path; turns the propeller.
+ /// With a still phase it holds that point (and the propeller its angle), so screenshots repeat exactly.</summary>
+ public sealed class ShowcaseFlight : MonoBehaviour
+ {
+ Vector3 centre; float radius, altitude, seconds, bank; Transform? propeller; float? still;
+
+ public void Configure(Vector3 centre, float radius, float altitude, float seconds, float bank, Transform propeller, float? stillPhase)
+ {
+ this.centre = centre; this.radius = radius; this.altitude = altitude; this.seconds = seconds; this.bank = bank;
+ this.propeller = propeller; still = stillPhase;
+ Place(still ?? 0f);
+ }
+
+ public float? StillPhase => still;
+
+ void Update()
+ {
+ if (still.HasValue) return;
+ Place(Time.time / seconds % 1f);
+ if (propeller != null) propeller.localRotation = Quaternion.Euler(0, 0, -Time.time * 1500f);
+ }
+
+ /// <summary>Puts the aircraft at phase <paramref name="t"/> (0..1) of the loop, flying anticlockwise seen from above.</summary>
+ public void Place(float t)
+ {
+ float a = 2f * Mathf.PI * t;
+ var pos = centre + new Vector3(Mathf.Cos(a), 0, Mathf.Sin(a)) * radius; pos.y = altitude;
+ var forward = new Vector3(-Mathf.Sin(a), 0, Mathf.Cos(a));
+ transform.SetPositionAndRotation(pos, Quaternion.LookRotation(forward, Vector3.up) * Quaternion.Euler(0, 0, bank));
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/Units/ShowcaseFlight.cs.meta b/unity/Assets/Scripts/Map/Units/ShowcaseFlight.cs.meta
new file mode 100644
index 000000000..27af9a27c
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/ShowcaseFlight.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 1e0b9f9fcc7494d1c8829504533e748e
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/Units/UnitMaterials.cs b/unity/Assets/Scripts/Map/Units/UnitMaterials.cs
new file mode 100644
index 000000000..e65fe9603
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/UnitMaterials.cs
@@ -0,0 +1,13 @@
+namespace Statecraft.Game.Map.Units
+{
+ /// <summary>Where the unit materials live: in Resources, so the showcase loads them in players without Shader.Find
+ /// (M0 correction 1) and without a new serialized field on MapScene. Made by the editor's UnitMaterialAssets.Create.</summary>
+ public static class UnitMaterials
+ {
+ public const string Folder = "Assets/Resources/Units";
+ /// <summary>Matte URP Lit; the showcase sets its palette texture on a runtime copy.</summary>
+ public const string MiniatureResource = "Units/UnitMiniature";
+ /// <summary>The selection ring: the hex selection's own shader (unlit ivory, depth offset towards the camera).</summary>
+ public const string RingResource = "Units/UnitRing";
+ }
+}
diff --git a/unity/Assets/Scripts/Map/Units/UnitMaterials.cs.meta b/unity/Assets/Scripts/Map/Units/UnitMaterials.cs.meta
new file mode 100644
index 000000000..a3455bf73
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/UnitMaterials.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3053f45e200f04224a4810c0a6471d42
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/Units/UnitModels.cs b/unity/Assets/Scripts/Map/Units/UnitModels.cs
new file mode 100644
index 000000000..741928a37
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/UnitModels.cs
@@ -0,0 +1,229 @@
+#nullable enable
+using System.Collections.Generic;
+using UnityEngine;
+using P = Statecraft.Game.Map.Units.UnitPalette;
+
+namespace Statecraft.Game.Map.Units
+{
+ /// <summary>The unit miniatures, built in real metres (a man 1.78 m tall, the Spitfire's 11.2 m span, the corvette's
+ /// 62.5 m hull) and scaled up to the map's symbolic scale by <see cref="UnitShowcase"/>. Each model faces +Z with its
+ /// origin on the ground (the aircraft: its centre of gravity). References and their check dates: docs/units.md.
+ /// Rifles, straps and hat brims are thicker than real so they survive at 60 km (a painted miniature's exaggeration).</summary>
+ public static class UnitModels
+ {
+ public enum Headgear { SteelHelmet, SlouchHat, WoolCap }
+ public enum RiflePose { Ready, Slung, Grounded }
+
+ static Matrix4x4 T(float x, float y, float z) => Matrix4x4.Translate(new Vector3(x, y, z));
+ static Matrix4x4 TRS(Vector3 p, Vector3 euler, Vector3 s) => Matrix4x4.TRS(p, Quaternion.Euler(euler), s);
+ static Vector3 V(float x, float y, float z) => new Vector3(x, y, z);
+
+ /// <summary>A 1948 IDF rifleman (sources in docs/units.md): khaki drill shirt and trousers, a 37-pattern web belt with
+ /// two basic pouches and a brace, short anklets over boots, a No. 1 / No. 4 Lee-Enfield or a Czech Mauser (one long
+ /// rifle shape serves both at this scale), and one of the three headgear the 1948 photographs show.</summary>
+ public static Mesh Rifleman(Headgear hat, RiflePose pose, bool fadedShirt, string name)
+ {
+ var m = new MiniatureMesh();
+ int shirt = fadedShirt ? P.ShirtFaded : P.Shirt;
+ // Legs (trousers), anklets and boots; a slight stance.
+ foreach (var side in new[] { -1f, 1f })
+ {
+ float x = side * 0.105f;
+ m.Rod(V(x, 0.93f, 0f), V(x * 1.15f, 0.16f, 0.01f), 0.085f, 0.06f, P.Trousers);
+ m.Rod(V(x * 1.15f, 0.20f, 0.01f), V(x * 1.15f, 0.09f, 0.01f), 0.065f, 0.062f, P.Webbing, rounded: false);
+ m.Ellipsoid(TRS(V(x * 1.15f, 0.05f, 0.05f), Vector3.zero, V(0.06f, 0.05f, 0.13f)), P.Boots);
+ }
+ // Hips and torso (shirt), flattened front to back.
+ m.Lathe(Matrix4x4.Scale(V(1f, 1f, 0.68f)), new List<Vector2> { new Vector2(0.86f, 0.17f), new Vector2(1.00f, 0.165f),
+ new Vector2(1.22f, 0.175f), new Vector2(1.40f, 0.19f), new Vector2(1.47f, 0.13f), new Vector2(1.50f, 0.05f) }, shirt, 12);
+ // Web belt with two pouches, and a brace across the chest.
+ m.Lathe(Matrix4x4.Scale(V(1f, 1f, 0.70f)), new List<Vector2> { new Vector2(0.97f, 0.178f), new Vector2(1.04f, 0.178f) }, P.Webbing, 12);
+ foreach (var side in new[] { -1f, 1f })
+ m.Box(TRS(V(side * 0.085f, 1.06f, 0.125f), V(0, side * 12f, 0), V(0.10f, 0.11f, 0.05f)), P.Webbing);
+ m.Box(TRS(V(0f, 1.24f, 0.0f), V(0, 0, 38f), V(0.05f, 0.62f, 0.27f)), P.Webbing);
+ // Neck, head, hair.
+ m.Rod(V(0, 1.47f, 0), V(0, 1.56f, 0.01f), 0.05f, 0.05f, P.Skin, rounded: false);
+ m.Ellipsoid(TRS(V(0, 1.65f, 0.01f), Vector3.zero, V(0.105f, 0.125f, 0.115f)), P.Skin); // a miniature's slightly large head
+ switch (hat)
+ {
+ case Headgear.SteelHelmet: // British Mk II: a shallow bowl with a wide flat brim
+ m.Ellipsoid(TRS(V(0, 1.72f, 0.01f), Vector3.zero, V(0.13f, 0.08f, 0.14f)), P.Helmet);
+ m.Lathe(T(0, 1.70f, 0.01f), new List<Vector2> { new Vector2(0f, 0.20f), new Vector2(0.018f, 0.19f) }, P.Helmet, 14);
+ break;
+ case Headgear.SlouchHat: // the brimmed bush hat of the 1948 Negev photographs
+ m.Lathe(T(0, 1.71f, 0.01f), new List<Vector2> { new Vector2(0f, 0.11f), new Vector2(0.08f, 0.10f), new Vector2(0.12f, 0.07f) }, P.SlouchHat, 12);
+ m.Lathe(TRS(V(0, 1.715f, 0.01f), V(0, 0, -8f), Vector3.one), new List<Vector2> { new Vector2(0f, 0.22f), new Vector2(0.016f, 0.215f) }, P.SlouchHat, 14);
+ break;
+ default: // the Palmach's knitted stocking cap
+ m.Ellipsoid(TRS(V(0, 1.71f, 0.0f), V(-10f, 0, 0), V(0.105f, 0.085f, 0.115f)), P.WoolCap);
+ break;
+ }
+ m.Ellipsoid(TRS(V(0, 1.66f, -0.035f), Vector3.zero, V(0.09f, 0.08f, 0.08f)), P.Hair);
+ // Arms and the rifle, by pose.
+ var shoulderL = V(-0.20f, 1.40f, 0f); var shoulderR = V(0.20f, 1.40f, 0f);
+ switch (pose)
+ {
+ case RiflePose.Ready: // held across the body, muzzle up and forward to the left (the promo's lead figure)
+ {
+ var handR = V(0.08f, 1.08f, 0.24f); var handL = V(-0.16f, 1.30f, 0.28f);
+ Arm(m, shoulderR, V(0.22f, 1.16f, 0.10f), handR, shirt);
+ Arm(m, shoulderL, V(-0.26f, 1.16f, 0.16f), handL, shirt);
+ Rifle(m, V(0.20f, 0.92f, 0.20f), V(-0.42f, 1.62f, 0.36f));
+ break;
+ }
+ case RiflePose.Slung: // rifle on the right shoulder by its sling, arms relaxed
+ {
+ Arm(m, shoulderL, V(-0.25f, 1.12f, 0.02f), V(-0.24f, 0.88f, 0.06f), shirt);
+ Arm(m, shoulderR, V(0.25f, 1.15f, 0.06f), V(0.21f, 1.30f, 0.14f), shirt);
+ Rifle(m, V(0.24f, 0.72f, -0.10f), V(0.24f, 1.82f, -0.02f));
+ break;
+ }
+ default: // butt on the ground at the right foot, hand at the muzzle
+ {
+ Arm(m, shoulderL, V(-0.25f, 1.12f, 0.02f), V(-0.24f, 0.88f, 0.05f), shirt);
+ Arm(m, shoulderR, V(0.27f, 1.14f, 0.04f), V(0.30f, 1.02f, 0.12f), shirt);
+ Rifle(m, V(0.31f, 0.05f, 0.16f), V(0.30f, 1.14f, 0.13f));
+ break;
+ }
+ }
+ return m.Build(name);
+ }
+
+ static void Arm(MiniatureMesh m, Vector3 shoulder, Vector3 elbow, Vector3 hand, int sleeve)
+ {
+ m.Ellipsoid(TRS(shoulder, Vector3.zero, V(0.08f, 0.08f, 0.08f)), sleeve);
+ m.Rod(shoulder, elbow, 0.062f, 0.052f, sleeve);
+ m.Rod(elbow, hand, 0.05f, 0.04f, P.Skin);
+ m.Ellipsoid(TRS(hand, Vector3.zero, V(0.045f, 0.05f, 0.045f)), P.Skin);
+ }
+
+ /// <summary>A long service rifle from butt to muzzle: a wooden stock and fore-end with the barrel's last part bare.</summary>
+ static void Rifle(MiniatureMesh m, Vector3 butt, Vector3 muzzle)
+ {
+ var wood = Vector3.Lerp(butt, muzzle, 0.86f);
+ m.Rod(butt, Vector3.Lerp(butt, muzzle, 0.30f), 0.05f, 0.035f, P.RifleWood, segments: 6);
+ m.Rod(Vector3.Lerp(butt, muzzle, 0.28f), wood, 0.032f, 0.028f, P.RifleWood, segments: 6);
+ m.Rod(Vector3.Lerp(butt, muzzle, 0.34f), muzzle, 0.016f, 0.014f, P.RifleMetal, segments: 5);
+ }
+
+ /// <summary>A Supermarine Spitfire LF Mk IX as the IAF flew it in 1948 (sources in docs/units.md): 11.23 m elliptical
+ /// wing, 9.47 m fuselage, four-blade propeller, two-tone camouflage over a light underside, and the early IAF roundel
+ /// (a blue Star of David on a white disc ringed in blue) on the wings and fuselage. The propeller is a separate mesh
+ /// (<see cref="SpitfirePropeller"/>) so it can turn. Faces +Z, centre of gravity at the origin.</summary>
+ public static Mesh Spitfire(string name)
+ {
+ var m = new MiniatureMesh();
+ // Fuselage: a lathe along Z, taller than wide.
+ var body = new List<Vector2> { new Vector2(-6.2f, 0.06f), new Vector2(-5.2f, 0.28f), new Vector2(-3.0f, 0.52f), new Vector2(-1.0f, 0.68f),
+ new Vector2(1.0f, 0.72f), new Vector2(2.4f, 0.66f), new Vector2(3.0f, 0.50f) };
+ m.Lathe(TRS(Vector3.zero, V(90f, 0, 0), V(0.78f, 1f, 1.05f)), body, P.CamoGreen, 12);
+ m.Lathe(TRS(V(0, -0.22f, 0), V(90f, 0, 0), V(0.62f, 1f, 0.72f)), new List<Vector2> { new Vector2(-2.6f, 0.2f), new Vector2(-1.0f, 0.62f),
+ new Vector2(1.6f, 0.62f), new Vector2(2.6f, 0.42f) }, P.Underside, 12);
+ // Spinner.
+ m.Lathe(TRS(V(0, 0.02f, 3.0f), V(90f, 0, 0), Vector3.one), new List<Vector2> { new Vector2(0f, 0.36f), new Vector2(0.45f, 0.26f), new Vector2(0.75f, 0f) }, P.PropBlack, 10);
+ // Canopy.
+ m.Ellipsoid(TRS(V(0, 0.68f, -0.4f), Vector3.zero, V(0.34f, 0.32f, 1.0f)), P.Glass);
+ // Elliptical wing: semi-span 5.6 m, root chord 2.5 m, low on the fuselage, with a 6 degree dihedral.
+ float semi = 5.6f;
+ System.Func<float, float> lead = s => 1.05f * Mathf.Sqrt(Mathf.Max(0f, 1f - s * s)) + 0.04f;
+ System.Func<float, float> trail = s => 1.45f * Mathf.Sqrt(Mathf.Max(0f, 1f - s * s)) + 0.04f;
+ // Disruptive camouflage: two smooth waves across span and chord give irregular patches, not a chequerboard.
+ System.Func<int, int, int> camo = (i, j) => Mathf.Sin(i * 0.9f + j * 1.7f) + Mathf.Sin(i * 0.37f - j * 2.3f + 1.1f) > 0.2f ? P.CamoGreen : P.CamoGrey;
+ foreach (var side in new[] { 1f, -1f })
+ {
+ var w = TRS(V(side * 0.4f, -0.38f, 0.3f), V(0, 0, side * 6f), V(side, 1f, 1f));
+ m.Wing(w, lead, trail, semi, 0.06f, camo, P.Underside, spanSteps: 12, chordSteps: 4);
+ // Wing roundel near the tip, on top and below.
+ var rp = w.MultiplyPoint3x4(V(semi * 0.66f, 0.12f, -0.15f));
+ Roundel(m, TRS(rp, V(0, 0, side * 6f), Vector3.one), 0.62f);
+ Roundel(m, TRS(rp - V(0, 0.24f, 0), V(0, 0, side * 6f), Vector3.one), 0.62f);
+ // Tailplane: small ellipses.
+ var tp = TRS(V(side * 0.2f, 0.1f, -5.6f), Vector3.zero, V(side, 1f, 1f));
+ m.Wing(tp, s => 0.45f * Mathf.Sqrt(Mathf.Max(0f, 1f - s * s)) + 0.02f, s => 0.55f * Mathf.Sqrt(Mathf.Max(0f, 1f - s * s)) + 0.02f,
+ 1.55f, 0.05f, (i, j) => (i + j) % 3 == 0 ? P.CamoGreen : P.CamoGrey, P.Underside, spanSteps: 5, chordSteps: 2);
+ // Fuselage roundel.
+ Roundel(m, TRS(V(side * 0.58f, 0.15f, -2.6f), V(0, 0, side * 90f), Vector3.one), 0.48f);
+ // Radiator under each wing.
+ m.Box(TRS(V(side * 1.7f, -0.62f, 0.0f), Vector3.zero, V(0.42f, 0.28f, 1.3f)), P.Underside);
+ }
+ // Fin and rudder: the elliptic Spitfire fin, a vertical surface.
+ m.Wing(TRS(V(0, 0.4f, -5.5f), V(0, 0, 90f), Vector3.one), s => 0.55f * Mathf.Sqrt(Mathf.Max(0f, 1f - s * s)) + 0.05f,
+ s => 0.75f * Mathf.Sqrt(Mathf.Max(0f, 1f - s * s)) + 0.05f, 1.55f, 0.05f, (i, j) => i % 2 == 0 ? P.CamoGreen : P.CamoGrey, P.CamoGrey,
+ spanSteps: 5, chordSteps: 2);
+ return m.Build(name);
+ }
+
+ /// <summary>The Spitfire's four-blade propeller, centred on its hub; turns about +Z. Placed at
+ /// <see cref="SpitfirePropellerHub"/> in the aircraft's frame.</summary>
+ public static Mesh SpitfirePropeller(string name)
+ {
+ var m = new MiniatureMesh();
+ for (int b = 0; b < 4; b++)
+ {
+ var dir = Quaternion.Euler(0, 0, 90f * b + 20f) * Vector3.up;
+ m.Rod(dir * 0.2f, dir * 1.6f, 0.13f, 0.08f, P.PropBlack, segments: 5, shade: 0.8f);
+ }
+ return m.Build(name);
+ }
+
+ public static readonly Vector3 SpitfirePropellerHub = new Vector3(0f, 0.02f, 3.55f);
+
+ /// <summary>The early IAF roundel: a blue ring, a white disc and a blue six-pointed star of two triangles, stacked a
+ /// hair apart so they never z-fight; its plane is the local XZ, facing +Y.</summary>
+ static void Roundel(MiniatureMesh m, Matrix4x4 at, float radius)
+ {
+ m.Plate(at, Circle(radius, 20), P.RoundelBlue, shade: 0.8f);
+ m.Plate(at * T(0, 0.012f, 0), Circle(radius * 0.86f, 20), P.RoundelWhite, shade: 0.8f);
+ for (int k = 0; k < 2; k++)
+ {
+ var tri = new List<Vector2>();
+ for (int i = 0; i < 3; i++)
+ {
+ float a = Mathf.Deg2Rad * (90f + 60f * k + 120f * i);
+ tri.Add(new Vector2(Mathf.Cos(a), Mathf.Sin(a)) * radius * 0.74f);
+ }
+ m.Plate(at * T(0, 0.024f + 0.002f * k, 0), tri, P.RoundelBlue, shade: 0.8f);
+ }
+ }
+
+ static List<Vector2> Circle(float r, int n)
+ {
+ var pts = new List<Vector2>(n);
+ for (int i = 0; i < n; i++) { float a = 2f * Mathf.PI * i / n; pts.Add(new Vector2(Mathf.Cos(a), Mathf.Sin(a)) * r); }
+ return pts;
+ }
+
+ /// <summary>A modified Flower-class corvette as the Israeli Navy commissioned it in 1948 (INS Haganah, K-20, ex-HMCS
+ /// Norsyd; sources in docs/units.md): a 62.5 m hull with a raised forecastle, a bridge, one tall funnel, a mast and a
+ /// single gun forward. Origin at the waterline amidships, bow towards +Z.</summary>
+ public static Mesh Corvette(string name)
+ {
+ var m = new MiniatureMesh();
+ // Hull: a lathe along Z, flattened into a hull section, its keel below the waterline (hidden by the sea).
+ var hull = new List<Vector2> { new Vector2(-31f, 1.2f), new Vector2(-26f, 4.2f), new Vector2(-10f, 5.0f), new Vector2(8f, 5.0f),
+ new Vector2(20f, 4.0f), new Vector2(28f, 2.0f), new Vector2(31.2f, 0.2f) };
+ m.Lathe(TRS(V(0, 0.6f, 0), V(90f, 0, 0), V(1f, 1f, 0.95f)), hull, P.HullGrey, 14, shade: 0.75f);
+ m.Lathe(TRS(V(0, -0.2f, 0), V(90f, 0, 0), V(1.01f, 1f, 0.55f)), hull, P.Waterline, 14, shade: 0.5f);
+ // Decks: main deck and raised forecastle.
+ m.Box(TRS(V(0, 4.5f, -4f), Vector3.zero, V(8.6f, 0.4f, 46f)), P.Deck, shade: 0.8f);
+ m.Box(TRS(V(0, 5.6f, 17f), Vector3.zero, V(8.0f, 2.2f, 18f)), P.HullGrey, shade: 0.8f);
+ // Bridge and wheelhouse.
+ m.Box(TRS(V(0, 8.2f, 5.5f), Vector3.zero, V(6.2f, 4.0f, 6.0f)), P.HullGrey, shade: 0.9f);
+ m.Box(TRS(V(0, 10.8f, 6.0f), Vector3.zero, V(7.2f, 1.2f, 4.0f)), P.HullGrey, shade: 1f);
+ // Funnel, with a dark cap: upright, as the modified Flowers had it (the 1948 photograph shows it so).
+ m.Lathe(TRS(V(0, 5f, -3.5f), Vector3.zero, V(1f, 1f, 1.35f)), new List<Vector2> { new Vector2(0f, 1.9f), new Vector2(7.0f, 1.8f) }, P.HullGrey, 12, shade: 0.95f);
+ m.Lathe(TRS(V(0, 5f, -3.5f), Vector3.zero, V(1f, 1f, 1.35f)), new List<Vector2> { new Vector2(7.0f, 1.82f), new Vector2(7.8f, 1.82f) }, P.Funnel, 12, shade: 1f);
+ // Mast with a yard.
+ m.Rod(V(0, 11.4f, 4.0f), V(0, 21f, 3.2f), 0.30f, 0.18f, P.Funnel, segments: 6, shade: 1f);
+ m.Rod(V(-3.2f, 18f, 3.4f), V(3.2f, 18f, 3.4f), 0.14f, 0.14f, P.Funnel, segments: 5, shade: 1f);
+ // The forward gun: a shield and a barrel.
+ m.Box(TRS(V(0, 7.6f, 20f), Vector3.zero, V(2.4f, 1.8f, 2.0f)), P.HullGrey, shade: 0.95f);
+ m.Rod(V(0, 7.8f, 20.8f), V(0, 8.4f, 25.5f), 0.22f, 0.18f, P.Funnel, segments: 6, shade: 0.9f);
+ // Boats and depth-charge rails aft (small boxes, they read as deck clutter).
+ foreach (var side in new[] { -1f, 1f })
+ m.Box(TRS(V(side * 3.2f, 6.2f, -10f), Vector3.zero, V(1.4f, 1.0f, 5.5f)), P.RoundelWhite, shade: 0.85f);
+ m.Box(TRS(V(0, 5.2f, -26f), Vector3.zero, V(5f, 0.8f, 3f)), P.Funnel, shade: 0.8f);
+ return m.Build(name);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/Units/UnitModels.cs.meta b/unity/Assets/Scripts/Map/Units/UnitModels.cs.meta
new file mode 100644
index 000000000..4504fe008
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/UnitModels.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: a3a55aabdca7b46e1be81803a2efe34b
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/Units/UnitPalette.cs b/unity/Assets/Scripts/Map/Units/UnitPalette.cs
new file mode 100644
index 000000000..dcb31ae36
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/UnitPalette.cs
@@ -0,0 +1,80 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.Game.Map.Units
+{
+ /// <summary>The paint pots of the unit miniatures: one column per slot, one row per shade. The colours follow the
+ /// references cited in docs/units.md (1948 IDF khaki drill and British 37-pattern webbing; RAF day-fighter camouflage on
+ /// the Czech-supplied Spitfire LF.IX; the early IAF roundel; Royal Canadian Navy grey on the ex-RCN corvettes), pushed
+ /// a little warmer and lighter than the photographs so they read at map scale under the warm grade, as the promo's
+ /// painted figures do. The texture is made at runtime (no file ships), owned by the map.</summary>
+ public static class UnitPalette
+ {
+ public const int Skin = 0, Shirt = 1, Trousers = 2, Webbing = 3, Helmet = 4, SlouchHat = 5, WoolCap = 6, Boots = 7,
+ RifleWood = 8, RifleMetal = 9, Hair = 10, ShirtFaded = 11,
+ CamoGrey = 12, CamoGreen = 13, Underside = 14, RoundelWhite = 15, RoundelBlue = 16, PropBlack = 17, Glass = 18,
+ HullGrey = 19, Deck = 20, Waterline = 21, Funnel = 22, Count = 23;
+
+ /// <summary>Texels per slot along u: the sample at a slot's centre never reaches its neighbours (bilinear, no mips).</summary>
+ public const int SlotWidth = 4, Rows = 32;
+
+ static readonly Color[] Base =
+ {
+ new Color(0.80f, 0.60f, 0.46f), // Skin: sun-tanned
+ new Color(0.74f, 0.63f, 0.42f), // Shirt: khaki drill
+ new Color(0.47f, 0.40f, 0.28f), // Trousers: khaki drill, darker and dustier (the photographs' trousers read darker than the shirts)
+ new Color(0.86f, 0.80f, 0.62f), // Webbing: 37-pattern, pale
+ new Color(0.30f, 0.31f, 0.22f), // Helmet: Mk II steel helmet, dark olive
+ new Color(0.60f, 0.49f, 0.33f), // SlouchHat: khaki felt
+ new Color(0.36f, 0.33f, 0.27f), // WoolCap: knitted stocking cap, dark
+ new Color(0.20f, 0.14f, 0.10f), // Boots
+ new Color(0.45f, 0.28f, 0.16f), // RifleWood
+ new Color(0.20f, 0.20f, 0.21f), // RifleMetal
+ new Color(0.17f, 0.13f, 0.10f), // Hair
+ new Color(0.80f, 0.71f, 0.50f), // ShirtFaded: sun-bleached khaki
+ new Color(0.47f, 0.50f, 0.50f), // CamoGrey: ocean grey
+ new Color(0.27f, 0.32f, 0.22f), // CamoGreen: dark green
+ new Color(0.68f, 0.71f, 0.72f), // Underside: medium sea grey
+ new Color(0.95f, 0.95f, 0.93f), // RoundelWhite
+ new Color(0.07f, 0.17f, 0.45f), // RoundelBlue
+ new Color(0.08f, 0.08f, 0.08f), // PropBlack
+ new Color(0.20f, 0.26f, 0.30f), // Glass: canopy
+ new Color(0.56f, 0.59f, 0.60f), // HullGrey
+ new Color(0.48f, 0.46f, 0.42f), // Deck
+ new Color(0.12f, 0.12f, 0.13f), // Waterline
+ new Color(0.30f, 0.31f, 0.32f), // Funnel top
+ };
+
+ public static Color Colour(int slot) => Base[slot];
+
+ /// <summary>u of a slot's column centre.</summary>
+ public static float U(int slot) => (slot * SlotWidth + SlotWidth * 0.5f) / (Count * SlotWidth);
+
+ /// <summary>The paint at shade row v (0 at the model's lowest point, 1 at its highest): a dark wash near the ground
+ /// (with a little dust in it), the base colour through the middle and a dry-brushed highlight on top.</summary>
+ public static Color Shade(int slot, float v)
+ {
+ var c = Base[slot];
+ float k = Mathf.Lerp(0.62f, 1.0f, Mathf.SmoothStep(0f, 0.45f, v)) + 0.08f * Mathf.SmoothStep(0.7f, 1f, v);
+ var dust = new Color(0.58f, 0.50f, 0.38f);
+ var shaded = c * k;
+ return Color.Lerp(shaded, dust * 0.8f, 0.25f * (1f - Mathf.SmoothStep(0f, 0.12f, v)));
+ }
+
+ public static Texture2D MakeTexture()
+ {
+ int w = Count * SlotWidth;
+ var tex = new Texture2D(w, Rows, TextureFormat.RGBA32, false, false)
+ { name = "UnitPalette", wrapMode = TextureWrapMode.Clamp, filterMode = FilterMode.Bilinear, hideFlags = HideFlags.DontSave };
+ var px = new Color[w * Rows];
+ for (int y = 0; y < Rows; y++)
+ for (int x = 0; x < w; x++)
+ {
+ var c = Shade(x / SlotWidth, (y + 0.5f) / Rows); c.a = 1f;
+ px[y * w + x] = c;
+ }
+ tex.SetPixels(px); tex.Apply(false, false);
+ return tex;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/Units/UnitPalette.cs.meta b/unity/Assets/Scripts/Map/Units/UnitPalette.cs.meta
new file mode 100644
index 000000000..fda92148d
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/UnitPalette.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ce7fae3f840444fc58b39a513378cfc4
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/Units/UnitShowcase.cs b/unity/Assets/Scripts/Map/Units/UnitShowcase.cs
new file mode 100644
index 000000000..97c93f0bd
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/UnitShowcase.cs
@@ -0,0 +1,175 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Game.Boot;
+using UnityEngine;
+
+namespace Statecraft.Game.Map.Units
+{
+ /// <summary>The unit art slice (owner, 2026-10-11: "make sure the units are like in the promo video"): a 1948 rifle
+ /// trio with a selection ring, a Spitfire flying a loop with its shadow on the ground, and a corvette at sea, all at
+ /// <see cref="PromoPose.Gameplay03"/>. A showcase only: it reads nothing from the sim and places no unit the game state
+ /// knows about (where real units stand, move and fight is war mode's job, issue #104). It appears only when asked
+ /// for ("units" in the WebGL page URL or -units on desktop), in the art checkpoint's screenshots ("shot") and in the
+ /// editor's promo renders; normal play never shows it. Registers the "units" visual toggle, so the frame profile can
+ /// price it (?vprofile&amp;units).</summary>
+ public static class UnitShowcase
+ {
+ public const string RootName = "UnitShowcase", ToggleName = "units";
+
+ /// <summary>Symbolic scale, measured on the promo (docs/units.md): the promo's riflemen stand about 0.38 of a hex's
+ /// screen width tall at the gameplay zoom, which on our 5 km hexes at 60 km is about 5.5 km. So a man is drawn
+ /// <see cref="FigureScale"/> times his real size, and the aircraft and the ship are sized against him, as Civ draws
+ /// them, not against each other.</summary>
+ public const float FigureScale = 2600f;
+ public const float AircraftScale = 520f; // span 11.2 m x 520 = 5.8 km: a little wider than a man is tall
+ public const float ShipScale = 105f; // 62.5 m x 105 = 6.6 km: about one hex, like the promo's boats
+ /// <summary>Trio spacing and the ring, as fractions of the hex circumradius.</summary>
+ public const float TrioSpread = 0.30f, RingRadius = 0.62f, RingWidth = 0.035f, RingClearanceM = 25f;
+ /// <summary>The flight: a circle of <see cref="LoopRadiusM"/> about <see cref="LoopCentre"/>, at
+ /// <see cref="AltitudeM"/> above the highest ground under it, once every <see cref="LoopSeconds"/>, banked inwards.</summary>
+ public const float LoopRadiusM = 16000f, AltitudeM = 4200f, LoopSeconds = 48f, BankDegrees = 28f;
+ /// <summary>The loop's phase (0..1) used for still images (screenshots, editor renders), so they are repeatable: the
+ /// aircraft over the coast off Tel Aviv, inside the tilt-shift's sharp band, its shadow on the coastal plain (chosen
+ /// from renders at 0.40-0.74, docs/units.md).</summary>
+ public const float StillPhase = 0.52f;
+
+ /// <summary>Where the slice stands, inside the gameplay03 frame: the trio on the coastal plain south-east of Jaffa
+ /// (the promo puts its trio there), the loop over Tel Aviv and the plain, the corvette off Jaffa.</summary>
+ public static readonly (double lon, double lat) TrioAt = (34.84, 31.93), LoopCentre = (34.86, 32.03), ShipAt = (34.63, 32.02);
+ public const float ShipHeadingDegrees = 200f;
+
+ public static bool Requested() =>
+ Requested(Application.absoluteURL, Environment.GetCommandLineArgs(), Application.platform == RuntimePlatform.WebGLPlayer);
+
+ public static bool Requested(string? url, string[] args, bool webgl) =>
+ webgl ? UrlFlags.Has(url, "units") || UrlFlags.Has(url, "shot") : args.Contains("-units") || args.Contains("-shot");
+
+ /// <summary>True when the flight should hold its still phase (screenshots: the same image every run).</summary>
+ public static bool StillRequested(string? url, string[] args, bool webgl) =>
+ webgl ? UrlFlags.Has(url, "shot") : args.Contains("-shot");
+
+ /// <summary>Builds the showcase under the map's terrain (so a map rebuild destroys it), its meshes, palette and
+ /// materials owned by the terrain's MapRuntimeAssets, and registers the "units" toggle through its teardown.
+ /// <paramref name="still"/> freezes the flight at <see cref="StillPhase"/>. Returns the root.</summary>
+ public static GameObject Spawn(MapScene map, bool still)
+ {
+ if (map == null || map.Terrain == null || map.Hexes == null) throw new InvalidOperationException("UnitShowcase needs a built map");
+ var terrain = map.Terrain;
+ var assets = terrain.GetComponent<MapRuntimeAssets>();
+ var old = terrain.transform.Find(RootName);
+ if (old != null) { if (Application.isPlaying) UnityEngine.Object.Destroy(old.gameObject); else UnityEngine.Object.DestroyImmediate(old.gameObject); }
+
+ var template = Resources.Load<Material>(UnitMaterials.MiniatureResource)
+ ?? throw new InvalidOperationException($"Resources/{UnitMaterials.MiniatureResource}.mat is missing (run UnitMaterials.Create)");
+ var ringTemplate = Resources.Load<Material>(UnitMaterials.RingResource)
+ ?? throw new InvalidOperationException($"Resources/{UnitMaterials.RingResource}.mat is missing (run UnitMaterials.Create)");
+ var palette = assets.Own(UnitPalette.MakeTexture());
+ var paint = assets.Own(new Material(template) { name = "UnitMiniature (palette)" });
+ paint.SetTexture("_BaseMap", palette);
+
+ var root = new GameObject(RootName);
+ root.transform.SetParent(terrain.transform, false);
+ root.transform.position = Vector3.zero; // children are placed in world space
+ float hex = map.Hexes.hex_size_km * 1000f;
+
+ // The trio: three riflemen in a loose triangle facing the camera's side of south-west, on the hex's centre.
+ var centre = Ground(map, map.Frame.ToWorld(TrioAt.lon, TrioAt.lat, 0));
+ var looks = new[]
+ {
+ (UnitModels.Headgear.SlouchHat, UnitModels.RiflePose.Ready, false, new Vector2(-0.62f, -0.30f), 200f),
+ (UnitModels.Headgear.SteelHelmet, UnitModels.RiflePose.Grounded, true, new Vector2(0.05f, 0.05f), 185f),
+ (UnitModels.Headgear.WoolCap, UnitModels.RiflePose.Slung, false, new Vector2(0.66f, -0.40f), 170f),
+ };
+ for (int i = 0; i < looks.Length; i++)
+ {
+ var (hat, pose, faded, offset, heading) = looks[i];
+ var mesh = assets.Own(UnitModels.Rifleman(hat, pose, faded, $"Rifleman1948-{i}"));
+ var p = Ground(map, centre + new Vector3(offset.x, 0, offset.y) * TrioSpread * hex);
+ Piece(root.transform, $"Rifleman{i}", mesh, paint, p, Quaternion.Euler(0, heading, 0), FigureScale);
+ }
+ Ring(map, assets, ringTemplate, root.transform, centre, RingRadius * hex);
+
+ // The aircraft and its propeller.
+ var plane = new GameObject("Spitfire1948");
+ plane.transform.SetParent(root.transform, false);
+ var body = Piece(plane.transform, "Airframe", assets.Own(UnitModels.Spitfire("Spitfire1948")), paint, Vector3.zero, Quaternion.identity, 1f);
+ body.transform.localPosition = Vector3.zero;
+ var prop = Piece(plane.transform, "Propeller", assets.Own(UnitModels.SpitfirePropeller("SpitfirePropeller")), paint, Vector3.zero, Quaternion.identity, 1f);
+ prop.transform.localPosition = UnitModels.SpitfirePropellerHub;
+ plane.transform.localScale = Vector3.one * AircraftScale;
+ var loopCentre = map.Frame.ToWorld(LoopCentre.lon, LoopCentre.lat, 0);
+ var flight = plane.AddComponent<ShowcaseFlight>();
+ flight.Configure(loopCentre, LoopRadiusM, LoopFloor(map, loopCentre, LoopRadiusM) + AltitudeM, LoopSeconds, BankDegrees, prop.transform, still ? StillPhase : (float?)null);
+
+ // The corvette, at the sea surface.
+ var ship = Ground(map, map.Frame.ToWorld(ShipAt.lon, ShipAt.lat, 0));
+ Piece(root.transform, "Corvette1948", assets.Own(UnitModels.Corvette("CorvetteK20")), paint, ship, Quaternion.Euler(0, ShipHeadingDegrees, 0), ShipScale);
+
+ assets.OnTeardown(VisualToggles.Register(ToggleName, on => { if (root != null) root.SetActive(on); }));
+ return root;
+ }
+
+ static GameObject Piece(Transform parent, string name, Mesh mesh, Material mat, Vector3 position, Quaternion rotation, float scale)
+ {
+ var go = new GameObject(name);
+ go.transform.SetParent(parent, false);
+ go.transform.SetPositionAndRotation(position, rotation);
+ go.transform.localScale = Vector3.one * scale;
+ go.AddComponent<MeshFilter>().sharedMesh = mesh;
+ go.AddComponent<MeshRenderer>().sharedMaterial = mat;
+ return go;
+ }
+
+ /// <summary>The point on the terrain under <paramref name="p"/> (world x, z).</summary>
+ public static Vector3 Ground(MapScene map, Vector3 p)
+ {
+ p.y = map.Terrain.SampleHeight(p) + map.Terrain.transform.position.y;
+ return p;
+ }
+
+ /// <summary>The highest ground under the loop (sampled every 5 degrees and at its centre), so the aircraft never
+ /// dips into a ridge; its altitude is constant, so its shadow keeps one offset.</summary>
+ public static float LoopFloor(MapScene map, Vector3 centre, float radius)
+ {
+ float top = Ground(map, centre).y;
+ for (int a = 0; a < 360; a += 5)
+ {
+ var p = centre + new Vector3(Mathf.Cos(a * Mathf.Deg2Rad), 0, Mathf.Sin(a * Mathf.Deg2Rad)) * radius;
+ top = Mathf.Max(top, Ground(map, p).y);
+ }
+ return top;
+ }
+
+ /// <summary>The selection ring: a thin flat band on the ground around the trio, drawn with the hex selection's
+ /// unlit ivory and depth offset (the promo's white ring), each vertex lifted to the ground under it.</summary>
+ static void Ring(MapScene map, MapRuntimeAssets assets, Material ringTemplate, Transform parent, Vector3 centre, float radius)
+ {
+ const int n = 96;
+ var verts = new List<Vector3>(2 * n); var tris = new List<int>(6 * n);
+ float w = RingWidth * radius / RingRadius;
+ for (int i = 0; i < n; i++)
+ {
+ float a = 2f * Mathf.PI * i / n; var d = new Vector3(Mathf.Cos(a), 0, Mathf.Sin(a));
+ var outer = Ground(map, centre + d * (radius + w / 2)); var inner = Ground(map, centre + d * (radius - w / 2));
+ float y = Mathf.Max(outer.y, inner.y) + RingClearanceM;
+ outer.y = y; inner.y = y;
+ verts.Add(outer); verts.Add(inner);
+ }
+ for (int i = 0; i < n; i++)
+ {
+ int a = 2 * i, b = 2 * ((i + 1) % n);
+ tris.AddRange(new[] { a, b, a + 1, a + 1, b, b + 1 }); // the ring shader draws both faces
+ }
+ var mesh = assets.Own(new Mesh { name = "UnitSelectionRing" });
+ mesh.SetVertices(verts); mesh.SetTriangles(tris, 0); mesh.RecalculateBounds();
+ var go = new GameObject("SelectionRing");
+ go.transform.SetParent(parent, false);
+ go.AddComponent<MeshFilter>().sharedMesh = mesh;
+ var r = go.AddComponent<MeshRenderer>();
+ r.sharedMaterial = ringTemplate;
+ r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/Units/UnitShowcase.cs.meta b/unity/Assets/Scripts/Map/Units/UnitShowcase.cs.meta
new file mode 100644
index 000000000..d560767d9
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Units/UnitShowcase.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: d87b0a21598c84d1fbaab68bf868aa09
\ No newline at end of file
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 897d797e9..ddecb49e2 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -200,6 +200,10 @@ namespace Statecraft.Game.UI
if (Application.isPlaying && FrameProfile.Requested())
StartCoroutine(FrameProfile.Run(camRig, map.Frame, Debug.Log, Application.platform != RuntimePlatform.WebGLPlayer));
else if (Application.isPlaying && VisualShots.Requested()) StartCoroutine(VisualShots.Run(camRig, map.Frame, Debug.Log));
+ // The unit art slice at gameplay03 (a showcase, never in normal play; war mode's units are issue #104).
+ if (Application.isPlaying && Statecraft.Game.Map.Units.UnitShowcase.Requested())
+ Statecraft.Game.Map.Units.UnitShowcase.Spawn(map, Statecraft.Game.Map.Units.UnitShowcase.StillRequested(
+ Application.absoluteURL, Environment.GetCommandLineArgs(), Application.platform == RuntimePlatform.WebGLPlayer));
}
T Own<T>(T d) where T : IDisposable { owned.Add(d); return d; }
diff --git a/unity/Assets/Tests/EditMode/UnitShowcaseTests.cs b/unity/Assets/Tests/EditMode/UnitShowcaseTests.cs
new file mode 100644
index 000000000..317e52c6f
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/UnitShowcaseTests.cs
@@ -0,0 +1,160 @@
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game.Map;
+using Statecraft.Game.Map.Units;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+
+public class UnitShowcaseTests
+{
+ static Mesh[] AllMeshes() => new[]
+ {
+ UnitModels.Rifleman(UnitModels.Headgear.SlouchHat, UnitModels.RiflePose.Ready, false, "a"),
+ UnitModels.Rifleman(UnitModels.Headgear.SteelHelmet, UnitModels.RiflePose.Grounded, true, "b"),
+ UnitModels.Rifleman(UnitModels.Headgear.WoolCap, UnitModels.RiflePose.Slung, false, "c"),
+ UnitModels.Spitfire("s"), UnitModels.SpitfirePropeller("p"), UnitModels.Corvette("k"),
+ };
+
+ [Test]
+ public void ShowcaseIsAskedForOnlyByUnitsOrShot()
+ {
+ Assert.IsTrue(UnitShowcase.Requested("https://x/index.html?units", new string[0], true));
+ Assert.IsTrue(UnitShowcase.Requested("https://x/index.html?golden&shot", new string[0], true));
+ Assert.IsFalse(UnitShowcase.Requested("https://x/index.html?golden&smoke=5", new string[0], true));
+ Assert.IsFalse(UnitShowcase.Requested("https://x/index.html?vprofile", new string[0], true), "profiles price it only with &units");
+ Assert.IsFalse(UnitShowcase.Requested("https://x/units/index.html?unitsx", new string[0], true));
+ Assert.IsTrue(UnitShowcase.Requested(null, new[] { "player", "-units" }, false));
+ Assert.IsFalse(UnitShowcase.Requested(null, new[] { "player" }, false));
+ Assert.IsTrue(UnitShowcase.StillRequested("https://x/?shot", new string[0], true));
+ Assert.IsFalse(UnitShowcase.StillRequested("https://x/?units", new string[0], true));
+ }
+
+ [Test]
+ public void ModelsAreRepeatableAndWithinBudget()
+ {
+ var a = AllMeshes(); var b = AllMeshes();
+ int total = 0;
+ for (int i = 0; i < a.Length; i++)
+ {
+ CollectionAssert.AreEqual(a[i].vertices, b[i].vertices, a[i].name);
+ CollectionAssert.AreEqual(a[i].triangles, b[i].triangles, a[i].name);
+ CollectionAssert.AreEqual(a[i].uv, b[i].uv, a[i].name);
+ total += a[i].triangles.Length / 3;
+ }
+ // Budget: the whole slice under 25k triangles (a WebGL integrated GPU draws millions; this keeps a full front of
+ // trios cheap when #104 instances them).
+ Assert.Less(total, 25000, $"slice triangles {total}");
+ foreach (var m in a.Concat(b)) Object.DestroyImmediate(m);
+ }
+
+ [Test]
+ public void EveryTriangleFacesAlongItsNormals()
+ {
+ foreach (var mesh in AllMeshes())
+ {
+ var v = mesh.vertices; var n = mesh.normals; var t = mesh.triangles;
+ int bad = 0, counted = 0;
+ for (int i = 0; i < t.Length; i += 3)
+ {
+ var face = Vector3.Cross(v[t[i + 1]] - v[t[i]], v[t[i + 2]] - v[t[i]]);
+ if (face.sqrMagnitude < 1e-12f) continue;
+ counted++;
+ if (Vector3.Dot(face, n[t[i]] + n[t[i + 1]] + n[t[i + 2]]) < 0f) bad++;
+ }
+ Assert.AreEqual(0, bad, $"{mesh.name}: {bad} of {counted} triangles face against their normals");
+ Object.DestroyImmediate(mesh);
+ }
+ }
+
+ [Test]
+ public void RiflemanStandsOnTheOriginAtAMansHeight()
+ {
+ foreach (UnitModels.Headgear hat in System.Enum.GetValues(typeof(UnitModels.Headgear)))
+ {
+ var m = UnitModels.Rifleman(hat, UnitModels.RiflePose.Grounded, false, "r");
+ Assert.That(m.bounds.min.y, Is.InRange(-0.01f, 0.02f), $"{hat}: feet on the ground");
+ Assert.That(m.bounds.max.y, Is.InRange(1.70f, 1.95f), $"{hat}: about a man's height");
+ Object.DestroyImmediate(m);
+ }
+ }
+
+ [Test]
+ public void PaletteSlotsSampleTheirOwnColour()
+ {
+ var tex = UnitPalette.MakeTexture();
+ for (int slot = 0; slot < UnitPalette.Count; slot++)
+ {
+ var c = tex.GetPixelBilinear(UnitPalette.U(slot), 0.5f);
+ var want = UnitPalette.Shade(slot, 0.5f);
+ Assert.That(Mathf.Abs(c.r - want.r) + Mathf.Abs(c.g - want.g) + Mathf.Abs(c.b - want.b), Is.LessThan(0.03f), $"slot {slot}");
+ }
+ Object.DestroyImmediate(tex);
+ }
+
+ [Test]
+ public void FlightHoldsItsStillPhaseAndKeepsItsAltitude()
+ {
+ var go = new GameObject("f"); var prop = new GameObject("p");
+ try
+ {
+ var f = go.AddComponent<ShowcaseFlight>();
+ f.Configure(new Vector3(1000, 0, 2000), 500f, 300f, 10f, 20f, prop.transform, 0.25f);
+ var first = go.transform.position;
+ f.Configure(new Vector3(1000, 0, 2000), 500f, 300f, 10f, 20f, prop.transform, 0.25f);
+ Assert.AreEqual(first, go.transform.position);
+ Assert.AreEqual(300f, first.y, 1e-3f);
+ Assert.AreEqual(500f, Vector2.Distance(new Vector2(first.x, first.z), new Vector2(1000, 2000)), 0.01f);
+ // Nose along the path (tangent to the circle).
+ var radial = (first - new Vector3(1000, first.y, 2000)).normalized;
+ Assert.AreEqual(0f, Vector3.Dot(Vector3.ProjectOnPlane(go.transform.forward, Vector3.up).normalized, radial), 1e-3f);
+ }
+ finally { Object.DestroyImmediate(go); Object.DestroyImmediate(prop); }
+ }
+
+ [Test]
+ public void SpawnBuildsTheSliceAtGameplay03AndTheToggleHidesIt()
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
+ var map = new GameObject("MapScene").AddComponent<MapScene>();
+ map.Configure(Load("Terrain"), Load("SettlementMarker"), Load("HexSelection"), Load("Sea"), Load("BorderLand"));
+ map.Build();
+ try
+ {
+ var root = UnitShowcase.Spawn(map, still: true);
+ Assert.AreSame(map.Terrain.transform, root.transform.parent, "a map rebuild destroys it");
+ Assert.AreEqual(3, root.GetComponentsInChildren<MeshFilter>().Count(f => f.name.StartsWith("Rifleman")));
+ Assert.IsNotNull(root.transform.Find("SelectionRing"));
+ Assert.IsNotNull(root.transform.Find("Corvette1948"));
+ var plane = root.GetComponentInChildren<ShowcaseFlight>();
+ Assert.AreEqual(UnitShowcase.StillPhase, plane.StillPhase);
+ // Each figure stands on the ground under it.
+ foreach (var f in root.GetComponentsInChildren<MeshFilter>().Where(f => f.name.StartsWith("Rifleman")))
+ Assert.AreEqual(UnitShowcase.Ground(map, f.transform.position).y, f.transform.position.y, 1f, f.name);
+ // The aircraft clears the highest ground under its loop.
+ var loop = map.Frame.ToWorld(UnitShowcase.LoopCentre.lon, UnitShowcase.LoopCentre.lat, 0);
+ Assert.Greater(plane.transform.position.y, UnitShowcase.LoopFloor(map, loop, UnitShowcase.LoopRadiusM) + UnitShowcase.AltitudeM * 0.99f);
+ // Everything stands inside the gameplay03 view.
+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();
+ PromoPose.Gameplay03.Apply(rig, map.Frame);
+ foreach (var r in root.GetComponentsInChildren<Renderer>())
+ {
+ var vp = cam.WorldToViewportPoint(r.bounds.center);
+ Assert.That(vp.x, Is.InRange(0.02f, 0.98f), r.name); Assert.That(vp.y, Is.InRange(0.02f, 0.98f), r.name); Assert.Greater(vp.z, 0f, r.name);
+ }
+ CollectionAssert.Contains(VisualToggles.Names, UnitShowcase.ToggleName);
+ VisualToggles.Set(UnitShowcase.ToggleName, false);
+ Assert.IsFalse(root.activeSelf);
+ VisualToggles.Set(UnitShowcase.ToggleName, true);
+ Assert.IsTrue(root.activeSelf);
+ // A second spawn replaces the first rather than stacking.
+ UnitShowcase.Spawn(map, still: true);
+ int count = 0; foreach (Transform c in map.Terrain.transform) if (c.name == UnitShowcase.RootName) count++;
+ Assert.AreEqual(1, count);
+ }
+ finally { Object.DestroyImmediate(map.gameObject); }
+ CollectionAssert.DoesNotContain(VisualToggles.Names, UnitShowcase.ToggleName, "the map's teardown removes the switch");
+ }
+
+ static Material Load(string name) => AssetDatabase.LoadAssetAtPath<Material>($"Assets/Materials/{name}.mat");
+}
diff --git a/unity/Assets/Tests/EditMode/UnitShowcaseTests.cs.meta b/unity/Assets/Tests/EditMode/UnitShowcaseTests.cs.meta
new file mode 100644
index 000000000..2e8237218
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/UnitShowcaseTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: e7abd133d0e414051baeebbb58a03865
\ No newline at end of file