@@ -17,6 +17,7 @@ var ThreeModel = widgets.WidgetModel.extend({
17
17
defaults : function ( ) {
18
18
return _ . extend ( widgets . WidgetModel . prototype . defaults . call ( this ) , {
19
19
_model_name : 'ThreeModel' ,
20
+ _model_module : 'jupyter-threejs' ,
20
21
} ) ;
21
22
} ,
22
23
@@ -123,8 +124,8 @@ var ThreeModel = widgets.WidgetModel.extend({
123
124
if ( cacheDescriptor ) {
124
125
var obj = this . getThreeObjectFromCache ( cacheDescriptor ) ;
125
126
if ( obj ) {
126
- if ( obj . ipymodelId != this . id ) {
127
- throw new Error ( 'model id does not match three object: ' + obj . ipymodelId + ' -- ' + this . id ) ;
127
+ if ( obj . ipymodelId != this . model_id ) {
128
+ throw new Error ( 'model id does not match three object: ' + obj . ipymodelId + ' -- ' + this . model_id ) ;
128
129
}
129
130
130
131
this . obj = obj ;
@@ -146,9 +147,17 @@ var ThreeModel = widgets.WidgetModel.extend({
146
147
147
148
return objPromise . bind ( this ) . then ( function ( obj ) {
148
149
149
- obj . ipymodelId = this . id ; // brand that sucker
150
+ obj . ipymodelId = this . model_id ; // brand that sucker
150
151
obj . ipymodel = this ;
151
152
153
+ if ( ! cacheDescriptor ) {
154
+ cacheDescriptor = this . getCacheDescriptor ( ) ;
155
+ if ( ! cacheDescriptor ) {
156
+ console . error ( 'Model missing ID:' , this ) ;
157
+ throw new Error ( 'Model missing ID!' ) ;
158
+ }
159
+ }
160
+
152
161
this . putThreeObjectIntoCache ( cacheDescriptor , obj ) ;
153
162
154
163
// pickers need access to the model from the three.js object
@@ -173,7 +182,7 @@ var ThreeModel = widgets.WidgetModel.extend({
173
182
174
183
getCacheDescriptor : function ( ) {
175
184
176
- var id = this . id ;
185
+ var id = this . model_id ;
177
186
if ( id != null ) {
178
187
return { id : id } ;
179
188
}
@@ -298,7 +307,7 @@ var ThreeModel = widgets.WidgetModel.extend({
298
307
} ,
299
308
300
309
onChildChanged : function ( model , options ) {
301
- console . log ( 'child changed: ' + model . id ) ;
310
+ console . log ( 'child changed: ' + model . model_id ) ;
302
311
// Propagate up hierarchy:
303
312
this . trigger ( 'childchange' , this ) ;
304
313
} ,
0 commit comments