Created
March 5, 2019 05:31
-
-
Save prestomation/dcbc02a3f61a27d411a609dd327070fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function setup(args, ctx) { | |
// This is a HTMLVideoElement that is powering the video texture for the current entity | |
// You can use any standard method on the Video element. See the docs here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement | |
// The following example uses the 'Space' key to toggle play/pause | |
ctx.video = ctx.entity.meshRendererComponent.materials[0].getTexture("DIFFUSE_MAP").image; | |
ctx.onKeyDown = (e) => { | |
switch(e.keyCode){ | |
case sumerian.ScriptUtils.getKey("Space"): | |
if(ctx.video.paused) { | |
ctx.video.play(); | |
} | |
else if(!ctx.video.paused) { | |
ctx.video.pause(); | |
} | |
} | |
} | |
document.body.addEventListener('keydown', ctx.onKeyDown, false); | |
} | |
function cleanup(args, ctx) { | |
document.body.removeEventListener('keydown', ctx.onKeyDown, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment