- The jQuery code was removed.
- There are two canvases: one containing the video image (flipped horizontally for easier interaction by the viewer), the second canvas containing the superimposed graphics
- For code readability, there is an array (called "buttons") that contains x/y/width/height information for all the superimposed graphics, used for both the drawImage calls and the getImageData calls when checking regions for sufficient motion to trigger an action.
The first demo is a minimal example which just displays a message when motion is detected in certain regions; no Three.js code appears here.
The second demo incorporates motion detection in a Three.js scene. When motion is detected over one of three displayed textures, the texture of the spinning cube in the Three.js scene changes to match.
Here is a YouTube video of these demos in action: