engine

package
v0.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

This package provides functionality for the app engine.

Index

Constants

View Source
const (
	StateStopped   = 0
	StateStarted   = 1
	StateUpdating  = 2
	StateRendering = 3
)
View Source
const (
	EventUpdate      = -1
	EventRender      = -2
	EventCloseScene  = -3
	EventMouseDown   = -4
	EventDoubleClick = -5
	EventNavigate    = -6
	EventStop        = -7
	EventKeyDown     = -8
	EventMouseUp     = -9
	EventAppHide     = -10
	EventAppShow     = -11
	EventPaste       = -12
	EventCopy        = -13
	EventMouseIn     = -14
	EventMouseOut    = -15
	EventDropFile    = -16
	EventMouseMove   = -17
	EventAppLoaded   = -18
	EventFocusGain   = -19
	EventFocusLoose  = -20
)
View Source
const (
	MessageRedraw       = 0
	MessageBuiltinEvent = 1
)
View Source
const (
	MatchParent    = -2147483648
	WrapContent    = -2147483647
	CenterInParent = -2147483646
)

Deprecated. Use a.MatchParent, a.WrapContent and a.CenterInParent instead.

View Source
const MessageMaxDepth = -1
View Source
const (
	TargetFrameTime = 16
)

Variables

This section is empty.

Functions

func BindEventHandler added in v0.1.5

func BindEventHandler(eventCode int, handler EventHandler)

Shortcut for (engine *AmphionEngine) BindEventHandler(code int, handler EventHandler). Binds an event handler for the specified event code. The handler will be invoked in the event loop goroutine, when the event with the specified code is raised.

func ExecuteOnFrontendThread added in v0.1.7

func ExecuteOnFrontendThread(action func())

Shortcut for (engine *AmphionEngine) ExecuteOnFrontendThread(action func()). Executes the specified action on frontend thread.

func IsSpecialValue added in v0.1.1

func IsSpecialValue(x float32) bool

Checks if the given float32 value is special(MatchParent, WrapContent or CenterInParent).

func IsSpecialVector added in v0.1.1

func IsSpecialVector(pos a.Vector3) bool

Checks if the given vector contains special values.

func IsStatefulComponent

func IsStatefulComponent(component Component) bool

Checks if the given component has state. A component becomes stateful if is implements StatefulComponent interface or contains fields with state tag.

func LogDebug added in v0.1.1

func LogDebug(msg string, values ...interface{})

Same as LogInfo, but prints only if app is in debug mode.

func LogError added in v0.1.1

func LogError(msg string, values ...interface{})

Prints an error to the log from the current component, formatting the msg using fmt.Sprintf.

func LogInfo added in v0.1.1

func LogInfo(msg string, values ...interface{})

Prints a message to the log from the current component, formatting the msg using fmt.Sprintf.

func LogWarning added in v0.1.1

func LogWarning(msg string, values ...interface{})

Prints a warning to the log from the current component, formatting the msg using fmt.Sprintf.

func NameOfComponent

func NameOfComponent(component interface{}) string

Return the name of the given component suitable for serialization.

func Navigate(path string, args a.SiMap) (err error)

Opens the scene corresponding to the specified path. Path "/" corresponds to the app's main scene. Other paths correspond to the scene path in the scene folder. For example "res/scenes/test.scene" corresponds to "/test", "res/scenes/hello/test.scene" to "/hello/test". Args can be passed, that can be later read from the scene.

func RequestRendering added in v0.1.1

func RequestRendering()

Shortcut for (engine *AmphionEngine) RequestRendering().

func RequestUpdate added in v0.1.1

func RequestUpdate()

Shortcut for (engine *AmphionEngine) RequestUpdate().

func RunTask added in v0.1.1

func RunTask(task Task)

Shortcut for (engine *AmphionEngine) RunTask(task Task).

func UnbindEventHandler added in v0.1.5

func UnbindEventHandler(eventCode int, handler EventHandler)

Shortcut for (engine *AmphionEngine) UnbindEventHandler(code int, handler EventHandler). Unbinds the event handler for the specified event code. The handler will no longer be invoked, when the event with the specified code is raised.

Types

type AmphionEngine

type AmphionEngine struct {
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() *AmphionEngine

Returns pointer to the engine instance.

func Initialize

func Initialize(front frontend.Frontend) *AmphionEngine

Initializes a new instance of Amphion Engine and configures it to run with the specified frontend. Returns pointer to the created engine instance. The engine is a singleton, so calling Initialize more than once will have no effect.

func (*AmphionEngine) BindEventHandler

func (engine *AmphionEngine) BindEventHandler(code int, handler EventHandler)

Binds an event handler for the specified event code. The handler will be invoked in the event loop goroutine, when the event with the specified code is raised.

func (*AmphionEngine) CloseScene

func (engine *AmphionEngine) CloseScene(callback func())

Closes the currently showing scene asynchronously. It will call the provided callback function as soon as the scene was closed. If no scene is showing calls the callback function immediately.

func (*AmphionEngine) ExecuteOnFrontendThread added in v0.1.7

func (engine *AmphionEngine) ExecuteOnFrontendThread(action func())

Executes the specified action on frontend thread. Can be used to execute UI related functions from another goroutine.

func (*AmphionEngine) GetAppContext added in v0.1.7

func (engine *AmphionEngine) GetAppContext() *AppContext

Returns the current app's context.

func (*AmphionEngine) GetComponentsManager

func (engine *AmphionEngine) GetComponentsManager() *ComponentsManager

func (*AmphionEngine) GetCurrentApp

func (engine *AmphionEngine) GetCurrentApp() *frontend.App

Returns the current loaded app or nil if no app is loaded.

func (*AmphionEngine) GetCurrentScene

func (engine *AmphionEngine) GetCurrentScene() *SceneObject

Returns the currently displaying scene object.

func (*AmphionEngine) GetFrontend

func (engine *AmphionEngine) GetFrontend() frontend.Frontend

Returns the current frontend.

func (*AmphionEngine) GetGlobalContext

func (engine *AmphionEngine) GetGlobalContext() frontend.Context

Returns the global application context. See frontend.Context.

func (*AmphionEngine) GetInputManager

func (engine *AmphionEngine) GetInputManager() frontend.InputManager

Returns the current input manager.

func (*AmphionEngine) GetLogger

func (engine *AmphionEngine) GetLogger() *Logger

Returns the logger.

func (*AmphionEngine) GetMessageDispatcher

func (engine *AmphionEngine) GetMessageDispatcher() *MessageDispatcher

func (*AmphionEngine) GetName

func (engine *AmphionEngine) GetName() string

func (*AmphionEngine) GetRenderer

func (engine *AmphionEngine) GetRenderer() rendering.Renderer

Returns the renderer.

func (*AmphionEngine) GetResourceManager

func (engine *AmphionEngine) GetResourceManager() frontend.ResourceManager

Returns the current resource manager.

func (*AmphionEngine) GetSceneContext added in v0.1.7

func (engine *AmphionEngine) GetSceneContext() *SceneContext

Returns the current scene's context.

func (*AmphionEngine) GetState

func (engine *AmphionEngine) GetState() byte

Returns the current engine state.

func (*AmphionEngine) GetStateString

func (engine *AmphionEngine) GetStateString() string

Returns the current engine state as string.

func (*AmphionEngine) GetTasksRoutine

func (engine *AmphionEngine) GetTasksRoutine() *TasksRoutine

func (*AmphionEngine) IsForcedToRedraw

func (engine *AmphionEngine) IsForcedToRedraw() bool

func (*AmphionEngine) IsRenderingRequested

func (engine *AmphionEngine) IsRenderingRequested() bool

Returns whether rendering is requested for the next update cycle.

func (*AmphionEngine) IsUpdateRequested

func (engine *AmphionEngine) IsUpdateRequested() bool

Returns whether an update is requested for the next frame.

func (*AmphionEngine) LoadApp

func (engine *AmphionEngine) LoadApp()

Loads app data from well-known source and shows the main scene.

func (*AmphionEngine) LoadPrefab added in v0.1.1

func (engine *AmphionEngine) LoadPrefab(resId a.ResId) (*SceneObject, error)

Synchronously loads prefab from file.

func (*AmphionEngine) LoadScene

func (engine *AmphionEngine) LoadScene(scene a.ResId, show bool)

Loads scene from a resource file asynchronously. If show is true, after loading also shows this scene.

func (*AmphionEngine) OnMessage

func (engine *AmphionEngine) OnMessage(_ Message) bool

func (*AmphionEngine) RaiseEvent added in v0.1.7

func (engine *AmphionEngine) RaiseEvent(event AmphionEvent)

Raises a new event.

func (*AmphionEngine) RequestRendering

func (engine *AmphionEngine) RequestRendering()

Tells the engine to schedule rendering in the next update cycle. It will also request an update, if it was not requested already.

func (*AmphionEngine) RequestUpdate

func (engine *AmphionEngine) RequestUpdate()

Tells the engine to schedule an update as soon as possible.

func (*AmphionEngine) RunTask

func (engine *AmphionEngine) RunTask(task Task)

Runs the given task in the background goroutine.

func (*AmphionEngine) SetWindowTitle added in v0.1.7

func (engine *AmphionEngine) SetWindowTitle(title string)

Updates app's window title. On web sets the tab's title.

func (*AmphionEngine) ShowScene

func (engine *AmphionEngine) ShowScene(scene *SceneObject) error

Shows the specified scene object. Returns an error, if the engine is not yet ready or if another scene is already showing.

func (*AmphionEngine) Start

func (engine *AmphionEngine) Start()

Starts the engine. Must be called, before any interaction with the engine.

func (*AmphionEngine) Stop

func (engine *AmphionEngine) Stop()

Closes the current scene if any, and stops the engine.

func (*AmphionEngine) SwapScenes

func (engine *AmphionEngine) SwapScenes()

Hides the current showing scene and shows the currently loaded scene (using LoadScene). The previously showing scene will be properly stopped and the deleted. So, calling SwapScenes again wont swap the two scenes back. If no scene is loaded, wont do anything.

func (*AmphionEngine) UnbindEventHandler

func (engine *AmphionEngine) UnbindEventHandler(code int, handler EventHandler)

Unbinds the event handler for the specified event code. The handler will no longer be invoked, when the event with the specified code is raised.

func (*AmphionEngine) WaitForStop

func (engine *AmphionEngine) WaitForStop()

Blocks the calling goroutine until the engine is stopped.

type AmphionEvent

type AmphionEvent struct {
	Sender interface{}
	Code   int
	Data   interface{}
}

func NewAmphionEvent

func NewAmphionEvent(from interface{}, code int, data interface{}) AmphionEvent

type AmphionObject

type AmphionObject interface {
	Object
	NamedObject
	GetId() int64
}

type AppContext added in v0.1.7

type AppContext struct {
	// contains filtered or unexported fields
}

App context holds app specific data.

type BoundaryComponent

type BoundaryComponent interface {
	Component
	common.Boundary
}

A component, that determines the bounding box of an object in the scene. Used for mouse interactions.

type ClipboardData added in v0.1.1

type ClipboardData struct {
	// contains filtered or unexported fields
}

Experimental Holds an entry of clipboard

func NewClipboardData added in v0.1.1

func NewClipboardData(kind, mime string, str string, bytes []byte) *ClipboardData

func (*ClipboardData) GetData added in v0.1.1

func (c *ClipboardData) GetData() []byte

func (*ClipboardData) GetKind added in v0.1.1

func (c *ClipboardData) GetKind() string

func (*ClipboardData) GetMime added in v0.1.1

func (c *ClipboardData) GetMime() string

func (*ClipboardData) GetString added in v0.1.1

func (c *ClipboardData) GetString() string

type Component

type Component interface {
	NamedObject

	// This method is called only once when the component is first created.
	OnInit(ctx InitContext)

	// This method is called every time the component is being enabled.
	// If the scene object is enabled on component attachment this method will also be called.
	OnStart()

	// This method is called when the component is being disabled.
	OnStop()
}

Basic component interface. A component is a piece of functionality, that can be attached to scene objects.

type ComponentContainer

type ComponentContainer struct {
	// contains filtered or unexported fields
}

Wrap around container interface, that can be enabled or disabled

func NewComponentContainer

func NewComponentContainer(sceneObject *SceneObject, component Component) *ComponentContainer

func (*ComponentContainer) GetComponent

func (c *ComponentContainer) GetComponent() Component

func (*ComponentContainer) IsEnabled

func (c *ComponentContainer) IsEnabled() bool

func (*ComponentContainer) SetEnabled

func (c *ComponentContainer) SetEnabled(enabled bool)

type ComponentImpl

type ComponentImpl struct {
	Engine      *AmphionEngine
	SceneObject *SceneObject
	Logger      *Logger
	// contains filtered or unexported fields
}

Default component interface implementation

func (*ComponentImpl) GetName

func (c *ComponentImpl) GetName() string

func (ComponentImpl) NameOf

func (c ComponentImpl) NameOf(outer interface{}) string

func (*ComponentImpl) OnInit

func (c *ComponentImpl) OnInit(ctx InitContext)

func (*ComponentImpl) OnStart

func (c *ComponentImpl) OnStart()

func (*ComponentImpl) OnStop

func (c *ComponentImpl) OnStop()

type ComponentsManager

type ComponentsManager struct {
	// contains filtered or unexported fields
}

Manages types of components that are present in the application.

func (*ComponentsManager) GetComponentState

func (m *ComponentsManager) GetComponentState(component Component) a.SiMap

Retrieves component's state and returns it as string-interface map.

func (*ComponentsManager) GetEventHandler

func (m *ComponentsManager) GetEventHandler(name string) EventHandler

Retrieves the previously registered event handler by it's name.

func (*ComponentsManager) GetName

func (m *ComponentsManager) GetName() string

func (*ComponentsManager) MakeComponent

func (m *ComponentsManager) MakeComponent(name string) Component

Creates an instance of a component with the specified name. Returns the new instance of component ot nil if component with the name was not registered.

func (*ComponentsManager) RegisterComponentType

func (m *ComponentsManager) RegisterComponentType(component Component)

Register component, so an instance of it can be later created using MakeComponent.

func (*ComponentsManager) RegisterEventHandler

func (m *ComponentsManager) RegisterEventHandler(handler EventHandler)

Registers an event handler, so that it can be serialized and deserialized as a part of component's state.

func (*ComponentsManager) SetComponentState

func (m *ComponentsManager) SetComponentState(component Component, state a.SiMap)

Sets the component's state to the given state map.

type ConsoleLogger

type ConsoleLogger struct{}

func (*ConsoleLogger) Log

func (logger *ConsoleLogger) Log(level LogLevel, subsystem string, message string)

type DrawingContext

type DrawingContext struct {
	// contains filtered or unexported fields
}

Contains renderer

func (DrawingContext) GetRenderer

func (c DrawingContext) GetRenderer() rendering.Renderer

type EventBinder

type EventBinder struct {
	// contains filtered or unexported fields
}

func (*EventBinder) Bind

func (b *EventBinder) Bind(code int, handler EventHandler)

func (*EventBinder) GetHandlers

func (b *EventBinder) GetHandlers(code int) []EventHandler

func (*EventBinder) InvokeHandlers

func (b *EventBinder) InvokeHandlers(event AmphionEvent)

func (*EventBinder) Unbind

func (b *EventBinder) Unbind(code int, handler EventHandler)

type EventHandler

type EventHandler func(event AmphionEvent) bool

Function, that handles event. Returns whether to continue event propagation or not.

type ILogger

type ILogger interface {
	Log(level LogLevel, subsystem string, message string)
}

type InitContext

type InitContext struct {
	// contains filtered or unexported fields
}

Contains necessary objects for component initialization

func (InitContext) GetEngine

func (c InitContext) GetEngine() *AmphionEngine

func (InitContext) GetLogger

func (c InitContext) GetLogger() *Logger

func (InitContext) GetRenderer

func (c InitContext) GetRenderer() rendering.Renderer

func (InitContext) GetSceneObject

func (c InitContext) GetSceneObject() *SceneObject

type InputFileData added in v0.1.1

type InputFileData struct {
	Name string
	Data []byte
	Mime string
}

Represents file data returned as a result of the user selecting file or dragging it.

type KeyEvent

type KeyEvent struct {
	Key, Code string
}

type Layout

type Layout interface {
	Component
	LayoutChildren()
}

type LogLevel

type LogLevel uint
const (
	Info    LogLevel = 0
	Warning LogLevel = 1
	Error   LogLevel = 2
)

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func GetLoggerForPlatform

func GetLoggerForPlatform(p common.Platform) *Logger

func (*Logger) Error

func (logger *Logger) Error(subsystem NamedObject, message string)

func (*Logger) Info

func (logger *Logger) Info(subsystem NamedObject, message string)

func (*Logger) Warning

func (logger *Logger) Warning(subsystem NamedObject, message string)

type Message

type Message struct {
	Sender interface{}
	Code   byte
	Data   interface{}
}

func NewMessage

func NewMessage(sender interface{}, code byte, data interface{}) Message

func (Message) ToString

func (m Message) ToString() string

type MessageDispatcher

type MessageDispatcher struct {
	// contains filtered or unexported fields
}

func NewMessageDispatcher

func NewMessageDispatcher(root MessageListener) *MessageDispatcher

func (*MessageDispatcher) AddListener

func (d *MessageDispatcher) AddListener(listener MessageListener, parent MessageListener)

Adds listener into the message tree

func (*MessageDispatcher) Dispatch

func (d *MessageDispatcher) Dispatch(message Message, maxDepth int)

Sends message from the root down in the message tree

func (*MessageDispatcher) DispatchDirectly

func (d *MessageDispatcher) DispatchDirectly(listener MessageListener, message Message)

func (*MessageDispatcher) DispatchDown

func (d *MessageDispatcher) DispatchDown(from MessageListener, message Message, maxDepth int)

Sends this message up in the message tree

func (*MessageDispatcher) DispatchUp

func (d *MessageDispatcher) DispatchUp(from MessageListener, message Message)

Sends specified message down in the message tree.

func (*MessageDispatcher) RemoveListener

func (d *MessageDispatcher) RemoveListener(listener MessageListener)

Removes listener from message tree. You cannot remove the root element.

type MessageListener

type MessageListener interface {
	// Receives a message and returns whether to continue message propagation or not
	OnMessage(message Message) bool
}

Interface for receiving messages from dispatcher

type MessageListenerComponent

type MessageListenerComponent interface {
	Component
	MessageListener
}

type MouseEventData added in v0.1.5

type MouseEventData struct {
	MousePosition a.IntVector2
	SceneObject   *SceneObject
}

Represents the data of mouse related event.

type NamedObject

type NamedObject interface {
	GetName() string
}

type Object

type Object interface {
	ToString() string
}

type SceneContext added in v0.1.7

type SceneContext struct {
	Args a.SiMap
	// contains filtered or unexported fields
}

This struct holds data related to a scene.

type SceneObject

type SceneObject struct {
	Transform Transform
	// contains filtered or unexported fields
}

An object in the scene. The scene itself is also a SceneObject.

func LoadPrefab added in v0.1.1

func LoadPrefab(resId a.ResId) (*SceneObject, error)

Shortcut for (engine *AmphionEngine) LoadPrefab(resId int) (*SceneObject, error).

func NewSceneObject

func NewSceneObject(name string) *SceneObject

NewSceneObject creates a new instance of scene object.

func (*SceneObject) AddChild

func (o *SceneObject) AddChild(object *SceneObject)

Adds a child object to this scene object.

func (*SceneObject) AddComponent

func (o *SceneObject) AddComponent(component Component)

Adds a component to this scene object.

func (*SceneObject) DebugString added in v0.1.12

func (o *SceneObject) DebugString() string

For GoLand debugging.

func (*SceneObject) DecodeFromYaml

func (o *SceneObject) DecodeFromYaml(data []byte) error

func (*SceneObject) EncodeToYaml

func (o *SceneObject) EncodeToYaml() ([]byte, error)

func (*SceneObject) ForEachComponent

func (o *SceneObject) ForEachComponent(action func(component Component))

ForEachComponent iterates over each component attached to the object, calling the action function for each of them. The method skips uninitialized or disabled components.

func (*SceneObject) ForEachObject

func (o *SceneObject) ForEachObject(action func(object *SceneObject))

ForEachObject traverses the scene object tree, calling the action function for each of the objects. The action is also called for the object on which the method was called. The method skips uninitialized or disabled objects.

func (*SceneObject) FromMap

func (o *SceneObject) FromMap(siMap a.SiMap)

func (*SceneObject) GetChildByName

func (o *SceneObject) GetChildByName(name string) *SceneObject

Finds scene object in the list of children of the current object. Returns nil if no object with the specified name was not found.

func (*SceneObject) GetChildren

func (o *SceneObject) GetChildren() []*SceneObject

Returns the list of children of this object.

func (*SceneObject) GetComponentByName

func (o *SceneObject) GetComponentByName(n string) Component

Searches for component with the specified name throughout the components attached to this object. The parameter n can be a regex string. If there are multiple components with the same name returns the first. Returns nil if no component with the name n was found.

func (*SceneObject) GetComponents

func (o *SceneObject) GetComponents() []Component

Returns a slice of all components attached to the object.

func (*SceneObject) GetComponentsByName

func (o *SceneObject) GetComponentsByName(n string) []Component

Searches for all components with the specified name throughout the components attached to this object. The parameter n can be a regex string. Returns empty slice if no components with the name n was found.

func (*SceneObject) GetId

func (o *SceneObject) GetId() int

GetId returns the id of the object in the scene. The id is not guaranteed to remain the same over time and serves for internal engine purposes. For identification use object's name.

func (*SceneObject) GetName

func (o *SceneObject) GetName() string

GetName returns the name of the scene object.

func (*SceneObject) GetParent

func (o *SceneObject) GetParent() *SceneObject

Returns the parent object of this scene object. Returns nil if no parent object.

func (*SceneObject) HasBoundary

func (o *SceneObject) HasBoundary() bool

HasBoundary checks if the scene object has any boundary components.

func (*SceneObject) IsEnabled

func (o *SceneObject) IsEnabled() bool

Returns if this object is currently enabled or not.

func (*SceneObject) IsFocused

func (o *SceneObject) IsFocused() bool

IsFocused checks if the scene object is currently focused.

func (*SceneObject) IsHovered added in v0.1.7

func (o *SceneObject) IsHovered() bool

IsHovered checks if the cursor is over the scene object.

func (*SceneObject) IsPointInsideBoundaries

func (o *SceneObject) IsPointInsideBoundaries(point a.Vector3) bool

func (*SceneObject) IsPointInsideBoundaries2D

func (o *SceneObject) IsPointInsideBoundaries2D(point a.Vector3) bool

func (*SceneObject) IsRendering

func (o *SceneObject) IsRendering() bool

IsRendering checks if the scene object has any view components.

func (*SceneObject) IsVisibleInScene added in v0.1.7

func (o *SceneObject) IsVisibleInScene() bool

func (*SceneObject) OnMessage

func (o *SceneObject) OnMessage(message Message) bool

func (*SceneObject) Redraw added in v0.1.3

func (o *SceneObject) Redraw()

Forces all views of this object to redraw and requests rendering.

func (*SceneObject) RemoveChild

func (o *SceneObject) RemoveChild(object *SceneObject)

Removes a child from this scene object.

func (*SceneObject) SetEnabled

func (o *SceneObject) SetEnabled(enabled bool)

Set the enabled state of this object as specified.

func (*SceneObject) SetPosition added in v0.1.1

func (o *SceneObject) SetPosition(v a.Vector3)

Set the position of this object equal to the specified vector, requesting rendering.

func (*SceneObject) SetPositionXy added in v0.1.3

func (o *SceneObject) SetPositionXy(x, y float32)

func (*SceneObject) SetPositionXyz added in v0.1.1

func (o *SceneObject) SetPositionXyz(x, y, z float32)

Set the position of this object equal to a new vector with specified coordinates, requesting rendering.

func (*SceneObject) SetSize added in v0.1.1

func (o *SceneObject) SetSize(v a.Vector3)

Set the size of this object equal to the specified vector, requesting rendering.

func (*SceneObject) SetSizeXy added in v0.1.7

func (o *SceneObject) SetSizeXy(x, y float32)

Set the size of this object equal to a new vector with specified coordinates, requesting rendering.

func (*SceneObject) SetSizeXyz added in v0.1.1

func (o *SceneObject) SetSizeXyz(x, y, z float32)

Set the size of this object equal to a new vector with specified coordinates, requesting rendering.

func (*SceneObject) ToMap

func (o *SceneObject) ToMap() a.SiMap

func (*SceneObject) ToString

func (o *SceneObject) ToString() string

Returns the string representation of the scene object.

type StatefulComponent

type StatefulComponent interface {
	GetInstanceState() a.SiMap
	SetInstanceState(state a.SiMap)
}

Interface for components, that can persist state.

type Task

type Task struct {
	// contains filtered or unexported fields
}

func NewTask

func NewTask(runner TaskRunner, callback TaskCallback, errorCallback TaskErrorCallback) Task

type TaskBuilder

type TaskBuilder struct {
	// contains filtered or unexported fields
}

func NewTaskBuilder

func NewTaskBuilder() *TaskBuilder

func (*TaskBuilder) Build

func (b *TaskBuilder) Build() Task

func (*TaskBuilder) Err

func (b *TaskBuilder) Err(callback TaskErrorCallback) *TaskBuilder

func (*TaskBuilder) Run

func (b *TaskBuilder) Run(runner TaskRunner) *TaskBuilder

func (*TaskBuilder) Then added in v0.1.1

func (b *TaskBuilder) Then(callback TaskCallback) *TaskBuilder

type TaskCallback

type TaskCallback func(res interface{})

type TaskErrorCallback

type TaskErrorCallback func(err error)

type TaskRunner

type TaskRunner func() (interface{}, error)

type TasksRoutine

type TasksRoutine struct {
	// contains filtered or unexported fields
}

func (*TasksRoutine) RunTask

func (r *TasksRoutine) RunTask(task Task)

type Transform

type Transform struct {
	Position a.Vector3
	Pivot    a.Vector3
	Rotation a.Vector3
	Size     a.Vector3

	SceneObject *SceneObject
	// contains filtered or unexported fields
}

Transform describes how a scene object is positioned on the screen.

func NewTransform

func NewTransform(object *SceneObject) Transform

Creates a new transform with default values.

func NewTransformFromMap

func NewTransformFromMap(siMap a.SiMap) Transform

func (*Transform) FromMap

func (t *Transform) FromMap(siMap a.SiMap)

func (Transform) GetGlobalPosition

func (t Transform) GetGlobalPosition() a.Vector3

Calculates the actual global position in the scene.

func (Transform) GetGlobalRect

func (t Transform) GetGlobalRect() *common.RectBoundary

Calculates global rect of this transform.

func (Transform) GetGlobalTopLeftPosition

func (t Transform) GetGlobalTopLeftPosition() a.Vector3

Calculates global position of the top left point of the bounding box.

func (Transform) GetLocalPosition

func (t Transform) GetLocalPosition() a.Vector3

Calculates the actual local position related to this transform's parent.

func (Transform) GetParent

func (t Transform) GetParent() *Transform

Returns the parent transform of the current transform.

func (Transform) GetRect

func (t Transform) GetRect() *common.RectBoundary

Calculates local rect of this transform.

func (Transform) GetSize added in v0.1.1

func (t Transform) GetSize() a.Vector3

Calculates the actual size of the Transform replacing the special values.

func (Transform) GetTopLeftPosition

func (t Transform) GetTopLeftPosition() a.Vector3

Calculates local position of the top left point of the bounding box.

func (Transform) ToMap

func (t Transform) ToMap() a.SiMap

func (*Transform) ToRenderingTransform added in v0.1.1

func (t *Transform) ToRenderingTransform() rendering.Transform

Calculates a transform that is ready to be rendered on screen with all absolute values in pixels calculated.

type UpdateContext

type UpdateContext struct {
	DeltaTime float32
}

Contains info about current update cycle

type UpdatingComponent

type UpdatingComponent interface {
	Component
	OnUpdate(ctx UpdateContext)
}

Interface for components that can receive updates.

type ViewComponent

type ViewComponent interface {
	Component
	OnDraw(ctx DrawingContext)
	ForceRedraw()
}

Interface for views.

type ViewImpl added in v0.1.1

type ViewImpl struct {
	Redraw      bool
	Context     InitContext
	PrimitiveId int
	Engine      *AmphionEngine
	SceneObject *SceneObject
}

Basic view component implementation.

func (*ViewImpl) ForceRedraw added in v0.1.1

func (v *ViewImpl) ForceRedraw()

func (*ViewImpl) GetName added in v0.1.1

func (v *ViewImpl) GetName() string

func (*ViewImpl) OnDraw added in v0.1.1

func (v *ViewImpl) OnDraw(_ DrawingContext)

func (*ViewImpl) OnInit added in v0.1.1

func (v *ViewImpl) OnInit(ctx InitContext)

func (*ViewImpl) OnMessage added in v0.1.1

func (v *ViewImpl) OnMessage(message Message) bool

func (*ViewImpl) OnStart added in v0.1.1

func (v *ViewImpl) OnStart()

func (*ViewImpl) OnStop added in v0.1.1

func (v *ViewImpl) OnStop()

func (*ViewImpl) ShouldRedraw added in v0.1.1

func (v *ViewImpl) ShouldRedraw() bool

Directories

Path Synopsis
This package is a wrapper around github.com/cadmean-ru/goRPCKit library adapted for Amphion tasks system.
This package is a wrapper around github.com/cadmean-ru/goRPCKit library adapted for Amphion tasks system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL