xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
715 stars 286 forks source link

Extend LASLoaderPlugin and convert2xkt to auto-align LAS/LAZ models from info in header #1147

Closed xeolabs closed 5 months ago

xeolabs commented 11 months ago

When loading a LAS/LAZ file (especially alongside a BIM model), we want to automatically position and align the point cloud within xeokit's double-precision coordinate system.

To do this, we need to read the position/alignment info from the LAS header, then set that on the SceneModel position and rotation properties.

We can read that info using the las-header library.

We want to do this within LasLoaderPlugin, and also within convert2xkt (in @xeokit/xeokit-convert) when converting LAS/LAZ to XKT.

xeolabs commented 11 months ago

I can now extract information from the LAS header (see example JSON below), and can also dynamically transform models loaded from both LAS and XKT/IFC - @Amoki in your experience of working with LAS scans, does anything come to mind concerning how to automatically align scans with IFC models as we load them, using the LAS header information and IFC metadata?

{
    "publicHeaderBlock": {
        "CreationDay": 87,
        "CreationYear": 2017,
        "FileSignature": "LASF",
        "FileSoureceID": 0,
        "GeneratingSoftware": "las2las (version 180706)",
        "GlobalEncoding": 0,
        "HeaderSize": 227,
        "MaxX": 5.63,
        "MaxY": 7.55,
        "MaxZ": 12.36,
        "MinX": -22.990000000000002,
        "MinY": -1.97,
        "MinZ": -7.9,
        "NumberOfPointByReturn": 808042,
        "NumberOfPoints": 808042,
        "NumberOfVariableLengthRecords": 1,
        "OffsetToPointData": 333,
        "OffsetX": 0,
        "OffsetY": 0,
        "OffsetZ": 0,
        "PointDataFormatID": 131,
        "PointDataRecordLength": 34,
        "ScaleFactorX": 0.01,
        "ScaleFactorY": 0.01,
        "ScaleFactorZ": 0.01,
        "SystemIdentifier": "LAStools (c) by rapidlasso GmbH",
        "VersionMajor": 1,
        "VersionMinor": 2,
        "epsg": "undefined",
        "variableLengthRecords": -1,
        "variableRecords": [
            {
                "Description": "by laszip of LAStools (180706)",
                "RecordId": 22204,
                "RecordLengthAfterHeader": 52,
                "Reserved": 43707,
                "UserId": "laszip encoded"
            }
        ]
    }
}
Amoki commented 11 months ago

"epsg": "undefined", Your LAS is not positioned. If an epsg is defined, then you have to translate both epsg (las and ifc) in the same world coordinates (e.g. Marc Antoine Petit uses https://epsg.io/4326 but without explicitly saying it with an IfcProjectedCRS).

xeolabs commented 11 months ago

@Amoki yes it seems that the sample LAS I used had no such information. Do you happen to have any sample IFC and LAS files that I could use to develop with?

Amoki commented 11 months ago

Unfortunately, no. We did not work on this yet.