Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Thapa
visualization
Commits
af6859ec
Commit
af6859ec
authored
Jun 20, 2023
by
Thapa
Browse files
Update 1-Cube.html
parent
7502cbb1
Pipeline
#8084
passed with stage
in 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
public/1-Cube.html
View file @
af6859ec
...
...
@@ -23,29 +23,26 @@ async function activateXR() {
const
scene
=
new
THREE
.
Scene
();
// The cube will have a different color on each side.
const
materials
=
[
new
THREE
.
MeshBasicMaterial
({
color
:
0x744700
}),
new
THREE
.
MeshBasicMaterial
({
color
:
0x744700
}),
new
THREE
.
MeshBasicMaterial
({
color
:
0x744700
}),
new
THREE
.
MeshBasicMaterial
({
color
:
0x744700
}),
new
THREE
.
MeshBasicMaterial
({
color
:
0x744700
}),
new
THREE
.
MeshBasicMaterial
({
color
:
0x744700
})
];
// Create the cube and add it to the demo scene.
const
cube
=
new
THREE
.
Mesh
(
new
THREE
.
BoxBufferGeometry
(
0.5
,
0.5
,
0.5
),
materials
);
cube
.
position
.
set
(
0
,
0
,
-
1
);
scene
.
add
(
cube
);
// Set up the WebGLRenderer, which handles rendering to the session's base layer.
const
renderer
=
new
THREE
.
WebGLRenderer
({
alpha
:
true
,
preserveDrawingBuffer
:
true
,
canvas
:
canvas
,
context
:
gl
});
renderer
.
autoClear
=
false
;
// Load the texture for the Earth globe.
const
textureLoader
=
new
THREE
.
TextureLoader
();
const
texture
=
textureLoader
.
load
(
'
earth_texture.jpg
'
);
// Create the Earth sphere and add it to the demo scene.
const
sphere
=
new
THREE
.
Mesh
(
new
THREE
.
SphereBufferGeometry
(
0.5
,
64
,
64
),
// Adjust the radius as needed.
new
THREE
.
MeshBasicMaterial
({
map
:
texture
})
// Apply the Earth texture to the sphere.
);
sphere
.
position
.
set
(
0
,
0
,
-
1
);
scene
.
add
(
sphere
);
// Set up the WebGLRenderer, which handles rendering to the session's base layer.
const
renderer
=
new
THREE
.
WebGLRenderer
({
alpha
:
true
,
preserveDrawingBuffer
:
true
,
canvas
:
canvas
,
context
:
gl
});
renderer
.
autoClear
=
false
;
// The API directly updates the camera matrices.
// Disable matrix auto updates so three.js doesn't attempt
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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