Style CZML paths thinner and with shade to ground - cesiumjs

I want to display a GPS tracklog in my Cesium application. But I can't get a nice styling for the path working. What I want it to look like:
What it currently looks like:
This is how I style the path currently:
path : {
width : 2,
leadTime : 0,
resolution : 5,
material : {
polylineOutline : {
color : {
rgba : [255, 0, 0, 255]
}
},
},
},
What I want to have:
Thin colored lines without black blurry "outlines" (see second image and compare with first).
A faded area that marks the elevation above ground for the first section of the path.
SOLUTION:
For 1.) I now found a pretty similar solution thanks to emackey:
path : {
show : true,
leadTime : 0,
trailTime : 60,
width : 2.5,
resolution : 1,
material : new Cesium.PolylineGlowMaterialProperty({
glowPower : 15,
taperPower : 0.0001,
color : Cesium.Color.fromBytes(349, 66, 68, 255)
})
}
For 2.) I still haven't found what I'm looking for.

There isn't a built-in effect exactly like that first screenshot you posted from Ayvri (formerly Doarama), but, the most similar built-in thing could be the "tapered line" effect added earlier this year to Cesium:
Here's a demo. Click in the Cesium window and use the arrow keys to steer the aircraft.
These are the path settings from the demo:
path : {
show : true,
leadTime : 0,
trailTime : 60,
width : 10,
resolution : 1,
material : new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.3,
taperPower : 0.3,
color : Cesium.Color.PALEGOLDENROD
})
}

Related

Cesium model loading from GLB/GLTF not loading material

I've generated a generated a GLB file using khronos's SharpGLTF libraries and have got the model loading in cesium, the model appears correctly. The problem is the material for the model does not show. I have tested the generated GLB in other viewers and the material does show.
I'm using the following code in cesium:
var entity = viewer.entities.add({
name : 'url_here',
position : center,
orientation : orientation,
model : {
uri : 'url_here',
minimumPixelSize : 128,
maximumScale : 20000,
}
});
also tried
var model = scene.primitives.add(Cesium.Model.fromGltf({
id: 'here',
url: 'url here'
modelMatrix : modelMatrix,
scale : 1.0,
}));
I've tried using the color modifiers for cesium and the only option that responds is "color" which doesn't help as it doesn't apply any lighting to the color.
Below is a picture of what cesium is outputting. However there should be more effects to the material than just red. It seems to respect only KnownChannel.BaseColor and that's it.
Any ideas?

Cesim translucid material image

I think I mean "translucent"...
I'm trying to put a rectangle with an image material and control the translucency of the image so I can see the background behind it (like we do with ordinary layers).
This is my code:
var redRectangle = viewer.entities.add({
name : 'Red translucent rectangle',
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-110.0, 20.0, -80.0, 25.0),
material : new Cesium.ImageMaterialProperty({
image : '../images/Cesium_Logo_Color.jpg',
transparent: true,
translucent : true,
alpha: 0.2
}),
}
});
I can't get it to work. I already tried every option inside material but with no results.
try it in Sandcastle. My goal is to see a translucid logo.
Solved.
Need to give a color to the image ( what?? ) and apply an alpha to it.
var redRectangle = viewer.entities.add({
name : 'Red translucent rectangle',
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-110.0, 20.0, -80.0, 25.0),
material : new Cesium.ImageMaterialProperty({
image : '../images/Cesium_Logo_Color.jpg',
color: Cesium.Color.WHITE.withAlpha(0.1) <<<< ----- THIS MAKE IT TRANSLUCENT
}),
}
});

Is it possible to adjust the pin image size of annotation ti.map

I add the anntation like this
var annot= Map.createAnnotation({
latitude: XXXXXXXXXXX,
longitude: XXXXXXXXXX,
title: 'myPlace',
image: 'myPin.png',
width:'100dp',// doesn't work
height:'100dp'// doesn't work
});
this.mapView.addAnnotation(annot);
}
I would like to change the size of image though,
there seems no way to change.
So I need to edit the file size itself by image editor or something.
Moreover images are show differently in Android or iPhone.
So I need to make two size for each pins.
MapModule.createAnnotation({
latitude : XXXX,
longitude : XXXX,
customView : Ti.UI.createView({
width : widthImg,
height : heightImg * 2,
children : [Ti.UI.createView({
top : 0,
width : width,
height : height,
backgroundImage : "myPin.png"
})]
})
});

Libgdx Missing LabelStyle font for ImageTextButton

I've been creating Button(s) just using the Button class, but figured I'd try the ImageTextButton. However, even with just the Button class, I'm not quite following the docs on how a .pack (atlas) file with a .json file should be working together.
Using the Button class, I can 'name' my button whatever I like in code, and have it named in the json accordingly (see examples below), but for 'Image's, I have to 'name' everything the same, from the construction in code, through the pack and json files. Example of what works:
code:
// note the 'Constants' just point to the json and atlas files, respectively.
skinShops = new Skin(Gdx.files.internal(Constants.SKIN_SHOPS), new
TextureAtlas(Constants.TEXTURE_ATLAS_SHOPS));
// for this next line, note the json definition for Button$ButtonStyle:
Button buttonBuy = new Button(skinShops, "Button-Buy");
// for Images, it seems I cannot have a 'unique' name first, then the drawable name, which I thought refers to the json
Image imgItemsBackground = new Image(skinShops, "shop-items-background");
If you look at the 'scene2d.ui.Image:' definitions, everything is named the same. While its working this way, I'm not clear why.
This could be 2 questions I guess, the previous concern about nomenclature of naming between all these elements, but my current issue I cannot get past is trying to construct an ImageTextButton. In code, I'm building them dynamically depending on where the player is: different shops have different items to sell, and those are read into the items[] array.
ImageTextButton buttonPurchase = new ImageTextButton(items[j], skinShops, "shop_item-button-background");
Stack trace:
Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: Missing LabelStyle font.
at com.badlogic.gdx.scenes.scene2d.ui.Label.setStyle(Label.java:78)
at com.badlogic.gdx.scenes.scene2d.ui.Label.<init>(Label.java:72)
at com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton.<init>(ImageTextButton.java:57)
at com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton.<init>(ImageTextButton.java:44)
at com.uv.screen.InteriorScreen.buildItemButtons(InteriorScreen.java:134)
Where should I be creating / setting the font for these buttons?
json file:
{
com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: {
Button-Exit: { down: Button_Exit_112x60, up: Button_Exit_112x60 },
Button-Buy: { down: Button_Buy_112x60, up: Button_Buy_112x60 },
Button-Sell: { down: Button_Sell_112x60, up: Button_Sell_112x60 }
},
com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton$ImageTextButtonStyle: {
shop_item-button-background: { down: shop_item-button-background, up: shop_item-button-background }
},
com..badlogic.gdx.scenes.scene2d.ui.Image: {
background: { drawable: background },
shop-items-background: { drawable: shop-items-background },
shop-menu-background: { drawable: shop-menu-background },
shop-talk-text-background: { drawable: shop-talk-text-background },
weapon-shop-portrait_world1: { drawable: weapon-shop-portrait_world1 },
armor-shop-portrait_world1: { drawable: armor-shop-portrait_world1 },
item-shop-portrait_world1: { drawable: item-shop-portrait_world1 },
inn-shop-portrait_world1: { drawable: inn-shop-portrait_world1 }
}
atlas file:
shops-pack.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
background
rotate: false
xy: 0, 504
size: 800, 480
orig: 800, 480
offset: 0, 0
index: -1
shop-items-background
rotate: false
xy: 0, 248
size: 608, 256
orig: 608, 256
offset: 0, 0
index: -1
shop_item-button-background
rotate: false
xy: 0, 60
size: 256, 60
orig: 256, 60
offset: 0, 0
index: -1
...
There's no reason your Images in your json have to have the same names as the drawables in them. You don't even need to put Images in your skin. Look at the documentation of ImageTextButtonStyle...its parameters are Drawables, not Images. And so that's why it seems like you need to use the exact texture region names.
Skin automatically creates a TextureRegionDrawable or NinePatchDrawable out of a texture region with that name if you haven't created one in the Skin. But you can create all kinds of Drawables (such as TiledDrawable or TintedDrawable, or a TextureRegionDrawable with custom padding) and specify those as your button's image if you want to.
Also note in the documentation that ImageTextButtonStyle inherits a member named font from TextButtonStyle, which is not marked as optional in the documentation. So you're getting an exception for using an ImageTextButtonStyle that did not specify a font.
There are a couple ways you can put a font into your skin. If you have generated a bitmap font with a tool such as BMFont or Heiro, you can pack it into your texture atlas. Simply put the .fnt file and its image into the same directory with your other images that you are packing. And put another copy of the .fnt file into your assets directory, next to your atlas file. Then specify the font in your skin json by using its file name:
com.badlogic.gdx.graphics.g2d.BitmapFont: { myfont: { file: myfont.fnt } },
If you are using FreeTypeFontGenerator, this is more complicated. Let me know if that's what you're doing.

Is it possible to access google Chrome's theme?

This must have been asked somewhere, but can't find where :(
I was reading up on finding out which browser someone was using in html.
My site uses a 'theme' (DevExpress' Black glass) and was wondering if there was a way of accessing Chrome's current theme, when the user is logged in.
I understand this has the potential to be a huge undertaking, but if it was possible, is there a way of getting the 'css' of chromes theme (obviously this would only apply if user was using chrome)?
I am currently writing a project in mvc, but any html/css approaches would be beneficial here.
For Example:
Is it possible to obtain access to the css of the 'Grass' theme (please note, this is just one example, there are many other themes available)?
As far as I know it's not possible, because it doesn't work like CSS. You have to get the JSON file, because I don't think it's possible from CRX.
Here is how a JSON file for a GC theme looks like:
{
"version": "1.0",
"name": "test theme",
"description": "A test theme",
"theme": {
"images" : {
"theme_frame" : "images/theme_frame_camo.png",
"theme_toolbar" : "images/theme_toolbar_camo.png",
"theme_ntp_background" : "images/theme_ntp_background_norepeat.png",
"theme_ntp_attribution" : "images/attribution.png"
},
"colors" : {
"frame" : [71, 105, 91],
"toolbar" : [207, 221, 192],
"ntp_text" : [20, 40, 0],
"ntp_link" : [36, 70, 0],
"ntp_section" : [207, 221, 192],
"button_background" : [255, 255, 255]
},
"tints" : {
"buttons" : [0.33, 0.5, 0.47]
},
"properties" : {
"ntp_background_alignment" : "bottom"
}
}
}
More info:
https://code.google.com/p/chromium/wiki/ThemeCreationGuide
BTW: Why would you want this, when there are 3-4 colors, no styles? You can get the colors with color picker.