@rive-app/webgl2 2.32.2 → 2.33.0
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 +10 -0
- package/rive.js +39 -21
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +2 -0
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ export declare enum Alignment {
|
|
|
33
33
|
BottomCenter = "bottomCenter",
|
|
34
34
|
BottomRight = "bottomRight"
|
|
35
35
|
}
|
|
36
|
+
export declare enum DrawOptimizationOptions {
|
|
37
|
+
AlwaysDraw = "alwaysDraw",
|
|
38
|
+
DrawOnChanged = "drawOnChanged"
|
|
39
|
+
}
|
|
36
40
|
export interface LayoutParameters {
|
|
37
41
|
fit?: Fit;
|
|
38
42
|
alignment?: Alignment;
|
|
@@ -260,6 +264,10 @@ export interface RiveParameters {
|
|
|
260
264
|
* Enables multi touch support
|
|
261
265
|
*/
|
|
262
266
|
enableMultiTouch?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Enum with drawing options for optimizations
|
|
269
|
+
*/
|
|
270
|
+
drawingOptions?: DrawOptimizationOptions;
|
|
263
271
|
onLoad?: EventCallback;
|
|
264
272
|
onLoadError?: EventCallback;
|
|
265
273
|
onPlay?: EventCallback;
|
|
@@ -421,6 +429,7 @@ export declare class Rive {
|
|
|
421
429
|
private _boundDraw;
|
|
422
430
|
private _viewModelInstance;
|
|
423
431
|
private _dataEnums;
|
|
432
|
+
private drawOptimization;
|
|
424
433
|
durations: number[];
|
|
425
434
|
frameTimes: number[];
|
|
426
435
|
frameCount: number;
|
|
@@ -700,6 +709,7 @@ export declare class Rive {
|
|
|
700
709
|
* renderer is already active, then this will have zero effect.
|
|
701
710
|
*/
|
|
702
711
|
startRendering(): void;
|
|
712
|
+
private scheduleRendering;
|
|
703
713
|
/**
|
|
704
714
|
* Enables frames-per-second (FPS) reporting for the runtime
|
|
705
715
|
* If no callback is provided, Rive will append a fixed-position div at the top-right corner of
|
package/rive.js
CHANGED
|
@@ -427,7 +427,7 @@ function Na(a, b) {
|
|
|
427
427
|
return Ma(c, a, b);
|
|
428
428
|
}));
|
|
429
429
|
}
|
|
430
|
-
var Oa, Pa, Ta = {
|
|
430
|
+
var Oa, Pa, Ta = {547041:(a, b, c, d, e) => {
|
|
431
431
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
432
432
|
return 0;
|
|
433
433
|
}
|
|
@@ -490,11 +490,11 @@ var Oa, Pa, Ta = {544671:(a, b, c, d, e) => {
|
|
|
490
490
|
}
|
|
491
491
|
window.h.Ea += 1;
|
|
492
492
|
return 1;
|
|
493
|
-
},
|
|
493
|
+
}, 549219:() => {
|
|
494
494
|
"undefined" !== typeof window.h && (window.h.Xa.map(function(a) {
|
|
495
495
|
document.removeEventListener(a, window.h.unlock, !0);
|
|
496
496
|
}), --window.h.Ea, 0 === window.h.Ea && delete window.h);
|
|
497
|
-
},
|
|
497
|
+
}, 549523:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 549627:() => {
|
|
498
498
|
try {
|
|
499
499
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
500
500
|
a.close();
|
|
@@ -502,7 +502,7 @@ var Oa, Pa, Ta = {544671:(a, b, c, d, e) => {
|
|
|
502
502
|
} catch (c) {
|
|
503
503
|
return 0;
|
|
504
504
|
}
|
|
505
|
-
},
|
|
505
|
+
}, 549798:(a, b, c, d, e, f) => {
|
|
506
506
|
if ("undefined" === typeof window.h) {
|
|
507
507
|
return -1;
|
|
508
508
|
}
|
|
@@ -548,7 +548,7 @@ var Oa, Pa, Ta = {544671:(a, b, c, d, e) => {
|
|
|
548
548
|
a == window.h.I.Ca && g.Y.connect(g.K.destination);
|
|
549
549
|
g.nb = f;
|
|
550
550
|
return window.h.lc(g);
|
|
551
|
-
},
|
|
551
|
+
}, 552675:a => window.h.ta(a).K.sampleRate, 552748:a => {
|
|
552
552
|
a = window.h.ta(a);
|
|
553
553
|
void 0 !== a.Y && (a.Y.onaudioprocess = function() {
|
|
554
554
|
}, a.Y.disconnect(), a.Y = void 0);
|
|
@@ -556,13 +556,13 @@ var Oa, Pa, Ta = {544671:(a, b, c, d, e) => {
|
|
|
556
556
|
a.K.close();
|
|
557
557
|
a.K = void 0;
|
|
558
558
|
a.nb = void 0;
|
|
559
|
-
},
|
|
559
|
+
}, 553148:a => {
|
|
560
560
|
window.h.yb(a);
|
|
561
|
-
},
|
|
561
|
+
}, 553198:a => {
|
|
562
562
|
a = window.h.ta(a);
|
|
563
563
|
a.K.resume();
|
|
564
564
|
a.state = window.h.ia.ub;
|
|
565
|
-
},
|
|
565
|
+
}, 553337:a => {
|
|
566
566
|
a = window.h.ta(a);
|
|
567
567
|
a.K.suspend();
|
|
568
568
|
a.state = window.h.ia.stopped;
|
|
@@ -3388,7 +3388,9 @@ f, g, k, m) => {
|
|
|
3388
3388
|
W.vertexAttribIPointer(a, b, c, d, e);
|
|
3389
3389
|
}, glVertexAttribPointer:(a, b, c, d, e, f) => {
|
|
3390
3390
|
W.vertexAttribPointer(a, b, c, !!d, e, f);
|
|
3391
|
-
}, glViewport:(a, b, c, d) => W.viewport(a, b, c, d),
|
|
3391
|
+
}, glViewport:(a, b, c, d) => W.viewport(a, b, c, d), isWindowsBrowser:function() {
|
|
3392
|
+
return -1 < navigator.platform.indexOf("Win");
|
|
3393
|
+
}, provokingVertexWEBGL:function(a, b) {
|
|
3392
3394
|
(a = w[a].C.pb) && a.provokingVertexWEBGL(b);
|
|
3393
3395
|
}, strftime_l:(a, b, c, d) => Yd(a, b, c, d), upload_image:function(a, b) {
|
|
3394
3396
|
var c = l.images;
|
|
@@ -3496,7 +3498,7 @@ moduleRtn = ca;
|
|
|
3496
3498
|
/* 2 */
|
|
3497
3499
|
/***/ ((module) => {
|
|
3498
3500
|
|
|
3499
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.
|
|
3501
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.33.0","description":"Rive\'s webgl2 based web api.","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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3500
3502
|
|
|
3501
3503
|
/***/ }),
|
|
3502
3504
|
/* 3 */
|
|
@@ -4311,6 +4313,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4311
4313
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4312
4314
|
/* harmony export */ Alignment: () => (/* binding */ Alignment),
|
|
4313
4315
|
/* harmony export */ DataEnum: () => (/* binding */ DataEnum),
|
|
4316
|
+
/* harmony export */ DrawOptimizationOptions: () => (/* binding */ DrawOptimizationOptions),
|
|
4314
4317
|
/* harmony export */ EventType: () => (/* binding */ EventType),
|
|
4315
4318
|
/* harmony export */ Fit: () => (/* binding */ Fit),
|
|
4316
4319
|
/* harmony export */ Layout: () => (/* binding */ Layout),
|
|
@@ -4458,6 +4461,12 @@ var Alignment;
|
|
|
4458
4461
|
Alignment["BottomCenter"] = "bottomCenter";
|
|
4459
4462
|
Alignment["BottomRight"] = "bottomRight";
|
|
4460
4463
|
})(Alignment || (Alignment = {}));
|
|
4464
|
+
// Drawing optimization options
|
|
4465
|
+
var DrawOptimizationOptions;
|
|
4466
|
+
(function (DrawOptimizationOptions) {
|
|
4467
|
+
DrawOptimizationOptions["AlwaysDraw"] = "alwaysDraw";
|
|
4468
|
+
DrawOptimizationOptions["DrawOnChanged"] = "drawOnChanged";
|
|
4469
|
+
})(DrawOptimizationOptions || (DrawOptimizationOptions = {}));
|
|
4461
4470
|
// Alignment options for Rive animations in a HTML canvas
|
|
4462
4471
|
var Layout = /** @class */ (function () {
|
|
4463
4472
|
function Layout(params) {
|
|
@@ -5780,7 +5789,7 @@ var RiveFile = /** @class */ (function () {
|
|
|
5780
5789
|
var Rive = /** @class */ (function () {
|
|
5781
5790
|
function Rive(params) {
|
|
5782
5791
|
var _this = this;
|
|
5783
|
-
var _a;
|
|
5792
|
+
var _a, _b;
|
|
5784
5793
|
// Tracks if a Rive file is loaded
|
|
5785
5794
|
this.loaded = false;
|
|
5786
5795
|
// Tracks if a Rive file is destroyed
|
|
@@ -5822,6 +5831,7 @@ var Rive = /** @class */ (function () {
|
|
|
5822
5831
|
this._boundDraw = null;
|
|
5823
5832
|
this._viewModelInstance = null;
|
|
5824
5833
|
this._dataEnums = null;
|
|
5834
|
+
this.drawOptimization = DrawOptimizationOptions.DrawOnChanged;
|
|
5825
5835
|
// Durations to generate a frame for the last second. Used for performance profiling.
|
|
5826
5836
|
this.durations = [];
|
|
5827
5837
|
this.frameTimes = [];
|
|
@@ -5861,6 +5871,7 @@ var Rive = /** @class */ (function () {
|
|
|
5861
5871
|
? params.dispatchPointerExit
|
|
5862
5872
|
: this.dispatchPointerExit;
|
|
5863
5873
|
this.enableMultiTouch = !!params.enableMultiTouch;
|
|
5874
|
+
this.drawOptimization = (_b = params.drawingOptions) !== null && _b !== void 0 ? _b : this.drawOptimization;
|
|
5864
5875
|
this.enableRiveAssetCDN =
|
|
5865
5876
|
params.enableRiveAssetCDN === undefined
|
|
5866
5877
|
? true
|
|
@@ -6185,7 +6196,7 @@ var Rive = /** @class */ (function () {
|
|
|
6185
6196
|
}
|
|
6186
6197
|
}
|
|
6187
6198
|
else {
|
|
6188
|
-
this.
|
|
6199
|
+
this.scheduleRendering();
|
|
6189
6200
|
}
|
|
6190
6201
|
};
|
|
6191
6202
|
/**
|
|
@@ -6272,17 +6283,21 @@ var Rive = /** @class */ (function () {
|
|
|
6272
6283
|
this.artboard.advance(elapsedTime);
|
|
6273
6284
|
}
|
|
6274
6285
|
var renderer = this.renderer;
|
|
6275
|
-
// Canvas must be wiped to prevent artifacts
|
|
6276
|
-
renderer.clear();
|
|
6277
|
-
renderer.save();
|
|
6278
|
-
// Update the renderer alignment if necessary
|
|
6279
|
-
this.alignRenderer();
|
|
6280
6286
|
// Do not draw on 0 canvas size
|
|
6281
6287
|
if (!this._hasZeroSize) {
|
|
6282
|
-
this
|
|
6288
|
+
// If there was no dirt on this frame, do not clear and draw
|
|
6289
|
+
if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
|
|
6290
|
+
this.artboard.didChange()) {
|
|
6291
|
+
// Canvas must be wiped to prevent artifacts
|
|
6292
|
+
renderer.clear();
|
|
6293
|
+
renderer.save();
|
|
6294
|
+
// Update the renderer alignment if necessary
|
|
6295
|
+
this.alignRenderer();
|
|
6296
|
+
this.artboard.draw(renderer);
|
|
6297
|
+
renderer.restore();
|
|
6298
|
+
renderer.flush();
|
|
6299
|
+
}
|
|
6283
6300
|
}
|
|
6284
|
-
renderer.restore();
|
|
6285
|
-
renderer.flush();
|
|
6286
6301
|
// Check for any animations that looped
|
|
6287
6302
|
this.animator.handleLooping();
|
|
6288
6303
|
// Check for any state machines that had a state change
|
|
@@ -6303,7 +6318,7 @@ var Rive = /** @class */ (function () {
|
|
|
6303
6318
|
// https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations
|
|
6304
6319
|
if (this.animator.isPlaying) {
|
|
6305
6320
|
// Request a new rendering frame
|
|
6306
|
-
this.
|
|
6321
|
+
this.scheduleRendering();
|
|
6307
6322
|
}
|
|
6308
6323
|
else if (this.animator.isPaused) {
|
|
6309
6324
|
// Reset the end time so on playback it starts at the correct frame
|
|
@@ -6993,6 +7008,9 @@ var Rive = /** @class */ (function () {
|
|
|
6993
7008
|
* renderer is already active, then this will have zero effect.
|
|
6994
7009
|
*/
|
|
6995
7010
|
Rive.prototype.startRendering = function () {
|
|
7011
|
+
this.drawFrame();
|
|
7012
|
+
};
|
|
7013
|
+
Rive.prototype.scheduleRendering = function () {
|
|
6996
7014
|
if (this.loaded && this.artboard && !this.frameRequestId) {
|
|
6997
7015
|
if (this.runtime.requestAnimationFrame) {
|
|
6998
7016
|
this.frameRequestId = this.runtime.requestAnimationFrame(this._boundDraw);
|