billboard module for three.js
npm install @masatomakino/threejs-billboard --save-dev
threejs-billboard depend on three.js and pixi.js.
threejs-billboard is composed of ES6 modules and TypeScript d.ts files.
At first, import classes.
import {
BillBoard,
StageBillBoard,
StagePlaneMesh,
ScaleCalculator,
} from "@masatomakino/threejs-billboard";
Add billboard in THREE.Scene.
const billboard = new BillBoard("./map01.png", 0.1);
scene.add(billboard);
The library provides different classes for creating billboards and plane meshes, each with distinct characteristics and use cases:
If you want to display dot-by-dot billboard, get image scale with ScaleCalculator.
const scale = ScaleCalculator.getNonAttenuateScale(
renderer.getSize(new THREE.Vector2()).height,
camera,
);
const billboard = new BillBoard("./map01.png", scale);
billboard.material.sizeAttenuation = false;
The CameraChaser
utility can be used with SharedStagePlaneMesh
, MultiViewPixiPlaneMesh
, and BillBoardPlane
to make the plane track the camera's rotation. By default, this feature is off. You can enable it to make the plane always face the camera, similar to a billboard but maintaining its plane geometry. Note that unlike a Sprite, the rotation is limited to the Y-axis.