2017-11-10 5 views

답변

2

dynamic-body에서 자동 형상 감지 텍스트를 처리하지 않습니다

여기 내 결함이다. 대신 Physics Body Shape를 수동으로 적용 할 수 있습니다.

<!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

'형식 오류 : a.position는 undefined' https://glitch.com/edit/#!/sincere-forger입니다 –

관련 문제