@netless/slide 0.6.4 → 0.6.5
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/README.md +6 -0
- package/lib/PlayerController.d.ts +27 -11
- package/lib/PlayerController.js +131 -86
- package/lib/RenderingTaskManager.js +1 -1
- package/lib/Slide.d.ts +1 -0
- package/lib/Slide.js +86 -106
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
player
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { PPTPlayer } from "@netless/ppt-player";
|
|
2
|
+
export declare class PlayerConfig {
|
|
3
|
+
private player;
|
|
4
|
+
constructor(player: PPTPlayer);
|
|
5
|
+
get frameRate(): any;
|
|
6
|
+
set frameRate(_: any);
|
|
7
|
+
get drawFrames(): number;
|
|
8
|
+
set drawFrames(_: number);
|
|
9
|
+
get drawCall(): number;
|
|
10
|
+
set drawCall(_: number);
|
|
11
|
+
get resolution(): number;
|
|
12
|
+
set resolution(value: number);
|
|
13
|
+
get size(): any;
|
|
14
|
+
set size(_: any);
|
|
15
|
+
get minFPS(): number;
|
|
16
|
+
set minFPS(value: number);
|
|
17
|
+
get maxFPS(): number;
|
|
18
|
+
set maxFPS(value: number);
|
|
19
|
+
get autoResolution(): boolean;
|
|
20
|
+
set autoResolution(value: boolean);
|
|
21
|
+
get autoFPS(): boolean;
|
|
22
|
+
set autoFPS(value: boolean);
|
|
23
|
+
get backgroundColor(): any;
|
|
24
|
+
set backgroundColor(value: any);
|
|
6
25
|
}
|
|
7
26
|
export declare class PlayerController {
|
|
8
27
|
private stateId;
|
|
9
|
-
private
|
|
10
|
-
private data;
|
|
11
|
-
private player;
|
|
28
|
+
private anchor;
|
|
12
29
|
private gui;
|
|
13
30
|
private controller;
|
|
14
|
-
private
|
|
15
|
-
constructor(
|
|
31
|
+
private config;
|
|
32
|
+
constructor(player: PPTPlayer, anchor: HTMLDivElement);
|
|
16
33
|
private createStats;
|
|
17
34
|
private createControllerGUI;
|
|
18
|
-
private addEventListener;
|
|
19
35
|
destroy(): void;
|
|
20
36
|
}
|
package/lib/PlayerController.js
CHANGED
|
@@ -1,113 +1,158 @@
|
|
|
1
1
|
import { GUI } from "dat.gui";
|
|
2
|
-
|
|
2
|
+
var PlayerConfig = /** @class */ (function () {
|
|
3
|
+
function PlayerConfig(player) {
|
|
4
|
+
this.player = player;
|
|
5
|
+
}
|
|
6
|
+
;
|
|
7
|
+
Object.defineProperty(PlayerConfig.prototype, "frameRate", {
|
|
8
|
+
get: function () {
|
|
9
|
+
return this.player.fps.value;
|
|
10
|
+
},
|
|
11
|
+
set: function (_) { },
|
|
12
|
+
enumerable: false,
|
|
13
|
+
configurable: true
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(PlayerConfig.prototype, "drawFrames", {
|
|
16
|
+
get: function () {
|
|
17
|
+
return this.player.runtime.fps;
|
|
18
|
+
},
|
|
19
|
+
set: function (_) { },
|
|
20
|
+
enumerable: false,
|
|
21
|
+
configurable: true
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(PlayerConfig.prototype, "drawCall", {
|
|
24
|
+
get: function () {
|
|
25
|
+
return this.player.runtime.drawCall;
|
|
26
|
+
},
|
|
27
|
+
set: function (_) { },
|
|
28
|
+
enumerable: false,
|
|
29
|
+
configurable: true
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(PlayerConfig.prototype, "resolution", {
|
|
32
|
+
get: function () {
|
|
33
|
+
return this.player.config.resolution;
|
|
34
|
+
},
|
|
35
|
+
set: function (value) {
|
|
36
|
+
this.player.updateConfig({ resolution: value });
|
|
37
|
+
},
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(PlayerConfig.prototype, "size", {
|
|
42
|
+
get: function () {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
return "".concat((_a = this.player.view) === null || _a === void 0 ? void 0 : _a.width, "*").concat((_b = this.player.view) === null || _b === void 0 ? void 0 : _b.height);
|
|
45
|
+
},
|
|
46
|
+
set: function (_) { },
|
|
47
|
+
enumerable: false,
|
|
48
|
+
configurable: true
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(PlayerConfig.prototype, "minFPS", {
|
|
51
|
+
get: function () {
|
|
52
|
+
return this.player.config.minFPS;
|
|
53
|
+
},
|
|
54
|
+
set: function (value) {
|
|
55
|
+
this.player.updateConfig({ minFPS: value });
|
|
56
|
+
},
|
|
57
|
+
enumerable: false,
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(PlayerConfig.prototype, "maxFPS", {
|
|
61
|
+
get: function () {
|
|
62
|
+
return this.player.config.maxFPS;
|
|
63
|
+
},
|
|
64
|
+
set: function (value) {
|
|
65
|
+
this.player.updateConfig({ maxFPS: value });
|
|
66
|
+
},
|
|
67
|
+
enumerable: false,
|
|
68
|
+
configurable: true
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(PlayerConfig.prototype, "autoResolution", {
|
|
71
|
+
get: function () {
|
|
72
|
+
return this.player.config.autoResolution;
|
|
73
|
+
},
|
|
74
|
+
set: function (value) {
|
|
75
|
+
this.player.updateConfig({ autoResolution: value });
|
|
76
|
+
},
|
|
77
|
+
enumerable: false,
|
|
78
|
+
configurable: true
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(PlayerConfig.prototype, "autoFPS", {
|
|
81
|
+
get: function () {
|
|
82
|
+
return this.player.config.autoFPS;
|
|
83
|
+
},
|
|
84
|
+
set: function (value) {
|
|
85
|
+
this.player.updateConfig({ autoFPS: value });
|
|
86
|
+
},
|
|
87
|
+
enumerable: false,
|
|
88
|
+
configurable: true
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(PlayerConfig.prototype, "backgroundColor", {
|
|
91
|
+
get: function () {
|
|
92
|
+
return this.player.config.transactionBgColor;
|
|
93
|
+
},
|
|
94
|
+
set: function (value) {
|
|
95
|
+
this.player.updateConfig({ transactionBgColor: value });
|
|
96
|
+
},
|
|
97
|
+
enumerable: false,
|
|
98
|
+
configurable: true
|
|
99
|
+
});
|
|
100
|
+
return PlayerConfig;
|
|
101
|
+
}());
|
|
102
|
+
export { PlayerConfig };
|
|
3
103
|
var PlayerController = /** @class */ (function () {
|
|
4
|
-
function PlayerController(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.target = props.target;
|
|
10
|
-
this.data = props.params;
|
|
11
|
-
this.player = props.player;
|
|
12
|
-
this.gui = this.createControllerGUI();
|
|
104
|
+
function PlayerController(player, anchor) {
|
|
105
|
+
var _a;
|
|
106
|
+
this.config = new PlayerConfig(player);
|
|
107
|
+
this.anchor = anchor;
|
|
108
|
+
_a = this.createControllerGUI(), this.gui = _a[0], this.controller = _a[1];
|
|
13
109
|
this.createStats();
|
|
14
|
-
this.addEventListener();
|
|
15
110
|
}
|
|
16
111
|
PlayerController.prototype.createStats = function () {
|
|
17
112
|
var _this = this;
|
|
18
113
|
this.stateId = setInterval(function () {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
114
|
+
_this.controller.frameRate.updateDisplay();
|
|
115
|
+
_this.controller.size.updateDisplay();
|
|
116
|
+
_this.controller.minFPS.updateDisplay();
|
|
117
|
+
_this.controller.drawFrames.updateDisplay();
|
|
118
|
+
_this.controller.maxFPS.updateDisplay();
|
|
119
|
+
_this.controller.resolution.updateDisplay();
|
|
120
|
+
_this.controller.autoFps.updateDisplay();
|
|
121
|
+
_this.controller.autoResolution.updateDisplay();
|
|
122
|
+
_this.controller.drawCall.updateDisplay();
|
|
123
|
+
}, 16);
|
|
25
124
|
};
|
|
26
125
|
PlayerController.prototype.createControllerGUI = function () {
|
|
27
|
-
var _a, _b, _c, _d, _e;
|
|
28
126
|
var gui = new GUI({
|
|
29
127
|
autoPlace: true,
|
|
30
|
-
closed:
|
|
128
|
+
closed: false,
|
|
31
129
|
});
|
|
32
130
|
gui.domElement.style.opacity = ".6";
|
|
33
131
|
gui.domElement.style.transformOrigin = "100% 0";
|
|
34
132
|
gui.domElement.style.transform = "scale(1)";
|
|
35
|
-
this.
|
|
133
|
+
this.anchor.appendChild(gui.domElement);
|
|
36
134
|
gui.domElement.style.position = "absolute";
|
|
37
135
|
gui.domElement.style.right = "0";
|
|
38
136
|
gui.domElement.style.top = "0";
|
|
39
137
|
gui.domElement.style.zIndex = "2";
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
maxFPS: renderOptions.add({ "最高fps": (_b = this.data.maxFPS) !== null && _b !== void 0 ? _b : 50 }, "最高fps", 0, 60),
|
|
52
|
-
resolution: renderOptions.add({ "目标分辨倍率": (_c = this.data.resolution) !== null && _c !== void 0 ? _c : window.devicePixelRatio }, "目标分辨倍率", 0.5, 6),
|
|
53
|
-
autoResolution: renderOptions.add({ "自动分辨率": (_d = this.data.autoResolution) !== null && _d !== void 0 ? _d : false }, "自动分辨率", true),
|
|
54
|
-
autoFps: renderOptions.add({ "自动fps": (_e = this.data.autoFPS) !== null && _e !== void 0 ? _e : true }, "自动fps", true),
|
|
55
|
-
transactionBgColor: renderOptions.addColor({ "切页背景色": this.data.transactionBgColor }, "切页背景色"),
|
|
138
|
+
var controller = {
|
|
139
|
+
frameRate: gui.add(this.config, "frameRate"),
|
|
140
|
+
drawFrames: gui.add(this.config, "drawFrames"),
|
|
141
|
+
drawCall: gui.add(this.config, "drawCall"),
|
|
142
|
+
size: gui.add(this.config, "size"),
|
|
143
|
+
minFPS: gui.add(this.config, "minFPS", 0, 60),
|
|
144
|
+
maxFPS: gui.add(this.config, "maxFPS", 0, 60),
|
|
145
|
+
resolution: gui.add(this.config, "resolution", 0.5, 8, 0.5),
|
|
146
|
+
autoResolution: gui.add(this.config, "autoResolution"),
|
|
147
|
+
autoFps: gui.add(this.config, "autoFPS"),
|
|
148
|
+
transactionBgColor: gui.addColor(this.config, "backgroundColor"),
|
|
56
149
|
};
|
|
57
|
-
|
|
58
|
-
this.controller.runTimeResolution.disabled = true;
|
|
59
|
-
return gui;
|
|
60
|
-
};
|
|
61
|
-
PlayerController.prototype.addEventListener = function () {
|
|
62
|
-
var _this = this;
|
|
63
|
-
this.controller.autoFps.onChange(function (value) {
|
|
64
|
-
_this.data.autoFPS = value;
|
|
65
|
-
_this.player.updateConfig(_this.data);
|
|
66
|
-
});
|
|
67
|
-
this.controller.maxFPS.onChange(function (value) {
|
|
68
|
-
_this.data.maxFPS = value;
|
|
69
|
-
_this.player.updateConfig(_this.data);
|
|
70
|
-
});
|
|
71
|
-
this.controller.minFPS.onChange(function (value) {
|
|
72
|
-
_this.data.minFPS = value;
|
|
73
|
-
_this.player.updateConfig(_this.data);
|
|
74
|
-
});
|
|
75
|
-
this.controller.autoResolution.onChange(function (value) {
|
|
76
|
-
_this.data.autoResolution = value;
|
|
77
|
-
_this.player.updateConfig(_this.data);
|
|
78
|
-
});
|
|
79
|
-
this.controller.resolution.onChange(function (value) {
|
|
80
|
-
_this.data.resolution = value;
|
|
81
|
-
_this.player.updateConfig(_this.data);
|
|
82
|
-
});
|
|
83
|
-
this.controller.transactionBgColor.onChange(function (value) {
|
|
84
|
-
_this.data.transactionBgColor = value;
|
|
85
|
-
_this.player.updateConfig(_this.data);
|
|
86
|
-
});
|
|
87
|
-
var md5Value;
|
|
88
|
-
this.controller.moreCalculation.onChange(function (value) {
|
|
89
|
-
var calc = function () {
|
|
90
|
-
var str = "";
|
|
91
|
-
while (str.length < value * 8000) {
|
|
92
|
-
str += Math.random().toString(32).substr(2);
|
|
93
|
-
}
|
|
94
|
-
md5(str);
|
|
95
|
-
};
|
|
96
|
-
if (md5Value) {
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
_this.player.app.ticker.remove(md5Value);
|
|
99
|
-
}
|
|
100
|
-
if (value > 0) {
|
|
101
|
-
md5Value = calc;
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
_this.player.app.ticker.add(md5Value);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
150
|
+
return [gui, controller];
|
|
106
151
|
};
|
|
107
152
|
PlayerController.prototype.destroy = function () {
|
|
108
153
|
try {
|
|
109
154
|
window.clearInterval(this.stateId);
|
|
110
|
-
this.
|
|
155
|
+
this.anchor.removeChild(this.gui.domElement);
|
|
111
156
|
this.gui.destroy();
|
|
112
157
|
}
|
|
113
158
|
catch (_a) {
|
|
@@ -95,7 +95,7 @@ var RenderingTaskManager = /** @class */ (function () {
|
|
|
95
95
|
_this.tasks.splice(selfIndex, 1);
|
|
96
96
|
_this.replaceIdleTask();
|
|
97
97
|
}
|
|
98
|
-
_this.eventHub.emit("task-end-"
|
|
98
|
+
_this.eventHub.emit("task-end-".concat(task.id));
|
|
99
99
|
});
|
|
100
100
|
this.eventHub.on("task-error", function (_a) {
|
|
101
101
|
var task = _a.task;
|
package/lib/Slide.d.ts
CHANGED