FERRETGame engine over Babylon.js
Ferret

@ferret/physics-fx

The render side: glow of hot parts, water meshes, fluid views and lamp lights.

The render side of the physics capabilities: what a temperature, a water surface, a particle liquid and a lamp look like in a Babylon scene. The capabilities report numbers and own no look; these bindings turn the numbers into a picture and are what a game uses or replaces with its own. Each returns a dispose.

10 exports · source in packages/physics-fx/src

Functions

blackbody function

function blackbody(T: number): [number, number, number]

Colour of a black body at T kelvin (Tanner Helland's fit of the Planck locus; within a few percent from 1000 K to 40000 K), 0..1.

packages/physics-fx/src/index.ts:8

flowArrows function

function flowArrows(scene: BABYLON.Scene, samples: () => Array<{ at: [number, number, number]; velocity: [number, number, number] }>, o: { scale?: number; color?: [number, number, number] } = {})

The inspector's flow arrows: a line from each grid point along the flow there (length by speed), redrawn every frame.

packages/physics-fx/src/index.ts:115

fluidView function

function fluidView(scene: BABYLON.Scene, view: () => FluidViewLike, o: { max?: number; color?: [number, number, number]; foam?: [number, number, number]; foamSpeed?: number } = {})

A particle liquid as thin instances of one small sphere, a particle each (the liquid's spacing is its size), shaded from a still colour to a foam colour by speed. Up to max particles are drawn.

packages/physics-fx/src/index.ts:72

glow function

function glow(scene: BABYLON.Scene, mesh: BABYLON.AbstractMesh, temperature: () => number, o: { full?: number; strength?: number } = {})

A mesh glows by the temperature of a heat part (a brake disc, a forge's iron, a reactor vessel).

packages/physics-fx/src/index.ts:29

incandescence function

function incandescence(T: number, full = 1800): number

How bright a hot body glows, 0..1: nothing below the Draper point (798 K, where a dull red first shows in the dark), then rising with the visible part of the radiation, about T⁴ times the share that is visible, normalised to 1 at full (a white-hot 1800 K by default).

packages/physics-fx/src/index.ts:21

lampLight function

function lampLight(scene: BABYLON.Scene, light: BABYLON.Light, lamp: LampLike, o: { rated?: number; intensity?: number } = {})

A scene light follows a lamp of the circuit: its colour from the filament's temperature, its intensity from the visible light the filament gives (incandescence, against the lamp's rated temperature, so the rated lamp shines at intensity). A dimmed lamp goes red and dark; a burnt one goes out.

packages/physics-fx/src/index.ts:103

waterMesh function

function waterMesh(scene: BABYLON.Scene, field: () => SurfaceField, o: { name?: string; material?: BABYLON.Material } = {})

A mesh that follows a water surface of L2: a grid of the surface's cells, heights and normals written every frame.

packages/physics-fx/src/index.ts:44

Interfaces

FluidViewLike interface

interface FluidViewLike

What particleLiquid().view(name) returns (L3).

count: number
spacing: number
positions: Float32Array
speeds: Float32Array

packages/physics-fx/src/index.ts:66

LampLike interface

interface LampLike

What a lamp of W reports: its filament temperature and whether it burnt out.

T: number
burnt?: boolean

packages/physics-fx/src/index.ts:96

SurfaceField interface

interface SurfaceField

What WaterSurface.field() returns (L2).

nx: number
nz: number
dx: number
origin: [number, number] | number[]
heights: Float32Array
normals: Float32Array

packages/physics-fx/src/index.ts:41