Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
HFT-informatics-weekend
AR - Urban Planner
Commits
435bd854
Commit
435bd854
authored
Oct 11, 2025
by
Stoll
Browse files
Initial VR Setup
parent
d1607b82
Changes
1
Hide whitespace changes
Inline
Side-by-side
first_test/a-frame/index.html
0 → 100644
View file @
435bd854
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
WebXR Cube Example
</title>
<style>
body
{
margin
:
0
;
overflow
:
hidden
;
}
#info
{
position
:
absolute
;
top
:
10px
;
width
:
100%
;
text-align
:
center
;
color
:
white
;
}
</style>
</head>
<body>
<div
id=
"info"
>
Hello, Three.js + WebXR!
</div>
<script
type=
"module"
>
import
*
as
THREE
from
'
https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js
'
;
import
{
XRButton
}
from
'
https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/webxr/XRButton.js
'
;
// Scene
const
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0xaaaaaa
);
// Camera
const
camera
=
new
THREE
.
PerspectiveCamera
(
70
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
100
);
camera
.
position
.
set
(
0
,
1.6
,
3
);
// Renderer
const
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
xr
.
enabled
=
true
;
document
.
body
.
appendChild
(
renderer
.
domElement
);
document
.
body
.
appendChild
(
XRButton
.
createButton
(
renderer
));
// Light
const
light
=
new
THREE
.
HemisphereLight
(
0xffffff
,
0x444444
);
light
.
position
.
set
(
0
,
1
,
0
);
scene
.
add
(
light
);
// Cube at fixed position on the ground
const
cube
=
new
THREE
.
Mesh
(
new
THREE
.
BoxGeometry
(
0.5
,
0.5
,
0.5
),
new
THREE
.
MeshStandardMaterial
({
color
:
0xff0000
})
);
cube
.
position
.
set
(
0
,
0.25
,
-
1
);
// 0.25 because cube height / 2
scene
.
add
(
cube
);
// Resize handler
window
.
addEventListener
(
'
resize
'
,
()
=>
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
});
// Animation loop
function
animate
()
{
renderer
.
setAnimationLoop
(()
=>
{
renderer
.
render
(
scene
,
camera
);
});
}
animate
();
</script>
</body>
</html>
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