STLloader and three.js - How to check if file is binary? -


um using three.js (r79) , stlloader rendering .stl files.

following piece of code should processed if file binary, because if it's ascii - error.

 geometry = new three.geometry().frombuffergeometry( geometry ); 

the following code adds new property generated geometry isascii , isbinary.

var loader = new three.stlloader(); loader.parsebinary = function(data){     var parsebinary = three.stlloader.prototype.parsebinary.bind(this);      var result = parsebinary(data);     result.isbinary = true;     return result; }; loader.parseascii= function(data){     var parseascii= three.stlloader.prototype.parseascii.bind(this);      var result = parseascii(data);     result.isascii = true;     return result; }; loader.load(url,function(geometry){     if (geometry.isascii){         ...     } else if (geometry.isbinary){         ...     }  }); 

the loader separates binary , ascii files. makes use of feature.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -