"Immersive Virtual Reality Experience with Curved Plane and Interactive Text in

While the Aframe API already supports curved images, I'm interested in creating curved text and planes as well. Can anyone provide guidance on how to achieve this?

I believe I need to create an entity for this purpose, but I am unsure about which properties need to be set. Any assistance would be greatly appreciated.

Answer №1

To achieve curved text, I recommend utilizing the https://github.com/mayognaise/aframe-html-shader. This technique involves creating a partial cylinder where the material is rendered on the inside with repeat: -1 1.

The HTML shader allows us to generate a texture using HTML for our text and then apply this texture to the cylinder shape. Unfortunately, manually applying repeat: -1 1 is required since this option is not readily available. Here's an outline of the process...

<!DOCTYPE html>
<html>
  <head>
    <title>Hello, WebVR! - A-Frame</title>
    <meta name="description" content="Hello, WebVR! - A-Frame">
    <script src="https://aframe.io/releases/0.6.0/aframe.min.js"></script>
    <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="47262135262a226a6e292532256e302b222722656b2620222e">[email protected]</a>/dist/aframe-html-shader.min.js">
  </head>
  <body>
    <script>
      AFRAME.registerComponent('update-repeat', {
        dependencies: ['material'], 

        init: function () {
          var texture = this.el.components.material.material.map;
          texture.repeat = new THREE.Vector2(-1, 1);
          texture.needsUpdate = true;
        }
      });
    </script>

    <div id="texture" style="width: 100%; height: 100%; position: fixed; left: 0; top: 0; z-index: -1; overflow: hidden">
      <p style="position: relative; top: 20px; font-size: 72px">HELLO HELLO</p>
      <p style="position: relative; top: 20px; font-size: 48px">curvy text</p>
    </div>

    <a-scene>
      <a-entity geometry="primitive: cylinder; radius: 2; segmentsRadial: 48; thetaLength: -160; openEnded: true"       
                material="shader: html; target: #texture; side: double; width: 500; height: 300; transparent: true" update-repeat position="0 0 -4" rotation="0 -90 0"></a-entity>
      <a-sky color="#FAFAFA"></a-sky>
    </a-scene>
  </body>
</html>

For a detailed example, check out this Glitch project created for comprehensive guidance

Access the live demo here

Answer №2

For a unique solution, simply utilize a-curvedimage with src="#canvas". Within the canvas element, you have the freedom to generate whatever your heart desires.

<!DOCTYPE html>
<html>
    <head>
        <script src="https://aframe.io/releases/1.0.3/aframe.min.js"></script>
    </head>
    <body>

    <a-scene>
        <a-assets>
            <canvas id="myCanvas"></canvas>
        </a-assets>

        <a-curvedimage
            src="#myCanvas"
            radius="2"
            theta-length="30"
            rotation="0 160 0"
            >        
        </a-curvedimage>
    </a-scene>

    <script>
        var canvas = document.getElementById("myCanvas");
        var ctx = canvas.getContext("2d");
        ctx.fillStyle = "#000"
        ctx.font = "22px sans-serif";
        ctx.fillText("Lorem ipsum dolor sit amet", 0, 30);
    </script>
</body>
</html>

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

Gremlin, can you tell me where the "valueMap()" function has been imported from in JavaScript?

Working with ES6 on Node.js, I am attempting to execute the project() step within a Gremlin query. For this projection, my goal is to extract the properties. In the Gremlin console, I would typically use valueMap() to retrieve these properties. However, ...

Leveraging the 'require' method in Node.js for linking with external JavaScript files

Recently, I've been experimenting with using the require function in nodejs to access JavaScript files containing simple scripts. My objective is to require the script and then output its return value to the console. Here's an example of what I c ...

What is the best way to limit a form to only allow 2 checkbox selections?

Seeking advice on implementing a form for a website giveaway featuring 3 prizes. Each participant should only be able to select 2 items from the list. I've already created a JavaScript-based form, but I'm concerned about its reliability since it ...

Troubleshooting problems with dropdown binding in Knockout ObservableArray

I am encountering an issue with fetching data from a restful wcf service during page load and binding it to a dropdown, which is not functioning as expected. function CreateItem(name, value) { var self = this; self.itemNam ...

Trouble with second function invocation in JavaScript

After creating two sets of arrays and passing them into different functions, I noticed some strange behavior. The first time I called the functions for scores1, everything worked perfectly. Likewise, the second time I called the first function (for Scores2 ...

Retrieve vuex state in a distinct axios template js file

I have encountered an issue with my Vue project. I am using Vuex to manage the state and making axios requests. To handle the axios requests, I created a separate file with a predefined header setup like this: import axios from 'axios' import st ...

Employ the parameter within the main object

I currently have this code snippet in my function: add(messenger) { switch (messenger) { case 'skype': this.messengers = _.assign(this.messengers, {skype: ''}) break case 'telegram': this.messenge ...

Passing a value from a Pop-Up window to its parent JavaScript variable through the use of window.opener or alternative methods

On my HTML page (let's call it the Parent Page), I have a link that opens a pop-up (Child Page) when clicked. However, I need to set a JavaScript variable on theParent Page using JavaScript code from the pop-up page. I attempted to use window.opener ...

What is the best way in React to handle large operations, such as filtering and mapping a 10000-row array, asynchronously in order to prevent the UI from being blocked?

Currently, my table contains a large amount of data. Whenever I apply a filter, the data needs to be filtered and remapped, causing a delay of approximately 1-2 seconds. However, during this processing time, the UI becomes unresponsive. Is there a method ...

What is the reason for the ng-style function being called twice?

In my angular application, I have defined a module called 'ngStyleApp' with a controller named 'testCtrl' that contains a list of numbers and a function to return styles based on the index. angular.module('ngStyleApp', []) . ...

Troubleshooting: React.js State not updating properly on forms

New to React and facing a challenge with changing the state of form inputs. Here's what I'm trying to do: constructor(props) { super(props); this.state = { pwd:'', email:'', value:'' ...

A step-by-step guide on incorporating box-shadow for the jackColor in the Switchery Plugin

I am looking to add a box shadow to my iOS7 style switches for checkboxes when they are checked. Here is the code I have so far: var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch')); elems.forEach(function (html) { va ...

Display only a loading image with a see-through background after submitting the page

After submitting the page, I would like to display a loading image in the middle of the page with a transparent background. The current styling code I have used is as follows: #loading { position: fixed; top: 50%; left: 50%; z-index: 1104; ...

Launch a modal from a separate webpage

I've been trying to implement a modal using Bootstrap 4, and after referring to the documentation, it seems to be working smoothly. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/> <scri ...

Encountering internal server error while utilizing multipart/form-data with Express and KrakenJS

I am facing a challenge with executing a post request using multipart/form-data. Every post request I make results in an Error: Forbidden. The console output is as follows: Error: Forbidden 127.0.0.1 - - [Sat, 12 Apr 2014 20:08:33 GMT] "POST /addComic HTT ...

The function successfully triggers when clicked using (React, JS, TS) but does not respond to key presses

When the function is called with "onClick", it works correctly, but when called with "onKeyPress", it does not execute an if statement. scenario Consider a scenario where you can search for food recipes (e.g. "pizza") and receive a list of recipes from a ...

Nestjs struggles with resolving dependencies

Having trouble finding the issue in my code. (I'm still new to nestjs and trying to learn by working on some apps). The console log is showing the following error: Nest can't resolve dependencies of the UrlsAfipService (?). Please ensure tha ...

The browser fails to display the canvas when using the fillRect function

As a novice in Canvas, I've been experimenting with some code, but unfortunately, it's not working for me. Here's the code I used. Can someone help me identify the issue? <!DOCTYPE html> <html> <head> <title> 28 ...

Creating a multi-step form in Rails without using the Wizard gem allows for more

My Rails 3.2.14 app gathers call data and the new/edit action form is quite lengthy on a single page. I am interested in implementing a multistep form using JS/client side processing to navigate between steps. While considering the Wicked Gem for multi-ste ...

When you click on a list of links, a stylish image gallery will appear using fancybox

Can anyone lend a hand with this? I would greatly appreciate any assistance CSS <a id="fancybox" href="javascript:;">Gallery 1</a> <br /> <a id="fancybox" href="javascript:;">Gallery 2</a> <br /> <a id="fancybox" hr ...