在伪造查看器中加载图钉不遵守viewerState

时间:2019-10-10 09:28:42

标签: autodesk-forge

我们正在伪造查看器中使用“ Autodesk.BIM360.Extension.PushPin”扩展名来启用图钉。

在模型中添加图钉后,我们会序列化图钉数据并将其存储在我们的数据库中。这样的图钉示例在这里:

{
    "id": "12",
    "label": "12",
    "status": "quality_issues-not_approved",
    "position": {
        "x": 15.324803588519861,
        "y": -10.150864635427533,
        "z": -5.532972775562976
    },
    "type": "issues",
    "objectId": 24518,
    "externalId": "d9a1e318-14d0-4d08-b7ab-6d1c331454c2-002793d1",
    "viewerState": {
        "seedURN": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6MDQyY2QwMmUtNzU0Yi00ZDY2LTgyYTMtNjBmYjFlOWVjMjcxL2U5ODAxZTA4LTUwZjQtNDc0ZS05ZWU4LTAxYWQ0ZGM0ODFiYl9WMV9Lb25nZXN0aWVuKzMwKy0rVGlsYnlnbmluZystK0clMjVDMyUyNUE2bGRlbmRlK2QuKzA1LjA2LnJ2dA",
        "objectSet": [{
            "id": [],
            "isolated": [],
            "hidden": [],
            "explodeScale": 0,
            "idType": "lmv"
        }],
        "viewport": {
            "name": "",
            "eye": ["-15.17842530349136", "-0.9048862425583284", "0.6506974303790392"],
            "target": ["-22.06049144652811", "0.915848677106827", "-0.4205110420886964"],
            "up": [-0.14385076361076257, 0.038057482024001874, 0.9888673247056924],
            "worldUpVector": [0, 0, 1],
            "pivotPoint": ["-22.510046835506888", "1.6223793651751013", "3.668585646439837"],
            "distanceToOrbit": 7.198985875545766,
            "aspectRatio": 1.491792224702381,
            "projection": "orthographic",
            "isOrthographic": true,
            "orthographicHeight": 7.198985875545767
        },
        "renderOptions": {
            "environment": "Boardwalk",
            "ambientOcclusion": {
                "enabled": true,
                "radius": 13.123359580052492,
                "intensity": 1
            },
            "toneMap": {
                "method": 1,
                "exposure": -7,
                "lightMultiplier": -1e-20
            },
            "appearance": {
                "ghostHidden": true,
                "ambientShadow": true,
                "antiAliasing": true,
                "progressiveDisplay": true,
                "swapBlackAndWhite": false,
                "displayLines": true,
                "displayPoints": true
            }
        },
        "cutplanes": [],
        "globalOffset": {
            "x": -20.808594999999997,
            "y": 6.686511499999999,
            "z": 8.456207
        }
    },
    "objectData": {
        "guid": "6de5f80c-73da-30ae-b2d1-8a78f177c2a4",
        "urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6MDQyY2QwMmUtNzU0Yi00ZDY2LTgyYTMtNjBmYjFlOWVjMjcxL2U5ODAxZTA4LTUwZjQtNDc0ZS05ZWU4LTAxYWQ0ZGM0ODFiYl9WMV9Lb25nZXN0aWVuKzMwKy0rVGlsYnlnbmluZystK0clMjVDMyUyNUE2bGRlbmRlK2QuKzA1LjA2LnJ2dA",
        "viewableId": "aaff5911-e8b1-4ae2-b41c-4284d0703eb4-00150218",
        "viewName": "{3D}"
    }
}

然后我们在以后的某个时刻(当用户重新打开模型时)再次将图钉加载到模型中,如下所示:

pushPinExtension.loadItems([pushPinItem]);

结果是图钉在模型中的正确位置添加了,但是查看器状态不正确。似乎图钉的查看器状态设置为在加载图钉时模型的查看器状态,而不是存储在图钉内部的查看器状态。

这是预期的行为吗? -如果可以,我该如何使用图钉中的查看器状态?

1 个答案:

答案 0 :(得分:1)

为什么在加载图钉之后没有显式分别加载存储在图钉中的查看器状态:

pushPinExtension.loadItems([pushPinItem]);
viewer.restoreState(pushPinItem.viewerState)

编辑:

尝试在单击某项时恢复查看器状态-通过以下方式订阅click事件:

   viewer.restoreState(...)
   //...
})