Skip to main content

Crate euv_engine

Crate euv_engine 

Source
Expand description

euv-engine

A high-performance 2D and 3D game engine built on the euv framework for WebAssembly, featuring an ECS-style entity system, fixed-timestep game loop, canvas rendering, WebGPU rendering, physics simulation, collision detection, sprite animation, scene management, asset loading, and Web Audio integration.

Modules§

self
Utilities for formatting and printing Strings.
self
Basic functions for dealing with memory, values, and types.

Structs§

AABB3D
A 3D axis-aligned bounding box defined by its minimum and maximum corners.
AabbCollider
An axis-aligned bounding box collider wrapping a Rect.
AabbCollider3D
A 3D axis-aligned bounding box collider wrapping an AABB3D.
Animator
Manages the playback state of sprite animations.
AssetCache
A cache for storing loaded game assets, keyed by URL.
AssetClosureStore
The backing store behind AssetClosures.
AssetEntry
An entry in the asset cache containing the loaded data and its state.
AssetLoader
An asynchronous asset loader that fetches resources over HTTP and populates a shared AssetCache.
AtlasRegions
The name-to-rectangle index of a sprite atlas, without the image handle.
AudioClip
An audio clip wrapping a decoded AudioBuffer with playback control.
BindGroupLayoutEntry
A single entry inside a GpuBindGroupLayoutDescriptor.
Camera2D
A 2D camera that defines the viewport into the game world.
Camera3D
A 3D camera that defines the viewport into a 3D world using perspective or orthographic projection.
CanvasRenderer
A wrapper around CanvasRenderingContext2d providing convenience drawing methods and camera management for the game engine.
Circle
A circle defined by its center point and radius.
CircleCollider
A circle collider wrapping a Circle.
CollisionResult
The result of a collision check between two colliders, containing the contact normal and penetration depth if they overlap.
CollisionResult3D
The result of a collision check between two 3D colliders, containing the contact normal and penetration depth if they overlap.
Color
A color represented by red, green, blue, and alpha channels in the range 0.0 to 1.0.
DrawList
An ordered buffer of deferred draw commands recorded during a frame.
Engine
A zero-sized namespace struct providing static engine entry points.
EngineCell
A Sync wrapper holding a single value of type T.
EngineConfig
The top-level engine configuration containing rendering and scheduler settings.
EngineHandle
A handle to a running or initialized engine instance.
Entity
The fundamental entity in the engine, combining a transform with a collection of behavior-defining components.
EventBus
A publish-subscribe event bus for decoupled inter-entity communication.
Formatter
Configuration for formatting.
GameAudioContext
A wrapper around the Web Audio API AudioContext providing game engine audio playback and volume management.
GamepadManager
Owns the state of every gamepad the page has seen and drives the per-frame poll.
GamepadState
Per-frame and steady-state data for a single gamepad index.
GpuSamplerDescriptor
A sampler descriptor for create_sampler.
Hit
The result of a ray-object intersection.
Input
A zero-sized namespace struct providing static input event extraction methods.
InputState
Tracks the current state of all input devices (keyboard, mouse, touch) for a single game frame. The state should be updated by event handlers and cleared of per-frame data at the end of each frame.
LazyLock
A value which is initialized on the first access.
Light
A light source contributing illumination to a shaded point.
LightingUniforms
Bundles of uniforms supplied to lighting and shading routines.
LinearGradient
A linear gradient defined by two endpoints and a list of color stops.
Material
A material describing how a surface responds to illumination.
Matrix4x4
A 4x4 matrix stored in column-major order, used for 3D transformations.
MaybeEngineCell
A Sync wrapper that may or may not contain a value.
NineSlice
A source image paired with the insets that split it into nine patches.
NineSliceInsets
The four per-edge border insets that carve an image into nine patches.
NineSliceRects
The nine source or destination sub-rectangles produced by a nine-slice split.
Numeric
A zero-sized namespace struct providing static math utility methods.
Occluder
A ray-traceable geometric surface with an attached material.
Particle
A single live particle.
ParticleConfig
The static configuration of a particle emitter, describing how new particles are spawned and how they evolve over their lifetime.
ParticleEmitter
A point emitter that continuously (or in bursts) spawns particles, integrates their motion, and records them into a DrawList as colored circles whose color and size interpolate over each particle’s lifetime.
ParticleRng
A deterministic xorshift64* pseudo-random generator used by particle emitters.
PendingErrorCell
Interior-mutable slot for the renderer’s pending error-scope value.
PhysicsConfig
Configuration parameters for the physics world simulation.
PhysicsConfig3D
Configuration parameters for the 3D physics world simulation.
PhysicsWorld2D
The physics world managing all rigid bodies and simulation steps.
PhysicsWorld3D
The 3D physics world managing all rigid bodies and simulation steps.
Plane
A 3D plane defined by a normal vector and a distance from the origin.
QuadTree2D
A 2D quadtree broad-phase acceleration structure, interface-compatible with SpatialHashGrid2D.
QuadTreeEntry2D
One inserted body inside a 2D quadtree, stored with its exact world-space axis-aligned bounding box.
QuadTreeNode2D
One node of the 2D quadtree, holding an axis-aligned region plus the entries that could not be pushed further down.
Quaternion
A quaternion representing a 3D rotation with x, y, z, and w components.
RadialGradient
A radial gradient defined by inner and outer circles and a list of color stops.
Ray
A 3D ray carrying the parameters needed for traversal and depth tracking.
Ray2D
A 2D ray defined by an origin point and a direction vector, used for raycasting against 2D shapes (Rect, Circle).
Ray3D
A 3D ray defined by an origin point and a direction vector.
RayTraceScene
An owned ray-tracing scene with precomputed shadow data.
Ready
A future that is immediately ready with a value.
Rect
An axis-aligned rectangle defined by its top-left corner and dimensions.
RenderConfig
Rendering configuration controlling the backend type, canvas target, viewport dimensions, quality, and backend-specific options.
RenderLayer
Represents the rendering priority layer for draw call ordering.
RenderPassColorAttachment
The descriptor for a single (color or depth-stencil) render pass attachment, used as input to begin_render_pass / begin_render_pass_to_texture.
RenderPassDepthStencilAttachment
The depth-stencil portion of a RenderPassDescriptor, used as input to begin_render_pass / begin_render_pass_to_texture.
RenderPassDescriptorCache
OPT 34: persistent render-pass descriptor and its inner attachments, reused across begin_render_pass_full calls.
RigidBody2D
A 2D rigid body participating in the physics simulation.
RigidBody3D
A 3D rigid body participating in the physics simulation.
SceneManager
Manages scene registration, transitions, and lifecycle.
SchedulerConfig
Configuration parameters for the fixed-timestep scheduler.
SchedulerHandle
A handle to a running scheduler, allowing the caller to stop it later.
SchedulerState
The runtime state of a scheduler instance.
ShadowConfig
Shadow rendering configuration for drop shadow effects on canvas primitives.
SpatialHashGrid2D
A uniform-grid spatial hash for broad-phase collision culling in 2D.
SpatialHashGrid3D
A uniform-grid spatial hash for broad-phase collision culling in 3D.
Sphere
A 3D sphere defined by its center point and radius.
SphereCollider3D
A 3D sphere collider wrapping a Sphere.
SpriteAnimation
A named sequence of frames that form an animation.
SpriteAtlas
A named collection of sprite regions packed into one shared image.
SpriteFrame
Defines a single frame in a sprite animation.
SpriteSheet
Defines a sprite sheet with uniform frame grid dimensions.
SsaaCanvas
A supersampling anti-aliasing (SSAA) canvas wrapper that renders at a higher resolution on an offscreen canvas and downscales to the display canvas for smoother polygon edges in software-rendered 3D scenes.
TaskHandle
A handle to a task registered with a TaskRegistry.
TaskRegistry
A registry of Updatable tasks driven by the fixed-timestep scheduler.
Texture2DDescriptor
A 2D texture descriptor for create_texture_2d.
TextureViewDescriptor
Descriptor for GpuTexture.createView(descriptor).
TextureWriteDescriptor
Descriptor for queue.writeTexture(destination, data, dataLayout, size).
Timer
A countdown timer that fires after a fixed duration, optionally repeating.
Transform2D
A 2D transform composed of position, rotation (in radians), and scale.
Transform3D
A 3D transform composed of position, rotation (as a quaternion), and scale.
Tween
A generic tween interpolating a value of type T from a start to an end value over a fixed duration, driven by an Easing curve.
UvRect
Normalized texture coordinates for one sub-rectangle of an atlas image.
Vector2D
A 2D vector with x and y components represented as f64.
Vector3D
A 3D vector with x, y, and z components represented as f64.
VertexAttribute
A single vertex attribute within a vertex buffer layout.
VertexBufferLayout
The layout of a single vertex buffer, expressed as an array stride plus a list of attributes.
ViewportDescriptor
Describes a 2D viewport rectangle plus optional depth range, in the same pixel space as the destination render target.
WebGlRenderer
A WebGL 2 rendering backend wrapping the WebGl2RenderingContext.
WebGpuRenderer
A WebGPU rendering backend wrapping the GPU device, queue, and canvas context for GPU-accelerated rendering on the web.

Enums§

AnimationMode
Defines how an animation behaves when it reaches the last frame.
AnimationState
Represents the current playback state of an animation.
AssetState
Represents the loading state of an asset in the cache.
AssetType
Categorizes the type of a game asset for appropriate loading and storage.
AudioPlayState
Represents the playback state of an audio clip.
BindGroupEntry
A single binding entry inside a BindGroupDescriptor.
BindGroupEntryType
The resource kind bound at a single slot of a BindGroupLayoutEntry.
BlendMode
Defines how new pixels are composited with existing pixels on the canvas.
BodyCollider
Wraps the concrete collider shape data attached to a rigid body.
BodyCollider3D
Wraps the concrete 3D collider shape data attached to a 3D rigid body.
BodyType
Defines how a rigid body participates in the physics simulation.
ColliderShape
Represents the geometric shape of a collider.
ColliderShape3D
Represents the geometric shape of a 3D collider.
DrawCommand
A single deferred draw operation recorded into a DrawList.
Easing
The complete set of Robert Penner easing functions used to warp a linear interpolation parameter into an accelerated / decelerated curve.
EntityEvent
Events that can be emitted by entities for inter-entity communication.
GpuPowerPreference
The power preference hint passed to navigator.gpu.requestAdapter.
GpuReceiverClass
WebGPU receiver-class discriminator for the cached_method cache.
InputAction
Represents a high-level input action category.
LightType
Describes the kind of light source being represented.
MaterialKind
Describes the shading model applied to a Material during lighting and ray-tracing evaluation.
MouseButton
Represents a standard mouse button identifier.
OccluderKind
Identifies the geometric shape of a ray-tracing Occluder.
RenderBackendType
The rendering backend type used by the engine.
RenderQuality
Rendering quality preset controlling anti-aliasing smoothing strategy.
TweenState
The playback state of a Tween.
VertexStepMode
Whether a vertex buffer is consumed per-vertex or per-instance.
WebGlInitError
Errors that can occur while initializing a WebGlRenderer.
WebGlProgramError
Errors that can occur while building a WebGL shader program.
WebGpuInitError
Errors that can occur while asynchronously initializing a WebGpuRenderer.

Constants§

DEFAULT_ANGULAR_DAMPING
The default angular damping coefficient applied per second.
DEFAULT_CAMERA_FAR
The default far clipping plane distance for a 3D perspective camera.
DEFAULT_CAMERA_FOV
The default vertical field of view in radians for a 3D perspective camera (~60 degrees).
DEFAULT_CAMERA_NEAR
The default near clipping plane distance for a 3D perspective camera.
DEFAULT_FIXED_TIMESTEP
The fixed timestep duration in seconds for the game loop (60 FPS).
DEFAULT_FRICTION
The default friction coefficient for rigid body surface contact.
DEFAULT_GRAVITY
The default gravity acceleration in pixels per second squared.
DEFAULT_GRAVITY_3D
The default 3D gravity acceleration in meters per second squared (pointing down on the y axis).
DEFAULT_LINEAR_DAMPING
The default linear damping coefficient applied per second.
DEFAULT_MAX_FRAME_TIME
The maximum accumulated time in seconds before the game loop drops frames.
DEFAULT_RESTITUTION
The default restitution (bounciness) for rigid body collisions.
DEG_TO_RAD
Conversion factor from degrees to radians.
EPSILON
A small epsilon value used for floating-point comparisons.
FRAC_PI_2
π/2
HALF_PI
Half of pi, a quarter circle angle in radians (~1.57079).
LIGHTING_PBR_ENERGY_CONSERVATION
The baseline reflectance weight applied to the MaterialKind::Pbr diffuse term before the Schlick fresnel factor is applied.
PI
Archimedes’ constant (π)
RAD_TO_DEG
Conversion factor from radians to degrees.
TAU
The full circle constant (τ)
TWO_PI
Two times pi, the full circle angle in radians (~6.28318).

Traits§

Collider
A trait for objects that can participate in collision detection.
Collider3D
A trait for 3D objects that can participate in collision detection.
Component
The base trait for all entity components.
Debug
? formatting.
Display
Format trait for an empty format, {}.
Error
Error is a trait representing the basic expectations for error values, i.e., values of type E in Result<T, E>.
Future
A future represents an asynchronous computation, commonly obtained by use of async.
Interpolable
A trait for types that support linear interpolation between two values.
Lifecycle
The common lifecycle stage shared by Component and Scene.
RenderBackend
An abstract rendering backend that decouples draw calls from the concrete canvas API, enabling future backends such as WebGL or WebGPU.
Renderable
A trait for objects that can record themselves into a draw list.
Scene
The base trait for all game scenes.
TickHandler
The trait that game implementations must fulfill to receive fixed-timestep update and interpolated render callbacks from the scheduler.
Updatable
A trait for objects that participate in the engine’s update step.
Vector
A trait abstracting the operations common to Vector2D and Vector3D.
Write
A trait for writing or formatting into Unicode-accepting buffers or streams.

Functions§

apply_axis_deadzone
Applies the analog deadzone to a single raw axis reading.
apply_falloff
Applies the inverse-square falloff formula 1.0 / (1.0 + falloff * d²), clamped to a non-negative result.
apply_schlick_fresnel
Computes a Schlick fresnel factor for the MaterialKind::Pbr branch of LightingUniforms::shade.
compute_held_buttons
Folds one frame of raw gamepad readings into the per-pad edge sets.
compute_lambert
Computes the Lambertian (diffuse) contribution of a single light at a shaded surface point.
compute_phong
Computes the Blinn-Phong specular contribution of a single light.
compute_pressed_buttons
Folds one frame of raw gamepad readings into the per-pad edge sets.
compute_released_buttons
Folds one frame of raw gamepad readings into the per-pad edge sets.
intersect_triangle
Intersects a ray with the triangle v0, v1, v2 using the Moller-Trumbore algorithm.
is_button_down
Tests whether one raw button pressure counts as the button being down.
mark_asset_closure_settled
Marks the asset load callback occupying slot as having run.
ray_aabb_intersect
Intersects a ray with an axis-aligned bounding box using the slab method.
ray_sphere_intersect
Intersects a ray with a sphere centered at center with radius radius.
read_raw_axis
Reads the nth analog axis out of a raw axis reading list.
ready
Creates a future that is immediately ready with a value.
replace
Moves src into the referenced dest, returning the previous dest value.
soft_shadow_factor
Computes a soft-shadow visibility factor in the range 0.0..=1.0.

Type Aliases§

AssetClosures
A reference-counted, shared-mutable store of asset load callbacks.
AssetPending
A shared counter of loads that have been requested but not yet settled.
CellEntries
A list of body indices stored within a single grid cell.
CellKey2D
A grid cell key for 2D spatial partitioning, combining x and y indices.
CellKey3D
A grid cell key for 3D spatial partitioning, combining x, y, and z indices.
ComponentRc
A reference-counted, shared-mutable handle to a dyn Component trait object.
EntityRc
A reference-counted, shared-mutable handle to an Entity.
EventHandler
A handler function that processes an EntityEvent.
EventHandlers
A handler function that processes an EntityEvent.
GamepadButtonSet
A set of gamepad button indices in a single frame edge state.
GamepadIndexSet
A set of gamepad indices in a single frame edge state.
GamepadManagerCell
A shared, single-threaded cell holding a GamepadManager.
GamepadStateMap
The states of every gamepad the manager has ever observed, keyed by the browser-assigned gamepad index.
InputStateCell
A shared, single-threaded cell holding the engine’s InputState.
KeyStateSet
A set of keyboard key code strings currently in a given state.
QuadTreeChildren2D
The four child node handles of a subdivided 2D quadtree node, ordered low-x/low-y, high-x/low-y, low-x/high-y, high-x/high-y.
QuadTreeEntryList2D
The list of body entries stored directly inside one 2D quadtree node.
QuadTreeNodeList2D
The flat node arena backing a 2D quadtree, addressed by node handle.
QuadTreeNodeStack2D
The explicit traversal stack used by 2D quadtree queries, so no recursion is needed and no Box-linked child borrows are required.
RafClosureCell
A reference-counted requestAnimationFrame closure cell.
SceneRc
A reference-counted, shared-mutable scene trait object.
SpatialCellMap2D
A hash map from 2D cell keys to lists of body indices.
SpatialCellMap3D
A hash map from 3D cell keys to lists of body indices.
TaskRegistryRc
A reference-counted shared-mutable TaskRegistry.
TickHandlerRc
A reference-counted shared-mutable container for a dyn TickHandler.
TouchPointMap
A map from touch identifier to touch position.

Derive Macros§

Debug
Derive macro generating an impl of the trait Debug.