error when loading a mesh with ros3djs
I am trying to load a .stl 3d model of a drone in a html page using Javascript and ros3djs as follow :
const mesh = new ROS3D.MeshResource({
resource: 'models/3d-model-drone/octo-asm.stl',
path: 'ws://localhost:9090/',
warnings: true
});
but I keep getting this object as error:
error
bubbles: false
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
eventPhase: 0
explicitOriginalTarget: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
isTrusted: true
lengthComputable: false
loaded: 0
originalTarget: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
returnValue: true
srcElement: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
target: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
timeStamp: 601
total: 0
type: "error"
<get isTrusted()>: function isTrusted()
<prototype>: ProgressEventPrototype { lengthComputable: Getter, loaded: Getter, total: Getter, … }
ros3d.min.js:1:579846
onError file:///home/.../script/lib/ros3djs/build/ros3d.min.js:1
load file:///home/.../script/lib/ros3djs/build/ros3d.min.js:1
what does this mean? is my path false ? I tried different paths but I couldn't get it to work.
EDIT: I am using this modified ros3djs library (link to my merge request request) but I have tried using with the normal one and the same error pops up.
And one of the model that I m using is in this link all models that I try loading give the same error.
EDIT2/Problem2: as @Solrac3589 recommended installing Apache2 to use as a server. I used for testing the example @Solrac3589 created. After putting the code in /var/www/html
and opening the index.html by typing localhost in my browser (I couldn't open the the html files directly from the file manager) the CORS warning message does not pop up any more but I get the following new object error from ros3djs :
load
bubbles: false
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
eventPhase: 0
explicitOriginalTarget: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
isTrusted: true
lengthComputable: true
loaded: 271
originalTarget: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
returnValue: true
srcElement: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
target: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
timeStamp: 92
total: 271
type: "load"
<get isTrusted()>: function isTrusted()
<prototype>: ProgressEventPrototype { lengthComputable: Getter, loaded: Getter, total: Getter, … }
ros3d.min.js:1:579846
onError http://localhost/js/ros3d.min.js:1
load http://localhost/js/ros3d.min.js:1
Can you attach your mesh and a link to the library you are using so others can try and replicate your results?
It seems to me like there is an error in your ros3djs file. Anyway, if you do what @kscottz says, would be helptful
thank you for your reply. I added a links above.
Hello, sorry for the late response. I saw your comment yesterday but i had a few issues managing the system work.
i just create an example for you working (at least for me) Anything more here I am!
Hope it helps! :)
Hi thank you for your response but I still get the error even in your example. I noticed that there is always this warning before the error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost/testg/meshes/3dmodel.stl. (Reason: CORS request did not succeed).
after some reading on the issue I understood that browsers do not allow automatic reading of local files on a machine. What should I do to get around this warning, which is causing the error (I think)?
I just noticed that you mentioned in your
README.md
something about setting up an apache2 server. After some research that might be the solution to my problem. I will try following tutorials on how to set it up and making it work. I will keep you updated !Yes exactly. What it is used to do to open something in the same computer is to do a local server . If you configure apache2 server in ubuntu, it is just as easy as leave all the code in the folder /var/www/html.
Any doubt just ask!
please check EDIT2 above.