Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda