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的更多相关文章

  1. three.js 3d三维网页代码加密的实现方法

    http://www.jiamisoft.com/blog/17827-three-js-3dsanweiwangyejiami.html https://www.html5tricks.com/ta ...

  2. 排名前10的H5、Js 3D游戏引擎和框架

    由于很多人都在用JavaScript.HTML5和WebGL技术创建基于浏览器的3D游戏,所有JavaScript 3D游戏引擎是一个人们主题.基于浏览器的游戏最棒的地方是平台独立,它们能在iOS.A ...

  3. Make3D Convert your image into 3d model

    Compiling and Running Make3D on your own computer source: http://make3d.cs.cornell.edu/code_linux.ht ...

  4. 3d模型 手办制作 3d model manual production

    3d模型 手办制作 3d model manual production 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:313134555@qq.com E-mail: 313 ...

  5. QT Graphics-View 3D编程例子- 3D Model Viewer

    学习在Graphics-View框架中使用opengl进行3D编程,在网上找了一个不错的例子“3D Model Viewer”,很值得学习. 可以在http://www.oyonale.com/acc ...

  6. Backbone.js之model篇(一)

    Backbone.js之model篇(一) Backbone 是一个前端 JS 代码 MVC 框架,它不可取代 Jquery,不可取代现有的 template 库.而是和这些结合起来构建复杂的 web ...

  7. WPF 3D model - Sphere, Cone, and Cylinder

    原文:WPF 3D model - Sphere, Cone, and Cylinder   Extending Visual3D - Sphere, Cone, and Cylinder http: ...

  8. ShapeNet: An Information-Rich 3D Model Repository 阅读笔记

    ShapeNet: An Information-Rich 3D Model Repository 注:本论文只是讲述数据库建立方法 摘要 ShapeNet是一个有丰富注释的大型形状存储库,由对象的3 ...

  9. AlloyTouch与three.js 3D模型交互

    如你所见,上面的cube的旋转.加速.减速停止都是通过AlloyTouch去实现的. 演示 代码 <script src="asset/three.js"></s ...

随机推荐

  1. 从myeclipse导入eclipse,不能识别为web项目(java项目转为web项目)

    1.进入项目目录,找到.project文件,打开. 2.找到<natures>...</natures>代码段. 3.在第2步的代码段中加入如下标签内容并保存:         ...

  2. Vue.js——60分钟组件快速入门(下篇)

    概述 上一篇我们重点介绍了组件的创建.注册和使用,熟练这几个步骤将有助于深入组件的开发.另外,在子组件中定义props,可以让父组件的数据传递下来,这就好比子组件告诉父组件:"嘿,老哥,我开 ...

  3. MyBatis2:config.xml文件

    前言 前一篇文章,讲了MyBatis入门,讲到了MyBatis有两个基本的配置文件,一个用来配置环境信息,一个用来写SQL语句.前者我把它命名为config.xml,config.xml的内容是: & ...

  4. egret调用页面js的方法。

    参考文献: http://bbs.egret-labs.org/thread-267-3-1.html http://docs.egret-labs.org/post/manual/threelibs ...

  5. mysql 列名中 包含斜杠或者空格的处理方式

    今天客户那边遇到了一个比较奇葩的问题跑来问我,这个问题比较冷门,所以特别记录下. 问题描述 数据库的字段存在斜杠或者空格的时候,怎么用sql进行insert或者select操作. 问题解答 对于这种特 ...

  6. python学习 异常

    #===========================常见异常 ===================== #print(a);#NameError: name 'a' is not defined ...

  7. Memcached和Redis比较

    一.存储 Memcached基本只支持简单的key-value存储方式.Redis除key-value之外,还支持list,set,sorted set,hash等数据结构:Redis支持数据的备份, ...

  8. JavaScript随笔6

    Ajax:(1) 阻止缓存?+t = new data(); eval可以把string变为数组(2) get:放入URL username = &password = ; 容量有小 安全性差 ...

  9. Chrome调试手机页面

    新开发的网页需要在手机或是模拟机上运行测试,如果手头事件比加紧,那么可以借助 Chrome提供的手机网页预览程序进行简单调试.查看 制作的网页是否能够适合各种手机型号使用. 下面所以下如何使用Chro ...

  10. NodeJs+http+fs+request+cheerio 采集,保存数据,并在网页上展示(构建web服务器)

    目的: 数据采集 写入本地文件备份 构建web服务器 将文件读取到网页中进行展示 目录结构: package.json文件中的内容与上一篇一样:NodeJs+Request+Cheerio 采集数据 ...