jsapi-resources icon indicating copy to clipboard operation
jsapi-resources copied to clipboard

how to obtain the mesh data of node in sceneLayer

Open webmapLee opened this issue 8 months ago • 1 comments

the url of scenelayer node mesh data:https://xxx/server/rest/services/xxx/SceneLayer/layers/0/nodes/{nodeid}/geometries/0

the url of node info of scenelayer: https://xxx/server/rest/services/xxx/SceneLayer/layers/0/nodes/root

my question is, when i click the scene of sceneView, how to pick up accurate mesh of scenelayer,

the click event codes as follows:

app.view.whenLayerView(sceneLayer).then((sceneLayerView) => {
      // 监听点击事件
      app.view.on("click", function (event) {
        resultMeshs = [];
        arcgisMeshs = [];
        resultArcgisMeshs = [];

        // 清理场景
        if (app.webglRenderer && app.webglRenderer.scene) {
          disposeScene(app.webglRenderer.scene);
        }

        app.view.hitTest(event).then((response) => {
          // 获取点击的SceneLayer要素
          const result = response.results.filter(
            (result) => result.graphic.layer === sceneLayer
          )[0];

          if (!result) return;
          console.log(result);
          const graphic = result.graphic;

          // 高亮选中的图形
          const highlightHandle = sceneLayerView.highlight(graphic);
          highlightHandles.push(highlightHandle);

          // 获取图形的边界信息

          sceneLayerView.whenGraphicBounds(graphic).then((bounds) => {
            console.log("图形边界:", bounds);

            // const targetNodes = getNodeByBox(bounds.boundingBox);
            // targetNodes.forEach((node) => {
            //   getNodeGeometries(node);
            // });

            // const l = nodePagesInfos.length;
            // const nodeInfo = nodePagesInfos[Math.floor(Math.random() * l)];
            // const boxGeometry = createGeometryByNode(nodeInfo);
            // addTestNodeBound(boxGeometry, nodeInfo.id);
            // getNodeGeometries(nodeInfo);

            // const boundGeometry = createGeometryFromBounds(bounds.boundingBox);
            // addTestNodeBound(boundGeometry);
            nodePagesInfos.forEach((node) => {
              const boxGeometry = createGeometryByNode(node);
              if (geometryEngine.intersect(event.mapPoint, boxGeometry)) {
                // if (boxGeometry.contains(boundGeometry)) {
                // addTestNodeBound(boxGeometry, node.id);

                createAndAddMeshFromOBB(node,node.id);

                getNodeGeometries(node);
              }
            });

            // // 如果需要创建一个可视化的几何体来表示这个网格面
            // // 可以使用bounds创建一个简单的多边形或者盒子
            // const geometryForVisualization = createGeometryFromBounds(bounds.boundingBox);

            // app.view.graphics.add(
            //   createTestBoundsGraphic(geometryForVisualization)
            // );
          });
        });
        // 根据点获取节点
        // getNodesByPoint(mapPoint);
      });
    });

but i don't how to pick up the accurate node mesh of scenelayer, i'v tried many methods, but none of them worked, I use the spatial relationship between bounds.boundingBox and node.obb to obtain accurate node information, and I also tried to obtain accurate node information through the correlation between node information and graphic attribute information, all attempts have failed, can you provide me with a feasible solution

webmapLee avatar May 28 '25 03:05 webmapLee

@webmapLee for best visibility with the worldwide ArcGIS community we recommend posting this question about SDK functionality to the Esri community site: https://community.esri.com/t5/arcgis-api-for-javascript/ct-p/arcgis-api-for-javascript. Can you post your question on that site?

This issue also a duplicate of https://github.com/Esri/arcgis-rest-js/issues/1230.

andygup avatar Jun 05 '25 21:06 andygup