# SceneScript Reference

SceneScript is follows the ECMAScript 2018 specification, so you can utilize all functionalities from ECMAScript that you would also find in similar languages such as JavaScript. This is very useful as you can make use of various helpful classes. For example, Date allows you to access the current date and time, Math allows you to access various mathematical utility functions.

This page only covers all additions that SceneScript adds to make working with wallpapers possible.

# Globals

SceneScript introduces a handful of globals which you can access at any point in your code.

Global Description
engine Access to general features of the application. IEngine class.
input Input related data, mainly the mouse cursor. IInput class.
thisScene The currently loaded scene wallpaper. IScene class
thisLayer The layer this script has been loaded on. ILayer class.
thisObject The object this script belongs to. IThisPropertyObject class.
console Access the console log for debugging purposes. IConsole class.
shared Empty by default, allows you to share data between multiple scripts. Shared class.

# Events

SceneScript uses an event system that allows you to run specific code whenever certain events take place. Most notably, the update event is most commonly used to execute SceneScript code at every frame that Wallpaper Engine calculates. The init event is good for running code once when the wallpaper is first loaded and the applyUserProperties event allows you to react to changes to user properties of your wallpaper. Additionally, there are a handful of cursor events which related to mouse movement and mouse input which you can incorporate into your wallpaper.

Event Description
init This initialization function will be called once after the object it belongs to has been created.
update This event function will be called every frame for all scripts that export it.
destroy This event function will be called just before the object it belongs to gets destroyed.
resizeScreen This function will be called every time the wallpaper resizes because of a change to the current resolution.
applyUserProperties This event function will be called once initially when the wallpaper is loaded and whenever any user properties are being adjusted by the user.
cursorEnter This event function will be called when the cursor enters the bounds of the object.
cursorLeave This event function will be called when the cursor leaves the bounds of the object.
cursorMove This event function will be called when the cursor has been moved.
cursorDown This event function will be called when the cursor is being pressed down on an object.
cursorUp This event function will be called when the cursor is being released over an object.
cursorClick This event function will be called when the cursor has been pressed and released on the same object.
mediaStatusChanged This event function will be called when the media integration is turned on or off by the user.
mediaPlaybackChanged This event function will be called when the users starts, stops or pauses media.
mediaPropertiesChanged This event function will be called when the properties of the currently playing media change.
mediaThumbnailChanged This event function will be called when the thumbnail of the currently playing media changes.
mediaTimelineChanged This event function will be called when the current time of the playing media changes and is only provided by certain applications.

# Classes

All components of Wallpaper Engine are provided with a fitting class so that you can access everything programmatically. The following list contains all relevant classes introduced by SceneScript:

Class Description
AnimationEvent This object describes an animation event that has been fired from a timeline or puppet warp animation.
AudioBuffers Provides access to the left and right audio spectrum values and their combined average for audio visualization purposes.
CameraTransforms Objects of this class describe the camera orientation and position.
CursorEvent Provides information about the cursor position during cursor events.
IAnimation This class represents a timeline property animation.
IAnimationLayer This class represents a puppet warp or 3D model animation layer.
IConsole You can access this interface anywhere in your SceneScript code through the global console object to interact with the console log.
IEffect Provides access to image effects used on image layers.
IEffectLayer Base class for image and text layers.
IEngine Provides general information about the user device and the running wallpaper.
IImageLayer This class provides access to functions specific to image layers.
IModelLayer This class provides access to functions specific to 3D model layers.
IInput Provides access to input related data, mainly the mouse cursor.
ILayer Provides access to data related to a layer.
ILocalStorage Provides access to the local storage functionality.
IMaterial Provides access to dynamic properties of materials / shader properties.
IParticleSystem Provides access to particle systems and lets you modify their playback state.
IParticleSystemInstance Provides access to instance modifiers for particle systems. You can use this to adjust details of a particle system dynamically.
IScene Provides access to properties of the currently loaded scene.
ISoundLayer Provides access functions specific to sound layers.
ITextureAnimation This class represents a texture animation.
IVideoTexture This class represents a video texture animation.
Mat4 Utility class used for creating a 4 dimensional identity matrix.
MediaPlaybackEvent Media integration event, fired when the user starts, stops or pauses media.
MediaPropertiesEvent Media integration event, fired when the properties of the current media session are changing.
MediaStatusEvent Media integration event, fired when the user turns the media integration on or off.
MediaThumbnailEvent Media integration event, fired when the thumbnail pertaining to the current media changes.
MediaTimelineEvent Optional media integration event, fired irregularly when the current time of the media session changes.
Shared Related to the global object shared which you may use to share data between multiple scripts.
Vec2 Utility class which holds a 2 dimensional value pair: x and y.
Vec3 Utility class which holds a 3 dimensional value pair: x, y and z.

# Modules

Wallpaper Engine also provides some modules which can be used to access certain utility functions. These can be helpful to easily implement certain use-cases.

Module Description
WEColor Module which provides utility functions related to color manipulation.
WEMath Module which provides utility functions related to general mathematical functions.
WEVector Module which provides utility functions related to working with vectors.