{"action":"created","issue":{"url":"https://api.github.com/repos/x3dom/x3dom/issues/538","labels_url":"https://api.github.com/repos/x3dom/x3dom/issues/538/labels{/name}","comments_url":"https://api.github.com/repos/x3dom/x3dom/issues/538/comments","events_url":"https://api.github.com/repos/x3dom/x3dom/issues/538/events","html_url":"https://github.com/x3dom/x3dom/pull/538","id":102060945,"number":538,"title":"Added support for S3TC textures in ImageTextureAtlas.","user":{"login":"girier-tsha","id":8132137,"avatar_url":"https://avatars.githubusercontent.com/u/8132137?v=3","gravatar_id":"","url":"https://api.github.com/users/girier-tsha","html_url":"https://github.com/girier-tsha","followers_url":"https://api.github.com/users/girier-tsha/followers","following_url":"https://api.github.com/users/girier-tsha/following{/other_user}","gists_url":"https://api.github.com/users/girier-tsha/gists{/gist_id}","starred_url":"https://api.github.com/users/girier-tsha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/girier-tsha/subscriptions","organizations_url":"https://api.github.com/users/girier-tsha/orgs","repos_url":"https://api.github.com/users/girier-tsha/repos","events_url":"https://api.github.com/users/girier-tsha/events{/privacy}","received_events_url":"https://api.github.com/users/girier-tsha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-08-20T04:46:03Z","updated_at":"2015-08-25T07:26:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/x3dom/x3dom/pulls/538","html_url":"https://github.com/x3dom/x3dom/pull/538","diff_url":"https://github.com/x3dom/x3dom/pull/538.diff","patch_url":"https://github.com/x3dom/x3dom/pull/538.patch"},"body":"\r\nImageTextureAtlas node has been extended to handle compressed (S3TC) textures by simply setting the \"compressed\" boolean field to true.\r\n\r\nIn case the necessary extension (WEBGL_compressed_texture_s3tc) is not supported by the browser, the \"fallbackUrl\" field can be set to the URL of an equivalent uncompressed image (See src/Texture.js, line 267 and following).\r\n\r\nThe actual logic for reading an s3tc fileis contained in src/util/Utils.js (x3dom.Utils.createCompressedTexture2D).\r\nThe src/Cache.js file is only adding caching feature to this behavior (x3dom.Cache.prototype.getCompressedTexture2D).\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/x3dom/x3dom/issues/comments/134509592","html_url":"https://github.com/x3dom/x3dom/pull/538#issuecomment-134509592","issue_url":"https://api.github.com/repos/x3dom/x3dom/issues/538","id":134509592,"user":{"login":"girier-tsha","id":8132137,"avatar_url":"https://avatars.githubusercontent.com/u/8132137?v=3","gravatar_id":"","url":"https://api.github.com/users/girier-tsha","html_url":"https://github.com/girier-tsha","followers_url":"https://api.github.com/users/girier-tsha/followers","following_url":"https://api.github.com/users/girier-tsha/following{/other_user}","gists_url":"https://api.github.com/users/girier-tsha/gists{/gist_id}","starred_url":"https://api.github.com/users/girier-tsha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/girier-tsha/subscriptions","organizations_url":"https://api.github.com/users/girier-tsha/orgs","repos_url":"https://api.github.com/users/girier-tsha/repos","events_url":"https://api.github.com/users/girier-tsha/events{/privacy}","received_events_url":"https://api.github.com/users/girier-tsha/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T07:26:41Z","updated_at":"2015-08-25T07:26:41Z","body":"Thanks for your comments and suggestions.\r\n\r\nI was very reluctant to add the `compressed` and `fallbackUrl` fields and totally agree that it would be better to do without them.\r\n\r\nI considered using the URL list as is specified in the X3D specification instead of `fallbackUrl`, but as said in issue #435, this behavior is not implemented in X3DOM. Solving #435 would effectively remove the need for the `fallbackUrl` field.\r\n\r\nAs for the `compressed` boolean field, I added it because I saw no other way to make sure the image is a compressed texture without downloading it twice. It is my understanding that the solution proposed above by @andreasplesch will download the image twice, once through setting the `src` field of an `Image` instance, and then by getting the binary data directly through an `XMLHttpRequest`. To my knowledge, there is no way to download the binary once, check its content and only then decide wether to generate a `Image` instance if it is a JPEG/GIF or to handle it as compressed texture. But maybe I am wrong about this. Please tell me if such a method exists. Anyway, as long as this inefficiency is not an issue to you, i see no problem in implementing it this way. \r\n\r\nI also considered checking the URL extension to decide if the image is a JPEG or a X3TC file, but it seems far too unreliable to me.\r\n\r\nFinally, I think the two issues can be solved separately.\r\n\r\nAs for #435, wouldn't a simple for loop at the end of the `updateTexture` function of __src/Texture.js__ (around `this.texture = this.cache.getTexture2D(`...)  solve the problem ?\r\n\r\nAs for the removal of the `compressed` field, I will first try and implement the proposal form @andreasplesch. Something along:\r\n\r\n```\r\ntry download as JPEG\r\n  if error\r\n    if error is 404 (or similar) || X3TC not supported -> try next URL\r\n    else \r\n      try download as X3TC\r\n      if error -> try next URL\r\n```\r\n\r\nDoes this approach seems practical to you ? "}}