Updating the sceneview on geometry change

489
3
08-19-2022 06:45 AM
NorbertByiringiro
New Contributor II

Hello folks, 

I am trying to move a 3D object, feeding in the geometry values from the API, however the changes do not appear on my sceneview unless I reload the page.

...
const newGeometry = {
              type: "point", // autocasts as new Point()
              x: props.valueX,
              y: props.valueY,
              z: props.valueZ,
            };

        function updateGeometry(){
   
            var objLayer = pointGraphic.layer  
         
            // clone old graphic and edit geometry
            var newGraphic = pointGraphic.clone();
            newGraphic.geometry = newGeometry;
         
            // remove old graphic, add new graphic
            objLayer .remove(pointGraphic);
            objLayer .add(newGraphic);
         
          }
 
updateGeometry()
...
 
Do you guys have any hint on how all the changes can appear directly on the map (sceneView) without reloading the page, thank you! 
 
 
0 Kudos
3 Replies
GeoJason
New Contributor III

Have you tried adding the graphics to the SceneView in the updateGeometry function? 

0 Kudos
NorbertByiringiro
New Contributor II

I am actually:

1. Creating a graphicsLayer  and add it to the map on which I applied the view: 

      const graphicsLayer = new GraphicsLayer();
      map.add(graphicsLayer);
 
2. Add the geometry and the symbol to create a graphic:
    
       const pointGraphic = new Graphic({
            geometry: point, //point is defined somewhere above
            symbol: markerSymbol //markerSymbol is defined somewhere above
          });
3. Add the graphic to the graphicsLayer/.
     
           graphicsLayer.add(pointGraphic);
 
4. Update the this graphic inside the  updateGeometry function shown in the first post.
 
However even when I try to add the newgraphic to the graphicsLayer inside the updateGeometry function, or even adding again the graphicsLayer to the map inside this function, It still requires to refresh the page for realising the changes.
Thanks @GeoJason 
 
0 Kudos
GreteSoosalu
Esri Contributor

Hi @NorbertByiringiro

It is hard to estimate what may be the issue with your app without having a closer look at your code. 

Here's a simple app where one can move a boat symbol with keys:

https://codepen.io/gsoosalu/pen/OJvKPMV?editors=1000

Hope this helps you further! If not, could you share a similar simple app we could take a look at?

0 Kudos