网址:https://github.com/anvaka/three.map.control

在threejs群里发现的一个很有意思的问题之前没有接触过:

存在的问题:

 我在微信小游戏中,用orbit也会出现计算错误的情况,动一下就不见了。 
解决办法

 发现了, 原来是小游戏里面获取不到 element.clientWidth, 要替换成 window.innerWidth 

three.map.control

Mobile friendly three.js camera that mimics 2d maps navigation with pan and zoom.

DEMO

Features

  • Touch friendly. Drag scene around with single finger touch, or zoom it with standard pinch gesture.

  • Zoom into point. Use your mouse wheel to zoom into particular point on the scene.
  • Easing. When you pan around, the movement does not stop immediately. Smooth kinetic panning gives natural feel to it.

  • Tiny. It's less than 400 lines of documented code.

usage

// let's say you have a standard THREE.js PerspectiveCamera:
var camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 3000 ); // To turn on a map-like navigation:
var createPanZoom = require('three.map.control'); // We assume that three.js scene is hosted inside DOM element `container`
var panZoom = createPanZoom(camera, container); // That's it. panZoom wil now listen to events from `container`. You can pan and
// zoom with your mouse or fingers (on touch device) // If you want to dispose three.js scene, make sure to call:
panZoom.dispose();

events

// the panZoom api fires events when something happens,
// so that you can react to user actions:
panZoom.on('panstart', function() {
// fired when users begins panning (dragging) the surface
console.log('panstart fired');
}); panZoom.on('panend', function() {
// fired when user stpos panning (dragging) the surface
console.log('panend fired');
}); panZoom.on('beforepan', function(panPayload) {
// fired when camera position will be changed.
console.log('going to move camera.position.x by: ' + panPayload.dx);
console.log('going to move camera.position.y by: ' + panPayload.dy);
}); panZoom.on('beforezoom', function(panPayload) {
// fired when befor zoom in/zoom out
console.log('going to move camera.position.x by: ' + panPayload.dx);
console.log('going to move camera.position.y by: ' + panPayload.dy);
console.log('going to move camera.position.z by: ' + panPayload.dz);
});

license

MIT

three.map.control的更多相关文章

  1. Bing Map

    To use map services in Windows 10 packages for this application, you need to acquire a token from th ...

  2. DevExpress WPF v19.1新版亮点:Gantt/Map控件新功能

    行业领先的.NET界面控件DevExpress 日前正式发布v19.1版本,本站将以连载的形式介绍各版本新增内容.在本系列文章中将为大家介绍DevExpress WPFv19.1中新增的一些控件及部分 ...

  3. ArcGIS Engine开发之鹰眼视图

    鹰眼是GIS软件的必备功能之一.它是一个MapControl控件,主要用来表示数据视图中的地理范围在全图中的位置. 鹰眼一般具有的功能: 1)鹰眼视图与数据视图的地理范围保持同步. 2)数据视图的当前 ...

  4. 课程上线 -“新手入门 : Windows Phone 8.1 开发”

    经过近1个月的准备和录制,“新手入门 : Windows Phone 8.1 开发”系列课程已经在Microsoft 虚拟学院上线,链接地址为:http://www.microsoftvirtuala ...

  5. 开源倾情奉献:基于.NET打造IP智能网络视频监控系统(一)开放源代码

    本文为 Dennis Gao 原创技术文章,发表于博客园博客,未经作者本人允许禁止任何形式的转载. 开源倾情奉献系列链接 开源倾情奉献:基于.NET打造IP智能网络视频监控系统(一)开放源代码 开源倾 ...

  6. UWP深入学习五: 传感器与搜索、共享及链接

    Responding to motion and orientation sensors: Quickstart: Responding to user movement with the accel ...

  7. javascript: jquery.gomap-1.3.3.js

    from:http://www.pittss.lv/jquery/gomap/solutions.php jquery.gomap-1.3.3.js: /** * jQuery goMap * * @ ...

  8. Google地图接口API之Google地图 API 参考手册(七)

    Google 地图API 参考手册 地图 构造函数/对象 描述 Map() 在指定的 HTML 容器中创建新的地图,该容器通常是一个DIV元素. 叠加层 构造函数/对象 描述 Marker 创建一个标 ...

  9. Google地图接口API之地图控件集(五)

    1.默认控件集 当使用一个标准的google地图,它的控件默认设置如下: (1). Zoom-显示一个滑动条来控制map的Zoom级别,如下所示:

随机推荐

  1. 自定义标签在IE6-8的困境

    或许未来前端组件化之路都是自定义标签,但这东西早在20年前,JSTL已在搞了.现在Web Component还只有webkit支持.但一个组件库,还需要一个特殊的标识它们是一块的.不过这个XML已经帮 ...

  2. LeetCode OJ 93. Restore IP Addresses

    题目 Given a string containing only digits, restore it by returning all possible valid IP address comb ...

  3. LeetCode OJ 79. Word Search

    题目 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed fro ...

  4. week06 08 postman 测试jsonrpc

    用postman来测试rpc需要添加特别的字段 ’ { "jsonrpc":"2.0", "id":"123", &qu ...

  5. IIS 7配置需要注意的地方,RTX SDK运行必须Enable 32-bit Applications为True

    简单说一下IIS 7的配置里那些需要注意的 首先每个网站都必须运行在特定得程序池上,程序池的配置中,关键的几个如下图: 1. .Net Framework Version : 这个设置的是你项目用到的 ...

  6. 解决:python 连接Oracle 11g 报错:ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务

    其次,将查询到的service_name替换sid即可:conn=cx_Oracle.connect('hr/admin@localhost:1521/EE.oracle.docker')

  7. 学JS的心路历程-JS支持面向对象?(二)

    昨天讲了面向对象的继承,今天我们来谈谈多态和封装吧! 多态polymorphism 抽象讲法解释,就是使用单一界面操作多种型态的物件 继承父类别,定义与父类别中相同的方法,但实作内容不同,称为复写(o ...

  8. Oracle SCN机制解析

    SCN(System Chang Number)作为oracle中的一个重要机制,在数据恢复.Data Guard.Streams复制.RAC节点间的同步等各个功能中起着重要作用.理解SCN的运作机制 ...

  9. openssl数字证书常见格式 协议

    证书主要的文件类型和协议有: PEM.DER.PFX.JKS.KDB.CER.KEY.CSR.CRT.CRL .OCSP.SCEP等. PEM – Openssl使用 PEM(Privacy Enha ...

  10. 【翻译】 View Frustum Culling --1 View Frustum’s Shape

    这是一些列来自lighthouse3d的视锥体裁剪教程.旨在学习总结,及便于查阅. 1.视锥体的形状 在OpenGL中,透视投影是由两个函数定义的gluPerspective和gluLookAt.我们 ...