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/module-solid-object

v0.7.0

Published

<img alt="version" src="https://img.shields.io/npm/v/@vis-three/module-solid-object">

Downloads

12

Readme

@vis-three/module-solid-object

最新版本

license

模块信息

这是一个虚拟公共模块,是其他实体物体模块的基础模块,没有实际的模块对象,只提供相关方法属性。

:::tip 实体物体也就是这个物体既有geometry又有material。 :::

模块规则

SolidObjectRule

此规则目前仅作为ts的声明拓展使用。

import { Rule } from "@vis-three/middleware";
import { SolidObject3D, SolidObjectCompiler } from "./SolidObjectCompiler";
import { SolidObjectConfig } from "./SolidObjectConfig";

export type SolidObjectRule<
  E extends SolidObjectCompiler<C, O>,
  C extends SolidObjectConfig,
  O extends SolidObject3D
> = Rule<E>;

使用

import { ProxyNotice } from "@vis-three/middleware";
import { ObjectRule } from "@vis-three/module-object";
import { SolidObjectRule } from "@vis-three/module-solid-object";
import { Mesh } from "three";

import { MeshCompiler } from "./MeshCompiler";
import { MeshConfig } from "./MeshConfig";

export type MeshRule = SolidObjectRule<MeshCompiler, MeshConfig, Mesh>;

export const MeshRule: MeshRule = function (
  notice: ProxyNotice,
  compiler: MeshCompiler
) {
  ObjectRule(notice, compiler);
};

模块编译器

export abstract class SolidObjectCompiler<
  C extends SolidObjectConfig,
  O extends SolidObject3D
> extends ObjectCompiler<C, O> {
  constructor() {
    super();
  }
}

使用

import { SolidObjectCompiler } from "@vis-three/module-solid-object";
import { Mesh } from "three";
import { MeshConfig } from "./MeshConfig";

export class MeshCompiler extends SolidObjectCompiler<MeshConfig, Mesh> {
  constructor() {
    super();
  }
}

模块处理器

实体物体命令链-SolidObjectCommands

Ƭ SolidObjectCommands<C, T>: ObjectCommands<C, T>

作为公共的实体物体命令链模块使用,也可以使用其中的部分命令。

类型参数

| Name | Type | | :--- | :-------------------------- | | C | extends SolidObjectConfig | | T | extends SolidObject3D |

预览

export const solidObjectCommands: SolidObjectCommands<
  SolidObjectConfig,
  SolidObject3D
> = {
  add: {
    material: materialHandler,
    ...(<SolidObjectCommands<SolidObjectConfig, SolidObject3D>>(
      objectCommands.add
    )),
  },
  set: {
    geometry: geometryHandler,
    material: materialHandler,
    ...(<SolidObjectCommands<SolidObjectConfig, SolidObject3D>>(
      objectCommands.set
    )),
  },
  delete: {
    material: materialHandler,
    ...(<SolidObjectCommands<SolidObjectConfig, SolidObject3D>>(
      objectCommands.delete
    )),
  },
};

使用

import { defineProcessor, EngineSupport } from "@vis-three/middleware";
import {
  solidObjectCommands,
  SolidObjectCommands,
  solidObjectCreate,
  solidObjectDispose,
} from "@vis-three/module-solid-object";
import { Mesh } from "three";

import { MeshCompiler } from "../MeshCompiler";
import { getMeshConfig, MeshConfig } from "../MeshConfig";

export default defineProcessor<MeshConfig, Mesh, EngineSupport, MeshCompiler>({
  type: "Mesh",
  config: getMeshConfig,
  commands: <SolidObjectCommands<MeshConfig, Mesh>>(
    (<unknown>solidObjectCommands)
  ),
  create(config: MeshConfig, engine: EngineSupport): Mesh {
    return solidObjectCreate(new Mesh(), config, {}, engine);
  },
  dispose: solidObjectDispose,
});

geometryHandler

geometryHandler<C, O>(«destructured»): void

类型参数

| Name | Type | | :--- | :---------------------------------------------------------------------------------- | | C | extends SolidObjectConfig | | O | extends SolidObject3D<O> |

参数

| Name | Type | | :--------------- | :------------------------------------------------- | | «destructured» | ProcessParams<C, O, EngineSupport, any> |

Returns

void


materialHandler

materialHandler<C, O>(«destructured»): void

类型参数

| Name | Type | | :--- | :---------------------------------------------------------------------------------- | | C | extends SolidObjectConfig | | O | extends SolidObject3D<O> |

参数

| Name | Type | | :--------------- | :------------------------------------------------- | | «destructured» | ProcessParams<C, O, EngineSupport, any> |

Returns

void


solidObjectCreate

solidObjectCreate<C, O>(object, config, filter, engine): O

类型参数

| Name | Type | | :--- | :---------------------------------------------------------------------------------- | | C | extends SolidObjectConfig | | O | extends SolidObject3D<O> |

参数

| Name | Type | | :------- | :--------------------------------------------------------------------- | | object | O | | config | C | | filter | DeepUnion<DeepPartial<DeepRecord<C, boolean>>, boolean> | | engine | EngineSupport |

Returns

O

solidObjectDispose

solidObjectDispose<O>(target): void

类型参数

| Name | Type | | :--- | :---------------------------------------------------------------------------------- | | O | extends SolidObject3D<O> |

参数

| Name | Type | | :------- | :--- | | target | O |

Returns

void

提供配置

实体物体-SolidObject

  • 类型SolidObject
  • 配置类型:
export interface SolidObjectConfig extends ObjectConfig {
  material: string | string[];
  geometry: string;
}
  • 默认配置:
{
    material: "",
    geometry: "",
  }

:::tip 此配置供其他物体模块使用。 :::