Skip to content

Instalación

Instala el paquete monolook y el motor 3D que vaya a usar tu integración.

bash
npm install monolook

Para Three.js:

bash
npm install three

Para Babylon.js:

bash
npm install @babylonjs/core

A-Frame se carga normalmente por CDN en el HTML.

Imports

Monolook usa sub-paths. Importa solo el producto y adapter que necesites.

Sub-pathDescripción
monolook/worldCore/facade de Monolook World para surface tracking.
monolook/world/threeAdapter Three.js para World.
monolook/world/aframeAdapter A-Frame para World.
monolook/world/babylonAdapter Babylon.js para World.
monolook/imageCore de Monolook Image para image tracking.
monolook/image/threeAdapter Three.js para Image.
monolook/image/aframeAdapter A-Frame para Image.
monolook/image/babylonAdapter Babylon.js para Image.

World

js
import * as THREE from 'three'
import { Monolook } from 'monolook/world'

const monolook = new Monolook({
  adapter: 'three',
  THREE,
  scene,
  camera,
  renderer,
  domOverlayRoot: document.getElementById('dom_overlay')
})

await monolook.start({
  mode: 'surface',
  licenseKey: '<WORLD_LICENSE_KEY>'
})

Image

js
import { MonolookImage } from 'monolook/image'
import { ThreeAdapter } from 'monolook/image/three'

const tracker = new MonolookImage({
  licenseKey: '<IMAGE_LICENSE_KEY>'
})

await tracker.init()

const adapter = new ThreeAdapter({ scene, camera, renderer })
adapter.attach(tracker)

Vite

Si usas Monolook Image con Vite, excluye monolook de optimizeDeps para que el WASM se resuelva correctamente en desarrollo.

js
import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {
    exclude: ['monolook']
  }
})

Peer dependencies

three, aframe y @babylonjs/core son peer dependencies opcionales. Instala solo el motor que use tu proyecto.