Camera walks through the wall built in blender

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

My camera simply walks through interior walls of a house I built in Blender. Here are the steps I followed -

  1. Modelled a house in Blender.
  2. Applied physics -> collision to interior and the exterior walls of the house
  3. Exported as .obj and .mtl and used it in a-frame
  4. Placed the camera inside the house.
  5. While the camera is able to walk out of the house from inside by walking through walls, it is unable to move back into the house from outside as collision occurs. Also, camera is able to walk through all the interior walls of the house without collision.
  6. I am not sure how to share my blender files.

Here is my code -

<div id="myEmbeddedScene">     <a-scene raycaster-autorefresh physics embedded="">          <a-assets>           <a-asset-item id="house-obj" src="../images/house.obj"></a-asset-item>           <a-asset-item id="house-mtl" src="../images/house.mtl"></a-asset-item>           <a-mixin id="checkpoint"></a-mixin>           <a-mixin id="checkpoint-hovered" color="#6CEEB5"></a-mixin>         </a-assets>        <!-- Player -->         <a-entity camera="userHeight: 0.6"             universal-controls="movementControls: checkpoint, keyboard"             checkpoint-controls="mode: animate"             kinematic-body>             <a-cursor                   cursor="fuse: true;"                   timeout="10"                   position="0 0.1 -3"                   geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03;"                   material="color: #4CC3D9; shader: flat;">             </a-cursor>         </a-entity>           <!-- Ground -->         <a-grid static-body visible="false"></a-grid>          <!-- Obstacles -->         <a-obj-model src="#house-obj" mtl="#house-mtl" scale="0.5 0.5 0.5" rotation="0 0 0" class="clickable" static-body></a-obj-model>           <!-- Lighting -->       <a-light type="ambient" color="#bbb"></a-light>     <!--  <a-light color="#ccc" position="0 30 0" distance="100" intensity="0.4" type="point"></a-light>       <a-light color="#ccc" position="3 10 -10" distance="50" intensity="0.4" type="point"></a-light> -->      </a-scene>  </div>  My codepen - https://codepen.io/nirajupadhyay11/pen/ZaGWdN 

回答1:

https://aframe.io/docs/0.7.0/introduction/faq.html#can-i-prevent-the-camera-from-going-through-obstacles

For non-VR desktop experiences with a gamepad or keyboard controls or for VR scenes where the camera is inside a vehicle, you can add a physics engine to prevent movement through obstacles.

https://github.com/donmccurdy/aframe-physics-system



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!