Skip to content

Commit

Permalink
Merge pull request DragonBones#115 from alcalyn/bugfix/int16-to-uint16
Browse files Browse the repository at this point in the history
Fix type error, assigning Int16 to Uint16 colors
  • Loading branch information
akdcl authored Aug 6, 2019
2 parents be28ef8 + f18cc9b commit 1ea565e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DragonBones/src/dragonBones/model/DragonBonesData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace dragonBones {
/**
* @internal
*/
public intArray: Int16Array;
public intArray: Uint16Array;
/**
* @internal
*/
Expand Down
6 changes: 3 additions & 3 deletions DragonBones/src/dragonBones/parser/BinaryDataParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace dragonBones {
export class BinaryDataParser extends ObjectDataParser {
private _binaryOffset: number;
private _binary: ArrayBuffer;
private _intArrayBuffer: Int16Array;
private _intArrayBuffer: Uint16Array;
private _frameArrayBuffer: Int16Array;
private _timelineArrayBuffer: Uint16Array;

Expand Down Expand Up @@ -366,13 +366,13 @@ namespace dragonBones {
const l5 = offsets[9];
const l6 = offsets[11];
const l7 = offsets.length > 12 ? offsets[13] : 0; // Color.
const intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT);
const intArray = new Uint16Array(this._binary, this._binaryOffset + offsets[0], l1 / Uint16Array.BYTES_PER_ELEMENT);
const floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT);
const frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT);
const frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT);
const frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT);
const timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT);
const colorArray = l7 > 0 ? new Int16Array(this._binary, this._binaryOffset + offsets[12], l7 / Int16Array.BYTES_PER_ELEMENT) : intArray; // Color.
const colorArray = l7 > 0 ? new Uint16Array(this._binary, this._binaryOffset + offsets[12], l7 / Uint16Array.BYTES_PER_ELEMENT) : intArray; // Color.

this._data.binary = this._binary;
this._data.intArray = this._intArrayBuffer = intArray;
Expand Down
4 changes: 2 additions & 2 deletions DragonBones/src/dragonBones/parser/ObjectDataParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2244,13 +2244,13 @@ namespace dragonBones {
const lTotal = l1 + l2 + l3 + l4 + l5 + l6 + l7;
//
const binary = new ArrayBuffer(lTotal);
const intArray = new Int16Array(binary, 0, this._intArray.length);
const intArray = new Uint16Array(binary, 0, this._intArray.length);
const floatArray = new Float32Array(binary, l1, this._floatArray.length);
const frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length);
const frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length);
const frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length);
const timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length);
const colorArray = new Int16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length);
const colorArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length);

for (let i = 0, l = this._intArray.length; i < l; ++i) {
intArray[i] = this._intArray[i];
Expand Down

0 comments on commit 1ea565e

Please sign in to comment.