Commit af6859ec authored by Thapa's avatar Thapa
Browse files

Update 1-Cube.html

parent 7502cbb1
Pipeline #8084 passed with stage
in 6 seconds
...@@ -23,29 +23,26 @@ async function activateXR() { ...@@ -23,29 +23,26 @@ async function activateXR() {
const scene = new THREE.Scene(); const scene = new THREE.Scene();
// The cube will have a different color on each side. // Load the texture for the Earth globe.
const materials = [ const textureLoader = new THREE.TextureLoader();
new THREE.MeshBasicMaterial({color: 0x744700}), const texture = textureLoader.load('earth_texture.jpg');
new THREE.MeshBasicMaterial({color: 0x744700}),
new THREE.MeshBasicMaterial({color: 0x744700}), // Create the Earth sphere and add it to the demo scene.
new THREE.MeshBasicMaterial({color: 0x744700}), const sphere = new THREE.Mesh(
new THREE.MeshBasicMaterial({color: 0x744700}), new THREE.SphereBufferGeometry(0.5, 64, 64), // Adjust the radius as needed.
new THREE.MeshBasicMaterial({color: 0x744700}) new THREE.MeshBasicMaterial({ map: texture }) // Apply the Earth texture to the sphere.
]; );
sphere.position.set(0, 0, -1);
// Create the cube and add it to the demo scene. scene.add(sphere);
const cube = new THREE.Mesh(new THREE.BoxBufferGeometry(0.5, 0.5, 0.5), materials);
cube.position.set(0, 0, -1); // Set up the WebGLRenderer, which handles rendering to the session's base layer.
scene.add(cube); const renderer = new THREE.WebGLRenderer({
alpha: true,
// Set up the WebGLRenderer, which handles rendering to the session's base layer. preserveDrawingBuffer: true,
const renderer = new THREE.WebGLRenderer({ canvas: canvas,
alpha: true, context: gl
preserveDrawingBuffer: true, });
canvas: canvas, renderer.autoClear = false;
context: gl
});
renderer.autoClear = false;
// The API directly updates the camera matrices. // The API directly updates the camera matrices.
// Disable matrix auto updates so three.js doesn't attempt // Disable matrix auto updates so three.js doesn't attempt
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment