
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
three-interact
Advanced tools
A declarative library for managing Three.js object interactions with a simple method-chaining API.
npm install three-interact
# or
yarn add three-interact
# or
pnpm add three-interact
import * as THREE from 'three'
import { InteractManager, interact } from 'three-interact'
// Create a basic Three.js setup
const renderer = new THREE.WebGLRenderer()
const camera = new THREE.PerspectiveCamera()
const scene = new THREE.Scene()
// Initialize the interaction manager
const manager = new InteractManager(renderer, camera)
// Create an object
const cube = new THREE.Mesh(
new THREE.BoxGeometry(),
new THREE.MeshBasicMaterial({ color: 0x3080ff })
)
scene.add(cube)
// Add interaction with method chaining
interact(cube, manager)
.onPointerEnter(() => {
cube.material.color.set(0xff0000)
document.body.style.cursor = 'pointer'
})
.onPointerLeave(() => {
cube.material.color.set(0x3080ff)
document.body.style.cursor = 'default'
})
.onPointerMove((e) => {
console.log('Pointer moving over cube', e.delta)
})
.onClick(() => {
console.log('Cube clicked')
})
.onDrag((e) => {
// Access e.delta.x and e.delta.y for drag movement amount
cube.position.x += e.delta.x * 0.01
cube.position.y -= e.delta.y * 0.01
})
// Don't forget to update the manager in your animation loop
function animate() {
requestAnimationFrame(animate)
manager.update()
renderer.render(scene, camera)
}
animate()
The main controller for handling interactions.
const manager = new InteractManager(renderer, camera);
Factory function that creates an Interactable instance for a Three.js object.
const interactable = interact(myObject, manager);
Factory function for creating multiple Interactable instances.
const interactables = interactGroup([object1, object2], manager);
Each interactable object provides methods for different interaction types:
.onPointerEnter(handler) - Handle pointer enter events.onPointerLeave(handler) - Handle pointer leave events.onPointerMove(handler) - Handle pointer move events over the object.onClick(handler) - Handle click events.onDrag(handler) - Handle drag events with delta movement valuesMIT
FAQs
Easy Three.js interactions with declarative method chaining
We found that three-interact demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.