2017-09-30 4 views
0

AフレームのAパネルの素材をJavascriptから設定して、テクスチャが両面になるようにするにはどうすればよいですか?Javascriptの両面aフレームaパネル

私は <a-plane src="image.jpg" material="side: double">でJavascript以外からやりましたが、Javascriptで動作させることはできません。

これはフロントのみが表示されている非実施例である:あなたが提供されるHTMLで行く

<html> 
<head> 
    <script src="aframe.min.js"></script> 
    <script type="text/javascript"> 
    function setup() { 
     scene = document.querySelector('a-scene'); 

     var entity = document.createElement('a-entity'); 
     entity.setAttribute('position', '0 1.6 -1'); 

     var plane = document.createElement('a-plane'); 
     var planeMaterial = document.createElement('material'); 
     planeMaterial.setAttribute('side', 'double'); 
     plane.appendChild(planeMaterial); 
     plane.setAttribute('src', 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/30/Jubilee_and_Munin%2C_Ravens%2C_Tower_of_London_2016-04-30.jpg/240px-Jubilee_and_Munin%2C_Ravens%2C_Tower_of_London_2016-04-30.jpg') 
     entity.appendChild(plane); 

     scene.appendChild(entity); 
    } 
    window.onload = setup; 
    </script> 
</head> 

<body> 
    <a-scene></a-scene> 
</body> 
</html> 

答えて

2

、これは何が必要です。

plane.setAttribute('material','side:double');

あなたが投稿したコードは、私は、これが動作することを見つける

<a-plane src="image.jpg"><material side="double"></material></a-plane>


function setup() { 
 
    scene = document.querySelector('a-scene'); 
 

 
    var entity = document.createElement('a-entity'); 
 
    entity.setAttribute('position', '0 1.6 -1'); 
 

 
    var plane = document.createElement('a-plane'); 
 
    plane.setAttribute('material', 'side: double;'); 
 
    plane.setAttribute('src', 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/30/Jubilee_and_Munin%2C_Ravens%2C_Tower_of_London_2016-04-30.jpg/240px-Jubilee_and_Munin%2C_Ravens%2C_Tower_of_London_2016-04-30.jpg') 
 
    entity.appendChild(plane); 
 

 
    scene.appendChild(entity); 
 
} 
 
window.onload = setup;
<html> 
 

 
<head> 
 
    <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script> 
 
</head> 
 

 
<body> 
 
    <a-scene></a-scene> 
 
</body> 
 

 
</html>

+0

を生成します。私は 'plane.setAttribute( 'material'、 'side:double;');'を試しても動作しませんでしたが、バージョン0.7.0の提案に更新されました。 –

関連する問題