Is three.js ObjectLoader capable of loading textures? - three.js

three.js version 0.0.70, blender version 2.73a
I have a scene exported from blender to three.js json format using new io_three (not io_three_mesh) exporter.
I'm able to import the scene into three.js using ObjectLoader:
var objectLoader = new THREE.ObjectLoader();
objectLoader.load('assets/models/exportedScene.json', function(imported) {
scene.add(imported);
});
Unfortunatelly, no texture is applied to an object, only the material.
As I see from exportedScene.json file, there is an info about texture in file:
"images": [{
"url": "blue.jpg",
"uuid": "DFE5BBBF-601B-48EA-9C05-B9CB9C07D92E",
"type": "Geometry",
"name": "blue.jpg"
}],
"materials": [{
"color": 200962,
"specular": 5066061,
"shininess": 8,
"ambient": 200962,
"depthTest": true,
"depthWrite": true,
"name": "partitionMat",
"emissive": 0,
"uuid": "A705A33F-68C1-489C-A702-89A0140247AB",
"blending": "NormalBlending",
"vertexColors": false,
"map": "73277351-6CCF-4E84-A9F0-D275A101D842",
"type": "MeshPhongMaterial"
}],
"textures": [{
"minFilter": "LinearMipMapLinearFilter",
"wrap": ["RepeatWrapping","RepeatWrapping"],
"magFilter": "LinearFilter",
"mapping": "UVMapping",
"image": "DFE5BBBF-601B-48EA-9C05-B9CB9C07D92E",
"repeat": [1,1],
"name": "carpetTexture",
"anisotropy": 1.0,
"uuid": "73277351-6CCF-4E84-A9F0-D275A101D842",
"type": "Geometry"
}],
But as I said before, no texture is applied.
I tried placing texture file near the html with js script, but it didn't work.
Maybe my initial approach is incorrect and I should import textures similar to http://threejs.org/examples/webgl_loader_obj.html? However, this one is about using ObjLoader (not ObjectLoader), and I'm not sure if it's correct.

Check out the dev branch. There have been recent commits for texture support for the upcoming r71 release.

Latest format support it like following:
"images":[
{
"uuid": "A430CF4-AD77-11E3-914E-00248C62C323",
"url": "../models/1024_tornis.png"
},
{
"uuid": "eka_tv_2_i",
"url": "../models/eka_tv_2.jpg"
},
{
"uuid": "sala_model_0709_map_i",
"url": "../models/sala_model_0709_map.png"
}
],
"textures":[
{
"uuid": "1024_tornis",
"image": "A430CF4-AD77-11E3-914E-00248C62C323"
},
{
"uuid": "eka_tv_2",
"image": "eka_tv_2_i"
},
{
"uuid": "sala_model_0709_map",
"image": "sala_model_0709_map_i"
}
],
"materials": [
{
"uuid": "3C5CA6AA-055B-417B-97E0-706BA446140B",
"type": "MeshLambertMaterial",
"name": "Material.001",
"color": 16777215,
"emissive": 0,
"map": "1024_tornis"
}]

Related

Google Places API: different output for textsearch and nearbysearch (formatted_address missing)

Want to use Google Places API nearby search for reverse lookup using coordinates.
I use nearbysearch endpoint.
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.892674%2C151.200727&rankby=distance&type=bar&key=...
What is missing is formatted_address.
When trying to use textsearch instead, I do get formatted_address.
https://maps.googleapis.com/maps/api/place/textsearch/json?location=-33.892674%2C151.200727&rankby=distance&type=bar&key=...
Both return the same first place_id and look very similar.
Differences I noticed:
textsearch: formatted_address, empty opening_hours are included
nearbysearch: vicinity, scope, empty opening_hours are not included
How do I get formatted_address?
Update: I checked and both types should return the same fields.
details
When searching by distance & type I guess I could use either nearbysearch or textsearch, but when searching by prominence I will have to use nearbysearch as textsearch requires either type or query.
The query I would like to use (using nearbysearch, so missing formatted_address):
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.892674%2C151.200727&rankby=prominence&radius=500&key=...
Full output textsearch
{
"business_status": "OPERATIONAL",
"formatted_address": "7 Cope St, Redfern NSW 2016",
"geometry": {
"location": {
"lat": -33.892682,
"lng": 151.20075
},
"viewport": {
"northeast": {
"lat": -33.89147812010727,
"lng": 151.2019769298927
},
"southwest": {
"lat": -33.89417777989272,
"lng": 151.1992772701072
}
}
},
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png",
"id": "d8b3f319ad00fafd66527b248e450284a53386c2",
"name": "Arcadia",
"opening_hours": {
"open_now": true
},
"photos": [
{
"height": 3000,
"html_attributions": [
"Colin Hannah"
],
"photo_reference": "CmRaAAAAvnYeIFoCoiiQoyRqKQqpz1yJK71eXM3wYuCiTFTTtj3iwTiIW_z865AfLogqMiEyyBh5GqZoxAcHDmzyE8KelhGEh3C-ggm5LQDGK4zFWxdTNCholvXurq0ce7zLoztgEhBgklqzYxK5jhDhwqB5wuabGhQRUb448z5zV9l7EDSmXLMo5icv1w",
"width": 4000
}
],
"place_id": "ChIJ3Y3vQdqxEmsRTvCcbZnsYJ8",
"plus_code": {
"compound_code": "4642+W7 Redfern, New South Wales",
"global_code": "4RRH4642+W7"
},
"price_level": 2,
"rating": 4.5,
"reference": "ChIJ3Y3vQdqxEmsRTvCcbZnsYJ8",
"types": [
"bar",
"point_of_interest",
"establishment"
],
"user_ratings_total": 279
},
Full output nearbysearch:
{
"business_status": "OPERATIONAL",
"geometry": {
"location": {
"lat": -33.892682,
"lng": 151.20075
},
"viewport": {
"northeast": {
"lat": -33.8914789697085,
"lng": 151.2019760802915
},
"southwest": {
"lat": -33.89417693029149,
"lng": 151.1992781197085
}
}
},
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png",
"id": "d8b3f319ad00fafd66527b248e450284a53386c2",
"name": "Arcadia",
"opening_hours": {
"open_now": true
},
"photos": [
{
"height": 3024,
"html_attributions": [
"Milan"
],
"photo_reference": "CmRaAAAA7u4ZpZOddZ8ypuGySsQ1lG0HEX4Ke0DHeYtHYN1gEchx-yf1U-DVLNHVdmFVLoocHbMmWlMVCqcW9oMnpDC4-dw6ObZAovVQG90GpVD3sYeMEpzBB80yjhttjZ1lsIEdEhCzQJane_k8xy-HlI9ZlE9WGhQJ13KgR88Q239e8ocBCt5H0BgpKQ",
"width": 4032
}
],
"place_id": "ChIJ3Y3vQdqxEmsRTvCcbZnsYJ8",
"plus_code": {
"compound_code": "4642+W7 Redfern NSW, Australia",
"global_code": "4RRH4642+W7"
},
"price_level": 2,
"rating": 4.5,
"reference": "ChIJ3Y3vQdqxEmsRTvCcbZnsYJ8",
"scope": "GOOGLE", <===========
"types": [
"bar",
"point_of_interest",
"establishment"
],
"user_ratings_total": 279,
"vicinity": "7 Cope Street, Redfern" <===========
},
Comment from #MrUpsidown points to the documentation where it is stated:
A Text Search response is similar, except that it returns a formatted_address instead of a vicinity property
So, it seems that's just the way it is.
"formatted_address": "7 Cope St, Redfern NSW 2016",
vs
"vicinity": "7 Cope Street, Redfern"

Combine json response in nifi

We are calling invokehttp processes and getting response which json. Example
{
"id": "h569gcjhcm",
"doi": {
"id": "10.17632/h569gcjhcm.1",
"status": "allocated",
"prefix": "10.17632"
},
"name": "Data for: Flooding of the Caspian Sea at the intensification of Northern Hemisphere Glaciations",
"description": "Supplementary data for the Jeirankechmez section in Azerbaijan.\n\n- Appendix A contains all paleomagnetic data and interpretations of the Jeirankechmez section. This .dir file can be imported into the paleomagnetism.org webportal under \"Interpretation Portal\", \"Advanced Options\", \"Import Application Save\". For further details on the use of paleomagnetism.org please refer to the article by Koymans et al. (2016) - https://doi.org/10.1016/j.cageo.2016.05.007.\n- Appendix B contains the magnetic susceptibility data for the analysed samples, including geographic coordinates and stratigraphic levels.\n- Appendix C contains the 40Ar/39Ar data for the three analysed volcanic ash layers. ",
"version": 1,
"publish_date": "2019-01-29T12:51:38.090Z",
"data_licence": {
"id": "01d9c749-3c4d-4431-9df3-620b2dcfe144",
"short_name": "CC BY 4.0",
"full_name": "Creative Commons Attribution 4.0 International",
"description": "This dataset is licensed under a Creative Commons Attribution 4.0 International licence.\n\nWhat does this mean?\nYou can share, copy and modify this dataset so long as you give appropriate credit, provide a link to the CC BY license, and indicate if changes were made, but you may not do so in a way that suggests the rights holder has endorsed you or your use of the dataset. Note that further permission may be required for any content within the dataset that is identified as belonging to a third party.",
"url": "http://creativecommons.org/licenses/by/4.0",
"category": "Creative"
},
"contributors": [
{
"first_name": "Christiaan",
"last_name": "van Baak"
},
{
"first_name": "Marius",
"last_name": "Stoica"
},
{
"first_name": "Arjen",
"last_name": "Grothe"
},
{
"first_name": "Gareth",
"last_name": "Davies"
},
{
"profile_id": "72970719-95c8-341b-80d2-afa9e7154baf",
"first_name": "Wout",
"last_name": "Krijgsman"
},
{
"profile_id": "3a4bfe2c-4098-3859-9b88-789fa993e05a",
"first_name": "Keith",
"last_name": "Richards"
},
{
"profile_id": "f1660f3c-ebbd-3289-8240-1f4ea7913df4",
"first_name": "Klaudia",
"last_name": "Kuiper"
},
{
"first_name": "Elmira",
"last_name": "Aliyeva"
}
],
"versions": [
{
"version": 1,
"publish_date": "2019-01-29T12:51:38.090Z",
"available": true
}
],
"files": [
{
"filename": "Appendix_A_Jeirankechmez_pmag_interpretations.dir",
"id": "f2f4cba7-2411-4737-a9b2-f094db30dca1",
"content_details": {
"id": "994bc865-5300-4d76-a373-e528ccd830e8",
"sha256_hash": "2427c4b077372760973ce8224694f2a2ee5383c7f022ad818164d847a20e27cc",
"sha1_hash": "73792dc6d6eb2c1de1e04926ba5d4420dd0aaece",
"content_type": "application/x-director",
"size": 917022,
"created_date": "2019-01-03T00:00:00.000Z"
"download_expiry_time": "2019-01-29T13:52:25.729Z"
},
"metrics": {
"downloads": 0,
"previews": 0
}
},
{
"filename": "Appendix_B_Sample_locations_susceptibility.xlsx",
"id": "64241bf0-5279-49e8-a505-be9075b910e1",
"content_details": {
"id": "af8809d0-8e63-4599-abaa-e7af9ad39959",
"sha256_hash": "0588f44a0cbd477aa2798323e57ce0b2d4a118e767c0b1ffdc9eb1017e4d23c2",
"sha1_hash": "02e89f6f197ebf495e1e2c3d1aab250efc7545e7",
"content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"size": 24770,
"created_date": "2019-01-03T00:00:00.000Z"
,
"download_expiry_time": "2019-01-29T13:52:25.732Z"
},
"metrics": {
"downloads": 0,
"previews": 0
}
},
{
"filename": "Appendix_C_ArAr_data.xlsx",
"id": "2e912027-ff3f-48ad-98b9-b643b59ba0e3",
"content_details": {
"id": "4960377c-060d-41f6-b7af-150617d8ebeb",
"sha256_hash": "235dc32c1e99f350ee5c99908a5f5d72d1aeeab02f78c2e0181d585bd1880fa6",
"sha1_hash": "6483156e4577948cac5d2679eee862c76faed1c9",
"content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"size": 18510,
"created_date": "2019-01-03T00:00:00.000Z"
},
"metrics": {
"downloads": 0,
"previews": 0
}
}
],
"articles": [
{
"id": "10.1016/j.gloplacha.2019.01.007",
"title": "Flooding of the Caspian Sea at the intensification of Northern Hemisphere Glaciations",
"doi": "10.1016/j.gloplacha.2019.01.007",
"journal": {
"issn": "0921-8181",
"name": "Global and Planetary Change",
"url": "http://www.sciencedirect.com/science/journal/09218181"
}
}
],
"categories": [
{
"id": "http://com/vocabulary/OmniScience/Concept-170590667",
"label": "Geology"
},
{
"id": "http://data.elsevier.com/vocabulary/OmniScience/Concept-473860195",
"label": "Strontium Isotope"
}
],
"institutions": [ ],
"metrics": {
},
"available": true,
"related_links": [ ]
}
I am using $contributors.profile_id from above json to call new endpoint(invokeshttp) (https://api.xxx.com/profile/$.profile_id)
Json response for this
"contributors": [
{
“profile_id”:”cedferfiherhforhforf”
"first_name": “xxx”,
"last_name": "van Baak”,
“other_ids”:[] ,
“Other info”: “deeded” }
I have to call this endpoint depending upon number of object in contributor(let say we have 5 object in contributor ,so I have to call this endpoint 5 time)and combine these 5 response together
Then I have to merge the response(above response to the main response )
just an example:
EvaluateJsonPath to extract "id" into attribute, later join by this attribute
SplitJson to split your json by "contributors"
call endpoint
MergeContent merge by "id" and with count after SplitJson

Custom colors when generating a pie chart from JSON

I'm trying to create a pie chart with a custom set of colours using Am4Charts and the createFromConfig method.
I've followed the tutorial here but the chart keeps appearing with it's default color set.
Here is a sample of the JSON I've tried:
"innerRadius": 100,
"colors": {"list": ["#ff0000", "#00ff00", "#0000ff" ]},
"data": {
"0": {
"pot": "Within 8 days",
"value": "£111,119.70",
},
"1": {
"pot": "9 - 17 days",
"value": "£225,537.73"
},
"2": {
"pot": "18+ days",
"value": "£720,279.85"
}
},
"legend": [],
"xAxes": [
{
"type": "CategoryAxis",
"title": {
"text": "pot"
},
"dataFields": {
"category": "pot",
"title": {
"text": "Month"
}
},
"renderer": {
"labels": {
"rotation": 190,
"verticalCenter": "middle",
"horizontalCenter": "left"
}
}
}
],
"series": [
{
"type": "PieSeries",
"dataFields": {
"value": "value",
"category": "pot"
},
"ticks": {
"disabled": true
},
"labels": {
"disabled": true
},
}
],
Can somebody see where I've gone wrong?
Update 2:
Fixed in 4.0.0-beta.85.
Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.
Update 1:
Response from amchart contributor/CTO Martynas Majeris (https://github.com/martynasma):
Looks like there are two issues: documentation is wrong and there's a bug that prevents it from working :)
I updated the docs. It should say this:
{
// ...
"series": [{
// ...
"colors": {
"list": [
"#845EC2",
"#D65DB1",
"#FF6F91",
"#FF9671",
"#FFC75F",
"#F9F871"
]
}
}]
}
Also, fixed bug in dev version. New version will be released within 1-2 days.
Original
This might be a bug and I have opened an issue on amchart github. I will update this once I get a response: https://github.com/amcharts/amcharts4/issues/577
By the way, I do think your configuration JSON has couple issues:
data is an array, not an object
legend is an object, not an array
This is what I used to create the pie chart demo for the opened issue:
// Create chart instance in one go
let chart = am4core.createFromConfig({
"colors": {
"list": ["#ff0000","#00ff00", "#0000ff"]
},
// Create pie series
"series": [{
"colors": ["#ff0000","#00ff00", "#0000ff"],
"type": "PieSeries",
"dataFields": {
"value": "value",
"category": "pot"
}
}],
// Add data
"data": [{
"pot": "Within 8 days",
"value": "£111,119.70"
}, {
"pot": "9 - 17 days",
"value": "£225,537.73"
}, {
"pot": "18+ days",
"value": "£720,279.85"
}],
// Add legend
"legend": {},
"innerRadius": 100
}, "chart", am4charts.PieChart);

Vega-lite bar chart space between bars

D3 newbie.
How I adjust the spacing between bars in vega-lite bar chart and override the default? binSpacing I think only works on histograms. See code below.
I'll want to adjust colour of text and font family too... But am having trouble finding it in the docs.
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"width": 1200,
"height": 900,
"data": {
"url": "data/seattle-weather.csv"
},
"mark": "bar",
"encoding": {
"x": {
"aggregate": "count",
"type": "quantitative"
},
"size": {
"value": 40
},
"y": {
"field": "date",
"type": "temporal",
"timeUnit": "month",
"axis": {
"title": "Regions"
}
},
"color": {
"field": "weather",
"type": "nominal",
"scale": {
"domain": [
"0-20 days",
"21-27 days",
">28 days"
],
"range": [
"red",
"orange",
"green"
]
},
"legend": {
"title": "Case Ageing"
}
}
}
}
I can understand your confusion. It seems there are three questions:
How do I change bin width for histograms? This is documented here. If you have trouble with a reproducible example, I will be happy to help.
How do I adjust the spacing of the bars? This is controlled by padding, paddingInner and paddingOuter all documented at the encoding level and at the config level. You might be having trouble since you are setting size manually with "size": {"value": 40}, but I am guessing this is a remnant from experimenting. Here is a working spec from this gist. You can play with paddingOuter, paddingInner, or add padding to apply to both inner and outer.
How do I change font styling? See this gist.

amcharts not rendering India map correctly in worldmap

While amcharts shows the India map correctly (showing the disputed regions as part of India) when displaying only India (http://jsfiddle.net/zxhseguw/5/)
"dataProvider": {
"map": "indiaLow",
"areas": [ {
"id": "IN-KA",
"value": 4447100,
}, {
"id": "IN-UP",
"value": 38763
}]
},
it shades it differently when rendering it on world map (http://jsfiddle.net/zxhseguw/6/)
"dataProvider": {
"map": "worldLow",
"areas": [ {
"id": "IN",
"value": 4447100,
}, {
"id": "AU",
"value": 387633
}]
},
I wonder, if there is a way to make it render India correctly, just like its possible in Google Charts by setting origin='India'
I'm assuming you're referring to the region around Kashmir, correct? Try using worldIndiaLow instead of worldLow, which includes more of that disputed area as part of India.
"dataProvider": {
"map": "worldIndiaLow",
"areas": [ {
"id": "IN",
"value": 4447100,
}, {
"id": "AU",
"value": 387633
}]
},
Updated fiddle

Resources