【发布时间】:2021-03-24 19:36:43
【问题描述】:
我看到here 提到了这个问题,但是这个解决方案(e.touches[0].pageX 和 e.touches[0].pageY(而不是 e.clientX 和 e.clientY)不起作用)对我来说。
如果你触摸热点大约 10 次,并且幸运地击中了魔法点,或者有时你随机击中附近的某个地方,热点就会被选中,否则什么也不会。
我的代码:
mouse.x = ( event.touches[0].pageX / window.innerWidth ) ;
mouse.y = - ( event.touches[0].pageX / window.innerHeight );
// This is the mouse clicks that do work
//mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
//mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
var vector = new THREE.Vector3( mouse.x, mouse.y, 1 );
projector.unprojectVector( vector, camera );
var ray = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );
var intersects = ray.intersectObjects( targetList, true );
if ( intersects.length > 0)
hotspotClick(intersects[ 0 ].object);
编辑
我在这方面取得了一些进展
mouse.x = ( event.touches[0].pageX / window.innerWidth ) * 0.1;
mouse.y = ( event.touches[0].pageY / window.innerHeight ) * 0.1;
但是,它似乎要么单击网格附近的任意位置将其激活,要么您必须按下网格中间某处的某个位置。所以我假设乘数出来了。
X 似乎没问题,Y 似乎是问题所在。
有人可以帮忙吗?
【问题讨论】: