我正在处理以下脚本。更改.glb模型的图像。它仅产生白色。没有适当的纹理变化发生。请帮助我。
const nextButtonComponent = () => ({
init: function() {
const image = document.getElementById('img1');
const model = document.getElementById('model')
const nextButton = document.getElementById('nextbutton')
nextButton.style.display = 'block'
const nextAnimation = () => {
var mesh = model.getObject3D('mesh');
if (!mesh) return;
mesh.traverse(function(child) {
if (child instanceof THREE.Mesh)
{
child.material.map = new THREE.Texture(image);
child.material.needsUpdate = true;
this.switch = !this.switch;
}
});
}
nextButton.onclick = nextAnimation // Switch to the next animation when the button is pressed.
}
})
export {nextButtonComponent}
这里是有关如何在框架中制作我的世界的教程的一部分:
[我们放入,将资产(例如图像,视频,模型,声音)放入,并通过选择器(例如#myTexture)从我们的实体指向它们。
让我们移动地面纹理以使用元素进行预加载:
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<a-scene>
<a-assets>
<img id="groundTexture" src="https://cdn.aframe.io/a-painter/images/floor.jpg">
</a-assets>
<a-cylinder id="ground" src="#groundTexture" radius="32" height="0.1"></a-cylinder>
</a-scene>