I am using STLLoader to load some binary STL file for meshing, and I am writing it in ES6. The issue I got is when I use _.bind
to bind this
object with function (because some attribute in this
will be used in callback function), it seems this will be treated as onprogress which cases error Uncaught TypeError: callback.onProgress is not a function
in three js
here is some of my code:
initialize(setting){
this.Url='xxxxxx'
//for 3D rendering
this.overlay = {
label: 'STL',
loaded: false,
material: null,
materialFront: null,
materialBack: null,
mesh: null,
meshFront: null,
meshBack: null,
color: 0xe91e63,
opacity: 0.7,
}
this.doMesh(this.Url);
}
doMesh: function(Url){
stlLoader.load(Url, _.bind(function(geometry) {
console.log(geometry);
}),this.overlay);
}
error happens in three.js:
request.addEventListener( 'progress', function ( event ) {
var callbacks = loading[ url ];
for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
var callback = callbacks[ i ];
if ( callback.onProgress ) callback.onProgress( event );
///callback.onProgress will be `this` object instead of `null`
}
}, false );
Is there a way to fix that? Any help appreciate!