This file contains 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
/* | |
REQUIRED: Create a ground plane with a collider | |
so we can hit test against it to place the object on the surface. | |
*/ | |
/* API */ | |
script.api.enablePlacement = function (bool) { placementEnabled = bool } | |
script.api.setScreenPoint = function (pt) { screenPoint = pt } |
This file contains 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
//@input SceneObject obj | |
/** @type {SceneObject} */ | |
var obj = script.obj | |
script.createEvent('CameraFrontEvent').bind(function(){ | |
if(obj) obj.enabled = true | |
}) | |
script.createEvent('CameraBackEvent').bind(function(){ | |
if(obj) obj.enabled = false |
This file contains 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
Shader "ShadowShader" { | |
Properties{ | |
_Color("Main Color", Color) = (1,1,1,1) | |
_MainTex("Base (RGB)", 2D) = "white" {} | |
_Cutoff("Cutout", Range(0,1)) = 1.0 | |
} | |
SubShader{ | |
Pass{ | |
Alphatest Greater[_Cutoff] SetTexture[_MainTex] |
This file contains 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
/* | |
Debouncing functions is used for delaying a function call until a certain amount of time has passed. | |
In the example below, it's used to hide a slider after 3 seconds if the user isn't interacting with it. | |
*/ | |
/** | |
* Polyfill for browser function setTimeout | |
* @param {function} callback - function to trigger after timeout is completed |
This file contains 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
/* | |
Include this script at the top of the scene to enable global commands | |
Usage: | |
global.showProps(object) | |
global.showScene(scene) | |
global.showSceneObject(sceneObject) | |
global.showComponent(component) | |
Original by @robertlugg | |
https://gist.github.com/robertlugg/a5161200998092ddf69cb7393f7efcc0 |
This file contains 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
/* | |
Register a callback for when a video frame is updated | |
Since video playback generally isn't 60fps, this can be used as a render optimization | |
new FrameUpdateMonitor(videoElement, callback) | |
*/ | |
export class FrameUpdateMonitor { |
This file contains 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
#!/bin/bash | |
# A simple script to backup an organization's GitHub repositories. | |
# NOTE: if you have more than 100 repositories, you'll need to step thru the list of repos | |
# returned by GitHub one page at a time, as described at https://gist.github.com/darktim/5582423 | |
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files | |
GHBU_ORG=${GHBU_ORG-"<REPLACE_ME>"} # the GitHub organization whose repos will be backed up | |
# (if you're backing up a user's repos instead, this should be your GitHub username) | |
GHBU_UNAME=${GHBU_UNAME-"<REPLACE_ME>"} # the username of a GitHub account (to use with the GitHub API) |
This file contains 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
/** | |
* @param {String} HTML representing a single element | |
* @return {Element} | |
*/ | |
export function html2Element(html) { | |
var template = document.createElement('template'); | |
html = html.trim(); // Never return a text node of whitespace as the result | |
template.innerHTML = html; | |
return template.content.firstChild; | |
} |
This file contains 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
/* | |
Resize plane to match screen size | |
*/ | |
const Scene = require('Scene') | |
const camera = Scene.root.find('Camera') | |
const plane = Scene.root.find('plane0') | |
plane.width = camera.focalPlane.width | |
plane.height = camera.focalPlane.height |
This file contains 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
var elapsed = 0 | |
var updateEvent = script.createEvent('UpdateEvent') | |
updateEvent.enabled = false | |
updateEvent.bind(function(e){ | |
elapsed += e.getDeltaTime() | |
if(elapsed > .5){ | |
updateEvent.enabled = false | |
reset() | |
} | |
}) |
NewerOlder