3
웹 3D 앱을 개발 중이며 iframe 내에서 모델이있는 외부 .html 파일에 다음 태그를 구현하는 Javascript로 일부 코드를 생성했습니다.X3DOM 모델의 텍스처를 동적으로 업데이트하십시오.
<texture id="XXX" repeats="true" repeatt="true" url="" scale="true"
hidechildren="true">
<img src="" attr=".../BMW.jpg" style="display: none; visibility: hidden;">
</texture>
나는 버튼을 클릭 한 후 iframe에 해당 블록에 위의 코드를 배치
자바 스크립트 코드 :
외부이 .html 파일의 X3D 코드 블록에서<appearance>
요소에서
ogl = true;
function toggleTexture(){
if (!ogl) {
var t = document.createElement("Texture");
t.setAttribute("id", "XXX");
t.setAttribute("repeatS", "true");
t.setAttribute("repeatT", "true");
var imgElement = document.createElement("img");
imgElement.setAttribute("src", "../HomeFurniture/assets/BMW.jpg");
t.appendChild(imgElement);
var iframe = document.getElementById("frame");
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
innerDoc.getElementById("anApp").appendChild(t);
innderDoc.x3dom.reload();
} else {
var iframe = document.getElementById("frame");
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
var ot = innerDoc.getElementById("anApp");
ot.removeChild(innerDoc.getElementById('XXX'));
}
return false;
}
Chrome 브라우저를 디버깅 한 결과 필요한 코드가 삽입되지만 실제 모델은 적절한 텍스처로 업데이트되지 않습니다.
나는 놓쳐 버린 것이 틀림 없습니다. 그러나 해결책을 찾을 수 없습니다. 어떤 도움을 주시면 감사하겠습니다.