Reference
Waves
Transverse, longitudinal, standing, ring, sonar, spherical, plane, interference and echo waves.
import { ... } from 'cseen/waves';Functions
Section titled “Functions”The arcs above an antenna or a router. Points up and spreads wide by default.
function radio(o?: Omit<WaveOpts, 'kind'>): Wave| Parameter | Type |
|---|---|
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 }));ripple
Section titled “ripple”Circles spreading from a point, like a drop in water.
function ripple(o?: Omit<WaveOpts, 'kind'>): Wave| Parameter | Type |
|---|---|
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 }));A sonar beam: arcs travelling in one direction, fading with distance.
function sonar(o?: Omit<WaveOpts, 'kind'>): Wave| Parameter | Type |
|---|---|
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 }));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| Parameter | Type |
|---|---|
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 }));Classes
Section titled “Classes”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): WaveOptions: WaveOpts
Extends Node.
| Member | Description |
|---|---|
o: WaveOpts | |
pt(d: number): (): V3 | the point d along the wave’s direction from its source, as an anchor that follows it |
collect(out: Prim[]): void | appends what this node draws right now to out, in world coordinates. Draws nothing when fully transparent. |
Options and types
Section titled “Options and types”WaveKind
Section titled “WaveKind”The kinds of wave wave can draw.
type WaveKind = 'sine' | 'longitudinal' | 'standing' | 'rings' | 'directional' | 'spherical' | 'plane' | 'interference' | 'echo'WaveOpts
Section titled “WaveOpts”Options of wave.
Extends NodeOpts.
| Option | Type | Default | Description |
|---|---|---|---|
kind? | WaveKind | which wave to draw | |
direction? | V3 | the direction the wave travels in. Default +y (into the scene). | |
wavelength? | number | distance between crests, in world units | |
reach? | number | how far the wave reaches from its source (or its length, for a line wave) | |
spread? | number | directional and echo: the width of the beam in degrees. Default 60. | |
cone? | boolean | directional: draw the arcs as caps of a cone in 3D instead of flat arcs | |
amplitude? | number | sine, 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? | boolean | let the wave fade as it travels (default true) | |
sources? | [V3, V3] | interference: the two sources, relative to at. Default 1.6 either side. | |
nodal? | boolean | interference: draw the lines where the waves cancel | |
target? | number | echo: how far away the reflector is, along the direction | |
reflect? | number | echo: how strong the return is, 0 to 1 | |
edges? | boolean | draw the edges of the beam | |
role? | string | colour role (ink, faint, accent, s1 to s8) or a role you define in CSS | |
width? | number | line width in SVG units |