How-to guide·3D viewerJavaScript

Show point clouds

Upload an E57, LAS or LAZ point cloud (COPC included) and stream it into the 3D viewer next to an IFC model, with the upload settings for unit, colour and intensity.

A point cloud is uploaded as an E57, LAS or LAZ file. LAZ includes COPC, the cloud-optimised layout, and BIM.works decodes the LASzip compression itself. Whatever the format, the result is the same octree, which the 3D viewer streams as you move the camera, at the density the view needs. This guide shows a scan next to the model it was taken of.

Live demo#

A construction scan alongside the IFC modelLive demo
Uses the Schependomlaan IFC model and your choice of the E57 or LAS / LAZ construction scan in the Demo folder. The LAS / LAZ option uses Schependomlaan/Schependomlaan.las when available. Open BIM.works and sign in once in this browser.

The IFC model loads first. Choose E57 or LAS / LAZ from Point cloud to load the scan alongside it, or None to see the IFC on its own. The scan was captured during construction: compare the work in progress with the IFC model. Points stream in while you navigate; the status line says when the octree is loading.

1. Upload the point cloud#

Upload the file like any model (Upload a model). The upload accepts format settings for point clouds: the unit, the colour source, the colour bit depth, the intensity range, which classifications to include, whether withheld points are excluded, and a default colour. The effective settings are kept in the model metadata.

A LAS file does not record its unit. When it has no coordinate system record either, BIM.works reads an extent no point cloud has in metres as millimetres and says so in the model's warnings; the upload dialog of the app has a unit field for .las and .laz files for the cases that guess gets wrong.

Every LASzip flavour in use is read: compressors 1, 2 and 3, item versions 1 to 4, point formats 0 to 10, fixed and variable chunk tables, extended variable-length records. A file that is mislabelled is recognised by its content, not its extension. The decoder splits the chunk table over the cores of the server, so a few hundred million points decode in minutes.

2. Load it next to the model#

The point cloud loads through the ModelManager like any version and streams with the same dynamic-loading callbacks whatever its format. Colour, intensity and classification come along.

const factory = new BimWorksClientFactory("https://bim.works");
const client = await factory.createClientWithApiToken("<your API token>");
const ifcVersionUuid = "<version uuid of the first demo model>";

// First we make sure that the PointCloud model has actually been loaded in BIM.works, if it is not, we download it from https://bimbase.nl

var pointCloudNode;
pointCloudNode = await client.fs.getNodeByPath("/Schependomlaan/Schependomlaan.e57");

// The ModelManager is responsible for keeping track of which models are 
// loaded/unloaded
const modelManager = new ModelManager(client);

// The ObjectStateManager is responsible for keeping track of certain states of 
// loaded objects such as visibility, color, selection
const objectStateManager = new ObjectStateManager(modelManager);

// Create a new Viewer3d
const viewer = new Viewer3d(objectStateManager, {
	dynamicLoadStarted: (version) => {
		console.log("Dynamic load started");
	},
	dynamicLoadStopped: (version) => {
		console.log("Dynamic load stopped");
	}

});

await viewer.initializeViewer();

// Add the canvas to the body of the page, so we can see it
document.body.appendChild(viewer.container);

const promises = [];

// Get a bit more information about the node version and tell the ModelManager to load it
promises.push(client.fs.getNodeVersion(ifcVersionUuid).then((version) => {
	return modelManager.addModels([version]);
}));

promises.push(client.fs.getNodeVersion(pointCloudNode.last_version_uuid).then((version) => {
	return modelManager.addModels([version]);
}));

Promise.all(promises).then(() => {
	// Both models have now been loaded, we then focus the camera on only the IFC file
	objectStateManager.viewFitModels([ifcVersionUuid], {
		margin: 5,
		animate: true
	});
});

Loads an IFC model and a point cloud into one viewer and fits the camera to the model. The dynamicLoadStarted and dynamicLoadStopped callbacks of the viewer fire while the octree streams.

Limits#

PLY uploads are rejected for now and XYZ text files are not read. A LAZ with an unknown coder or an item version outside 1 to 4 is refused with a message that says so. A point cloud has no objects, so it is not queryable and cannot be picked.

Check#

The scan appears around the model and gets denser where you move the camera; dynamicLoadStarted and dynamicLoadStopped fire while it streams.

Since 3.0