Giter Site home page Giter Site logo

babylonjs-shaders's Introduction

HTML2DLabel

HTML2DLabel is a class for Babylon.js that allows you to create HTML elements synchronized with 3D positions within the scene. This can be useful for labels, tooltips, or any HTML content that needs to follow a 3D object.

Installation

To install this package, use npm:

npm install html-2d-label

Usage

Importing the Class

import { HTML2DLabel } from "html-2d-label";
import { Scene, Vector3 } from "@babylonjs/core";

Creating an HTML2DLabel

const labelElement = document.createElement('div');
labelElement.innerText = 'Hello, World!';

const html2DLabel = new HTML2DLabel(
  "myLabel",
  {
    htmlElement: labelElement,
    center: true,
    onCameraMoveOnly: false,
    distanceFactor: 1.0
  },
  scene
);

html2DLabel.position = new Vector3(0, 1, 0);
scene.addMesh(html2DLabel);

Parameters

  • name: string
    • The name of the label.
  • options: object
    • htmlElement: HTMLElement: The HTML element to attach.
    • center?: boolean: Center the HTML element (default: false).
    • onCameraMoveOnly?: boolean: Update position only when the camera moves (default: false).
    • el?: string: The HTML element tag to create (default: div).
    • distanceFactor?: number: Scale factor based on distance from the camera (default: 1).
  • scene: Scene
    • The Babylon.js scene.

Dispose

html2DLabel.dispose()

Disposes the HTML2DLabel and removes the HTML element from the DOM.

babylonjs-shaders's People

Contributors

bhushan-ctruh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.