|
@@ -133,6 +133,9 @@ const notify = (areas, num, str )=>{ //num: 0-1
|
|
|
str == 'loadpoints' && Potree.settings.isTest && console.log('notify pro', p, str)
|
|
|
deferred.notify(p)
|
|
|
curPercent = p
|
|
|
+ if(isNaN(p)){
|
|
|
+ console.log('nan')
|
|
|
+ }
|
|
|
}
|
|
|
setTimeout(resolve, delayForNotify)
|
|
|
})
|
|
@@ -170,7 +173,7 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
this.material = new ExtendPointCloudMaterial();
|
|
|
|
|
|
- this.material.activeAttributeName = "rgba"// testPoint ? "rgba" : 'heightCpt' ;// 'rgba' indices prismHeight
|
|
|
+ this.material.activeAttributeName = testPoint ? "rgba" : 'heightCpt' ;// 'rgba' indices prismHeight
|
|
|
|
|
|
this.prisms = []
|
|
|
|
|
@@ -205,13 +208,18 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
})
|
|
|
|
|
|
|
|
|
-
|
|
|
+ let this_ = this
|
|
|
this.events = {
|
|
|
- transfromCallback:()=>{
|
|
|
- let object = viewer.transformationTool.selection[0]
|
|
|
- if(object == this.baseModel){
|
|
|
- this.updateModelBound()
|
|
|
- }
|
|
|
+ transformCallback: ()=>{
|
|
|
+ if(!this_.currentPrism)return
|
|
|
+ //Common.intervalTool.isWaiting('volCptTransformed', ()=>{ //延时update,防止卡顿
|
|
|
+ let object = viewer.transformationTool.selection[0]
|
|
|
+ if(object == this_.currentPrism.baseModel ){
|
|
|
+ this.updateModelBound({modelChange:true})
|
|
|
+ }
|
|
|
+ this_.currentPrism.dispatchEvent('needsCompute') //模型变动或clipBox变动后要重算
|
|
|
+ //}, 1000)
|
|
|
+
|
|
|
},
|
|
|
}
|
|
|
}
|
|
@@ -225,16 +233,17 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
Potree.settings.rotAroundPoint = false
|
|
|
|
|
|
//viewer.objs.traverse(e=>e.material && ( e.material = this.material))
|
|
|
- viewer.transformationTool.addEventListener('transformed', this.events.transfromCallback)
|
|
|
-
|
|
|
+ viewer.transformationTool.addEventListener('stopDrag', this.events.transformCallback)
|
|
|
+ viewer.transformationTool.addEventListener('changeByHistory', this.events.transformCallback)
|
|
|
}
|
|
|
|
|
|
leave(){
|
|
|
this.entered = false
|
|
|
Potree.settings.rotAroundPoint = this.oldStates.rotAroundPoint
|
|
|
- this.setCurrentPrismAndModel(null)
|
|
|
+ this.setCurrentPrism(null)
|
|
|
|
|
|
- viewer.transformationTool.removeEventListener('transformed', this.events.transfromCallback)
|
|
|
+ viewer.transformationTool.removeEventListener('stopDrag', this.events.transformCallback)
|
|
|
+ viewer.transformationTool.removeEventListener('changeByHistory', this.events.transformCallback)
|
|
|
}
|
|
|
|
|
|
add(prism){
|
|
@@ -246,14 +255,14 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
i>-1 && this.prisms.splice(i,1)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ cancel(){
|
|
|
+ if(this.computingObject){
|
|
|
+ interrupt = true
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
startCompute(model,dontCompute){//test
|
|
|
this.enter();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
let deferred = $.Deferred()
|
|
|
deferred.done((e)=>{
|
|
|
console.log('done', e)
|
|
@@ -265,43 +274,38 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
console.log('progress', e)
|
|
|
}) */
|
|
|
if(model){
|
|
|
- this.setCurrentPrismAndModel(this.prisms[this.prisms.length-1], model)
|
|
|
- dontCompute || this.compute(this.prisms[this.prisms.length-1], model)
|
|
|
+ this.prisms[this.prisms.length-1].setBaseModel(model)
|
|
|
+ this.setCurrentPrism(this.prisms[this.prisms.length-1])
|
|
|
+ dontCompute || this.compute(this.prisms[this.prisms.length-1])
|
|
|
}else{
|
|
|
this.compute(this.prisms[this.prisms.length-1], deferred )
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- cancel(){
|
|
|
- if(this.computingObject){
|
|
|
- interrupt = true
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
- setCurrentPrismAndModel(prism, model){//当进入单个prism编辑后才会高亮点云
|
|
|
-
|
|
|
-
|
|
|
+ setCurrentPrism(prism ){//当进入单个prism编辑后才会高亮点云
|
|
|
if(this.currentPrism){
|
|
|
this.currentPrism.removeEventListeners('updated')
|
|
|
- }
|
|
|
-
|
|
|
- if(!model || !prism){
|
|
|
- return //this.setModelMat(this.baseModel, 'recover')
|
|
|
- }
|
|
|
-
|
|
|
- this.baseModel = model
|
|
|
- this.currentPrism = prism
|
|
|
- this.setModelMat(model )
|
|
|
+ }
|
|
|
+ this.currentPrism = prism //允许没有model
|
|
|
+ if(!prism || !prism.baseModel/* || !prism.baseModel.visible */){
|
|
|
+ viewer.scene.pointclouds.forEach(e=>{
|
|
|
+ this.updateMatForModel(e.material ) //取消高亮
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
prism.addEventListener('updated',()=>{
|
|
|
+ if(this.currentPrism != prism){
|
|
|
+ return console.log('currentPrism changed? 侦听没删除')
|
|
|
+ }
|
|
|
this.updateModelBound()
|
|
|
})
|
|
|
|
|
|
|
|
|
- this.updateModelBound()
|
|
|
+ this.updateModelBound({regetMap:true})
|
|
|
|
|
|
}
|
|
|
|
|
@@ -314,29 +318,45 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
|
|
|
- updateModelBound(){
|
|
|
- let model = this.baseModel
|
|
|
+ updateModelBound({modelChange, regetMap}={}){ //regetMap是在更换currentPrism必须重绘map,但不需要needUpdate
|
|
|
let prism = this.currentPrism
|
|
|
+ let model = this.currentPrism.baseModel
|
|
|
+
|
|
|
+ if(!model)return
|
|
|
model.currentBound = model.boundingBox.clone().applyMatrix4(model.matrixWorld) //作用同prismBound
|
|
|
let oldBound = model.clipBound && model.clipBound.clone()
|
|
|
|
|
|
model.clipBound = model.currentBound.clone()//高亮范围
|
|
|
- model.clipBound.min.max(prism.prismBound.min)
|
|
|
+ model.clipBound.min.max(prism.prismBound.min)//xy为交集
|
|
|
model.clipBound.max.min(prism.prismBound.max)
|
|
|
- model.clipBound.min.z = Math.min(model.currentBound.min.z, prism.prismBound.min.z)
|
|
|
+ model.clipBound.min.z = Math.min(model.currentBound.min.z, prism.prismBound.min.z)//z为并集,范围覆盖prism点、点云、model三者
|
|
|
model.clipBound.max.z = Math.max(model.currentBound.max.z, prism.prismBound.max.z)
|
|
|
this.modelMat.uniforms.boundZ.value.set(model.clipBound.min.z,model.clipBound.max.z)
|
|
|
|
|
|
-
|
|
|
- if(!oldBound || !oldBound.equals(model.clipBound)){
|
|
|
- model.baseHeightAreaMap = this.getModelHeightMap()//包含cad在俯视中的范围 + 高度信息
|
|
|
- //this.setModelMat(model,this.overBound ? 'recover' : null)
|
|
|
-
|
|
|
- viewer.scene.pointclouds.forEach(e=>{//暂时先只支持一个高亮区域
|
|
|
- this.updateMatForModel(e.material, model)
|
|
|
- })
|
|
|
-
|
|
|
+ let boundChanged = !oldBound || !oldBound.equals(model.clipBound)
|
|
|
+
|
|
|
+ let boundSize = this.currentPrism.baseModel.clipBound.getSize(new THREE.Vector3)
|
|
|
+ this.boundSizeZero = boundSize.x<=0 ||boundSize.y<=0 || boundSize.z<=0 //会造成renderTarget尺寸为0,背景变白,报错:Framebuffer is incomplete: Attachment has zero size 和 The texture is a non-power-of-two texture.
|
|
|
+
|
|
|
+
|
|
|
+ if( (modelChange || regetMap || boundChanged) && !this.boundSizeZero){
|
|
|
+ this.setModelHeightMap()//包含cad在俯视中的范围 + 高度信息
|
|
|
+ //this.setModelMat(model,this.boundSizeZero ? 'recover' : null)
|
|
|
}
|
|
|
+ viewer.scene.pointclouds.forEach(e=>{//暂时先只支持一个高亮区域
|
|
|
+ this.updateMatForModel(e.material, model)
|
|
|
+ })
|
|
|
+
|
|
|
+ //需要重新渲染modelHeightmap的情况:bound改变、模型变动、更换currentPrism后
|
|
|
+ //注意,即使上传几种都没发生,仅仅移动prism的marker也要重算,假设一个marker在model范围内,移动后bound可能不变但体积肯定变。
|
|
|
+ /* if(boundChanged){
|
|
|
+ if(prism.recoverNeedCptNextTime){
|
|
|
+ prism.needsCompute = 'byVolume' //初始化,有volume就不用重算
|
|
|
+ prism.recoverNeedCptNextTime = false
|
|
|
+ }else{
|
|
|
+ prism.dispatchEvent('needsCompute')
|
|
|
+ }
|
|
|
+ } */
|
|
|
|
|
|
}
|
|
|
|
|
@@ -344,7 +364,7 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
updateMatForModel(material, model){
|
|
|
let oldMap = material.uniforms.baseHeightAreaMap.value
|
|
|
if(model){
|
|
|
- material.uniforms.baseHeightAreaMap.value = model.baseHeightAreaMap ;
|
|
|
+ material.uniforms.baseHeightAreaMap.value = this.renderTarget2.texture //model.baseHeightAreaMap ;
|
|
|
material.uniforms.baseHeightBoundZ.value.set(model.clipBound.min.z,model.clipBound.max.z)
|
|
|
material.uniforms.baseHeightBoundXY.value.set(model.clipBound.min.x, model.clipBound.max.x, model.clipBound.min.y, model.clipBound.max.y)
|
|
|
}else{
|
|
@@ -359,23 +379,25 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
- getModelHeightMap(){
|
|
|
- let oldTarget = viewer.renderer.getRenderTarget()
|
|
|
- let oldParent = this.baseModel.parent
|
|
|
-
|
|
|
+ setModelHeightMap(){
|
|
|
|
|
|
-
|
|
|
- let boundSize = this.baseModel.clipBound.getSize(new THREE.Vector3)
|
|
|
- if(boundSize.x<=0||boundSize.y<=0||boundSize.z<=0){
|
|
|
- this.overBound = true
|
|
|
- return
|
|
|
- }
|
|
|
- this.overBound = false
|
|
|
+ let oldTarget = viewer.renderer.getRenderTarget()
|
|
|
+ let oldParent = this.currentPrism.baseModel.parent
|
|
|
+ let oldVisi = this.currentPrism.baseModel.visible
|
|
|
|
|
|
|
|
|
- let boundCenter = this.baseModel.clipBound.getCenter(new THREE.Vector3)
|
|
|
+ let boundSize = this.currentPrism.baseModel.clipBound.getSize(new THREE.Vector3)
|
|
|
+
|
|
|
+ let boundCenter = this.currentPrism.baseModel.clipBound.getCenter(new THREE.Vector3)
|
|
|
let {w, h} = this.getResByBound(boundSize,'forModel')
|
|
|
|
|
|
+ if(w<=0 || h<=0){
|
|
|
+ return console.error('w<=0 || h<=0!!!!!!!!!', w,h)
|
|
|
+ }
|
|
|
+
|
|
|
+ /* w = THREE.Math.floorPowerOfTwo( w );
|
|
|
+ h = THREE.Math.floorPowerOfTwo( h ); */ //for warning:The texture is a non-power-of-two texture
|
|
|
+
|
|
|
this.camera.far = boundSize.z + 10
|
|
|
this.camera.right = w / 2
|
|
|
this.camera.left = -this.camera.right
|
|
@@ -386,44 +408,49 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
viewer.renderer.setRenderTarget(this.renderTarget2);
|
|
|
|
|
|
- console.log('getModelHeightMap')
|
|
|
+ console.log('setModelHeightMap')
|
|
|
|
|
|
//最高处朝下看
|
|
|
|
|
|
let endPosition = new THREE.Vector3
|
|
|
|
|
|
- endPosition.copy(boundCenter).setZ(this.baseModel.clipBound.max.z + this.camera.near+0.1)
|
|
|
+ endPosition.copy(boundCenter).setZ(this.currentPrism.baseModel.clipBound.max.z + this.camera.near+0.1)
|
|
|
this.view.pitch = -Math.PI / 2;
|
|
|
|
|
|
this.view.moveOrthoCamera(this.viewport, {boundSize , endPosition }, 0)
|
|
|
this.view.applyToCamera(this.camera)
|
|
|
- this.scene.add(this.baseModel)
|
|
|
+ this.scene.add(this.currentPrism.baseModel)
|
|
|
+ this.setModelMat(this.currentPrism.baseModel)
|
|
|
+ this.currentPrism.baseModel.visible = true;
|
|
|
|
|
|
-
|
|
|
- let gl = viewer.renderer.getContext();
|
|
|
- gl.clearColor(0, 0, 0, 0);
|
|
|
- viewer.renderer.clear(true, true, true);
|
|
|
+ let gl = viewer.renderer.getContext();
|
|
|
+ viewer.renderer.setClearColor(new THREE.Color('#000'), 0);
|
|
|
+ viewer.renderer.clear()
|
|
|
|
|
|
viewer.renderer.render(this.scene,this.camera)
|
|
|
-
|
|
|
+ this.setModelMat(this.currentPrism.baseModel, 'recover')
|
|
|
|
|
|
|
|
|
let pixelCount = this.renderTarget2.width * this.renderTarget2.height
|
|
|
buffer2 = new Uint8Array(4 * pixelCount);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
//因为需要渲染完立即readPixels才能获取到,所以只能这时候就read了
|
|
|
gl.readPixels(0, 0, this.renderTarget2.width , this.renderTarget2.height, gl.RGBA, gl.UNSIGNED_BYTE, buffer2); //这句花费最多时间 pc:2-4, 即使只有1*1像素
|
|
|
- modelZs = [] //等待计算
|
|
|
+ modelZs = [] //等待计算
|
|
|
|
|
|
if(window.needDownload) {
|
|
|
let dataUrl = Potree.Utils.renderTargetToDataUrl(this.renderTarget2, this.renderTarget2.width, this.renderTarget2.height, viewer.renderer)
|
|
|
Common.downloadFile(dataUrl, (name || 'screenshot') + '-' + Date.now() +'.png')
|
|
|
}
|
|
|
- oldParent.add(this.baseModel)
|
|
|
+ oldParent.add(this.currentPrism.baseModel)
|
|
|
+
|
|
|
+ this.currentPrism.baseModel.visible = oldVisi
|
|
|
+
|
|
|
viewer.renderer.setRenderTarget(oldTarget);
|
|
|
|
|
|
- this.renderTarget2.texture.needsRebuild = true //renderTarget在resize后会触发dispose, 然后 _gl.deleteTexture( textureProperties.__webglTexture )所以需要重新建立
|
|
|
+
|
|
|
+ this.renderTarget2.texture.needsRebuild = true //renderTarget在resize后会触发dispose, 然后 _gl.deleteTexture( textureProperties.__webglTexture )所以需要重新建立 否则图片变黑
|
|
|
return this.renderTarget2.texture
|
|
|
}
|
|
|
|
|
@@ -433,8 +460,8 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
getResByBound(boundSize, type){
|
|
|
- let pxPerMetric = math.linearClamp(Math.max(boundSize.x,boundSize.y), [4, 10, 20, 80, 500, 2000], [300, 200, 100, 30, 6, 3])
|
|
|
-
|
|
|
+ //let pxPerMetric = math.linearClamp(Math.max(boundSize.x,boundSize.y), [4, 10, 20, 80, 500, 2000], [300, 200, 100, 30, 6, 3])
|
|
|
+ let pxPerMetric = math.linearClamp(Math.max(boundSize.x,boundSize.y), [ 10, 60, 100, 500, 2000], [150, 60, 40, 6, 3])
|
|
|
let w = pxPerMetric * boundSize.x, h = boundSize.y * pxPerMetric
|
|
|
|
|
|
let cW = 1 , cH = 1 //横向纵向渲染次数 超过maxWidth时分批渲染
|
|
@@ -461,25 +488,39 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
//法1:只用一个顶部相机(当挖方遮挡填方时不准,但好算)
|
|
|
- async compute(prism, model, deferred_, getResolveResult){
|
|
|
+ async compute(prism, deferred_, getResolveResult){
|
|
|
if(!prism)return console.log('无prism?')
|
|
|
if(this.computingObject) return console.log('正在计算,请稍等')
|
|
|
|
|
|
+ let oldCurPrism = this.currentPrism
|
|
|
+ if(prism != this.currentPrism){//在列表外点击计算
|
|
|
+ this.setCurrentPrism(prism)
|
|
|
+ }
|
|
|
|
|
|
- if(model && this.overBound){
|
|
|
+ let computeDone = ({highest,lowest,Vupper,Vlower}, deferred )=>{
|
|
|
prism && prism.setVolumeInfo({
|
|
|
- highest:0,lowest:0,Vupper:0,Vlower:0,
|
|
|
+ highest,lowest,Vupper,Vlower
|
|
|
})
|
|
|
+
|
|
|
+ if(oldCurPrism != prism){
|
|
|
+ this.setCurrentPrism(oldCurPrism)
|
|
|
+ }
|
|
|
+
|
|
|
deferred && deferred.resolve(getResolveResult && getResolveResult())
|
|
|
-
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
- deferred = deferred_
|
|
|
- timestamp = Date.now()
|
|
|
+ }
|
|
|
+
|
|
|
+ if(prism.baseModel && this.boundSizeZero){ //bound没有交集 或 prism的boundsize为0
|
|
|
+ return computeDone({highest:0,lowest:0,Vupper:0,Vlower:0}, deferred_ )
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- this.computingObject = {prism, model}
|
|
|
|
|
|
+ this.computingObject = {prism, model: prism.baseModel}
|
|
|
+ deferred = deferred_
|
|
|
|
|
|
|
|
|
|
|
@@ -505,22 +546,23 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
viewer.mapViewer && (viewer.mapViewer.viewports[0].active = true )
|
|
|
viewer.magnifier.viewport.active = true
|
|
|
viewer.pauseTestMaxLevel = false
|
|
|
- console.log('pxPerMetric',pxPerMetric, 'boundSize',boundSize)
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- let startTime = Date.now()
|
|
|
-
|
|
|
- let pointcloud = viewer.scene.pointclouds[0]
|
|
|
|
|
|
|
|
|
+ let pointcloud = viewer.scene.pointclouds[0]
|
|
|
let center = new THREE.Vector3
|
|
|
let boundSize = new THREE.Vector3
|
|
|
- let bound
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(!model){
|
|
|
+ let bound
|
|
|
+ let gl = viewer.renderer.getContext();
|
|
|
+ let statesBefore = {
|
|
|
+ mode: Potree.settings.displayMode,
|
|
|
+ pointDensity:Potree.settings.pointDensity
|
|
|
+ }
|
|
|
+ timestamp = Date.now()
|
|
|
+
|
|
|
+ if(!this.computingObject.model){
|
|
|
horizonZ = prism.horizonZ
|
|
|
zMin = prism.zMin
|
|
|
zMax = prism.zMax
|
|
@@ -529,9 +571,9 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
bound.expandByPoint(prism.points[i])
|
|
|
}
|
|
|
}else{
|
|
|
- zMin = model.clipBound.min.z
|
|
|
- zMax = model.clipBound.max.z
|
|
|
- bound = model.clipBound
|
|
|
+ zMin = this.computingObject.model.clipBound.min.z
|
|
|
+ zMax = this.computingObject.model.clipBound.max.z
|
|
|
+ bound = this.computingObject.model.clipBound
|
|
|
|
|
|
//读取model的高度
|
|
|
for (let u = 0; u < this.renderTarget2.width; u++) {
|
|
@@ -555,6 +597,12 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
bound.getCenter(center)
|
|
|
bound.getSize(boundSize)
|
|
|
+
|
|
|
+ this.boundSizeZero = boundSize.x<=0 ||boundSize.y<=0 || boundSize.z<=0 //prism的问题
|
|
|
+ if(this.boundSizeZero){
|
|
|
+ computeDone({highest:0,lowest:0,Vupper:0,Vlower:0}, deferred )
|
|
|
+ return computeFinish('finish', true)
|
|
|
+ }
|
|
|
center.z = zMax + this.camera.near + 0.1
|
|
|
this.camera.far = zMax - zMin + 10
|
|
|
|
|
@@ -576,11 +624,7 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
wDelta = boundSize.x / (w * cW )
|
|
|
sDelta = Math.pow(wDelta, 2)
|
|
|
|
|
|
- //准备
|
|
|
- let statesBefore = {
|
|
|
- mode: Potree.settings.displayMode,
|
|
|
- pointDensity:Potree.settings.pointDensity
|
|
|
- }
|
|
|
+ //准备
|
|
|
Potree.settings.displayMode = 'showPointCloud'
|
|
|
Potree.settings.pointDensity = 'screenshot'
|
|
|
viewer.mainViewport.active = false //暂停渲染,否则影响这边点云的加载
|
|
@@ -590,18 +634,21 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
{//material
|
|
|
|
|
|
- if(!model){
|
|
|
+ if(!this.computingObject.model){
|
|
|
//this.material.shape = Potree.PointShape.PARABOLOID;//加上之后depth出错,后排点云会挡前排,可pick时为什么不会?
|
|
|
|
|
|
this.updateMatForModel(this.material, null) //计算时的shader这两种类型只能选一个,要么prism要么model,只能渲染一块区域
|
|
|
//this.material.opacity = 1;
|
|
|
}else{
|
|
|
- this.updateMatForModel(this.material, model)
|
|
|
+ this.updateMatForModel(this.material, this.computingObject.model)
|
|
|
//this.material.opacity = 0.9; //为了输出透明度,负数高度的alpha是0.5
|
|
|
|
|
|
}
|
|
|
- this.material.setClipBoxes(null,[],[],[],[prism])
|
|
|
- this.material.pointSizeType = 'ADAPTIVE' //node会自动根据的其level更改点大小
|
|
|
+ let clipBoxes_out = prism.clipBoxes.map(box=>{return {inverse:box.matrixWorld.clone().invert(), box}} )
|
|
|
+ this.material.setClipBoxes(null,[], clipBoxes_out,[],[prism])
|
|
|
+
|
|
|
+
|
|
|
+ this.material.pointSizeType = 'FIXED' //'ADAPTIVE' //node会自动根据的其level更改点大小 使用ADAPTIVE后会使baseModelMap整片是黑的,原因未知
|
|
|
this.material.uniforms.minSize.value = 0.1
|
|
|
this.material.uniforms.orthoMaxSize.value = 5; //px
|
|
|
|
|
@@ -610,7 +657,7 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
this.material.shaderNeedsUpdate = true
|
|
|
pointcloud.updateMaterial(this.material, null, this.camera, viewer.renderer, this.viewport.resolution);
|
|
|
|
|
|
- this.material.size = this.getPointsize(pointcloud.maxLevel) //0.025 米 //视图缩小(截图面积变大)后点会自动缩小,但至少是1个像素大小
|
|
|
+ this.material.size = 1//this.getPointsize(pointcloud.maxLevel) //0.025 米 //视图缩小(截图面积变大)后点会自动缩小,但至少是1个像素大小
|
|
|
|
|
|
}
|
|
|
|
|
@@ -618,7 +665,7 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
- let gl = viewer.renderer.getContext();
|
|
|
+
|
|
|
|
|
|
viewer.renderer.state.buffers.depth.setTest(this.material.depthTest);
|
|
|
viewer.renderer.state.buffers.depth.setMask(this.material.depthWrite);
|
|
@@ -659,7 +706,8 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
this.view.pitch = -Math.PI / 2;
|
|
|
let endPosition = new THREE.Vector3(center.x + (i-cW/2+0.5) * boundSize_.x, center.y + (j-cH/2+0.5) * boundSize_.y, center.z)
|
|
|
this.view.moveOrthoCamera(this.viewport, {boundSize: boundSize_, endPosition }, 0)
|
|
|
- await this.render({i,j,index:1,cW,cH, infos, /* maxLevels, */ notifyArea:[[progressStart, progressEnd],[0,0.4]], computeFinish })
|
|
|
+ let endPercent = this.computingObject.model ? 0.7 : 0.4
|
|
|
+ await this.render({i,j,index:1,cW,cH, infos, /* maxLevels, */ notifyArea:[[progressStart, progressEnd],[0,endPercent]], computeFinish })
|
|
|
|
|
|
|
|
|
if(interrupt){
|
|
@@ -668,7 +716,7 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
- if(!model){
|
|
|
+ if(!this.computingObject.model){
|
|
|
//水平面朝下看,找填方
|
|
|
this.view.position.z = horizonZ + this.camera.near
|
|
|
await this.render({i,j,index:2, cW,cH, infos, /* maxLevels, */ notifyArea:[[progressStart, progressEnd], [0.4, 0.7]], computeFinish})
|
|
@@ -895,20 +943,18 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
Vupper += c.Vupper; Vlower += c.Vlower;
|
|
|
fillVlower += c.fillVlower; fillVupper += c.fillVupper;
|
|
|
})
|
|
|
-
|
|
|
- prism && prism.setVolumeInfo({
|
|
|
- highest,lowest,Vupper,Vlower,
|
|
|
- })
|
|
|
-
|
|
|
- let endTime = Date.now()
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+ computeDone({
|
|
|
+ highest,lowest,Vupper,Vlower,
|
|
|
+ }, deferred)
|
|
|
|
|
|
|
|
|
+ computeFinish('finish', true)
|
|
|
|
|
|
- deferred && deferred.resolve(getResolveResult && getResolveResult())
|
|
|
|
|
|
- computeFinish('finish', true)
|
|
|
- console.log( {Vupper,Vlower, oldVupper: Vupper - fillVupper, oldVlower: Vlower - fillVlower, highest,lowest, horizonZ, wDelta}, results, this.viewport.resolution, {cW,cH}, 'cost:', endTime-startTime)//firefox用时是chrome两倍,edge和chrome差不多
|
|
|
+ console.log( {Vupper,Vlower, oldVupper: Vupper - fillVupper, oldVlower: Vlower - fillVlower, highest,lowest, horizonZ, wDelta}, results, this.viewport.resolution, {cW,cH}, 'cost:', Date.now()-timestamp, 'pxPerMetric', pxPerMetric, 'boundSize',boundSize )//firefox用时是chrome两倍,edge和chrome差不多
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1158,7 +1204,7 @@ export default class VolumeComputer extends THREE.EventDispatcher{
|
|
|
|
|
|
getPointsize(maxLevel){//尽量铺满 size单位是米,需要和点云缝隙同宽
|
|
|
|
|
|
- return 0.2
|
|
|
+ return 0.01 /* adaptive:0.2 */
|
|
|
|
|
|
|
|
|
|