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

lythreeframe

v2.0.0

Published

Three.js 封装

Downloads

253

Readme

lythreeframe

一个基于 Three.js 的 WebGPU/WebGL 3D 应用框架,提供类似游戏引擎的架构设计,简化 3D 场景的开发流程。

特性

  • 🎮 类 Unreal Engine 的 Actor-Component 架构
  • 🖥️ 支持 WebGPU 和 WebGL 双渲染后端
  • 📦 完善的资源管理系统(几何体、材质、纹理)
  • 🎬 内置后处理效果(Bloom、DOF、GTAO、SSR、Outline 等)
  • 🎯 射线检测与交互事件系统
  • 🎥 灵活的相机控制(轨道控制、第一人称)
  • 📐 支持透视/正交相机切换

安装

npm install lythreeframe

依赖

{
  "three": "^0.181.0",
  "@types/three": "^0.181.0",
  "gsap": "^3.12.2"
}

快速开始

import { ThreeJsApp, BoxActor, DirectionalLightActor, AmbientLightActor } from 'lythreeframe';

// 创建应用
const app = new ThreeJsApp({
  viewportParam: {
    elementId: 'canvas-container'
  }
});

// 添加光源
const dirLight = new DirectionalLightActor(app);
dirLight.setPosition(5, 10, 5);
app.world.addActor(dirLight);

const ambLight = new AmbientLightActor(app);
app.world.addActor(ambLight);

// 添加物体
const box = new BoxActor(app);
box.setPosition(0, 1, 0);
app.world.addActor(box);

核心架构

ThreeJsApp

应用入口,管理整个 3D 应用的生命周期。

World

场景管理器,负责 Actor 的添加、移除和 Tick 更新。

Viewport

视口管理,处理渲染器创建、窗口缩放和后处理管线。

Controller

输入控制器,处理鼠标交互、射线检测和相机控制。

Actor / Component

  • Actor: 场景中的实体对象,包含一个或多个 Component
  • SceneComponent: 具有 3D 变换的组件基类
  • MeshComponent: 网格渲染组件

内置 Actor

| Actor | 说明 | |-------|------| | BoxActor | 立方体 | | PlaneActor | 平面 | | DirectionalLightActor | 平行光 | | AmbientLightActor | 环境光 | | SkyActor | 天空盒 | | LevelActor | 关卡容器 |

后处理效果

import { ThreeJsApp, PostProcessStepType } from 'lythreeframe';

const app = new ThreeJsApp({
  viewportParam: { elementId: 'container' },
  postProcessParam: {
    steps: [
      { type: PostProcessStepType.Bloom, enabled: true, param: { threshold: 0.8, strength: 0.5, radius: 0.5 } },
      { type: PostProcessStepType.FXAA, enabled: true }
    ]
  }
});

支持的后处理效果:

  • Bloom(泛光)
  • DOF(景深)
  • GTAO(环境光遮蔽)
  • SSR(屏幕空间反射)
  • Outline(轮廓描边)
  • FXAA / SMAA(抗锯齿)

交互事件

// 组件级别事件
component.onClickDelegate.add(() => console.log('clicked'));
component.onHoverBeginDelegate.add(() => console.log('hover begin'));

// Actor 级别事件
actor.onClickDelegate.add((component) => console.log('actor clicked'));

// 控制器级别事件
app.controller.onComponentClickDelegate.add((event) => {
  console.log('component:', event.component);
  event.handled = true; // 阻止默认行为
});

相机控制

// 切换相机类型
app.updateCamera({
  type: 'perspective',
  fov: 60,
  near: 0.1,
  far: 1000
});

// 聚焦到目标
app.controller.focusTo(targetPosition, targetQuaternion, distance, duration);

资源管理

// 加载 GLTF 模型
const gltf = await app.assetManager.loadGltfFromPathAsync('/models/scene.glb');

// 资源会自动进行引用计数管理
app.assetManager.addAsset(geometry);
app.assetManager.releaseAsset(geometry);

销毁

app.destroy();

License

MIT