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

device-orientation-controls-es

v1.0.0

Published

DeviceOrientationControls 2023年最新版 类是一种基于 three.js 的相机控制方式,允许用户使用设备方向来控制相机。

Downloads

1

Readme

device-orientation-controls-es 类是一种基于 three.js 的相机控制方式,允许用户使用设备方向来控制相机。

构造函数接收两个参数:

  • object:要控制的相机对象。
  • rotationType:相机欧拉角使用的旋转顺序。默认为 'YXZ'

以下是该类的实例方法:

  • setRotationType(rotationType):设置欧拉角的旋转顺序。
  • debug():显示调试信息。
  • close():关闭调试信息和设备方向事件监听器。
  • update():更新物体的方向。

该类还有以下属性:

  • screenOrientation:屏幕方向。
  • alpha:设备绕 z 轴旋转的角度。
  • beta:设备绕 x 轴旋转的角度。
  • gamma:设备绕 y 轴旋转的角度。

注意:使用此类需要在设备上打开陀螺仪或加速度计功能。

MIT 许可证 (https://opensource.org/licenses/MIT)适用于该类。

demo

	// 创建场景、相机和渲染器
	var scene = new THREE.Scene();
	var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
	var renderer = new THREE.WebGLRenderer();
	renderer.setSize(window.innerWidth, window.innerHeight);
	document.body.appendChild(renderer.domElement);

	// 添加立方体到场景
	var geometry = new THREE.BoxGeometry();
	var material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
	var cube = new THREE.Mesh(geometry, material);
	scene.add(cube);

	// 创建 DeviceOrientationControls 实例
	var controls = new DeviceOrientationControls(camera);

	// 调试:显示调试信息
	//controls.debug();

	// 循环渲染场景
	function animate() {
		requestAnimationFrame(animate);

		// 更新 DeviceOrientationControls 实例
		controls.update();

		renderer.render(scene, camera);
	}
	animate();