X3Dom set ImageTexture in Text - x3d

I have this code and it doesn't work. How can I fix it?
And how can I change the size of text?
<x3d width='800px' height='400px'>
<scene>
<shape>
<Appearance>
<ImageTexture url='1.jpg'/>
</Appearance>
<Text string='3'>
<FontStyle style='BOLD' />
</Text>
</shape>
</scene>

You cannot set a font size on a ImageTexture. Anyways, here's an example of creating a textured cube (Box) and putting a Text shape in front of it.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D>
<Scene>
<Group>
<Transform>
<Shape>
<Appearance>
<ImageTexture url='1.jpg'/>
</Appearance>
<Box/>
</Shape>
<Transform translation="0 0 1">
<Shape>
<Appearance>
<Material/>
</Appearance>
<Text string='"This is a text"'>
<FontStyle family='"SANS"' justify='"MIDDLE"' size="1.5" style="BOLD"/>
</Text>
</Shape>
</Transform>
</Transform>
</Group>
</Scene>
</X3D>

Related

X3D: PROTO converted from VRML not working

I have a VRML code I want to convert to X3D. The code should define spheres with different radius and colors to later instantiate by giving the coordinates as an argument.
First, I used an online converter suggested in another question, then opened it in blender to check it but it only displays one sphere instead of the 4 it's supposed to. I compared it with other similar examples found by googling and I don't see any difference or clue as to why it does this. I've tried changing some fields so it looks more like the examples: field accessType to initializeOnly, the information inside <X3D ...> to profile="Interchange" version="3.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.2.xsd". I also tried placing <Shape> inside <children> like in VRML but in all cases it displays just one sphere.
This is a simplified version of the VRML code I want to convert to x3d:
#VRML 2.0 utf8
PROTO Copper [ exposedField SFVec3f xyz 0 0 0 ] {
Transform {
translation IS xyz
children [
Shape {
appearance Appearance {
material Material { diffuseColor 0.78 0.5 0.2 }
}
geometry Sphere { radius 1.32 }
}
]
}
}
Copper { xyz 0.0 0.0 0.0 } # 0
Copper { xyz 0.0 1.8 1.8 } # 1
Copper { xyz 1.8 0.0 1.8 } # 2
Copper { xyz 1.8 1.8 0.0 } # 3
This is what I get from the converter:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' profile='Full' version='3.0' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
<Scene DEF='scene'>
<ProtoDeclare name='Copper'>
<ProtoInterface>
<field accessType='inputOutput' name='xyz' type='SFVec3f' value='0 0 0'/>
</ProtoInterface>
<ProtoBody>
<Transform>
<Shape>
<Appearance>
<Material diffuseColor='0.78 0.5 0.2'/>
</Appearance>
<Sphere radius='1.32'/>
</Shape>
<IS>
<connect nodeField='translation' protoField='xyz'/>
</IS>
</Transform>
</ProtoBody>
</ProtoDeclare>
<Copper xyz='0.0 0.0 0.0'/>
<Copper xyz='0.0 1.8 1.8'/>
<Copper xyz='1.8 0.0 1.8'/>
<Copper xyz='1.8 1.8 0.0'/>
</Scene>
</X3D>
Unfortunately, it looks like a bug in the Blender X3D importer, because the following shows four spheres (as expected) in the BS Contact viewer, yet only one sphere in Blender:
<?xml version="1.0" encoding="UTF-8"?>
<X3D profile="Immersive" version="3.0">
<Scene>
<ProtoDeclare name="Copper">
<ProtoInterface>
<field accessType="inputOutput" name="xyz" type="SFVec3f"/>
</ProtoInterface>
<ProtoBody>
<Transform translation='0 0 0'>
<Shape>
<Appearance>
<Material diffuseColor='0.78 0.5 0.2'/>
</Appearance>
<Sphere radius='1.32' />
</Shape>
<IS>
<connect nodeField="translation" protoField="xyz"/>
</IS>
</Transform>
</ProtoBody>
</ProtoDeclare>
<Copper />
<Copper xyz='0 1.8 1.8' />
<Copper xyz='1.8 0 1.8' />
<Copper xyz='1.8 1.8 0' />
</Scene>
</X3D>

Display static text/picture on X3D/X3DOM

What is a correct way to display a static text or picture in X3D/X3DOM? Using HTML elements really easy screw up the format of the entire website...
You can use ImageTexture
Example:
<x3d width='500px' height='400px'>
<scene>
<shape>
<appearance>
<ImageTexture url="myTexture.png"><ImageTexture/>
</appearance>
<box> </box>
</shape>
</scene>
</x3d>
And for static text you can use the Text node.

Not able to show image on dialog box in AEM

I am trying to create a dialog with image preview on it. I am able to create dialog with all the fields but i am facing issue with image. I have seen the image component where you can drag drop image but i need the image to be shown when i open dialog component. Is there any component for this without drag drop.
I have tried with html5smartimage image but not working. Please see code below:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
height="{Long}500"
title="Test Dialog"
width="{Long}800"
xtype="dialog">
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Panel"
title="Component Details">
<items jcr:primaryType="cq:WidgetCollection">
<image
jcr:primaryType="cq:Widget"
cropParameter="./imageCrop"
ddGroups="[media]"
fileNameParameter="./fileName"
fileReferenceParameter="./fileReference"
mapParameter="./imageMap"
name="./file"
requestSuffix=".img.png"
rotateParameter="./imageRotate"
title="Image"
xtype="html5smartimage">
<icon.png jcr:primaryType="nt:file">
<jcr:content
jcr:data="{Binary}"
jcr:lastModified="{Date}2015-07-28T19:27:46.878+05:30"
jcr:lastModifiedBy="admin"
jcr:mimeType="image/png"
jcr:primaryType="nt:resource"
jcr:uuid="754c14c8-4423-45df-b982-06bfc13dc6e3"/>
</icon.png>
</image>
</items>
</tab1>
</items>
</items>
</jcr:root>
Please help me out on this.
I don't think there is a need to use the html5smartimage if all that you want to do is, display a static image in the dialog (which needn't get submitted too).
You can make use of the xtype displayfield and use the html property as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
height="{Long}500"
title="Test Dialog"
width="{Long}800"
xtype="dialog">
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Panel"
title="Component Details">
<items jcr:primaryType="cq:WidgetCollection">
<displayimage jcr:primaryType="cq:Widget"
html="<img src='/content/dam/geometrixx/icons/target.png'>"
xtype="displayfield" />
</items>
</tab1>
</items>
</items>
</jcr:root>
Replace the image src with the path to your image which you want to display in the dialog.

AEM 6: xtype tabpanel unable to change the dimension

Is it even possible to change the dimension of a tabpanel. I tried height and width but it's not working. Any pointers.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
height="{Long}600"
title="Tiles"
width="{Long}850"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
</items>
</jcr:root>
Thanks
Change the xtype on cq:Dialog to "dialog", and move the tabpanel 2 levels down, i.e.:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
height="650"
title="Tiles"
width="850"
xtype="dialog">
<items jcr:primaryType="cq:WidgetCollection">
<tabpanel
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
...
</items>
</tabpanel>
</items>
</jcr:root>
I have implemented the following structure and it works perfectly:
- cq:Dialog
- cq:WidgetCollection
- cq:TabPanel
- cq:WidgetCollection
- cq:Widget
- cq:Widget
...
as real life example:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Dialog"
title="Filter Component"
height="{Long}500"
width="{Long}550"
xtype="dialog">
<items jcr:primaryType="cq:WidgetCollection">
<tabs jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1 jcr:primaryType="cq:Widget"
... more attributes
/>
<tab2 jcr:primaryType="cq:Widget"
... more attributes
/>
</items>
</tabs>
</items>
</jcr:root>
NOTE: Both width and height attributes must be configured explicitly in the cq:Dialog node

Editing XML files

I have some XML files and I need to edit them automatically.
For example
<Content>
<Texts>
<Text id="1">
<en value="blaabla" />
</Text>
<Text id="2">
<en value="blablablablal" />
</Text>
</Texts>
</Content>
I need to copy "en value" lines and add these lines to their under line but with one change.
So when processing done, result should be that:
<Content>
<Texts>
<Text id="1">
<en value="blablabla" />
<fr value="blablabla" />
</Text>
<Text id="2">
<en value="blablablablal" />
<fr value="blablablablal" />
</Text>
</Texts>
</Content>
You could use this XSLT to transform your XML files:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="en[#value]">
<xsl:copy>
<xsl:apply-templates select="#*|node()" />
</xsl:copy>
<fr value="{#value}"/>
</xsl:template>
</xsl:stylesheet>
$ sed '/<en /p' data.txt | awk '/<en /{if(x++%2)sub(/<en /, "<fr ")}1'
<Content>
<Texts>
<Text id="1">
<en value="blaabla" />
<fr value="blaabla" />
</Text>
<Text id="2">
<en value="blablablablal" />
<fr value="blablablablal" />
using sed to duplicate line which contains <en
using awk to change the odd <en to <fr
WARNING: <en ... /> must be one line.

Resources