4.0.0 • Published 8 months ago

@ag-three/interaction v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

three.ez

Quality Gate Status DeepScan grade CodeFactor BundlePhobia

three.ez is a library designed to simplify the development of a three.js application, allowing the easy creation of reusable and maintainable components and providing a host of other features.

Features

Automatic Resize Handling

Automatically resizes Renderer, Camera, EffectComposer. Using rendererResize event is also possibile to set resolution for custom shaders.

Smart Rendering

The smart rendering mode can be activated to render a frame only when necessary, optimizing performance and reducing unnecessary computational overhead.

Simplified Multiple Rendering

It simplifies the handling of multiple renderings of different scenes or viewports on the same canvas.

Object3D Property Binding

Bind the properties of Object3D to simplify management.

Event Programming

Facilitates interaction with Object3D by adding a series of programmable events. The interaction events are dom-like, so they have the same propagation mechanics.

Focus and Blur

Implement focus and blur interactions to enhance user experience and interactivity.

Drag and Drop

Integrate drag and drop functionality.

Tweening

Implement smooth animations effortlessly with integrated tweening functionality.

Raycasting Options

Choose between continuous raycasting or raycasting only during mouse movement, providing flexibility in optimizing raycasting operations based on your application's requirements. In addition, there is the possibility to choose which objects can be intersected.

Hitbox Functionality

Hitboxes can be used to handle a different intersection area or to simplify intersection calculations.

Simplified InstancedMesh

Simplify the use of InstancedMesh by managing it as if each entity were an Object3D. This approach simplifies the creation and manipulation of InstancedMesh instances, providing a more intuitive and easy-to-develop workflow.

Installation

You can install three.ez via npm using the following command:

npm install @three.ez/main

Usage

Smaller version:

import { Scene, Mesh, BoxGeometry, MeshNormalMaterial } from 'three';
import { Main, PerspectiveCameraAuto } from '@three.ez/main';

const box = new Mesh(new BoxGeometry(0.2, 0.2, 0.2), new MeshNormalMaterial());
box.on('animate', (e) => box.rotateX(e.delta).rotateY(e.delta * 2));
const scene = new Scene().add(box);
const main = new Main();
main.createView({ scene, camera: new PerspectiveCameraAuto(70).translateZ(1) });

Extended version (recommended):

import { Scene as SceneBase, Mesh, BoxGeometry, MeshNormalMaterial } from 'three';
import { Main as MainBase, PerspectiveCameraAuto } from '@three.ez/main';

class Box extends Mesh {
  constructor() {
    super(new BoxGeometry(0.2, 0.2, 0.2), new MeshNormalMaterial());
    this.on('animate', (e) => this.rotateX(e.delta).rotateY(e.delta * 2));
  }
}

class Scene extends SceneBase {
  constructor() {
    super();
    this.add(new Box());
  }
}

class Main extends MainBase {
  constructor() {
    super();
    this.createView({ scene: new Scene(), camera: new PerspectiveCameraAuto(70).translateZ(1) });
  }
}

const main = new Main();

Override Typescript Definition

To extend the definitions of three, go into `ts.config and add this path:

"compilerOptions": {
  "paths": {
    "three": ["./node_modules/@three.ez/main/types"]
  }
}

Examples

Work in progress...

Documentation

Work in progress...

Contributing

Any help is highly appreciated. If you would like to contribute to this package or report problems, feel free to open a bug or pull request.

Questions?

If you have questions or need assistance, you can open an issue in the package's repository.

1.0.0

10 months ago

2.3.0

9 months ago

2.2.0

9 months ago

2.5.0

8 months ago

2.4.1

9 months ago

2.4.0

9 months ago

2.5.2

8 months ago

2.4.3

9 months ago

2.5.1

8 months ago

2.4.13

9 months ago

2.4.2

9 months ago

2.5.4

8 months ago

2.4.5

9 months ago

2.5.3

8 months ago

2.4.4

9 months ago

2.4.10

9 months ago

2.4.12

9 months ago

2.4.11

9 months ago

2.1.0

10 months ago

2.0.0

10 months ago

3.0.4

8 months ago

3.0.3

8 months ago

3.0.2

8 months ago

2.4.7

9 months ago

2.4.6

9 months ago

2.4.9

9 months ago

2.4.8

9 months ago

3.0.0

8 months ago

0.0.3

10 months ago

4.0.0

8 months ago

0.0.1-beta.1

11 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago