@@ -13,23 +13,23 @@ var unpackThreeModel = require('./serializers').unpackThreeModel;
1313var BLACK = new THREE . Color ( 'black' ) ;
1414
1515
16- var PreviewView = RenderableView . extend ( {
16+ class PreviewView extends RenderableView {
1717
18- initialize : function ( ) {
18+ initialize ( ) {
1919 RenderableView . prototype . initialize . apply ( this , arguments ) ;
2020
2121 this . _resetCameraNeeded = true ;
2222 this . _rebuildNeeded = true ;
2323
24- } ,
24+ }
2525
26- render : function ( ) {
26+ render ( ) {
2727 // ensure that model is fully initialized before attempting render
2828 return this . model . initPromise . bind ( this ) . then ( this . doRender ) ;
29- } ,
29+ }
3030
3131
32- setupEventListeners : function ( ) {
32+ setupEventListeners ( ) {
3333 RenderableView . prototype . setupEventListeners . call ( this ) ;
3434 var child = this . model . get ( 'child' ) ;
3535 this . listenTo ( child , 'change' , this . onChildChanged . bind ( this ) ) ;
@@ -38,17 +38,17 @@ var PreviewView = RenderableView.extend({
3838 // any nested change instead of just rerendering.
3939 this . listenTo ( child , 'childchange' , this . onChildChanged . bind ( this ) ) ;
4040 }
41- } ,
41+ }
4242
43- onChildChanged : function ( ) {
43+ onChildChanged ( ) {
4444 // Enabling this line will reset the camera
4545 // when any changes are made to the child
4646 //this._resetCameraNeeded = true;
4747
4848 this . _rebuildNeeded = true ;
49- } ,
49+ }
5050
51- constructScene : function ( ) {
51+ constructScene ( ) {
5252
5353 var obj = this . model . get ( 'child' ) . obj ;
5454
@@ -131,9 +131,9 @@ var PreviewView = RenderableView.extend({
131131 // Clear at end to ensure that any changes to obj does not
132132 // cause infinite rebuild chain.
133133 this . _rebuildNeeded = false ;
134- } ,
134+ }
135135
136- resetCamera : function ( ) {
136+ resetCamera ( ) {
137137 // Compute bounding sphere for entire scene
138138 var sphere = utils . computeBoundingSphere ( this . scene ) ;
139139 if ( sphere === null ) {
@@ -152,14 +152,14 @@ var PreviewView = RenderableView.extend({
152152 // Position light up to the left and behind camera
153153 var dist = 2.5 * ( this . camera . position . z - sphere . center . z ) ;
154154 this . pointLight . position . set ( - dist , dist , dist ) ;
155- } ,
155+ }
156156
157- clearScene : function ( ) {
157+ clearScene ( ) {
158158 // this.controls.reset();
159159 this . scene . remove . apply ( this . scene , this . scene . children . slice ( ) ) ;
160- } ,
160+ }
161161
162- setupControls : function ( ) {
162+ setupControls ( ) {
163163 // Allow user to inspect object with mouse/scrollwheel
164164 this . debug ( 'setting up controls' ) ;
165165 var control = new OrbitControls ( this . camera , this . renderer . domElement ) ;
@@ -168,9 +168,9 @@ var PreviewView = RenderableView.extend({
168168 control . target . set ( 0 , 0 , 0 ) ;
169169 control . update ( ) ;
170170 this . controls = [ control ] ;
171- } ,
171+ }
172172
173- lazyRendererSetup : function ( ) {
173+ lazyRendererSetup ( ) {
174174 this . camera = new THREE . PerspectiveCamera ( 60 , 1.0 ) ;
175175 // aspect is updated by this.updateSize()
176176 // position and lookat target is updated to fit scene
@@ -194,9 +194,9 @@ var PreviewView = RenderableView.extend({
194194 this . enableControls ( ) ;
195195
196196 this . renderScene ( ) ;
197- } ,
197+ }
198198
199- renderScene : function ( ) {
199+ renderScene ( ) {
200200 this . debug ( 'renderScene' ) ;
201201
202202 if ( this . isFrozen ) {
@@ -220,24 +220,24 @@ var PreviewView = RenderableView.extend({
220220 if ( this . scene . ipymodel ) {
221221 this . scene . ipymodel . trigger ( 'afterRender' , this . scene , this . renderer , this . camera ) ;
222222 }
223- } ,
223+ }
224224
225- updateSize : function ( ) {
225+ updateSize ( ) {
226226 RenderableView . prototype . updateSize . call ( this ) ;
227227 if ( this . camera ) {
228228 var width = this . model . get ( '_width' ) ;
229229 var height = this . model . get ( '_height' ) ;
230230 this . camera . aspect = width / height ;
231231 this . camera . updateProjectionMatrix ( ) ;
232232 }
233- } ,
233+ }
234234
235- } ) ;
235+ }
236236
237237
238- var PreviewModel = RenderableModel . extend ( {
238+ class PreviewModel extends RenderableModel {
239239
240- defaults : function ( ) {
240+ defaults ( ) {
241241 return _ . extend ( RenderableModel . prototype . defaults . call ( this ) , {
242242 _model_name : 'PreviewModel' ,
243243 _view_name : 'PreviewView' ,
@@ -246,34 +246,33 @@ var PreviewModel = RenderableModel.extend({
246246 _wire : false ,
247247 child : null ,
248248 } ) ;
249- } ,
249+ }
250250
251- initialize : function ( attributes , options ) {
251+ initialize ( attributes , options ) {
252252 RenderableModel . prototype . initialize . apply ( this , arguments ) ;
253253
254254 // Don't listen to child until it is finished it's setup
255255 this . initPromise = this . get ( 'child' ) . initPromise . bind ( this ) . then ( function ( ) {
256256 this . setupListeners ( ) ;
257257 } ) ;
258- } ,
258+ }
259259
260- setupListeners : function ( ) {
260+ setupListeners ( ) {
261261 var child = this . get ( 'child' ) ;
262262 this . listenTo ( child , 'change' , this . onChildChanged . bind ( this ) ) ;
263263 this . listenTo ( child , 'childchange' , this . onChildChanged . bind ( this ) ) ;
264- } ,
264+ }
265265
266- onChildChanged : function ( model , options ) {
266+ onChildChanged ( model , options ) {
267267 this . trigger ( 'rerender' , this , { } ) ;
268- } ,
268+ }
269269
270- } , {
270+ }
271271
272- serializers : _ . extend ( {
273- child : { deserialize : unpackThreeModel } ,
274- } , RenderableModel . serializers ) ,
275-
276- } ) ;
272+ PreviewModel . serializers = {
273+ ...RenderableModel . serializers ,
274+ child : { deserialize : unpackThreeModel } ,
275+ } ;
277276
278277
279278module . exports = {
0 commit comments