Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

three.interaction-fixed

jasonChen1982154MIT0.2.3

a interaction manager, serve the three.js, help you build a interactivity 3d-scene

threejs, three.js, event, eventer, interaction, event-system

readme

three.interaction

npm javascript style guide Standard Version

a full-interaction event manager, help three.js binding interaction event more simple

install

npm install -S three.interaction

usage

import { Scene, PerspectiveCamera, WebGLRenderer, Mesh, BoxGeometry, MeshBasicMaterial } from 'three';
import { Interaction } from 'three.interaction';

const renderer = new WebGLRenderer({ canvas: canvasElement });
const scene = new Scene();
const camera = new PerspectiveCamera(60, width / height, 0.1, 100);

// new a interaction, then you can add interaction-event with your free style
const interaction = new Interaction(renderer, scene, camera);

const cube = new Mesh(
  new BoxGeometry(1, 1, 1),
  new MeshBasicMaterial({ color: 0xffffff }),
);
scene.add(cube);
cube.cursor = 'pointer';
cube.on('click', function(ev) {});
cube.on('touchstart', function(ev) {});
cube.on('touchcancel', function(ev) {});
cube.on('touchmove', function(ev) {});
cube.on('touchend', function(ev) {});
cube.on('mousedown', function(ev) {});
cube.on('mouseout', function(ev) {});
cube.on('mouseover', function(ev) {});
cube.on('mousemove', function(ev) {});
cube.on('mouseup', function(ev) {});
// and so on ...

/**
 * you can also listen on parent-node or any display-tree node,
 * source event will bubble up along with display-tree.
 * you can stop the bubble-up by invoke ev.stopPropagation function.
 */
scene.on('touchstart', ev => {
  console.log(ev);
})
scene.on('touchmove', ev => {
  console.log(ev);
})

Documentation

documentation

Examples

examples cube

examples cube overlap

changelog

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.2.3 (2020-07-24)

0.2.3-beta.0 (2020-07-24)

0.2.2 (2018-09-06)

Bug Fixes

  • recursive: mistake again, should use recursive mode to intersect objects (5d9c99d)

0.2.1 (2018-09-04)

Bug Fixes

  • invoke: use three ray caster with a wrong way, my bad (4e165a8)

0.2.0 (2018-09-03)

Features

  • intersects: add intersects for event (5be6e2b)

0.1.0 (2018-08-24)

Features

  • layer: add interaction for layer (6cd1c5a)

0.0.9 (2018-03-13)

Bug Fixes

  • error: fixed event was undefined in onClick function (08a91f0)

0.0.8 (2018-03-13)

0.0.7 (2018-01-31)

Features

  • patch: remove object3d patch about event emit (edc6746)
  • peer: peer dependencies three at 0.89.0 (93343de)
  • utils: remove some redundant function (da46a97)

0.0.6 (2017-12-21)

Features

  • struct: adjust modules struct (1a58af2)

0.0.5 (2017-12-13)

Bug Fixes

  • touch: fixed touchmove and touchend impl like browser (3a99d11)

0.0.4 (2017-12-08)

Bug Fixes

  • addEvents: fixed multiple bind event, when repeat invoke addEvents (15acda7)

0.0.3 (2017-12-08)

Features

  • interaction: add interaction impl (8191b1c)
  • target: put target into interactionData (82aed3d)

0.0.2 (2017-12-06)

Bug Fixes

  • move: move event was not same with browser (05991dc)

Features

  • click: add really click event (b1abb5a)
  • script: adjust release script (e42b357)

0.0.1 (2017-12-05)

Features

  • init: finish interaction (cbb9697)
  • readme: add some readme (363eda1)