简体   繁体   English

获取图像在A帧中的画布位置

[英]Get canvas position of image in A-frame

Right now, I have an A-frame scene with a 360 video mapped onto the inside of a sphere, and I added a few <a-plane> 's, but I wanted to add 2D buttons on the canvas (using plain ol' HTML) next to the <a-plane> (kind of hovering on top of the object). 现在,我有一个A帧场景,其中360°视频映射到一个球的内部,我添加了几个<a-plane> ,但是我想在画布上添加2D按钮(使用普通ol' HTML)在<a-plane>旁边(在对象顶部徘徊)。 The problem is that the user can click and drag the <a-plane> , so the position in 3D environment will change (and so will the size of the <a-plane> since the image will get warped when you rotate the screen). 问题在于用户可以单击并拖动<a-plane> ,因此3D环境中的位置将发生变化( <a-plane>的大小也会发生变化,因为旋转屏幕时图像会变形) 。

Is there any way to find out the xy position of the bounds of the image in the <a-plane> in the canvas element? 有什么方法可以找出canvas元素中<a-plane>中图像边界的xy位置吗? I have to use the canvas because the is slightly warped when it's at the corner of the screen due to the skewed perspective. 我必须使用画布,因为由于视角倾斜,当它在屏幕的一角时会略微变形。

There's a mouse-cursor component that will start a raycaster based on the XY of the mouse. 有一个鼠标光标组件,它将根据鼠标的XY启动光线投射器。 So you can tell when the actual mouse cursor hovers over an object: https://github.com/mayognaise/aframe-mouse-cursor-component 因此,您可以知道实际的鼠标光标何时悬停在对象上: https : //github.com/mayognaise/aframe-mouse-cursor-component

For the raw three.js example, check out https://threejs.org/examples/#webgl_interactive_cubes 对于原始的three.js示例,请查看https://threejs.org/examples/#webgl_interactive_cubes

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

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