potree的API说明文档

Potree


 

.version

 major: 1,

 minor: 5,

 suffix: "RC"

.pointBudget

 1*1000*1000

.Webgl

 shaders: {},

 vaos: {},

 vbos: {}

.scriptPath

 null

.startQuery(name, gl)

 @return:query

.endQuery (query, gl)

 

.resolveQueries (gl)

 

.loadPointCloud (path, name, callback)

 @return: {type: "pointcloud_loaded", pointcloud: pointcloud}

.updatePointClouds (pointclouds, camera, renderer)

@return:{visibleNodes: visibleNodes,      numVisiblePoints: numVisiblePoints,       lowestSpacing: lowestSpacing };

.updateVisibility (pointclouds, camera, renderer)

@return:{visibleNodes: visibleNodes,      numVisiblePoints: numVisiblePoints,       lowestSpacing: lowestSpacing };

.updateDEMs (renderer, visibleNodes)

 

.Shader(vertexShader, fragmentShader, program, uniforms)

.VBO(name, id, attribute)

.VAO(id, geometry, vbos)

.compileShader(gl, vertexShader, fragmentShader)

@return: Potree.Shader();

.createVAO(gl, geometry)

@return: Potree.VAO();

.renderPointcloud(pointcloud, camera, renderer)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.PointCloudTreeNode


 

getChildren():

getBoundingBox():

isLoaded():

isGeometryNode():

isTreeNode():

getLevel():

getBoundingSphere():

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.PointCloudTree

 


 

extends THREE.Object3D()

 

initialized():

@return this.root !== null;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

/**

 * @class Loads mno files and returns a PointcloudOctree

 * for a description of the mno binary file format, read mnoFileFormat.txt

 *

 * @author Markus Schuetz

 */

.POCLoader


 

load (url, callback):

/**

 * @return a point cloud octree with the root node data loaded.

 * loading of descendants happens asynchronously when they're needed

 *

 * @param url

 * @param loadingFinishedListener executed after loading the binary has been finished

 */

loadPointAttributes(mno):

@return Potree.PointAttributes()

createChildAABB(aabb, childIndex):

@return THREE.Box3()

 

 

 

 

 

 

 

 

 

 

/**

 * A single point attribute such as color/normal/.. and its data format/number of elements/...

 *

 * @class

 * @param name

 * @param type

 * @param size

 * @returns

 */

.PointAttribute


 

POSITION_CARTESIAN:

RGBA_PACKED

COLOR_PACKED

NORMAL_FLOATS

FILLER_1B

INTENSITY

CLASSIFICATION

NORMAL_SPHEREMAPPED

NORMAL_OCT16

NORMAL

 

 

 

 

 

 

 

 

/**

 * Ordered list of PointAttributes used to identify how points are aligned in a buffer.

 *

 * @class

 *

 */

.PointAttributes


 

属性:

attributes = [];

byteSize = 0;

size = 0;

方法:

add(pointAttribute):

hasColors():

@return: ture/false

hasNormals ():

@return: ture/false

 

 

 

 

 

 

 

 

 /**

  * 加载二进制文件

  *

  * @class

  * @param version

  * @param boundingBox

  * @param scale

  * @returns

 */

.BinaryLoader


 

属性:

VersionboundingBoxscale

方法:

load(node)

 

parse(node, buffer)

 

 

 

 

 

 

 

 

 

 /**

  * 加载二进制文件(las格式或者laz格式)

  *

  * @class

  * @param version

 * @returns

 */

LasLazLoader

 


 

属性

Version

方法

load(node)

parse(node, buffer)

 

 

 

 

 

 

 

 

 

 

 

 

 /**

  * 点云材质

  *

  * @class

  * @param parameters

 * @returns

 */

THREE.Material.call( this );继承自THREE.Matrial

.PointCloudMaterial 


 

属性

visibleNodesTexturenew THREE.DataTexture();

pointSizesize || 1.0

minSizeminSize || 1.0;

maxSizemaxSize || 50.0

_pointSizeType  {OCTREE:0,KDTREE:1}

_pointShape {SQUARE: 0,CIRCLE: 1};

_interpolatetrue/false;

_pointColorType {RGB:0, COLOR:1,DEPTH: 2,HEIGHT: 3,ELEVATION: 3,INTENSITY:    4,INTENSITY_GRADIENT:5,LOD: 6,LEVEL_OF_DETAIL:6,POINT_INDEX: 7,CLASSIFICATION: 8,   RETURN_NUMBER: 9,      SOURCE: 10,NORMAL: 11,PHONG: 12,RGB_HEIGHT: 13,      COMPOSITE: 50}

_useClipBoxtrue/false;

numClipBoxes0;

_clipMode{DISABLED: 0,  CLIP_OUTSIDE: 1,HIGHLIGHT_INSIDE: 2}

_weightedtrue/false;

_depthMap null

_gradient{RAINBOW: [[0, new THREE.Color(0.278, 0, 0.714)],[1/6, new THREE.Color(0, 0, 1)],[2/6, new THREE.Color(0, 1, 1)],[3/6, new THREE.Color(0, 1, 0)],[4/6, new THREE.Color(1, 1, 0)],[5/6, new THREE.Color(1, 0.64, 0)],[1, new THREE.Color(1, 0, 0)]  ],

        GRAYSCALE: [ [0, new THREE.Color(0,0,0)],     [1, new THREE.Color(1,1,1)]]

};

_classification{

                 "DEFAULT": {

                              0:                   new THREE.Vector4(0.5, 0.5,0.5, 1.0),

                              1:                   new THREE.Vector4(0.5, 0.5,0.5, 1.0),

                              2:                   new THREE.Vector4(0.63, 0.32, 0.18, 1.0),

                              3:                   new THREE.Vector4(0.0, 1.0, 0.0, 1.0),

                              4:                   new THREE.Vector4(0.0, 0.8, 0.0, 1.0),

                              5:                   new THREE.Vector4(0.0, 0.6, 0.0, 1.0),

                              6:                   new THREE.Vector4(1.0, 0.66, 0.0, 1.0),

                              7:                    new THREE.Vector4(1.0, 0, 1.0, 1.0),

                              8:                   new THREE.Vector4(1.0, 0, 0.0, 1.0),

                              9:                   new THREE.Vector4(0.0, 0.0, 1.0, 1.0),

                              12:                  new THREE.Vector4(1.0, 1.0, 0.0, 1.0),

                              "DEFAULT": new THREE.Vector4(0.3, 0.6, 0.6, 0.5)

                       }

                    };

gradientTexture: new THREE.Texture();

classificationTexture: new THREE.DataTexture( );

lights: true/false;

fog: true/false;

_useEDL: true/false;

attributes:{};

uniforms:{};

vertexShader:

fragmentShader:

vertexColors: THREE.VertexColors;

 

方法

 

PointCloudMaterial.prototype = new THREE.RawShaderMaterial()

updateShaderSource():

getDefines():返回预定义的shader

setClipBoxesclipBoxes):

gradient.get():返回THREE.Texture()

gradient.set (value):

classification.get():返回THREE.Texture()

classification.set(value):

spacing.get():返回uniforms.spacing.value

spacing.set(value):

useClipBox.get():返回_useClipBox

useClipBox.set(value):

weighted.get():返回_weighted

weighted.set(value):

fov.get():返回uniforms.fov.value

fov.set(value):

screenWidth.get():返回uniforms.screenWidth.value

screenWidth.set(value):

screenHeight.get():返回uniforms.screenHeight.value

screenHeight.set(value):

等等。。。

/**

 * Generates a look-up texture for gradient values (height, intensity, ...)

 *

 */

generateGradientTexture(gradient)

/**

 * Generates a look up texture for classification colors

 *

 */

generateClassificationTexture (classification)

 

 

 

 

 

 

 

 

 

 

 

 

 

/**

 *

 * @class A doubly-linked-list of the least recently used elements.

 */

LRU


 

属性

// the least recently used item

first :叶子节点;

       // the most recently used item

       last 根节点;

       // a list of all items in the lru list

       items  { LRUItem};

       elements : 0;

       numPoints : 0;

方法

          size ()

       @return  this.elements;

            contains (node):

       @return true/false;

            touch(node):

       /**

 * makes node the most recently used item. if the list does not contain node, it will be added.

* @param node

 */

remove(node):

* removes the least recently used item from the list

getLRUItem():

@return this.first.node

freeMemory ():

当点云数量大于最大加载数量限制时,从最后的叶子节点开始释放内存

disposeDescendants (node)

删除当前节点

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.PointCloudOctreeNode

 


 

extends Potree.PointCloudTreeNode

属性

children:

sceneNode:

octree:

方法

getNumPoints()

   @return numPoints

isLoaded():

   @return true/false

isTreeNode():

@return true/false

isGeometryNode():

   @return true/false

getLevel():

@return level

getBoundingSphere():

   @return boundingSphere

getBoundingBox():

   @return boundingBox

getChildren():

   @return 八个叶子

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.PointCloudOctree


 

extends Potree.PointCloudTree

属性

pcoGeometry : geometry;

   boundingBox : .pcoGeometry.boundingBox;

   boundingSphere : .boundingBox.getBoundingSphere();

   material : material || new Potree.PointCloudMaterial();

   visiblePointsTarget : 2*1000*1000;

   minimumNodePixelSize : 150;

   level : 0;    

   showBoundingBox : false;

   boundingBoxNodes : [];

   loadQueue : [];

   visibleBounds : new THREE.Box3();   

   visibleNodes : [];

   visibleGeometry : [];

   pickTarget : null;

   generateDEM : false;

   profileRequests : [];

   name : ""; 

   // TODO read projection from file instead

   projection : geometry.projection;

   root : .pcoGeometry.root;

方法

   setName(name)

   getName()

   @return name

   toTreeNode(geometryNode, parent):

   @return PointCloudOctreeNode()

   updateVisibleBounds():

   根据叶子节点的boundingBox,重新计算visibleBounds

   updateMaterial(material, visibleNodes, camera, renderer):

   更新材质

   updateVisibilityTexture(material, visibleNodes):

   更新材质所需的texture

nodeIntersectsProfile(node, profile):

判断node与轮廓之间的相交关系

nodesOnRay(nodes, ray)

返回被射线穿过的node

updateMatrixWorld( force )

是否强制更新模型坐标系

hideDescendants(object)

隐藏对象的所有子节点

moveToOrigin()

移动至起始点

moveToGroundPlane()

移动至物体表面

getBoundingBoxWorld()

返回包围盒子

getPointsInProfile(profile, maxDepth, callback)

/**    * returns points inside the profile points

   * maxDepth:           search points up to the given octree depth

   * The return value is an array with all segments of the profile path

   *  var segment = {

   *          start:     THREE.Vector3,

   *          end:      THREE.Vector3,

   *          points: {}

   *          project: function()

   *  };

   * The project() function inside each segment can be used to transform

   * that segments point coordinates to line up along the x-axis.

    */

getProfile(start, end, width, depth, callback)

/**

   * returns points inside the given profile bounds.

   * start:      

   * end:       

   *     

   * depth:            search points up to the given octree depth

   * callback: if specified, points are loaded before searching

   */

getVisibleExtent()

可视范围

pick(renderer, camera, ray, params = {})

/**

   * params.pickWindowSize: Look for points inside a pixel window of this size.

   *                                             Use odd values: 1, 3, 5, ...

    * TODO: only draw pixels that are actually read with readPixels().

   */

 

 

 

 

 

 

 

 

 

 

 

 

.PointCloudOctreeGeometry 


 

属性

url : null;

  octreeDir : null;

  spacing : 0;

  boundingBox : null;

  root : null;

  numNodesLoading : 0;

  nodes : null;

  pointAttributes : null;

  hierarchyStepSize : -1;

  loader : null;

 

 

 

 

 

 

 

 

 

.PointCloudOctreeGeometryNode


 

@param name

@param pcoGeometry

@param boundingBox

属性

id :  number;

  name : name;

  index : 索引;

  pcoGeometry : pcoGeometry;

  geometry : null;

  boundingBox : boundingBox;

  boundingSphere : boundingBox.getBoundingSphere();

  children : {};

  numPoints : 0;

  level : null;

  loaded : false;

  oneTimeDisposeHandlers : [];

  IDCount 0

方法

Object.create(Potree.PointCloudTreeNode.prototype)

isGeometryNode():

@return true

getLevel ()

@return level

isTreeNode ()

@return false

isLoaded ()

@return true/false

getBoundingSphere ()

@return boundingSphere

getBoundingBox ()

@return boundingBox

getChildren ()

@return children[8]

getURL ()

@return url

getHierarchyPath ()

@return path

addChild (child)

向该Geometry添加“子Geometry”

load ()

数据加载

loadPoints  ()

if(fMno.pointAttributes === "LAS"){

         pco.loader = new Potree.LasLazLoader(fMno.version);

  }else if(fMno.pointAttributes === "LAZ"){

         pco.loader = new Potree.LasLazLoader(fMno.version);

  }else{

         pco.loader = new Potree.BinaryLoader(fMno.version, boundingBox, fMno.scale);

         pco.pointAttributes = new Potree.PointAttributes(pco.pointAttributes);

  }

loadHierachyThenPoints  ()

先加载hrc文件后加载点数据

getNumPoints ()

@return numPoints

dispose  ()

清空geometry

 

 

 

 

 

 

 

 

 

 

 

 

.utils 


 

方法

toString(value)

 

normalizeURL(url)

标准化url

pathExists(url)

判断路径是否正确

computeTransformedBoundingBox(box, transform)

@return boundingBox

addCommas(nStr)

对于较大的数据,添加分离器

createWorker(code)

* create worker from a string

loadSkybox(path)

加载天空盒子

createGrid(width, length, spacing, color)

创建格网,返回line

createBackgroundTexture(width, height)

创建背景图片,返回texture

getMousePointCloudIntersection(mouse, camera, renderer, pointclouds)

@return  {location: closestIntersection,  distance: closestDistance,    pointcloud: selectedPointcloud}  or  null

pixelsArrayToImage(pixels, width, height)

@return new Image()

projectedRadius(radius, fov, distance, screenHeight)

topView(camera, node)

俯视图

frontView(camera, node)

前视图

leftView (camera, node)

左视图

rightView (camera, node)

右视图

frustumSphereIntersection(frustum, sphere)

   * 0: no intersection

   * 1: intersection

   * 2: fully inside

generateDataTexture(width, height, color)

生成texture

getParameterByName(name)

setParameter(name, value)

 

 

.View


 

属性

position  new THREE.Vector3(0, 0, 0);     

  yaw  Math.PI / 4;

  _pitch  -Math.PI / 4;

  radius  1;         

  maxPitch  Math.PI / 2;

  minPitch  -Math.PI / 2;      

  navigationMode  Potree.OrbitControls;

方法

clone()

@return new Potree.View()

Pitch

Direction

lookAt(t)

改变相机观看方向

getPivot()

getSide()

pan(x, y)

translate(x, y, z)

translateWorld(x, y, z)

 

.Scene

extends THREE.EventDispatcher

属性

annotations  [];

  scene  new THREE.Scene();

  scenePointCloud  new THREE.Scene();

  sceneBG  new THREE.Scene();

  camera  new THREE.PerspectiveCamera(fov, 1, 0.1, 1000*1000);

  cameraBG  new THREE.Camera();

  pointclouds  [];            

  measurements  [];

  profiles  [];

  volumes  [];     

  view  new Potree.View();

  directionalLight  null;

 

方法

addPointCloud(pointcloud)

  pointclouds.push(pointcloud);scenePointCloud.add(pointcloud);

addVolume(volume)

  volumes.push(volume)

removeVolume(volume)

volumes.splice(index, 1)

   addMeasurement(measurement)

        measurements.push(measurement)

removeMeasurement(measurement)

  measurements.splice(index, 1)

addProfile(profile)

  profiles.push(profile)

removeProfile(profile)

  profiles.splice(index, 1)

removeAllMeasurements()

  移除全部的measurement和profile

initialize()

  初始化scene

addAnnotation(position, args = {})

  annotations.push(annotation)

@return annotation

   getAnnotations()

@return annotations

 

 

 

 

 .Viewer


@param domElement

@param args

属性

renderArea  domElement;

   fov  60;

   pointSize  1;

   minPointSize  1;

   maxPointSize  50;

   opacity  1;

   sizeType  "Fixed";

   pointSizeType  Potree.PointSizeType.FIXED;

   pointColorType  null;

   clipMode  Potree.ClipMode.HIGHLIGHT_INSIDE;

   quality  "Squares";

   isFlipYZ  false;

   useDEMCollisions  false;

   minNodeSize  100;

   edlStrength  1.0;

   edlRadius  1.4;

   useEDL  false;

   intensityMax  null;

   heightMin  0;

   heightMax  1;

   materialTransition  0.5;

   weightRGB  1.0;

   weightIntensity  0.0;

   weightElevation  0.0;

   weightClassification  0.0;

   weightReturnNumber  0.0;

   weightSourceID  0.0;

   intensityRange  [0, 65000];

   intensityGamma  1;

   intensityContrast  0;

   intensityBrightness  0;

   rgbGamma  1;

   rgbContrast  0;

   rgbBrightness  0;

   moveSpeed  10;

   showDebugInfos  false;

   showStats  false;

   showBoundingBox  false;

   freeze  false;

   progressBar  new ProgressBar();

   stats  new Stats();

   potreeRenderer  null;

   highQualityRenderer  null;

   edlRenderer  null;

   renderer  null;

   scene  null;

   inputHandler  null;

   measuringTool  null;

   profileTool  null;

   volumeTool  null;

   transformationTool  null;

   skybox  null;

   clock  new THREE.Clock();

   background  null;   

   inputHandler  new Potree.InputHandler(this);

measuringTool  new Potree.MeasuringTool(this);

   profileTool  new Potree.ProfileTool(this);

   volumeTool new Potree.VolumeTool(this);

   transformationTool new Potree.TransformationTool(this);

方法

setScene(scene)

  设置scene

getControls(navigationMode)

  return orbitControls / fpControls / earthControls / null;

getMinNodeSize()

@return minNodeSize

setMinNodeSize(value)

设置最小节点值

getBackground()

@return background

setBackground(bg)

设置背景

setDescription(value)

setNavigationMode(value)

设置漫游模式

setShowBoundingBox(value)

设置显示盒子大小

getShowBoundingBox ()

@return showBoundingBox

setMoveSpeed(value)

设置鼠标控制灵敏度

getMoveSpeed ()

@return moveSpeed

setHeightRange(min, max)

设置高度范围

getHeightRange ()

@return {min: this.heightMin, max: this.heightMax}

setIntensityRange(min, max)

设置强度范围

getIntensityRange ()

@return intensityRange

setIntensityGamma (value)

设置强度伽玛值

getIntensityGamma ()

@return getIntensityGamma

setIntensityContrast (value)

设置强度对比度

getIntensityContrast ()

@return intensityContrast

setIntensityBrightness (value)

设置强度亮度

getIntensityBrightness ()

@return intensityBrightness

setRGBGamma (value)

设置RGB伽玛值

getRGBGamma ()

@return rgbGamma

setRGBContrast (value)

设置RGB对比度

getRGBContrast ()

@return rgbContrast

setRGBBrightness (value)

设置RGB亮度

getRGBBrightness ()

@return rgbBrightness

setMaterialTransition(t)

设置材质的转变方式

getMaterialTransition ()

@return materialTransition

setWeightRGB(w)

设置RGB权重

getWeightRGB ()

@return weightRGB

setWeightIntensity(w)

设置Intensity权重

getWeightIntensity ()

@return weightIntensity

setWeightElevation(w)

设置Elevation权重

getWeightElevation ()

@return weightElevation

setWeightClassification(w)

设置Classification权重

getWeightClassification ()

@return weightClassification

setWeightReturnNumber(w)

设置weightReturnNumber权重

getWeightReturnNumber ()

@return weightReturnNumber

setWeightSourceID(w)

设置weightSourceID权重

getWeightSourceID ()

@return weightSourceID

setIntensityMax(max)

设置intensityMax

getIntensityMax ()

@return intensityMax

setFreeze(value)

设置freeze

getFreeze ()

@return freeze

setPointBudget(value)

设置pointBudget

getPointBudget ()

@return pointBudget

setClipMode(clipMode)

设置clipMode

getClipMode ()

@return clipMode

setDEMCollisionsEnabled(value)

设置useDEMCollisions

getDEMCollisionsEnabled ()

@return useDEMCollisions

setEDLEnabled (value)

设置useEDL

getEDLEnabled ()

@return useEDL

setEDLRadius (value)

设置edlRadius

getEDLRadius ()

@return edlRadius

setEDLStrength (value)

设置edlStrength

getEDLStrength ()

@return edlStrength

setPointSize (value)

设置pointSize

getPointSize ()

@return pointSize

setMinPointSize (value)

设置minPointSize

getMinPointSize ()

@return minPointSize

setMaxPointSize (value)

设置maxPointSize

getMaxPointSize ()

@return maxPointSize

setFOV (value)

设置fov

getFOV ()

@return fov

setOpacity (value)

设置opacity

getOpacity ()

@return opacity

setPointSizing (value)

设置sizeType

getPointSizing ()

@return sizeType

setQuality (value)

设置quality

getQuality ()

@return quality

disableAnnotations ()

enableAnnotations() ()

setMaterial (value)

设置maxPointSize

setClassificationVisibility(key, value)

@return maxPointSize

setMaterialID (value)

设置maxPointSize

getMaterial ()

@return pointColorType

toMaterialID(materialName)

toMaterialName(materialID)

zoomTo(node, factor)

getBoundingBox(pointclouds)

@return box

fitToScreen(factor = 1)

setTopView()

setFrontView()

setLeftView()

setRightView()

flipYZ()

updateHeightRange()

loadSettingsFromURL()

createControls()

toggleSidebar()

toggleMap()

loadGUI(callback)

setLanguage(lang)

initThree()

update(delta, timestamp)

loop(timestamp)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PotreeRenderer


 

@param viewer

方法

render()