Cesium.js禁止三维球鼠标旋转、缩放、鼠标中键拖动
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cesium.js禁止三维球鼠标旋转、缩放、鼠标中键拖动相关的知识,希望对你有一定的参考价值。
参考技术A // 如果为真,则允许用户旋转相机。如果为假,相机将锁定到当前标题。此标志仅适用于2D和3D。(可以理解为禁用鼠标左键旋转地球)scene.screenSpaceCameraController.enableRotate = false;
// 如果为真,允许用户放大和缩小。如果为假,相机将锁定到距离椭圆体的当前距离
scene.screenSpaceCameraController.enableZoom = false;(可以理解为禁用鼠标右键缩放地球)
// 如果为真,则允许用户倾斜相机。如果为假,相机将锁定到当前标题。这个标志只适用于3D和哥伦布视图。(可以理解为禁用鼠标中键拖动地球)
scene.screenSpaceCameraController.enableTilt = false
unity3d中点击一个按钮实现相机之间的转换,点选已添加物体,并使用键盘实现移动鼠标实现旋转缩放操作
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class build : MonoBehaviour {
public GameObject camera_main;
public GameObject camera_front;
public int cameraflag;
public Vector3 pos;
public GameObject Abuild;
public Dropdown drp;
public float x, y;
public float speed= 10.0f;
void Start()
{
camera_main = GameObject.Find("Camera");
camera_front = GameObject.Find("Camera_front");
camera_front.SetActive(false);
cameraflag = 1;
}
void Update () {
//按住鼠标左键旋转模型
if (Input.GetMouseButton(0)&&Abuild!=null)
{
//鼠标按着左键移动
y = Input.GetAxis("Mouse X") * Time.deltaTime * speed;
x = Input.GetAxis("Mouse Y") * Time.deltaTime * speed;
Abuild.transform.Rotate(new Vector3(x, y, 0));
}
//键盘上下左右键实现模型的移动
if (Input.GetAxis("Horizontal") != 0 && Abuild != null)
{
Abuild.transform.Translate(Input.GetAxis("Horizontal") * 3, 0, 0);
}
if (Input.GetAxis("Vertical") != 0 && Abuild != null)
{
Abuild.transform.Translate(0, 0,Input.GetAxis("Vertical") * 3);
}
//鼠标滑轮实现模型的放缩
if (Input.GetAxis("Mouse ScrollWheel") != 0)
{
Abuild.transform.localScale += new Vector3(Input.GetAxis("Mouse ScrollWheel"), Input.GetAxis("Mouse ScrollWheel"), Input.GetAxis("Mouse ScrollWheel"));
}
if (Input.GetMouseButtonDown(1) && cameraflag > 0)
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
pos = hit.point;
if (hit.transform.gameObject.name == "Plane")
pick = GameObject.Instantiate(Resources.Load("选中"), pos, transform.rotation) as GameObject;
else
{
Debug.Log("已选中物体!");
Abuild = hit.transform.gameObject;
}
}
}
//实现相机之间转换的函数
public void changecamera()
{
cameraflag = -cameraflag;
if (cameraflag > 0)
{
camera_main.SetActive(true);
camera_front.SetActive(false);
}
else
{
camera_main.SetActive(false);
camera_front.SetActive(true);
Abuild = null;
}
}
}
以上是关于Cesium.js禁止三维球鼠标旋转、缩放、鼠标中键拖动的主要内容,如果未能解决你的问题,请参考以下文章
openGL三维网格坐标,旋转,缩放,灯光设置,纹理读取,模型读取(MFC单文档)