Move the axes to the upper right corner

This commit is contained in:
MrKBear 2022-02-15 22:04:27 +08:00
parent e6023d2ef7
commit 3e92c452f2
2 changed files with 15 additions and 2 deletions

View File

@ -97,7 +97,6 @@ abstract class BasicRenderer<
*/ */
protected resize() { protected resize() {
this.loop(0); this.loop(0);
this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
} }
/** /**

View File

@ -66,8 +66,13 @@ class ClassicRenderer extends BasicRenderer<{}, IClassicRendererParams> {
} }
loop(t: number): void { loop(t: number): void {
// 常规绘制窗口
this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
this.camera.dynamics(t); this.camera.dynamics(t);
// 自动计算最佳雾参数
let dist = this.camera.eyeDist; let dist = this.camera.eyeDist;
if (Math.abs(this.lastScale - dist) > this.camera.EL) { if (Math.abs(this.lastScale - dist) > this.camera.EL) {
this.lastScale = dist; this.lastScale = dist;
@ -79,9 +84,18 @@ class ClassicRenderer extends BasicRenderer<{}, IClassicRendererParams> {
this.cleanCanvas(); this.cleanCanvas();
this.axisObject.draw(this.basicShader);
this.cubeObject.draw(this.basicShader); this.cubeObject.draw(this.basicShader);
this.basicGroup.draw(this.groupShader); this.basicGroup.draw(this.groupShader);
// 右上角绘制坐标轴
const position = 120;
this.gl.viewport(
this.canvas.width - position * this.camera.ratio + (this.camera.ratio - 1) * position / 2,
this.canvas.height - position,
position * this.camera.ratio,
position
);
this.axisObject.draw(this.basicShader);
} }
clean(id?: ObjectID | ObjectID[]): this { clean(id?: ObjectID | ObjectID[]): this {