How do I put limits on OrbitControl?

前端 未结 3 1138
攒了一身酷
攒了一身酷 2020-12-24 06:24

Is there a way to put limits on the OrbitControls.js? Imagine I\'m creating something above the ground, I wouldn\'t like the camera to go below the ground, know

3条回答
  •  猫巷女王i
    2020-12-24 06:58

    If you want more control over Orbit:

        const controls = new OrbitControls(camera, this.renderer.domElement);
        controls.enableDamping = true;   //damping 
        controls.dampingFactor = 0.25;   //damping inertia
        controls.enableZoom = true;      //Zooming
        controls.autoRotate = true;       // enable rotation
        controls.maxPolarAngle = Math.PI / 2; // Limit angle of visibility
        controls.keys = {
          LEFT: 37, //left arrow
          UP: 38, // up arrow
          RIGHT: 39, // right arrow
          BOTTOM: 40 // down arrow
        };
    
       controls.addEventListener("change", () => {
          if (this.renderer) this.renderer.render(this.scene, camera);
        });
    

提交回复
热议问题