Skip to content

Commit e422136

Browse files
authored
Merge pull request #82 from jasongrout/lights2
Make lights inherit from the base 3d object
2 parents cd5dbbe + 71f2ec4 commit e422136

File tree

1 file changed

+16
-40
lines changed

1 file changed

+16
-40
lines changed

js/src/jupyter-threejs.js

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ define(["jupyter-js-widgets", "underscore", "three", "ndarray"],
155155

156156
update: function() {
157157
//this.replace_obj(this.new_obj());
158-
//this.update_object_parameters();
158+
this.update_object_parameters();
159159
this.needs_update();
160160
},
161161

@@ -1185,36 +1185,22 @@ define(["jupyter-js-widgets", "underscore", "three", "ndarray"],
11851185
}
11861186
});
11871187

1188-
1189-
var Basic3dObject = Object3dView.extend({
1190-
render: function() {
1191-
this.update();
1192-
return this.obj;
1193-
},
1194-
1195-
update: function() {
1196-
this.replace_obj(this.new_obj());
1197-
Object3dView.prototype.update.call(this);
1198-
}
1199-
});
1200-
1201-
1202-
var AmbientLight = Basic3dObject.extend({
1188+
var AmbientLight = Object3dView.extend({
12031189
new_obj: function() {
12041190
return new THREE.AmbientLight(this.model.get('color'));
12051191
}
12061192
});
12071193

12081194

1209-
var DirectionalLight = Basic3dObject.extend({
1195+
var DirectionalLight = Object3dView.extend({
12101196
new_obj: function() {
12111197
return new THREE.DirectionalLight(this.model.get('color'),
12121198
this.model.get('intensity'));
12131199
}
12141200
});
12151201

12161202

1217-
var PointLight = Basic3dObject.extend({
1203+
var PointLight = Object3dView.extend({
12181204
new_obj: function() {
12191205
return new THREE.PointLight(this.model.get('color'),
12201206
this.model.get('intensity'),
@@ -1223,15 +1209,15 @@ define(["jupyter-js-widgets", "underscore", "three", "ndarray"],
12231209
});
12241210

12251211

1226-
var SpotLight = Basic3dObject.extend({
1212+
var SpotLight = Object3dView.extend({
12271213
new_obj: function() {
12281214
return new THREE.SpotLight(this.model.get('color'),
12291215
this.model.get('intensity'),
12301216
this.model.get('distance'));
12311217
}
12321218
});
12331219

1234-
var HemisphereLight = Basic3dObject.extend({
1220+
var HemisphereLight = Object3dView.extend({
12351221
new_obj: function() {
12361222
return new THREE.HemisphereLight(this.model.get('color'),
12371223
this.model.get('ground_color'),
@@ -1277,17 +1263,21 @@ define(["jupyter-js-widgets", "underscore", "three", "ndarray"],
12771263
}
12781264
});
12791265

1280-
var Basic3dObjectModel = widgets.WidgetModel.extend({
1266+
var Object3dModel = widgets.WidgetModel.extend({
12811267
defaults: _.extend({}, widgets.WidgetModel.prototype.defaults, {
1282-
_model_module: 'jupyter-threejs',
12831268
_view_module: 'jupyter-threejs',
1284-
_model_name: 'Basic3dObjectModel',
1285-
_view_name: 'Basic3dObjectView'
1269+
_model_module: 'jupyter-threejs',
1270+
_view_name: 'Object3dView',
1271+
_model_name: 'Object3dModel'
12861272
})
1273+
}, {
1274+
serializers: _.extend({
1275+
children: { deserialize: widgets.unpack_models }
1276+
}, widgets.WidgetModel.serializers)
12871277
});
12881278

1289-
var LightModel = Basic3dObjectModel.extend({
1290-
defaults: _.extend({}, Basic3dObjectModel.prototype.defaults, {
1279+
var LightModel = Object3dModel.extend({
1280+
defaults: _.extend({}, Object3dModel.prototype.defaults, {
12911281
_model_name: 'LightModel',
12921282
color: 'white'
12931283
})
@@ -1340,18 +1330,6 @@ define(["jupyter-js-widgets", "underscore", "three", "ndarray"],
13401330
})
13411331
}, {}, LightModel.serializers);
13421332

1343-
var Object3dModel = widgets.WidgetModel.extend({
1344-
defaults: _.extend({}, widgets.WidgetModel.prototype.defaults, {
1345-
_view_module: 'jupyter-threejs',
1346-
_model_module: 'jupyter-threejs',
1347-
_view_name: 'Object3dView',
1348-
_model_name: 'Object3dModel'
1349-
})
1350-
}, {
1351-
serializers: _.extend({
1352-
children: { deserialize: widgets.unpack_models }
1353-
}, widgets.WidgetModel.serializers)
1354-
});
13551333

13561334
var ScaledObjectModel = Object3dModel.extend({
13571335
defaults: _.extend({}, Object3dModel.prototype.defaults, {
@@ -2065,8 +2043,6 @@ define(["jupyter-js-widgets", "underscore", "three", "ndarray"],
20652043
EffectModel : EffectModel,
20662044
AnaglyphEffectView : AnaglyphEffectView,
20672045
AnaglyphEffectModel : AnaglyphEffectModel,
2068-
Basic3dObject : Basic3dObject,
2069-
Basic3dObjectModel : Basic3dObjectModel,
20702046
BasicMaterialView : BasicMaterialView,
20712047
BasicMaterialModel : BasicMaterialModel,
20722048
BoxGeometryView : BoxGeometryView,

0 commit comments

Comments
 (0)