Have a task: create 10 sphere objects, put them in pool; on each click got each sphere from pool and show to user at cursor intersection point.
Problem: can't figure how to properly create and after this, put it to pool. Please check code below.
Currently each sphere create dynamicly like this: (in a-scene on click event)
let {x, y, z} = event.detail.intersection.point
sceneEl.insertAdjacentHTML('beforeend',
`<a-sphere data-coords="[${x}, ${y}, ${z}]" data-clickable position="${x} ${y} ${z}" radius="32.0" color="#eee"></a-sphere>`)
need in further work to get each a-sphere object from pool.
Layout:
<a-scene id="scene" pool__sphere="mixin: sphere; size: 10" main-scene class="ascene" cursor="rayOrigin: mouse" raycaster="zobjects: a-sky">
....
<!-- Asset-s from them want to create each a-sphere -->
<a-assets>
<a-mixin id="gray" color="#eee" ></a-mixin>
<a-mixin id="radius" radius="32.0" ></a-mixin>
<a-mixin id="sphere" geometry="primitive: sphere"></a-mixin>
</a-assets>
Pool creation:
AFRAME.registerComponent('main-scene', {
init() {
//here maybe needed to create each a-sphere object
//end add each to pool,
//then on each scene click, needed to get one by one sphere from pool
//pool creation
let sceneEl = this.el
var el = sceneEl.components
sceneEl.play();
//pool logs 10 empty objects {} if console.log('pool with spheres', el.pool__sphere)
el.pool__sphere.returnEntity(el);
console.log('entity', el)
},
// console.log('el', el)
play (){
}
})
Maybe it's me, but not got how exactly do it There no clear example for obj. creating in doc. only for object get from pool please look: https://github.com/aframevr/aframe/blob/master/docs/components/pool.md