Home › Forums › Programming › Unable to Reference Updated Global Object From External Interface
Tagged: External Interface, Javascript Objects, puzzles
- This topic has 7 replies, 2 voices, and was last updated 4 years, 9 months ago by Yuri Kovelenov.
-
AuthorPosts
-
2020-03-03 at 2:34 pm #24208jstubbCustomer
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.
2020-03-04 at 10:18 am #24259Yuri KovelenovStaff2020-03-04 at 9:12 pm #24304jstubbCustomerHello Yuri,
Thank you for your response.
The same issue still arises even when the variable is a string or a number.
2020-03-05 at 7:37 am #24327Yuri KovelenovStaff2020-03-05 at 3:00 pm #24366jstubbCustomerYes I have one ready. Would you like me to upload it to the Verge3D Network or send it by some other means?
2020-03-06 at 7:27 am #24392Yuri KovelenovStaff2020-03-06 at 3:09 pm #24431jstubbCustomerAwesome!
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 entries2020-03-07 at 11:21 am #24468Yuri KovelenovStaff -
AuthorPosts
- You must be logged in to reply to this topic.