Timer + Aframe : How to use setTimeOut for Aframe.registercomponent(“…”)









up vote
1
down vote

favorite












I know it's a beginner's question but I have a bit of trouble with html / javascript.
I learned about the setTimeout (function, time) and I knew how to use it by creating a function.
However, I was wondering if it is possible to use this setTimeOut for Aframe.registercomponent my other scripts? I didn't find anything on that and all my attempts failed.



For example for the "audioanalyser-waveform":



AFRAME.registerComponent('audioanalyser-waveform', {
dependencies: ['audioanalyser'],

schema:
maxHeight: default: 0.2,
multiplier: default: .01,
radius: default: 1,
,

init: function ()
this.colors = ;
this.geometry;
this.levels = ;
this.noisePos = 0;
this.rings = ;
,


update: function () {
setTimeout(Color, 4000);
var data = this.data;
var el = this.el;
var i;
...
...


This one is in my wave.js script
and i know i can call it in my index.html with the tags:



 <a-entity id="analyser"
audioanalyser="src: #song"
audioanalyser-waveform="radius: 1"
rotation="210 0 0"
position="0 100 -150"
></a-entity>


And it would have been so simple if I could add that :



 <script> setTimeout(audioanalyser-waveform, 4000); </script>


But it doesn't work like that and I don't have idea how to set the start / stop of an Aframe.registercomponent to choose its seconds of play.



Can you help me please...



Pulsar,










share|improve this question

























    up vote
    1
    down vote

    favorite












    I know it's a beginner's question but I have a bit of trouble with html / javascript.
    I learned about the setTimeout (function, time) and I knew how to use it by creating a function.
    However, I was wondering if it is possible to use this setTimeOut for Aframe.registercomponent my other scripts? I didn't find anything on that and all my attempts failed.



    For example for the "audioanalyser-waveform":



    AFRAME.registerComponent('audioanalyser-waveform', {
    dependencies: ['audioanalyser'],

    schema:
    maxHeight: default: 0.2,
    multiplier: default: .01,
    radius: default: 1,
    ,

    init: function ()
    this.colors = ;
    this.geometry;
    this.levels = ;
    this.noisePos = 0;
    this.rings = ;
    ,


    update: function () {
    setTimeout(Color, 4000);
    var data = this.data;
    var el = this.el;
    var i;
    ...
    ...


    This one is in my wave.js script
    and i know i can call it in my index.html with the tags:



     <a-entity id="analyser"
    audioanalyser="src: #song"
    audioanalyser-waveform="radius: 1"
    rotation="210 0 0"
    position="0 100 -150"
    ></a-entity>


    And it would have been so simple if I could add that :



     <script> setTimeout(audioanalyser-waveform, 4000); </script>


    But it doesn't work like that and I don't have idea how to set the start / stop of an Aframe.registercomponent to choose its seconds of play.



    Can you help me please...



    Pulsar,










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I know it's a beginner's question but I have a bit of trouble with html / javascript.
      I learned about the setTimeout (function, time) and I knew how to use it by creating a function.
      However, I was wondering if it is possible to use this setTimeOut for Aframe.registercomponent my other scripts? I didn't find anything on that and all my attempts failed.



      For example for the "audioanalyser-waveform":



      AFRAME.registerComponent('audioanalyser-waveform', {
      dependencies: ['audioanalyser'],

      schema:
      maxHeight: default: 0.2,
      multiplier: default: .01,
      radius: default: 1,
      ,

      init: function ()
      this.colors = ;
      this.geometry;
      this.levels = ;
      this.noisePos = 0;
      this.rings = ;
      ,


      update: function () {
      setTimeout(Color, 4000);
      var data = this.data;
      var el = this.el;
      var i;
      ...
      ...


      This one is in my wave.js script
      and i know i can call it in my index.html with the tags:



       <a-entity id="analyser"
      audioanalyser="src: #song"
      audioanalyser-waveform="radius: 1"
      rotation="210 0 0"
      position="0 100 -150"
      ></a-entity>


      And it would have been so simple if I could add that :



       <script> setTimeout(audioanalyser-waveform, 4000); </script>


      But it doesn't work like that and I don't have idea how to set the start / stop of an Aframe.registercomponent to choose its seconds of play.



      Can you help me please...



      Pulsar,










      share|improve this question













      I know it's a beginner's question but I have a bit of trouble with html / javascript.
      I learned about the setTimeout (function, time) and I knew how to use it by creating a function.
      However, I was wondering if it is possible to use this setTimeOut for Aframe.registercomponent my other scripts? I didn't find anything on that and all my attempts failed.



      For example for the "audioanalyser-waveform":



      AFRAME.registerComponent('audioanalyser-waveform', {
      dependencies: ['audioanalyser'],

      schema:
      maxHeight: default: 0.2,
      multiplier: default: .01,
      radius: default: 1,
      ,

      init: function ()
      this.colors = ;
      this.geometry;
      this.levels = ;
      this.noisePos = 0;
      this.rings = ;
      ,


      update: function () {
      setTimeout(Color, 4000);
      var data = this.data;
      var el = this.el;
      var i;
      ...
      ...


      This one is in my wave.js script
      and i know i can call it in my index.html with the tags:



       <a-entity id="analyser"
      audioanalyser="src: #song"
      audioanalyser-waveform="radius: 1"
      rotation="210 0 0"
      position="0 100 -150"
      ></a-entity>


      And it would have been so simple if I could add that :



       <script> setTimeout(audioanalyser-waveform, 4000); </script>


      But it doesn't work like that and I don't have idea how to set the start / stop of an Aframe.registercomponent to choose its seconds of play.



      Can you help me please...



      Pulsar,







      html time components settimeout aframe






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 19:54









      Pulsar19

      83




      83






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          What are you trying to accomplish? Can you have a component that sets audioanalyser-waveform after 4000ms?



           <a-entity id="analyser"
          audioanalyser="src: #song"
          rotation="210 0 0"
          position="0 100 -150"
          your-component
          ></a-entity>


          Component code:



          AFRAME.registerComponent('your-component', 
          ...
          init: function ()
          setTimeout(() =>
          this.el.setAttribute('audioanalyser-waveform', radius: 1);
          , 4000)

          ...
          );





          share|improve this answer




















          • I try to create an ""animation music video" and my video must match the music. Yes, it is working ! Thank you !! Mmmh... is it possible to stop my component after 8000ms for example ? (Thanks)
            – Pulsar19
            Nov 8 at 21:59










          • Using setTimeout is probably not the best way to sync with music but you can do this.el.removeAttribute('audioanalyser-waveform') or define methods start / stop in your component that you can call: this.el.components['audioanalyser-waveform'].start()
            – Diego Marcos
            Nov 8 at 22:43










          • Sorry I didn't see your answer yesterday. I have some difficult to write these methods start/stop, it is why I prefer setTimeout haha :^) Thank you so much for your help, it is working ! Good evening Diego !
            – Pulsar19
            Nov 9 at 20:26











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53215206%2ftimer-aframe-how-to-use-settimeout-for-aframe-registercomponent%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          What are you trying to accomplish? Can you have a component that sets audioanalyser-waveform after 4000ms?



           <a-entity id="analyser"
          audioanalyser="src: #song"
          rotation="210 0 0"
          position="0 100 -150"
          your-component
          ></a-entity>


          Component code:



          AFRAME.registerComponent('your-component', 
          ...
          init: function ()
          setTimeout(() =>
          this.el.setAttribute('audioanalyser-waveform', radius: 1);
          , 4000)

          ...
          );





          share|improve this answer




















          • I try to create an ""animation music video" and my video must match the music. Yes, it is working ! Thank you !! Mmmh... is it possible to stop my component after 8000ms for example ? (Thanks)
            – Pulsar19
            Nov 8 at 21:59










          • Using setTimeout is probably not the best way to sync with music but you can do this.el.removeAttribute('audioanalyser-waveform') or define methods start / stop in your component that you can call: this.el.components['audioanalyser-waveform'].start()
            – Diego Marcos
            Nov 8 at 22:43










          • Sorry I didn't see your answer yesterday. I have some difficult to write these methods start/stop, it is why I prefer setTimeout haha :^) Thank you so much for your help, it is working ! Good evening Diego !
            – Pulsar19
            Nov 9 at 20:26















          up vote
          0
          down vote



          accepted










          What are you trying to accomplish? Can you have a component that sets audioanalyser-waveform after 4000ms?



           <a-entity id="analyser"
          audioanalyser="src: #song"
          rotation="210 0 0"
          position="0 100 -150"
          your-component
          ></a-entity>


          Component code:



          AFRAME.registerComponent('your-component', 
          ...
          init: function ()
          setTimeout(() =>
          this.el.setAttribute('audioanalyser-waveform', radius: 1);
          , 4000)

          ...
          );





          share|improve this answer




















          • I try to create an ""animation music video" and my video must match the music. Yes, it is working ! Thank you !! Mmmh... is it possible to stop my component after 8000ms for example ? (Thanks)
            – Pulsar19
            Nov 8 at 21:59










          • Using setTimeout is probably not the best way to sync with music but you can do this.el.removeAttribute('audioanalyser-waveform') or define methods start / stop in your component that you can call: this.el.components['audioanalyser-waveform'].start()
            – Diego Marcos
            Nov 8 at 22:43










          • Sorry I didn't see your answer yesterday. I have some difficult to write these methods start/stop, it is why I prefer setTimeout haha :^) Thank you so much for your help, it is working ! Good evening Diego !
            – Pulsar19
            Nov 9 at 20:26













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          What are you trying to accomplish? Can you have a component that sets audioanalyser-waveform after 4000ms?



           <a-entity id="analyser"
          audioanalyser="src: #song"
          rotation="210 0 0"
          position="0 100 -150"
          your-component
          ></a-entity>


          Component code:



          AFRAME.registerComponent('your-component', 
          ...
          init: function ()
          setTimeout(() =>
          this.el.setAttribute('audioanalyser-waveform', radius: 1);
          , 4000)

          ...
          );





          share|improve this answer












          What are you trying to accomplish? Can you have a component that sets audioanalyser-waveform after 4000ms?



           <a-entity id="analyser"
          audioanalyser="src: #song"
          rotation="210 0 0"
          position="0 100 -150"
          your-component
          ></a-entity>


          Component code:



          AFRAME.registerComponent('your-component', 
          ...
          init: function ()
          setTimeout(() =>
          this.el.setAttribute('audioanalyser-waveform', radius: 1);
          , 4000)

          ...
          );






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 21:37









          Diego Marcos

          1,5851913




          1,5851913











          • I try to create an ""animation music video" and my video must match the music. Yes, it is working ! Thank you !! Mmmh... is it possible to stop my component after 8000ms for example ? (Thanks)
            – Pulsar19
            Nov 8 at 21:59










          • Using setTimeout is probably not the best way to sync with music but you can do this.el.removeAttribute('audioanalyser-waveform') or define methods start / stop in your component that you can call: this.el.components['audioanalyser-waveform'].start()
            – Diego Marcos
            Nov 8 at 22:43










          • Sorry I didn't see your answer yesterday. I have some difficult to write these methods start/stop, it is why I prefer setTimeout haha :^) Thank you so much for your help, it is working ! Good evening Diego !
            – Pulsar19
            Nov 9 at 20:26

















          • I try to create an ""animation music video" and my video must match the music. Yes, it is working ! Thank you !! Mmmh... is it possible to stop my component after 8000ms for example ? (Thanks)
            – Pulsar19
            Nov 8 at 21:59










          • Using setTimeout is probably not the best way to sync with music but you can do this.el.removeAttribute('audioanalyser-waveform') or define methods start / stop in your component that you can call: this.el.components['audioanalyser-waveform'].start()
            – Diego Marcos
            Nov 8 at 22:43










          • Sorry I didn't see your answer yesterday. I have some difficult to write these methods start/stop, it is why I prefer setTimeout haha :^) Thank you so much for your help, it is working ! Good evening Diego !
            – Pulsar19
            Nov 9 at 20:26
















          I try to create an ""animation music video" and my video must match the music. Yes, it is working ! Thank you !! Mmmh... is it possible to stop my component after 8000ms for example ? (Thanks)
          – Pulsar19
          Nov 8 at 21:59




          I try to create an ""animation music video" and my video must match the music. Yes, it is working ! Thank you !! Mmmh... is it possible to stop my component after 8000ms for example ? (Thanks)
          – Pulsar19
          Nov 8 at 21:59












          Using setTimeout is probably not the best way to sync with music but you can do this.el.removeAttribute('audioanalyser-waveform') or define methods start / stop in your component that you can call: this.el.components['audioanalyser-waveform'].start()
          – Diego Marcos
          Nov 8 at 22:43




          Using setTimeout is probably not the best way to sync with music but you can do this.el.removeAttribute('audioanalyser-waveform') or define methods start / stop in your component that you can call: this.el.components['audioanalyser-waveform'].start()
          – Diego Marcos
          Nov 8 at 22:43












          Sorry I didn't see your answer yesterday. I have some difficult to write these methods start/stop, it is why I prefer setTimeout haha :^) Thank you so much for your help, it is working ! Good evening Diego !
          – Pulsar19
          Nov 9 at 20:26





          Sorry I didn't see your answer yesterday. I have some difficult to write these methods start/stop, it is why I prefer setTimeout haha :^) Thank you so much for your help, it is working ! Good evening Diego !
          – Pulsar19
          Nov 9 at 20:26


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53215206%2ftimer-aframe-how-to-use-settimeout-for-aframe-registercomponent%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          Edmonton

          Crossroads (UK TV series)