Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lgl
SmartVillages2
Commits
b0f5a114
Commit
b0f5a114
authored
Jul 10, 2025
by
Riegel
Browse files
Add fine adjustment of position
parent
ce1fa9a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/index.js
View file @
b0f5a114
...
@@ -12,6 +12,8 @@ let model;
...
@@ -12,6 +12,8 @@ let model;
let
conditions
=
[[
true
,
true
]];
let
conditions
=
[[
true
,
true
]];
let
activeMouseEvent
;
let
activeMouseEvent
;
let
currentMousePosition
;
let
currentMousePosition
;
let
initialPosition
;
let
initialPickResult
;
let
heightDif
=
0
;
let
heightDif
=
0
;
const
hpRollMap
=
new
Map
();
const
hpRollMap
=
new
Map
();
let
placedModels
=
[];
let
placedModels
=
[];
...
@@ -145,7 +147,7 @@ function setupModel(vcsApp, windowPos, url, name) {
...
@@ -145,7 +147,7 @@ function setupModel(vcsApp, windowPos, url, name) {
name
:
name
,
name
:
name
,
});
});
vcMap
.
requestRender
();
vcMap
.
requestRender
();
const
interaction
=
new
Mov
eInteraction
();
const
interaction
=
new
PickPlac
eInteraction
();
interaction
.
setActive
(
EventType
.
CLICKMOVE
);
interaction
.
setActive
(
EventType
.
CLICKMOVE
);
activeMouseEvent
=
vcsApp
.
maps
.
eventHandler
.
addExclusiveInteraction
(
interaction
,
()
=>
{});
activeMouseEvent
=
vcsApp
.
maps
.
eventHandler
.
addExclusiveInteraction
(
interaction
,
()
=>
{});
}
}
...
@@ -157,6 +159,41 @@ function removePlacedModel(modelToBeRemoved) {
...
@@ -157,6 +159,41 @@ function removePlacedModel(modelToBeRemoved) {
}
}
class
MoveInteraction
extends
AbstractInteraction
{
class
MoveInteraction
extends
AbstractInteraction
{
async
pipe
(
event
)
{
if
(
event
.
pointerEvent
===
2
)
{
if
(
activeMouseEvent
!==
undefined
)
{
activeMouseEvent
();
}
}
else
if
(
event
.
pointerEvent
===
3
&&
model
!==
undefined
)
{
const
cesiumMap
=
event
.
map
;
const
scene
=
cesiumMap
.
getScene
();
const
pickResult
=
scene
.
globe
.
pick
(
event
.
ray
,
scene
);
if
(
initialPickResult
===
undefined
)
{
initialPickResult
=
pickResult
;
}
if
(
initialPosition
===
undefined
)
{
initialPosition
=
model
.
position
.
getValue
().
clone
();
}
let
xDif
=
pickResult
.
x
-
initialPickResult
.
x
;
let
yDif
=
pickResult
.
y
-
initialPickResult
.
y
;
let
zDif
=
pickResult
.
z
-
initialPickResult
.
z
;
// pickResult.z = pickResult.z + heightDif;
let
pos
=
initialPosition
.
clone
();
pos
.
x
=
pos
.
x
+
xDif
;
pos
.
y
=
pos
.
y
+
yDif
;
pos
.
z
=
pos
.
z
+
zDif
;
model
.
position
.
setValue
(
pos
);
}
return
event
;
}
}
class
PickPlaceInteraction
extends
AbstractInteraction
{
async
pipe
(
event
)
{
async
pipe
(
event
)
{
if
(
event
.
pointerEvent
===
2
)
{
if
(
event
.
pointerEvent
===
2
)
{
if
(
activeMouseEvent
!==
undefined
)
{
if
(
activeMouseEvent
!==
undefined
)
{
...
@@ -384,6 +421,8 @@ export default function smartVillagesPlugin(config, baseUrl) {
...
@@ -384,6 +421,8 @@ export default function smartVillagesPlugin(config, baseUrl) {
id
:
'
move
'
,
id
:
'
move
'
,
name
:
'
Objekt verschieben
'
,
name
:
'
Objekt verschieben
'
,
callback
()
{
callback
()
{
initialPosition
=
undefined
;
initialPickResult
=
undefined
;
const
interaction
=
new
MoveInteraction
();
const
interaction
=
new
MoveInteraction
();
interaction
.
setActive
(
EventType
.
CLICKMOVE
);
interaction
.
setActive
(
EventType
.
CLICKMOVE
);
activeMouseEvent
=
vcsApp
.
maps
.
eventHandler
.
addExclusiveInteraction
(
interaction
,
()
=>
{
console
.
log
(
"
removed
"
)
});
activeMouseEvent
=
vcsApp
.
maps
.
eventHandler
.
addExclusiveInteraction
(
interaction
,
()
=>
{
console
.
log
(
"
removed
"
)
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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