Skip to content

Commit a7a14e3

Browse files
committed
Fix id -> model_id
1 parent d7a6571 commit a7a14e3

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

js/src/_base/Three.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var ThreeModel = widgets.WidgetModel.extend({
1717
defaults: function() {
1818
return _.extend(widgets.WidgetModel.prototype.defaults.call(this), {
1919
_model_name: 'ThreeModel',
20+
_model_module: 'jupyter-threejs',
2021
});
2122
},
2223

@@ -123,8 +124,8 @@ var ThreeModel = widgets.WidgetModel.extend({
123124
if (cacheDescriptor) {
124125
var obj = this.getThreeObjectFromCache(cacheDescriptor);
125126
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);
128129
}
129130

130131
this.obj = obj;
@@ -146,9 +147,17 @@ var ThreeModel = widgets.WidgetModel.extend({
146147

147148
return objPromise.bind(this).then(function(obj) {
148149

149-
obj.ipymodelId = this.id; // brand that sucker
150+
obj.ipymodelId = this.model_id; // brand that sucker
150151
obj.ipymodel = this;
151152

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+
152161
this.putThreeObjectIntoCache(cacheDescriptor, obj);
153162

154163
// pickers need access to the model from the three.js object
@@ -173,7 +182,7 @@ var ThreeModel = widgets.WidgetModel.extend({
173182

174183
getCacheDescriptor: function() {
175184

176-
var id = this.id;
185+
var id = this.model_id;
177186
if (id != null) {
178187
return { id: id };
179188
}
@@ -298,7 +307,7 @@ var ThreeModel = widgets.WidgetModel.extend({
298307
},
299308

300309
onChildChanged: function(model, options) {
301-
console.log('child changed: ' + model.id);
310+
console.log('child changed: ' + model.model_id);
302311
// Propagate up hierarchy:
303312
this.trigger('childchange', this);
304313
},

0 commit comments

Comments
 (0)