提交 bc272b03 编写于 作者: D Dale Stammen

changed readByte() and readString() to read from Uint8Array returned by xhr2

上级 15deafae
......@@ -585,27 +585,16 @@ CTM.InterleavedStream.prototype.writeByte = function(value){
CTM.Stream = function(data){
this.data = data;
this.offset = 0;
if (typeof data === 'string'){
this.readByte = this.readByteFromString;
this.readString = this.readStringFromString;
} else {
this.readByte = this.readByteFromArray;
this.readString = this.readStringFromArray;
}
};
CTM.Stream.prototype.TWO_POW_MINUS23 = Math.pow(2, -23);
CTM.Stream.prototype.TWO_POW_MINUS126 = Math.pow(2, -126);
CTM.Stream.prototype.readByteFromArray = function(){
CTM.Stream.prototype.readByte = function(){
return this.data[this.offset ++] & 0xff;
};
CTM.Stream.prototype.readByteFromString = function(){
return this.data.charCodeAt(this.offset ++) & 0xff;
};
CTM.Stream.prototype.readInt32 = function(){
var i = this.readByte();
i |= this.readByte() << 8;
......@@ -636,7 +625,7 @@ CTM.Stream.prototype.readFloat32 = function(){
return s * 0;
};
CTM.Stream.prototype.readStringFromArray = function(){
CTM.Stream.prototype.readString = function(){
var len = this.readInt32();
this.offset += len;
......@@ -644,15 +633,6 @@ CTM.Stream.prototype.readStringFromArray = function(){
return this.data.subarray(this.offset - len, len);
};
CTM.Stream.prototype.readStringFromString = function(){
var len = this.readInt32();
this.offset += len;
return this.data.substr(this.offset - len, len);
};
CTM.Stream.prototype.readArrayInt32 = function(array){
var i = 0, len = array.length;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册