- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 AFRAME 来创建 VR 视频体验。我正在尝试优化视频请求的数量,因为我正在视口(viewport)周围渲染大量视频显示。我没有对 10 个 .webm 视频文件提出独特的请求,而是考虑做一些类似“视频 Sprite ”的事情,将所有 10 个剪辑编辑到一个 .webm 视频文件中。从这里,我将单个视频源加载到 webVR 场景中的 10 个原始平面上。如果我抓取视频元素,我可以将视频拖动更改为视频中的任何位置,但这会更新视频正在播放的每个位置。是否可以获取 WebGL 视频引用并更改每个单独视频显示器上的视频位置?
我想如果能够获取每个元素的 id、访问源并将 currentTime 值更新为每个元素的唯一值,那就太棒了...这在 WebGL 中可能吗?或者这是一个 Canvas 和视频资源的限制?
A 框架文档网址为 https://aframe.io/docs/0.7.0/components/material.html#video-textures我想要做的事情没有在文档中描述,但想看看社区内是否有人知道如何做到这一点。
下面列出了应用程序视频代码的片段以供引用。
谢谢!
<a-assets>
<video id="testvideo" src="./assets/video/_sm/video_sprite.webmvp8.webm" webkit-playsinline playsinline preload="true" loop="true"></video>
</a-assets>
....
HTML Code
....
<a-entity layout="type: pyramid; margin: 2; radius: 10;">
<a-video cursor-listener mixin="video" id="video0" material="src: #testvideo" rotation="-1.662 14.897 2.588" position="0.054 1.470 5.472"
opacity="0.0" transparent="true"
animation__opacity="property: opacity; dir: normal; dur: 3000;
easing: easeInSine; loop: false; to: 1.0"
></a-video>
<a-video cursor-listener mixin="video" id="video1" material="src: #testvideo" rotation="0 50 0" position="-5 0 -2"
opacity="0.0" transparent="true"
animation__opacity="property: opacity; dir: normal; dur: 3000;
easing: easeInSine; loop: false; to: 1.0"
></a-video>
<a-video cursor-listener mixin="video" id="video2" material="src: #testvideo" rotation="0.630 101.643 0.115" position="5.743 0 -1.972"
opacity="0.0" transparent="true"
animation__opacity="property: opacity; dir: normal; dur: 3000;
easing: easeInSine; loop: false; to: 1.0"
></a-video>
<a-video cursor-listener mixin="video" id="video4" material="src: #testvideo" rotation="90 90 0" position="0.0 8.165 -1.44"
opacity="0.0" transparent="true" scale="1.2 1.2 1.0"
animation__opacity="property: opacity; dir: normal; dur: 3000;
easing: easeInSine; loop: false; to: 1.0"
></a-video>
<a-video cursor-listener mixin="video" id="video5" material="src: #testvideo" position="0 -4 0" rotation="-90 0 0"
opacity="0.0" transparent="true"
animation__opacity="property: opacity; dir: normal; dur: 3000;
easing: easeInSine; loop: false; to: 1.0"
></a-video>
<a-video cursor-listener mixin="video" id="video6" material="src: #testvideo" rotation="-27.960 -49.5 3.953" position="-5.186 4.297 2.595"
opacity="0.0" transparent="true"
animation__opacity="property: opacity; dir: normal; dur: 3000;
easing: easeInSine; loop: false; to: 1.0"
></a-video>
</a-entity>
最佳答案
我会跳过 Material 组件并在 Three.js 中手动创建纹理。这就是我要做的:
(在 HTML 或 JS 中),创建十个指向相同 src
的视频。希望浏览器能够识别出它们都来自同一个 src
并且不执行重复的请求。
创建 10 个不同的 THREE.VideoTexture
每个视频 s。 https://threejs.org/docs/#api/textures/VideoTexture
现在,对于您的平面,您需要指定 UV 以指向视频片段。这是一个很好的教程:https://solutiondesign.com/blog/-/blogs/webgl-and-three-js-texture-mappi-1 ...我稍后将发布一个组件,以便轻松地为网格 map 集执行此操作。
然后将每个飞机的视频的当前时间更改为其各自的视频部分。
我们需要构建几个组件(一个简化的 video-material
,用于创建带有视频纹理的基本 Material )和一个用于指定 UV 的组件(除非您想手动执行此操作),我可以稍后发布。
所以也许最终,您构建的实体可能看起来像 <a-plane geometry="buffer: false" video-material="src: myvideo.mp4; time: 150" uvs="totalColumns: 3; totalRows: 3; row: 2; column: 1"></a-plane>
video-material
组件可能如下所示:
AFRAME.registerComponent('video-material', {
dependencies: ['geometry'],
schema: {
src: {type: 'string'},
time: {type: 'number'}
},
init: function () {
var mesh = this.el.getObject3D('mesh');
this.video = document.createElement('video');
this.video.setAttribute('src', this.data.src);
mesh.material = new THREE.MeshBasicMaterial({color: '#FFF', map: this.video});
this.video.currentTime = this.data.time;
}
});
这是我的 UV 组件:
var uvs = [new THREE.Vector2(), new THREE.Vector2(), new THREE.Vector2(), new THREE.Vector2()];
/**
* 1-indexed.
*/
AFRAME.registerComponent('plane-grid-uvs', {
dependencies: ['geometry'],
schema: {
totalColumns: {type: 'int'},
totalRows: {type: 'int'},
column: {type: 'int'},
row: {type: 'int'}
},
init: function () {
var geometry;
geometry = this.el.getObject3D('mesh').geometry;
geometry.faceVertexUvs[0][0] = [new THREE.Vector2(), new THREE.Vector2(), new THREE.Vector2()];
geometry.faceVertexUvs[0][1] = [new THREE.Vector2(), new THREE.Vector2(), new THREE.Vector2()];
},
update: function () {
var column;
var columnWidth;
var data = this.data;
var geometry;
var row;
var rowHeight;
column = data.column - 1;
row = data.row - 1;
columnWidth = 1 / data.totalRows;
rowHeight = 1 / data.totalColumns;
uvs[0].set(columnWidth * column,
rowHeight * row + rowHeight);
uvs[1].set(columnWidth * column,
rowHeight * row);
uvs[2].set(columnWidth * column + columnWidth,
rowHeight * row);
uvs[3].set(columnWidth * column + columnWidth,
rowHeight * row + rowHeight);
geometry = this.el.getObject3D('mesh').geometry;
geometry.faceVertexUvs[0][0][0].copy(uvs[0]);
geometry.faceVertexUvs[0][0][1].copy(uvs[1]);
geometry.faceVertexUvs[0][0][2].copy(uvs[3]);
geometry.faceVertexUvs[0][1][0].copy(uvs[1]);
geometry.faceVertexUvs[0][1][1].copy(uvs[2]);
geometry.faceVertexUvs[0][1][2].copy(uvs[3]);
geometry.uvsNeedUpdate = true;
}
});
关于javascript - 一个视频资源是否可以在多个 3D 平面上渲染,所有平面均以 webVR 中的不同 video.currentTime 值开始?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47078410/
我想做的是让 JTextPane 在 JPanel 中占用尽可能多的空间。对于我使用的 UpdateInfoPanel: public class UpdateInfoPanel extends JP
我在 JPanel 中有一个 JTextArea,我想将其与 JScrollPane 一起使用。我正在使用 GridBagLayout。当我运行它时,框架似乎为 JScrollPane 腾出了空间,但
我想在 xcode 中实现以下功能。 我有一个 View Controller 。在这个 UIViewController 中,我有一个 UITabBar。它们下面是一个 UIView。将 UITab
有谁知道Firebird 2.5有没有类似于SQL中“STUFF”函数的功能? 我有一个包含父用户记录的表,另一个表包含与父相关的子用户记录。我希望能够提取用户拥有的“ROLES”的逗号分隔字符串,而
我想使用 JSON 作为 mirth channel 的输入和输出,例如详细信息保存在数据库中或创建 HL7 消息。 简而言之,输入为 JSON 解析它并输出为任何格式。 最佳答案 var objec
通常我会使用 R 并执行 merge.by,但这个文件似乎太大了,部门中的任何一台计算机都无法处理它! (任何从事遗传学工作的人的附加信息)本质上,插补似乎删除了 snp ID 的 rs 数字,我只剩
我有一个以前可能被问过的问题,但我很难找到正确的描述。我希望有人能帮助我。 在下面的代码中,我设置了varprice,我想添加javascript变量accu_id以通过rails在我的数据库中查找记
我有一个简单的 SVG 文件,在 Firefox 中可以正常查看 - 它的一些包装文本使用 foreignObject 包含一些 HTML - 文本包装在 div 中:
所以我正在为学校编写一个 Ruby 程序,如果某个值是 1 或 3,则将 bool 值更改为 true,如果是 0 或 2,则更改为 false。由于我有 Java 背景,所以我认为这段代码应该有效:
我做了什么: 我在这些账户之间创建了 VPC 对等连接 互联网网关也连接到每个 VPC 还配置了路由表(以允许来自双方的流量) 情况1: 当这两个 VPC 在同一个账户中时,我成功测试了从另一个 La
我有一个名为 contacts 的表: user_id contact_id 10294 10295 10294 10293 10293 10294 102
我正在使用 Magento 中的新模板。为避免重复代码,我想为每个产品预览使用相同的子模板。 特别是我做了这样一个展示: $products = Mage::getModel('catalog/pro
“for”是否总是检查协议(protocol)中定义的每个函数中第一个参数的类型? 编辑(改写): 当协议(protocol)方法只有一个参数时,根据该单个参数的类型(直接或任意)找到实现。当协议(p
我想从我的 PHP 代码中调用 JavaScript 函数。我通过使用以下方法实现了这一点: echo ' drawChart($id); '; 这工作正常,但我想从我的 PHP 代码中获取数据,我使
这个问题已经有答案了: Event binding on dynamically created elements? (23 个回答) 已关闭 5 年前。 我有一个动态表单,我想在其中附加一些其他 h
我正在尝试找到一种解决方案,以在 componentDidMount 中的映射项上使用 setState。 我正在使用 GraphQL连同 Gatsby返回许多 data 项目,但要求在特定的 pat
我在 ScrollView 中有一个 View 。只要用户按住该 View ,我想每 80 毫秒调用一次方法。这是我已经实现的: final Runnable vibrate = new Runnab
我用 jni 开发了一个 android 应用程序。我在 GetStringUTFChars 的 dvmDecodeIndirectRef 中得到了一个 dvmabort。我只中止了一次。 为什么会这
当我到达我的 Activity 时,我调用 FragmentPagerAdapter 来处理我的不同选项卡。在我的一个选项卡中,我想显示一个 RecyclerView,但他从未出现过,有了断点,我看到
当我按下 Activity 中的按钮时,会弹出一个 DialogFragment。在对话框 fragment 中,有一个看起来像普通 ListView 的 RecyclerView。 我想要的行为是当
我是一名优秀的程序员,十分优秀!