From 7bd2ffd1df8cbf2b6e06bb7f7ec456a04bf9bfc9 Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Fri, 21 Dec 2018 21:26:06 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=80=A7=E8=83=BD=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=BB=8E=E7=BC=96=E8=BE=91=E5=99=A8=E7=A7=BB=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=99=A8=E3=80=82=202=E3=80=81=E6=B3=95?= =?UTF-8?q?=E7=BA=BFsea3d=E5=8A=A0=E8=BD=BD=E6=9C=89bug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.Web/src/editor/Editor.js | 8 -------- ShadowEditor.Web/src/event/AnimateEvent.js | 4 ---- ShadowEditor.Web/src/loader/SEA3DLoader.js | 2 +- ShadowEditor.Web/src/player/Player.js | 18 ++++++++++++++++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ShadowEditor.Web/src/editor/Editor.js b/ShadowEditor.Web/src/editor/Editor.js index a0cdb5be..d122eea7 100644 --- a/ShadowEditor.Web/src/editor/Editor.js +++ b/ShadowEditor.Web/src/editor/Editor.js @@ -83,14 +83,6 @@ function Editor(app) { // 编辑器控件 this.controls = new THREE.EditorControls(this.camera, this.app.viewport.container.dom); - // 性能控件 - this.stats = new Stats(); - this.stats.dom.style.position = 'absolute'; - this.stats.dom.style.left = '8px'; - this.stats.dom.style.top = '8px'; - this.stats.dom.style.zIndex = 'initial'; - this.app.viewport.container.dom.appendChild(this.stats.dom); - // 碰撞检测 this.raycaster = new THREE.Raycaster(); this.mouse = new THREE.Vector2(); diff --git a/ShadowEditor.Web/src/event/AnimateEvent.js b/ShadowEditor.Web/src/event/AnimateEvent.js index e78f4b4b..bbb8b77e 100644 --- a/ShadowEditor.Web/src/event/AnimateEvent.js +++ b/ShadowEditor.Web/src/event/AnimateEvent.js @@ -24,15 +24,11 @@ AnimateEvent.prototype.stop = function () { }; AnimateEvent.prototype.onAnimate = function () { - this.app.editor.stats.begin(); - var deltaTime = this.clock.getDelta(); this.app.call('animate', this, this.clock, deltaTime); this.app.call('render', this); - this.app.editor.stats.end(); - if (this.running) { requestAnimationFrame(this.onAnimate.bind(this)); } diff --git a/ShadowEditor.Web/src/loader/SEA3DLoader.js b/ShadowEditor.Web/src/loader/SEA3DLoader.js index 2b29af2c..c1e56df6 100644 --- a/ShadowEditor.Web/src/loader/SEA3DLoader.js +++ b/ShadowEditor.Web/src/loader/SEA3DLoader.js @@ -15,7 +15,7 @@ SEA3DLoader.prototype.load = function (url, options) { var obj = new THREE.Object3D(); return new Promise(resolve => { - this.require('SEA3D', true).then(() => { + this.require('SEA3D').then(() => { var loader = new THREE.SEA3D({ autoPlay: true, // Auto play animations container: obj, // Container to add models diff --git a/ShadowEditor.Web/src/player/Player.js b/ShadowEditor.Web/src/player/Player.js index d00cde22..f9872258 100644 --- a/ShadowEditor.Web/src/player/Player.js +++ b/ShadowEditor.Web/src/player/Player.js @@ -38,7 +38,7 @@ Player.prototype = Object.create(UI.Control.prototype); Player.prototype.constructor = Player; Player.prototype.render = function () { - (UI.create({ + var control = UI.create({ xtype: 'div', parent: this.parent, id: 'player', @@ -47,7 +47,17 @@ Player.prototype.render = function () { style: { display: 'none' } - })).render(); + }); + + control.render(); + + // 性能控件 + this.stats = new Stats(); + this.stats.dom.style.position = 'absolute'; + this.stats.dom.style.left = '8px'; + this.stats.dom.style.top = '8px'; + this.stats.dom.style.zIndex = 'initial'; + control.dom.appendChild(this.stats.dom); }; /** @@ -156,6 +166,8 @@ Player.prototype.animate = function () { return; } + this.stats.begin(); + var deltaTime = this.clock.getDelta(); this.event.update(this.clock, deltaTime); @@ -164,6 +176,8 @@ Player.prototype.animate = function () { this.animation.update(this.clock, deltaTime); this.physics.update(this.clock, deltaTime); + this.stats.end(); + requestAnimationFrame(this.animate.bind(this)); };