How to change the position of point object?
I have a project at three.js created from qgis to threejs export. I have some DEM layers in that project, and one point layer (cylinders). For example I selected one point object and want to move it using keyboard or mouse.
I tried to change the visibility of these objects from console, for instance: project.getLayerByName("tx").queryableObjects[3].visible = false // (or true) it works;
But if I try to change the position, like this: project.getLayerByName("tx").queryableObjects[3].position.x = 10 it doesn't work!
How to change the position of any point object dynamically?
alexv71, have you tried calling app.scene.updateMatrixWorld(); after you update the position?
Thank you so much, it works!!! Could you please let me know, how to find the point object that has been selected by mouse before? I need to change the position of selected object.
I would try calling a function from app.canvasClicked() in the qgis2threejs.js file. You should be able to return the object clicked with the following:
var layer = app.project.layers[layerId];
var selectedObject = layer.f[featureId];
I would be a little careful here because the script creates a clone of the clicked object once it is selected, this is the highlighted object that you see when an object is clicked in 3D space. It may be the case that the highlight will remain after you drag the object that you are intending to move. You may need to do a little experimentation depending on how you set up your function.
Also, if you want a smooth drag on your selected object then you might consider setting app.scene.autoUpdate = true; when dragging begins and app.scene.autoUpdate = false; when the object is released.
Let me know what you come up with for this. I'd love to see your implementation!
Thank you so much, appreciate it!