@rive-app/canvas-single 1.0.14 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rive.d.ts +5 -0
- package/rive.js +32 -3
- package/rive.js.map +1 -1
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -255,6 +255,9 @@ export declare class Rive {
|
|
|
255
255
|
private taskQueue;
|
|
256
256
|
private animator;
|
|
257
257
|
private static readonly missingErrorMessage;
|
|
258
|
+
durations: number[];
|
|
259
|
+
frameTimes: number[];
|
|
260
|
+
frameCount: number;
|
|
258
261
|
constructor(params: RiveParameters);
|
|
259
262
|
static new(params: RiveParameters): Rive;
|
|
260
263
|
private init;
|
|
@@ -276,6 +279,8 @@ export declare class Rive {
|
|
|
276
279
|
* Align the renderer
|
|
277
280
|
*/
|
|
278
281
|
private alignRenderer;
|
|
282
|
+
get fps(): number;
|
|
283
|
+
get frameTime(): string | 0;
|
|
279
284
|
/**
|
|
280
285
|
* Cleans up any Wasm-generated objects that need to be manually destroyed:
|
|
281
286
|
* artboard instances, animation instances, state machine instances.
|
package/rive.js
CHANGED
|
@@ -124,7 +124,7 @@ if(h.preInit)for("function"==typeof h.preInit&&(h.preInit=[h.preInit]);0<h.preIn
|
|
|
124
124
|
/* 2 */
|
|
125
125
|
/***/ ((module) => {
|
|
126
126
|
|
|
127
|
-
module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.0.
|
|
127
|
+
module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.0.15","description":"Rive\'s high-level canvas based web api all in one js file.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
128
128
|
|
|
129
129
|
/***/ })
|
|
130
130
|
/******/ ]);
|
|
@@ -1018,6 +1018,10 @@ var Rive = /** @class */ (function () {
|
|
|
1018
1018
|
this.readyForPlaying = false;
|
|
1019
1019
|
// Runtime artboard
|
|
1020
1020
|
this.artboard = null;
|
|
1021
|
+
// Durations to generate a frame for the last second. Used for performance profiling.
|
|
1022
|
+
this.durations = [];
|
|
1023
|
+
this.frameTimes = [];
|
|
1024
|
+
this.frameCount = 0;
|
|
1021
1025
|
/**
|
|
1022
1026
|
* Used be draw to track when a second of active rendering time has passed. Used for debugging purposes
|
|
1023
1027
|
*/
|
|
@@ -1206,6 +1210,7 @@ var Rive = /** @class */ (function () {
|
|
|
1206
1210
|
* @param time the time at which to render a frame
|
|
1207
1211
|
*/
|
|
1208
1212
|
Rive.prototype.draw = function (time, onSecond) {
|
|
1213
|
+
var before = performance.now();
|
|
1209
1214
|
// Clear the frameRequestId, as we're now rendering a fresh frame
|
|
1210
1215
|
this.frameRequestId = null;
|
|
1211
1216
|
// On the first pass, make sure lastTime has a valid value
|
|
@@ -1256,6 +1261,15 @@ var Rive = /** @class */ (function () {
|
|
|
1256
1261
|
this.animator.handleLooping();
|
|
1257
1262
|
// Check for any state machines that had a state change
|
|
1258
1263
|
this.animator.handleStateChanges();
|
|
1264
|
+
// Add duration to create frame to durations array
|
|
1265
|
+
this.frameCount++;
|
|
1266
|
+
var after = performance.now();
|
|
1267
|
+
this.frameTimes.push(after);
|
|
1268
|
+
this.durations.push(after - before);
|
|
1269
|
+
while (this.frameTimes[0] <= after - 1000) {
|
|
1270
|
+
this.frameTimes.shift();
|
|
1271
|
+
this.durations.shift();
|
|
1272
|
+
}
|
|
1259
1273
|
// Calling requestAnimationFrame will rerun draw() at the correct rate:
|
|
1260
1274
|
// https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations
|
|
1261
1275
|
if (this.animator.isPlaying) {
|
|
@@ -1281,8 +1295,6 @@ var Rive = /** @class */ (function () {
|
|
|
1281
1295
|
var _a = this, renderer = _a.renderer, runtime = _a.runtime, _layout = _a._layout, artboard = _a.artboard;
|
|
1282
1296
|
// Canvas must be wiped to prevent artifacts
|
|
1283
1297
|
renderer.clear();
|
|
1284
|
-
// Now save so that future changes to align can restore
|
|
1285
|
-
renderer.save();
|
|
1286
1298
|
// Align things up safe in the knowledge we can restore if changed
|
|
1287
1299
|
renderer.align(_layout.runtimeFit(runtime), _layout.runtimeAlignment(runtime), {
|
|
1288
1300
|
minX: _layout.minX,
|
|
@@ -1291,6 +1303,23 @@ var Rive = /** @class */ (function () {
|
|
|
1291
1303
|
maxY: _layout.maxY
|
|
1292
1304
|
}, artboard.bounds);
|
|
1293
1305
|
};
|
|
1306
|
+
Object.defineProperty(Rive.prototype, "fps", {
|
|
1307
|
+
get: function () {
|
|
1308
|
+
return this.durations.length;
|
|
1309
|
+
},
|
|
1310
|
+
enumerable: false,
|
|
1311
|
+
configurable: true
|
|
1312
|
+
});
|
|
1313
|
+
Object.defineProperty(Rive.prototype, "frameTime", {
|
|
1314
|
+
get: function () {
|
|
1315
|
+
if (this.durations.length === 0) {
|
|
1316
|
+
return 0;
|
|
1317
|
+
}
|
|
1318
|
+
return (this.durations.reduce(function (a, b) { return a + b; }, 0) / this.durations.length).toFixed(4);
|
|
1319
|
+
},
|
|
1320
|
+
enumerable: false,
|
|
1321
|
+
configurable: true
|
|
1322
|
+
});
|
|
1294
1323
|
/**
|
|
1295
1324
|
* Cleans up any Wasm-generated objects that need to be manually destroyed:
|
|
1296
1325
|
* artboard instances, animation instances, state machine instances.
|