Skip to content

Instantly share code, notes, and snippets.

@tedbrownxr
tedbrownxr / PlaneTrackerExample.js
Created December 1, 2021 01:04
Lens Studio: An example of how you can use PlaneTracker in your Next Generation Spectacles project
// -----JS CODE-----
// PLANE TRACKER EXAMPLE
// For Lens Studio on Next Generation Spectacles
// Requires Plane Tracker script: https://gist.github.com/tedbrownxr/64914f814b0d121a9f53f66e5ecf2350
// - Uses Plane Tracker to position an object in the world
// - If the plane is invalid, hides the object and shows the problem with on-screen text
// - Activates on start
// - Tap to set object position
// Ted Brown / November 30, 2021
@tedbrownxr
tedbrownxr / PlaneTracker.js
Last active December 10, 2021 07:39
An easy-to-use implementation of Plane Tracking on Next Generation Spectacles
// -----JS CODE-----
// PLANE TRACKER
// For Lens Studio on Next Generation Spectacles
// - Gets plane tracking data
// - Determines if a tracked plane is valid or not, based on settings
// - If valid, sets position, normal, and calculated rotation
// Ted Brown / November 30, 2021
// @input SceneObject cameraObject
// @input string floor = "head" {"widget":"combobox", "values":[{"label":"Disabled", "value":"disabled"}, {"label":"Default Rotation", "value":"default"}, {"label":"Head Rotation", "value":"head"}]}
@tedbrownxr
tedbrownxr / TurnTowardsCameraInsideDistance.js
Last active November 9, 2021 20:02
Lens Studio: Rotate on up axis to face camera
// -----JS CODE-----
// LENS STUDIO
// When camera is within the specified distance of this object,
// rotate to face the camera at the specified lerp value.
// When the camera is outside the distance, rotate back to original rotation.
// @input SceneObject cameraObject
// @input float triggerDistance = 135
// @input float lerpValue = .05