React Scene
Installation
npm install --save react-scene
Usage
React Scene is a component that expose different methods to handle a typic scene logic.
The methods are:
load
Load everything that has to be loadedbuild
Build the scene (if you need to create or rend any object)resize
Resize the scene. It is also automatically called when thewidth
orheight
props change on the scenemute
To mute the sceneunmute
To unmute the sceneplay
Play the scenepause
Pause the sceneend
End the scenedestroy
Destroy any resources
Each method can be synchronous or asynchronous and will trigger lifecycle methods on the parent listening to them. Those lifecycles methods are in the following format sceneWill[Method]
and sceneDid[Method]
(Ex: sceneWillLoad
, sceneDidLoad
)
Basic usage
Creating a scene component
var React = ;var ReactScene = ;var createjs = ; var Scene = React; // Calling createScene with the Component as the first argument, will wrap// your scene component in a ReactScene Component and assure that the methods// you define will be called and the corresponding lifecycle methods.moduleexports = ReactScene;
Using the scene component
var React = ;var Scene = ; var Story = React; moduleexports = Story;
Controlling the scene
var React = ;var Scene = ; var Story = React; moduleexports = Story;