npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aframe-htmlembed-component-1.3.0-ready

v1.0.17

Published

HTML Embed is a component created for A-Frame. The HTML Embed component allows for arbitrary html to be inserted into your aframe scene. It allows you to update the display within A-Frame simply by manipulating the DOM as you normally would.

Downloads

60

Readme

HTML Embed Component A-Frame 1.3.0 ready

This package is a fork of the https://github.com/supereggbert/aframe-htmlembed-component component.

The original component unfortunately looks abandoned and did not work with aframe 1.3.0. The entity was not displayed in the scene, which was accompanied by a warning in the console:

  • Firefox: "WebGL warning: texSubImage: Offset+size must be <= the size of the existing specified image."
  • Chrome: "[.WebGL-00005B4402385500] GL_INVALID_VALUE: Offset overflows texture dimensions."

This package has been modified to fix the above problem. There is also pull-request to source project: https://github.com/supereggbert/aframe-htmlembed-component/pull/35

Repo: https://github.com/arkonsolutions/aframe-htmlembed-component-1.3.0-ready

What's new?

  • The component works with AFRAME version 1.3.0.
  • Fixed an issue with performance degradation when multiple menus are added to a scene. Or when adding and hiding the same menu many times.
  • Improved mechanism for releasing unused resources.
  • Reduced time of the first appearance of the menu on the screen (if it is not displayed at startup).
  • Now the touch screen (smartphone) works as well.
  • Fixed WebGL error issue when сhanging HTML after the first display.

HTML Embed Component

HTML Embed is a component created for A-Frame. The HTML Embed component allows for arbitrary html to be inserted into your aframe scene. It allows you to update the display within A-Frame simply by manipulating the DOM as you normally would.

In addition to rendering the html to the A-Frame scene it allows for interaction. Most css pseudo selectors such as hover, active, focus and target should work with interactivity enabled without any modifications to your css. Mouse events can be attached to the html elements as usual.

Limitations

  • All styles and images must be in the same origin or allow access via CORS; this allows the component to embed all of the assets required to render the html properly to the canvas via the foreignObject element.
  • transform-style css is limited to flat. This is mainly due to it not being rendered properly to canvas so element bounding for preserve-3d has not yet been implemented. If the rendering is fixed as some point I may go back and get it working as well.
  • "a-" tags do not render correctly as XHTML embeded into SVG, so any parent "a-" elements of the embed html will be converted to div tags for rendering. This may mean your css will require modification.
  • Elements that require rendering outside of the DOM such as the iframe and canvas element will not work.
  • :before and :after pseudo elements can't be accessed via the DOM so they can't be used in the element to determine the object bounds. As such, use them with caution.
  • Form elements are not consistently rendered to the canvas element so some basic default styles are included for consistency.
  • Currently there is no support for css transitions.

Properties

| Property | Default | Description | |----------|---------|-------------| | ppu | 256 | number of pixels to display per unit of the aframescene. |

Methods

| Method | Description | |--------|-------------| | forceRender | Forces the htmlembed component to be re-render |

Events

| Name | Event Type | Description | |------|-------|-------------| |focusableenter | FocusableEvent | Dispatched when the cursor is moved over a focusable element. Useful for providing visual/haptic feedback to the user letting them know that the element is clickable. | | focusableleave | FocusableEvent | Dispatched when the cursor is moved out of a focusable element. | | inputrequired | InputrequiredEvent | Dispatched when an element that requires keyboard input or a user selection is clicked. Can be used to bring up a custom keyboard. | | resized | N/A | Dispatched when the embed html content size is changed. | | rendered | N/A | Dispatched when the embedded HTML content is rendered to the A-Frame Scene. |

FocusableEvent

| Property | Description | |----------|-------------| | target | The target element that the cursor is over. |

InputrequiredEvent

| Property | Description | |----------|-------------| | target | The input element that the user selected. ||

How to Use

To use the component you just add the component to the A-Frame entity containing the html. For example:

<a-scene>
  <a-entity htmlembed position="0 0 -5">
    <h1>An Example</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    <img src="myImages.png" alt="image">
  </a-entity>
</a-scene>

Interactivity

Using CSS

HTML Embed allows you to add interactivity by adding standard css interactions such as hover:

.button{
	display: inline-block;
	border-radius: 5px;
	background-color: #dddddd;
	color: #000000;
}
.button:hover{
	background-color: #000000;
	color: #ffffff;
}
<a-scene>
	<a-entity htmlembed>
		<a href="#home" class="button">Home</a>
	</a-entity>
</a-scene>

Using Javascript

You can add javascript interactivity in the standard way either by events on the elements themselves or alternatively by adding event listeners to the DOM.

<a-scene>
	<a-entity htmlembed>
		<div id="clickme" onclick="console.log('do something')">Click Me</div>
	</a-entity>
</a-scene>
document.querySelector('#clickme').addEventListener('click',function(e){
	console.log('do something else');
});

Interactions

Interactions are achived though the normal cursor and laser-controls components and allow you to interacte with the html as if you where using a mouse. If an element is clicked that requires keyboard input the inputrequired event is dispatched so a keyboard overlay can be invoked.

Installation

Browser

Install and use by directly including the browser files:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
  <script src="https://supereggbert.github.io/aframe-htmlembed-component/dist/build.js"></script>
</head>

<body>
  <a-scene>
    <a-entity position="0 1.6 -1" htmlembed>
		<p>My HTML</p>
	</a-entity>
  </a-scene>
</body>
	

npm

Install via npm:

npm install aframe-htmlembed-component

Then register and use.

require('aframe');
require('aframe-htmlembed-component');

Building

  • Install Node.js.

  • Clone the project to your file system:

git clone https://github.com/supereggbert/aframe-htmlembed-component.git
  • enter the aframe-htmlembed-component directory.

cd ./aframe-htmlembed-component

  • Install build dependencies

npm install

  • Run the build script.

npm run build

The compiled file is at aframe-htmlembed-component/dist/build.js