Last active
August 23, 2020 19:41
-
-
Save tomaspietravallo/a627bb9ce2e5f07e76e95d7949442a13 to your computer and use it in GitHub Desktop.
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
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 | |
*/ | |
(async function initPlaneTracker() { | |
let nullPositioner = await Scene.root.findFirst("nullPositioner"); // CHANGE to the name of your parent null object in the scene | |
let trackerPlane = await Scene.root.findFirst("planeTracker0"); // CHANGE to the name of your plane tracker in the scene | |
new Promise(resolve => {Time.setTimeout(()=>{resolve()}, 3000)}).then(()=>{ | |
R.monitorMany({'X': DMw.x, 'Y': DMw.y, 'Z': DMw.z, 'rtx': DMw.rotationX, 'rty': DMw.rotationY, 'rtz': DMw.rotationZ}) | |
.subscribe(()=>{ | |
trackerPlane.trackPoint(R.div(CameraInfo.previewSize.x, 2).pinLastValue(), R.div(CameraInfo.previewSize.y, 2).pinLastValue()); | |
nullPositioner.transform.scaleX = R.div(1, trackerPlane.worldTransform.scaleX); | |
nullPositioner.transform.scaleY = R.div(1, trackerPlane.worldTransform.scaleY); | |
nullPositioner.transform.scaleZ = R.div(1, trackerPlane.worldTransform.scaleZ); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment