How to create a 180-degree/semisphere/segment/part

2019-06-22 13:22发布

问题:

<a-videosphere src="myvideo.mp4"> displays a video on an entire 360-degree sphere, but I want to display a video or image, but only on a portion of a sphere like a hemisphere. Something like:

http://mathworld.wolfram.com/images/eps-gif/SphericalSegment_1000.gif

How would I do this in A-Frame?

回答1:

You can use the sphere geometry (<a-entity geometry="primitive: sphere"> or <a-sphere>) and control the phiLength/thetaLength angles of the sphere to specify a segment. Theta length controls horizontal sweep angle and phi length controls vertical sweep angle:

http://forums.mediabox.fr/wiki/_media/tutoriaux/flashplatform/affichage/3d/carrousel_papervision/sphere/theta_phi.png

For a hemisphere, we would do:

<a-entity geometry="primitive: sphere; thetaLength: 180; radius: 5000; segmentsWidth: 64; segmentsHeight: 20" scale="1 1 -1" material="src: #myVideo; shader: flat"></a-entity>

Or:

<a-sphere theta-length="180">

And then apply the material.

For videosphere, we can update it:

<a-videosphere src="#myVideo" geometry="thetaLength: 180"></a-videosphere>

However, the video won't be cropped as you'd expect. So you might have to crop beforehand. If you want it to crop like background-size: cover, we might have to do something special like hide portions of the sphere.



标签: aframe