Visit the Documentation of the upcoming Threlte 6.
  1. @threlte/core
  2. InteractiveObject

@threlte/core

InteractiveObject

Provides access to the interactivity system of Threlte.

INFO

This is a trait component. Trait components are mostly used internally and make certain aspects of three.js objects accessible and reactive and interact with Threlte systems.

Import

Source

Github View Source Code

Package

NPM View Package

Basic Example

<script>
	import { InteractiveObject } from '@threlte/core'
	import { Mesh } from 'three'

	const mesh = new Mesh()

	const onClick = () => {
		console.log('Mesh has been clicked!')
	}
</script>

<InteractiveObject
	object={mesh}
	interactive
	on:click={onClick}
/>

Properties

// required
object: Object3D
interactive: boolean = false
ignorePointer: boolean = false

Events

click: ThreltePointerEvent
contextmenu: ThreltePointerEvent
pointerup: ThreltePointerEvent
pointerdown: ThreltePointerEvent
pointerenter: ThreltePointerEvent
pointerleave: ThreltePointerEvent
pointermove: ThreltePointerEvent