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
9558fd27
Commit
9558fd27
authored
Sep 23, 2025
by
Luna Riegel
Browse files
Add loading from catalog for placement files
parent
5a38e4d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/index.js
View file @
9558fd27
import
{
ToolboxType
,
WindowSlot
,
NotificationType
}
from
'
@vcmap/ui
'
;
import
{
Cesium3DTileStyle
,
Math
as
CMath
,
Ellipsoid
,
Cartesian3
,
ConstantProperty
,
Transforms
,
HeadingPitchRoll
,
Cesium3DTileset
,
Matrix4
}
from
'
@vcmap-cesium/engine
'
;
import
{
Cesium3DTileStyle
,
Math
as
CMath
,
Ellipsoid
,
Cartesian3
,
ConstantProperty
,
Transforms
,
HeadingPitchRoll
,
Cesium3DTileset
,
Matrix4
,
EntityCollection
}
from
'
@vcmap-cesium/engine
'
;
import
{
AbstractInteraction
,
EventType
}
from
'
@vcmap/core
'
;
import
{
name
,
version
,
mapVersion
}
from
'
../package.json
'
;
import
BIMOptions
,
{
bimOptionsId
}
from
'
./upload.vue
'
;
...
...
@@ -104,7 +115,7 @@ function saveObjects() {
position
:
[
wgs84X
,
wgs84Y
,
height
],
heading
:
heading
,
scale
:
m
.
model
.
model
.
scale
.
getValue
(),
fromCatalog
:
m
.
fromCatalog
,
fromCatalog
:
m
.
model
.
fromCatalog
.
valueOf
()
,
});
}
outputObject
.
placedObjects
=
outputArray
;
...
...
@@ -355,19 +366,22 @@ export default function smartVillagesPlugin(config, baseUrl) {
}
}
if
(
objectUrl
===
undefined
)
{
console
.
log
(
"
From Catalog:
"
+
loadingObject
.
fromCatalog
);
if
(
loadingObject
.
fromCatalog
===
true
){
// TODO: Fetch from catalog
objectUrl
=
loadingObject
.
uri
;
// Load the model into memory
loadCatalogModel
(
objectUrl
).
catch
(
e
=>
{
const
model
=
await
loadCatalogModel
(
loadingObject
.
name
).
catch
(
e
=>
{
console
.
error
(
e
);
app
.
notifier
.
add
({
type
:
NotificationType
.
ERROR
,
message
:
"
Katalogobject:
"
+
loadingObject
.
name
+
"
konnte nicht geladenen werden. Konfiguration konnte nicht vollständig geladen werden.
"
,
});
return
undefined
;
});
return
;
if
(
model
===
undefined
)
{
return
;
}
else
{
objectUrl
=
model
.
url
;
}
}
else
{
app
.
notifier
.
add
({
type
:
NotificationType
.
ERROR
,
...
...
@@ -386,8 +400,8 @@ export default function smartVillagesPlugin(config, baseUrl) {
uri
:
objectUrl
,
scale
:
loadingObject
.
scale
,
show
:
true
,
fromCatalog
:
loadingObject
.
fromCatalog
,
},
fromCatalog
:
loadingObject
.
fromCatalog
,
});
const
roll
=
new
HeadingPitchRoll
();
hpRollMap
.
set
(
model
,
roll
);
...
...
src/objectList.vue
View file @
9558fd27
...
...
@@ -16,7 +16,7 @@
<vcs-button
v-for=
"entry in entries"
:key=
"entry.title"
@
click=
"
fetch
Catalog
ue
Model(entry.model)"
@
click=
"
place
CatalogModel(entry.model)"
class=
"p-0 mx-1 my-0 border gc-2"
style=
"width: auto; height: auto; margin-left: 1rem; margin-bottom: 1px;"
variant=
"filled"
...
...
@@ -129,17 +129,17 @@ let setupModelFunction = undefined;
let
app
=
undefined
;
let
projectStateObject
=
undefined
;
async
function
loadCatalog
ue
sFromConfig
(
config
)
{
async
function
loadCatalogsFromConfig
(
config
)
{
const
configJson
=
JSON
.
parse
(
JSON
.
stringify
(
config
));
const
catalogues
=
Object
.
values
(
configJson
.
objectCatalogues
);
for
(
const
cat
of
catalogues
)
{
const
catJson
=
await
retrieveCatalog
ue
Json
(
cat
.
url
);
const
catJson
=
await
retrieveCatalogJson
(
cat
.
url
);
if
(
!
catJson
)
continue
;
const
category
=
cat
.
category
.
toString
();
const
linkPrefix
=
cat
.
url
.
replace
(
/
\/[^/]
*catalog
\.
json$/
,
'
/
'
);
const
entries
=
getCatalog
ue
Entries
(
catJson
,
linkPrefix
);
const
entries
=
getCatalogEntries
(
catJson
,
linkPrefix
);
if
(
!
objLib
.
value
[
category
])
{
objLib
.
value
[
category
]
=
entries
;
...
...
@@ -151,7 +151,7 @@ async function loadCataloguesFromConfig(config) {
}
async
function
retrieveCatalog
ue
Json
(
link
)
{
async
function
retrieveCatalogJson
(
link
)
{
const
controller
=
new
AbortController
();
const
timeout
=
setTimeout
(()
=>
controller
.
abort
(),
5000
);
...
...
@@ -173,7 +173,7 @@ async function retrieveCatalogueJson(link) {
}
}
function
getCatalog
ue
Entries
(
json
,
linkPrefix
)
{
function
getCatalogEntries
(
json
,
linkPrefix
)
{
const
part
=
{};
...
...
@@ -209,7 +209,7 @@ function getCatalogueEntries(json, linkPrefix) {
return
part
;
}
async
function
retriev
eCatalogModel
(
modelLink
){
async
function
plac
eCatalogModel
(
modelLink
){
loadCatalogModel
(
modelLink
).
then
(
model
=>
{
const
catModel
=
model
;
const
x
=
window
.
innerWidth
/
2
;
...
...
@@ -230,9 +230,9 @@ async function retrieveCatalogModel(modelLink){
export
async
function
loadCatalogModel
(
modelLink
){
return
new
Promise
(
(
resolve
,
reject
)
=>
{
if
(
preloadedModels
.
value
[
modelLink
]
!=
null
){
// Model is already in memory
resolve
(
preloadedModels
.
value
[
modelLink
]);
}
else
{
//Todo: parse model from catalog
const
loader
=
new
GLTFLoader
();
loader
.
load
(
modelLink
,
...
...
@@ -433,8 +433,7 @@ function uploadModel() {
const
dialog
=
ref
(
false
);
setupModelFunction
=
setupModel
;
projectStateObject
=
pluginState
;
// loadCataloguesFromConfig(config).then(response => {console.log(objLib);});
onMounted
(()
=>
loadCataloguesFromConfig
(
config
).
then
(
response
=>
{
console
.
log
(
objLib
)}));
onMounted
(()
=>
loadCatalogsFromConfig
(
config
).
then
(
response
=>
{
console
.
log
(
objLib
)}));
return
{
draggable
,
selectable
,
...
...
@@ -528,8 +527,8 @@ function uploadModel() {
loadModel
()
{
uploadModel
();
},
fetch
Catalog
ue
Model
(
modelLink
)
{
retriev
eCatalogModel
(
modelLink
);
place
CatalogModel
(
modelLink
)
{
plac
eCatalogModel
(
modelLink
);
},
loadConfiguration
()
{
loadObjects
(
app
);
...
...
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