Using AlloyTouch to control three.js 3D model

As you can see, the above cube rotation, acceleration, deceleration stop all through the AlloyTouch to achieve.
Demo(Mobile)

Code
<script src="asset/three.js"></script>
<script src="../../alloy_touch.js"></script>
<script>
var camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.z = 500;
var scene = new THREE.Scene();
var texture = new THREE.TextureLoader().load( 'asset/crate.gif' );
var geometry = new THREE.BoxBufferGeometry( 200, 200, 200 );
var material = new THREE.MeshBasicMaterial( { map: texture } );
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
var renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
animate();
new AlloyTouch({
touch: document, //touch the whole document
vertical: false, //monitor horizontal touch
target: mesh.rotation, //animate mesh.rotation's y property
property: "y",
factor: 0.08, //friction coefficient
moveFactor: 0.2 //touch move friction coefficient
})
</script>
factor need to continue to debug the best value for the speed and time of inertial motion let go after the best effect.
moveFactor need to continue to debug the best value, is to let the lateral drag distance map to achieve the rotation angle.
If you don't need an inertial motion. For example, the king of glory in the task rotation is not inertia, the finger left the screen will immediately stop moving. Such as:

You only need to set the AlloyTouch inertia to false.
Non inertia demo

Code
<script src="asset/three.js"></script>
<script src="../../alloy_touch.js"></script>
<script>
...
...
...
animate();
new AlloyTouch({
touch: document,
vertical: false,
target: mesh.rotation,
property: "y",
factor: 0.08,
moveFactor: 0.2 ,
inertia: false //disable the inertia animation
})
</script>
AlloyTouch
Github:https://github.com/AlloyTeam/AlloyTouch
Any question, please let me know:https://github.com/AlloyTeam/AlloyTouch/issues
Using AlloyTouch to control three.js 3D model的更多相关文章
- three.js 3d三维网页代码加密的实现方法
http://www.jiamisoft.com/blog/17827-three-js-3dsanweiwangyejiami.html https://www.html5tricks.com/ta ...
- 排名前10的H5、Js 3D游戏引擎和框架
由于很多人都在用JavaScript.HTML5和WebGL技术创建基于浏览器的3D游戏,所有JavaScript 3D游戏引擎是一个人们主题.基于浏览器的游戏最棒的地方是平台独立,它们能在iOS.A ...
- Make3D Convert your image into 3d model
Compiling and Running Make3D on your own computer source: http://make3d.cs.cornell.edu/code_linux.ht ...
- 3d模型 手办制作 3d model manual production
3d模型 手办制作 3d model manual production 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:313134555@qq.com E-mail: 313 ...
- QT Graphics-View 3D编程例子- 3D Model Viewer
学习在Graphics-View框架中使用opengl进行3D编程,在网上找了一个不错的例子“3D Model Viewer”,很值得学习. 可以在http://www.oyonale.com/acc ...
- Backbone.js之model篇(一)
Backbone.js之model篇(一) Backbone 是一个前端 JS 代码 MVC 框架,它不可取代 Jquery,不可取代现有的 template 库.而是和这些结合起来构建复杂的 web ...
- WPF 3D model - Sphere, Cone, and Cylinder
原文:WPF 3D model - Sphere, Cone, and Cylinder Extending Visual3D - Sphere, Cone, and Cylinder http: ...
- ShapeNet: An Information-Rich 3D Model Repository 阅读笔记
ShapeNet: An Information-Rich 3D Model Repository 注:本论文只是讲述数据库建立方法 摘要 ShapeNet是一个有丰富注释的大型形状存储库,由对象的3 ...
- AlloyTouch与three.js 3D模型交互
如你所见,上面的cube的旋转.加速.减速停止都是通过AlloyTouch去实现的. 演示 代码 <script src="asset/three.js"></s ...
随机推荐
- iOS开发--ChildViewController实现订单页的切换
先不说废话, 上效果图, 代码量也不大, 也不上传github骗星星了, 你们复制粘贴下代码, 就可以轻而易举的弄出一个小demo. 这个代码的实现并不复杂, 甚至于说非常简单, 就是逻辑有点小绕, ...
- JAVA 设计模式之策略模式
定义:定义一组算法,将每个算法都封装起来,并且使他们之间可以互换. 类型:行为类模式 策略模式是对算法的封装,把一系列的算法分别封装到对应的类中,并且这些类实现相同的接口,相互之间可以替换.在前面说过 ...
- 用C++实现Linux中shell的ls功能
实现输出当前目录下的文件名 ls功能: 方法一: #include <iostream> #include <algorithm> #include <stdio.h&g ...
- 为支持ASP.NET5跨平台,Jexus再添新举措
Jexus作为一款运行于Linux/FreeBSD平台上,以支持ASP.NET著称的高性能HTTP服务器和反向代理服务器,继5.6版完成对OWIN标准应用的支持后,就把着力点放到了对ASP.NET5的 ...
- 开源一个WEB版本GEF,基于SVG的网页流程图框架
8月开始断断续续的制作这个web gef,没有任何依赖,完全原生js开发,目前已经完成了雏形,基本上可以在项目里应用了. 下图展示的是demo1的效果,包括拖拽,生成连线,点击生成\取消墙体,整个de ...
- 【腾讯Bugly干货分享】移动客户端中高效使用SQLite
本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57b57f2a0703f7d31b9a3932 作者:赵丰 导语 iOS 程序能 ...
- subline text3 使用总结
安装:http://www.sublimetext.com/3 插件扩展: 安装package control组件 按Ctrl+`调出console(注:安装有QQ输入法的这个快捷键会有冲突的,输入 ...
- Johnson 全源最短路径算法
解决单源最短路径问题(Single Source Shortest Paths Problem)的算法包括: Dijkstra 单源最短路径算法:时间复杂度为 O(E + VlogV),要求权值非负: ...
- Android开发学习之路-动态高斯模糊怎么做
什么是高斯模糊? 高斯模糊(英语:Gaussian Blur),也叫高斯平滑,是在Adobe Photoshop.GIMP以及Paint.NET等图像处理软件中广泛使用的处理效果,通常用它来减少图像噪 ...
- construction const parameter问题 构造函数const引用参数问题
工程在window下编译没有任何问题, 但是在linux(CentOS6)下编译就老是报错 C++ 编译器已升级到最新版 6.1.0 错误如下: In file included /bits/stl_ ...