@@ -13,23 +13,23 @@ var unpackThreeModel = require('./serializers').unpackThreeModel;
13
13
var BLACK = new THREE . Color ( 'black' ) ;
14
14
15
15
16
- var PreviewView = RenderableView . extend ( {
16
+ class PreviewView extends RenderableView {
17
17
18
- initialize : function ( ) {
18
+ initialize ( ) {
19
19
RenderableView . prototype . initialize . apply ( this , arguments ) ;
20
20
21
21
this . _resetCameraNeeded = true ;
22
22
this . _rebuildNeeded = true ;
23
23
24
- } ,
24
+ }
25
25
26
- render : function ( ) {
26
+ render ( ) {
27
27
// ensure that model is fully initialized before attempting render
28
28
return this . model . initPromise . bind ( this ) . then ( this . doRender ) ;
29
- } ,
29
+ }
30
30
31
31
32
- setupEventListeners : function ( ) {
32
+ setupEventListeners ( ) {
33
33
RenderableView . prototype . setupEventListeners . call ( this ) ;
34
34
var child = this . model . get ( 'child' ) ;
35
35
this . listenTo ( child , 'change' , this . onChildChanged . bind ( this ) ) ;
@@ -38,17 +38,17 @@ var PreviewView = RenderableView.extend({
38
38
// any nested change instead of just rerendering.
39
39
this . listenTo ( child , 'childchange' , this . onChildChanged . bind ( this ) ) ;
40
40
}
41
- } ,
41
+ }
42
42
43
- onChildChanged : function ( ) {
43
+ onChildChanged ( ) {
44
44
// Enabling this line will reset the camera
45
45
// when any changes are made to the child
46
46
//this._resetCameraNeeded = true;
47
47
48
48
this . _rebuildNeeded = true ;
49
- } ,
49
+ }
50
50
51
- constructScene : function ( ) {
51
+ constructScene ( ) {
52
52
53
53
var obj = this . model . get ( 'child' ) . obj ;
54
54
@@ -131,9 +131,9 @@ var PreviewView = RenderableView.extend({
131
131
// Clear at end to ensure that any changes to obj does not
132
132
// cause infinite rebuild chain.
133
133
this . _rebuildNeeded = false ;
134
- } ,
134
+ }
135
135
136
- resetCamera : function ( ) {
136
+ resetCamera ( ) {
137
137
// Compute bounding sphere for entire scene
138
138
var sphere = utils . computeBoundingSphere ( this . scene ) ;
139
139
if ( sphere === null ) {
@@ -152,14 +152,14 @@ var PreviewView = RenderableView.extend({
152
152
// Position light up to the left and behind camera
153
153
var dist = 2.5 * ( this . camera . position . z - sphere . center . z ) ;
154
154
this . pointLight . position . set ( - dist , dist , dist ) ;
155
- } ,
155
+ }
156
156
157
- clearScene : function ( ) {
157
+ clearScene ( ) {
158
158
// this.controls.reset();
159
159
this . scene . remove . apply ( this . scene , this . scene . children . slice ( ) ) ;
160
- } ,
160
+ }
161
161
162
- setupControls : function ( ) {
162
+ setupControls ( ) {
163
163
// Allow user to inspect object with mouse/scrollwheel
164
164
this . debug ( 'setting up controls' ) ;
165
165
var control = new OrbitControls ( this . camera , this . renderer . domElement ) ;
@@ -168,9 +168,9 @@ var PreviewView = RenderableView.extend({
168
168
control . target . set ( 0 , 0 , 0 ) ;
169
169
control . update ( ) ;
170
170
this . controls = [ control ] ;
171
- } ,
171
+ }
172
172
173
- lazyRendererSetup : function ( ) {
173
+ lazyRendererSetup ( ) {
174
174
this . camera = new THREE . PerspectiveCamera ( 60 , 1.0 ) ;
175
175
// aspect is updated by this.updateSize()
176
176
// position and lookat target is updated to fit scene
@@ -194,9 +194,9 @@ var PreviewView = RenderableView.extend({
194
194
this . enableControls ( ) ;
195
195
196
196
this . renderScene ( ) ;
197
- } ,
197
+ }
198
198
199
- renderScene : function ( ) {
199
+ renderScene ( ) {
200
200
this . debug ( 'renderScene' ) ;
201
201
202
202
if ( this . isFrozen ) {
@@ -220,24 +220,24 @@ var PreviewView = RenderableView.extend({
220
220
if ( this . scene . ipymodel ) {
221
221
this . scene . ipymodel . trigger ( 'afterRender' , this . scene , this . renderer , this . camera ) ;
222
222
}
223
- } ,
223
+ }
224
224
225
- updateSize : function ( ) {
225
+ updateSize ( ) {
226
226
RenderableView . prototype . updateSize . call ( this ) ;
227
227
if ( this . camera ) {
228
228
var width = this . model . get ( '_width' ) ;
229
229
var height = this . model . get ( '_height' ) ;
230
230
this . camera . aspect = width / height ;
231
231
this . camera . updateProjectionMatrix ( ) ;
232
232
}
233
- } ,
233
+ }
234
234
235
- } ) ;
235
+ }
236
236
237
237
238
- var PreviewModel = RenderableModel . extend ( {
238
+ class PreviewModel extends RenderableModel {
239
239
240
- defaults : function ( ) {
240
+ defaults ( ) {
241
241
return _ . extend ( RenderableModel . prototype . defaults . call ( this ) , {
242
242
_model_name : 'PreviewModel' ,
243
243
_view_name : 'PreviewView' ,
@@ -246,34 +246,33 @@ var PreviewModel = RenderableModel.extend({
246
246
_wire : false ,
247
247
child : null ,
248
248
} ) ;
249
- } ,
249
+ }
250
250
251
- initialize : function ( attributes , options ) {
251
+ initialize ( attributes , options ) {
252
252
RenderableModel . prototype . initialize . apply ( this , arguments ) ;
253
253
254
254
// Don't listen to child until it is finished it's setup
255
255
this . initPromise = this . get ( 'child' ) . initPromise . bind ( this ) . then ( function ( ) {
256
256
this . setupListeners ( ) ;
257
257
} ) ;
258
- } ,
258
+ }
259
259
260
- setupListeners : function ( ) {
260
+ setupListeners ( ) {
261
261
var child = this . get ( 'child' ) ;
262
262
this . listenTo ( child , 'change' , this . onChildChanged . bind ( this ) ) ;
263
263
this . listenTo ( child , 'childchange' , this . onChildChanged . bind ( this ) ) ;
264
- } ,
264
+ }
265
265
266
- onChildChanged : function ( model , options ) {
266
+ onChildChanged ( model , options ) {
267
267
this . trigger ( 'rerender' , this , { } ) ;
268
- } ,
268
+ }
269
269
270
- } , {
270
+ }
271
271
272
- serializers : _ . extend ( {
273
- child : { deserialize : unpackThreeModel } ,
274
- } , RenderableModel . serializers ) ,
275
-
276
- } ) ;
272
+ PreviewModel . serializers = {
273
+ ...RenderableModel . serializers ,
274
+ child : { deserialize : unpackThreeModel } ,
275
+ } ;
277
276
278
277
279
278
module . exports = {
0 commit comments