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 🙏

© 2026 – Pkg Stats / Ryan Hefner

fspy2vmd

v0.1.0

Published

fSpy camera data applier and VMD exporter for Three.js

Readme

fspy2vmd

fSpy のカメラ情報を threePerspectiveCamera に反映し、 そのカメラ状態から MMD 用 VMD カメラモーションを出力するライブラリです。

できること

  • fSpy JSON の値を PerspectiveCamera に適用
  • PerspectiveCamera から VMD カメラモーション (ArrayBuffer) を生成
  • 型定義付きで利用可能(TypeScript 対応)

インストール

three は peer dependency です。

npm install fspy2vmd three
yarn add fspy2vmd three
pnpm add fspy2vmd three

クイックスタート

import * as THREE from "three";
import { FspyVmdConverter, type FspyData } from "fspy2vmd";

const camera = new THREE.PerspectiveCamera(75, 16 / 9, 0.1, 2000);

// fSpy の JSON データをそのまま渡せます
const fspy: FspyData = /* your fSpy JSON */;

const converter = new FspyVmdConverter(camera, {
  distanceBaseMultiplier: 5,
});

// 1) fSpy をカメラへ適用
converter.applyFSpyToCamera(fspy);

// 2) VMD を生成(戻り値は ArrayBuffer)
const vmdBuffer = converter.exportVmd({
  distanceMultiplier: 1,
  target: [0, 0, 0],
  frameTime: 0,
});

主要 API

new FspyVmdConverter(camera, options?)

  • camera: PerspectiveCamera 変換対象カメラ
  • options?: FspyVmdConverterOptions
  • distanceBaseMultiplier?: number 距離計算の基準倍率(デフォルト: 5

applyFSpyToCamera(fspy, opts?)

fSpy データを内部カメラに適用します。

  • fspy: FspyData
  • opts?: ApplyFSpyToCameraOptions
  • near?: number(デフォルト: 0.01
  • far?: number(デフォルト: 2000

exportVmd(options?)

内部カメラ状態を VMD バイナリに変換して返します。

  • 戻り値: ArrayBuffer
  • options?: ExportVmdOptions
  • distanceMultiplier?: number(デフォルト: 1
  • target?: [number, number, number](デフォルト: [0, 0, 0]
  • frameTime?: number(デフォルト: 0

writeCameraVmd(cameraFrames)

CameraFrame[] を直接 VMD バイナリ化します。 モデル名は固定で "カメラ・照明"(Shift-JIS)を書き込みます。

補助メソッド

  • createDefaultCameraCurve() 線形補間用カーブ(24 要素)を返す
  • getCamera() 内部保持している PerspectiveCamera を返す
  • getFspyData() 内部保持している fSpy データ(防御的コピー)を返す
  • getOptions() コンバータ設定(読み取り用)を返す

エラー

不正な入力や利用順序エラー時には FspyVmdConverterError が投げられます。

  • FSPY_VMD_CONVERTER_ERROR_CODE.FSPY_DATA_NOT_SET
  • FSPY_VMD_CONVERTER_ERROR_CODE.INVALID_CAMERA_TRANSFORM_ROWS_SIZE
  • FSPY_VMD_CONVERTER_ERROR_CODE.INVALID_CAMERA_TRANSFORM_VALUE
import {
  FSPY_VMD_CONVERTER_ERROR_CODE,
  FspyVmdConverterError,
} from "fspy2vmd";

try {
  converter.applyFSpyToCamera(fspy);
  const vmd = converter.exportVmd();
} catch (error) {
  if (
    error instanceof FspyVmdConverterError &&
    error.code === FSPY_VMD_CONVERTER_ERROR_CODE.INVALID_CAMERA_TRANSFORM_ROWS_SIZE
  ) {
    // cameraTransform.rows が 4x4 ではない場合
  }
}

注意点

  • exportVmd() の前に applyFSpyToCamera() を呼んでください
  • 出力されるのは VMD カメラモーションのバイナリです(ArrayBuffer
  • ライブラリ側はファイル保存を行わないため、保存処理は利用側で実装してください