picking

three.js orthographic camera object picking

二次信任 提交于 2019-11-28 11:40:51
i am trying to pick objects in a scene where i use an orthographic camera. my code fragment already works, but it is not precise. i already found some answers on stackoverflow, but those are deprecated or won't work anymore at all. here is my code onMouseDown function onDocumentMouseUp( event ) { event.preventDefault(); mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1; mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1; var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5); var pos = camera.position; var ray = new THREE.Raycaster(pos, vector.unproject(camera).sub(camera.position

OpenGL GL_SELECT or manual collision detection?

假如想象 提交于 2019-11-27 18:38:03
As seen in the image I draw set of contours (polygons) as GL_LINE_STRIP. Now I want to select curve(polygon) under the mouse to delete,move..etc in 3D . I am wondering which method to use: 1.use OpenGL picking and selection. ( glRenderMode(GL_SELECT) ) 2.use manual collision detection , by using a pick-ray and check whether the ray is inside each polygon. I strongly recommend against GL_SELECT . This method is very old and absent in new GL versions, and you're likely to get problems with modern graphics cards. Don't expect it to be supported by hardware - probably you'd encounter a software

Threejs: assign different colors to each vertex in a geometry

大城市里の小女人 提交于 2019-11-27 13:36:51
I want to do picking via IdMapping in Three.js Because of performance issues I only have one huge geometry, computed like this: for (var i = 0; i < numberOfVertices; i += 9) { p1 = new THREE.Vector3(graphData.triangles.vertices[i+0], graphData.triangles.vertices[i+1], graphData.triangles.vertices[i+2]); p2 = new THREE.Vector3(graphData.triangles.vertices[i+3], graphData.triangles.vertices[i+4], graphData.triangles.vertices[i+5]); p3 = new THREE.Vector3(graphData.triangles.vertices[i+6], graphData.triangles.vertices[i+7], graphData.triangles.vertices[i+8]); geometry.vertices.push(new THREE

OpenGL ES 2.0 Object Picking on iOS

懵懂的女人 提交于 2019-11-27 11:36:59
What is the best method to select objects that have been drawn in OpenGL ES 2.0 (iOS)? I am drawing points. Here is working prototype of color picking, tested on most old ipads and working well. This is actually some part of project called InCube Chess that one may find in app store. The main code you will see is located in a class derived from GLKViewController like this: @interface IncubeViewController : GLKViewController This means you have glkview in it: ((GLKView *)self.view). Here are also some properties: @property (strong, nonatomic) EAGLContext *context; @property (strong, nonatomic)

three.js orthographic camera object picking

孤街醉人 提交于 2019-11-27 06:32:21
问题 i am trying to pick objects in a scene where i use an orthographic camera. my code fragment already works, but it is not precise. i already found some answers on stackoverflow, but those are deprecated or won't work anymore at all. here is my code onMouseDown function onDocumentMouseUp( event ) { event.preventDefault(); mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1; mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1; var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5); var

OpenGL ES 2.0 Object Picking on iOS

ぐ巨炮叔叔 提交于 2019-11-27 04:03:19
问题 What is the best method to select objects that have been drawn in OpenGL ES 2.0 (iOS)? I am drawing points. 回答1: Here is working prototype of color picking, tested on most old ipads and working well. This is actually some part of project called InCube Chess that one may find in app store. The main code you will see is located in a class derived from GLKViewController like this: @interface IncubeViewController : GLKViewController This means you have glkview in it: ((GLKView *)self.view). Here

OpenGL GL_SELECT or manual collision detection?

纵然是瞬间 提交于 2019-11-26 22:42:00
问题 As seen in the image I draw set of contours (polygons) as GL_LINE_STRIP. Now I want to select curve(polygon) under the mouse to delete,move..etc in 3D . I am wondering which method to use: 1.use OpenGL picking and selection. ( glRenderMode(GL_SELECT) ) 2.use manual collision detection , by using a pick-ray and check whether the ray is inside each polygon. 回答1: I strongly recommend against GL_SELECT . This method is very old and absent in new GL versions, and you're likely to get problems with

Implementing Ray Picking

巧了我就是萌 提交于 2019-11-26 18:29:00
I have a renderer using directx and openGL, and a 3d scene. The viewport and the window are of the same dimensions. How do I implement picking given mouse coordinates x and y in a platform independent way? Andreas Brinck If you can, do the picking on the CPU by calculating a ray from the eye through the mouse pointer and intersect it with your models. If this isn't an option I would go with some type of ID rendering. Assign each object you want to pick a unique color, render the objects with these colors and finally read out the color from the framebuffer under the mouse pointer. EDIT: If the

Threejs: assign different colors to each vertex in a geometry

坚强是说给别人听的谎言 提交于 2019-11-26 16:25:59
问题 I want to do picking via IdMapping in Three.js Because of performance issues I only have one huge geometry, computed like this: for (var i = 0; i < numberOfVertices; i += 9) { p1 = new THREE.Vector3(graphData.triangles.vertices[i+0], graphData.triangles.vertices[i+1], graphData.triangles.vertices[i+2]); p2 = new THREE.Vector3(graphData.triangles.vertices[i+3], graphData.triangles.vertices[i+4], graphData.triangles.vertices[i+5]); p3 = new THREE.Vector3(graphData.triangles.vertices[i+6],

Implementing Ray Picking

旧城冷巷雨未停 提交于 2019-11-26 06:21:03
问题 I have a renderer using directx and openGL, and a 3d scene. The viewport and the window are of the same dimensions. How do I implement picking given mouse coordinates x and y in a platform independent way? 回答1: If you can, do the picking on the CPU by calculating a ray from the eye through the mouse pointer and intersect it with your models. If this isn't an option I would go with some type of ID rendering. Assign each object you want to pick a unique color, render the objects with these