Display an interactive HTML element in the scene. html-pointer component " /> Display an interactive HTML element in the scene. html-pointer component " /> Display an interactive HTML element in the scene. html-pointer component "/>

Element for displaying HTML based on THREE.js HTMLMesh

Overview

AFrame-HTML

<a-entity html="#my-interface" position="0 1.5 -0.5"></a-entity>

image

Display an interactive HTML element in the scene.

html-pointer component

Property Type Description Default
activationType string Use an event for mouse down and up or proximity between two elements. One of event, proximity "event"
downEvents array Event to trigger 'mouseDown' events ["selectstart"]
upEvents array Event to trigger 'mouseUp' events ["selectend"]
clickEvents array Event to trigger 'click' events ["select"]

html component

Type Description Default
selector HTML element to use.
Comments
  • Proper cleanup when removing html component

    Proper cleanup when removing html component

    I'm using solidjs to create an ui on the wrist. I render the dom element when necessary when entering vr mode, and setting the html component on the wrist at that moment. When I remove the dom element when exiting vr mode, I also remove the html component, but I got the following error because the setTimeout was run after the the dom element was removed:

    core:a-node:error Failure loading node:   DOMException: Failed to execute 'arcTo' on 'CanvasRenderingContext2D': The radius provided (-2) is negative.
        at r (https://192.168.1.15:8080/cdn/npm/[email protected]/build/aframe-html.min.js:1:2333)
        at e (https://192.168.1.15:8080/cdn/npm/[email protected]/build/aframe-html.min.js:1:4782)
        at e (https://192.168.1.15:8080/cdn/npm/[email protected]/build/aframe-html.min.js:1:5734)
        at e (https://192.168.1.15:8080/cdn/npm/[email protected]/build/aframe-html.min.js:1:5734)
        at s (https://192.168.1.15:8080/cdn/npm/[email protected]/build/aframe-html.min.js:1:5769)
        at new i (https://192.168.1.15:8080/cdn/npm/[email protected]/build/aframe-html.min.js:1:674)
        at new t (https://192.168.1.15:8080/cdn/npm/[email protected]/build/aframe-html.min.js:1:73)
        at n.update (https://192.168.1.15:8080/cdn/npm/[email protected]/build/aframe-html.min.js:1:6387)
        at n.initComponent (https://192.168.1.15:8080/cdn/gh/aframevr/aframe@75898345005d43d2d48f6ddd4249aa93d7676613/dist/aframe-master.min.js:2:412843)
        at n.updateProperties (https://192.168.1.15:8080/cdn/gh/aframevr/aframe@75898345005d43d2d48f6ddd4249aa93d7676613/dist/aframe-master.min.js:2:412373)
    

    There is actually a clearTimeout already in HTMLMesh dispose but you didn't call mesh.dispose() in your remove(). I also fixed removing all the listeners.

    opened by vincentfretin 12
  • Support YouTube videos

    Support YouTube videos

    Hey Ada. Thanks for the great work with all of your repos. Your aframe-xr-boilerplate scene is brilliant!

    I was having a quick play with this to see if it is possible to render videos with this method by using a simple iframe or video tag. So far it's not displaying anything. I wonder if you had tried it?

    There seems to be a way using THREE.js as shown here: https://codepen.io/asjas/pen/pWawPm

    opened by aaweb 2
  • Backport code style changes from three.js repo

    Backport code style changes from three.js repo

    for easier comparison in the future of the HTMLMesh.js file, especially if we're adding new features to it, see #3

    There is absolutely no bug fixes here, so don't do a new release for that. ;)

    opened by vincentfretin 1
  • iframes not working

    iframes not working

    ##I tried displaying iframes using this component and the result was a blank screen.

    <html>
    
    <head>
        <meta charset="utf-8" />
        <title>Basic Example — AFrame HTML</title>
        <meta name="description" content="Basic Example — AFrame HTML" />
        <style>
    		body {
    			font-size: 16px;
    		}
    		* {
    			box-sizing: border-box;
    		}
    		#dom-overlay {
    			font-family: Sans-Serif;
    			color: white;
    		}
    		#dom-overlay .overlay-footer {
    			background: #00000066;
    			padding: 1em;
    			margin: 0;
    			position:absolute;
    			inset:auto 0 0 0;
    		}
        </style>
    	<script src="aframe-master.js"></script>
    	<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/handy-controls.min.js"></script>
    	<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/magnet-helpers.min.js"></script>
    	<script
    		src="https://cdn.jsdelivr.net/npm/[email protected]/dist/aframe-environment-component.min.js"></script>
    	<script src="build/aframe-html.js"></script>
    </head>
    
    <body>
    	<a-scene
    		webxr="overlayElement:#dom-overlay;"
    		reflection="directionalLight:#dirlight;"
    		renderer="alpha:true;physicallyCorrectLights:true;colorManagement:true;exposure:1;toneMapping:ACESFilmic;"
    		gltf-model="dracoDecoderPath: https://cdn.jsdelivr.net/npm/[email protected]/examples/js/libs/draco/gltf/;"
    		shadow="type: pcfsoft"
    		cursor="rayOrigin: mouse" raycaster="objects: [html]; interval:100;"
    	>
    
    		<a-assets>
    			<a-mixin id="blink" blink-controls="cameraRig: #cameraRig; teleportOrigin: #head; collisionEntities:.navmesh;"></a-mixin>
    		</a-assets>
    
    		<a-sphere color="black" radius="0.01" id="cursor" material="shader:flat"></a-sphere>
    
    		<a-entity id="cameraRig" spawn-in-circle="radius:3">
    			<!-- camera -->
    			<a-entity class="avatar-head" camera="near:0.01;" look-controls="pointerLockEnabled: false"
    				wasd-controls="acceleration:20;" simple-navmesh-constraint="navmesh:.navmesh;fall:0.5;height:1.65;"
    				position="0 1.65 0"></a-entity>
    
    			<!-- Hand tracking -->
    			<a-entity handy-controls="materialOverride:both;" material="color:gold;metalness:1;roughness:0;">
    
    				<!-- These also do teleportaion for Blink controls in VR -->
    				<!-- These are present for hand tracking but hands don't have joysticks so do nothing -->
    				<a-entity data-right="ray" mixin="blink" cursor raycaster="showLine: true; far: 100; lineColor: red; objects: [html]; interval:100;"></a-entity>
    				<a-entity data-left="ray" mixin="blink" cursor raycaster="showLine: true; far: 100; lineColor: red; objects: [html]; interval:100;"></a-entity>
    
    				<!-- Use the finger tips for teleporting when the user points in VR with hand tracking -->
    				<a-entity data-right="index-finger-tip" mixin="blink"
    					blink-controls="startEvents:pose_point;cancelEvents:pose_cancel_point;endEvents:pose_point_fuseLong;">
    				</a-entity>
    				<a-entity data-left="index-finger-tip" mixin="blink"
    					blink-controls="startEvents:pose_point;cancelEvents:pose_cancel_point;endEvents:pose_point_fuseLong;">
    				</a-entity>
    
    				<!-- These get drawn towards grabable objects, moving the whole hand and the attached elements-->
    				<a-entity id="left-magnet" position="0 0.6 0" class="avatar-hand-left" data-left="grip"
    					data-magnet="magnet-left"
    					grab-magnet-target="startEvents:squeezestart,pose_fist;stopEvents:pose_flat_fuseShort,squeezeend;noMagnetEl:#left-no-magnet;">
    				</a-entity>
    				<a-entity id="right-magnet" position="0 0.6 0" class="avatar-hand-right" data-right="grip"
    					data-magnet="magnet-right"
    					grab-magnet-target="startEvents:squeezestart,pose_fist;stopEvents:pose_flat_fuseShort,squeezeend;noMagnetEl:#right-no-magnet;">
    				</a-entity>
    
    				<!-- markers to let us know the real location of the hands, you probably want to make them visible="false" or just make them empty <a-entities> -->
    				<a-entity id="left-no-magnet" data-left="grip" data-no-magnet radius="0.01">
    					<a-entity html="cursor:#cursor;html:#my-interface" position="-0.142 -0.0166 -0.02928" rotation="-80 90 0" scale="0.5 0.5 0.5"></a-entity>
    				</a-entity>
    				<a-entity id="right-no-magnet" data-right="grip" data-no-magnet radius="0.01"></a-entity>
    			</a-entity>
    		</a-entity>
    
    
    		<a-light id="dirlight" shadow-camera-automatic=".navmesh" intensity="0.7"
    			light="castShadow:true;type:directional" position="40 80 0"></a-light>
    		<a-light type="hemisphe
    ![Screenshot 2022-08-29 083413](https://user-images.githubusercontent.com/69774063/187138382-eb563575-7018-4d20-bf54-a3cd4c799bb4.png)
    ![Screenshot 2022-08-29 083413](https://user-images.githubusercontent.com/69774063/187138476-480d1a4c-4d08-4ab1-ac6e-feda3969e1f2.png)
    
    re" ground-color="orange" color="blue" intensity="0.3"></a-light>
    		<a-circle hide-on-enter-ar shadow="cast:false" class="navmesh" rotation="-90 0 0" radius="6"
    			material="shader:phong;color:paleblue;"></a-circle>
    		<a-entity hide-on-enter-ar position="0 -0.2 0" environment="lighting:none;preset:yavapai;skyType:atmosphere;">
    		</a-entity>
    		<a-torus-knot position="0 1.5 -1" radius="0.1" radius-tubular="0.02" material="shader:phong;reflectivity:0.3;" id="knot"></a-torus-knot>
    		<a-entity html="cursor:#cursor;html:#my-interface" shadow position="0.25 1.5 -0.5"></a-entity>
    	</a-scene>
    
    	<div id="dom-overlay">
    		<header style="pointer-events: none; user-select: none;">
    			<h1>
    				My Metaverse Site
    			</h1>
    		</header>
    		<section style="display: inline-block; background: lavenderblush; color: #333333; border-radius: 1em; padding: 1em; margin:0; accent-color: hotpink;" id="my-interface">
    			<iframe src="index.html"></iframe>
    		</section>
    	</div>
    </body>
    
    </html>
    
    

    The result looks something like this:

    Screenshot 2022-08-29 083413

    Is this wanted behaviour (iframes are not supported)?. if so, will iframe support be added in the future?

    opened by PietroAmmaturo 1
  • Implement text wrapping

    Implement text wrapping

    I create the PR in draft with just the changes related to text wrapping to gather feedback if you have any. Capture d’écran du 2022-12-20 17-52-02

    I based my getLines function from https://stackoverflow.com/a/16599668

    opened by vincentfretin 0
  • offset interactive elements

    offset interactive elements

    I am tempted to create two canvases and two meshes where one physically sits slightly offset.

    Buttons handles checkboxes radio buttons etc would be rendered to the offset one instead of the one underneath

    Once that layer is rendered then render it blurred and flat colour semi transparent grey to the layer below to give a nice shadow, it's a bit more expensive but would look pretty.

    opened by AdaRoseCannon 0
  • Hover on button

    Hover on button

    This references #3 Don't merge it just yet. I opened the PR as draft for discussion and if anyone want to test it. I'm still experimenting, I added the behavior only on button, but it should be added to input of type submit and button as well. Do we need it on other elements? If we move too quickly out of the button, the active or hover classes aren't deleted. I need to investigate that, we should have the mouseleave event from the whole div normally so this is strange...

    I'm testing on this button styled with tailwindcss:

    <button
      onClick="AFRAME.scenes[0].exitVR();"
      class="btn-red"
    >
      Exit Immersive
    </button>
    

    and

    .btn-red {
        @apply bg-red-600;
        &:hover,
        &.hover {
          @apply bg-red-700;
        }
      }
    
    opened by vincentfretin 13
  • Backdrop proposal for readibility

    Backdrop proposal for readibility

    As background seems to be transparent by default sometimes having a backdrop helps, in particular when there is text.

    const geometry = new THREE.PlaneGeometry( el.object3D.children[0].geometry.parameters.width*1.1,
                    el.object3D.children[0].geometry.parameters.height*1.1 );
    const material = new THREE.MeshBasicMaterial( {color: 0xffffff, side: THREE.DoubleSide} );
    const plane = new THREE.Mesh( geometry, material );
    plane.position.z = -.1
    el.object3D.add( plane );
    

    I tend to use this relatively often. If useful to others could be an optional, disabled by default, parameter for the component. Itself with color as a parameter.

    opened by Utopiah 1
Owner
Ada Rose Cannon
Front End Web Developer & Developer Advocate at Samsung. Co-chair of the W3c Immersive Web working group.
Ada Rose Cannon
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Text Engraving & Extrusion demo based on Three.js is implemented with Typescript and webpack5. Used THREE-CSGMesh as the core tech to achieve engraving and extrusion results

Text Engraving & Extrusion Text Engraving & Extrusion demo is implemented using Three.js, with Typescript and webpack5. Used THREE-CSGMesh as the core

Jiahong Li 3 Oct 12, 2022
three.js examples. if you are first in learning three.js , this will give you much help.

three-projected-material Three.js Material which lets you do Texture Projection on a 3d Model. Installation After having installed three.js, install i

null 22 Nov 2, 2022
Kuldeep 2 Jun 21, 2022
Awesome Books project : An online Book Library. Storing book information using local storage and displaying it as a list on HTML page

This is project is my based on building an online Book Library. Storing book information using local storage and displaying it as a list on html page

Richard Chileya 7 Nov 11, 2022
JavaScript API based capstone project using TVmaze API for displaying and interacting with items from the data base.

Yuriy Chamkoriyski & Bonke Gcobo Javascript capstone project API-based webapp from Module 2 at Microverse Wireframe requirements The Home Page low fid

Yuriy Chamkoriyski 5 May 30, 2022
JavaScript micro-library: pass in an element and a callback and this will trigger when you click anywhere other than the element

Add a click listener to fire a callback for everywhere on the window except your chosen element. Installation run npm install @lukeboyle/when-clicked-

Boyleing Point 5 May 13, 2021
📦 An aframe component for displaying live stock tickers.

aframe-stock-ticker An aframe component for displaying live stock tickers. Also works with cryptocurrency and forex. Usage crypto-chart To create a cr

Mitarai 7 Jun 26, 2022
Displaying actual age in percentage with 9 signs after dot (floating number)

Actual Age Chrome Extension Displaying actual age in percentage with 9 signs after dot (floating number) Features Popup You can select your Birth date

Igor Makeenko 22 Nov 2, 2022
App for displaying geospatial data on queues on the Polish-Ukrainian border.

Live app embedded here. App helps coordinate volunteer work with refugees from Ukraine on Polish-Belarusian Border. Data comes from Grupa Granica – a

null 3 Mar 10, 2022
A lightweight JavaScript library that renders text in a brilliant style by displaying strings of random characters before the actual text.

cryptoWriter.js A lightweight javascript library which creates brilliant text animation by rendering strings of random characters before the actual te

Keshav Bajaj 2 Sep 13, 2022
jQuery pop-up script displaying various types of content in corner of browser

Corner Popup v1.30 Fully customizable pop-up box created to display all types of messages in corner of your browser. Website: https://espritdesign.pl/

Łukasz Brzostek 24 Nov 27, 2022
An App for backing up and better displaying Onetab data Powered by Tauri.

Onetab Re 『Data is Priceless』 Onetab Re 是一款用于备份并原样展示Onetab数据的应用,基于 Tauri 跨平台构建,支持 Windows macOS Linux. 备份脚本使用方法 请先确认已经正确安装node.js 安装后打开软件的scripts目录, 为

ziyu 9 Nov 12, 2022
A small jQuery plugin for displaying Muslim Prayer Times

jquery-prayer-times A small jQuery plugin for displaying Muslim Prayer Times. Features! English/Arabic language support. Auto detect visitor location.

Muhammad Mabrouk 3 Oct 30, 2022
Dynamic island style widget for displaying what you're recently played on Spotify.

Spotify Island Dynamic island style widget for displaying what you're recently played on Spotify. ?? Check the demo spotify-island.mov 1. Get Spotify

Nurçin 5 Nov 24, 2022
Chromium extension for displaying all the available formats of an AppleMusic album.

AppleMusic-Formats-Extension Chromium extension for displaying all the available formats of an AppleMusic album. Before Vs After How to Install? From

bunny 7 Dec 16, 2022
A site displaying Rice University's O-week family tree .

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Adam Zawierucha 7 Dec 5, 2022