How to change the material of io3d-furniture? - aframe

Furniture can have multiple materials, for example:
<a-entity id="shelf" io3d-furniture="id:10344b13-d981-47a0-90ac-f048ee2780a6"></a-entity>
Now this shelf has a bunch of materials:
> console.log(document.getElementById('shelf').components['io3d-furniture'].availableMaterials.Wood)
< [ Oak stained aqua blue,
Oak stained pink pastell,
Black Walnut Tree,
Oak stained chalk,
Oak stained dark warmgrey,
Oak stained mint blue,
Oak stained graphite grey,
Oak stained salmon pink,
Oak stained graphite black,
Oak stained light warmgrey,
Oak stained cold grey,
European Oak
How can I change the material?

The materials can be changed either via HTML or via JavaScript.
HTML:
<a-entity id="shelf" io3d-furniture="id:10344b13-d981-47a0-90ac-f048ee2780a6;material_Wood:Black Walnut Tree"></a-entity>
JavaScript:
var component = document.getElementById('shelf').components['io3d-furniture']
component.data.material_Wood = 'Black Walnut Tree'
component.update()
Note that the material names are case-sensitive.

Related

How to build equal ranges of a green or brown tone in a color palette from dark to bright with RGB for images with R?

Does anyone know how I can search in many images for green tones and cluster them for a later characterisation of the images? The idea is to include all shades of green from the green palette and only leave out as few as possible, none would be great actually. I have thought of taking a photo with a lot of green tones, clustering it using R and then creating areas between the values of the cluster centres. However, since forming areas of RGB images is a three-dimensional space, I find it difficult to form areas that contain all the color tones in total, but only one color tone should occur in an area, so there are no overlaps. It is also difficult to find an image with all green shades for the clustering.
Does anyone have a tip for me?

column layout in R Presentation

I'd like to have two columns on a slide in R Presentation, with the column-split after a full-width paragraph, but I can only get this:
I want the "Ice Cream" section to take up the full width of the slide, and the "Ben's Ice Cream Palace" and "Jerry's Ice Cream Castle" sections to appear next to each other below that. Changing the level of the section headings doesn't seem to have any effect. Is there a way to do this?
Troubleshooting
========================================================
## Ice Cream
My town has two ice-cream parlours, Ben's Ice Cream Palace and Jerry's Ice Cream Castle. It would be nice to show the two establishments' flavours side-by-side so that we could compare them easily when deciding where to go buy ice cream on a hot sunny day.
### Ben's Ice Cream Palace
- Chocolate
- Vanilla
- Neopolitan
- Rum Raisin
- Butter Pecan
- Mint Chocolate Chip
***
### Jerry's Ice Cream Castle
- Chocolate
- Vanilla
- Strawberry
- Chunky Monkey
- Chocolate Chip Cookie Dough

Finding permutations and combinations possible to build a customizable bag

Working on producing a customizable bag and need to combine individual components to make full bag.
The bag following 4 components:
Body
Handle
Metal
Zip
Each bag has set of leathers or colored metal or colored cloth which can be used.
Example:
"Body" has the following leathers as applicable options...
Leather01, Leather02, Leather03, Leather04, Leather05
"Handle" has the following leathers as applicable options...
Leather01, Leather02, Leather03, Leather04, Leather05
"Metal" has the following colored metals as options...
Gold and Silver
"Zip" has the following colored cloth options...
Beige and Black
Considering the above, how do I get the permutations and combinations of making the bag.
Use cases:
A bag can built with the following:
body: Leather01
Handle: Leather01
Metal: Gold
Zip: Beige
Also, I am looking for half built bags as well, like...
body: Leather01
Or
body: Leather01
Zip: Beige
Looking for a way to calculate the possible combinations.

XQuery expression. Something about ordering

I have to order and then print out parts of a text. I've tried some expressions and finally became the code that help me, but I think it isn't really good.
I will post a part of the text and then the code that I've made.
<?xml version="1.0"?>
<recipes>
<recipe>
<title>Beef Parmesan with Garlic Angel Hair Pasta</title>
<ingredient name="beef cube steak" amount="1.5" unit="pound"/>
<ingredient name="onion, sliced into thin rings" amount="1"/>
<ingredient name="green bell pepper, sliced in rings" amount="1"/>
<ingredient name="Italian seasoned bread crumbs" amount="1" unit="cup"/>
<ingredient name="grated Parmesan cheese" amount="0.5" unit="cup"/>
<ingredient name="olive oil" amount="2" unit="tablespoon"/>
<ingredient name="spaghetti sauce" amount="1" unit="jar"/>
<ingredient name="shredded mozzarella cheese" amount="0.5" unit="cup"/>
<ingredient name="angel hair pasta" amount="12" unit="ounce"/>
<ingredient name="minced garlic" amount="2" unit="teaspoon"/>
<ingredient name="butter" amount="0.25" unit="cup"/>
<preparation>
<step>
Preheat oven to 350 degrees F (175 degrees C).
</step>
<step>
Cut cube steak into serving size pieces. Coat meat with the bread crumbs
and parmesan cheese. Heat olive oil in a large frying pan, and saute 1
teaspoon of the garlic for 3 minutes. Quick fry (brown quickly on both sides)
meat. Place meat in a casserole baking dish, slightly overlapping edges.
Place onion rings and peppers on top of meat, and pour marinara sauce
over all.
</step>
<step>
Bake at 350 degrees F (175 degrees C) for 30 to 45 minutes, depending on
the thickness of the meat. Sprinkle mozzarella over meat and leave in the
oven till bubbly.
</step>
<step>
Boil pasta al dente. Drain, and toss in butter and 1 teaspoon garlic. For a
stronger garlic taste, season with garlic powder. Top with grated parmesan
and parsley for color. Serve meat and sauce atop a mound of pasta!
</step>
</preparation>
<comment>
Make the meat ahead of time, and refrigerate over night, the acid in the
tomato sauce will tenderize the meat even more. If you do this, save the
mozzarella till the last minute.
</comment>
<nutrition calories="1167" fat="23" carbohydrates="45" protein="32"/>
</recipe>
<recipe>
<title>Ricotta Pie</title>
<ingredient name="filling">
<ingredient name="ricotta cheese" amount="3" unit="pound"/>
<ingredient name="eggs" amount="12"/>
<ingredient name="white sugar" amount="2" unit="cup"/>
<ingredient name="vanilla extract" amount="2" unit="teaspoon"/>
<ingredient name="semisweet chocolate chips" amount="0.25" unit="cup"/>
<preparation>
<step>
Beat the 12 eggs, 2 cups sugar and vanilla extract together. Stir in
the ricotta cheese and the chocolate chips. Set aside.
</step>
</preparation>
</ingredient>
<ingredient name="dough">
<ingredient name="flour" amount="4" unit="cup"/>
<ingredient name="baking powder" amount="5" unit="teaspoon"/>
<ingredient name="white sugar" amount="1" unit="cup"/>
<ingredient name="shortening" amount="0.5" unit="cup"/>
<ingredient name="eggs, lightly beaten" amount="4"/>
<ingredient name="vanilla extract" amount="1" unit="teaspoon"/>
<preparation>
<step>
Combine the flour, baking powder, and 1 cup of the sugar together. Cut in the
shortening and mix until the mixture resembles coarse crumbs. Mix in 4 of
the eggs and 1 teaspoon of the vanilla. Divide dough into 4 balls and chill (if
needed).
</step>
</preparation>
</ingredient>
<ingredient name="milk" amount="*"/>
<preparation>
<step>
Preheat oven to 325 degrees F (165 degrees C). Grease two deep dish pie
plates.
</step>
<step>
Roll out 2 of the balls to fit into the pie pans. Do not make the crust too thick
as it will expand during cooking and get too thick. Do not flute the edges of
the dough. Roll out the other 2 balls of dough and cut each into 8 narrow
strips for the top of the crust. Alternately you can use cookie cutters and
place the cutouts on the top of the pies.
</step>
<step>
Pour the filling evenly into the pie crusts. Top each pie with 8 narrow strips
of dough or cookie cut-outs. Brush top of pie with milk for shine. Place foil on
the edge of crust.
</step>
<step>
Bake at 325 degrees F (165 degrees C) for 20 to 30 minutes then remove
foil. Continue to bake for another 25 or 30 minutes or until a knife inserted in
the center comes out clean.
</step>
</preparation>
<nutrition calories="349" fat="18" carbohydrates="64" protein="18"/>
</recipe>
> </recipes>
The code I've made is following
<result>
{
for $x in doc()/recipes/recipe
order by $x/nutrition[#calories>600]
return
($x/title) |($x/nutrition[#calories])
}
</result>
The main idea of XQuery expression is to show the title and the calories ordered by calories in <result> tag.
Your first attempt doesn't look that bad, apart from that the result XML doesn't look very useful. You might want to rewrap each title and nutrition in a recipe element. Secondly, your order clause is likely to not do much. You write:
order by $x/nutrition[#calories>600]
But that way you order by the text contents of the nutrition element, which it doesn't have any. You probably meant:
order by $x/nutrition[#calories>600]/#calories
Or perhaps even better, you want to order numerically on calories:
order by $x/nutrition[#calories>600]/#calories/fn:number(.)
HTH!
It is not quite clear to me what you are trying to achieve exactly. So what does the calories > 600 condition stand for (it does not seem to be of much use in the order by clause, as it will just apply to the ordering condition). I would guess, that you want to filter out all nutrition values with less than 600 calories (your current statement would order everything with more than 600 calories, but the others would still appear in the result).
Also, you did miss to put the #calories attribute as the ordering attribute, which I guess is what you want to achieve.
<result>
{
for $x in doc()/recipes/recipe
return ($x/title,
for $n in $x/nutrition[#calories>600]
order by $n/#calories
return $n
)
}
</result>

R's XML to Dataframe

I have the next XML Example and I want to get "listing" data in a R dataframe. What's the best way to do it, ex: How would you configure xmlToDataFrame function to do the job starting with an URL?
<response>
<area_name/>
<bounding_box>
<latitude_max>51.667389</latitude_max>
<latitude_min>51.385262</latitude_min>
<longitude_max>0.137236</longitude_max>
<longitude_min>-0.34844</longitude_min>
</bounding_box>
<country>England</country>
<county>London</county>
<latitude>51.5263255</latitude>
<listing>
<agent_address>218a Brick Lane</agent_address>
<agent_logo/>
<agent_name>Salik & Co</agent_name>
<agent_phone>020 3318 7059</agent_phone>
<country/>
<county>London</county>
<description>
Description:
Salik & Co is offering this Commercial Freehold Property for sale on Wise Road, Stratford, London E15... Premises consists of:
12 X 2 Bedroom Flat AS Following-
* 2x Pent House With One Bath
* 2x Flat With 2 Double Bed With 2 Bath
* 8x Flat With 1 Bath
* 4x Car Park
* 4x floor with ground floor parking
* Lift
* Flat 11 & 13 Pent House with 500 sqft Terrace.
* Flat 12 & Ground Floor shop sold for Long lease. Area Profile:
Stratford is a place in the London Borough of Newham in East London. It will be the primary location of the 2012 Summer Olympics. The area is identified in the London Plan as one of 35 major centres in Greater London. Stratford has been a focus of regeneration for some years, and is the location of a number of major projects.... Property Location:
Set only moments from the vibrant amenities of Stratford, Olympic park, Westfield Shopping centre. This modern 2 bed stunning flat offers contemporary accommodation with a private balcony, in a fabulous new eco building close to the green open spaces of East London
Situated on Stratford High Street the property enjoys swift access into the fashionable bars, restaurants and boutiques of Stratford High Street. Transport links include Stratford (Central line, Jubilee Line and British Rail) which provide further link to district line. Price:
Asking price £2.8 million. For further information contact:
Ryan -
Salik -
Office -
Email -
Web -
</description>
<details_url>http://www.zoopla.co.uk/for-sale/details/4507257</details_url>
<displayable_address>Wise Road, London</displayable_address>
<image_caption/>
<image_url>
http://images.zoopla.co.uk/52367ed1b61a63c1b93f1ec0a70d39f83d590c74_354_255.jpg
</image_url>
<latitude>51.53477</latitude>
<listing_id>4507257</listing_id>
<listing_status>sale</listing_status>
<longitude>-0.0045035</longitude>
<num_bathrooms>0</num_bathrooms>
<num_bedrooms>0</num_bedrooms>
<num_floors>0</num_floors>
<num_recepts>0</num_recepts>
<outcode>E15</outcode>
<post_town>London</post_town>
<price>2800000</price>
<price_change>
<date>2010-04-27 00:42:05</date>
<price>3000000</price>
</price_change>
<price_change>
<date>2010-07-04 03:21:14</date>
<price>2800000</price>
</price_change>
<property_type/>
<street_name>Commercial Property</street_name>
<thumbnail_url>
http://images.zoopla.co.uk/52367ed1b61a63c1b93f1ec0a70d39f83d590c74_80_60.jpg
</thumbnail_url>
</listing>
<listing>
<agent_address>Rawlings House 2a Milner Street</agent_address>
<agent_logo>
http://static.zoopla.co.uk/zoopla_static_agent_logo_(29807).gif
</agent_logo>
<agent_name>Marsh & Parsons</agent_name>
<agent_phone>020 3318 6922</agent_phone>
<country/>
<county>London</county>
<description>
A stunning, three bed mews house with spacious, roof terrace in a popular gated development off Milner Street and ideally located for the nearby amenities of South Kensington and Knightsbridge. A large reception room and a contemporary, open plan kitchen occupy the ground floor, while the first floor houses two double bedrooms and a modern family bathroom. An additional shower room can be found on the second floor which also has a substantial area suitable for a third bedroom and access to the sunny roof terrace. Located in the heart SW3's Brompton area, there is a multitude of local amenities available at Chelsea's popular King's Road and Sloane Street, while the shops, bars and restaurants of Brompton Road and Knightsbridge are easily reached. St. Catherine's Mews is ideally located for the Underground stations at both Sloane Square (Circle and District Lines) and South Kensington (Piccadilly, Circle and District Lines) while such a central location provides a number of convenient bus services. For transport links into and out of London the motorways can be accessed via the nearby A4.The property also has planning permission to extend the 2nd floor to encompass some of the roof terrace that would create greater internal square footage.
</description>
<details_url>http://www.zoopla.co.uk/for-sale/details/491528</details_url>
<displayable_address>St Catherines Mews, London SW3</displayable_address>
<floor_plan>
http://content.zoopla.co.uk/5cb125b77de67eb6717bd8a2c74ba7edb6839959.jpg
</floor_plan>
<image_caption>Picture No.46</image_caption>
<image_url>
http://images.zoopla.co.uk/0867139d8bc2e2aac63056d75bbce1677de438c6_354_255.jpg
</image_url>
<latitude>51.493774</latitude>
<listing_id>491528</listing_id>
<listing_status>sale</listing_status>
<longitude>-0.164762</longitude>
<num_bathrooms>0</num_bathrooms>
<num_bedrooms>2</num_bedrooms>
<num_floors>0</num_floors>
<num_recepts>0</num_recepts>
<outcode>SW3</outcode>
<post_town>London</post_town>
<price>1500000</price>
<price_change>
<date>2009-05-16 01:40:29</date>
<price>1350000</price>
</price_change>
<price_change>
<date>2010-02-20 00:30:24</date>
<price>1450000</price>
</price_change>
<price_change>
<date>2011-02-12 00:31:53</date>
<price>1500000</price>
</price_change>
<property_type>Town house</property_type>
<street_name>London</street_name>
<thumbnail_url>
http://images.zoopla.co.uk/0867139d8bc2e2aac63056d75bbce1677de438c6_80_60.jpg
</thumbnail_url>
</listing>
<listing>
<agent_address>175 Putney High Street, Putney</agent_address>
<agent_logo>
http://static.zoopla.co.uk/zoopla_static_agent_logo_(47723).jpeg
</agent_logo>
<agent_name>Foxtons - Putney</agent_name>
<agent_phone>020 3318 9160</agent_phone>
<country/>
<county>London</county>
<description>
A stunning four bedroomed house offering exceptionally spacious accommodation with stylish interior throughout. The property is arranged over four floors and comprises two good-sized reception rooms, generous 29' kitchen/dining room, four bedrooms (two with en suite), two bathrooms, two shower rooms, utility room, guest cloakroom, attractive garden and off-street parking. Akehurst Street is a quiet residential road located close to the green expanses of Richmond Park, and close to amenities in Roehampton with a greater selection of shops, bars and restaurants within easy reach in Putney. The area is well served by a number of local bus routes, while the nearby A3 provides motorists with a fast route into central London and to the South-West.
</description>
<details_url>http://www.zoopla.co.uk/for-sale/details/14226965</details_url>
<displayable_address>Akehurst Street, London</displayable_address>
<image_caption/>
<image_url>
http://images.zoopla.co.uk/5a24b05bff28865405aee72bcf4c46ae2ce299a4_354_255.jpg
</image_url>
<latitude>51.450905</latitude>
<listing_id>14226965</listing_id>
<listing_status>sale</listing_status>
<longitude>-0.242762</longitude>
<num_bathrooms>0</num_bathrooms>
<num_bedrooms>4</num_bedrooms>
<num_floors>0</num_floors>
<num_recepts>0</num_recepts>
<outcode>SW15</outcode>
<post_town>London</post_town>
<price>1499950</price>
<property_type>Town house</property_type>
<street_name>Akehurst Street</street_name>
<thumbnail_url>
http://images.zoopla.co.uk/5a24b05bff28865405aee72bcf4c46ae2ce299a4_80_60.jpg
</thumbnail_url>
</listing>
<listing>
<agent_address>55 Fulham Broadway, Fulham</agent_address>
<agent_logo>
http://static.zoopla.co.uk/zoopla_static_agent_logo_(47732).jpeg
</agent_logo>
<agent_name>Foxtons - Fulham</agent_name>
<agent_phone>020 3318 6868</agent_phone>
<country/>
<county>London</county>
<description>
Located on a quiet residential street in Fulham, this great four bedroomed house offers spacious accommodation with loft conversion and south-facing flat roof. Arranged over three floors, the property comprises reception room with bay window, dining room, kitchen with space to dine and access to the garden, top floor master bedroom with en suite shower room, large second bedroom, two additional bedrooms, bathroom and outside store room. The property is situated on a tree-lined street, ideally located just moments from the local amenities on both Dawes Road and Lillie Road and is within easy reach of a more a comprehensive range of bars, shops and restaurants on nearby Fulham Broadway. The closest underground station is Fulham Broadway (District Line), providing convenient access to various central and greater London destinations.
</description>
<details_url>http://www.zoopla.co.uk/for-sale/details/14351415</details_url>
<displayable_address>Prothero Road, London</displayable_address>
<image_caption/>
<image_url>
http://images.zoopla.co.uk/a9d983b76018a07537de832224bb5174099c2758_354_255.jpg
</image_url>
<latitude>51.48186</latitude>
<listing_id>14351415</listing_id>
<listing_status>sale</listing_status>
<longitude>-0.208447</longitude>
<num_bathrooms>0</num_bathrooms>
<num_bedrooms>4</num_bedrooms>
<num_floors>0</num_floors>
<num_recepts>0</num_recepts>
<outcode>SW6</outcode>
<post_town>London</post_town>
<price>750000</price>
<property_type>Town house</property_type>
<street_name>Prothero Road</street_name>
<thumbnail_url>
http://images.zoopla.co.uk/a9d983b76018a07537de832224bb5174099c2758_80_60.jpg
</thumbnail_url>
</listing>
<longitude>-0.105602</longitude>
<postcode/>
<result_count>76494</result_count>
<street/>
<town/>
</response>
Thank You
Dataframes require that the input data be "rectangular". You clearly do not have such a data arrangement. R's list data type is more appropriate to something like this. The other problem appears to be the presence of ampersands, "&", in this file. Given that "&" is an escape character in html, the safer maneuver here would have been to replace "& " with "&amp ". If you change all of the "&"'s to "and" you can get xmlToList() to read it and create a corresponding list ( but that might damage other files if they had valid HTML buried in them).
The listing data can be extracted by matching 'listing' to the names of the list :
xmlToList(f)[grep("listing", names(xmlToList(f)))]
(You will need to provide an URL.)

Resources