All Projects → bzztbomb → three_js_gpu_picking

bzztbomb / three_js_gpu_picking

Licence: Unlicense license
GPU based object picking for Three.JS

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Labels

Projects that are alternatives of or similar to three js gpu picking

three-earth
画“地图”
Stars: ✭ 15 (-48.28%)
Mutual labels:  threejs
terkel.com-2016
My Personal website. Build with Vue and ThreeJS.
Stars: ✭ 38 (+31.03%)
Mutual labels:  threejs
immersive-ar-emulation
A sort-of polyfill to emulate a fake AR environment which can be hit-tested against.
Stars: ✭ 26 (-10.34%)
Mutual labels:  threejs
three-orbitcontrols
is the three.js OrbitControls from official repo examples
Stars: ✭ 80 (+175.86%)
Mutual labels:  threejs
three-vrm
⚠️ [deprecated] VRM file loader for three.js
Stars: ✭ 44 (+51.72%)
Mutual labels:  threejs
Depthkit.js
🎞 A plugin for using DepthKit's volumteric captures in Three.js
Stars: ✭ 64 (+120.69%)
Mutual labels:  threejs
potree-core
Potree point cloud viewer library core components for easier integration in a three.js project.
Stars: ✭ 88 (+203.45%)
Mutual labels:  threejs
three-loader-3dtiles
This is a Three.js loader module for handling OGC 3D Tiles, created by Cesium. It currently supports the two main formats, Batched 3D Model (b3dm) - based on glTF Point cloud.
Stars: ✭ 179 (+517.24%)
Mutual labels:  threejs
three-onEvent
Add an EventListener for Object3d in your three.js project.(support click,hover or gaze)
Stars: ✭ 55 (+89.66%)
Mutual labels:  threejs
TweetMigration
A WebGL heatmap of global Twitter activity
Stars: ✭ 42 (+44.83%)
Mutual labels:  threejs
three.wasm-experimental
Experimental Three.js WASM (WIP)
Stars: ✭ 51 (+75.86%)
Mutual labels:  threejs
THREE.WebGPURenderer
Experimental Three.js WebGPU renderer
Stars: ✭ 117 (+303.45%)
Mutual labels:  threejs
iThreeJS
以three.js为开发基础的3D模型 + 数据可视化
Stars: ✭ 40 (+37.93%)
Mutual labels:  threejs
three-jsm
Minimal three.js project setup using ES6 modules and rollup.
Stars: ✭ 74 (+155.17%)
Mutual labels:  threejs
FairyGUI-threejs
A GUI Editor & framework for Three.js
Stars: ✭ 115 (+296.55%)
Mutual labels:  threejs
three-kt-wrapper
Kotlin wrappers for Three.js
Stars: ✭ 46 (+58.62%)
Mutual labels:  threejs
solarsystemts
케플러 방정식을 이용한 태양계 행성들의 궤도 계산 시뮬레이터
Stars: ✭ 49 (+68.97%)
Mutual labels:  threejs
aframe-registry
[DISCONTINUED] Curated collection of community A-Frame components.
Stars: ✭ 76 (+162.07%)
Mutual labels:  threejs
three-laser-pointer
Interactive laser object for VR-like scenes
Stars: ✭ 26 (-10.34%)
Mutual labels:  threejs
typefaces
Collection of Google fonts as typeface data for usage with three.js, react-three-fiber, and other tools.
Stars: ✭ 53 (+82.76%)
Mutual labels:  threejs

GPU Object Picking for Three.JS

Overview

This library is a production ready implementation of GPU object picking for Three.JS. The advantage this library has over the other ones that are already available is that it doesn't require a seperate picking scene. This is a big deal because you do not have to keep a second scene in sync with the scene that is being rendered.

GPU Picking also works with skinned meshes and performs better with meshes that have a high poly count. The Three.JS raycaster does not currently work with skinned meshes. These cases are shown in the example that is provided. The yellow sphere below has over a half million polys. If CPU picking is used the framerate will drop while the pick is happening, using GPU picking the framerate remains constant. The other case is skinned meshes. If CPU picking is used picking only works against the initial pose of the object whereas GPU picking works against the current animated pose.

Picking Example Note: The example loads slowly because the sphere has so many polys in it.

Install

Two Options:

A) Install with npm, npm install three_gpu_picking

B) This is a one file library, one can just copy gpupicker into their project

Usage

Import the picker

import { GPUPicker } from 'three_gpu_picking';

Create the picker with the following parameters

  • THREE: reference to the ThreeJS library. I do it this way to avoid issues I've had in the past with WebPack having multiple copies of ThreeJS imported and causing issues.
  • renderer: A reference to the THREE.Renderer (must be a WebGLRenderer) being used.
  • scene: A reference to the THREE.Scene
  • camera: A reference to the camera
  // Here's an example that works for GLTF objects.
  var picker = new GPUPicker(THREE, renderer, scene, camera);

Use the picker

Call GPUPicker.pick with the following parameters:

  • x, the x coordinate of the location you want to pick in. Make sure to multiply by window.devicePixelRatio
  • y, the y coordinate of the location you want to pick in. Make sure to multiply by window.devicePixelRatio
  • shouldPickObject, optional, a callback that allows you to not consider some objects pickable. Return false to skip an object.
  var objectId = picker.pick(ev.clientX * window.devicePixelRatio, ev.clientY * window.devicePixelRatio, obj => {
    return obj.myPickingFlag;
  });

This should happen pretty much directly after renderer.render is called. Depending on how complicated your render loop is, you may need to store the picking coordinates of onMouseUp in a variable and then process the pick in your render call. There's an example of this here

Custom shaders

If you have an object that requires a custom material for picking (due to vertex animation or you want alpha support). Set a pickingMaterial property on it and the GPUPicker will use it.

Authors / Thanks

This library was developed at Torch by Brian Richardson with bugfixes from Josh Faust and Benny Lichtner. Big thanks to Torch for allowing us to release this library!

The dancer model is by 12626 used by CC Attribution License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].