mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
get endianness dynamically
This commit is contained in:
@@ -278,4 +278,9 @@ function _getIndicesWriter (dataView: DataView, indexUnit: IndexUnit) {
|
||||
return (offset: number, value: number) => dataView.setUint8(offset, value);
|
||||
}
|
||||
|
||||
const isLittleEndian = true;
|
||||
const isLittleEndian = (() => {
|
||||
const buffer = new ArrayBuffer(2);
|
||||
new DataView(buffer).setInt16(0, 256, true);
|
||||
// Int16Array uses the platform's endianness.
|
||||
return new Int16Array(buffer)[0] === 256;
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user