A green-screen presenter
Updated
A presenter filmed on a green screen is keyed into the scene by a Chroma Key on the Video entity; a script sets the key colour and switches the key, a blue key or automatic measurement from the keyboard.
Click the scene, then press K to turn the key off and on, B to key a blue screen instead, and A to let the key measure the screen colour itself. Drag to orbit the camera, scroll to zoom.
A green-screen presenter
#pragma lifecycle(startup, update)
const SCREEN = '#3f7a30'; // the green of this video's screenlet key;
function startup() { key = self.parent.getComponent(ChromaKeyComponent); key.setProps({ color: SCREEN, similarity: 0.4, spill: 0.6 });
#if IS_MOBILE || IS_HEADSET key.setProps({ edgeShrink: 0 }); // the cheapest key#endif
log('Keying out', SCREEN);}
function update() { if (Input.keyboard.isKeyReleased(Key.K)) key.setEnabled(!key.enabled); if (Input.keyboard.isKeyReleased(Key.B)) key.setProps({ color: '#1d4ed8' }); if (Input.keyboard.isKeyReleased(Key.A)) { key.setProps({ color: 'auto' }); delay(() => log('Measured screen colour:', key.detectedColor ?? 'not measured yet'), 1500); }}How it works
Section titled “How it works”The script is explained step by step in A green-screen presenter.
Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
GreenScreenPresenter.xrproj