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
/* | |
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 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
/* | |
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 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
//@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 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
/* | |
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 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
/** | |
* @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 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
/* | |
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 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
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() | |
} | |
}) |
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
#!/bin/bash | |
# Lens Studio video asset encoder. Max dimension of 1280 using H.264 / AVC / MP4 | |
# https://lensstudio.snapchat.com/guides/2d/video/ | |
# USAGE: ./encode-lens-studio.sh myvideo.mov | |
ffmpeg -i $1 \ | |
-vf "scale='if(gt(iw, ih), min(1280, iw-mod(iw, 16)), -16)':'ifnot(gt(iw, ih), min(1280, ih-mod(ih, 16)), -16)'" \ | |
-c:v libx264 \ | |
-crf 23 \ | |
-preset veryslow \ | |
-c:a copy \ |
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
#!/bin/bash | |
for project in **/*.arproj; | |
do /Applications/Spark\ AR\ Studio.app/Contents/MacOS/sparkTerminalAppleMac export $project; | |
done; |
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
const Scene = require('Scene') | |
const {log} = require('Diagnostics') | |
const {RGBA} = require('Reactive') | |
;(async function () { | |
const light = await Scene.root.findFirst('ambientLight0') | |
log(light) | |
light.color = new RGBA(1, 1, 179/255, 1) |
NewerOlder