Build an immersive experience by incorporating threejs into A-Frame to develop a spherical environment filled with 360-degree videos

I've been working on a VR project that involves 360° videos in VR. My concept was to construct a sphere and apply a 360° video as the material.

I've already managed to create my own Sphere Component and map a 360° image onto it!

Similar to this:

    <html>
<!--Information about Aframe library-->
  <head>
    <script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
  </head>
  <body>
      <script>

        AFRAME.registerComponent('mysphere', {
            schema: {
                width: {type: 'number', default: 10},
                height: {type: 'number', default: 32},
                depth: {type: 'number', default: 32}
            },

            /**
            * Initial creation and setting of the mesh.
            */
            init: function () {
              var data = this.data;
              var el = this.el;

              // Create geometry.
              this.geometry = new THREE.SphereGeometry(data.width, data.height, data.depth);        

              //Load Image
              var texture = new THREE.TextureLoader().load( '3d50eke-360-panorama-pier-miami-bayside.jpeg.jpg' );

              // Create material.
              this.material = new THREE.MeshBasicMaterial({map: texture});
              this.material.side = THREE.DoubleSide;
              console.log();

              // Create mesh.
              this.mesh = new THREE.Mesh(this.geometry, this.material);

              // Set mesh on entity.
              el.setObject3D('mesh', this.mesh);
              el.getObject3D('mesh').material = this.material;
            }
        });
      </script>
    <a-scene>

      <a-camera position="0 6 2"></a-camera>

      <a-entity mysphere
                position="0 6 2">

      </a-entity>
    </a-scene>
  </body>
</html>

Now, I'm looking for a way to avoid using a "video" tag and instead create it using THREE.VideoTexture to map it as a material on the sphere...

Does anyone have any ideas?

Answer №1

If you want to incorporate a videosphere into your project, you can utilize the pre-built videosphere component.

<a-scene>
 <a-assets>
  <video id="antarctica" autoplay loop="true" src="antarctica.mp4"> </video>
 </a-assets>
 <a-videosphere src="#antarctica"></a-videosphere>
 <!-- Alternatively, you can define the video source directly within the element. Though, this practice is not recommended but may be more convenient for some web developers. -->
 <a-videosphere src="africa.mp4"></a-videosphere>
</a-scene>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for incorporating Vue.js tag attributes in IDEA

I am using IDEA 2016.2.5 and I'm trying to incorporate Vue.js into my project. However, Vue has some tag attributes that IDEA is not recognizing and keeps highlighting as errors. I have installed the Vue Plugin and tried setting the HTML custom unkno ...

Ways to convert an object with values into an array containing those values

To process the JSON data and convert it into an array with the same values for insertion into my PostgreSQL database using pool.query(message, values), where values should be an array if multiple are present. Currently, my object structure is as follows: { ...

Customize Popover Color in SelectField Component

Looking to customize the SelectField's popover background color in material-ui. Is this possible? After exploring the generated theme, it seems that there is no option for configuring the selectField or popover. Attempted adjusting the menu's ba ...

JavaScript Bridge function in WebView not invoked

I encountered a strange issue with my application, which functions as an e-reader. To invoke functions for the web view, I utilize a JavaScript class: public class MyJavaScriptInterface { Context mContext; /* Instantiate the interface ...

What could be the reason behind receiving a 406 Not Acceptable status at the client side from the server, and why is my Spring controller not being triggered?

Here is the code for an AJAX GET request: $("#tabsss2").click(function tab1() { $.ajax({ type: "get", traditional: true, dataType: 'json', url: "DataGridServlet.htm", cache: false, ...

Place the React rendering inside a class element, rather than an ID

For my project, I need to display the same information in multiple locations using react. Instead of targeting elements by id (as shown in the code below), I would like to use class selectors. ReactDOM.render(<App />, document.getElementById('a ...

The loading spinner remains active (ng-show = loading) even after submitting the form. It should be disabled once the data has been received

I'm struggling with a scope variable issue. I have implemented a loading spinner that appears when the ng-show property is set to true after the submit button is clicked on my contact form. The goal is to set the ng-show property to false after the fo ...

HTML and JavaScript: Struggling to include multiple parameters in onclick event even after escaping quotes

I am struggling to correctly append an HTML div with multiple parameters in the onclick function. Despite using escaped quotes, the rendered HTML is not displaying as intended. Here is the original HTML code: $("#city-list").append("<div class='u ...

Adjusting the size of content tags depending on their popularity

Currently, I am working on setting up a basic tagging system by following the database structure provided in this Stack Overflow post. My goal is to create a single page that showcases all the tags, with each tag being visually scaled based on its popular ...

Can a virtual host proxy utilize an external IP address?

Currently, I have three node apps running on the same server but with different localhost ports. My goal is to create a router that acts as a proxy for each app and then place this proxy in a virtual host. While I am currently testing this setup on my loca ...

Setting a unique identifier for a newly created element in JavaScript and the DOM

Is there a way to assign an element ID to a newly created element using JavaScript DOM? The code I've written generates a table that is displayed when a button is clicked. I'm looking to give this table a unique ID so it can have a distinct sty ...

The element 'flat' is not found within the specified type

My challenge involves utilizing the flat() method in a TypeScript script. In my tsconfig.json file, I have set the target to es2017 and defined an interface for the input variable. However, I keep encountering this error message: Property 'flat' ...

Ways to adjust the height of an element using the ::before selector in javascript

Within the realm of styling, there exists an element adorned with the .bg class. Its aesthetic instructions are described as follows: .bg { width:100%; } .bg:before { position: absolute; content: ''; background: rgba(0,0,0,0.5) ...

Encountering an undefined response in API call using Fetch with Express Nuxt

I've hit a roadblock with a task involving Express, API, and Fetch. I'm utilizing Nuxt along with Shopify API endpoints to retrieve data such as orders. Below is my express API Endpoint which should return an array of objects (orders). const bod ...

Navigating through a multistep form in AngularJS using UI Router and arrow keys for seamless movement

Is there a way to navigate to the next or previous form step using arrow keys in AngularJS UI Router? The code provided below is currently allowing navigation with previous and next buttons. .config(function($stateProvider, $urlRouterProvider) { $stat ...

Two separate buttons in two distinct views that trigger the same function in AngularJS

I am currently working on a Single Page Application (SPA) that has two distinct views - one for subjects and another for students. In the subject view, there is a save button located in app/views/subject/subject.html: <button type="button" class="b ...

Surveillance software designed to keep tabs on how long visitors remain on external websites

My goal is to increase sign-ups on my website by providing users with a unique JavaScript snippet to add to their own sites. I have two specific questions: 1) If I implement the following code to track visit duration on external websites, how can I ensure ...

Utilizing Raycaster in conjunction with an Orthographic Camera

While I typically use an orthographic camera to accurately represent objects' dimensions, I have encountered a problem with intersection detection. After researching online, I discovered that pickingray was suggested as a solution, but it has since be ...

The Next.js developer encounters an issue where the build fails due to a ReferenceError on a client component, stating that "window

Just starting out with nextjs, I'm sticking to using only the basic features without diving into any advanced functionalities. During the next build process, I encountered an issue where 6 paths failed because of a ReferenceError: window is not defin ...

How to handle redirects based on status codes in AngularJS $http requests

My angular application includes numerous $http requests, and I am looking for a way to automatically redirect users to the login page in case the server session expires (resulting in a 401 error). Does anyone have a solution that can handle this for all ...