@depasquale/three-wizard

中文文档
0.0.14发布于 2023/11/06MITTypeScriptES Module近 30 天下载 1.4万

Create a Three.js scene without the boilerplate

原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. Options
  4. Example
  5. To do

Three.js Wizard

This tool does all the magical incantations necessary for creating a scene with Three.js:

  • Create camera, renderer, and scene instances
  • Size the renderer's DOM element to fill the browser window, with the appropriate pixel ratio
  • Add the renderer's DOM element to the DOM
  • Apply CSS to the page
  • Add an event listener to resize the renderer's DOM element and update the camera when the browser window is resized
  • Add your choice of controls
  • Set up the animation loop with your render routine
  • Update the controls each frame

Installation

npm install @depasquale/three-wizard

Usage

import Wizard from '@depasquale/three-wizard';

const wizard = new Wizard({
  // Choose from `ImmersiveControls`, `OrbitControls`, and `static` (more options coming soon)
  controls: 'OrbitControls',
});

// You can access these if necessary
const { scene, camera, renderer, controls } = wizard;

// Add things to the scene
// ...

Define the render loop in which things are updated each frame. (Three.js Wizard takes care of updating the controls and telling the renderer to render, so there's no need to include this boilerplate code.) Then start the animation.

const render = () => {
  // Update things in the scene
  // ...
};

wizard.start(render);

Options

  • controls: 'ImmersiveControls' | 'OrbitControls' | 'static'

    • The type of controls to be used in the scene. Default is static.
  • initialPosition: THREE.Vector3

    • The camera's initial position in the scene. Default is new THREE.Vector3(0, 1.6, 5).
  • css: true | false

    • Apply CSS to the page. Default is true.
  • If using ImmersiveControls, the options for these controls can be included here as well.

Example

A full example is provided in the example directory. To try it locally in your browser, run:

npm run example

Or try it here.

To do

  • Add more controls options
  • Add option to specify a target for the renderer's DOM element, instead of the full browser window

版本与发布记录

@depasquale/three-wizard 共发布 14 个版本,首次发布于 2022/03/03;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.14latest2023/11/063 年前
0.0.132022/05/084 年前
0.0.122022/03/184 年前
0.0.112022/03/074 年前
0.0.102022/03/064 年前
0.0.92022/03/064 年前

关于 @depasquale/three-wizard 的常见问题

@depasquale/three-wizard 是什么?

Create a Three.js scene without the boilerplate

如何安装 @depasquale/three-wizard?

在项目目录运行 npm install @depasquale/three-wizard,或使用 pnpm add / yarn add / bun add。

@depasquale/three-wizard 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@depasquale/three-wizard 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@depasquale/three-wizard 可以商用吗?

@depasquale/three-wizard 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@depasquale/three-wizard 的下载量有多少?

根据 npm 官方下载统计,@depasquale/three-wizard 在 2026/10/12 – 2026/11/10 这 30 天内被下载 14,119 次,日均约 471 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@depasquale/three-wizard 还在维护吗?

最新版本 0.0.14 发布于 2023/11/06(3 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/03/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。