Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
SparkAR pinLastValue() returning 0;

I'm started a project in SparkAR and having some trouble with getting the correct value in my script in 2 places now. Using .pinLastValue() doesn't provided the number shown in the diagnostics.

Example 1:

const directionX = Reactive.sub(Object.worldTransform.x, Target.worldTransform.x);
const directionY = Reactive.sub(Object.worldTransform.y, Target.worldTransform.y);
const directionZ = Reactive.sub(Object.worldTransform.z, Target.worldTransform.z);

Diagnostics.watch('directionX: ', directionX);
Diagnostics.watch('directionZ: ', directionZ);

Provides the values in the diagnostics:

directionX: -0.44

directionZ: -0.02

const angleRad = Math.atan2(directionX, directionZ);
Diagnostics.watch('angleRad: ', angleRad);

returns null/underfined

const angleRad = Math.atan2(directionX.pinLastValue(), directionZ.pinLastValue());
Diagnostics.watch('angleRad: ', angleRad);

returns angleRad of 0

const angleRad = Math.atan2(-0.44, -0.02);
Diagnostics.watch('angleRad: ', angleRad);

returns the correct value

Example 2:

when I call

const closestIndex = indexes.reduce((acc, cur) => Reactive.max(acc, cur));
Diagnostics.watch('Result',closestIndex);

returns closestIndex as 2

If I try to use closetIndex to find an object by name in my array it doesn't give me the 3rd object [2] in the list it just provides me the first [0]

I'm using:

Diagnostics.log(objArray[closestIndex.pinLastValue()].name);

returns object_0

where I want it to return object_2

In both these examples it doesn't return the number I want (what's in the diagnostics) but just returns 0. What am I doing wrong? Thank you for your time.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda