My camera simply walks through interior walls of a house I built in Blender. Here are the steps I followed -
- Modelled a house in Blender.
- Applied physics -> collision to interior and the exterior walls of the house
- Exported as .obj and .mtl and used it in a-frame
- Placed the camera inside the house.
- 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.
- 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