Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-station-module-view
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
station
amos-station-module-view
Commits
029270c7
Commit
029270c7
authored
Jun 10, 2020
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修改多线程
parent
65a1bc65
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
29 deletions
+106
-29
3dService.js
mods/components/3dviewConvertor/services/3dService.js
+11
-4
index.json
...mponents/3dviewConvertor/threeres/models/yinan/index.json
+0
-0
View3D.js
mods/components/3dviewConvertor/view/View3D.js
+40
-21
conf.js
mods/components/3dviewConvertor/view/conf.js
+4
-4
dataProcessor.js
mods/components/3dviewConvertor/view/dataProcessor.js
+51
-0
No files found.
mods/components/3dviewConvertor/services/3dService.js
View file @
029270c7
...
@@ -3,6 +3,8 @@ import * as helper from 'base-r3d/lib/utils/helper';
...
@@ -3,6 +3,8 @@ import * as helper from 'base-r3d/lib/utils/helper';
import
{
FscSerUrl
,
FasSerUrl
}
from
'./../consts/urlConsts'
;
import
{
FscSerUrl
,
FasSerUrl
}
from
'./../consts/urlConsts'
;
import
{
commonGet
,
commonPost
,
singleFetch
}
from
'./../utils/request'
;
import
{
commonGet
,
commonPost
,
singleFetch
}
from
'./../utils/request'
;
import
{
encodeUrl
}
from
'amos-tool'
;
//---------------- 加载模型、解析模型json -----------
//---------------- 加载模型、解析模型json -----------
export
const
getObjFromNet
=
(
url
,
callback
)
=>
{
export
const
getObjFromNet
=
(
url
,
callback
)
=>
{
return
singleFetch
(
url
).
then
(
data
=>
{
return
singleFetch
(
url
).
then
(
data
=>
{
...
@@ -10,10 +12,15 @@ export const getObjFromNet = (url, callback) => {
...
@@ -10,10 +12,15 @@ export const getObjFromNet = (url, callback) => {
// 临时将 asyncModels 也放在主线程
// 临时将 asyncModels 也放在主线程
const
{
basePath
,
asyncModels
=
[]
}
=
data
;
const
{
basePath
,
asyncModels
=
[]
}
=
data
;
const
_asyncModels
=
asyncModels
.
map
(
m
=>
({
const
_asyncModels
=
asyncModels
.
map
(
m
=>
{
basePath
,
const
{
objName
,
mtlName
,
...
rest
}
=
m
;
...
m
return
{
}));
basePath
,
...
rest
,
objName
:
encodeUrl
(
objName
),
mtlName
:
encodeUrl
(
mtlName
)
};
});
// const _objs = objs.concat(_asyncModels);
// const _objs = objs.concat(_asyncModels);
callback
(
objs
,
_asyncModels
);
callback
(
objs
,
_asyncModels
);
...
...
mods/components/3dviewConvertor/threeres/models/yinan/index.json
View file @
029270c7
This diff is collapsed.
Click to expand it.
mods/components/3dviewConvertor/view/View3D.js
View file @
029270c7
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
PropTypes
from
'prop-types'
;
import
PropTypes
from
'prop-types'
;
import
{
utils
,
UUID
,
deepCopy
}
from
'amos-tool'
;
import
{
UUID
,
deepCopy
}
from
'amos-tool'
;
import
{
PubSub
}
from
'ray-eventpool'
;
import
{
PubSub
}
from
'ray-eventpool'
;
import
{
Connect
as
UIConnect
,
message
,
AmosAlert
,
Modal
}
from
'amos-framework'
;
import
{
Connect
as
UIConnect
,
message
}
from
'amos-framework'
;
import
{
FatLine
}
from
'amos-3d/lib/advanced'
;
import
{
FatLine
}
from
'amos-3d/lib/advanced'
;
import
A3DDesigner
,
{
Connect
,
FireObject
,
DESIGNER_CONSTS
,
PolygonRegion
}
from
'amos-3d/lib/designer'
;
import
A3DDesigner
,
{
Connect
,
FireObject
,
DESIGNER_CONSTS
,
PolygonRegion
}
from
'amos-3d/lib/designer'
;
import
WorkerObjContent
from
'amos-3d/lib/worker/WorkerObjContent'
;
import
WorkerObjContent
from
'amos-3d/lib/worker/WorkerObjContent'
;
...
@@ -13,9 +13,17 @@ import MaskContent from './MaskContent';
...
@@ -13,9 +13,17 @@ import MaskContent from './MaskContent';
import
{
getObjFromNet
,
initView3DAction
,
query3DStatistics
,
pointModelistAction
}
from
'../services/3dService'
;
import
{
getObjFromNet
,
initView3DAction
,
query3DStatistics
,
pointModelistAction
}
from
'../services/3dService'
;
import
{
desigerConf
,
desigerHelperConfig
}
from
'./conf'
;
import
{
desigerConf
,
desigerHelperConfig
}
from
'./conf'
;
import
PointsPool
from
'./PointsPool'
;
import
PointsPool
from
'./PointsPool'
;
import
PromptModal
from
'./PromptModal'
import
PromptModal
from
'./PromptModal'
;
import
{
eventTopics
,
isControllerEvent
,
isManualOperate
}
from
'./consts'
;
import
{
eventTopics
,
isControllerEvent
,
isManualOperate
}
from
'./consts'
;
import
{
executeView3dCMD
,
parseManual
,
parseBubbleMarkers
,
tirggerPlanTopic
,
tirggerTransTopic
}
from
'./dataProcessor'
;
import
{
executeView3dCMD
,
parseManual
,
parseBubbleMarkers
,
tirggerPlanTopic
,
tirggerTransTopic
,
cacheObjsSave
,
flyToSubView
}
from
'./dataProcessor'
;
import
{
import
{
dealTroubleMarkers
,
dealTroubleMarkers
,
assembleTroubleView
,
assembleTroubleView
,
...
@@ -32,7 +40,7 @@ import {
...
@@ -32,7 +40,7 @@ import {
flickerTroubleMarkers
flickerTroubleMarkers
}
from
'./ruleActionView'
;
}
from
'./ruleActionView'
;
import
{
lineData
}
from
'./datas'
;
import
{
lineData
}
from
'./datas'
;
import
{
getAreaTreeAction
,
getPointTypeAction
,
getPointTreeAction
,
getPointListAction
,
saveAreaDataAction
,
savePointListAction
}
from
'../services/moduleEditServices'
;
import
{
getAreaTreeAction
,
getPointTypeAction
,
getPointTreeAction
,
saveAreaDataAction
,
savePointListAction
}
from
'../services/moduleEditServices'
;
import
AreaLeftTree
from
'./moduleEditComponent/AreaLeftTree'
;
import
AreaLeftTree
from
'./moduleEditComponent/AreaLeftTree'
;
import
PointLeftTree
from
'./moduleEditComponent/PointLeftTree'
;
import
PointLeftTree
from
'./moduleEditComponent/PointLeftTree'
;
import
RightEditPointPanel
from
'./moduleEditComponent/RightEditPointPanel'
;
import
RightEditPointPanel
from
'./moduleEditComponent/RightEditPointPanel'
;
...
@@ -40,6 +48,7 @@ import RightEditRegionPanel from './moduleEditComponent/RightEditRegionPanel';
...
@@ -40,6 +48,7 @@ import RightEditRegionPanel from './moduleEditComponent/RightEditRegionPanel';
import
{
EVENTS_CONSTS
}
from
'../consts/EventConsts'
;
import
{
EVENTS_CONSTS
}
from
'../consts/EventConsts'
;
import
ExceptionArea
from
'./exceptionArea/ExceptionArea'
;
import
ExceptionArea
from
'./exceptionArea/ExceptionArea'
;
import
{
exceptionRegionListAction
,
getPointsByRegionIdAction
}
from
'../services/panoramicService'
;
import
{
exceptionRegionListAction
,
getPointsByRegionIdAction
}
from
'../services/panoramicService'
;
import
{
chunk
}
from
'../utils/MathUtils'
;
const
AmosConfig
=
endConf
.
AmosConfig
;
const
AmosConfig
=
endConf
.
AmosConfig
;
...
@@ -166,6 +175,8 @@ class View3D extends Component {
...
@@ -166,6 +175,8 @@ class View3D extends Component {
onMouseMove
:
this
.
onMouseMove
onMouseMove
:
this
.
onMouseMove
};
};
this
.
_marker
=
[];
this
.
_marker
=
[];
this
.
_cacheObj
=
{};
//3维模型对象缓存
this
.
processorLevel
=
{};
//3维模型对应关系缓存
}
}
componentDidMount
()
{
componentDidMount
()
{
...
@@ -261,6 +272,7 @@ class View3D extends Component {
...
@@ -261,6 +272,7 @@ class View3D extends Component {
this
.
lensJumpFactory
.
jumpRoot
(
obj
=>
{
this
.
lensJumpFactory
.
jumpRoot
(
obj
=>
{
this
.
lensJumpFactory
.
fadeIn
(
obj
);
this
.
lensJumpFactory
.
fadeIn
(
obj
);
});
});
this
.
outlineFactory
.
toggleOutline
([]);
//清除选中
this
.
lensLevel
=
LENS_LEVEL
.
ROOT
;
this
.
lensLevel
=
LENS_LEVEL
.
ROOT
;
}
}
});
});
...
@@ -268,7 +280,7 @@ class View3D extends Component {
...
@@ -268,7 +280,7 @@ class View3D extends Component {
_bindPubSubEvents
=
()
=>
{
_bindPubSubEvents
=
()
=>
{
this
.
props
.
subscribe
(
eventTopics
.
base3d_view
,
(
topic
,
data
)
=>
{
this
.
props
.
subscribe
(
eventTopics
.
base3d_view
,
(
topic
,
data
)
=>
{
console
.
log
(
'subscribe base3d_view'
)
console
.
log
(
'subscribe base3d_view'
+
data
);
if
(
isControllerEvent
(
topic
))
{
if
(
isControllerEvent
(
topic
))
{
executeView3dCMD
(
this
,
topic
,
data
);
executeView3dCMD
(
this
,
topic
,
data
);
}
else
if
(
isManualOperate
(
topic
))
{
}
else
if
(
isManualOperate
(
topic
))
{
...
@@ -467,7 +479,7 @@ class View3D extends Component {
...
@@ -467,7 +479,7 @@ class View3D extends Component {
});
});
};
};
onGraphCreated
=
({
cameraFactory
,
sceneFactory
,
outlineFactory
,
r3d
,
stagePilot
})
=>
{
onGraphCreated
=
({
cameraFactory
,
sceneFactory
,
outlineFactory
,
r3d
,
stagePilot
})
=>
{
this
.
cameraFactory
=
cameraFactory
;
this
.
cameraFactory
=
cameraFactory
;
this
.
sceneFactory
=
sceneFactory
;
this
.
sceneFactory
=
sceneFactory
;
this
.
outlineFactory
=
outlineFactory
;
this
.
outlineFactory
=
outlineFactory
;
...
@@ -492,7 +504,8 @@ class View3D extends Component {
...
@@ -492,7 +504,8 @@ class View3D extends Component {
onAllDone
=
objGroup
=>
{
onAllDone
=
objGroup
=>
{
this
.
sceneFactory
.
level
.
change
(
objGroup
);
this
.
sceneFactory
.
level
.
change
(
objGroup
);
this
.
stagePilot
.
rendererFactory
.
setupUModelSahdow
();
//接受阴影
// 接受阴影
this
.
stagePilot
.
rendererFactory
.
setupUModelSahdow
();
this
.
setState
({
this
.
setState
({
startAsyncLoad
:
true
startAsyncLoad
:
true
});
});
...
@@ -508,15 +521,15 @@ class View3D extends Component {
...
@@ -508,15 +521,15 @@ class View3D extends Component {
onComplete
=
obj
=>
{
onComplete
=
obj
=>
{
const
me
=
this
;
const
me
=
this
;
cacheObjsSave
(
me
,
obj
,
LENS_LEVEL
);
//缓存对象及对应关系
if
(
!
obj
.
isForceParent
)
{
if
(
!
obj
.
isForceParent
)
{
obj
.
on
(
'click'
,
evt
=>
{
obj
.
on
(
'click'
,
evt
=>
{
if
(
this
.
state
.
isEditMode
==
false
)
{
const
me
=
this
;
console
.
log
(
'obj click:'
,
evt
);
if
(
this
.
state
.
isEditMode
===
false
)
{
// this.focusPosition(evt.pickedPosition);
// this.focusPosition(evt.pickedPosition);
me
.
outlineFactory
.
toggleOutline
(
evt
.
object
);
me
.
outlineFactory
.
toggleOutline
(
evt
.
object
);
me
.
focusObject
(
evt
.
object
);
flyToSubView
(
me
,
obj
,
LENS_LEVEL
);
}
}
});
});
}
}
// 处理跳跃
// 处理跳跃
...
@@ -541,14 +554,7 @@ class View3D extends Component {
...
@@ -541,14 +554,7 @@ class View3D extends Component {
// 飞行到具体的 obj 之后,执行进入层级操作
// 飞行到具体的 obj 之后,执行进入层级操作
onComplete
()
{
onComplete
()
{
console
.
log
(
'fly done!'
,
object
);
console
.
log
(
'fly done!'
,
object
);
// 进入子层级
me
.
lensLevel
=
LENS_LEVEL
.
SUB
;
if
(
object
.
foreignKey
)
{
me
.
lensJumpFactory
.
jumpInByForeignKey
(
object
.
foreignKey
,
excludeObj
=>
{
// 处理非该层级的物体 (fadeOut)
me
.
lensJumpFactory
.
fadeOut
(
excludeObj
);
});
me
.
lensLevel
=
LENS_LEVEL
.
SUB
;
}
}
}
});
});
}
else
if
(
me
.
state
.
alarmStarted
)
{
}
else
if
(
me
.
state
.
alarmStarted
)
{
...
@@ -1582,6 +1588,19 @@ class View3D extends Component {
...
@@ -1582,6 +1588,19 @@ class View3D extends Component {
return
object
;
return
object
;
}
}
multLoadWorkerObjContent
=
(
asyncModels
)
=>
{
const
sliceArry
=
chunk
(
asyncModels
,
5
);
return
sliceArry
.
map
(
objs
=>
{
return
<
WorkerObjContent
onComplete
=
{
this
.
onComplete
}
objs
=
{
objs
}
onWorkerMessage
=
{
this
.
onWorkerLoading
}
enableLoading
afterInit
=
{
this
.
onAfterWorkerInit
}
/>
;
});
}
addMarker
=
({
extData
,
position
})
=>
{
addMarker
=
({
extData
,
position
})
=>
{
const
me
=
this
;
const
me
=
this
;
const
{
markers
}
=
me
.
state
;
const
{
markers
}
=
me
.
state
;
...
@@ -1722,7 +1741,7 @@ class View3D extends Component {
...
@@ -1722,7 +1741,7 @@ class View3D extends Component {
positionCtlProps
=
{
positionCtlProps
}
positionCtlProps
=
{
positionCtlProps
}
onCreated
=
{
this
.
onGraphCreated
}
onCreated
=
{
this
.
onGraphCreated
}
>
>
{
startAsyncLoad
&&
<
WorkerObjContent
objs
=
{
asyncModels
}
onWorkerMessage
=
{
this
.
onWorkerLoading
}
enableLoading
afterInit
=
{
this
.
onAfterWorkerInit
}
/>
}
{
startAsyncLoad
&&
this
.
multLoadWorkerObjContent
(
asyncModels
)
}
{
isEditMode
&&
pageType
===
'region'
?
''
:
{
isEditMode
&&
pageType
===
'region'
?
''
:
<
PointsPool
markers
=
{
markers
}
isEditMode
=
{
isEditMode
}
selectPoints
=
{
selectPoints
}
updateMarker
=
{
this
.
updateMarker
}
planStarted
=
{
alarmStarted
}
stagePilot
=
{
this
.
stagePilot
}
positionCtl
=
{
this
.
positionCtl
}
addMarker
=
{
this
.
addMarker
}
ref
=
{
node
=>
this
.
pointsPool
=
node
}
/>
}
<
PointsPool
markers
=
{
markers
}
isEditMode
=
{
isEditMode
}
selectPoints
=
{
selectPoints
}
updateMarker
=
{
this
.
updateMarker
}
planStarted
=
{
alarmStarted
}
stagePilot
=
{
this
.
stagePilot
}
positionCtl
=
{
this
.
positionCtl
}
addMarker
=
{
this
.
addMarker
}
ref
=
{
node
=>
this
.
pointsPool
=
node
}
/>
}
{
fireTruckRoute
&&
<
FatLine
{...
lineData
.
fatLineConf
}
linePath
=
{
JSON
.
parse
(
fireTruckRoute
)}
visible
=
{
showFireTruckRoute
}
/>
}
{
fireTruckRoute
&&
<
FatLine
{...
lineData
.
fatLineConf
}
linePath
=
{
JSON
.
parse
(
fireTruckRoute
)}
visible
=
{
showFireTruckRoute
}
/>
}
...
...
mods/components/3dviewConvertor/view/conf.js
View file @
029270c7
...
@@ -311,8 +311,8 @@ export const desigerConf = {
...
@@ -311,8 +311,8 @@ export const desigerConf = {
fov
:
45
,
fov
:
45
,
near
:
1
,
near
:
1
,
far
:
5000
,
far
:
5000
,
position
:
[
-
12.560443473044181
,
234.91788662409795
,
325.0800512251056
],
position
:
[
-
66.72828735496893
,
239.00238807176638
,
340.1218562325041
],
target
:
[
2.408441971875859
,
1.3271790975878637
,
3.918674823963386
],
target
:
[
-
52.608562486768115
,
-
6.882567219297089
,
1.984922473879572
],
// 是否启用拾取器
// 是否启用拾取器
enablePicker
:
true
,
enablePicker
:
true
,
builtInOrbit
:
{
builtInOrbit
:
{
...
@@ -357,8 +357,8 @@ export const curveConf = {
...
@@ -357,8 +357,8 @@ export const curveConf = {
export
const
desigerHelperConfig
=
{
export
const
desigerHelperConfig
=
{
cameraEffect
:
{
cameraEffect
:
{
position
:
[
-
12.560443473044181
,
234.91788662409795
,
325.0800512251056
],
position
:
[
-
66.72828735496893
,
239.00238807176638
,
340.1218562325041
],
target
:
[
2.408441971875859
,
1.3271790975878637
,
3.918674823963386
]
target
:
[
-
52.608562486768115
,
-
6.882567219297089
,
1.984922473879572
]
},
},
objAnchor
:
{
objAnchor
:
{
position
:
[
0
,
5
,
0
]
position
:
[
0
,
5
,
0
]
...
...
mods/components/3dviewConvertor/view/dataProcessor.js
View file @
029270c7
...
@@ -344,4 +344,55 @@ export const objRunning = (markerObj, routePath, delayTime) => {
...
@@ -344,4 +344,55 @@ export const objRunning = (markerObj, routePath, delayTime) => {
});
});
};
};
/**
* 模型对象缓存
* @param {object} instance
* @param {object} obj
*/
export
const
cacheObjsSave
=
(
instance
,
obj
,
LENS_LEVEL
)
=>
{
const
{
level
,
parentKey
,
key
}
=
obj
.
userData
||
{};
if
(
level
&&
key
){
instance
.
_cacheObj
[
key
]
=
obj
;
switch
(
level
)
{
case
LENS_LEVEL
.
ROOT
:
// 父节点
if
(
!
instance
.
processorLevel
[
key
]){
instance
.
processorLevel
[
key
]
=
[];
}
break
;
case
LENS_LEVEL
.
SUB
:
// 子节点
if
(
!
instance
.
processorLevel
[
parentKey
]){
instance
.
processorLevel
[
parentKey
]
=
[];
}
instance
.
processorLevel
[
parentKey
].
push
(
key
);
// 在对应关系中,添加其子节点
break
;
default
:
break
;
}
}
};
/**
* 进入选择物体内部
* @param {object} instance
* @param {object} obj
*/
export
const
flyToSubView
=
(
instance
,
obj
,
LENS_LEVEL
)
=>
{
if
(
obj
.
userData
&&
obj
.
userData
.
level
&&
obj
.
userData
.
level
===
'root'
){
Object
.
keys
(
instance
.
processorLevel
).
forEach
(
key
=>
{
// 隐藏所有一级
instance
.
_cacheObj
[
key
].
visible
=
false
;
// 隐藏非目标二级
if
(
key
!==
obj
.
userData
.
key
){
instance
.
processorLevel
[
key
].
forEach
(
sec
=>
{
instance
.
_cacheObj
[
sec
].
visible
=
false
;
});
}
});
// 镜头切换
obj
.
userData
.
fitView
&&
instance
.
cameraFactory
.
fitView
(
obj
.
userData
.
fitView
);
//视角调整为最近视角
instance
.
lensLevel
=
LENS_LEVEL
.
SUB
;
}
else
{
instance
.
focusObject
(
obj
);
}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment