Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*jshint esversion: 6 */
var widgets = require('@jupyter-widgets/base');
var _ = require('lodash');
var d3 = require("d3");
var bqplot = require('bqplot');
var THREE = require('three');
var interpolations = {'nearest': THREE.NearestFilter, 'bilinear': THREE.LinearFilter};
var jupyter_dataserializers = require("jupyter-dataserializers");
var serialize = require("./serialize");
class ImageGLModel extends bqplot.MarkModel {
defaults() {
return _.extend(bqplot.MarkModel.prototype.defaults(), {
_model_name : 'ImageGLModel',
_view_name : 'ImageGLView',
_model_module : 'bqplot-image-gl',
_view_module : 'bqplot-image-gl',
_model_module_version : '0.2.0',
_view_module_version : '0.2.0',
interpolation: 'nearest',
opacity: 1.0,
x: (0.0, 1.0),
y: (0.0, 1.0),
scales_metadata: {
'x': {'orientation': 'horizontal', 'dimension': 'x'},
'y': {'orientation': 'vertical', 'dimension': 'y'},
defaults() {
return _.extend(bqplot.MarkModel.prototype.defaults(), {
_model_name : 'ImageGLModel',
_view_name : 'ImageGLView',
_model_module : 'bqplot-image-gl',
_view_module : 'bqplot-image-gl',
_model_module_version : '0.2.0',
_view_module_version : '0.2.0',
interpolation: 'nearest',
opacity: 1.0,
x: (0.0, 1.0),
y: (0.0, 1.0),
scales_metadata: {
'x': {'orientation': 'horizontal', 'dimension': 'x'},
'y': {'orientation': 'vertical', 'dimension': 'y'},
},
});
}
} else {
x_scale.del_domain([], this.model_id + "_x");
}
}
if(y_scale) {
if(!this.get("preserve_domain").y) {
y_scale.compute_and_set_domain(this.mark_data.y, this.model_id + "_y");
} else {
y_scale.del_domain([], this.model_id + "_y");
}
}
}
}
ImageGLModel.serializers = Object.assign({}, bqplot.MarkModel.serializers,
{ x: serialize.array_or_json,
y: serialize.array_or_json,
image: { deserialize: (obj, manager) => {
let state = {buffer: obj.value, dtype: obj.dtype, shape: obj.shape};
return jupyter_dataserializers.JSONToArray(state);
}}});
class ImageGLView extends bqplot.Mark {
render() {
var base_render_promise = super.render();
window.last_image = this;
this.image_plane = new THREE.PlaneBufferGeometry( 1.0, 1.0 );
this.image_material = new THREE.ShaderMaterial( {
uniforms: {