Я использую A-Frame HTMLEmbed-Component для рендеринга HTML в 3D-сцене. Если я создаю две сущности с присоединенным htmlembed -компонентом, они будут работать, как ожидалось, и мой raycaster вызовет события пересечения. Тем не менее, если я пытаюсь использовать их в качестве родителя, я получаю следующую ошибку:
IndexSizeError: Index or size is negative or greater than the allowed amount
Если я удаляю компонент innerObjects htmlembed , ошибка исчезает, но я не могу вызвать события пересечения , Минимальный код:
var plane = document.createElement('a-entity');
plane.id = 'plane';
plane.className = 'selectable';
plane.setAttribute('position', '0 2 -1');
plane.setAttribute('htmlembed', '');
plane.addEventListener('stateadded', function(evt){
console.log(evt);
});
var planeContainer = document.createElement('div');
planeContainer.id = 'planeContainer';
planeContainer.innerHTML = 'Test';
plane.appendChild(planeContainer);
var innerObject = document.createElement('a-entity');
innerObject.id = "innerObject";
innerObject.className = 'selectable';
innerObject.setAttribute('position', '0 2 -0.99');
innerObject.setAttribute('htmlembed', '');
var innerObjectContainer = document.createElement('div');
innerObjectContainer.id = 'innerObjectContainer';
innerObjectContainer.className = "innerObjectContainer";
innerObjectContainer.innerHTML = "Test2";
innerObject.addEventListener('stateadded', function(evt){
console.log(evt);
});
innerObject.appendChild(innerObjectContainer);
scene.appendChild(innerObject); // This does work
//plane.appendChild(innerObject); // This does not work
scene.appendChild(plane);
}
Строка ошибки закомментирована. Я также сделал скрипку для лучшей демонстрации: https://jsfiddle.net/Lbdjyxev/4/