一键导入
lens-studio-interactive-solvers
Implement proximity-based triggers and smooth tethering behaviors for interactive objects.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Implement proximity-based triggers and smooth tethering behaviors for interactive objects.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Reference guide for 2D UI and screen-space interaction in Lens Studio — covering ScreenTransform anchors/offsets/size/pivot and coordinate conversions (localPointToScreenPoint, screenPointToLocalPoint, localPointToWorldPoint), ScreenImage (texture, stretch mode, color tint), Text component (content, font, alignment, color, size), ScreenRegionComponent for defining tap/touch areas, TouchComponent with TouchStartEvent/TouchMoveEvent/TouchEndEvent, tap input for phone lenses, LSTween UI animations (colorTo, moveTo on screen elements), multi-swatch color picker pattern, undo stack pattern, and common gotchas. Use this skill whenever a lens needs a 2D UI panel, tap interaction, on-screen buttons, text labels, color pickers, swipeable menus, or undo/redo — covering Drawing, Quiz, TappableQuestion, MemeSticker, MusicVideo, and HighScore examples.
Learn how to programmatically request and manage raw camera textures and crops.
Reference guide for face and body AR tracking in Lens Studio — covering FaceTrackingComponent setup (multi-face, faceIndex), FaceInset and FaceMask effects, 2D and 3D Face Attachments (hat/mouth/left_eye/right_eye anchors), Face Mesh UV texturing, Face Landmarks (68 keypoints), Face Expression weights for mouth-open/eye-blink detection, Eye Tracking component (left/right eye direction), Upper Body Tracking 3D asset (hips/spine/shoulder attachment points), Upper Body Mesh for seamless selfie occlusion, and Face Retouch/Eye Color/Face Liquify/Face Stretch effects. Use this skill for any phone or front-camera lens involving faces, selfie effects, makeup, face masks, 3D head ornaments, body tracking, or expression-driven animations — covering the vast majority of Snapchat lens content.
Learn how to dynamically instantiate prefabs algorithmically in grid or spherical patterns.
Learn how to track image markers and detach the tracked content into World Space in AR.
Reference guide for materials and shaders in Lens Studio — covering runtime material property changes (clone-before-modify, mainPass.baseColor, mainPass.opacity, mainPass.baseTex), blend modes (Normal/Alpha/Add/Screen/Multiply), depth and cull settings (depthTest, depthWrite, twoSided, cullMode), render order, material variants, assigning textures and render targets, reading and writing RenderTarget textures for post-processing, the graph-based Material Editor node system, custom shader graph nodes, and common shader pitfalls. Use this skill for any lens that needs to change material colors or textures at runtime, implement custom visual effects with shaders, set up post-processing render pipelines, chain render targets, or debug material/blend-mode issues — covering MaterialEditor, Drawing, and HairSimulation examples.
| name | lens-studio-interactive-solvers |
| description | Implement proximity-based triggers and smooth tethering behaviors for interactive objects. |
Solvers provide reusable mathematical logic for common AR interaction patterns. The two primary solvers available for Spectacles are Distance Triggers (for proximity events) and Tethering (for objects that follow the user or other targets).
Using DistanceEventsTS, you can define specific distance thresholds (in meters) that trigger callbacks when a user or object crosses them.
// Define multiple thresholds
const myProximityTrigger = this.sceneObject.getComponent("Component.DistanceEventsTS");
myProximityTrigger.target = mainCamera;
myProximityTrigger.distances = [1.0, 3.0, 5.0];
// Handle entering a range
myProximityTrigger.onEnterRange = (distance) => {
print(`User entered the ${distance}m zone!`);
};
// Handle exit
myProximityTrigger.onExitRange = (distance) => {
print(`User left the ${distance}m zone.`);
};
The TetherTS script implements a "constrained follow" behavior, where an object only repositions itself after the target has moved beyond a certain horizontal or vertical limit. This prevents objects from jittering or feeling too tightly bound to the user's head.
const tether = this.sceneObject.getComponent("Component.TetherTS");
tether.target = mainCamera;
tether.offset = new vec3(0, -10, 50); // Relative position
tether.verticalDistanceFromTarget = 15.0; // Don't move if user only tilts head slightly
tether.horizontalDistanceFromTarget = 20.0; // Don't move if user only shifts slightly
tether.lerpSpeed = 5.0; // Smooth movement speed
Interactive solvers typically use the following linear interpolation (lerp) pattern for smooth updates:
const newPos = vec3.lerp(
currentPos,
targetGoalPos,
lerpSpeed * getDeltaTime()
);
myTransform.setWorldPosition(newPos);
The code logic below is extracted from the official Solvers.lspkg package, detailing the distance threshold and tethering math.
See the reference guides: