使用Forge Viewer 6.5.2获取无效的投影矩阵和隐藏的自定义THREE.js对象

时间:2019-03-20 07:22:02

标签: autodesk-forge autodesk-viewer

已从Forge Viewer 6.4.1升级到6.5.2,我遇到了两个问题:

projectionMatrix中的viewer.navigation.getCamera()具有Infinity元素,例如:

0: 1.491671085357666
1: 0
2: 0
3: 0
4: 0
5: 1.7320507764816284
6: 0
7: 0
8: 0
9: 0
10: -Infinity
11: -1
12: 0
13: 0
14: -Infinity
15: 0

此外,我正在显示一些自定义的THREE.js点云,这些云对于某些摄影机视点是隐藏的。仅当我尚未在Forge中加载任何合适的SVF模型时,才会发生这种情况。

请注意,我正在加载“不可见三角形”的SVF模型以初始化伪造查看器,以便能够在不加载任何适当SVF的情况下查看自定义点云。然后,三角形应跨越整个场景。这曾经与6.4.1一起使用。

关于如何使此功能适用于6.5.2版的任何想法?

修改 在投影矩阵中获取无穷大值时,以下是一些相机参数:

camera: {
    ...
    far: 0.07279428289764538,
    near: 0.07279428289764538,
    matrix: Z.Matrix4
        elements: Float32Array(16)
        0: 0.7071067690849304 1: -0.7071067690849304 2: 1.2355465983659997 e-8 3: 0 4: 0.09901473671197891 5: 0.0990147516131401 6: 0.9901475310325623 7: 0 8: -0.7001400589942932 9: -0.7001400589942932 10: 0.1400279998779297 11: 0 12: 335.91473388671875 13: 307.50555419921875 14: 103.9164047241211 15: 1
     projectionMatrix: Z.Matrix4
       elements: Float32Array(16)
       0: 1.491671085357666 1: 0 2: 0 3: 0  4: 0 5: 1.7320507764816284 6: 0 7: 0 8: 0 9: 0 10: -Infinity 11: -1 12: 0 13: 0 14: -Infinity 15: 0 
     fov: 60, 
     position: Z.Vector3
       x: 338.37971488661725
       y: 309.97052196410925
       z: 103.42340670070932

    quaternion: Z.Quaternion
       w: 0.6975223178288207
       x: 0.6058184615827841
       y: -0.250938228461858
       z: -0.288923200051608

    scale: Z.Vector3
       x: 1
       y: 1
       z: 1
}


查看器以以下方式加载:


Autodesk.Viewing.Document.load(urn_base_64, (doc) => {
     const viewables = Autodesk.Viewing.Document
                    .getSubItemsWithProperties(doc.getRootItem(), {'type': 'geometry'}, true);

    const initialViewable = viewables[0];
    const svfUrl = doc.getViewablePath(initialViewable);
    let mat = new THREE.Matrix4();
    mat.compose(globalOffset, new THREE.Quaternion(), scale);

    const modelOptions = {
        applyScaling: {to: 'm'},
        placementTransform: mat,
        worldUpVector: new THREE.Vector3(0, 0, 1),
        sharedPropertyDbPath: doc.getPropertyDbPath(),
    };

    viewer.start(svfUrl, modelOptions,
         (model) => {
         ... 
    })

此处的svf表示一个.obj模型,该模型由(-1 -1 -1)(1, 1, 1)处的两个三角形组成。 scaleVector3 {x: 132, y: 240, z: 59},而globalOffsetVector3 {x: 403, y: 330, z: 103.5}。 目的是偏移和缩放两个三角形,以整个场景为中心,其宽度,深度和高度等于globalOffset,以scale为中心。

0 个答案:

没有答案