Created
March 31, 2020 13:51
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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