mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
全屏播放功能。
This commit is contained in:
parent
20f52c3090
commit
65bbd03a66
@ -26,7 +26,7 @@ PlayMenu.prototype.render = function () {
|
||||
cls: 'title',
|
||||
html: L_PLAY,
|
||||
onClick: this.onTogglePlay.bind(this),
|
||||
}, , {
|
||||
}, {
|
||||
xtype: 'div',
|
||||
cls: 'options',
|
||||
children: [{
|
||||
@ -36,14 +36,12 @@ PlayMenu.prototype.render = function () {
|
||||
cls: 'option',
|
||||
html: '播放',
|
||||
onClick: this.onTogglePlay.bind(this),
|
||||
},
|
||||
// {
|
||||
// xtype: 'div',
|
||||
// cls: 'option',
|
||||
// html: '全屏播放',
|
||||
// onClick: this.playFullscreen.bind(this),
|
||||
// },
|
||||
{
|
||||
}, {
|
||||
xtype: 'div',
|
||||
cls: 'option',
|
||||
html: '全屏播放',
|
||||
onClick: this.playFullscreen.bind(this),
|
||||
}, {
|
||||
xtype: 'div',
|
||||
cls: 'option',
|
||||
html: '新窗口播放',
|
||||
@ -95,11 +93,24 @@ PlayMenu.prototype.stopPlay = function () { // 停止播放
|
||||
this.app.player.stop();
|
||||
};
|
||||
|
||||
// PlayMenu.prototype.playFullscreen = function () { // 全屏播放
|
||||
// var dom = this.app.editor.renderer.domElement;
|
||||
// dom.requestFullscreen();
|
||||
// this.startPlayer();
|
||||
// };
|
||||
PlayMenu.prototype.playFullscreen = function () { // 全屏播放
|
||||
if (!this.isPlaying) {
|
||||
this.startPlay();
|
||||
}
|
||||
|
||||
this.app.player.on(`init.${this.id}`, this._requestFullscreen.bind(this));
|
||||
};
|
||||
|
||||
PlayMenu.prototype._requestFullscreen = function () {
|
||||
var dom = this.app.player.renderer.domElement;
|
||||
dom.addEventListener('fullscreenchange', this._onFullscreenChange.bind(this));
|
||||
dom.requestFullscreen();
|
||||
};
|
||||
|
||||
PlayMenu.prototype._onFullscreenChange = function () {
|
||||
debugger
|
||||
this.app.player.resize();
|
||||
};
|
||||
|
||||
PlayMenu.prototype.playNewWindow = function () { // 新窗口播放
|
||||
UI.msg('新窗口播放!');
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { dispatch } from '../third_party';
|
||||
import UI from '../ui/UI';
|
||||
import Converter from '../serialization/Converter';
|
||||
|
||||
@ -18,6 +19,12 @@ function Player(options) {
|
||||
UI.Control.call(this, options);
|
||||
this.app = options.app;
|
||||
|
||||
this.dispatch = new dispatch([
|
||||
'init'
|
||||
]);
|
||||
this.call = this.dispatch.call.bind(this.dispatch);
|
||||
this.on = this.dispatch.on.bind(this.dispatch);
|
||||
|
||||
this.scene = null;
|
||||
this.camera = null;
|
||||
this.renderer = null;
|
||||
@ -88,6 +95,8 @@ Player.prototype.start = function () {
|
||||
this.loader.create(jsons).then(obj => {
|
||||
this.initPlayer(obj);
|
||||
|
||||
this.dispatch.call('init', this);
|
||||
|
||||
var promise1 = this.event.create(this.scene, this.camera, this.renderer, obj.scripts);
|
||||
var promise2 = this.control.create(this.scene, this.camera, this.renderer);
|
||||
var promise3 = this.audio.create(this.scene, this.camera, this.renderer);
|
||||
@ -184,4 +193,21 @@ Player.prototype.animate = function () {
|
||||
requestAnimationFrame(this.animate.bind(this));
|
||||
};
|
||||
|
||||
Player.prototype.resize = function () {
|
||||
if (!this.camera || !this.renderer) {
|
||||
return;
|
||||
}
|
||||
|
||||
var camera = this.camera;
|
||||
var renderer = this.renderer;
|
||||
|
||||
var width = renderer.domElement.clientWidth;
|
||||
var height = renderer.domElement.clientHeight;
|
||||
|
||||
camera.aspect = width / height;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
};
|
||||
|
||||
export default Player;
|
||||
Loading…
x
Reference in New Issue
Block a user