简体   繁体   English

如何缩放 A 帧 Videosphere

[英]How to zoom A-frame Videosphere

I did not find any way to zoom in to a-videosphere.我没有找到任何放大视频球的方法。 Tried changing the radius but it is just not working.尝试更改半径,但它不起作用。 I want to zoom based on the mouse scroll-wheel action.我想根据鼠标滚轮动作进行缩放。

    <a-scene id="vr-scene" canvas="canvas: #vr-canvas">
    <canvas class="vr-canvas"></canvas>
    <a-assets timeout="500">

        <video id="player" src="" autoplay="true" controls="false" webkit-playsinline ></video>                
    </a-assets>
    <a-videosphere id="video" src="#player" rotation="0 90 0">
    </a-videosphere>

</a-scene>

You can do this by making a custom component that controls the fov (ie zoom) of the camera.您可以通过制作一个自定义组件来控制相机的 fov(即缩放)来做到这一点。

 AFRAME.registerComponent('zoom-controls', {
      schema:{
        min:{type:"number", default: 5},
        max: {type:"number", default: 120}
      },
      init: function(){
          let self = this;
          let sceneEl = document.querySelector("a-scene");          
          self.camera = sceneEl.querySelector("#camera");
        console.log('min: ', self.data.min);
        console.log('max: ', self.data.max);
          window.addEventListener("wheel", event =>{
              let amount = Math.sign(event.deltaY)*5 ;              
              let fov = Number(self.camera.getAttribute('camera').fov);
              let adjust = amount + fov;      
              if(adjust < self.data.min) {adjust = self.data.min;}
              if (adjust > self.data.max) {adjust = self.data.max;}
            console.log('zoom: ', adjust);
              self.camera.setAttribute('camera', 'fov', adjust);
          }); 
      }  
    });

    <a-entity id="camera" camera="active: true" look-controls zoom-controls="min:5; max: 140" fov="100" position="0 0 0"></a-entity>    

glitch here故障在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM