manu225 Posted June 8, 2016 Share Posted June 8, 2016 Hi everyone, I'm writing a plugin for Wordpress that use Babylon JS and I got a little problem. I try to load a mesh : var obj = loader.addMeshTask("tortue", "", WPURLS.plugin_dir+'/models/turtle/', "turtle-lowpoly.obj"); obj.onSuccess = function(task){ console.log('ok'); } The model is loaded (I see it in Firebug) but the onSuccess function is never triggered. If I put the code as standalone it works well... You can see here the problem : http://www.info-d-74.com/test-3d-object/ URL of the script is : http://www.info-d-74.com/wp-content/plugins/3d-objects/js/3d_object.js?ver=4.5.2 Any idea to fix it ? Thanks Quote Link to comment Share on other sites More sharing options...
adam Posted June 8, 2016 Share Posted June 8, 2016 Try adding an onError callback. manu225 1 Quote Link to comment Share on other sites More sharing options...
adam Posted June 8, 2016 Share Posted June 8, 2016 "Unexpected token # in JSON at position 0" Quote Link to comment Share on other sites More sharing options...
adam Posted June 8, 2016 Share Posted June 8, 2016 Shouldn't this onError function: https://github.com/BabylonJS/Babylon.js/blob/7317ed822e3e2d52a44966fa4d2fdc3b0a91291a/src/Tools/babylon.assetsManager.ts#L100 be passing on the error message that is passed to it here: https://github.com/BabylonJS/Babylon.js/blob/069da0144a4eb915e2e9b1043f91df7f776b7470/src/Loading/babylon.sceneLoader.ts#L133 Quote Link to comment Share on other sites More sharing options...
manu225 Posted June 9, 2016 Author Share Posted June 9, 2016 Thanks adam for your help. I add these followinh lines : obj.onError = function(error){ console.log('error'); }; loader.onTaskError = function(tasks) { console.log('Error loading: '+tasks.name); }; The two error callbacks are triggered, but I don't know how to get the error message... Where did you get "Unexpected token # in JSON at position 0" error ? Quote Link to comment Share on other sites More sharing options...
adam Posted June 9, 2016 Share Posted June 9, 2016 I used the Chrome debugger. The error message was here: https://github.com/BabylonJS/Babylon.js/blob/9eecc40cacb41b117cf6d229a87ab63e8182108b/src/Loading/babylon.sceneLoader.js#L137 Which is at line 16089 of the prettified babylon.js file on your site. Quote Link to comment Share on other sites More sharing options...
manu225 Posted June 13, 2016 Author Share Posted June 13, 2016 It's so strange, I don't understand what is going wrong... It try to change Wordpress theme but still the issue :/ The obj file is correctly loaded (see screenshot below). May be a problem with the charset and/or break lines ? Quote Link to comment Share on other sites More sharing options...
Temechon Posted June 14, 2016 Share Posted June 14, 2016 Works correctly here : http://www.babylonjs-playground.com/#NZLJD#1 Maybe the problem is on your server ? Quote Link to comment Share on other sites More sharing options...
manu225 Posted June 15, 2016 Author Share Posted June 15, 2016 It work correctly too when it put the code has standalone on the same server. The bug appear only when I used it in the Wordpress plugin. Maybe a conflict with another javascript library... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.