Skip to content

Instantly share code, notes, and snippets.

@agrancini-sc
agrancini-sc / CameraDoubleEye
Last active February 21, 2025 17:26
CameraDoubleEye
import NativeLogger from "SpectaclesInteractionKit/Utils/NativeLogger";
const log = new NativeLogger("CameraAPIBothLogger");
@component
export class CameraDoubleye extends BaseScriptComponent {
private cameraModule: CameraModule = require("LensStudio:CameraModule");
private cameraRequestLeft: CameraModule.CameraRequest | undefined;
private cameraTextureLeft: Texture | undefined;
private cameraTextureProviderLeft: CameraTextureProvider | undefined;
@agrancini-sc
agrancini-sc / ChangeLanguage.js
Last active March 22, 2025 00:12
Speech Recognition Fix
//@input Component.ScriptComponent speechRecognitionScript {"label": "Speech Recognition Script"}
//@input float switchInterval = 10.0 {"label": "Switch Interval (seconds)"}
var languages = [
"LANGUAGE_ENGLISH",
"LANGUAGE_SPANISH",
"LANGUAGE_FRENCH",
"LANGUAGE_GERMAN"
];
var currentLanguageIndex = 0;
import { Interactable } from "SpectaclesInteractionKit/Components/Interaction/Interactable/Interactable";
import { InteractorEvent } from "SpectaclesInteractionKit/Core/Interactor/InteractorEvent";
import { SIK } from "SpectaclesInteractionKit/SIK";
import { mix } from "SpectaclesInteractionKit/Utils/animate";
import NativeLogger from "SpectaclesInteractionKit/Utils/NativeLogger";
const log = new NativeLogger("MyNativeLogger");
// Interaction System https://developers.snap.com/spectacles/spectacles-frameworks/spectacles-interaction-kit/features/interactionsystem
// Instantiate https://developers.snap.com/lens-studio/api/lens-scripting/classes/Built-In.ObjectPrefab.html#instantiateasync or https://developers.snap.com/lens-studio/lens-studio-workflow/prefabs
@agrancini-sc
agrancini-sc / Example_PrefabInstantiateTween
Created April 3, 2025 21:25
Example_PrefabInstantiateTween
import { LSTween } from "../../LSTween";
import Easing from "../../TweenJS/Easing";
import { RotationInterpolationType } from "../../RotationInterpolationType";
@component
export class Example_PrefabInstantiateTween extends BaseScriptComponent {
@input prefab: ObjectPrefab = null;
@input minRotation: vec3 = new vec3(-45, -45, -45);
@input maxRotation: vec3 = new vec3(45, 45, 45);
@input minScale: vec3 = new vec3(0.5, 0.5, 0.5);
@agrancini-sc
agrancini-sc / gist:5096c51c658f0b342922faf1ce2b42df
Created April 16, 2025 23:56
QuestMarkControllerPlaceObjects.ts
/**
* Imports required dependencies for map functionality, quest markers, and camera handling
*/
import { MapComponent } from "../MapComponent/Scripts/MapComponent";
import { MapPin } from "../MapComponent/Scripts/MapPin";
import {
calculateBearing,
customGetEuler,
getPhysicalDistanceBetweenLocations,
map,
@agrancini-sc
agrancini-sc / DirectionalShadow.ts
Created April 23, 2025 16:00
Directional Shadow
// Import required modules
const WorldQueryModule = require("LensStudio:WorldQueryModule");
const EPSILON = 0.01;
/**
* DirectionalWorldQuery
*
* A utility that performs world queries in a direction defined by two scene objects.
* It can then project rays from a third object in that same direction.
@agrancini-sc
agrancini-sc / SimpleRaycast
Last active April 25, 2025 05:14
SimpleRaycast
This bypasses the interactable system
let me know what you think
remember that you need to set up the ray start and end
you can create 2 scene objects and put them under the main camera
1. at 0,0,0
2. at 0,0,-100 (forward)
then assign a 3rd object that is the one that is instantiated on the hitPoint of the raycast
remember that the geometry receiving the raycast needs to have a collider and a physics body
if you want the receiver to not be dynamic uncheck the dynamic option so it won' react to physics
@agrancini-sc
agrancini-sc / LeaderboardExample
Created May 8, 2025 23:21
LeaderboardExample
@component
export class LeaderboardExample extends BaseScriptComponent {
@input
leaderboardModule: LeaderboardModule;
@input
textLogs: Text;
private leaderboardInstance: any;
private leaderboardName = 'EXAMPLE_LEADERBOARD';