0

I am trying to add some dynamic data to my scene. I've read that I need to do this using Register Component, so I tried it but I'm not having any luck.

I want to create some variables I can use in my scene.

<script>
    AFRAME.registerComponent("set-data", {
        init: function(){
    var theURL = "/link-to-my-NFT";
    var theScale = 220;
    var thePos = 100;
        }
    });
</script>

Then I tried to use these variables:

...
<a-nft
      type="nft"
      url="theURL"   <-------
      smooth="true"
      emitevents="true"
      smoothCount="10"
      smoothTolerance=".01"
      smoothThreshold="5"
    >
      <a-entity
        gltf-model="/link-to-model.glb"
        scale="theScale theScale theScale"    <-------
        position="thePOS thePOS 0"   <--------
      >

My goal is to be able to change these details based on which NFT image I want to load. Is this possible and I'm close, or should I go about it another way? Thanks for any help.

EDIT: I didn't realize that you could have multiple markers on one page! That is much easier than trying to read which marker I need from the URL.

glaemart
  • 129
  • 1
  • 10
  • to change the `scale` & `position` maybe you could try my answer in this question here https://stackoverflow.com/questions/60935284/event-listeners-in-ar-js/61044749#61044749. To change the `a-nft` `url` i am not sure – jef Apr 27 '20 at 05:38
  • if you want to change some attribute, i will not use init but tick() or update(). You are also mixing and confusing things. You are registering a component ('set-data') but you are not using it. – kalwalt Apr 28 '20 at 19:15
  • I don't need to change the attribute once it is loaded. I'm trying to set the initial parameters based on tags I will send in the URL. I see now that I am not using the component, I will try to figure that part out. Thanks! – glaemart Apr 29 '20 at 17:45

0 Answers0