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-event-manager

v0.7.0

Published

物体事件管理器插件。

Downloads

8

Readme

@vis-three/plugin-event-manager

物体事件管理器插件。

安装此插件可以为场景中的物体增加鼠标事件。

目前支持的事件枚举。

export enum EVENTNAME {
  POINTERDOWN = "pointerdown",
  POINTERUP = "pointerup",
  POINTERMOVE = "pointermove",
  POINTERENTER = "pointerenter",
  POINTERLEAVE = "pointerleave",
  CLICK = "click",
  DBLCLICK = "dblclick",
  CONTEXTMENU = "contextmenu",
}

使用案例。

import * as THREE from "three";
import { EventManagerPlugin } from "@vis-three/plugin-event-manager";

engine.install(EventManagerPlugin());

const box = new THREE.Mesh(new THREE.BoxGeometry(5, 5, 5));

box.addEventListener("click", (event) => {
  console.log(event);
});

最新版本

license

插件名称

EventManagerPlugin

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

插件依赖

  • PointerManagerPlugin: @vis-three/plugin-pointer-manager

插件传参

export interface EventManagerParameters {
  /**指定事件触发场景 */
  scene: Scene;
  /**指定事件触发相机 */
  camera: Camera;
  /**是否递归场景物体子集 */
  recursive?: boolean;
  /**是否穿透触发事件,比如2个物体即使重叠都会触发 */
  penetrate?: boolean;
  // support?: boolean;
  /**射线设置 参考three.js的射线设置*/
  raycaster?: {
    params: {
      Line?: { threshold: number };
      Points?: { threshold: number };
    };
  };
}

引擎拓展

export interface EventManagerEngine extends PointerManagerEngine {
  eventManager: EventManager;
}

EventManager

此类继承@vis-three/coreEventDispatcher

camera

Private camera: Camera

目标相机

delegation

delegation: boolean = false

Todo

以事件委托的形式触发事件

filter

Private filter: Set<Object3D<Event>>

不会触发事件的过滤器

penetrate

penetrate: boolean = false

事件穿透

propagation

propagation: boolean = false

Todo

以事件冒泡的形式触发事件

raycaster

raycaster: Raycaster

射线发射器

recursive

recursive: boolean = false

递归子物体

scene

Private scene: Scene

目标场景

addFilterObject

addFilterObject(object): EventManager

添加不会触发事件的场景中的物体

参数

| Name | Type | Description | | :------- | :------------------- | :---------- | | object | Object3D<Event> | Object3D |

Returns

EventManager

intersectObject

Private intersectObject(mouse): Intersection<Object3D<Event>>[]

参数

| Name | Type | | :------ | :-------- | | mouse | Vector2 |

Returns

Intersection<Object3D<Event>>[]

removeFilterObject

removeFilterObject(object): EventManager

移除过滤器中的物体

参数

| Name | Type | Description | | :------- | :------------------- | :---------- | | object | Object3D<Event> | Object3D |

Returns

this

setCamera

setCamera(camera): EventManager

设置当前相机

参数

| Name | Type | | :------- | :------- | | camera | Camera |

Returns

this

setScene

setScene(scene): EventManager

设置当前场景

参数

| Name | Type | | :------ | :------ | | scene | Scene |

Returns

this

use

use(pointerManager): EventManager

使用 pointerManger

参数

| Name | Type | | :--------------- | :--------------- | | pointerManager | PointerManager |

Returns

EventManager