feat(viewer): adds pointcloud support

This commit is contained in:
Dimitrie Stefanescu
2021-05-13 18:48:47 +01:00
parent 0ee8c86504
commit 1567c341ae
2 changed files with 81 additions and 3 deletions
@@ -50,7 +50,13 @@ export default class SceneObjectManager {
} )
this.lineMaterial = new THREE.LineBasicMaterial( { color: 0x7F7F7F } )
this.pointMaterial = new THREE.PointsMaterial( { size: 10, sizeAttenuation: false, color: 0x7F7F7F } )
this.pointMaterial = new THREE.PointsMaterial(
{ size: 2, sizeAttenuation: false, color: 0x7F7F7F }
)
this.pointVertexColorsMaterial = new THREE.PointsMaterial( {
size: 2, sizeAttenuation: false, vertexColors: true
} )
this.objectIds = []
this.postLoad = debounce( () => { this._postLoadFunction() }, 200 )
@@ -64,7 +70,7 @@ export default class SceneObjectManager {
}
get materials() {
return [ this.lineMaterial, this.pointMaterial, this.transparentMaterial, this.solidMaterial, this.solidVertexMaterial ]
return [ this.lineMaterial, this.pointMaterial, this.transparentMaterial, this.solidMaterial, this.solidVertexMaterial, this.pointVertexColorsMaterial ]
}
// Note: we might switch later down the line from cloning materials to solely
@@ -130,6 +136,10 @@ export default class SceneObjectManager {
case 'point':
this.addPoint( wrapper )
break
case 'pointcloud':
this.addPointCloud( wrapper )
break
}
this.postLoad()
@@ -160,13 +170,42 @@ export default class SceneObjectManager {
}
addPoint( wrapper ){
var dot = new THREE.Points( wrapper.bufferGeometry, this.pointMaterial )
let dot = new THREE.Points( wrapper.bufferGeometry, this.pointMaterial )
dot.userData = wrapper.meta
dot.uuid = wrapper.meta.id
this.objectIds.push( dot.uuid )
this.pointObjects.add( dot )
}
addPointCloud( wrapper ) {
let clouds
if ( wrapper.bufferGeometry.attributes.color ) {
clouds = new THREE.Points( wrapper.bufferGeometry, this.pointVertexColorsMaterial )
} else if ( wrapper.meta.renderMaterial ) {
let renderMat = wrapper.meta.renderMaterial
let color = new THREE.Color( this._argbToRGB( renderMat.diffuse ) )
this._normaliseColor( color )
let material = this.pointMaterial.clone()
material.clippingPlanes = this.viewer.interactions.sectionBox.planes
material.color = color
clouds = new THREE.Points( wrapper.bufferGeometry, material )
} else {
clouds = new THREE.Points( wrapper.bufferGeometry, this.pointMaterial )
}
clouds.userData = wrapper.meta
clouds.uuid = wrapper.meta.id
this.objectIds.push( clouds.uuid )
this.pointObjects.add( clouds )
}
removeObject( id ) {
// TODO
}