mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
修复缩放面板时三视图拉伸bug。
This commit is contained in:
parent
ac42829678
commit
a2da365155
@ -78,22 +78,22 @@ OrthographicCameraControls.prototype.onMouseUp = function (event) {
|
||||
};
|
||||
|
||||
OrthographicCameraControls.prototype.onMouseWheel = function (event) {
|
||||
const delta = event.wheelDelta / 1000;
|
||||
const delta = -event.wheelDelta / 1000;
|
||||
|
||||
let camera = this.camera;
|
||||
|
||||
let width = this.domElement.clientWidth;
|
||||
let height = this.domElement.clientHeight;
|
||||
|
||||
let pointerX = this.camera.left + (this.camera.right - this.camera.left) * event.offsetX / width;
|
||||
let pointerY = this.camera.top - (this.camera.top - this.camera.bottom) * event.offsetY / height;
|
||||
let pointerX = camera.left + (camera.right - camera.left) * event.offsetX / width;
|
||||
let pointerY = camera.top - (camera.top - camera.bottom) * event.offsetY / height;
|
||||
|
||||
this.camera.left = this.camera.left - Math.abs(pointerX - this.camera.left) * delta;
|
||||
this.camera.right = this.camera.right + Math.abs(this.camera.right - pointerX) * delta;
|
||||
this.camera.top = this.camera.top + Math.abs(this.camera.top - pointerY) * delta;
|
||||
this.camera.bottom = this.camera.bottom - Math.abs(pointerY - this.camera.bottom) * delta;
|
||||
camera.left = camera.left - Math.abs(pointerX - camera.left) * delta;
|
||||
camera.right = camera.right + Math.abs(camera.right - pointerX) * delta;
|
||||
camera.top = camera.top + Math.abs(camera.top - pointerY) * delta;
|
||||
camera.bottom = camera.bottom - Math.abs(pointerY - camera.bottom) * delta;
|
||||
|
||||
this.camera.updateProjectionMatrix();
|
||||
camera.updateProjectionMatrix();
|
||||
};
|
||||
|
||||
export default OrthographicCameraControls;
|
||||
@ -21,20 +21,43 @@ ResizeEvent.prototype.stop = function () {
|
||||
};
|
||||
|
||||
ResizeEvent.prototype.onResize = function () {
|
||||
var editor = app.editor;
|
||||
var viewport = app.viewport;
|
||||
var camera = editor.camera;
|
||||
var renderer = editor.renderer;
|
||||
let { editor, viewport } = app;
|
||||
let { DEFAULT_CAMERA, camera, orthCamera, renderer } = editor;
|
||||
|
||||
var width = viewport.clientWidth;
|
||||
var height = viewport.clientHeight;
|
||||
const width = viewport.clientWidth;
|
||||
const height = viewport.clientHeight;
|
||||
|
||||
editor.DEFAULT_CAMERA.aspect = width / height;
|
||||
editor.DEFAULT_CAMERA.updateProjectionMatrix();
|
||||
if (this.width === undefined || this.height === undefined) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
DEFAULT_CAMERA.aspect = width / height;
|
||||
DEFAULT_CAMERA.updateProjectionMatrix();
|
||||
|
||||
camera.aspect = width / height;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
if (width !== this.width) {
|
||||
let dwidth = (orthCamera.right - orthCamera.left) * (width / this.width - 1);
|
||||
|
||||
orthCamera.left -= dwidth / 2;
|
||||
orthCamera.right += dwidth / 2;
|
||||
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
if (height !== this.height) {
|
||||
let dheight = (orthCamera.top - orthCamera.bottom) * (height / this.height - 1);
|
||||
|
||||
orthCamera.top += dheight / 2;
|
||||
orthCamera.bottom -= dheight / 2;
|
||||
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
orthCamera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
};
|
||||
|
||||
|
||||
@ -43,6 +43,8 @@ ViewEvent.prototype.changeView = function (view) {
|
||||
|
||||
let camera = app.editor.orthCamera;
|
||||
|
||||
// TODO: 根据场景大小确定初始位置
|
||||
|
||||
switch (view) {
|
||||
case 'front':
|
||||
camera.position.set(100, 0, 0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user