Skip to content

Reference

Waves

Transverse, longitudinal, standing, ring, sonar, spherical, plane, interference and echo waves.

import { ... } from 'cseen/waves';

The arcs above an antenna or a router. Points up and spreads wide by default.

function radio(o?: Omit<WaveOpts, 'kind'>): Wave
ParameterType
o?Omit<WaveOpts, 'kind'>

Returns Wave

Example

import { Scene, ground } from 'cseen';
import { router } from 'cseen/devices';
import { radio } from 'cseen/waves';
const s = new Scene();
s.add(ground());
const r = s.add(router({ at: [0, 0, 0], width: 1.8 }));
s.add(radio({ at: r.signal()(), reach: 3.2, wavelength: 0.6, spread: 110 }));
Run it in the playground →

Circles spreading from a point, like a drop in water.

function ripple(o?: Omit<WaveOpts, 'kind'>): Wave
ParameterType
o?Omit<WaveOpts, 'kind'>

Returns Wave

Example

import { Scene, ground } from 'cseen';
import { ripple } from 'cseen/waves';
const s = new Scene();
s.add(ground(), ripple({ at: [0, 0, 0.02], reach: 4, wavelength: 0.5 }));
Run it in the playground →

A sonar beam: arcs travelling in one direction, fading with distance.

function sonar(o?: Omit<WaveOpts, 'kind'>): Wave
ParameterType
o?Omit<WaveOpts, 'kind'>

Returns Wave

Example

import { Scene, ground } from 'cseen';
import { sonar } from 'cseen/waves';
const s = new Scene();
s.add(ground(), sonar({ at: [0, -2, 0.02], reach: 6, spread: 60, wavelength: 0.5 }));
Run it in the playground →

A wave of any kind: sine, longitudinal, standing, rings, directional (sonar), spherical, plane, interference, echo or radio. The animatable property phase moves it, and one unit of phase is one wavelength.

function wave(o?: WaveOpts): Wave
ParameterType
o?WaveOpts

Returns Wave

Options: WaveOpts

Example

import { Scene, ground } from 'cseen';
import { wave } from 'cseen/waves';
const s = new Scene();
s.add(ground(), wave({ kind: 'echo', at: [0, -2.4, 0.02], target: 3.8, reflect: 0.5, reach: 7, spread: 50, wavelength: 0.55 }));
Run it in the playground →

Waves of many kinds. Everything is a function of phase: 0 to 1 moves the pattern by one wavelength, and the pattern at 1 is the same as at 0, so a looping timeline gives a seamless animation: tween(w, { phase: 1 }, { duration: 1.5, ease: 'linear' }).

sine, longitudinal, standing a wave along a line rings circles spreading from a point directional arcs travelling in one direction, a sonar beam (flat, or a cone with cone: true) spherical shells spreading in 3D plane straight fronts moving along a direction interference two sources and the lines where they cancel echo a beam out, a reflector, and a weaker beam back

new Wave(o?: WaveOpts): Wave

Options: WaveOpts

Extends Node.

MemberDescription
o: WaveOpts
pt(d: number): (): V3the point d along the wave’s direction from its source, as an anchor that follows it
collect(out: Prim[]): voidappends what this node draws right now to out, in world coordinates. Draws nothing when fully transparent.

The kinds of wave wave can draw.

type WaveKind = 'sine' | 'longitudinal' | 'standing' | 'rings' | 'directional' | 'spherical' | 'plane' | 'interference' | 'echo'

Options of wave.

Extends NodeOpts.

OptionTypeDefaultDescription
kind?WaveKindwhich wave to draw
direction?V3the direction the wave travels in. Default +y (into the scene).
wavelength?numberdistance between crests, in world units
reach?numberhow far the wave reaches from its source (or its length, for a line wave)
spread?numberdirectional and echo: the width of the beam in degrees. Default 60.
cone?booleandirectional: draw the arcs as caps of a cone in 3D instead of flat arcs
amplitude?numbersine, longitudinal, standing: the height of the wave, in world units
plane?'ground' | 'upright'which plane a flat wave lies in. ‘ground’ lies on the floor, ‘upright’ stands facing the viewer.
fade?booleanlet the wave fade as it travels (default true)
sources?[V3, V3]interference: the two sources, relative to at. Default 1.6 either side.
nodal?booleaninterference: draw the lines where the waves cancel
target?numberecho: how far away the reflector is, along the direction
reflect?numberecho: how strong the return is, 0 to 1
edges?booleandraw the edges of the beam
role?stringcolour role (ink, faint, accent, s1 to s8) or a role you define in CSS
width?numberline width in SVG units