网址: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. ORACLE表空间操作实例

    本文主要介绍oracle表空间常见的操作实例,包括创建.查询.增加.删除.修改.表空间和数据文件常用的数据字典和动态性能视图包括v$dbfile.v$datafile.v$tempfile.dba_s ...

  2. 将 DNSCrypt 部署到 Openwrt 路由器上+ DNSmasq 解析国内域名用本地 DNS[ZT+实践]

    原文地址: 1.https://typcn.com/legacy/blog/posts/openwrt-dnscypt.html 2.http://www.openwrt.pro/post-376.h ...

  3. hive sql 效率提升

    转 :  http://www.cnblogs.com/xd502djj/p/3799432.html hive的查询注意事项以及优化总结 . Hive是将符合SQL语法的字符串解析生成可以在Hado ...

  4. JS获取任意月份的最后一天

    在获取月份天数的时候,因为月份不同,所以每个月的天数也有差异,并且由于平闰年,2月份天数也有所不同,导致程序中获取任意月份的天数十分复杂,下面就用这个方法解决此问题,调用此方法将任意年份和月份传进去, ...

  5. svn转git

    在Git Bash 中输入 git-svn clone http://devsvnread.uuzuonline.net/GOT_PRIVATE/server/ --no-metadata -T tr ...

  6. 1-keystone 部署

    https://github.com/openstack/keystone 最新版为rocky 1. 进入mysql create database keystone; grant all privi ...

  7. linux 系统 网卡 ethX没有显示IP的处理方式

    1 临时方式 ifconfig  设备名 IP 地址 (ifconfig eth0  192.168.1.117) 设置好之后马上生效,不需要重启网卡服务(千万别重启网卡服务,不然刚刚设置的又没有了) ...

  8. php正则替换双引号里面的字符

  9. TensorFlow常用函数

    [1]卷积层(Convolutional Layer),构建一个2维卷积层,常用的参数有 conv = tf.layers.conv2d( inputs=pool, filters=64, kerne ...

  10. TF-IDF原理及使用

    1.TF-IDF(Term Frequency-Inverse Document Frequency, 词频-逆文件频率).(逆文档词频) 2.自我理解: 公式TF = $$\frac{语料库中关键词 ...