Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Rahman
Argumented Reality
Commits
bd1026db
Commit
bd1026db
authored
11 months ago
by
Rahman
Browse files
Options
Download
Email Patches
Plain Diff
Update index.html
parent
2e16ef49
Pipeline
#9771
passed with stage
in 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/index.html
+21
-16
public/index.html
with
21 additions
and
16 deletions
+21
-16
public/index.html
+
21
-
16
View file @
bd1026db
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<!-- Starting an immersive WebXR session requires user interaction.
<!-- Starting an immersive WebXR session requires user interaction.
We start this one with a simple button. -->
We start this one with a simple button. -->
<button
onclick=
"activateXR()"
>
Tap
to Place
AR
Demo
</button>
<button
onclick=
"activateXR()"
>
Start Hit
to Place Demo
</button>
<script>
<script>
async
function
activateXR
()
{
async
function
activateXR
()
{
// Add a canvas element and initialize a WebGL context that is compatible with WebXR.
// Add a canvas element and initialize a WebGL context that is compatible with WebXR.
...
@@ -60,6 +60,8 @@ const viewerSpace = await session.requestReferenceSpace('viewer');
...
@@ -60,6 +60,8 @@ const viewerSpace = await session.requestReferenceSpace('viewer');
const
hitTestSource
=
await
session
.
requestHitTestSource
({
space
:
viewerSpace
});
const
hitTestSource
=
await
session
.
requestHitTestSource
({
space
:
viewerSpace
});
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
)
{
...
@@ -68,20 +70,18 @@ loader.load("https://immersive-web.github.io/webxr-samples/media/gltf/reticle/re
...
@@ -68,20 +70,18 @@ loader.load("https://immersive-web.github.io/webxr-samples/media/gltf/reticle/re
scene
.
add
(
reticle
);
scene
.
add
(
reticle
);
})
})
let
pineCone
;
let
flower
;
// Replace the URL with new url
loader
.
load
(
"
https://immersive-web.github.io/webxr-samples/media/gltf/sunflower/sunflower.gltf
"
,
function
(
gltf
)
{
loader
.
load
(
"
https://transfer.hft-stuttgart.de/gitlab/22raya1mpg/argumented-reality/-/raw/master/public/scene.gltf
"
,
function
(
gltf
)
{
flower
=
gltf
.
scene
;
pineCone
=
gltf
.
scene
;
});
pineCone
.
scale
.
set
(
0.15
,
0.15
,
0.15
);
// Adjust scale as needed
});
session
.
addEventListener
(
"
select
"
,
(
event
)
=>
{
if
(
flower
)
{
session
.
addEventListener
(
"
select
"
,
(
event
)
=>
{
const
clone
=
flower
.
clone
();
if
(
pineCone
)
{
clone
.
position
.
copy
(
reticle
.
position
);
const
clone
=
pineCone
.
clone
();
scene
.
add
(
clone
);
clone
.
position
.
copy
(
reticle
.
position
);
}
scene
.
add
(
clone
);
});
}
});
// Create a render loop that allows us to draw on the AR view.
// Create a render loop that allows us to draw on the AR view.
const
onXRFrame
=
(
time
,
frame
)
=>
{
const
onXRFrame
=
(
time
,
frame
)
=>
{
...
@@ -112,7 +112,9 @@ const onXRFrame = (time, frame) => {
...
@@ -112,7 +112,9 @@ const onXRFrame = (time, frame) => {
reticle
.
visible
=
true
;
reticle
.
visible
=
true
;
reticle
.
position
.
set
(
hitPose
.
transform
.
position
.
x
,
hitPose
.
transform
.
position
.
y
,
hitPose
.
transform
.
position
.
z
)
reticle
.
position
.
set
(
hitPose
.
transform
.
position
.
x
,
hitPose
.
transform
.
position
.
y
,
hitPose
.
transform
.
position
.
z
)
reticle
.
updateMatrixWorld
(
true
);
reticle
.
updateMatrixWorld
(
true
);
}
}
// Render the scene with THREE.WebGLRenderer.
// Render the scene with THREE.WebGLRenderer.
renderer
.
render
(
scene
,
camera
)
renderer
.
render
(
scene
,
camera
)
...
@@ -120,6 +122,9 @@ const onXRFrame = (time, frame) => {
...
@@ -120,6 +122,9 @@ const onXRFrame = (time, frame) => {
}
}
session
.
requestAnimationFrame
(
onXRFrame
);
session
.
requestAnimationFrame
(
onXRFrame
);
}
}
</script>
</script>
</body>
</body>
...
...
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