mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-11 09:38:44 +08:00
Single precision: Backport from pixi-spine (#964)
This commit is contained in:
parent
f7bb981852
commit
720b9c316b
File diff suppressed because one or more lines are too long
@ -699,7 +699,7 @@ module spine {
|
||||
let eventMap = map.events[i];
|
||||
let eventData = skeletonData.findEvent(eventMap.name);
|
||||
if (eventData == null) throw new Error("Event not found: " + eventMap.name);
|
||||
let event = new Event(eventMap.time, eventData);
|
||||
let event = new Event(Utils.toSinglePrecision(eventMap.time), eventData);
|
||||
event.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
|
||||
@ -255,6 +255,10 @@ module spine {
|
||||
static toFloatArray (array: Array<number>) {
|
||||
return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
|
||||
}
|
||||
|
||||
static toSinglePrecision (value: number) {
|
||||
return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
|
||||
}
|
||||
}
|
||||
|
||||
export class DebugUtils {
|
||||
|
||||
13
spine-ts/core/src/polyfills.ts
Normal file
13
spine-ts/core/src/polyfills.ts
Normal file
@ -0,0 +1,13 @@
|
||||
interface Math {
|
||||
fround(n: number): number;
|
||||
}
|
||||
|
||||
(() => {
|
||||
if (!Math.fround) {
|
||||
Math.fround = (function (array) {
|
||||
return function (x: number) {
|
||||
return array[0] = x, array[0];
|
||||
};
|
||||
})(new Float32Array(1));
|
||||
}
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user