WorldProperties class final
The properties of one world, read by everything in it.
One gravity per game (decision 1 of tasks/1.0-physics-audit.md).
The engine's default is standardGravity; a game sets its own world
explicitly where it stages it — the platformer's at 24 m/s², the racing
game's at 20 — and a level may set its own on top (Level.world). Then a
rigid body, a runner, an AI's jump arc, a ragdoll, a spark, a cloth, a
tyre's grip and a swimmer's lift all read the same number, and a level
set on the Moon is the Moon for every one of them.
The air's density is derived from its airTemperature and
airPressure by the ideal gas law (airDensityAt) unless a world says
it explicitly (airDensityOverride), and the speed of sound from its
temperature (speedOfSound).
The medium is a material's id in the engine's MaterialCatalog:
f3d.air for a world on land, f3d.seawater for one under the sea, a
plugin's for one of its own. What a body moving through the world is
dragged and lifted by is mediumDensity — the world's own air where the
medium is air, the catalogue's entry otherwise.
What its numbers promise is its profile: the deterministic one, bit for bit on every platform, unless a laboratory or a twin asks for the accurate one. A body's integrator reads the profile's capabilities here, where it reads gravity.
Where it is on the Earth, when it is somewhere: geoOrigin, the latitude, longitude and altitude its origin stands on, its axes east, up and south.
Not how often it is stepped. A world's step rate is the loop's
(WorldTiming in flutter3d_sim); it was a field here until
1.0.0-rc.1, which nothing read, and a document that still carries it
reads with the key passed over.
Immutable: a world that changes takes a new value (copyWith), and a
snapshot holds one (toJson). gravity and wind are vector_math
vectors, which are mutable, so the world keeps its own copies and hands
out fresh ones. See docs/CONTRACTS.md's "World properties" for who reads
each field.
Constructors
- WorldProperties({Vector3? gravity, double airTemperature = standardAirTemperature, double airPressure = standardAtmosphere, double? airDensity, double airHumidity = standardRelativeHumidity, Vector3? wind, String medium = 'f3d.air', SimulationProfile profile = SimulationProfile.deterministic, GeoOrigin? geoOrigin})
-
A world with these properties; anything left out is the standard
world's (
standard_world.dart). Throws an ArgumentError for a temperature, pressure or density that is not finite and positive, or a gravity or wind that is not finite. -
WorldProperties.fromJson(Map<
String, Object?> json, {WorldProperties? base}) -
The world
jsondescribes, each field absent taken frombase— the standard world by default, a game's own world when a level overrides only some of it.factory
Properties
- airDensity → double
-
The air's density, kg/m³: airDensityOverride, or the ideal gas's at
airTemperature and airPressure (
airDensityAt) —standardAirDensityfor the standard air, to the bit.no setter - airDensityOverride → double?
-
The air's density a world set explicitly, kg/m³; null when it is
derived (airDensity).
final
- airHumidity → double
-
The air's relative humidity, nought to one: the water vapour it holds
over what it holds saturated at airTemperature. What open liquid
evaporates into, and the vapour's part of a fluid world's air
(
FluidAirinflutter3d_physics);standardRelativeHumidityby default. airDensity stays dry air's, which every recorded run was made with.final - airPressure → double
-
The air's pressure at the world's datum — the surface of its sea, the
floor of its valley — Pa.
final
- airTemperature → double
-
The air's temperature, K.
final
- geoOrigin → GeoOrigin?
-
Where the world's origin is on the Earth, or null for a world that is
nowhere in particular: a game's level, a laboratory's bench.
final
- gravity → Vector3
-
Metres per second squared;
standardGravitydown y by default. A fresh vector each call: aVector3is mutable.no setter - gravityMagnitude → double
-
How strong gravity is, m/s².
standardGravityto the bit for the standard gravity, asNativeWorld.gravityMagnitudeis.no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- medium → String
-
The id of the material the world is filled with, in its
MaterialCatalog:f3d.airby default.final - profile → SimulationProfile
-
What the world's numbers promise: SimulationProfile.deterministic by
default. Code that decides by it asks a capability
(
profile.usesDoublePrecision), never which profile it is.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- speedOfSound → double
-
How fast sound travels in the world's air, m/s (
speedOfSoundAtits temperature): what a listener's Doppler shift is reckoned against.no setter - wind → Vector3
-
The wind everywhere, m/s: what a cloth flaps in, smoke and sparks
drift on and the air drags a body by. A fresh vector each call.
no setter
Methods
-
copyWith(
{Vector3? gravity, double? airTemperature, double? airPressure, double? airDensity, bool clearAirDensity = false, double? airHumidity, Vector3? wind, String? medium, SimulationProfile? profile, GeoOrigin? geoOrigin, bool clearGeoOrigin = false}) → WorldProperties -
A copy with the fields given changed.
clearAirDensitygoes back to deriving the air's density from its temperature and pressure. -
mediumDensity(
MaterialCatalog catalog) → double -
The density of what a body moving through the world is dragged and
lifted by, kg/m³: airDensity when the medium is
f3d.air, else the medium's incatalog. Throws anUnknownMaterialExceptionnaming the plugin it needs whencataloghas no such material, and a StateError for a medium with no density. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, Object?> -
The world as JSON, every field: what a snapshot and a level hold.
airDensityonly when airDensityOverride says it;airHumidityonly when it is notstandardRelativeHumidity,profileonly when it is not SimulationProfile.deterministic andgeoOriginonly when there is one, so the default world is written, and digested, as it was before any of them existed. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Properties
- standard → WorldProperties
-
The standard world:
standardGravitydown, the air of a room at sea level, no wind, in air.final