I have been looking at the following project on GitHub:
https://github.com/ngokevin/aframe-template-component
I am quite new to using templates.
This following code works:
<script id="clouds" type="text/x-jade-template">
- for (var x = -5; x < 5; x++) {
- for (var z = -5; z < 5; z++) {
a-entity(geometry="primitive: box; depth: 8; height: 1; width: 6", material="opacity: 0.2", position="#{x * 20} 15 #{z * 20}")
- }
- }
</script>
But when I use an 3D object, it does not work:
<a-asset-item id="cloud-01-obj" src="cloud_1.obj"></a-asset-item>
<!-- Cloud template. -->
<script id="clouds" type="text/x-jade-template">
- for (var x = -5; x < 5; x++) {
- for (var z = -5; z < 5; z++) {
a-entity(obj-model="obj: #cloud-01-obj", position="#{x * 2} 15 #{z *2}")
- }
- }
</script>
</a-assets>
And in the scene block there is:
<a-entity template="src: #clouds"></a-entity>
I know the 3D objects loads as there is following code in the scene & all the different objects are loaded.
<!-- cloud instances -->
<a-entity obj-model="obj: #cloud-01-obj" position="5.0 0.0 -1" rotation="0 30 0"></a-entity>
<a-entity obj-model="obj: #cloud-02-obj" position="5.0 1.0 5"></a-entity>
<a-entity obj-model="obj: #cloud-03-obj" position="7.0 2.0 5"></a-entity>
<a-entity obj-model="obj: #cloud-04-obj" position="8.0 3.0 5"></a-entity>
<a-entity obj-model="obj: #cloud-05-obj" position="13.0 2.0 6" ></a-entity>
<a-entity obj-model="obj: #cloud-06-obj" position="12.0 2.0 -1" </a-entity>
<a-entity obj-model="obj: #cloud-07-obj" position="-2.0 4 0" ></a-entity>
<a-entity obj-model="obj: #cloud-08-obj" position="-10.0 0.0 0" ></a-entity>
<a-entity obj-model="obj: #cloud-09-obj" position="-9.0 4.0 0" ></a-entity>