1.0.30 • Published 9 months ago

three-gizmo v1.0.30

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

Description

Presenting an open-source solution designed for effortless object manipulation within Three.js. This interactive tool empowers you to modify objects by simply clicking and dragging on individual components of the gizmo. This solution offers three distinct modes: Move, Rotate, and Scale.

Move:

image

Rotate:

image

Scale:

image

Example

Here is an example page, with this library implemented:

image

link

source code

Usage

Install the package:

npm i three-gizmo

Then you can import it like this:

import { gizmo } from "three-gizmo";
helper = gizmo(camera, renderer)

To choose which type of transformation is active you can call these functions

helper.move()
helper.rotate()
helper.scale()
helper.none()

For each transformation you can use events to modify your objects:

helper.on("rotate", angle=>{
  // this function will be caleed during the rotation process
})
helper.on("end-rotate",angle=>{
  // this function will be caleed at the end of the rotation process
})

the available events are: scale, end-scale, move, end-move, rotate, end-rotate

Finally, to render your gizmo after the render function you must call the gizmo render function:

renderer.render( scene, camera );
helper.render()

You can change the gizmo position by calling this method:

helper.setOrigin(position)

you can call the following method to check if the mouse is over any of the helpers, this is useful to not take any other click action, if you are selecting a gizmo

helper.isHover()

You can customize your gizmo by using the setColor function

import { setColor } from "three-gizmo";
setColor("color1",0xff0000)
setColor("color2",0x00ff00)
setColor("color3",0x0000ff)

image

The supported parameters are

color1, color2, color3, color4 ,hover
1.0.30

9 months ago

1.0.29

9 months ago

1.0.28

9 months ago

1.0.27

9 months ago

1.0.26

9 months ago

1.0.25

9 months ago

1.0.24

9 months ago

1.0.23

9 months ago

1.0.22

9 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago