1.1.7 • Published 2 years ago

threejs-compass v1.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

This is a Simple project created and maintained with the just for fun philosophy

You can find a medium article that describe the implementation here https://medium.com/@ceccarellisimone1/zoom-and-pan-in-three-js-customly-simple-interactions-in-data-graph-visualization-26643a5d0287

With this package you can

  • zoom in your visualization in a specific point, using the pointer and the wheel (like google maps)
  • drag the visualization (like google maps)
  • translate the coordinates in 3 different spaces: the world, the real space of the canvas and the relative space of the canvas

Usage

See the wiki section for a little documentation https://github.com/simCecca/threejs-compass/wiki

Install the library

npm install threejs-compass

Simply import the library

import Compass from "threejs-compass";

Set the events

const compass = new Compass(camera, renderer);
compass.setAllEvents();

In a real example

import Compass from "threejs-compass";

const main = () => {
  // threejs configuration, you can do what you you want
  const canvas = document.querySelector("#c");
  const width = canvas.clientWidth;
  const height = canvas.clientHeight;
  const fov = 30;
  const z = 300;
  const aspectRatio = width / height;

  const renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
  ....
  ....
  // end threejs config
  
  const compass = new Compass(camera, renderer);
  compass.setAllEvents();
  ....
  ....
}

main();
1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago