11var Class = require ( '../../utils/Class' ) ;
2- var GetFastValue = require ( '../../utils/object/GetFastValue' ) ;
32var OrthographicCamera = require ( './OrthographicCamera' ) ;
43var PerspectiveCamera = require ( './PerspectiveCamera' ) ;
54var PluginManager = require ( '../../plugins/PluginManager' ) ;
@@ -38,6 +37,14 @@ var CameraManager = new Class({
3837 */
3938 this . systems = scene . sys ;
4039
40+ /**
41+ * An Array of the Camera objects being managed by this Camera Manager.
42+ *
43+ * @property {Phaser.Cameras.Sprite3D.Camera[] } cameras
44+ * @since 3.0.0
45+ */
46+ this . cameras = [ ] ;
47+
4148 if ( ! scene . sys . settings . isBooted )
4249 {
4350 scene . sys . events . once ( 'boot' , this . boot , this ) ;
@@ -96,6 +103,8 @@ var CameraManager = new Class({
96103
97104 var camera = new OrthographicCamera ( this . scene , width , height ) ;
98105
106+ this . cameras . push ( camera ) ;
107+
99108 return camera ;
100109 } ,
101110
@@ -121,18 +130,9 @@ var CameraManager = new Class({
121130
122131 var camera = new PerspectiveCamera ( this . scene , fieldOfView , width , height ) ;
123132
124- return camera ;
125- } ,
133+ this . cameras . push ( camera ) ;
126134
127- /**
128- * [description]
129- *
130- * @method Phaser.Cameras.Sprite3D.CameraManager#destroy
131- * @since 3.0.0
132- */
133- destroy : function ( )
134- {
135- this . scene = undefined ;
135+ return camera ;
136136 } ,
137137
138138 /**
@@ -170,58 +170,28 @@ var CameraManager = new Class({
170170 {
171171 var cameraIndex = this . cameras . indexOf ( camera ) ;
172172
173- if ( cameraIndex >= 0 && this . cameras . length > 1 )
173+ if ( cameraIndex !== - 1 )
174174 {
175- this . cameraPool . push ( this . cameras [ cameraIndex ] ) ;
176175 this . cameras . splice ( cameraIndex , 1 ) ;
177-
178- if ( this . main === camera )
179- {
180- this . main = this . cameras [ 0 ] ;
181- }
182- }
183- } ,
184-
185- /**
186- * [description]
187- *
188- * @method Phaser.Cameras.Sprite3D.CameraManager#render
189- * @since 3.0.0
190- *
191- * @param {[type] } renderer - [description]
192- * @param {[type] } children - [description]
193- * @param {[type] } interpolation - [description]
194- */
195- render : function ( renderer , children , interpolation )
196- {
197- var cameras = this . cameras ;
198-
199- for ( var i = 0 , l = cameras . length ; i < l ; ++ i )
200- {
201- var camera = cameras [ i ] ;
202-
203- camera . preRender ( ) ;
204-
205- renderer . render ( this . scene , children , interpolation , camera ) ;
206176 }
207177 } ,
208178
209179 /**
210180 * [description]
211181 *
212- * @method Phaser.Cameras.Sprite3D.CameraManager#resetAll
182+ * @method Phaser.Cameras.Sprite3D.CameraManager#removeAll
213183 * @since 3.0.0
214184 *
215185 * @return {[type] } [description]
216186 */
217- resetAll : function ( )
187+ removeAll : function ( )
218188 {
219189 while ( this . cameras . length > 0 )
220190 {
221- this . cameraPool . push ( this . cameras . pop ( ) ) ;
222- }
191+ var camera = this . cameras . pop ( ) ;
223192
224- this . main = this . add ( ) ;
193+ camera . destroy ( ) ;
194+ }
225195
226196 return this . main ;
227197 } ,
@@ -251,6 +221,17 @@ var CameraManager = new Class({
251221 */
252222 shutdown : function ( )
253223 {
224+ } ,
225+
226+ /**
227+ * [description]
228+ *
229+ * @method Phaser.Cameras.Sprite3D.CameraManager#destroy
230+ * @since 3.0.0
231+ */
232+ destroy : function ( )
233+ {
234+ this . scene = undefined ;
254235 }
255236
256237} ) ;
0 commit comments