问题
I need to be able to load a specific image into a scene, selected from a dropdown box. The dropdown box is written in html, and the scenes of course are with three.js.
I have tried implementing an onClick listener, but I am having trouble translating it in order to be loaded into the scene.
The javascript:
var mySelect = document.getElementById('mySelect');
mySelect.onchange = function() {
if(mySelect=="111"){
imgLink='images/111.jpg';
}
if(mySelect=="222"){
imgLink='images/222.jpg';
}
if(mySelect=="333"){
imgLink='images/333.jpg';
}
if(mySelect=="444"){
imgLink='images/444.jpg';
}
return imgLink;
}
const controls = new THREE.OrbitControls(camera);
var sceneEditor = new Scene(imgLink, camera);
The dropdown box (html):
<div class="dropdown">
<button class="dropbtn">Select Image</button>
<div class="dropdown-content" id="mySelect" onchange="function()">
<a href="">111</a>
<a href="">222</a>
<a href="">333</a>
</div>
</div>
来源:https://stackoverflow.com/questions/55660845/how-to-load-scene-from-dropdown-box