Technologies
Gradle (library arshadeskit) — core deps:
- Kotlin, AndroidX (core/appcompat/lifecycle)
- Sceneform 1.21.0 (ARCore rendering)
Gradle (sample app) — Compose Material 3, AndroidX; no AR logic beyond hosting the SDK.
Technologies
-
Language & UI
- Kotlin
- Jetpack Compose (sample app only; the SDK is UI-agnostic)
- Material 3 (sample app)
-
AR stack
- ARCore (Augmented Face)
- Sceneform (
com.gorisse.thomas.sceneform:sceneform:1.21.0) for GLB loading, nodes, transforms
-
Min/Target SDKs
minSdk 26,compileSdk/targetSdk 33(as in the provided Gradle)
-
Permissions
- Camera permission required for AR
Core Components
AugmentedGlassesController
- Purpose: the main orchestrator that binds the AR camera session, Augmented Face tracking, and GLB eyewear models.
- Responsibilities
- Start/stop AR session with camera lifecycle.
- Detect face regions (forehead/nose bridge/temples) and attach the eyewear node.
- Load & cache GLB models (via
RenderModelsUtils) and apply scale/rotation/offset. - Provide simple APIs to switch models (e.g., user taps a card → change glasses).
- Expose callbacks for tracking state (no face / one face / two faces).
RenderModelsUtils
- Purpose: utilities for loading & preparing GLB models for Sceneform.
- Responsibilities
- Async loading from local files or assets.
- Optional lightweight caching of
Renderables. - Helpers for applying initial transforms (scale/rotation) to match the face rig.
IModello
- Contract for eyewear models:
- Stable id
- Source (local file path / asset path / URI)
- Optional initial transforms (scale, position offset, rotation)
ITryOnScreenViewModel
- Host-app interface for controlling try-on UI state:
- Selected eyewear id/model
- Hooks to react to tracking state, snapshot requests, etc.
- Acts as a bridge between your app (filters, favorites, analytics) and the SDK.
IUserAr
- User/session hints interface, e.g. user category, IPD fallback ranges, app flavor flags.
- Optional; implement only if your app needs to tailor transforms or behavior.
Example usage
class MainActivity : AppCompatActivity() {
private lateinit var controller: AugmentedGlassesController
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// 1) Create/attach a container view for AR
val container = FrameLayout(this).apply { id = View.generateViewId() }
setContentView(container)
// 2) Build your model descriptor
val model: IModello = object : IModello {
override val id = "rb3447"
override val sourcePath = File(filesDir, "glasses/rb3447.glb").absolutePath
override val initialScale = 1.0f
override val initialRotation = Quaternion()
override val initialOffset = Vector3(0f, 0f, 0f)
}
// 3) Init the controller
controller = AugmentedGlassesController(
context = this,
containerId = container.id,
)
// 4) Start session & load a model
controller.start()
controller.loadModel(model)
}
override fun onResume() {
super.onResume()
controller.resume()
}
override fun onPause() {
controller.pause()
super.onPause()
}
override fun onDestroy() {
controller.destroy()
super.onDestroy()
}
}
In Compose, host the controller inside an
AndroidViewor a Fragment container.
Asset Management
- Model format: GLB recommended (PBR materials supported by Sceneform / Filament).
- Where to store:
- Local storage — pre-downloaded for offline mirrors or retail devices.
- Assets/ — for demo content.
- Remote — download once, persist to files, then pass the absolute path to the SDK.
- Quality tips:
- Bake textures & keep polycounts balanced for smooth 60 FPS rendering.
- Prefer physically correct materials; avoid unsupported Filament extensions.
Integration Notes
Device requirements
- Requires an ARCore-supported device with front camera Augmented Face capability.
Permissions
- Request Camera permission at runtime.
Lifecycle
- Tie
start/resume/pause/destroyto theActivity/Fragmentlifecycle to keep camera & GL resources alive.
Performance
- Reuse Renderables when switching glasses.
- Keep model sizes modest and compress textures to reduce GPU load.
Error handling
- Detect no-face or multiple-faces states.
- Provide user guidance (e.g., "Please position your face inside the frame").