Cesium terrain not loading from CDN - cesiumjs

I created a custom terrain using Cesium Terrain Builder docker and am trying to serve it from a standard CDN or cloud bucket. I've uploaded all the terrain folders to the CDN and they are correctly accessible, e.g.
https://mycdn.com/terrains/terrain1/layer.json
https://mycdn.com/terrains/terrain1/0/0/0.terrain
https://mycdn.com/terrains/terrain1/0/1/0.terrain
and so on - I can access all the files from a browser.
But, when trying to access them from my Cesium app, I don't see the terrain (i.e. transparent environment). Checking the network tab in Chrome, I can see layer.json and the root terrain files have been accessed successfully. There are no errors in the console log. It just doesn't show up.
Any idea why?
p.s. same data loads fine from a Cesium Terrain Server container...

Found the cause. The tiles are gzipped. The CDN need to be configured so that every tile file is served with Content-Encoding: gzip header.
Once that's done, terrain loads and I can see all tiles get loaded in chrome (not just the root tiles)

Related

Suddnly, loading files through source map is blocked

We have app working since almost 2 years. Suddenly I see it stopped loading. Console has below error:
Not allowed to load local resouce
Looks like brsower security is not allowing to load file SourceMap.
I looked at chrome, source map not loading but I can't follow that. As I can't ask my users to change browser settings or not to use chrome
Any possible solution?

Cesium-terrain-builder-docker error when i load cesium.js in browser

I want to serve custom terrain data at my server, so I tried Cesium Terrain Builder Docker (cesium-terrain-builder-docker).
(maybe) Completely generate quantized-mesh-terrain using cesium-terrain-builder docker, but error occurs when loading cesium.js in browser
Generated quantized-mesh terrain using cesium-terrain-builder:
This is my HTML code:
and this is error message at Chrome browser console:
Change
url: 'http://localhost:8080/tilesets/daegu/tiles'
to url: 'http://localhost:8080/tilesets/tiles' in the terrainProvider.
Can you please provide some more information on how you serve the tileset?
Are you using a normal web server or a dedicated service for publishing tilesets like
CesiumTerrainServer?
In general I see two possible sources for this error:
Terrain tiles serving path is wrong:
In that case, try opening your layer.json file in the browser, e.g. open https://localhost:8080/tilesets/daegu/tiles/layer.json. If that fails, you can be pretty sure there is something wrong with the path. Check your path and the documentation of the tileset provider service to fix that. For CesiumTerrainServer this is described here.
Tiles are served with wrong content encoding:
This usually only applies if you serve your tiles directly from a web server like Nginx or Apache. Cesium terrain tiles are gzipped and have to be served using gzip Content-Encoding. Try adding this header to the web server location you serve the tiles from, e.g. using Nginx:
location ~* \.terrain$ {
add_header Content-Encoding gzip;
}
The full example is available here.
Here is an example on how to use Docker to run CesiumTerrainServer with some documentation, that might be helpful as well.

Cross-origin error in canvas html5 kineticJS using path file://

I want to create image from my canvas, I'm using kineticjs, but I get error: "Kinetic warning: Unable to get data URL. Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported." I suppose, that it's caused by cross-origin error. In canvas I use localy saved images and address path starts with "file://..". Is there any solution how to create image without apache installing? Thanks.
Your local hard drive is deemed to be "other domain" by browsers and will taint Canvas.
That's a good thing! You don't want malicious code to get at stuff on your personal drive.
Some workarounds:
Install a web server on your computer.
Put your image(s) and all files associated with your web app on the desktop (this may/may not help depending on where you got the images to begin with).
Temporarily host your images on a site that allows anonymous cross-origin access to your images.

Load an image in flash/actionscript from a different origin domain

I'm a complete noob when it comes to flash coding.
I have a flash swf file that I'm loading from an S3 assets bucket. Inside the flash swf it should be displaying a "Browse" button, images also courtesy of the same bucket. This works fine when I host the images and swf file from the same domain that the site is on, but not when loaded from S3.
I have added a crossdomain.xml file to the assets bucket as follows (I'm trying with '*' to start just to get it working, and will narrow it down to my actual host when it appears to be doing anything):
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
I also have a cross-origin resource sharing configuration in the bucket so that the fonts will correctly load for our stylesheets (This is working).
What am I doing wrong to make the button images load in the actionscript? Do I need to modify the actionscript code itself? The code is located here (public library anyone can use, not authored by me): s3-swf-upload-plugin
You can see here that it is instantiating a new browseButton defined here. Like I said I'm not totally familiar with actionscript but believe I could fumble through it if someone could show me what's going wrong :) What's a good way to get actual error reporting? Firebug in Firefox and Chrome's console don't have any kind of messages from Flash about errors going on.
EDIT:
There were some quirkinesses going on in the setting up of the flash object and setting the paths for the button images. I updated BrowseButton.as to do this:
Security.loadPolicyFile("http://s3.amazonaws.com/my-bucket/crossdomain.xml");
I placed this before any of the URLRequest calls in the BrowseButton() function. However it's still not displaying the images :( I also hardcoded the values in the URLRequest to be things like:
upLoader.load(new URLRequest("http://s3.amazonaws.com/my-bucket/assets/s3_up_button.gif"));
but nothing seems to happen. When I set it to /assets/s3_up_button.gif to pull from the local file then it works fine. What am I doing wrong! How can I get error messages displaying from the flash video? :\ I compiled with <debug>true</debug> but I'm not sure how to get actual exception messages.
Check what sandbox your swf is in:
The Security.sandboxType property
An author of a SWF file can use the read-only static
Security.sandboxType property to determine the type of sandbox to
which Flash Player has assigned the SWF file. The Security class
includes constants that represent possible values of the
Security.sandboxType property, as follows:
Security.REMOTE--The SWF file is from an Internet URL, and operates under domain-based sandbox rules.
Security.LOCAL_WITH_FILE--The SWF file is a local file, but it has not been trusted by the user and was not published with a networking designation. The SWF file can read from local data sources but cannot communicate with the Internet.
Security.LOCAL_WITH_NETWORK--The SWF file is a local file and has not been trusted by the user, but it was published with a networking designation. The SWF can communicate with the Internet but cannot read from local data sources.
Security.LOCAL_TRUSTED--The SWF file is a local file and has been trusted by the user, using either the Settings Manager or a Flash Player trust configuration file. The SWF file can both read from local data sources and communicate with the Internet.
You probably want Security.LOCAL_WITH_NETWORK, although Security.LOCAL_TRUSTED will also work.
An explanation, along with details of how to set the sandbox in Flex, is here: http://livedocs.adobe.com/flex/3/html/help.html?content=05B_Security_04.html
If you're working in the Flash IDE, it should just be part of the publish settings.

When I zip up my demo FlashDevelop project..why does it break?

I built an AS3 image gallery using FlashDevelop.
Before I zip up the application, I can run the image gallery in my browser by simply opening the index.html for the project. Everything works perfectly.
I then zip up the project as proj-0.1.2.zip using winrar.
I then unzip this newly created zip and try to load the application using the project index.html like above. The gallery doesn't function properly. From seeing what happens, it appears as though the image metadata is not present(but I'm not sure, see below).
There are other applications as well that are broken. Videos don't load. If an application doesn't depend on any external assets then everything looks fine.
Another thing..If I then build the FlashDevelop project and republish the swf..then it works in the index.html like I want. What is going on here?
I want people to be able to fire up my demo apps out of the box by just running the index.html. If that doesn't always work and they have to figure out that they need to rebuild the SWF then that's pretty bad.
I don't think zipping is the problem, I think moving to a different folder is a problem.
I assume you are running this index.html on your local PC, and not on a webserver?
By default, Flash cannot access from a local SWF to load other local files. However, FlashDevelop / Flash CS3 / Flex Builder, in order to get around this restriction, set some flags in the flash player telling him "This SWF is a trusted SWF, allow him to open local files". But it's based on the exact location of the SWF.
There's a setting somewhere in the compiler, that sets a flag in the SWF saying "This SWF can access local data", but there's one downside: It blocks all access to network resources. So it's either/or: access local data, OR access network resources (anything that goes over HTTP, Socket, etc). I'm not sure where this setting is offhand. It may be that the default setting for Flash CS3 is different than the default setting for FlashDevelop.
Anyway, the easy way to avoid all this issue is to not run the file locally. Put it on your webserver before testing.