javascript - Get the image of an element that gets drawn in the three.js while rendering -


well way think three.js handles render turns each element image , draws on context. can more information on that. , if right, there way image, , manipulate it?

any information appreciated.

three.js internally has description of scene looks in 3d space, including vertices , materials among other things. rendering process takes 3d representation , projects 2d space. three.js has several renderers, including webglrenderer (the common), canvasrenderer, , css3drenderer. use different methods draw 2d projection:

  • webglrenderer uses javascript apis map opengl graphics commands. as possible, client's gpu takes parts of 3d representation , more or less performs 2d projection itself. each geometry rendered, painted onto buffer. complete buffer frame, complete 2d projection of 3d space shows in <canvas>.
  • canvasrenderer uses javascript apis 2d drawing. 2d projection internally (which slower) otherwise works webglrenderer @ high level.
  • css3drenderer uses dom elements , css3d transforms represent 3d scene. means browser takes normal 2d dom elements , transforms them 3d space match three.js 3d internal representation, projects them onto page in 2d.

(all highly simplified.)

it's important understand frame rendered webgl , canvas representations resulting picture see on screen, it's not <img>. typically, browser render 60 frames per second. can extract frame dumping <canvas> image. typically you'll want stop animation loop in order otherwise might not capturing frame want. capturing frames way slow , given browser rendering many frames per second there not easy ways capture every frame.

additionally, chrome has built-in canvas inspection tools allow take closer @ each frame browser paints.

you can't intercept buffer three.js rendering frame, can draw directly onto canvas would. renderer.context graphics context three.js draws onto, renderer renderer instance create when setting three.js scene. (a graphics context helper assemble buffer makes frame.)


Comments