Reputation: 11
This is my x3d dom context:
<x3d>
<Scene>
<Shape>
<Appearance>
<Material diffuseColor="0 0 1" emissiveColor="0 0.5 0" shininess="0.8" specularColor="0.5 0.5 0.5"/>
</Appearance>
<IndexedFaceSet id="idxFS">
<!--Coordinate point with values dynamically when function addFaces() is called-->
</IndexedFaceSet>
</Shape>
</Scene>
</x3d>
This is my function addFaces()
which is called when a button is pressed
function addFaces()
{
let faces = document.getElementById('idxFS');
faces.setAttribute('coordIndex', '0 1 2 3 -1 7 6 5 4 -1 0 4 5 1 -1 1 5 6 2 -1 2 6 7 3 -1 3 7 4 0');
let coords = document.createElement('Coordinate');
coords.setAttribute('point', '-2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 -2.0 -2.0 2.0 -2.0 -2.0 -2.0 2.0 2.0 -2.0 2.0 2.0 -2.0 -2.0 -2.0 -2.0 -2.0');
faces.appendChild(coords);
}
But the part with the coordinates does not work. If I put the coordinates static into the DOM it works. like it can be seen here https://www.web3d.org/x3d/content/examples/ConformanceNist/Geometry/IndexedFaceSet/default_facesetIndex.html
But my dynamic version does not work. Help would be much appreciated!! I've tried for hours now but I could not get it to work.
Upvotes: 1
Views: 225