Get the pixel screen size in Spark AR studio (for Facebook)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am starting to work with Spark AR studio and I looking for to get the screen size in pixel to compare the coordinate obtained by the gesture.location on Tap.



TouchGestures.onTap().subscribe((gesture) => {
// ! The location is always specified in the screen coordinates
Diagnostics.log(`Screen touch in pixel = { x:${gesture.location.x}, y: ${gesture.location.y} }`);

// ????
});


The gesture.location is in pixel (screen coordinate) and would like to compare it with the screen size to determine which side of the screen is touched.



Maybe using the Camera.focalPlane could be a good idea...



Update



I tried two new things to have the screen size:



const CameraInfo = require('CameraInfo');
Diagnostics.log(CameraInfo.previewSize.height.pinLastValue());

const focalPlane = Scene.root.find('Camera').focalPlane;
Diagnostics.log(focalPlane.height.pinLastValue());


But both return 0










share|improve this question































    0















    I am starting to work with Spark AR studio and I looking for to get the screen size in pixel to compare the coordinate obtained by the gesture.location on Tap.



    TouchGestures.onTap().subscribe((gesture) => {
    // ! The location is always specified in the screen coordinates
    Diagnostics.log(`Screen touch in pixel = { x:${gesture.location.x}, y: ${gesture.location.y} }`);

    // ????
    });


    The gesture.location is in pixel (screen coordinate) and would like to compare it with the screen size to determine which side of the screen is touched.



    Maybe using the Camera.focalPlane could be a good idea...



    Update



    I tried two new things to have the screen size:



    const CameraInfo = require('CameraInfo');
    Diagnostics.log(CameraInfo.previewSize.height.pinLastValue());

    const focalPlane = Scene.root.find('Camera').focalPlane;
    Diagnostics.log(focalPlane.height.pinLastValue());


    But both return 0










    share|improve this question



























      0












      0








      0








      I am starting to work with Spark AR studio and I looking for to get the screen size in pixel to compare the coordinate obtained by the gesture.location on Tap.



      TouchGestures.onTap().subscribe((gesture) => {
      // ! The location is always specified in the screen coordinates
      Diagnostics.log(`Screen touch in pixel = { x:${gesture.location.x}, y: ${gesture.location.y} }`);

      // ????
      });


      The gesture.location is in pixel (screen coordinate) and would like to compare it with the screen size to determine which side of the screen is touched.



      Maybe using the Camera.focalPlane could be a good idea...



      Update



      I tried two new things to have the screen size:



      const CameraInfo = require('CameraInfo');
      Diagnostics.log(CameraInfo.previewSize.height.pinLastValue());

      const focalPlane = Scene.root.find('Camera').focalPlane;
      Diagnostics.log(focalPlane.height.pinLastValue());


      But both return 0










      share|improve this question
















      I am starting to work with Spark AR studio and I looking for to get the screen size in pixel to compare the coordinate obtained by the gesture.location on Tap.



      TouchGestures.onTap().subscribe((gesture) => {
      // ! The location is always specified in the screen coordinates
      Diagnostics.log(`Screen touch in pixel = { x:${gesture.location.x}, y: ${gesture.location.y} }`);

      // ????
      });


      The gesture.location is in pixel (screen coordinate) and would like to compare it with the screen size to determine which side of the screen is touched.



      Maybe using the Camera.focalPlane could be a good idea...



      Update



      I tried two new things to have the screen size:



      const CameraInfo = require('CameraInfo');
      Diagnostics.log(CameraInfo.previewSize.height.pinLastValue());

      const focalPlane = Scene.root.find('Camera').focalPlane;
      Diagnostics.log(focalPlane.height.pinLastValue());


      But both return 0







      javascript facebook augmented-reality spark-ar-studio






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 23 at 17:34







      Jérémie Boulay

















      asked Jan 4 at 17:06









      Jérémie BoulayJérémie Boulay

      1169




      1169
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Screen size is available via the Device Info patch output, after dragging it to patch editor from the Scene section.
          Device Info patch






          share|improve this answer


























          • I need to have these values in the script. And I don't succeed to add these to the script. See my last update

            – Jérémie Boulay
            Jan 22 at 21:07



















          0














          Finally,



          Using the Device Info in the Path Editor and pass these through the script works!



          First, add a variable "to script" in the editor:



          enter image description here



          Then, create that in patch editor:



          enter image description here



          And you can grab that with this script:



          const Patches = require('Patches');
          const screenSize = Patches.getPoint2DValue('screenSize');


          My mistake was to use Diagnostic.log() to check if my variable worked well.
          Use instead Diagnostic.watch():



          Diagnostic.watch('screenSize.x', screenSize.x);
          Diagnostic.watch('screenSize.y', screenSize.y);





          share|improve this answer
























            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',
            autoActivateHeartbeat: false,
            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%2f54043264%2fget-the-pixel-screen-size-in-spark-ar-studio-for-facebook%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Screen size is available via the Device Info patch output, after dragging it to patch editor from the Scene section.
            Device Info patch






            share|improve this answer


























            • I need to have these values in the script. And I don't succeed to add these to the script. See my last update

              – Jérémie Boulay
              Jan 22 at 21:07
















            1














            Screen size is available via the Device Info patch output, after dragging it to patch editor from the Scene section.
            Device Info patch






            share|improve this answer


























            • I need to have these values in the script. And I don't succeed to add these to the script. See my last update

              – Jérémie Boulay
              Jan 22 at 21:07














            1












            1








            1







            Screen size is available via the Device Info patch output, after dragging it to patch editor from the Scene section.
            Device Info patch






            share|improve this answer















            Screen size is available via the Device Info patch output, after dragging it to patch editor from the Scene section.
            Device Info patch







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 22 at 3:57

























            answered Jan 22 at 1:09









            goretexgoretex

            112




            112













            • I need to have these values in the script. And I don't succeed to add these to the script. See my last update

              – Jérémie Boulay
              Jan 22 at 21:07



















            • I need to have these values in the script. And I don't succeed to add these to the script. See my last update

              – Jérémie Boulay
              Jan 22 at 21:07

















            I need to have these values in the script. And I don't succeed to add these to the script. See my last update

            – Jérémie Boulay
            Jan 22 at 21:07





            I need to have these values in the script. And I don't succeed to add these to the script. See my last update

            – Jérémie Boulay
            Jan 22 at 21:07













            0














            Finally,



            Using the Device Info in the Path Editor and pass these through the script works!



            First, add a variable "to script" in the editor:



            enter image description here



            Then, create that in patch editor:



            enter image description here



            And you can grab that with this script:



            const Patches = require('Patches');
            const screenSize = Patches.getPoint2DValue('screenSize');


            My mistake was to use Diagnostic.log() to check if my variable worked well.
            Use instead Diagnostic.watch():



            Diagnostic.watch('screenSize.x', screenSize.x);
            Diagnostic.watch('screenSize.y', screenSize.y);





            share|improve this answer




























              0














              Finally,



              Using the Device Info in the Path Editor and pass these through the script works!



              First, add a variable "to script" in the editor:



              enter image description here



              Then, create that in patch editor:



              enter image description here



              And you can grab that with this script:



              const Patches = require('Patches');
              const screenSize = Patches.getPoint2DValue('screenSize');


              My mistake was to use Diagnostic.log() to check if my variable worked well.
              Use instead Diagnostic.watch():



              Diagnostic.watch('screenSize.x', screenSize.x);
              Diagnostic.watch('screenSize.y', screenSize.y);





              share|improve this answer


























                0












                0








                0







                Finally,



                Using the Device Info in the Path Editor and pass these through the script works!



                First, add a variable "to script" in the editor:



                enter image description here



                Then, create that in patch editor:



                enter image description here



                And you can grab that with this script:



                const Patches = require('Patches');
                const screenSize = Patches.getPoint2DValue('screenSize');


                My mistake was to use Diagnostic.log() to check if my variable worked well.
                Use instead Diagnostic.watch():



                Diagnostic.watch('screenSize.x', screenSize.x);
                Diagnostic.watch('screenSize.y', screenSize.y);





                share|improve this answer













                Finally,



                Using the Device Info in the Path Editor and pass these through the script works!



                First, add a variable "to script" in the editor:



                enter image description here



                Then, create that in patch editor:



                enter image description here



                And you can grab that with this script:



                const Patches = require('Patches');
                const screenSize = Patches.getPoint2DValue('screenSize');


                My mistake was to use Diagnostic.log() to check if my variable worked well.
                Use instead Diagnostic.watch():



                Diagnostic.watch('screenSize.x', screenSize.x);
                Diagnostic.watch('screenSize.y', screenSize.y);






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 23 at 17:33









                Jérémie BoulayJérémie Boulay

                1169




                1169






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54043264%2fget-the-pixel-screen-size-in-spark-ar-studio-for-facebook%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

                    generate and download xml file after input submit (php and mysql) - JPK

                    Angular Downloading a file using contenturl with Basic Authentication

                    Can't read property showImagePicker of undefined in react native iOS