mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Settle leases, styles, credits and controls in the renderer contract
- claimPointer takes a grab filter, asked on each down: a lease takes
only the presses it grabs, and wheel, pinch and every other press stay
with the camera and everyone else. Each event of a press goes where its
down went, per button, so a claim never takes a press under way.
- The app owns the styles: effects.defineStyle passes a GLSL (and optionally
WGSL) full-screen pass, with the shader interface written out.
- Credits are plain data ({ text, href, logoUrl, inline }) that the app
renders; CreateOptions.creditContainer goes.
- controls.coast { drag, zoom } in seconds replaces the inertia trio; the
stub's defaults are the default renderer's, converted.
- The frame order is the default renderer's own: a move made by follow or
in preUpdate reaches changed on the next frame.
This commit is contained in:
1 parent
b7c26351f7
commit
a7aeeb558a
12 files changed
+591
-34
No files matched your search
Vendored
+7
-3
@@ -170,9 +170,13 @@ export interface CameraControls {
|
||||
enableZoom: boolean;
|
||||
minDistance: number;
|
||||
maxDistance: number;
|
||||
inertiaSpin: number;
|
||||
inertiaTranslate: number;
|
||||
inertiaZoom: number;
|
||||
/**
|
||||
* How long a motion the user lets go of coasts: seconds for its speed to
|
||||
* fall to 1/e. `drag` is moving the globe under the pointer and tilting
|
||||
* (one motion in the default renderer), `zoom` is zooming; 0 stops at
|
||||
* once. Set the whole object to change it.
|
||||
*/
|
||||
coast: { drag: number; zoom: number };
|
||||
/** What the eye cannot pass below. */
|
||||
collision: 'none' | 'terrain' | 'tiles' | 'both';
|
||||
zoomFactor: number;
|
||||
|
||||
Vendored
+7
-2
@@ -5,9 +5,14 @@
|
||||
*/
|
||||
import type { Off } from './common';
|
||||
|
||||
/** One credit, as plain data: the application renders and escapes it. */
|
||||
export interface Credit {
|
||||
/** Sanitised HTML: text, links and images only. */
|
||||
html: string;
|
||||
/** Plain text, never markup. */
|
||||
text: string;
|
||||
/** Where the credit links to. */
|
||||
href?: string;
|
||||
/** A logo drawn before the text. */
|
||||
logoUrl?: string;
|
||||
/** Shown on the map itself, rather than in the expanded list. */
|
||||
inline?: boolean;
|
||||
}
|
||||
|
||||
Vendored
+36
-3
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* Full-screen effects: visual styles, bloom, sharpen and screen modulation.
|
||||
* Each style is a plain full-screen pass over the frame's colour, so every
|
||||
* renderer can provide the same set.
|
||||
* Each style is a plain full-screen pass over the frame's colour. The
|
||||
* application owns the styles and defines them on the renderer
|
||||
* renderer runs the same set; a renderer's own styles are extra ones.
|
||||
*/
|
||||
import type { Off } from './common';
|
||||
|
||||
@@ -13,6 +14,32 @@ export interface StyleDescriptor {
|
||||
animated: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A style's shader. `glsl` is a GLSL ES 3.00 fragment shader with its
|
||||
* `main()`, as GEV's styles are written, without `#version`, `precision`
|
||||
* or an `out` declaration: the renderer declares `out_FragColor`, which it
|
||||
* writes. It declares what it reads of `uniform sampler2D colorTexture`,
|
||||
* `uniform vec2 colorTextureDimensions` (pixels),
|
||||
* `in vec2 v_textureCoordinates`, `uniform float intensity` (0..1),
|
||||
* `uniform float time` (seconds, for an animated style) and one
|
||||
* `uniform float` per parameter under its key. Parameter keys are GLSL
|
||||
* identifiers and never one of those names.
|
||||
* `wgsl` is the same pass in WGSL: a fragment entry
|
||||
* `fs_main` taking `@location(0) uv: vec2f` and returning the colour at
|
||||
* `@location(0)`. Group 0 binds `colorTexture` (`texture_2d<f32>`) at 0,
|
||||
* `colorSampler` at 1 and, at 2, a uniform struct the shader declares as
|
||||
* `params`: `intensity: f32`, `time: f32`, `dimensions: vec2f`, then one
|
||||
* `f32` per parameter in the order `params` lists them.
|
||||
*/
|
||||
export interface StyleShader {
|
||||
glsl: string;
|
||||
wgsl?: string;
|
||||
}
|
||||
|
||||
export interface StyleDefinition extends StyleDescriptor {
|
||||
shader: StyleShader;
|
||||
}
|
||||
|
||||
/** A sweeping sector drawn over the frame (a sonar band), or null. */
|
||||
export interface ModulationSector {
|
||||
/** Centre of the sweep, CSS pixels. */
|
||||
@@ -32,8 +59,14 @@ export interface EffectsDiagnostics {
|
||||
}
|
||||
|
||||
export interface EffectsPort {
|
||||
/** `styles`. */
|
||||
/** `styles`: every style, defined by the application or the renderer's own. */
|
||||
styles(): StyleDescriptor[];
|
||||
/**
|
||||
* `styles`: add a style, replacing one with the same id. Null without
|
||||
* the capability, or when the renderer runs none of the shader's
|
||||
* languages; the Off removes it (turning it off when it is the style).
|
||||
*/
|
||||
defineStyle(definition: StyleDefinition): Off | null;
|
||||
setStyle(id: string | null, params?: Record<string, number>): void;
|
||||
setStyleIntensity(id: string, intensity: number): void;
|
||||
setStyleParams(id: string, params: Record<string, number>): void;
|
||||
|
||||
Vendored
+5
-1
@@ -10,7 +10,11 @@
|
||||
* move detection (`moveStart` / `moveEnd`) → `preRender` → render →
|
||||
* `postRender`. `preUpdate` fires on every frame the loop ticks, including
|
||||
* frames that end up drawing nothing, so owners that write the camera there
|
||||
* (a cockpit, a follow clamp) see each one.
|
||||
* (a cockpit, a follow clamp) see each one. This is the default renderer's
|
||||
* own order. `changed` is measured before follow and `preUpdate` move the
|
||||
* camera, so a move made there is reported by `changed` on the next frame;
|
||||
* move detection runs after them and sees it in the same frame. The
|
||||
* default renderer's `postUpdate` has no place here: the application does not use it.
|
||||
*/
|
||||
import type { Off, Release } from './common';
|
||||
|
||||
|
||||
@@ -198,9 +198,9 @@ export const PORTS = deepFreeze({
|
||||
'controls.enableZoom',
|
||||
'controls.minDistance',
|
||||
'controls.maxDistance',
|
||||
'controls.inertiaSpin',
|
||||
'controls.inertiaTranslate',
|
||||
'controls.inertiaZoom',
|
||||
'controls.coast',
|
||||
'controls.coast.drag',
|
||||
'controls.coast.zoom',
|
||||
'controls.collision',
|
||||
'controls.zoomFactor',
|
||||
'controls.pitchRange',
|
||||
@@ -247,6 +247,7 @@ export const PORTS = deepFreeze({
|
||||
effects: Object.fromEntries([
|
||||
...required(
|
||||
'styles',
|
||||
'defineStyle',
|
||||
'setStyle',
|
||||
'setStyleIntensity',
|
||||
'setStyleParams',
|
||||
|
||||
Vendored
+33
-5
@@ -3,9 +3,26 @@
|
||||
*
|
||||
* A tool takes the pointer with a lease; while a lease is out, ambient
|
||||
* subscribers (those without a lease) get only `move` and `up`: no presses,
|
||||
* clicks, double-clicks, wheel or pinch. Suspending camera
|
||||
* input is separate and counted, and takes effect on the same pointerdown
|
||||
* that asked for it.
|
||||
* clicks, double-clicks, wheel or pinch. A lease with `grab` takes only the
|
||||
* presses it grabs: `grab` is asked on each `down`, and a grabbed press (its
|
||||
* `down`, and the `click` and `dblclick` it ends in) goes to the lease's
|
||||
* listeners alone. Every other press, and wheel and pinch, go to ambient
|
||||
* subscribers and the camera as if the pointer were free; `move` and `up`
|
||||
* go to both.
|
||||
*
|
||||
* Every event of a press goes where its `down` went, even when the lease
|
||||
* ends or changes before the press is over (an ended lease's to no one), so
|
||||
* a claim never takes a press already under way. Each button's presses
|
||||
* are separate. A press runs from its `down` through its `up`, the `click`
|
||||
* straight after it where it went up, and a `dblclick` straight after that
|
||||
* at the same spot;
|
||||
* any other event after its `up` ends it. A click or double-click with no
|
||||
* press of its own is decided as a press, `grab` seeing it as a `down`
|
||||
* (without `pick`, `drill` or `ground`).
|
||||
*
|
||||
* Suspending camera input is separate and counted, and takes effect on the
|
||||
* same pointerdown that asked for it, so a tool that grabs a press suspends
|
||||
* the camera in its `down` listener.
|
||||
*
|
||||
* A click is delivered with its pick already made, once, and shared by
|
||||
* every subscriber (`PointerEv.pick`). Where the renderer's picks answer a
|
||||
@@ -70,8 +87,19 @@ export interface InputPort {
|
||||
cb: (ev: PointerEv) => void,
|
||||
options?: { lease?: Lease | (() => Lease | null) },
|
||||
): Off;
|
||||
/** Take the pointer for a tool. A new claim ends the previous lease. */
|
||||
claimPointer(owner: string): Lease;
|
||||
/**
|
||||
* Take the pointer for a tool. A new claim ends the previous lease.
|
||||
* `grab` decides each press from its `down` event, synchronously: true
|
||||
* makes it the tool's, anything else leaves it. A `down` carries no pick,
|
||||
* so `grab` decides from the position, button and modifiers (and the
|
||||
* tool's own hit test, through `query`). Omitted, every press is the
|
||||
* tool's. A `grab` that throws is reported and leaves the press to the
|
||||
* others.
|
||||
*/
|
||||
claimPointer(
|
||||
owner: string,
|
||||
options?: { grab?: (down: PointerEv) => boolean },
|
||||
): Lease;
|
||||
isPointerFree(): boolean;
|
||||
/** Suspend user camera input until released. Holds are counted. */
|
||||
suspendCameraControls(reason: string): Release;
|
||||
|
||||
Vendored
-2
@@ -30,8 +30,6 @@ export interface RendererPlugin {
|
||||
export interface CreateOptions {
|
||||
/** The element the renderer fills. It creates its own canvas inside. */
|
||||
container: HTMLElement;
|
||||
/** Where the app renders credits, when it has a place for them. */
|
||||
creditContainer?: HTMLElement;
|
||||
/** Google Maps Platform key for photorealistic tiles. */
|
||||
googleApiKey?: string;
|
||||
/** Short-lived Google session tokens, when the key is held server-side. */
|
||||
|
||||
Reference in new issue
Block a user