Skip to content

Instantly share code, notes, and snippets.

@Utopiah
Created March 31, 2020 13:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Utopiah/a463b766016ce949fb4bbf46d62103ba to your computer and use it in GitHub Desktop.
Save Utopiah/a463b766016ce949fb4bbf46d62103ba to your computer and use it in GitHub Desktop.
Getting close to a target object, e.g. here latest added PDF, makes it grow for any avatar within a 5m radius
var avatars = document.querySelectorAll("[networked-avatar]")
var PDFs = AFRAME.scenes[0].querySelectorAll("[media-pdf]");
var mostRecentPDF = PDFs[PDFs.length-1]
if (scalingTrigger) clearInterval(scalingTrigger)
var scalingTrigger = setInterval(nearbyAvarScaleUp, 300)
function nearbyAvarScaleUp(){
for (var avatar of avatars) {
var dist = mostRecentPDF.object3D.position.distanceTo( avatar.object3D.position)
if (dist<5) mostRecentPDF.object3D.scale.addScalar( 0.1 )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment