diff --git a/js/src/k3d.js b/js/src/k3d.js index d6135f99..ad72e503 100644 --- a/js/src/k3d.js +++ b/js/src/k3d.js @@ -222,19 +222,19 @@ const PlotView = widgets.DOMWidgetView.extend({ this.model.lastCameraSync = (new Date()).getTime(); this.model.on('msg:custom', function (obj) { - const { model } = this; + const {model} = this; if (obj.msg_type === 'fetch_screenshot') { this.K3DInstance.getScreenshot(this.K3DInstance.parameters.screenshotScale, obj.only_canvas) .then((canvas) => { const data = canvas.toDataURL().split(',')[1]; - model.save('screenshot', data, { patch: true }); + model.save('screenshot', data, {patch: true}); }); } if (obj.msg_type === 'fetch_snapshot') { - model.save('snapshot', this.K3DInstance.getHTMLSnapshot(obj.compression_level), { patch: true }); + model.save('snapshot', this.K3DInstance.getHTMLSnapshot(obj.compression_level), {patch: true}); } if (obj.msg_type === 'start_auto_play') { @@ -350,13 +350,15 @@ const PlotView = widgets.DOMWidgetView.extend({ this._setVoxelPaintColor(); this.model.get('object_ids').forEach(function (id) { - this.renderPromises.push(this.K3DInstance.load({ objects: [objectsList[id].attributes] })); + this.renderPromises.push(this.K3DInstance.load({objects: [objectsList[id].attributes]})); }, this); this.cameraChangeId = this.K3DInstance.on(this.K3DInstance.events.CAMERA_CHANGE, (control) => { - if ((new Date()).getTime() - self.model.lastCameraSync > 200) { - self.model.lastCameraSync = (new Date()).getTime(); - self.model.save('camera', control, { patch: true }); + if (self.model._comm_live) { + if ((new Date()).getTime() - self.model.lastCameraSync > 200) { + self.model.lastCameraSync = (new Date()).getTime(); + self.model.save('camera', control, {patch: true}); + } } }); @@ -367,18 +369,18 @@ const PlotView = widgets.DOMWidgetView.extend({ } if (objectsList[change.id]) { - objectsList[change.id].save(change.key, change.value, { patch: true }); + objectsList[change.id].save(change.key, change.value, {patch: true}); } } }); this.GUIParametersChanges = this.K3DInstance.on(this.K3DInstance.events.PARAMETERS_CHANGE, (change) => { - self.model.save(change.key, change.value, { patch: true }); + self.model.save(change.key, change.value, {patch: true}); }); this.voxelsCallback = this.K3DInstance.on(this.K3DInstance.events.VOXELS_CALLBACK, (param) => { if (objectsList[param.object.K3DIdentifier]) { - objectsList[param.object.K3DIdentifier].send({ msg_type: 'click_callback', coord: param.coord }); + objectsList[param.object.K3DIdentifier].send({msg_type: 'click_callback', coord: param.coord}); } }); @@ -558,7 +560,7 @@ const PlotView = widgets.DOMWidgetView.extend({ }, this); _.difference(newObjectId, oldObjectId).forEach(function (id) { - this.renderPromises.push(this.K3DInstance.load({ objects: [objectsList[id].attributes] })); + this.renderPromises.push(this.K3DInstance.load({objects: [objectsList[id].attributes]})); }, this); },