2017-07-13 71 views
0

Aframe API支持曲面圖像。但是,除了曲面圖像之外,我還想製作彎曲的文字和平面。有人可以幫我解決這個問題嗎?Aframe VR曲面和文字

我想我必須做一個實體,但我不知道必須設置哪些屬性。

回答

1

我會用https://github.com/mayognaise/aframe-html-shader來創建曲線文本。彎曲的文字是部分圓柱體,其材質在內部呈現使用repeat: -1 1

HTML着色器使用我們可以用於文本的HTML爲我們創建一個紋理,然後將該紋理應用到圓柱體。不幸的是,我們必須手動應用repeat: -1 1,因爲該選項未公開。粗糙的想法...

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Hello, WebVR! - A-Frame</title> 
    <meta name="description" content="Hello, WebVR! - A-Frame"> 
    <script src="https://aframe.io/releases/0.6.0/aframe.min.js"></script> 
    <script src="https://unpkg.com/[email protected]/dist/aframe-html-shader.min.js"> 
    </head> 
    <body> 
    <script> 
     AFRAME.registerComponent('update-repeat', { 
     dependencies: ['material'], 

     init: function() { 
      var texture = this.el.components.material.material.map; 
      texture.repeat = new THREE.Vector2(-1, 1); 
      texture.needsUpdate = true; 
     } 
     }); 
    </script> 

    <div id="texture" style="width: 100%; height: 100%; position: fixed; left: 0; top: 0; z-index: -1; overflow: hidden"> 
     <p style="position: relative; top: 20px; font-size: 72px">HELLO HELLO</p> 
     <p style="position: relative; top: 20px; font-size: 48px">curvy text</p> 
    </div> 

    <a-scene> 
     <a-entity geometry="primitive: cylinder; radius: 2; segmentsRadial: 48; thetaLength: -160; openEnded: true"  
       material="shader: html; target: #texture; side: double; width: 500; height: 300; transparent: true" update-repeat position="0 0 -4" rotation="0 -90 0"></a-entity> 
     <a-sky color="#FAFAFA"></a-sky> 
    </a-scene> 
    </body> 
</html> 

看到這個example glitch I made for full answer

https://aframe-curved-text.glitch.me/