|
@@ -58,7 +58,90 @@ export const enter = (dom, isLocal) => {
|
|
|
info.unit = units[unit]
|
|
|
return info
|
|
|
}
|
|
|
+ let getMeasureFunction = function (measure, bus) {
|
|
|
+
|
|
|
+ measure.addEventListener('highlight',(e)=>{
|
|
|
+ bus.emit('highlight', e.state)
|
|
|
+ })
|
|
|
+ measure.addEventListener('marker_dropped',(e)=>{//拖拽结束后发送changeCallBack
|
|
|
+ if (measure.parent) {
|
|
|
+ //未被删除
|
|
|
+ bus.emit('update',[
|
|
|
+ measure.dataset_points.map(p=>p.clone()) ,
|
|
|
+ measure.points_datasets
|
|
|
+ ])
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return {
|
|
|
+ /* quit: () => {
|
|
|
+ Potree.Log('quit结束且删除: ' + measure.id, '#00c7b2')
|
|
|
+ viewer.dispatchEvent({ type: 'cancel_insertions', remove: true, measure })
|
|
|
+ }, //触发结束。退出测量模式,清除之前操作 */
|
|
|
+ destroy: () => {
|
|
|
+ viewer.dispatchEvent({ type: 'cancel_insertions', remove: true, measure })
|
|
|
+ viewer.scene.removeMeasurement(measure)
|
|
|
+ },
|
|
|
+
|
|
|
+ /* getPoints: () => {
|
|
|
+ return measure.points
|
|
|
+ },
|
|
|
+ getDatasetLocations: () => {
|
|
|
+ return measure.dataset_points
|
|
|
+ },
|
|
|
+ getDatasets: () => {
|
|
|
+ return measure.points_datasets
|
|
|
+ },
|
|
|
+ getDatasetId: () => {
|
|
|
+ return measure.datasetId
|
|
|
+ }, */
|
|
|
|
|
|
+ getArea: () => {
|
|
|
+ return measure.area //{value:area, string:..}
|
|
|
+ },
|
|
|
+ getDistance: () => {
|
|
|
+ if (measure.points.length < 2) return null
|
|
|
+
|
|
|
+ var value = measure.points[0].distanceTo(measure.points[1])
|
|
|
+
|
|
|
+ return {
|
|
|
+ value, //米
|
|
|
+ string: viewer.unitConvert.convert(value, 'distance', void 0, measure.unitSystem, 0.1, true),
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* changeUnit: unit => {
|
|
|
+ //公制|英制 , 1 | 2 单位
|
|
|
+ measure.setUnitSystem(units[unit])
|
|
|
+ },
|
|
|
+ toDataURL: (width, height) => {
|
|
|
+ //截图
|
|
|
+ isScreenshoting = true
|
|
|
+ var promise = viewer.startScreenshot({ type: 'measure', measurement: measure, hideMarkers: true }, width, height)
|
|
|
+ promise.done(() => {
|
|
|
+ isScreenshoting = false
|
|
|
+ })
|
|
|
+ return promise
|
|
|
+ }, */
|
|
|
+ //手动开启或关闭:
|
|
|
+ show: () => {
|
|
|
+ viewer.updateVisible(measure, 'inListByUser', true)
|
|
|
+ },
|
|
|
+ hide: () => {
|
|
|
+ viewer.updateVisible(measure, 'inListByUser', false)
|
|
|
+ },
|
|
|
+ fly(){
|
|
|
+ let result = viewer.focusOnObject(measure.object, 'measure', 1200 )
|
|
|
+
|
|
|
+ return result.msg ? result.msg : result.promise
|
|
|
+ //返回值 1 deferred 表示即将位移 2 'posNoChange' 表示已在最佳位置 3 'tooFar' 表示距离最佳位置太远
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ changeSelect(isHight){
|
|
|
+ measure.setSelected(isHight, 'byList')
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -683,7 +766,7 @@ export const enter = (dom, isLocal) => {
|
|
|
// 寻创建的测量对象有上面绘画测量对象的所有方法
|
|
|
const bus = mitt()
|
|
|
let info = getMeasureType(type)
|
|
|
-
|
|
|
+
|
|
|
|
|
|
let measure = viewer.measuringTool.startInsertion(
|
|
|
info,
|
|
@@ -711,18 +794,16 @@ export const enter = (dom, isLocal) => {
|
|
|
)
|
|
|
Potree.Log('startMeasure: ' + measure.id, '#00c7b2')
|
|
|
|
|
|
- let cancel = ()=>{
|
|
|
+ /* let cancel = ()=>{
|
|
|
Potree.Log('clear删除: ' + measure.id, '#00c7b2')
|
|
|
viewer.dispatchEvent({ type: 'cancel_insertions', remove: true, measure })
|
|
|
viewer.scene.removeMeasurement(measure)
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
let result = {
|
|
|
bus,
|
|
|
|
|
|
- destroy(){
|
|
|
- cancel()
|
|
|
- },
|
|
|
+ ...getMeasureFunction(measure, bus),
|
|
|
}
|
|
|
|
|
|
/* StartMeasure = Measure & {
|
|
@@ -770,46 +851,7 @@ export const enter = (dom, isLocal) => {
|
|
|
|
|
|
let result = {
|
|
|
bus,
|
|
|
- destroy(){
|
|
|
- //删除
|
|
|
- Potree.Log('clear删除: ' + measure.id, '#00c7b2')
|
|
|
-
|
|
|
- viewer.scene.removeMeasurement(measure)
|
|
|
- },
|
|
|
-
|
|
|
- show(){
|
|
|
- viewer.updateVisible(measure, 'inListByUser', true)
|
|
|
- },
|
|
|
-
|
|
|
- hide(){
|
|
|
- viewer.updateVisible(measure, 'inListByUser', false)
|
|
|
- },
|
|
|
-
|
|
|
- fly(){
|
|
|
- let result = viewer.focusOnObject(measure.object, 'measure', 1200 )
|
|
|
-
|
|
|
- return result.msg ? result.msg : result.promise
|
|
|
- //返回值 1 deferred 表示即将位移 2 'posNoChange' 表示已在最佳位置 3 'tooFar' 表示距离最佳位置太远
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- changeSelect(isHight){
|
|
|
- measure.setSelected(isHight, 'byList')
|
|
|
- },
|
|
|
-
|
|
|
- getArea: () => {
|
|
|
- return measure.area //{value:area, string:..}
|
|
|
- },
|
|
|
- getDistance: () => {
|
|
|
- if (measure.points.length < 2) return null
|
|
|
-
|
|
|
- var value = measure.points[0].distanceTo(measure.points[1])
|
|
|
-
|
|
|
- return {
|
|
|
- value, //米
|
|
|
- string: viewer.unitConvert.convert(value, 'distance', void 0, measure.unitSystem, 0.1, true),
|
|
|
- }
|
|
|
- },
|
|
|
+ ...getMeasureFunction(measure, bus),
|
|
|
}
|
|
|
return result
|
|
|
},
|