Copyright 2025 s3ntin5l
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Overview
Tessellation is a lightweight, high-performance animation kernel for Roblox, designed to handle large numbers of animations reliably by enforcing state coherence and providing intelligent conflict resolution . It streamlines loading, caching, and playback while providing robust debugging, grouping, and advanced playback control.
This kernel abstracts animation track management, automatically handles character respawn, and integrates seamlessly into existing systems.
Key Features
Core Animation Management
- Deterministic Loading: Automatically loads and caches animation instances from specified folders.
- Intelligent Caching (LRU): Handles AnimationTrack caching with automatic respawn handling and Least Recently Used (LRU) eviction to limit memory use.
- State Coherence: Provides reliable animation state tracking across character respawns and Animator recreation.
Advanced Playback Control
- Flexible Configuration: Set
fadeTime,weight,priority,speed, andlooped. - Priority Conflict Resolution: Configurable strategies (
aggressive,conservative,manual) to intelligently resolve animation blending conflicts based on priority. - Animation Groups: Named groups for synchronized, multi-animation control, treating them as a single atomic unit.
- Batch Operations: Play or stop multiple animations or groups with single method calls.
Observability & Debugging
- Debug Pipeline: Built-in debugging that logs the entire animation lifecycle, including track loads, cache evictions, and errors.
- Configurable Throttling: Debug events are batched and throttled for minimal performance impact.
- Kernel Statistics: Real-time tracking of tracks loaded, active tracks, cache size, and error count via
kernel:GetStats().
Event System
- Marker Binding: Simplifies binding functions directly to named animation markers/keyframe events (
BindMarker). - Global Debug Signals: Subscribe to the kernel’s debug stream for global play/stop/error events.
Performance & Optimization
- Track Pooling: Efficient reuse of AnimationTrack objects.
- LRU Cache: Automatically destroys the least recently used tracks when cache limits are reached.
- Debounced Operations: Prevents excessive reloads during rapid changes (e.g., from character updates).
Usage
Basic Setup
local Tessellation = require(game.ReplicatedStorage.Tessellation)
local folder = game.ReplicatedStorage:WaitForChild("anims")
local player = game.Players.LocalPlayer
-- Create kernel with custom configuration
local kernel = Tessellation.new(folder, player, {
debugMode = true,
maxCachedTracks = 30, -- Set LRU cache limit
priorityStrategy = "aggressive" -- Automatically stop conflicting animations
})
-- Subscribe to the debug event stream for deep monitoring
local unsubscribe = kernel:SubscribeToDebug(function(event)
if event.type == "ERROR_MISSING_ANIMATION" then
warn(`[Analytics] Missing animation: {event.animationName}`)
elseif event.type == "TRACK_PLAY" then
print(`Playing: {event.animationName} - {event.details}`)
end
end)
Animation Playback
-- Single animation
kernel:Play("Run")
-- Advanced config
kernel:Play("Walk", {
fadeTime = 0.3,
weight = 0.8,
priority = Enum.AnimationPriority.Movement,
looped = true,
-- stopOthers is now handled by the kernel's priorityStrategy
})
-- Stop animation
kernel:Stop("Walk", 0.2)
-- Adjust a playing animation's speed and weight
kernel:Adjust("Walk", 0.5, 0.5) -- Speed = 0.5, Weight = 0.5
Animation Groups
kernel:CreateGroup("movement", {"Walk", "Run"}, {
priority = Enum.AnimationPriority.Movement,
fadeTime = 0.2
})
-- Play group: plays all members with the merged config
kernel:PlayGroup("movement")
-- Stop group
kernel:StopGroup("movement", 0.3)
Marker Binding
-- Bind a function to a specific named marker in the animation
kernel:BindMarker("Attack", "HitFrame", function()
print("Hit registered! Dealing damage now.")
dealDamage()
end)
-- You can safely call BindMarker multiple times; it manages connections internally.
API Reference
The Tessellation Kernel API is streamlined for robustness and predictability.
Core Controls
kernel:Play(name: string, config: table?) -> AnimationTrack? -- Play animation with optional configuration
kernel:Stop(name: string, fadeTime: number?) -> () -- Stop animation with optional fade
kernel:Adjust(name: string, speed: number?, weight: number?, fade: number?) -> () -- Adjust speed/weight of playing track
kernel:IsPlaying(name: string) -> boolean -- Check if animation is playing
kernel:StopAll(fadeTime: number?) -> () -- Stop all playing tracks managed by the kernel
Grouping & Events
kernel:CreateGroup(name: string, members: {string}, defaultConfig: table?) -> () -- Create animation group
kernel:PlayGroup(name: string, config: table?) -> {[string]: AnimationTrack?} -- Play animation group
kernel:StopGroup(name: string, fadeTime: number?) -> () -- Stop animation group
kernel:BindMarker(animName: string, markerName: string, callback: () -> ()) -> () -- Bind function to a specific animation marker
Configuration Options
Playback Configuration (Used in :Play and :CreateGroup)
| Field | Type | Default | Description |
|---|---|---|---|
| fadeTime | number | 0.2 |
Crossfade duration in seconds. |
| weight | number | 1 |
Animation blending weight. |
| speed | number | 1 |
Animation playback speed. |
| priority | Enum.AnimationPriority | Action |
Animation priority level. |
| looped | boolean | false |
Whether to loop the animation. |
| stopOthers | boolean | DEPRECATED | This is now handled entirely by the kernel’s priorityStrategy. Setting this is ignored. |
Kernel Configuration (Used in Tessellation.new / :UpdateConfig)
| Field | Type | Default | Description |
|---|---|---|---|
| debugMode | boolean | false |
Enables the debug event logging system. |
| maxCachedTracks | number | 50 |
Maximum number of AnimationTracks to keep in the LRU cache. 0 for unlimited. |
| priorityStrategy | string | "aggressive" |
Conflict resolution: “aggressive” (stops tracks of lower or same priority), “conservative” (stops only lower priority), “manual” (no auto-stop). |
| autoRetryLoads | boolean | true |
Retries failed AnimationTrack loads once to mitigate temporary issues. |
| gracefulDegradation | boolean | true |
Prevents the kernel from crashing on minor internal errors. |
Important Notes
Best Practices
- Use the Debug Pipeline (
:SubscribeToDebug) during development for full visibility into animation lifecycle, caching, and errors. - The kernel automatically manages track lifecycles (loading, respawns, cleanup). Do not manually attempt to stop or destroy AnimationTrack objects retrieved from the kernel.
- The
stopOthersfield in playback configuration is deprecated. Rely on thepriorityStrategyin the kernel configuration for conflict resolution.
Example Implementation
local Tessellation = require(game.ReplicatedStorage.Tessellation)
-- Setup
local player = game.Players.LocalPlayer
local animations = game.ReplicatedStorage.PlayerAnimations
-- Initialize with custom conflict resolution strategy and debug mode enabled
local kernel = Tessellation.new(animations, player, {
debugMode = true,
priorityStrategy = "conservative", -- Only stop strictly lower priority tracks
})
-- Subscribe to the debug event stream (Crucial for monitoring kernel activity!)
local unsubscribeDebug = kernel:SubscribeToDebug(function(event)
print(`[DEBUG {event.severity}] {event.type}: {event.animationName or "N/A"} -> {event.details}`)
if event.severity == "error" then
warn("KERNEL ERROR DETECTED")
end
end)
-- Create movement group
kernel:CreateGroup("movement", {"Walk", "Run", "Sprint"}, {
priority = Enum.AnimationPriority.Movement,
fadeTime = 0.15
})
-- Set up combat marker
kernel:BindMarker("Sword_Attack", "Hit", function()
-- Combat logic happens precisely on the Hit keyframe
dealDamage()
end)
-- Example usage
kernel:Play("Idle")
-- When 'Run' plays, the debug stream will log the 'TRACK_PLAY' event.
kernel:PlayGroup("movement", {name = "Run"})
-- Cleanup when player leaves or module is no longer needed
-- unsubscribeDebug() -- Remember to disconnect the debug subscription if needed!
kernel:Destroy()