Search code examples
autodesk-viewerautodesk-model-derivative

Incorrect origins for IFC models


I've loaded two models: the FZK Haus model and RAC sample model available below.

They are both IFC4 models with no georeferencing data. I.e. very simple 0,0,0 origin with no map conversions. They should look like this relative to one another (shown via Xeokit):

enter image description here

If I translate them using the default settings, i.e.:

        json_data = {
            "input": {"urn": urn},
            "output": { "formats": [ { "type": "svf2", "views": ["2d", "3d"], } ] }
        }

Then I get the result below. Notice how the FZK house is placed incorrectly relative to the RAC model.

enter image description here

If I translate them using the recommended latest v3 converter, i.e.:

        json_data = {
            "input": {"urn": urn},
            "output": {
                "formats": [
                    {
                        "type": "svf2",
                        "views": ["2d", "3d"],
                        "advanced": {
                            "conversionMethod": "v3",
                            "buildingStoreys": "show",
                        }
                    }
                ]
            }}

Then I get this origin instead, where the FZK house is floating above the RAC model.

enter image description here

Sample models to help testing:


Solution

  • Even if you don't use geo-referencing, the Model Derivative conversion may still apply certain offset, typically to move geometry closer to origin to avoid precision issues. You can override this behavior by setting the global offset to (0,0,0) when loading a model:

    function loadModel(viewer, urn, options) {
        return new Promise(function (resolve, reject) {
            function onDocumentLoadSuccess(doc) {
                resolve(viewer.loadDocumentNode(doc, doc.getRoot().getDefaultGeometry(), options));
            }
            function onDocumentLoadFailure(code, message, errors) {
                reject({ code, message, errors });
            }
            Autodesk.Viewing.Document.load('urn:' + urn, onDocumentLoadSuccess, onDocumentLoadFailure);
        });
    }
    
    await loadModel(viewer, URN1, {
        applyScaling: 'm',
        globalOffset: new THREE.Vector3(0, 0, 0)
    });
    await loadModel(viewer, URN2, {
        keepCurrentModels: true,
        preserveView: true,
        applyScaling: 'm',
        globalOffset: new THREE.Vector3(0, 0, 0)
    });
    

    screenshot