-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Semantics of url field #1199
Comments
Confirmed, x3dom only looks at the first url and ignores subsequent ones. Is there are specific use case ? Due to cors, loading from non-origin servers is rare. For ImageTexture loading x3dom uses the html Image element. It sets the src property to load the image. https://developer.mozilla.org/en-US/docs/Web/API/Element/error_event maybe an option. https://github.com/x3dom/x3dom/blob/master/src/util/Utils.js#L177 already uses onerror to try .dds texture loading. Seems complicated to implement. Line 490 in 83ce363
Line 306 in 32c69a1
Line 327 in 32c69a1
|
Looking at this more, the small patch for createTexture2D here may work for most situations. Trying the next url on error after dds rejection should be about right. Only for ImageTexture and it does not do correct automatic blending for greyscale but should work for dds loading. Needs checking for potential Background url confusion. [Inline url needs different loading.] |
Could you please give this a try and report back ? It should work to just redefine the x3dom.Utils.createTexture2D function as above, after loading x3dom.js. |
Any luck ? |
Sorry,
Been offline...
Will try asap
…On Sun, Apr 3, 2022, 8:58 PM Andreas Plesch ***@***.***> wrote:
Any luck ?
—
Reply to this email directly, view it on GitHub
<#1199 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYQT72JSX7G4AY7IQU4AMH3VDI5CBANCNFSM5R7ASQZQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Thanks ~ I overloaded the function definition with what you supplied: I think this error is because I am looking at a path like file:///:/C: first Console: I have removed these addresses from my content with grep and now things are on relative paths. |
also error with this patch in my case: Uncaught RangeError: Invalid typed array length: 5 |
file:// urls typically will not work. |
Yes uncaught range error also happens in firefox, edge and chrome. the scene is awkardly large but the imagetextures are like: |
with which url do you get the range error ? are you using a http server for local files ? |
Line 59 in 53bb572
is probably where the range error occurs. I think that means that the xmlhttprequest was successful: Line 8 in 53bb572
while the earlier Image.onload had failed. Not sure when this occurs but perhaps Image src loading is stricter about local cors. Is that a really small texture png ? In any case, it would make sense to extend the check at Line 40 in 53bb572
to 148 bytes: if ( source === undefined || source.byteLength < 148 ) Could you try this by overloading the function Line 38 in 53bb572
with one which has the extended check ? |
Here is the fixed function to test x3dom.DDSLoader._read = function ( source )
{
if ( source === undefined || source.byteLength < ( 128 + 5 * 4 ) )
{
return;
}
var dds =
{
isCompressed : false,
isVolume : false,
isCubeMap : false,
targets : [],
data : []
};
var int32Buffer = new Uint32Array( source, 0, 32 );
//Parse DDS Header
dds.header = x3dom.DDSLoader._readHeader( int32Buffer );
int32Buffer = new Uint32Array( source, 128, 5 );
//Parse DDS Header
dds.header10 = x3dom.DDSLoader._readHeader10( dds, int32Buffer );
//Check if the magic number is present
if ( dds.header.dwMagic != 0x20534444 )
{
return;
}
//Check if the header size is correct
if ( dds.header.dwSize != 0x7C )
{
return;
}
//Parse resource format
if ( !x3dom.DDSLoader._readFormat( dds ) )
{
return;
}
x3dom.DDSLoader._readMipmapCount( dds );
x3dom.DDSLoader._readType( dds );
this._readData( dds, source );
return dds;
}; Just add after loading x3dom.js . |
Any errors with local urls ? Relative urls with a running server should work. |
I tried with a local html and local urls but chrome will not allow it (unless security checks are disabled with a command line switch). |
https://jsitor.com/4tCAhIRslT is updated to be more robust against mixed local and remote urls. Should also now sniff number of color components for proper alpha blending in any url. Any testing would be much appreciated. |
Using a similar strategy, it may be possible to support multiple urls for inline as well: https://github.com/andreasplesch/x3dom/blob/MFurl/src/nodes/Networking/Inline.js https://www.web3d.org/x3d/content/examples/ConformanceNist/SpecialGroups/Inline/index.html |
Please reopen as desirable. |
In X3D, it is expected that if one url is not found, try the next in the list.
X3DOM fails this if the first url is not found;
in ImageTexture for example.
The text was updated successfully, but these errors were encountered: