1

I'm trying to do object selection in Processing.js on 3d renderings through webgl, but don't find any method that allows me to do it.

I know that in OpenGL you could change render mode to GL_SELECT, name and render each object, and when you're done find the name of the object that lies under the cursor.

This method would be fine for me if I could get the WebGL context out of the target canvas, but the getContext method returns null, for some weird reason.

Is there a way to get the rendering context from Processing.js and apply the method I mentioned, or is there a better approach in Processing.js itself?

hoheinzollern
  • 651
  • 6
  • 16

1 Answers1

0

It is possible to access the rendering context from the instance as specified here:

From JavaScript:

var p = Processing.instances[0];
var context = p.externals.context;
var p2 = Processing.getInstanceById('canvas-id');
var p2Canvas = p2.externals.canvas;

From within Processing:

var currentContext = externals.context;

And then collision detection as in this answer.

Community
  • 1
  • 1
hoheinzollern
  • 651
  • 6
  • 16