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

@vmosedge/sensor-simulator

v1.0.1

Published

Android Sensor Simulator SDK - Accelerometer, Gyroscope, Magnetometer calculation based on official Android formulas

Readme

@vmosedge/sensor-simulator

Android 传感器模拟器 SDK,用于在浏览器或 Node 环境中根据旋转/位移输入计算传感器数据。

安装

npm install @vmosedge/sensor-simulator
# or
pnpm add @vmosedge/sensor-simulator

快速使用

import { SensorSimulator, DeviceOrientation } from '@vmosedge/sensor-simulator'

const simulator = new SensorSimulator()

// 监听数据变化
simulator.on('change', (sensors) => {
  console.log('accelerometer', sensors.accelerometer)
  console.log('gyroscope', sensors.gyroscope)
  console.log('magnetometer', sensors.magnetometer)
})

// 设置旋转角度 (度)
simulator.setRotation({ x: 10, y: 20, z: 30 })

// 设置设备方向 (0/90/180/270)
simulator.setDeviceOrientation(DeviceOrientation.LANDSCAPE_LEFT)

旋转模式 (Rotate)

// X: Pitch, Y: Roll, Z: Yaw (单位: 度)
simulator.setRotation({
  x: 15,
  y: -10,
  z: 45
})

移动模式 (Move)

// 位移 (单位: m)
simulator.setPosition({
  x: 1.5,
  y: 0.5,
  z: -0.3
})

// 需要在动画循环中调用 update 处理线性加速度衰减
let last = performance.now()
const animate = () => {
  const now = performance.now()
  const deltaSeconds = (now - last) / 1000
  last = now
  simulator.update(deltaSeconds)
  requestAnimationFrame(animate)
}

animate()

设备方向

simulator.setDeviceOrientation(DeviceOrientation.PORTRAIT)
simulator.setDeviceOrientation(DeviceOrientation.LANDSCAPE_LEFT)
simulator.setDeviceOrientation(DeviceOrientation.PORTRAIT_REVERSE)
simulator.setDeviceOrientation(DeviceOrientation.LANDSCAPE_RIGHT)

数据单位

  • rotation: 度 (deg)
  • position: 米 (m)
  • accelerometer: m/s^2
  • gyroscope: rad/s
  • magnetometer: uT
  • rotationVector: 四元数

可选配置

const simulator = new SensorSimulator({
  gravity: 9.80665,
  magneticField: { x: 0, y: 5.9, z: -48.4 },
  linearDecaySeconds: 0.08,
  maxLinearAccel: 34.3,
  linearEpsilon: 0.01
})

说明

SDK 仅负责传感器数值计算,不包含网络请求与 UI 渲染。