We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Unable to Reference Updated Global Object From External Interface

Home Forums Programming Unable to Reference Updated Global Object From External Interface

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #24208
    jstubb
    Customer

    Hello,

    It seems my last post was deleted for some reason. Errors kept appearing when I attempted to upload screenshots to the post.

    I am currently attempting to update a global object from outside the verge3d application js file and subsequently reference it inside the application js file in order to call puzzles based on those values.

    The issue I’m currently having is that despite the object appearing to have updated values (when logged with the console after changing settings), when puzzles tries to reference the object it still only has the initial values of the global object from when the application was loaded.

    Here is a small snippet of the code I am using to reference the object from puzzles and update it respectively:

    
    function prepareExternalInterface(app) {
    app.ExternalInterface.updateModel = function(){
    
            console.log("Attempting to update model");
            console.log(nexus);
    }
    }
    

    and for updating the object:

    var nexus = { 
    
        heightShapeFactor: 0,
        widthShapeFactor: 0,
        depthShapeFactor: 0,
    
    nexusImport(nexusUpdate,selectedAccessories,selectedParameters){
            this.heightShapeFactor = nexusUpdate.heightShapeFactor;
            this.widthShapeFactor = nexusUpdate.widthShapeFactor;
            this.depthShapeFactor = nexusUpdate.depthShapeFactor;
    
    ...
    console.log(nexus)
    }
    

    The attached screenshot shows the discrepancy in the console log.

    #24259

    Hi,

    if try to set your variable to a number or String rather than Object, will it work as intended?

    Chief 3D Verger | LinkedIn | Twitter

    #24304
    jstubb
    Customer

    Hello Yuri,

    Thank you for your response.

    The same issue still arises even when the variable is a string or a number.

    #24327

    can you prepare an example project for us that we could debug?

    Chief 3D Verger | LinkedIn | Twitter

    #24366
    jstubb
    Customer

    Yes I have one ready. Would you like me to upload it to the Verge3D Network or send it by some other means?

    #24392

    you can use the newly introduced ‘upload project zip’ feature and share the link with us. Thanks!

    Chief 3D Verger | LinkedIn | Twitter

    #24431
    jstubb
    Customer

    Awesome!

    Here is the link to the uploaded file: model_testbed

    Below is a brief description of the code to improve context/understanding:

    * The Verge3D rendering is displayed in an iframe with a button below it

    * The on screen html button changes and console logs the value of the global object (called “nexus”)

    * Clicking any of the model objects will also trigger a reference to the global object from the “external interface” and console log it
    * The discrepancy can be seen by comparing the console log entries

    #24468

    Hi,

    It look like some .js were linked from both HTML documents, which resulted in conflicts.

    Here is the modified index.html which seemingly works as intended.

    Attachments:
    You must be logged in to view attached files.

    Chief 3D Verger | LinkedIn | Twitter

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.