Ply file loading

Ply files (containing ‘point clouds’) are the output of many photogrammetric reconstruction algorithms (for example COLMAP. You can view them quickly in Meshlab or Field, using this code here:

// import load ply
var LoadPly = Java.type("trace.graphics.LoadPly")

// load something
var ply = new LoadPly("/Users/marc/Desktop/Organ_800k_text.ply")

// make a layer
var layer = _.stage.withName("asdf")

// that's fully 3d
layer.is3D = true
layer.vrDefaults()
layer.makeKeyboardCamera()

var f = new FLine()

// for all of the points...
for(var p of ply.points)
{
	f.moveTo(p.at.y, p.at.x, p.at.z)
	f.last().color = vec(p.color.x, p.color.y, p.color.z, 1)
}

f.pointed=true
f.pointSize=0.3
layer.lines.f = f

This will put a colored point-cloud onto a stage with a camera that you can drive around with the keyboard.