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
dcf9e841
Commit
dcf9e841
authored
Dec 09, 2024
by
Percen
Browse files
Update public/index.html
parent
58e92b35
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/index.html
View file @
dcf9e841
...
@@ -14,10 +14,10 @@
...
@@ -14,10 +14,10 @@
<button
id=
"startButton"
onclick=
"activateXR()"
>
Start city planning
</button>
<button
id=
"startButton"
onclick=
"activateXR()"
>
Start city planning
</button>
<script>
<script>
let
minimapRenderer
,
minimapCamera
;
let
minimapRenderer
,
minimapCamera
,
minimapTexture
,
minimapMesh
;
async
function
activateXR
()
{
async
function
activateXR
()
{
document
.
getElementById
(
"
startButton
"
).
style
.
display
=
"
none
"
;
//
Verstecke den
Start-Button
document
.
getElementById
(
"
startButton
"
).
style
.
display
=
"
none
"
;
// Start-Button
verstecken
const
canvas
=
document
.
createElement
(
"
canvas
"
);
const
canvas
=
document
.
createElement
(
"
canvas
"
);
document
.
body
.
appendChild
(
canvas
);
document
.
body
.
appendChild
(
canvas
);
...
@@ -49,9 +49,6 @@ async function activateXR() {
...
@@ -49,9 +49,6 @@ async function activateXR() {
const
viewerSpace
=
await
session
.
requestReferenceSpace
(
'
viewer
'
);
const
viewerSpace
=
await
session
.
requestReferenceSpace
(
'
viewer
'
);
const
hitTestSource
=
await
session
.
requestHitTestSource
({
space
:
viewerSpace
});
const
hitTestSource
=
await
session
.
requestHitTestSource
({
space
:
viewerSpace
});
// Minimap setup (wird erst jetzt erstellt)
setupMinimap
();
const
loader
=
new
THREE
.
GLTFLoader
();
const
loader
=
new
THREE
.
GLTFLoader
();
let
reticle
;
let
reticle
;
loader
.
load
(
"
https://immersive-web.github.io/webxr-samples/media/gltf/reticle/reticle.gltf
"
,
function
(
gltf
)
{
loader
.
load
(
"
https://immersive-web.github.io/webxr-samples/media/gltf/reticle/reticle.gltf
"
,
function
(
gltf
)
{
...
@@ -73,6 +70,9 @@ async function activateXR() {
...
@@ -73,6 +70,9 @@ async function activateXR() {
}
}
});
});
// Minimap-Integration
setupMinimap
(
scene
);
// Renderloop
// Renderloop
const
onXRFrame
=
(
time
,
frame
)
=>
{
const
onXRFrame
=
(
time
,
frame
)
=>
{
session
.
requestAnimationFrame
(
onXRFrame
);
session
.
requestAnimationFrame
(
onXRFrame
);
...
@@ -97,8 +97,7 @@ async function activateXR() {
...
@@ -97,8 +97,7 @@ async function activateXR() {
reticle
.
updateMatrixWorld
(
true
);
reticle
.
updateMatrixWorld
(
true
);
}
}
// Minimap-Update
updateMinimap
(
scene
);
updateMinimap
(
camera
,
scene
);
renderer
.
render
(
scene
,
camera
);
renderer
.
render
(
scene
,
camera
);
}
}
...
@@ -106,30 +105,34 @@ async function activateXR() {
...
@@ -106,30 +105,34 @@ async function activateXR() {
session
.
requestAnimationFrame
(
onXRFrame
);
session
.
requestAnimationFrame
(
onXRFrame
);
}
}
function
setupMinimap
()
{
function
setupMinimap
(
scene
)
{
const
minimapSize
=
5
;
// Sichtfeld der Minimap
const
minimapSize
=
5
;
// Minimap-Kamera (orthographische Kamera für Draufsicht)
minimapCamera
=
new
THREE
.
OrthographicCamera
(
-
minimapSize
,
minimapSize
,
minimapSize
,
-
minimapSize
,
0.1
,
100
);
minimapCamera
=
new
THREE
.
OrthographicCamera
(
-
minimapSize
,
minimapSize
,
minimapSize
,
-
minimapSize
,
0.1
,
100
);
minimapCamera
.
position
.
set
(
0
,
10
,
0
);
// Kamera in Vogelperspektive
minimapCamera
.
position
.
set
(
0
,
10
,
0
);
minimapCamera
.
lookAt
(
0
,
0
,
0
);
minimapCamera
.
lookAt
(
0
,
0
,
0
);
// Minimap-Renderer und Textur
minimapRenderer
=
new
THREE
.
WebGLRenderer
({
alpha
:
true
});
minimapRenderer
=
new
THREE
.
WebGLRenderer
({
alpha
:
true
});
minimapRenderer
.
setSize
(
200
,
200
);
minimapRenderer
.
setSize
(
256
,
256
);
// Kleine Auflösung für die Minimap
minimapRenderer
.
domElement
.
style
.
position
=
"
absolute
"
;
minimapTexture
=
new
THREE
.
CanvasTexture
(
minimapRenderer
.
domElement
);
minimapRenderer
.
domElement
.
style
.
bottom
=
"
10px
"
;
minimapRenderer
.
domElement
.
style
.
right
=
"
10px
"
;
document
.
body
.
appendChild
(
minimapRenderer
.
domElement
);
console
.
log
(
"
Minimap aktiviert
"
);
// Erstelle eine Ebene für die Minimap
const
geometry
=
new
THREE
.
PlaneGeometry
(
0.3
,
0.3
);
// Größe der Minimap in der AR-Welt
const
material
=
new
THREE
.
MeshBasicMaterial
({
map
:
minimapTexture
,
transparent
:
true
});
minimapMesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
minimapMesh
.
position
.
set
(
0
,
-
0.5
,
-
1
);
// Unterhalb des Sichtfeldes
scene
.
add
(
minimapMesh
);
}
}
function
updateMinimap
(
mainCamera
,
scene
)
{
function
updateMinimap
(
scene
)
{
if
(
minimapCamera
&&
minimapRenderer
)
{
// Render die Minimap-Ansicht
// Synchronisiere die Position der Minimap-Kamera mit der Hauptkamera
minimapRenderer
.
render
(
scene
,
minimapCamera
);
minimapCamera
.
position
.
x
=
mainCamera
.
position
.
x
;
minimapCamera
.
position
.
z
=
mainCamera
.
position
.
z
;
// Aktualisiere die Textur der Minimap in der AR-Welt
minimapTexture
.
needsUpdate
=
true
;
minimapRenderer
.
render
(
scene
,
minimapCamera
);
}
}
}
</script>
</script>
</body>
</body>
...
...
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