1// The two one-cell marks that are not things in the world: the order the ship is 2// flying to, and the pointer the dev build draws in place of the browser's cursor. 3import * as THREE from 'three'; 4import { lum } from './ink'; 5import { plate } from './shapes'; 6 7// A click target: a plus of 5 cells, bright enough to read past the dust. It is 8// built in cells and scaled by the view, so a plate is one glyph at every zoom 9// instead of one glyph at the one zoom its world size happens to match. 10export function crosshair(): THREE.Group { 11 const g = new THREE.Group(); 12 for (const [dx, dy] of [[0, 0], [1, 0], [-1, 0], [0, 1], [0, -1]]) { 13 const p = plate(1, 1, dx || dy ? 0.75 : 1); 14 p.position.set(dx, dy, 0); 15 g.add(p); 16 } 17 g.position.z = 0.5; 18 g.renderOrder = 2; // over every body and piece: it is an order, not a thing 19 return g; 20} 21 22// The pointer: a ring of whole cells around the pointer cell, one cell per plate. 23// The browser's own pointer is hidden, so the game draws one that lands on the cell 24// a click will resolve to. It is a ring and not a plus, so it can never be read as 25// the order marker the ship is flying to. 26export function reticle(): THREE.Group { 27 const g = new THREE.Group(); 28 for (const dx of [-1, 0, 1]) { 29 for (const dy of [-1, 0, 1]) { 30 if (!dx && !dy) continue; 31 const p = plate(1, 1, 1); // a full cell: a smaller plate is averaged away 32 p.material.color.copy(TONE.space); 33 p.position.set(dx, dy, 0); 34 g.add(p); 35 } 36 } 37 g.position.z = 1; // over the fuel gauge 38 g.renderOrder = 1; // and after it too: a cell of gauge must never hide the pointer 39 return g; 40} 41 42// What the ring says about the cell it is on: nothing is just space, a body is a 43// place to orbit, and a hull that is not yours is a fight. Never the cream of your 44// own hull, or the pointer would vanish on the one thing it sits on most. 45export const TONE = { space: lum(1, 4), body: lum(1, 6), hull: lum(1, 14) };