Documentation
¶
Overview ¶
Package scene provides scene components and runtime systems built on ecs, including transforms, common cameras, 2D rendering, animation, and input. The ui package owns container layouts and widget constraints. The scene/render3d package owns the optional 3D renderer and binds its camera settings through RenderWorld.RegisterCameraRenderer. Applications install the systems they use.
Index ¶
- Variables
- func ActiveTaskCount[Tag, T any](world *ecs.World, dependency uint64, ...) int
- func AnimationTaskCount(world *ecs.World) int
- func AppendTextUnderlineRects2D(dst []TextRangeRect2D, text *Text2D, lineIndex, start, end int, ...) ([]TextRangeRect2D, TextRangeRect2D, bool)
- func Bounds2D(transform mgl32.Mat4, anchor Anchor, width, height float32) (float32, float32, float32, float32, bool)
- func BoundsInSpace2D(transform mgl32.Mat4, anchor Anchor, width, height float32, ui bool) (float32, float32, float32, float32, bool)
- func DispatchInputEvent(world *ecs.World, event InputEvent)
- func DispatchInputEvents2DSystem(name string) ecs.SystemConfig
- func Draw2D(c *graphics.Canvas2D, world *ecs.World, views DrawViews2D)
- func Draw2DSubtree(c *graphics.Canvas2D, world *ecs.World, root ecs.Entity, views DrawViews2D)
- func DrawScreenText2D(c *graphics.Canvas2D, text *Text2D, transform mgl32.Mat4, anchor Anchor) bool
- func EvalWebView(world *ecs.World, entity ecs.Entity, script string) error
- func ExtractCameras(context *ecs.SystemContext) error
- func ExtractCamerasSystem(name string) ecs.SystemConfig
- func ExtractRender2DSystem(name string) ecs.SystemConfig
- func GetUIScrollOffset(world *ecs.World, entity ecs.Entity) (mgl32.Vec2, bool)
- func IsActive(world *ecs.World, entity ecs.Entity) bool
- func IsInteractive(world *ecs.World, entity ecs.Entity) bool
- func IsVisible(world *ecs.World, entity ecs.Entity) bool
- func MeasureText2D(text *Text2D) (float32, float32, bool)
- func MeasureTextLineOffsets2D(text *Text2D, value string, offsets []int, widths []float32) bool
- func MeasureTextMinimumWidth2D(text *Text2D) (float32, bool)
- func MeasureTextValue2D[V piecetree.Value](text *Text2D, inputValue V) (float32, float32, bool)
- func NavigateWebView(world *ecs.World, entity ecs.Entity, url string) error
- func ParticleEmitterBounds2D(emitter *ParticleEmitter2D, transform mgl32.Mat4, ui bool) (float32, float32, float32, float32, bool)
- func ParticleTaskCount(world *ecs.World) int
- func PrepareText2D(text *Text2D) bool
- func PrimaryCamera2D(world *ecs.World) (ecs.Entity, bool)
- func PrimaryCamera2DView(world *ecs.World) (Camera, Projection, GlobalTransform, bool)
- func QueueMaterial2DUploads(queue *graphics.UploadQueue, world *ecs.World, entity ecs.Entity)
- func RegisterCameraRenderer2D(world *ecs.World)
- func RegisterParticleRenderer2D(world *ecs.World)
- func RegisterSpineRenderer2D(world *ecs.World)
- func RegisterSpriteLayersRenderer2D(world *ecs.World)
- func RegisterSpriteRenderer2D(world *ecs.World)
- func RegisterSpriteTrailRenderer2D(world *ecs.World)
- func RegisterTextRenderer2D(world *ecs.World)
- func RegisterTilemapRenderer2D(world *ecs.World)
- func RegisterUIRenderer2D(world *ecs.World)
- func RemapInputEntity2D(world *ecs.World, previous, current ecs.Entity)
- func RenderCamerasSystem(name string) ecs.SystemConfig
- func RenderDebugInfoSystem(name string) ecs.SystemConfig
- func SampleAnimationProgress(tween AnimationTween, curve AnimationCurve, progress float32) float32
- func ScrollThumbSize(trackSize, viewportSize, contentSize, minThumbSize float32) float32
- func SetUIShapeFragment2D(world *ecs.World, entity ecs.Entity, index int, fragment UIShapeFragment2D)
- func SetUIShapeFragmentFill2D(world *ecs.World, entity ecs.Entity, index int, color graphics.ColorRGBA)
- func SetUIShapeFragments2D(world *ecs.World, entity ecs.Entity, fragments []UIShapeFragment2D)
- func SortedCameraEntities(world *ecs.World) []ecs.Entity
- func SpawnCamera2D(world *ecs.World) ecs.Entity
- func SpawnDebugInfo(world *ecs.World) ecs.Entity
- func SpineModelMatrix2D(transform mgl32.Mat4, ui bool) mgl32.Mat4
- func SpineTaskCount(world *ecs.World) int
- func SpriteBounds2D(sprite *Sprite2D, anchor Anchor, transform mgl32.Mat4, ui bool) (float32, float32, float32, float32, bool)
- func SpriteTrailTaskCount(world *ecs.World) int
- func SyncGlobalTransformSystem(name string) ecs.SystemConfig
- func SyncPointerCursor2D(world *ecs.World)
- func SyncUIGlobalTransformSystem(name string) ecs.SystemConfig
- func SyncWebViews(world *ecs.World) error
- func TextBounds2D(text *Text2D, anchor Anchor, transform mgl32.Mat4, ui bool) (float32, float32, float32, float32, bool)
- func TextCaretIndex2D[V piecetree.Value](text *Text2D, inputValue V, x, y float32) int
- func TextCaretRect2D[V piecetree.Value](text *Text2D, inputValue V, caret int) (x, y, width, height float32, ok bool)
- func TextLineCount2D(text *Text2D) int
- func TextSelectionRects2D[V piecetree.Value](text *Text2D, inputValue V, start, end int, top, bottom float32) iter.Seq[TextRangeRect2D]
- func UIScrollScrollbarActive(world *ecs.World, entity ecs.Entity, axis uint8) bool
- func UIScrollSystem(name string) ecs.SystemConfig
- func UIScrollTrackSize(scroll *UIScroll, viewport mgl32.Vec2) mgl32.Vec2
- func UpdateParticleEmitter2DSystem(name string) ecs.SystemConfig
- func UpdateSpine2DSystem(name string) ecs.SystemConfig
- func UpdateSpriteTrail2DSystem(name string) ecs.SystemConfig
- func UpdateUIAnimatorSystem(name string) ecs.SystemConfig
- func UpdateWorldAnimatorSystem(name string) ecs.SystemConfig
- func ValidateAnimationTimeCurve(tween AnimationTween, curve AnimationCurve) error
- func ViewportToWorld2D(world *ecs.World, viewportPosition mgl32.Vec2) (mgl32.Vec2, bool)
- func WebViewSystem(name string) ecs.SystemConfig
- func WebViewTaskCount(world *ecs.World) int
- func WorldToViewport2D(world *ecs.World, worldPosition mgl32.Vec2) (mgl32.Vec2, bool)
- type Activity
- type Anchor
- type AnimationBinding
- type AnimationClip
- type AnimationCurve
- type AnimationEvent
- type AnimationEventMessage
- type AnimationKeyframe
- type AnimationQuaternionSpline
- type AnimationTarget
- type AnimationTrack
- type AnimationTween
- type Animator
- func (a *Animator) Advance(delta float32)
- func (a *Animator) BindTargets(owner ecs.Entity, floatTargets, textureTargets, boolTargets []ecs.Entity)
- func (a *Animator) CurrentTexture() *graphics.Texture
- func (a *Animator) IsBound() bool
- func (a *Animator) Pause()
- func (a *Animator) Play()
- func (a *Animator) Restart()
- func (a *Animator) Seek(time float32)
- func (a *Animator) Time() float32
- type Camera
- func (c Camera) ClipFromWorld(transform GlobalTransform, projection Projection) mgl32.Mat4
- func (c Camera) ResolvedViewport() CameraViewport
- func (c *Camera) UpdateViewport(width, height int)
- func (c Camera) ViewportSize() (float32, float32)
- func (c Camera) ViewportToWorld2D(transform GlobalTransform, projection Projection, viewportPosition mgl32.Vec2) (mgl32.Vec2, bool)
- func (c Camera) WorldToViewport2D(transform GlobalTransform, projection Projection, worldPosition mgl32.Vec2) (mgl32.Vec2, bool)
- type Camera2D
- type CameraPipeline
- type CameraRenderOptions
- type CameraRenderer
- type CameraViewport
- type ClipExempt2D
- type ClipRect2D
- type CompositeSettings2D
- type CompositeStatistics2D
- type DebugInfo
- type DrawViews2D
- type ExtractedCamera
- type FixedTime
- func (t *FixedTime) Accumulate(delta time.Duration, maxDelta time.Duration)
- func (t *FixedTime) DeltaSeconds() float32
- func (t *FixedTime) ElapsedSeconds() float32
- func (t *FixedTime) Expend() bool
- func (t *FixedTime) OverstepFraction() float32
- func (t *FixedTime) SetTimestep(timestep time.Duration)
- type FocusedInputContext
- type FocusedInputEvent
- type FocusedInputHandler
- type GlobalTransform
- type Hierarchy
- func (h *Hierarchy) Depth(entity ecs.Entity) int
- func (h *Hierarchy) Entities() []ecs.Entity
- func (h *Hierarchy) FirstChild(entity ecs.Entity) ecs.Entity
- func (h *Hierarchy) MaintainCache()
- func (h *Hierarchy) NextSibling(entity ecs.Entity) ecs.Entity
- func (h *Hierarchy) Parent(entity ecs.Entity) ecs.Entity
- func (h *Hierarchy) Version() uint64
- func (h *Hierarchy) WalkSubtree(root ecs.Entity, visit func(ecs.Entity) bool)
- type InputBlocker2D
- type InputCapture2D
- type InputEvent
- type InputEventContext
- type InputEventKind
- type InputFilter
- type InputFocus
- type InputHandler2D
- type InputMask
- type InputRoute2D
- type InputState2D
- type InputTarget2D
- type MeshMaterial2D
- type Name
- type NineSlice2D
- type OrthographicArea
- type OrthographicProjection
- type PainterGroup2D
- type Parent
- type ParticleAppearance2D
- type ParticleEmitter2D
- type PerspectiveProjection
- type Projection
- type ProjectionKind
- type RenderLayers
- type RenderOrder2D
- type RenderOutput2D
- type RenderOutputHandle
- type RenderOutputPool
- type RenderPreparation2D
- type RenderRequest
- type RenderSettings2D
- type RenderWorld
- type ResolvedUIRect
- type RoundedClip2D
- type ScalingMode
- type ScalingModeKind
- type SceneLayer
- type Shader
- type Shape2D
- func CheckmarkShape2D(fill graphics.ColorRGBA) Shape2D
- func OutlinedRoundedRectShape2D(fill, border graphics.ColorRGBA, radius, borderWidth float32) Shape2D
- func RoundedRectShape2D(fill graphics.ColorRGBA, radius float32) Shape2D
- func TriangleShape2D(fill graphics.ColorRGBA, direction uint8) Shape2D
- type SiblingOrder
- type Size2D
- type Spine2D
- type Sprite2D
- type SpriteLayer2D
- type SpriteLayerTransform2D
- type SpriteLayers2D
- type SpriteTrail2D
- type Text2D
- type TextAlignment
- type TextIndex
- type TextInlineObject2D
- type TextInlineObjectRect2D
- type TextLineLayout2D
- type TextPrelayout2D
- type TextRangeRect2D
- type TextSpan2D
- type TextWrapMode
- type Tilemap2D
- type Time
- type Transform
- type UIBackground2D
- type UIBorder2D
- type UIBoxPaint2D
- type UIGlobalTransform
- type UIImage2D
- type UIImageMode
- type UIPaint2D
- type UIPaintList2D
- func (list *UIPaintList2D) Capacity() (boxes, free, glyphs int)
- func (list *UIPaintList2D) Compact() []uint32
- func (list *UIPaintList2D) Len() int
- func (list *UIPaintList2D) RemoveBox(id uint32)
- func (list *UIPaintList2D) Reset()
- func (list *UIPaintList2D) SetBox(id uint32, box UIBoxPaint2D) uint32
- func (list *UIPaintList2D) SetOrder(id uint32, stack int, order uint32)
- type UIRect
- type UIResolveContext
- type UIScroll
- type UIScrollContainerData
- type UIShapeFragment2D
- type UIStackIndex
- type UIStaticText2D
- type UITargetCamera
- type UITransform
- type UIVisualRects2D
- type Val
- func (v Val) Add(other Val) (Val, error)
- func (v Val) IsZero() bool
- func (v Val) MarshalJSON() ([]byte, error)
- func (v Val) Mul(factor float32) Val
- func (v Val) Resolve(scaleFactor, baseValue float32, viewport mgl32.Vec2) (float32, bool)
- func (v Val) String() string
- func (v Val) Sub(other Val) (Val, error)
- func (v *Val) UnmarshalJSON(data []byte) error
- type Val2
- type ValKind
- type ViewportSize
- type Visibility
- type WebView
- type WebViewBackend
- type WebViewBounds
- type WebViewEvent
- type WebViewEventKind
- type WebViewHandle
- type WebViewHandler
- type WebViewInvoke
- type WebViewMessageHandler
- type WebViewOptions
- type WebViewRuntime
Constants ¶
This section is empty.
Variables ¶
var ( AnchorBottomLeft = Anchor{-0.5, -0.5} AnchorBottomCenter = Anchor{0, -0.5} AnchorBottomRight = Anchor{0.5, -0.5} AnchorCenterLeft = Anchor{-0.5, 0} AnchorCenter = Anchor{} AnchorCenterRight = Anchor{0.5, 0} AnchorTopLeft = Anchor{-0.5, 0.5} AnchorTopCenter = Anchor{0, 0.5} AnchorTopRight = Anchor{0.5, 0.5} )
var ( ErrOutputCapacity = errors.New("scene: render output lease capacity reached") ErrOutputReleased = errors.New("scene: render output lease released") )
var ErrIncompatibleValUnits = errors.New("ecs: incompatible Val units")
ErrWebViewUnavailable indicates that the current target has no browser backend. WeChat builds intentionally return this error.
Functions ¶
func ActiveTaskCount ¶
func ActiveTaskCount[Tag, T any](world *ecs.World, dependency uint64, ready func(*ecs.World, ecs.Entity, *T) bool) int
ActiveTaskCount counts scoped, active entities satisfying ready. Tag identifies the predicate; dependency changes invalidate inputs it reads outside T. Unchanged inputs reuse the count without scanning entities or allocating.
func AnimationTaskCount ¶
func AppendTextUnderlineRects2D ¶
func AppendTextUnderlineRects2D(dst []TextRangeRect2D, text *Text2D, lineIndex, start, end int, thickness float32) ([]TextRangeRect2D, TextRangeRect2D, bool)
AppendTextUnderlineRects2D appends baseline-aligned underline segments for a byte range on one visual line, leaving gaps around ink crossing the underline. The returned bounds include those gaps. Reusing dst avoids allocations.
func BoundsInSpace2D ¶
func DispatchInputEvent ¶
func DispatchInputEvent(world *ecs.World, event InputEvent)
DispatchInputEvent delivers an event to its target path and publishes the result. Handlers may stop propagation or consume the event; nested dispatch reuses scratch storage.
func DispatchInputEvents2DSystem ¶
func DispatchInputEvents2DSystem(name string) ecs.SystemConfig
func Draw2D ¶
func Draw2D(c *graphics.Canvas2D, world *ecs.World, views DrawViews2D)
Draw2D draws every registered 2D renderer using explicit world and UI views.
func Draw2DSubtree ¶
Draw2DSubtree draws registered 2D render items owned by root or one of its descendants. Filtering reuses the frame render-item buffer.
func DrawScreenText2D ¶
func EvalWebView ¶
EvalWebView evaluates script in a materialized WebView.
func ExtractCameras ¶
func ExtractCameras(context *ecs.SystemContext) error
ExtractCameras refreshes snapshots of active registered cameras. Pipelines can call it directly without constructing a SystemConfig.
func ExtractCamerasSystem ¶
func ExtractCamerasSystem(name string) ecs.SystemConfig
func ExtractRender2DSystem ¶
func ExtractRender2DSystem(name string) ecs.SystemConfig
ExtractRender2DSystem extracts items for the renderers registered in world.
func GetUIScrollOffset ¶
func IsInteractive ¶
IsInteractive requires both activity and visibility along the parent chain. Hidden UI cannot retain keyboard focus or receive semantic form input.
func IsVisible ¶
IsVisible allows paused overlay backgrounds to render without enabling their simulation or input. Query scopes determine scene participation.
func MeasureTextLineOffsets2D ¶
MeasureTextLineOffsets2D writes prefix widths for sorted UTF-8 byte offsets in a single pass. Callers supply storage so repeated measurements allocate nothing, including lines with many highlighted ranges.
func MeasureTextValue2D ¶
func NavigateWebView ¶
NavigateWebView updates a WebView URL and applies it immediately when its native handle already exists. A later synchronization pass retries the operation when the component was not materialized yet.
func ParticleEmitterBounds2D ¶
func ParticleTaskCount ¶
func PrepareText2D ¶
PrepareText2D shapes and rasterizes the current glyph window without uploading its atlas. Call on the owning loop thread after layout has settled.
func PrimaryCamera2DView ¶
func PrimaryCamera2DView(world *ecs.World) (Camera, Projection, GlobalTransform, bool)
func QueueMaterial2DUploads ¶
QueueMaterial2DUploads uses the same registered generic material readers as rendering, including the entity's shader override.
func RegisterSpineRenderer2D ¶
func RegisterTextRenderer2D ¶
func RegisterUIRenderer2D ¶
func RemapInputEntity2D ¶
RemapInputEntity2D preserves pointer tracking when a retained UI control is rebuilt with a new entity identity during an active input.
func RenderCamerasSystem ¶
func RenderCamerasSystem(name string) ecs.SystemConfig
RenderCamerasSystem submits every registered camera pipeline in camera order.
func RenderDebugInfoSystem ¶
func RenderDebugInfoSystem(name string) ecs.SystemConfig
func SampleAnimationProgress ¶
func SampleAnimationProgress(tween AnimationTween, curve AnimationCurve, progress float32) float32
SampleAnimationProgress applies a keyframe tween to normalized progress. Time is clamped to [0, 1]; Back, Elastic and Bezier may overshoot in value.
func ScrollThumbSize ¶
ScrollThumbSize resolves the proportional scrollbar thumb within its track.
func SetUIShapeFragment2D ¶ added in v0.1.8
func SetUIShapeFragment2D(world *ecs.World, entity ecs.Entity, index int, fragment UIShapeFragment2D)
SetUIShapeFragment2D updates the geometry and paint of a single fragment.
func SetUIShapeFragmentFill2D ¶ added in v0.1.8
func SetUIShapeFragmentFill2D(world *ecs.World, entity ecs.Entity, index int, color graphics.ColorRGBA)
SetUIShapeFragmentFill2D updates the fill of a single fragment.
func SetUIShapeFragments2D ¶ added in v0.1.8
func SetUIShapeFragments2D(world *ecs.World, entity ecs.Entity, fragments []UIShapeFragment2D)
SetUIShapeFragments2D replaces the paint fragments, reusing their storage.
func SpineTaskCount ¶
func SpriteBounds2D ¶
func SpriteTrailTaskCount ¶
func SyncGlobalTransformSystem ¶
func SyncGlobalTransformSystem(name string) ecs.SystemConfig
func SyncPointerCursor2D ¶ added in v0.1.4
SyncPointerCursor2D refreshes the hovered entity's cursor after UI style updates. It reuses the input dispatcher's hit result without another hit-test traversal.
func SyncUIGlobalTransformSystem ¶
func SyncUIGlobalTransformSystem(name string) ecs.SystemConfig
func SyncWebViews ¶
SyncWebViews runs one WebView synchronization pass immediately.
func TextBounds2D ¶
func TextCaretIndex2D ¶
func TextCaretRect2D ¶
func TextCaretRect2D[V piecetree.Value](text *Text2D, inputValue V, caret int) (x, y, width, height float32, ok bool)
TextCaretRect2D returns the local caret rectangle for a rune index. It uses the text layout's actual line ranges, so wrapped lines and explicit newlines share the same geometry as rendering and hit testing.
func TextLineCount2D ¶
TextLineCount2D returns the number of visual lines without allocating.
func TextSelectionRects2D ¶
func TextSelectionRects2D[V piecetree.Value](text *Text2D, inputValue V, start, end int, top, bottom float32) iter.Seq[TextRangeRect2D]
TextSelectionRects2D visits the selected visual rows in a vertical viewport. Selection offsets are runes; bottom <= top disables viewport culling. It searches cached line ranges and measures only the selected visible rows.
func UIScrollScrollbarActive ¶
UIScrollScrollbarActive keeps a thumb expanded while hovered or captured. axis is 0 for horizontal and 1 for vertical.
func UIScrollSystem ¶
func UIScrollSystem(name string) ecs.SystemConfig
func UIScrollTrackSize ¶
UIScrollTrackSize excludes the shared corner when both overlay bars are visible.
func UpdateParticleEmitter2DSystem ¶
func UpdateParticleEmitter2DSystem(name string) ecs.SystemConfig
func UpdateSpine2DSystem ¶
func UpdateSpine2DSystem(name string) ecs.SystemConfig
func UpdateSpriteTrail2DSystem ¶
func UpdateSpriteTrail2DSystem(name string) ecs.SystemConfig
func UpdateUIAnimatorSystem ¶
func UpdateUIAnimatorSystem(name string) ecs.SystemConfig
UpdateUIAnimatorSystem updates UI animators after layout has authored the frame's base positions and before UI global transforms are synchronized.
func UpdateWorldAnimatorSystem ¶
func UpdateWorldAnimatorSystem(name string) ecs.SystemConfig
UpdateWorldAnimatorSystem updates animators that own world-space nodes. It is scheduled before global transform propagation so animated locals are visible to the same frame's hierarchy sync.
func ValidateAnimationTimeCurve ¶
func ValidateAnimationTimeCurve(tween AnimationTween, curve AnimationCurve) error
ValidateAnimationTimeCurve checks a track's normalized playback time mapping. Spline interpolation needs value tangents and cannot be used as a time curve.
func ViewportToWorld2D ¶
func WebViewSystem ¶
func WebViewSystem(name string) ecs.SystemConfig
WebViewSystem synchronizes WebView components into the runtime resource. It is intended for an update stage after scene/component mutations.
func WebViewTaskCount ¶
WebViewTaskCount keeps native browser callbacks serviced while a view exists. Installing the feature without any browser surfaces does not prevent idle.
Types ¶
type Activity ¶
type Activity struct{ Active bool }
Activity controls simulation independently of visibility. An entity may be invisible while running; suspended scene content must do neither.
type Anchor ¶
type Anchor [2]float32
type AnimationBinding ¶
type AnimationBinding struct {
Path string `json:"path,omitempty"`
Target AnimationTarget `json:"target"`
}
type AnimationClip ¶
type AnimationClip struct {
BoolTracks []AnimationTrack[bool]
TextureTracks []AnimationTrack[*graphics.Texture]
Events []AnimationEvent
FloatTracks []AnimationTrack[float32]
Duration float32
// contains filtered or unexported fields
}
func (*AnimationClip) Prepare ¶
func (c *AnimationClip) Prepare() error
Prepare validates and freezes the clip's compiled track metadata. Project loaders call it once before instances share the clip, keeping playback free of setup allocations.
func (*AnimationClip) RequiresSprite2D ¶
func (c *AnimationClip) RequiresSprite2D() (bool, error)
RequiresSprite2D reports whether root tracks require a Sprite2D target.
type AnimationCurve ¶
type AnimationCurve struct {
X1 float32 `json:"x1"`
Y1 float32 `json:"y1"`
X2 float32 `json:"x2"`
Y2 float32 `json:"y2"`
}
AnimationCurve maps normalized time to normalized animation progress using a cubic Bezier curve with fixed endpoints (0, 0) and (1, 1).
func EaseInAnimationCurve ¶
func EaseInAnimationCurve() AnimationCurve
func EaseInOutAnimationCurve ¶
func EaseInOutAnimationCurve() AnimationCurve
func EaseOutAnimationCurve ¶
func EaseOutAnimationCurve() AnimationCurve
func LinearAnimationCurve ¶
func LinearAnimationCurve() AnimationCurve
func (AnimationCurve) Sample ¶
func (c AnimationCurve) Sample(progress float32) float32
func (AnimationCurve) Validate ¶
func (c AnimationCurve) Validate() error
type AnimationEvent ¶
type AnimationEventMessage ¶
type AnimationKeyframe ¶
type AnimationKeyframe[T any] struct { Value T InTangent T OutTangent T Tween AnimationTween QuaternionSpline AnimationQuaternionSpline Curve AnimationCurve Time float32 InverseSpan float32 }
type AnimationQuaternionSpline ¶
type AnimationQuaternionSpline struct {
Value [4]float32
InTangent [4]float32
OutTangent [4]float32
Component uint8
}
AnimationQuaternionSpline preserves glTF quaternion cubic data while the public transform bindings continue to target individual Euler components. Component is one-based; zero disables quaternion sampling for the key.
type AnimationTarget ¶
type AnimationTarget string
const ( AnimationTargetSpriteTexture AnimationTarget = "sprite.texture" AnimationTargetSpriteAlpha AnimationTarget = "sprite.alpha" AnimationTargetTransformPositionX AnimationTarget = "transform.position.x" AnimationTargetTransformPositionY AnimationTarget = "transform.position.y" AnimationTargetTransformPositionZ AnimationTarget = "transform.position.z" AnimationTargetTransformScaleX AnimationTarget = "transform.scale.x" AnimationTargetTransformScaleY AnimationTarget = "transform.scale.y" AnimationTargetTransformScaleZ AnimationTarget = "transform.scale.z" AnimationTargetTransformRotationX AnimationTarget = "transform.rotation.x" AnimationTargetTransformRotationY AnimationTarget = "transform.rotation.y" AnimationTargetTransformRotationZ AnimationTarget = "transform.rotation.z" AnimationTargetVisibility AnimationTarget = "visibility.visible" )
type AnimationTrack ¶
type AnimationTrack[T any] struct { Binding AnimationBinding // TimeTween remaps elapsed time over the first-to-last keyframe interval. // Discrete tracks still select frames; the curve changes their playback pace. TimeTween AnimationTween Keyframes []AnimationKeyframe[T] TimeCurve AnimationCurve // contains filtered or unexported fields }
func NewAnimationTrack ¶
func NewAnimationTrack[T any](binding AnimationBinding, keyframes []AnimationKeyframe[T]) AnimationTrack[T]
type AnimationTween ¶
type AnimationTween string
AnimationTween controls the curve applied from one keyframe to the next.
const ( AnimationStep AnimationTween = "step" AnimationLinear AnimationTween = "linear" AnimationEaseIn AnimationTween = "easeIn" AnimationEaseOut AnimationTween = "easeOut" AnimationEaseInOut AnimationTween = "easeInOut" AnimationBezier AnimationTween = "bezier" AnimationCubicSpline AnimationTween = "cubicSpline" )
const ( AnimationEaseInSine AnimationTween = "easeInSine" AnimationEaseOutSine AnimationTween = "easeOutSine" AnimationEaseInOutSine AnimationTween = "easeInOutSine" AnimationEaseInCubic AnimationTween = "easeInCubic" AnimationEaseOutCubic AnimationTween = "easeOutCubic" AnimationEaseInOutCubic AnimationTween = "easeInOutCubic" AnimationEaseInQuart AnimationTween = "easeInQuart" AnimationEaseOutQuart AnimationTween = "easeOutQuart" AnimationEaseInOutQuart AnimationTween = "easeInOutQuart" AnimationEaseInQuint AnimationTween = "easeInQuint" AnimationEaseOutQuint AnimationTween = "easeOutQuint" AnimationEaseInOutQuint AnimationTween = "easeInOutQuint" AnimationEaseInExpo AnimationTween = "easeInExpo" AnimationEaseOutExpo AnimationTween = "easeOutExpo" AnimationEaseInOutExpo AnimationTween = "easeInOutExpo" AnimationEaseInCirc AnimationTween = "easeInCirc" AnimationEaseOutCirc AnimationTween = "easeOutCirc" AnimationEaseInOutCirc AnimationTween = "easeInOutCirc" AnimationEaseInBack AnimationTween = "easeInBack" AnimationEaseOutBack AnimationTween = "easeOutBack" AnimationEaseInOutBack AnimationTween = "easeInOutBack" AnimationEaseInElastic AnimationTween = "easeInElastic" AnimationEaseOutElastic AnimationTween = "easeOutElastic" AnimationEaseInOutElastic AnimationTween = "easeInOutElastic" AnimationEaseInBounce AnimationTween = "easeInBounce" AnimationEaseOutBounce AnimationTween = "easeOutBounce" AnimationEaseInOutBounce AnimationTween = "easeInOutBounce" )
func (AnimationTween) Valid ¶
func (t AnimationTween) Valid() bool
Valid reports whether the tween is supported by the runtime sampler.
type Animator ¶
type Animator struct {
Clip *AnimationClip
Speed float32
Playing bool
Loop bool
// contains filtered or unexported fields
}
func NewAnimator ¶
func NewAnimator(clip *AnimationClip, loop bool) Animator
func NewBoundAnimator ¶
func NewBoundAnimator(clip *AnimationClip, loop bool, owner ecs.Entity, floatTargets, textureTargets, boolTargets []ecs.Entity) Animator
NewBoundAnimator creates one playback state for a shared clip and binds its typed tracks to concrete scene entities. The target slices are copied once at instantiation; subsequent updates perform only ECS component access.
func (*Animator) BindTargets ¶
func (a *Animator) BindTargets(owner ecs.Entity, floatTargets, textureTargets, boolTargets []ecs.Entity)
BindTargets attaches concrete entities to an existing animator. It is useful for pooled entities whose clip is unchanged but hierarchy IDs are assigned only when the pool slot is activated.
func (*Animator) CurrentTexture ¶
type Camera ¶
type Camera struct {
Viewport CameraViewport
Order int
Active bool
Clear bool
ClearColor graphics.ColorRGBA
// Fallback is reserved for the engine camera used without an authored 2D camera.
Fallback bool
// contains filtered or unexported fields
}
func (Camera) ClipFromWorld ¶
func (c Camera) ClipFromWorld(transform GlobalTransform, projection Projection) mgl32.Mat4
func (Camera) ResolvedViewport ¶
func (c Camera) ResolvedViewport() CameraViewport
func (*Camera) UpdateViewport ¶
func (Camera) ViewportSize ¶
func (Camera) ViewportToWorld2D ¶
func (c Camera) ViewportToWorld2D(transform GlobalTransform, projection Projection, viewportPosition mgl32.Vec2) (mgl32.Vec2, bool)
func (Camera) WorldToViewport2D ¶
func (c Camera) WorldToViewport2D(transform GlobalTransform, projection Projection, worldPosition mgl32.Vec2) (mgl32.Vec2, bool)
type CameraPipeline ¶
type CameraPipeline uint8
const ( CameraPipeline2D CameraPipeline = iota CameraPipeline3D )
type CameraRenderOptions ¶
type CameraRenderOptions struct {
Target *render.RenderTarget
ViewMode render.RenderViewMode
DepthClear float32
}
CameraRenderOptions contains the output settings shared by camera pipelines.
type CameraRenderer ¶
CameraRenderer submits the prepared render data for one extracted camera.
type CameraViewport ¶
type CameraViewport struct {
X float32 `json:"x"`
Y float32 `json:"y"`
Width float32 `json:"width"`
Height float32 `json:"height"`
}
func (CameraViewport) PlacementMatrix ¶
func (viewport CameraViewport) PlacementMatrix(width, height float32) mgl32.Mat4
PlacementMatrix maps local clip coordinates into this viewport's output region.
type ClipExempt2D ¶
type ClipExempt2D struct {
// ParentOnly skips the immediate parent's clip while retaining ancestor clips.
ParentOnly bool
}
type CompositeSettings2D ¶
type CompositeSettings2D struct{ MaxCacheBytes int64 }
CompositeSettings2D bounds the persistent viewport cache. A negative budget disables it; zero selects 64 MiB. Dense animation uses direct drawing.
type CompositeStatistics2D ¶
type CompositeStatistics2D struct {
Tiles, DirtyTiles int
ReusedTiles int
RasterPixels int
Submitted, Occluded int
PreparedItems, PreparedTiles int
CacheBytes int64
Direct bool
}
CompositeStatistics2D distinguishes cached pixels from draw submission work. RasterPixels is the area redrawn, not a GPU time or fragment-count estimate.
type DebugInfo ¶
type DebugInfo struct {
Scale float32
Margin float32
Padding float32
TextColor graphics.ColorRGBA
BackgroundColor graphics.ColorRGBA
}
DebugInfo enables a compact frame statistics overlay in the top-left corner. Zero-valued fields use the defaults returned by NewDebugInfo.
func NewDebugInfo ¶
func NewDebugInfo() DebugInfo
type ExtractedCamera ¶
type ExtractedCamera struct {
Target *render.RenderTarget
RenderLayers RenderLayers
Camera Camera
Scene SceneLayer
Entity ecs.Entity
Projection Projection
Transform GlobalTransform
OutputSize mgl32.Vec2
DepthClear float32
Pipeline CameraPipeline
ViewMode render.RenderViewMode
}
func (ExtractedCamera) ClipFromWorld ¶
func (camera ExtractedCamera) ClipFromWorld() mgl32.Mat4
ClipFromWorld includes viewport placement for draws into the full output surface.
type FixedTime ¶
type FixedTime struct {
Timestep time.Duration
Overstep time.Duration
Delta time.Duration
Elapsed time.Duration
Frame uint64
}
func NewFixedTime ¶
func (*FixedTime) Accumulate ¶
func (*FixedTime) DeltaSeconds ¶
func (*FixedTime) ElapsedSeconds ¶
func (*FixedTime) OverstepFraction ¶
func (*FixedTime) SetTimestep ¶
type FocusedInputContext ¶
type FocusedInputContext struct {
World *ecs.World
Event input.Event
Entity ecs.Entity
Handled bool
}
func (*FocusedInputContext) Consume ¶
func (c *FocusedInputContext) Consume()
type FocusedInputEvent ¶
FocusedInputEvent routes one keyboard or text event to the focused entity.
type FocusedInputHandler ¶
type FocusedInputHandler struct {
Handle func(*FocusedInputContext)
}
FocusedInputHandler handles keyboard/text input synchronously on the focused entity.
type GlobalTransform ¶
type Hierarchy ¶
type Hierarchy struct {
// contains filtered or unexported fields
}
Hierarchy is the world-owned parent/child index shared by scene systems. It includes suspended scenes and never retains component storage pointers.
func HierarchyFor ¶
HierarchyFor synchronizes topology and invalidates inherited state only in affected subtrees. Borrowed lists remain valid until the next synchronization.
func (*Hierarchy) Depth ¶ added in v0.1.5
Depth returns the number of live ancestors, including ancestors outside the current query scope. Missing entities and cycles return -1.
func (*Hierarchy) Entities ¶
Entities returns the borrowed live entity list, independent of query scopes.
func (*Hierarchy) FirstChild ¶
FirstChild and NextSibling traverse ascending SiblingOrder with entity ties.
func (*Hierarchy) MaintainCache ¶
func (h *Hierarchy) MaintainCache()
func (*Hierarchy) WalkSubtree ¶ added in v0.1.9
WalkSubtree visits root and its descendants in sibling order. Returning false skips that entity's descendants. The visitor may read the hierarchy; collect entities before changing parentage or despawning them.
type InputBlocker2D ¶
type InputCapture2D ¶
InputCapture2D describes the active 2D input capture. A capture keeps receiving move/release/cancel events after the input leaves its bounds.
type InputEvent ¶
type InputEvent struct {
File string
Text string
// Path contains the receiver followed by its parents for bubbling.
Path []ecs.Entity
Composition input.TextComposition
Selection input.TextSelection
Seq uint64
Entity ecs.Entity
Key input.KeyCode
X float32
Y float32
DeltaX float32
DeltaY float32
WheelX float32
WheelY float32
// Handled is set when a synchronous handler consumes the event.
Handled bool
Kind InputEventKind
Device input.PointerDevice
Button input.MouseButton
Command input.TextCommand
}
InputEvent is the unified ECS input delivered to scripts and systems. Entity and Path are populated for hit-tested pointer input and remain zero for global keyboard, text, and file input.
func InputEventFromPlatform ¶
func InputEventFromPlatform(event input.Event) (InputEvent, bool)
InputEventFromPlatform converts non-pointer platform input into the unified ECS representation. Pointer input is emitted after 2D hit testing instead.
type InputEventContext ¶
type InputEventContext struct {
Event *InputEvent
Target ecs.Entity
Current ecs.Entity
Handled bool
}
func (*InputEventContext) Consume ¶
func (c *InputEventContext) Consume()
type InputEventKind ¶
type InputEventKind uint8
const ( InputEventKeyDown InputEventKind = iota + 1 InputEventKeyUp InputEventTextInput InputEventTextComposition InputEventTextCommand InputEventTextSelection InputEventFilesDropped InputEventEnter InputEventLeave InputEventPress InputEventMove InputEventRelease InputEventTap InputEventWheel InputEventCancel )
func (InputEventKind) IsPointer ¶
func (kind InputEventKind) IsPointer() bool
func (InputEventKind) Mask ¶
func (kind InputEventKind) Mask() InputMask
func (InputEventKind) String ¶
func (kind InputEventKind) String() string
type InputFilter ¶
type InputFilter uint8
const ( InputFilterStop InputFilter = iota InputFilterPass InputFilterIgnore )
type InputFocus ¶
InputFocus is the currently focused ECS entity for keyboard/text input. Zero means that no entity owns keyboard focus.
type InputHandler2D ¶
type InputHandler2D struct {
Handle func(*InputEventContext)
}
InputHandler2D handles events synchronously along the target path.
type InputMask ¶
type InputMask uint8
const ( InputMaskPointer InputMask = 1 << iota InputMaskKeyboard InputMaskText InputMaskFiles InputMaskAll = InputMaskPointer | InputMaskKeyboard | InputMaskText | InputMaskFiles )
func (InputMask) Intersects ¶
type InputRoute2D ¶ added in v0.1.8
type InputRoute2D struct {
Handle func(*ecs.World, *InputEventContext)
}
InputRoute2D routes input to a retained owner associated with an entity.
type InputState2D ¶
InputState2D is the input state shared by ordinary render entities and composed controls. The input dispatcher is its only writer.
type InputTarget2D ¶
type InputTarget2D struct {
Width float32
Height float32
Receiver ecs.Entity
Cursor input.Cursor
InputFilter InputFilter
PassThrough bool
Disabled bool
// AllowDisabledInput keeps non-editing inputs (for example
// scrolling a read-only textarea) available while suppressing editing.
AllowDisabledInput bool
}
type MeshMaterial2D ¶
type MeshMaterial2D[T graphics.Material2D] struct { Material *T }
type NineSlice2D ¶
type OrthographicArea ¶
type OrthographicProjection ¶
type OrthographicProjection struct {
// ReverseZ uses a [0,1] depth range, with positive Near/Far distances,
// for 3D cameras. The default matrix retains the 2D [-1,1] depth range.
ReverseZ bool
Near float32
Far float32
ViewportOrigin mgl32.Vec2
ScalingMode ScalingMode
Scale float32
Area OrthographicArea
}
func NewOrthographicProjection2D ¶
func NewOrthographicProjection2D() OrthographicProjection
func (OrthographicProjection) Matrix ¶
func (p OrthographicProjection) Matrix() mgl32.Mat4
func (*OrthographicProjection) Update ¶
func (p *OrthographicProjection) Update(width, height float32)
type PainterGroup2D ¶
type PainterGroup2D uint64
PainterGroup2D keeps a subtree in one stable painter group. Groups sort before local UIStackIndex/RenderOrder2D values and are inherited by children.
type ParticleAppearance2D ¶
ParticleAppearance2D pairs a particle element's texture with its colour.
type ParticleEmitter2D ¶
type ParticleEmitter2D struct {
Texture *graphics.Texture
Colors []graphics.ColorRGBA
Appearances []ParticleAppearance2D
Count int
SizeMin float32
GravityX float32
Lifetime float32
SpeedMin float32
SpeedMax float32
Width float32
SizeMax float32
Direction float32
Spread float32
Rate float32
GravityY float32
AlphaStart float32
AlphaEnd float32
Height float32
Loop bool
// contains filtered or unexported fields
}
func NewParticleEmitter2D ¶
func NewParticleEmitter2D() ParticleEmitter2D
func (*ParticleEmitter2D) Active ¶
func (e *ParticleEmitter2D) Active() bool
func (*ParticleEmitter2D) Normalize ¶
func (e *ParticleEmitter2D) Normalize()
func (*ParticleEmitter2D) Reserve ¶
func (e *ParticleEmitter2D) Reserve(maxParticles int)
Reserve preallocates particle storage for pooled effects.
func (*ParticleEmitter2D) Restart ¶
func (e *ParticleEmitter2D) Restart()
Restart clears live particles and arms a non-looping emitter for another burst.
func (*ParticleEmitter2D) Stop ¶
func (e *ParticleEmitter2D) Stop()
Stop clears live particles and disarms a burst emitter until it is restarted.
type PerspectiveProjection ¶
func NewPerspectiveProjection ¶
func NewPerspectiveProjection() PerspectiveProjection
type Projection ¶
type Projection struct {
Kind ProjectionKind
Orthographic OrthographicProjection
Perspective PerspectiveProjection
}
func OrthographicProjection2D ¶
func OrthographicProjection2D() Projection
func PerspectiveProjection3D ¶
func PerspectiveProjection3D() Projection
type ProjectionKind ¶
type ProjectionKind uint8
const ( ProjectionOrthographic ProjectionKind = iota ProjectionPerspective )
type RenderLayers ¶
type RenderLayers struct {
// contains filtered or unexported fields
}
func LayersForEntity ¶
func LayersForEntity(world *ecs.World, entity ecs.Entity) RenderLayers
LayersForEntity returns authored render layers or the default layer zero.
func RenderLayer ¶
func RenderLayer(layer uint) RenderLayers
func RenderLayersNone ¶
func RenderLayersNone() RenderLayers
func (RenderLayers) Contains ¶
func (layers RenderLayers) Contains(layer uint) bool
func (RenderLayers) Intersects ¶
func (layers RenderLayers) Intersects(other RenderLayers) bool
func (RenderLayers) With ¶
func (layers RenderLayers) With(layer uint) RenderLayers
func (RenderLayers) Without ¶
func (layers RenderLayers) Without(layer uint) RenderLayers
type RenderOutput2D ¶
type RenderOutput2D struct{ Handle RenderOutputHandle }
type RenderOutputHandle ¶
type RenderOutputHandle struct {
// contains filtered or unexported fields
}
RenderOutputHandle is one lease on immutable logical drawing data. Copying a handle borrows that lease; Retain creates an independently releasable lease. Pools and handles are used on the engine's single logic/render thread.
func (RenderOutputHandle) Empty ¶
func (h RenderOutputHandle) Empty() bool
func (RenderOutputHandle) Release ¶
func (h RenderOutputHandle) Release() error
func (RenderOutputHandle) Retain ¶
func (h RenderOutputHandle) Retain() (RenderOutputHandle, error)
func (RenderOutputHandle) Valid ¶
func (h RenderOutputHandle) Valid() bool
type RenderOutputPool ¶
type RenderOutputPool struct {
// contains filtered or unexported fields
}
Fixed storage makes cached-output Retain/Release allocation-free and rejects capacity overflow explicitly rather than silently growing the hot path.
func NewRenderOutputPool ¶
func NewRenderOutputPool(capacity int) *RenderOutputPool
func (*RenderOutputPool) Leases ¶
func (p *RenderOutputPool) Leases() int
func (*RenderOutputPool) Text ¶
func (p *RenderOutputPool) Text(value Text2D, release func() error) (RenderOutputHandle, error)
Text prepares glyph geometry once. The caller keeps the font alive until release runs after the final lease. No font or mutable draw callback is exposed through the resulting handle. Atlas textures use driver retirement.
func (*RenderOutputPool) TextBox ¶
func (p *RenderOutputPool) TextBox(value Text2D, bounds Size2D, release func() error) (RenderOutputHandle, error)
TextBox limits painted output to positive logical bounds. Zero is unbounded.
type RenderPreparation2D ¶
type RenderPreparation2D struct {
Extracted int
Reused int
Sorted bool
PropertiesUpdated int
PaintUpdated int
}
RenderPreparation2D counts CPU preparation work for the latest extraction.
type RenderRequest ¶
type RenderRequest struct {
// contains filtered or unexported fields
}
func NewRenderRequest ¶
func NewRenderRequest(wake func()) *RenderRequest
func (*RenderRequest) Pending ¶
func (r *RenderRequest) Pending() bool
func (*RenderRequest) Request ¶
func (r *RenderRequest) Request()
func (*RenderRequest) Take ¶
func (r *RenderRequest) Take() bool
type RenderSettings2D ¶
type RenderWorld ¶
type RenderWorld struct {
Cameras []ExtractedCamera
Items2D []renderItem2D
Composite2D CompositeStatistics2D
Preparation2D RenderPreparation2D
// contains filtered or unexported fields
}
func NewRenderWorld ¶
func NewRenderWorld() *RenderWorld
func RenderWorldFor ¶
func RenderWorldFor(world *ecs.World) *RenderWorld
RenderWorldFor returns the world's render state, creating it on first use.
func (*RenderWorld) Dispose ¶
func (state *RenderWorld) Dispose() error
Dispose releases retained GPU output while the window's device is alive.
func (*RenderWorld) RegisterCameraRenderer ¶
func (state *RenderWorld) RegisterCameraRenderer[T any](pipeline CameraPipeline, describe func(*T) CameraRenderOptions, draw CameraRenderer)
RegisterCameraRenderer binds a typed camera component to a render pipeline. Registration is idempotent for the same type and pipeline. Extraction borrows the component and stores only output settings; stable frames do not allocate.
func (*RenderWorld) RegisterMaterial2D ¶
func (state *RenderWorld) RegisterMaterial2D[T graphics.Material2D]()
RegisterMaterial2D enables extraction of MeshMaterial2D[T] components. It mirrors Bevy's Material2dPlugin<T> registration boundary.
type ResolvedUIRect ¶
func (ResolvedUIRect) Horizontal ¶
func (r ResolvedUIRect) Horizontal() float32
func (ResolvedUIRect) Vertical ¶
func (r ResolvedUIRect) Vertical() float32
type RoundedClip2D ¶
type RoundedClip2D struct {
X float32
Y float32
Width float32
Height float32
Radius float32
MaskColor graphics.ColorRGBA
}
RoundedClip2D adds a uniform corner radius to a local clip rectangle. It is consumed by the built-in sprite pipeline in addition to ClipRect2D; keeping the rectangle separate preserves the existing scissor/culling fast path.
type ScalingMode ¶
type ScalingMode struct {
Kind ScalingModeKind
Width float32
Height float32
}
func AutoMaxScaling ¶
func AutoMaxScaling(maxWidth, maxHeight float32) ScalingMode
func AutoMinScaling ¶
func AutoMinScaling(minWidth, minHeight float32) ScalingMode
func FixedHorizontalScaling ¶
func FixedHorizontalScaling(viewportWidth float32) ScalingMode
func FixedScaling ¶
func FixedScaling(width, height float32) ScalingMode
func FixedVerticalScaling ¶
func FixedVerticalScaling(viewportHeight float32) ScalingMode
type ScalingModeKind ¶
type ScalingModeKind uint8
const ( ScalingModeWindowSize ScalingModeKind = iota ScalingModeFixed ScalingModeAutoMin ScalingModeAutoMax ScalingModeFixedVertical ScalingModeFixedHorizontal )
type SceneLayer ¶
SceneLayer separates camera content and orders complete scenes before local world/UI order. Descendants inherit the scene root's layer.
func LayerForEntity ¶
func LayerForEntity(world *ecs.World, entity ecs.Entity) SceneLayer
type Shader ¶
type Shader[T graphics.Material2DShader | graphics.MeshShader] struct { Program *T Custom [4][4]float32 }
Shader attaches a shared GPU program and per-element uniforms to geometry. T is graphics.Material2DShader for sprites or graphics.MeshShader for meshes.
type Shape2D ¶
type Shape2D struct {
Kind render.ShapeKind
Fill graphics.ColorRGBA
Border graphics.ColorRGBA
Radius float32
BorderWidth float32
}
func CheckmarkShape2D ¶
type SiblingOrder ¶
type SiblingOrder int
SiblingOrder preserves authored sibling order. Runtime-created nodes fall back to their Entity value.
type Sprite2D ¶
type Sprite2D struct {
Texture *graphics.Texture
Slice *NineSlice2D
Shape Shape2D
Tint graphics.ColorRGBA
Width float32
Height float32
Alpha float32
}
func NewSprite2D ¶
func NewSprite2D() Sprite2D
func Sprite2DFromTexture ¶
type SpriteLayer2D ¶
type SpriteLayerTransform2D ¶
type SpriteLayerTransform2D struct {
X, Y, Z float32
ScaleX, ScaleY, ScaleZ float32
RotationX, RotationY float32
Rotation float32
}
SpriteLayerTransform2D describes the local transform of a standalone sprite layer. It is intentionally independent of animation playback.
func (SpriteLayerTransform2D) LocalMatrix ¶
func (t SpriteLayerTransform2D) LocalMatrix() mgl32.Mat4
type SpriteLayers2D ¶
type SpriteLayers2D struct {
Layers []SpriteLayer2D
// contains filtered or unexported fields
}
SpriteLayers2D is a collection of independently rendered sprite or shape fragments sharing one entity's transform, clip and paint order.
func (*SpriteLayers2D) InvalidateMatrices ¶
func (a *SpriteLayers2D) InvalidateMatrices()
func (*SpriteLayers2D) LayerMatrix ¶
func (a *SpriteLayers2D) LayerMatrix(index int) mgl32.Mat4
type SpriteTrail2D ¶
type SpriteTrail2D struct {
MaxSamples int
Lifetime float32
Interval float32
MinDistance float32
AlphaStart float32
AlphaEnd float32
// contains filtered or unexported fields
}
SpriteTrail2D records resolved transform snapshots and renders them as fading afterimages. Component presence enables the effect; remove it to disable and discard the trail.
func NewSpriteTrail2D ¶
func NewSpriteTrail2D() SpriteTrail2D
func (*SpriteTrail2D) Clear ¶
func (t *SpriteTrail2D) Clear()
func (*SpriteTrail2D) Reserve ¶
func (t *SpriteTrail2D) Reserve(maxSamples int)
Reserve allocates storage for up to maxSamples trail snapshots. It is useful for pooled effects that need allocation-free updates after activation.
func (*SpriteTrail2D) SampleCount ¶
func (t *SpriteTrail2D) SampleCount() int
type Text2D ¶
type Text2D struct {
// Source supplies immutable document text; Value is used when Source is empty.
Source piecetree.Snapshot
// Index optionally shares a document's indexed text buffer for caret lookup.
Index TextIndex
Font *onixtext.Font
// LineLayout spaces visual lines without inserting characters into Value.
LineLayout *TextLineLayout2D
Value string
// Spans are sorted, non-overlapping UTF-8 byte ranges.
Spans []TextSpan2D
InlineObjects []TextInlineObject2D
// Prelayout uses positions already computed by a layout engine for one line.
// Its producer increments Revision whenever those positions or Value change.
Prelayout TextPrelayout2D
DPI float64
FontSize float64
OutlineColor graphics.ColorRGBA
Color graphics.ColorRGBA
ShadowColor graphics.ColorRGBA
ShadowX float32
WrapWidth float32
OutlineWidth float32
ShadowY float32
LetterSpacing float32
Alpha float32
MaxWidth float32
// TabWidth is the distance between tab stops in logical pixels.
TabWidth float32
// InkOffsetY shifts painted glyphs without changing line or caret geometry.
InkOffsetY float32
LineHeight float32
TextAlignment TextAlignment
// LCD enables RGB-stripe antialiasing on an opaque UI surface.
LCD bool
WrapMode TextWrapMode
// contains filtered or unexported fields
}
func (*Text2D) QueueUploads ¶
func (t *Text2D) QueueUploads(queue *graphics.UploadQueue)
QueueUploads adds resources referenced by CPU-side text layout. Layout and rasterization stay on the owning loop thread; the queue budgets first upload.
type TextAlignment ¶
type TextAlignment uint8
const ( TextAlignLeft TextAlignment = iota TextAlignCenter TextAlignRight )
type TextInlineObject2D ¶
type TextInlineObjectRect2D ¶
type TextInlineObjectRect2D struct {
Start int
End int
Rect TextRangeRect2D
}
func TextInlineObjectRects2D ¶
func TextInlineObjectRects2D(text *Text2D) ([]TextInlineObjectRect2D, bool)
type TextLineLayout2D ¶
TextLineLayout2D adds vertical gaps and a minimum scrollable extent. Owners increment Revision whenever offsets or dimensions change; unchanged layouts require no slice comparison or allocation during measurement.
type TextPrelayout2D ¶
type TextPrelayout2D struct {
Glyphs []font.PositionedGlyph
OriginX, OriginY float64
Width, Height float32
Revision uint64
}
type TextRangeRect2D ¶
func MeasureTextRangeRects2D ¶
func MeasureTextRangeRects2D(text *Text2D, start, end int) ([]TextRangeRect2D, bool)
func TextLineRange2D ¶
func TextLineRange2D(text *Text2D, index int) (start, end int, rect TextRangeRect2D, ok bool)
TextLineRange2D exposes byte offsets and geometry of one cached visual line.
func TextLineRects2D ¶
func TextLineRects2D(text *Text2D) ([]TextRangeRect2D, bool)
type TextWrapMode ¶
type TextWrapMode uint8
const ( TextWrapWords TextWrapMode = iota TextWrapNewlines TextWrapNone // TextWrapCharacters wraps every line at WrapWidth, including long words. TextWrapCharacters // TextWrapTokens wraps at word/identifier and punctuation boundaries without // discarding whitespace. A token wider than WrapWidth remains on one line. TextWrapTokens )
type Tilemap2D ¶
type Tilemap2D struct {
Texture *graphics.Texture
Tiles []int
Revision uint64
Width int
Height int
TileWidth int
TileHeight int
Columns int
Alpha float32
}
func (*Tilemap2D) PixelHeight ¶
func (*Tilemap2D) PixelWidth ¶
type Time ¶
type Time struct {
Delta time.Duration
Elapsed time.Duration
Frame uint64
// contains filtered or unexported fields
}
func (*Time) DeltaSeconds ¶
func (*Time) ElapsedSeconds ¶
type Transform ¶
Transform is the local spatial transform shared by 2D and 3D world entities. Two-dimensional entities use the Z translation for depth ordering and normally rotate around Z with a unit Z scale.
func NewTransform ¶
func NewTransform() Transform
func TransformFromXYZ ¶
func (Transform) LocalMatrix ¶
type UIBackground2D ¶
UIBackground2D is the background layer of a UI node.
func NewUIBackground2D ¶
func NewUIBackground2D(shape Shape2D) UIBackground2D
type UIBorder2D ¶
UIBorder2D is the border layer of a UI node.
func NewUIBorder2D ¶
func NewUIBorder2D(shape Shape2D) UIBorder2D
type UIBoxPaint2D ¶ added in v0.1.8
type UIBoxPaint2D struct {
Text UIStaticText2D
Stack int
Shape Shape2D
X, Y, Width, Height float32
Order uint32
}
UIBoxPaint2D holds the paint of one passive UI box in surface coordinates. The solid border uses the shape's border parameters.
type UIGlobalTransform ¶
func (UIGlobalTransform) ClipRect ¶
func (t UIGlobalTransform) ClipRect() (ClipRect2D, bool)
ClipRect returns the inherited clipping bounds in world UI coordinates. The boolean distinguishes an empty clipping rectangle from no clipping.
type UIImage2D ¶
type UIImage2D struct {
Texture *graphics.Texture
Slice *NineSlice2D
Mode UIImageMode
Tint graphics.ColorRGBA
Alpha float32
}
UIImage2D is the image layer of a UI node.
func NewUIImage2D ¶
type UIImageMode ¶
type UIImageMode uint8
UIImageMode controls how a UI image is fitted into its node.
const ( // UIImageAuto preserves the source aspect ratio and fits inside the node. UIImageAuto UIImageMode = iota // UIImageStretch stretches the source image to the node bounds. UIImageStretch // UIImageSliced stretches the center while preserving the configured borders. UIImageSliced )
type UIPaint2D ¶ added in v0.1.8
type UIPaint2D struct {
// contains filtered or unexported fields
}
UIPaint2D owns the paint fragments attached to one UI entity.
func (*UIPaint2D) Fragments ¶ added in v0.1.8
func (paint *UIPaint2D) Fragments() []UIShapeFragment2D
Fragments returns the entity's fragments for read-only access.
type UIPaintList2D ¶ added in v0.1.8
type UIPaintList2D struct {
// contains filtered or unexported fields
}
UIPaintList2D stores paint on its surface entity. Slots are addressed by the layout producer and may be replaced without moving other boxes.
func (*UIPaintList2D) Capacity ¶ added in v0.1.8
func (list *UIPaintList2D) Capacity() (boxes, free, glyphs int)
Capacity reports the capacity of the slot table, free list, and glyph runs.
func (*UIPaintList2D) Compact ¶ added in v0.1.8
func (list *UIPaintList2D) Compact() []uint32
Compact reclaims slot storage after substantial shrinkage and reports the new IDs so the layout producer can keep its surviving slots addressable.
func (*UIPaintList2D) Len ¶ added in v0.1.8
func (list *UIPaintList2D) Len() int
func (*UIPaintList2D) RemoveBox ¶ added in v0.1.8
func (list *UIPaintList2D) RemoveBox(id uint32)
func (*UIPaintList2D) Reset ¶ added in v0.1.8
func (list *UIPaintList2D) Reset()
func (*UIPaintList2D) SetBox ¶ added in v0.1.8
func (list *UIPaintList2D) SetBox(id uint32, box UIBoxPaint2D) uint32
SetBox updates a slot and returns its ID. Zero creates a slot.
type UIRect ¶
type UIRect struct {
Left Val `json:"left,omitzero"`
Right Val `json:"right,omitzero"`
Top Val `json:"top,omitzero"`
Bottom Val `json:"bottom,omitzero"`
}
func UIRectPercent ¶
type UIResolveContext ¶
type UIScroll ¶
type UIScroll struct {
Position mgl32.Vec2
Momentum mgl32.Vec2
ViewportSize mgl32.Vec2
ContentSize mgl32.Vec2
WheelStep float32
// ScrollbarSize enables native scrollbar-thumb dragging for this viewport.
// A zero value keeps the legacy content-drag behavior for bare UIScroll
// components that do not render scrollbar parts.
ScrollbarSize float32
ScrollbarMinThumbSize float32
ScrollbarThin bool
// Overlay bars lie inside the viewport without reserving content space.
ScrollbarOverlay bool
DisableInput bool
DisableDrag bool
// DisableContentDrag leaves left-button gestures to text selection while
// preserving scrollbar dragging, the wheel and middle-button panning.
DisableContentDrag bool
ConsumeWheel bool
Horizontal bool
Vertical bool
// contains filtered or unexported fields
}
UIScroll stores allocation-free scrolling state for an absolute-positioned UI viewport. Position is the non-positive offset applied by the caller to its content transform.
type UIScrollContainerData ¶
type UIScrollContainerData struct {
Scroll *UIScroll
ViewportSize mgl32.Vec2
ContentSize mgl32.Vec2
Horizontal bool
Vertical bool
}
type UIShapeFragment2D ¶ added in v0.1.8
UIShapeFragment2D is a paint-only rectangle in a UI entity's local coordinates. It shares the entity's transform, clipping and camera routing.
type UIStackIndex ¶
type UIStackIndex int
type UIStaticText2D ¶ added in v0.1.8
type UIStaticText2D struct {
Font *onixtext.Font
Layout TextPrelayout2D
FontSize, DPI float64
Color graphics.ColorRGBA
X, Y float32
LCD bool
}
UIStaticText2D describes a single prelaid-out run. The glyph positions are borrowed from the layout producer and must stay valid until the next update.
type UITargetCamera ¶
type UITransform ¶
type UITransform struct {
Translation Val2
Scale mgl32.Vec2
Rotation float32
Skew mgl32.Vec2
// Pivot is the local point around which rotation, skew, and scale are applied.
Pivot mgl32.Vec2
// LinearMatrix overrides rotation, skew, and scale when nonzero. It preserves
// exact composition, including singular scales; pivot and translation still apply.
LinearMatrix mgl32.Mat4
}
func NewUITransform ¶
func NewUITransform() UITransform
func UITransformFromXY ¶
func UITransformFromXY(x, y float32) UITransform
func (UITransform) LocalMatrix ¶
func (t UITransform) LocalMatrix(context UIResolveContext) mgl32.Mat4
type UIVisualRects2D ¶ added in v0.1.8
type UIVisualRects2D []TextRangeRect2D
UIVisualRects2D repeats a node's background, image and border over local rectangles. An empty collection emits no visuals.
type ViewportSize ¶
type Visibility ¶
type Visibility struct {
Visible bool
}
type WebView ¶
type WebView struct {
OnMessage WebViewHandler
OnInvoke WebViewMessageHandler
Bindings map[string]WebViewHandler
HTML string
URL string
// Bounds is an alternate grouped form of X/Y/Width/Height. When it is
// non-zero it takes precedence over the scalar fields.
Bounds WebViewBounds
Y float32
Height float32
Width float32
X float32
Visible bool
DevTools bool
Transparent bool
}
WebView is a native browser surface owned by an ECS entity. URL and HTML are mutually exclusive; URL takes precedence when both are set. Bounds are expressed in logical window pixels.
The component is deliberately independent of any platform UI type. Install a WebViewRuntime resource and WebViewSystem to materialize it.
func NewWebView ¶
NewWebView creates a visible WebView that navigates to url.
func NewWebViewHTML ¶
NewWebViewHTML creates a visible WebView containing inline HTML.
type WebViewBackend ¶
type WebViewBackend interface {
Create(options WebViewOptions, invoke WebViewInvoke, events func(WebViewEvent)) (WebViewHandle, error)
}
WebViewBackend creates browser surfaces. The callback may be called by the backend at any time while the returned handle is alive.
type WebViewBounds ¶
WebViewBounds is the logical rectangle occupied by a browser surface.
type WebViewEvent ¶
type WebViewEvent struct {
Name string
Payload string
Message string
URL string
Error string
Entity ecs.Entity
Kind WebViewEventKind
}
WebViewEvent is emitted through the ECS message queue by WebViewRuntime. Message contains the raw JSON payload for WebViewEventMessage. Error is a stable text copy so events remain safe after a backend callback returns.
type WebViewEventKind ¶
type WebViewEventKind uint8
WebViewEventKind identifies a platform event delivered to ECS.
const ( WebViewEventReady WebViewEventKind = iota + 1 WebViewEventMessage WebViewEventError WebViewEventClosed )
type WebViewHandle ¶
type WebViewHandle interface {
SetHTML(html string) error
Eval(script string) error
SetBounds(bounds WebViewBounds) error
SetVisible(visible bool) error
Destroy() error
}
WebViewHandle is the platform-owned browser surface.
type WebViewHandler ¶
WebViewHandler handles a named invocation from a web page. Payload is the JSON text supplied by the page and the returned string is resolved back to the JavaScript Promise. Returning an error rejects that Promise.
type WebViewInvoke ¶
WebViewInvoke dispatches a named JavaScript bridge call to Go. The backend must call it on the platform UI thread and use the returned result to settle the JavaScript Promise.
type WebViewMessageHandler ¶
WebViewMessageHandler handles every bridge invocation, including its name.
type WebViewOptions ¶
type WebViewOptions struct {
URL string
HTML string
Bounds WebViewBounds
Visible bool
DevTools bool
Transparent bool
}
WebViewOptions is passed to a platform backend when an instance is created.
type WebViewRuntime ¶
type WebViewRuntime struct {
Backend WebViewBackend
// contains filtered or unexported fields
}
WebViewRuntime owns native handles for all WebView components in one world. It is safe to reuse a runtime across frames; synchronization only invokes backend methods when component state has changed.
func NewWebViewRuntime ¶
func NewWebViewRuntime(backend WebViewBackend) *WebViewRuntime
NewWebViewRuntime creates a runtime using backend. A nil backend is valid and causes WebViewSystem to emit one unavailable event per entity.
func (*WebViewRuntime) Close ¶
func (r *WebViewRuntime) Close() error
Close destroys every materialized browser surface. It is idempotent.
func (*WebViewRuntime) Eval ¶
func (r *WebViewRuntime) Eval(entity ecs.Entity, script string) error
Eval evaluates script in an existing browser surface.
func (*WebViewRuntime) Handle ¶
func (r *WebViewRuntime) Handle(entity ecs.Entity) (WebViewHandle, bool)
Handle returns the native handle for entity after synchronization. The handle is owned by the runtime and must not be destroyed by the caller.
Source Files
¶
- activity.go
- anchor.go
- animation.go
- animation_bound.go
- animation_curve.go
- animation_easing.go
- animation_time.go
- camera.go
- camera2d.go
- debug_info.go
- doc.go
- hierarchy.go
- input.go
- input2d.go
- input_cache2d.go
- input_routing.go
- particle2d.go
- perspective.go
- preparation.go
- render2d.go
- render_composite2d.go
- render_composite_damage2d.go
- render_hierarchy2d.go
- render_output.go
- render_phase2d.go
- render_registered.go
- render_request.go
- render_retained2d.go
- render_snapshot2d.go
- render_spine2d.go
- render_storage2d.go
- render_text2d.go
- render_texture2d.go
- render_tilemap2d.go
- render_ui2d.go
- render_world.go
- scene_layer.go
- shader.go
- sibling_order.go
- spine2d.go
- sprite_layers.go
- sprite_trail2d.go
- text_selection.go
- tilemap2d.go
- time.go
- transform.go
- ui_paint2d.go
- ui_paint_list2d.go
- ui_scroll.go
- ui_transform.go
- ui_value.go
- ui_value_json.go
- webview.go
- workload.go
- world.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package render3d owns meshes, camera settings, lights, deformation, shadows, post-processing, and the 3D extract/prepare/sort/draw pipeline.
|
Package render3d owns meshes, camera settings, lights, deformation, shadows, post-processing, and the 3D extract/prepare/sort/draw pipeline. |