How to load scene from dropdown box?

情到浓时终转凉″ 提交于 2019-12-13 03:46:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!