Sunday, February 9, 2014 0 comments
My 3D tic-tac-toe game demonstrates how to inject a factory singleton of a WebGL scene into AngularJS directives and controllers.
This approach encapsulates the WebGL scene as a service factory. Such encapsulation exposes access to the scene via the returned factory's API.
AngularJS Factory Features:
- Can be injected into controllers and directives
- Isolates all three.js code from user and framework
- Exposes API allowing DOM events, AngularJS and three.js code to interact
- Allows you to create/destroy scenes
- Manually start, stop render loop
- Manual render for static scenes (no render loop)