===Parser Interface===
There will be cases in which users have their own Currently XBPS only supports reading .ASC file formatwhich they want types. If you require the library to render with XB PointStream (for exampleother files,.ARA or .XML). We you will need to give users the ability to write theirown a custom parser and hook as register it into with the library. This should not be difficult, there are only a few things your parser must implement.
Users would write their JavaScript code which would implementthe methods belowWe have already created a demonstration of this. Once they do that, they would register theirparser with the library by passing in an extension and their parserYou can find it [http://# here].
The library would then take care Here is a skeleton of the rest by creating an instanceof their a parser, call its methods you could take and return a point cloud object.implement:
<pre>
var Your_Parser_Name = (function() { /** The constructor XBPS will create an instance of the your parser.and pass in an object with three @param {Object} obj - collection of named functions These functions pass the parser back to the library since the library couldproperties: be working with many parsers simultaneously.
start - must occur exactly once. Has one argument, the parser itself
end - must occur exactly once. Has one argument, the parser itself
parse - may occur one or many times. Has two arguments, the parser itself and a
named collection of value types.
See below for an example
*/
Constructor(obj)
/*
Begins to load the resource.
@param {String} path - path to resource
*/
load(path)
////// Getters Everytime your parser calls the parse function, it must send in an object with named arrays. In the following example, vertexArray is a Float32Array which contain the vertices which have already been read and parsed.
/* var attributes = {}; attributes["ps_Vertex"] = vertexArray; Get the version of this parser.attributes["ps_Color"] = colorsArray;
@returns {String} parse - may occur one or many times. Has two arguments, the parser itself and a Your parser versionis responsible for calling these functions at the appropriate times. */version function Your_Parser_Name(config) { /* Get Returns the number version of points which have been parsedthis parser.*/ this.__defineGetter__("version", function(){ return /*!!*/; @returns {Number } ); /*Get the number of parsed points parsed so far by the parser.*/ this.__defineGetter__("numParsedPoints", function(){ return /*!!*/;numParsedPoints }); /* Get the total number of points in the point cloud, including points.*/ which have not yet been parsed this.__defineGetter__("numTotalPoints", function(){ return /*!!*/; @returns {Number } ); /*Returns the total number progress of points in downloading the resource or -1 if unknownpoint cloud between zero and one.*/ this.__defineGetter__("progress", function(){ return /*!!*/;numTotalPoints }); /* Get Returns the progress file size of the parserresource in bytes.*/ this.__defineGetter__("fileSize", how much it has parsed so far.function(){ return /*!!*/; }); /** @returns {Number} value between 0 param path Path to 1 or -1 if unknownthe resource */ this.load = function(path){ /*!!*/progress }; } return Your_Parser_Name;}());</pre>
/*
The size of the resource in bytes.
@returns {Number} the number of bytes in the resource or -1 if unknown.
*/
fileSize
</pre>
<pre>
/*
The following example demonstrates how XB PointStream XBPS might use
a particular parser.
*/
// create a hypothetical parser and set the callbacks
parser = new XYZParserYour_Parser_Name({ start: startCallback, parse: parseCallback, end: finishCallback});
// load some resource
parser.load("pointcloud.xyz");
</pre>