与早期版本(0.8.0)相比,最新的A-Frame稳定版本(0.9.0)无法通过360ImageGallery。

时间:2019-03-10 19:41:33

标签: build aframe

在0.9.0贬值列表中找不到任何内容,也许我错过了。当使用https://aframe.io/releases/0.8.0/aframe.min.js时,360ImageGallery可以工作,但是当使用https://aframe.io/releases/0.9.0/aframe.min.js时,立方体,城市和塞舌尔缩略图平面会合拢为一个(它们相互重叠,因此无法选择)。有什么想法吗?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>360° Image Browser</title>
<meta name="description" content="360&deg; Image Gallery - A-Frame">
<script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
<script src="https://unpkg.com/aframe-template-component@3.x.x/dist/aframe-template-component.min.js"></script>
<script src="https://unpkg.com/aframe-layout-component@3.x.x/dist/aframe-layout-component.min.js"></script>
<script src="https://unpkg.com/aframe-event-set-component@3.x.x/dist/aframe-event-set-component.min.js"></script>
<script src="https://unpkg.com/aframe-layout-component@4.3.1/dist/aframe-layout-component.min.js"></script> 
<script>

AFRAME.registerComponent('set-image', {
  schema: {
    on: {type: 'string'},
    target: {type: 'selector'},
    src: {type: 'string'},
    dur: {type: 'number', default: 300}
  },
init: function () {
  var data = this.data;
  var el = this.el;

  this.setupFadeAnimation();

  el.addEventListener(data.on, function () {
    // Fade out image.
    data.target.emit('set-image-fade');
    // Wait for fade to complete.
    setTimeout(function () {
      // Set image.
      data.target.setAttribute('material', 'src', data.src);
    }, data.dur);
  });  
  },
    setupFadeAnimation: function () {
    // Appends an <a-animation> that fades to black.
  }
});
</script>


</head>
<body>


<a-scene>
  <a-assets>
    <audio id="click-sound" src="https://cdn.aframe.io/360-image-gallery-boilerplate/audio/click.ogg"></audio>

    <!-- Images. -->
    <img id="city" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/city.jpg">
    <img id="city-thumb" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/thumb-city.jpg">
    <img id="cubes" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/cubes.jpg">
    <img id="cubes-thumb" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/thumb-cubes.jpg">
    <img id="sechelt" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/sechelt.jpg">
    <img id="sechelt-thumb" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/thumb-sechelt.jpg">
	
  <script id="link" type="text/html">
    <a-entity class="link1"
      geometry="primitive: plane; height: 1; width: 1"
      material="shader: flat; src: ${thumb}"
      sound="on: click; src: #click-sound"
      event-set__1="_event: mousedown; scale: 1 1 1"
      event-set__2="_event: mouseup; scale: 1.2 1.2 1"
      event-set__3="_event: mouseenter; scale: 1.2 1.2 1"
	  set-image="on: click; target: #image-360; src: ${src}"
      event-set__4="_event: mouseleave; scale: 1 1 1"></a-entity>
  </script>
	
  </a-assets>

  <!-- 360-degree image. -->
  <a-sky id="image-360" radius="10" src="#cubes"></a-sky>
  <!-- Pass image sources to the template. -->
      <a-entity id="links" layout="type: line; margin: 1.5" position="-1.5 1.0 -3">
        <a-entity template="src: #link" data-src="#cubes" data-thumb="#cubes-thumb"></a-entity>
        <a-entity template="src: #link" data-src="#city" data-thumb="#city-thumb"></a-entity>
        <a-entity template="src: #link" data-src="#sechelt" data-thumb="#sechelt-thumb"></a-entity>
      </a-entity>

  <!-- Camera + Cursor. -->
  <a-camera>
    <a-cursor id="cursor">
      <a-animation begin="click" easing="ease-in" attribute="scale"
                   fill="backwards" from="0.1 0.1 0.1" to="1 1 1" dur="150"></a-animation>
      <a-animation begin="cursor-fusing" easing="ease-in" attribute="scale"
                   from="1 1 1" to="0.1 0.1 0.1" dur="1500"></a-animation>
    </a-cursor>
  </a-camera>
</a-scene>
</body>
</html>

0 个答案:

没有答案