简体   繁体   English

介绍视频后插入A帧和a场景

[英]Inject A-Frame and a-scene after intro video

I am using the a-frame 360 gallery as a starting point for a personal project. 我正在使用a-frame 360​​画廊作为个人项目的起点。

My scene has a total of 35 360º images. 我的场景共有35张360º图像。 I have also included an mp4 video that plays onload. 我还提供了一个播放onload的mp4视频。

The problem is I don't really need a-frame or any image, I only do when the video has finished playing. 问题是我真的不需要帧或任何图像,仅在视频播放完后才需要。 As I have read here I would love to Inject aframe scripts and the scene once the video has finished playing. 正如我在这里阅读的那样我希望在视频播放完毕后注入框架脚本和场景。

I have tried using timeout in a-assets and lazy-asset-loading, without any luck. 我尝试过在a-资产和惰性资产加载中使用超时,但是没有任何运气。

How can I do this? 我怎样才能做到这一点?

Thanks! 谢谢!

Without the use of a framework such as Angular, VueJs or (Aframe)React where you can load components (scenes) dynamically, 'injecting' a scene is not entirely impossible. 如果不使用诸如Angular,VueJs或(Aframe)React之类的框架,您可以在其中动态地加载组件(场景),则“注入”场景并不是完全不可能的。

An approach to 'load' scenes dynamically without a framework could be to wrap your scene elements in an a-entity element and set it's visability attribute to false. 在没有框架的情况下动态“加载”场景的一种方法可能是将场景元素包装在a-entity元素中并将其visibility属性设置为false。

eg: 例如:

<video #videoEl src="..."></video>
<a-scene>
  <a-entity #sceneEntity visible="false">
    <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
    <a-box position="-1 0.5 -3" rotation="0 45 0" width="1" height="1" depth="1" color="#4CC3D9"></a-box>
    <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
    <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
    <a-sky color="#ECECEC"></a-sky>
  </a-entity>
</a-scene>

<script>
  const videoEl = document.getElementById('videoEl');
  videoEl.onended = e => {
    document.getElementById('sceneEntity').setAttribute('visible', true);
  }
</script>

Another approach is to append an entire scene as string to the DOM when the video element has finished. 另一种方法是在视频元素完成后将整个场景作为字符串附加到DOM。 Which is what the mentioned frameworks can provide in a sophisticated manner. 所提到的框架可以以复杂的方式提供这些内容。

Something I would suggest is to also pause the scene ( document.getElementsByTagNames('a-scene')[0].pause() ) while the video is playing. 我建议的是在播放视频时也暂停场景( document.getElementsByTagNames('a-scene')[0].pause() )。 At the moment I am not aware if setting an entity's visibility property to false will pause it's lifecycle. 目前,我不知道是否将实体的可视性属性设置为false会暂停其生命周期。

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

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