Skip to content

Commit

Permalink
fix(OrbitController): limit zoom speed
Browse files Browse the repository at this point in the history
  • Loading branch information
lslzl3000 committed Jun 27, 2023
1 parent 7ad1581 commit 13608a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Engine3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { ShaderLib } from './assets/shader/ShaderLib';
import { ShaderUtil } from './gfx/graphics/webGpu/shader/util/ShaderUtil';
import { ComponentCollect } from './gfx/renderJob/collect/ComponentCollect';
import { ShadowLightsCollect } from './gfx/renderJob/collect/ShadowLightsCollect';
import { ProfilerUtil } from '.';

/**
* Orillusion 3D Engine
Expand Down Expand Up @@ -289,7 +288,7 @@ export class Engine3D {
* @returns
*/
public static async init(descriptor: { canvasConfig?: CanvasConfig; beforeRender?: Function; renderLoop?: Function; lateRender?: Function, engineSetting?: EngineSetting } = {}) {
console.log('engine version', version);
console.log('Engine Version', version);

this.setting = { ...this.setting, ...descriptor.engineSetting }

Expand Down
3 changes: 2 additions & 1 deletion src/components/controller/OrbitController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export class OrbitController extends ComponentBase {
* @internal
*/
private onWheel(e: PointerEvent3D) {
e.deltaY = clamp(e.deltaY, -this._spherical.radius, this._spherical.radius)
this._spherical.radius += e.deltaY * this.zoomFactor;
this._spherical.radius = clamp(this._spherical.radius, this.minDistance, this.maxDistance);
this.updateCamera();
Expand Down Expand Up @@ -231,7 +232,7 @@ export class OrbitController extends ComponentBase {
this._spherical.phi -= rb * Math.PI / 180;
this._spherical.phi = clamp(this._spherical.phi, this.minPolarAngle, this.maxPolarAngle);
this.updateCamera();
// pan
// pan
} else if (e.mouseCode === 2) {
Vector3Ex.mulScale(this.object3D.transform.up, e.movementY * this.panFactor * this._camera.aspect, Vector3.HELP_1);
this._target.y += Vector3.HELP_1.y;
Expand Down

0 comments on commit 13608a8

Please sign in to comment.