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

@vis-three/plugin-loader-manager

v0.7.0

Published

vis-three loader-manager plugin

Downloads

19

Readme

@vis-three/plugin-loader-manager

加载管理器插件。

此插件为所有资源加载器提供一个统一的入口,方便进行加载资源的内存管理和时间周期管理。

最新版本

license

插件名称

LoaderManagerPlugin

:::tip 可以使用枚举:LOADER_MANAGER_PLUGIN :::

插件依赖

插件传参

export interface LoaderManagerParameters {
  /**加载器拓展 */
  loaderExtends: { [key: string]: Loader };
}

export interface LoaderManagerPluginParameters extends LoaderManagerParameters {
  /**公共前缀路径 */
  path?: string;
}

loaderExtends

支持拓展不同格式的加载资源类型和覆盖当前的加载器。

import { Loader } from "three";
class MyGLFTLoader extends Loader {}

engine.install(
  LoaderManagerPlugin({
    loaderExtends: {
      pmx: new PMXLoader(),
      glft: new MyGLTFLoader(),
    },
  })
);

:::tip

自定义的加载器建议继承three.jsLoader。 :::

path

统一的资源前缀,这个对于有不同域名的服务地址会很有用。

engine.install(
  LoaderManagerPlugin({
    path: "https://www.mywebsite.com/model",
  })
);

engine.loadResources(["/home/desk.fbx"]);

// /home/desk.fbx -> https://www.mywebsite.com/model/home/desk.fbx

引擎拓展

export interface LoaderManagerEngine extends Engine {
  /**资源加载器管理器 */
  loaderManager: LoaderManager;
  /**加载资源函数 */
  loadResources: (
    urlList: Array<LoadUnit>,
    callback: (err: Error | undefined, event?: LoadedEvent) => void
  ) => LoaderManagerEngine;
  /**异步加载资源函数 */
  loadResourcesAsync: (urlList: Array<LoadUnit>) => Promise<LoadedEvent>;
}

加载 Blob 临时链接

可以通过指定当前资源的类型进行。

engine.loadResources([
  {
    url: "blob:https://shiotsukikaedesari.gitee.io/1e09dae0-94a2-4a32-bd9f-eeae8df51907",
    ext: "glft",
  },
]);

LoaderManager

此类继承@vis-three/coreDispatcher

LOADER_EVENT

export enum LOADER_EVENT {
  BEFORELOAD = "beforeLoad",
  LOADING = "loading",
  DETAILLOADING = "detailLoading",
  DETAILLOADED = "detailLoaded",
  LOADED = "loaded",
}

event

export interface LoadDetail {
  url: string;
  progress: number;
  error: boolean;
  message: string;
}

export interface BeforeLoadEvent extends BaseEvent {
  urlList: string[];
}

export interface LoadingEvent extends BaseEvent {
  loadTotal: number;
  loadSuccess: number;
  loadError: number;
}

export interface DetailEvent extends BaseEvent {
  detail: LoadDetail;
}

export interface LoadedEvent extends BaseEvent {
  loadTotal: number;
  loadSuccess: number;
  loadError: number;
  resourceMap: Map<string, unknown>;
}

getLoader

getLoader(ext): null | Loader

获取加载器

Parameters

| Name | Type | Description | | :---- | :------- | :---------- | | ext | string | 资源类型 |

Returns

null | Loader

getResource

getResource(url): unknown

获取 url 下的资源

Parameters

| Name | Type | | :---- | :------- | | url | string |

Returns

unknown

load

load(urlList): LoaderManager

加载资源

Parameters

| Name | Type | Description | | :-------- | :------------------------------------- | :--------------------------------------- | | urlList | LoadUnit[] | string[] | [{ext: string, url: string}] |

Returns

this

register

register(ext, loader): LoaderManager

注册 loader

Parameters

| Name | Type | Description | | :------- | :------- | :------------------ | | ext | string | 文件格式: jpg | | loader | Loader | extend THREE.Loader |

Returns

this

reset

reset(): LoaderManager

重置加载管理器属性

Returns

this

setLoadDetailMap

setLoadDetailMap(map): LoaderManager

Deprecated

设置详细资源信息

Parameters

| Name | Type | | :---- | :------- | | map | Object |

Returns

this

setPath

setPath(path): LoaderManager

设置统一资源路径前缀

Parameters

| Name | Type | | :----- | :------- | | path | string |

Returns

this

setRequestHeader

setRequestHeader(headers): LoaderManager

设置请求头

Parameters

| Name | Type | | :-------- | :---------------------------- | | headers | Record<string, string> |

Returns

this

setResponseType

setResponseType(responseType): LoaderManager

设置响应类型

Parameters

| Name | Type | | :------------- | :------- | | responseType | string |

Returns

this

toJSON

toJSON(): string

Returns

string