Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GeoVistoogsi
AR
Commits
7aafa751
Commit
7aafa751
authored
4 months ago
by
Percen
Browse files
Options
Download
Email Patches
Plain Diff
Update public/index.html
parent
7f9d3033
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/index.html
+3
-45
public/index.html
with
3 additions
and
45 deletions
+3
-45
public/index.html
+
3
-
45
View file @
7aafa751
...
...
@@ -143,18 +143,16 @@
</head>
<body>
<div
id=
"status"
></div>
<div
id=
"menu-bar"
>
<div
class=
"menu-item active"
id=
"robot-item"
onclick=
"selectModel('robot')"
>
<img
src=
"previewImages/robot.png"
alt=
"Roboter"
style=
"width: 50px; height: 50px;"
>
</div>
<div
class=
"menu-item"
id=
"sunflower-item"
onclick=
"selectModel('sunflower')"
>
<img
src=
"previewImages/sunflower.png"
alt=
"Sonnenblume"
style=
"width: 50px; height: 50px;"
>
</div>
<div
class=
"menu-item"
id=
"lantern-item"
onclick=
"selectModel('tree')"
>
<img
src=
"previewImages/tree.png"
alt=
"Baum"
style=
"width: 50px; height: 50px;"
>
</div>
<div
class=
"menu-item"
id=
"zipModel-item"
onclick=
"selectModel('zipModel')"
>
<img
src=
"previewImages/zipModel.png"
alt=
"zipModel"
style=
"width: 50px; height: 50px;"
>
</div>
<div
class=
"menu-item"
id=
"exit-item"
onclick=
"exitAR()"
>
<img
src=
"previewImages/exit.png"
alt=
"Exit"
style=
"width: 50px; height: 50px;"
>
</div>
...
...
@@ -188,22 +186,6 @@
console
.
log
(
`Modell ausgewählt:
${
selectedModel
}
`
);
updateMenu
();
}
async
function
loadAndUnpackZip
(
zipUrl
)
{
const
response
=
await
fetch
(
zipUrl
);
const
buffer
=
await
response
.
arrayBuffer
();
const
zip
=
await
JSZip
.
loadAsync
(
buffer
);
const
files
=
{};
for
(
const
filename
of
Object
.
keys
(
zip
.
files
))
{
if
(
!
zip
.
files
[
filename
].
dir
)
{
const
content
=
await
zip
.
files
[
filename
].
async
(
'
blob
'
);
files
[
filename
]
=
URL
.
createObjectURL
(
content
);
}
}
return
files
;
}
async
function
activateXR
()
{
const
canvas
=
document
.
createElement
(
'
canvas
'
);
...
...
@@ -221,30 +203,6 @@
light
.
position
.
set
(
10
,
10
,
10
);
scene
.
add
(
light
);
// Dynamisches Laden eines Modells aus ZIP-Datei
const
status
=
document
.
getElementById
(
'
status
'
);
status
.
textContent
=
"
Lade Modell aus ZIP-Datei...
"
;
try
{
const
zipUrl
=
'
./assets/models/city_trash_can.zip
'
;
// Relativer Pfad zur ZIP-Datei
const
files
=
await
loadAndUnpackZip
(
zipUrl
);
const
gltfFile
=
Object
.
keys
(
files
).
find
((
filename
)
=>
filename
.
endsWith
(
'
.gltf
'
));
if
(
!
gltfFile
)
{
throw
new
Error
(
'
Keine glTF-Datei in der ZIP gefunden.
'
);
}
loader
.
load
(
files
[
gltfFile
],
(
gltf
)
=>
{
const
zipModel
=
gltf
.
scene
;
zipModel
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
// Skaliere das Modell
scene
.
add
(
zipModel
);
status
.
textContent
=
"
Modell erfolgreich geladen!
"
;
});
}
catch
(
error
)
{
console
.
error
(
'
Fehler beim Laden der ZIP-Datei:
'
,
error
);
status
.
textContent
=
"
Fehler beim Laden der ZIP-Datei.
"
;
}
// Reticle (Cursor)
const
loader
=
new
THREE
.
GLTFLoader
();
loader
.
load
(
"
https://immersive-web.github.io/webxr-samples/media/gltf/reticle/reticle.gltf
"
,
(
gltf
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
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