← ClaudeAtlas

threejs-interactionlisted

Picking with raycasting, camera controls, transform gizmos, drag, hover and box selection for three.js, identical under WebGL and WebGPU. Use when handling mouse, touch or keyboard input, detecting clicks on 3D objects, adding camera controls, or making scene objects interactive.
ahmedamin20/hmcv-ui-studio-public · ★ 0 · Web & Frontend · score 62
Install: claude install-skill ahmedamin20/hmcv-ui-studio-public
# Three.js Interaction Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer. ## Quick Start ```javascript import * as THREE from "three"; import { OrbitControls } from "three/addons/controls/OrbitControls.js"; const renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); const scene = new THREE.Scene(); scene.background = new THREE.Color(0x111318); const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 100); camera.position.set(0, 1.5, 5); const mesh = new THREE.Mesh( new THREE.BoxGeometry(1, 1, 1), new THREE.MeshStandardMaterial({ color: 0x3a86ff }), ); scene.add(mesh); const light = new THREE.DirectionalLight(0xffffff, 2); light.position.set(3, 5, 4); scene.add(light, new THREE.AmbientLight(0xffffff, 0.4)); const controls = new OrbitControls(camera, renderer.domElement); // connects itself controls.enableDamping = true; // requires controls.update() every frame const timer = new THREE.Timer(); timer.connect(document); // freezes the delta while the tab is hidden const raycaster = new THREE.Raycaster(); const pointer = new THREE.Vector2(); function setPointer(event) { // NDC coordinates relative to the canvas, so the page can scroll or embed it const rect = renderer.domElement.getBoundingClientRect(); pointer.set( ((e