Skip to content

Instantly share code, notes, and snippets.

View tomaspietravallo's full-sized avatar

Tomás Pietravallo tomaspietravallo

View GitHub Profile
const Scene = require('Scene');
const FaceTracking = require('FaceTracking');
const Diagnostics = require('Diagnostics');
const Reactive = require('Reactive');
Promise.all([
Scene.root.findByPath('**/meshes0/*'),
]).then((result)=>{
let meshes = result[0];
const LightingEstimation = require("LightingEstimation"); // import the LightingEstimation module
const Patches = require("Patches"); // import the Patches module
// Patches.inputs.setScalar("brightness", theSecondArgument) sends the second argument (the one after the comma) to a 'from script' (number) variable called brightness
// (On patches select the script and create that variable (there's a menu on the right), then drag the script to the patch editor)
// LightingEstimation.frameBrightness gets a 0-1 value representing the frame brightness
Patches.inputs.setScalar('brightness', LightingEstimation.frameBrightness);
/**
* @param {} x
* @param {*} y
* @param {*} defaultValue
* @returns {Point2DSignal}
*/
function checkAndPack2(x, y, defaultValue){
let values = [x, y];
values.map(x => x || R.val(defaultValue));
return R.pack2(values[0], values[1]);
@tomaspietravallo
tomaspietravallo / touch-gestures.js
Last active August 8, 2020 17:08
onPan & onLongPress seem to be broken (? or my code is ¯\_(ツ)_/¯
let x, y;
TouchGestures.onLongPress().subscribe((event)=>{
event.location.x.monitor({fireOnInitialValue: true}).subscribe((v)=>{
x = v.newValue;
});
event.location.y.monitor({fireOnInitialValue: true}).subscribe((v)=>{
y = v.newValue;
Diagnostics.log(`Gesture: onLongPress \t| X: ${x}, Y: ${y}`);
});
});
const TG = require("TouchGestures");
const Scene = require("Scene");
const R = require("Reactive");
const DMw = require("DeviceMotion").worldTransform;
const CameraInfo = require("CameraInfo");
const Time = require("Time");
/*
Your scene should have a planeTracker and a nullObject as it's child
Everything under the nullObject (called nullPositioner in this case) will be affected and be modified with the plane tracker values
@tomaspietravallo
tomaspietravallo / repo-reset.md
Created September 6, 2020 17:11 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
// Set up a From Script variable called 'r' and drag the script to the Patch Editor
const DM = require('DeviceMotion');
const Patches = require('Patches');
const R = require('Reactive');
// send negated rotation to the patch editor
Patches.inputs.setVector(
'r',
R.vector(
DM.worldTransform.rotation.eulerAngles.x,
DM.worldTransform.rotation.eulerAngles.y,
#! /bin/bash
# export all arproj found in sub directories. e.g. you want to export several projects in one folder
for i in */*.arproj
do
echo "============================"
/Applications/Spark\ AR\ Studio/Spark\ AR\ Studio.app/Contents/MacOS/sparkTerminalAppleMac export "$i" -d ./
echo "============================"
done
// Made by Tomás Pietravallo for Diego Aguirre & The Spark AR Community
// Import modules
import Patches from 'Patches';
// Import Typescript types
import { BoolSignal } from 'ReactiveModule';
(async function () {
// await is used to get & resolve the getBoolean() promise
const input1: BoolSignal = await Patches.outputs.getBoolean('InputBool1');
@tomaspietravallo
tomaspietravallo / skinSmoothing.ts
Last active March 11, 2021 14:21
Made w/ <3 for the Spark AR Community. © Tomás Pietravallo 2021.
/**
* Skin Smoothing Script by Tomás Pietravallo
* Made w/ <3 for the Spark AR Community.
* Commercial use as part of a project is allowed;
* Selling this script on it's own is NOT allowed.
* © Tomás Pietravallo 2021.
* Do NOT remove this attribution.
*/
import M from 'Materials';
import UI from 'NativeUI';