我们可以渲染Babylon.JS中的一个场景,从表单字段读取位置/比例等值。但它是否允许在场景中进行更改,以监听输入字段中的实时更改,如$('input').val()
。如何更改一些JS变量后更新BabylonJS场景?
var cusotm_position = $('input').val();
canvas = document.getElementById("renderCanvas");
engine = new BABYLON.Engine(canvas, true);
scene = createScene(); //draws a mesh at custom_position
engine.runRenderLoop(function() {
scene.render();
});
$("input").change(function(){
cusotm_position = $('input').val();
scene.render();//doesn't seem to be updating the mesh to new value of custom_position
});
席力图召scene.render();
在输入变化的事件监听器,但似乎并没有被做任何事情。有什么像refrest /更新更改为更新的变量值。更好的是,如果可以完成而不需要移除所有内容并重新创建新场景。