Motivation
I have an Angular 6 app that has multiple A-Frame scenes. I would like to inject into each scene some common "partials" (in rails lingo) containing A-Frame HTML elements such as an afame-gui config panel. This way, I don't duplicate the html elements in each view. This is a standard thing to do in ng6, and you do it by creating an ng component for the partial, which then gets its own tag, which you then reference in each parent component you want to mix it into:
<a-scene>
<app-config-panel></app-config-panel> <-- insert partial #1
<ng-template appDynamicLoad></ng-template> <-- insert partial #2
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>
I have a fuller example here
Problem
Unfortunately, while Angular 6 does inject the partial into the DOM, I do not see it in the A-Frame scene.
I know that A-Frame has special wrapped createElement, setAttribute, and appendChild methods that override the default behavior and add additional info, such as a THREE.object3D to each element. Presumably, angular 6 is not using these methods for inserting into the DOM (note, this only applies to partials: the "main" component containing the scene works properly). Actually, in inspecting the DOM elements, I do see an Object3D, but it doesn't have any Material or Geometry info under it.
So my question is: Is there a way to make Angular drive these methods and thus insert into the A-Frame scene as well?
Details
I found this that mentions a way to force angular to call setAttribute and thus properly insert it into the a-frame scene, but there wasn't enough information for me to figure it out.
I tried dynamically loading the component based on this convoluted example from angular docs, but its the same thing: inserts into DOM but not the scene.
Yes, I can manually build up and insert the element programmatically from my script, something like this:
createEl() {
let newEl = this.renderer.createElement('a-entity');
this.renderer.setAttribute(newEl, 'text', this.msg);
this.renderer.setAttribute(newEl, 'position', this.position);
return newEl;
}
But I'd rather do it using a template in the official angular way.
It's odd that angular works fine for the parent component, but not for the partial component.
I fear this is simply an A-frame/Angular impedance mismatch and I'll just be forced to do it manually, but it never hurts to ask, right?
Angular 6.0.3
A-Frame 0.8.2