Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 1.2 KB

README.md

File metadata and controls

38 lines (31 loc) · 1.2 KB

Chromakey THREE.js

Remove chromakey in the video using three.js.

Installation

  1. Install an up-to-date version of Three.js, for example:
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>

<script type="importmap">
{
  "imports": {
    "three": "https://unpkg.com/[email protected]/build/three.module.js",
    "three/addons/": "https://unpkg.com/[email protected]/examples/jsm/"
  }
}
</script>
  1. Copy the code in the file (chromakey-three-js.js) into your project

Usage

Don't forget to create a three.js scene if you don't already have one.

Use case:

// video - is the id video in your HTML
// 0xd432 - is the color you want to remove
const myGreenScreenMaterial = new ChromaKeyMaterial("video", 0xd432);

// for example, we can place the video on a plane
const myGeometry = new THREE.PlaneGeometry(32, 18);
const myGreenScreenVideoObject = new THREE.Mesh(myGeometry, myGreenScreenMaterial);

// don't forget to add to your animate function:
scene.add(myGreenScreenVideoObject);

The code was taken from here and improved for current realities (2023's)

If there are any bugs or bugs write, we will fix :)