用于360图像的A帧用户滑动效果 [英] A-Frame user swipe effect for 360 Image

查看:61
本文介绍了用于360图像的A帧用户滑动效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用aframe.io库获得了360度图像。我想看看如何创建投掷效果。 [不确定效果如何]当用户向左或向右滑动时,这360个图像将旋转/旋转到任一方向,并最终在一段时间后完成(可能取决于滑动的程度?)。

I have a 360 Image using aframe.io library. And I would like to see how to create a "throw" effect. [Not sure what the effect calls] When user swipe left or right, the 360 images will rotate/spin to either direction and eventually finish after sometime (perhaps depends on how hard the swipe is?).

我正在考虑在天空中进行动画,可以达到目的,但是我想问一个人,这是否是正确的方法。

I am thinking of having a a-animation within a a-sky can do the trick, but I would like to ask someone whether this is the right approach.

效果类似于
http://photo-sphere-viewer.js.org/

谢谢。

<a-sky id="vr-sky">
          <a-animation attribute="rotation"></a-animation>
        </a-sky>
        
        
<!-- Or use animation component -->
 <a-sky id="vr-sky"
          animation__rotation="property: rotation; dur: 2000; easing: easeInOut; to: 0 360 0">         
        </a-sky>

推荐答案

一种方法是使用 super-hands 处理抛掷和 aframe-physics-system 来处理旋转和减速(在 aframe-physics-extras

One way to do this is using super-hands to handle the swipe-to-throw and aframe-physics-system to handle the spinning and deceleration (with a little help from aframe-physics-extras)

实时演示

<!DOCTYPE html>
<html>
 <head>
  <title>Swipe to spin photosphere</title>
  <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
  <script src="//cdn.rawgit.com/donmccurdy/aframe-physics-system/v2.1.0/dist/aframe-physics-system.min.js"></script>
  <script src="https://unpkg.com/super-hands/dist/super-hands.min.js"></script>
  <script src="https://unpkg.com/aframe-physics-extras/dist/aframe-physics-extras.min.js"></script>
</head>

<body>
  <a-scene physics="gravity: 0">
    <a-assets>
      <a-mixin id="static" static-body="shape: sphere; sphereRadius: 0.2"></a-mixin>
      <!-- the z position of the grabber determines the leverage/force for swipes -->
      <a-mixin id="grabber" physics-collider position="0 0 -25"
               collision-filter="collisionForces: false"
               super-hands="colliderEvent: collisions;
                            colliderEventProperty: els;
                            colliderEndEvent: collisions;
                            colliderEndEventProperty: clearedEls">
      </a-mixin>
      <img id="pano" src="https://your image url here" crossorigin="anonymous"/>
      <video id="video360" src="https://your video url here" crossorigin="anonymous"/>
    </a-assets>
    <!-- progressive-controls sets up mouse/touch input -->
    <a-entity progressive-controls="maxLevel: gaze; gazeMixin: grabber"></a-entity>
    <a-entity id="bottom" mixin="static" position="0 -100 0"></a-entity>
    <a-entity id="top" mixin="static" position="0 100 0"></a-entity>
    <!-- use an entity with a sphere because a-sky seems to have its rotation locked down -->
    <!-- angularDamping sets the deceleration rate and the constraints limit rotation to Y axis -->
    <!-- src can be #pano or #video360 -->
    <a-entity id="sky" geometry="primitive: sphere; radius: 100" material="src: #pano; side:front" grabbable 
              scale="-1 1 1"
              dynamic-body="angularDamping: 0.5"
              constraint__1="type: pointToPoint; target: #bottom; collideConnected: false; pivot: 0 -100 0"
              constraint__2="type: pointToPoint; target: #top; collideConnected: false; pivot: 0 100 0">
    </a-entity>
  </a-scene>
</body>
</html>

这篇关于用于360图像的A帧用户滑动效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆