2017-11-10 17 views

答えて

2

dynamic-body自動形状検出がテキストを処理しません。代わりに手動で物理ボディ形状を適用することができます。

<!DOCTYPE html> 
<html> 
    <head> 
    <title>The text shall fall. - A-Frame</title> 
    <meta name="description" content="The text shall fall."> 
    <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script> 
    <script src="//cdn.rawgit.com/donmccurdy/aframe-physics-system/v2.1.0/dist/aframe-physics-system.min.js"></script> 
    <script> 
     window.onload =() => { 
     const text = document.querySelector('a-text') 
     // Cannon boxes use 'halfExtents', side length/2 
     const shape = new CANNON.Box(new CANNON.Vec3(0.5, 0.1, 0.5)) 
     // body may or may not be ready when onload occurs 
     if (text.body) { 
      text.body.addShape(shape) 
     } else { 
      text.addEventListener('body-loaded',() => text.body.addShape(shape)) 
     } 
     } 
    </script> 
    </head> 
    <body> 
    <a-scene> 
     <!-- "shape:none" to disable auto detection. Required if combining text and geometry in same entity tree --> 
     <a-text dynamic-body="shape:none" position="-1 2 -3" value="Cylinder falls, this does too." height="1.5" color="#FFC65D" ></a-text> 
     <a-cylinder dynamic-body position="1 5 -3" rotation="12 0 0" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder> 
     <a-plane static-body position="0 0 -4" rotation="-90 0 0" width="14" height="14" color="#7BC8A4"></a-plane> 
     <a-sky color="#ECECEC"></a-sky> 
    </a-scene> 
    </body> 
</html> 
1

テキストを薄いボックスに入れてみてください。

<a-entity geometry="primitive: box; depth: 0.01" text="value: HEY" dynamic-body>

+0

'TypeError例外:a.positionがあるundefined' https://glitch.com/edit/#!/sincere-forger –

関連する問題