Technical manual
...
Spatial module
Turning entities into spatialized objects
2 min
transforms the first concept to spatialize our entities is to introduce the transformcomponent this stores the spatial information for our entity, its position , rotation , and scale these properties are bitecs proxified three js math objects a vector3 for position, a quaternion for rotation, and another vector3 for scale there are two more properties, the matrix and matrixworld , which are three js matrix4 properties matrix stores this transform relative to its parent, and matrixworld stores it relative to the absolute origin hierarchy our next component is the entitytreecomponent which stores the parent/child relationships a parententity and children array of entities changing either of these via setcomponent will automatically update the parent and children entities to reflect this change to optimize traditional hierarchy based calculations, the transformsystem automatically sorts a complete list of all spatial entities in order to utilize bitecs ’ soa cpu caching to allow the javascript engine to calculate matrices as fast as possible physics physics is split into two systems the first is the physicssystem which updates the ecs and physics bodies before and after simulation, as well as running the simulation substeps can be configured via physicsstate , and the simulation timestep can be configured via ecsstate beyond this, the system has a few neat tricks, such as interpolating kinematic rigidbodies between substeps, and automatically populating and depopulating collision events into the collisioncomponent the second is the physicspretransformsystem which has two responsibilities, teleporting rigidbodies & colliders if the transformcomponent has been mutated, and smoothly interpolating the transform of an entity between physics steps, such that it does not stutter relative to the device framerate