Create a set field of arrows in X3D(OM) - x3d

I know that you can create one arrow by appending a cone to the end of a cynlinder. Something like this:
<Shape>
<Cylinder DEF='ArrowCylinder' radius='.025' top='false'/>
<Appearance DEF='Green'>
<Material diffuseColor='.1 .6 .1' emissiveColor='.05 .2 .05'/>
</Appearance>
</Shape>
<Transform translation='0 1 0'>
<Shape>
<Cone DEF='ArrowCone' bottomRadius='.05' height='.1'/>
<Appearance USE='Green'/>
</Shape>
</Transform>
What if instead I want to show something like a glyph/vector field with X3DOM? Clearly creating an entire set of arrows where each arrow is defined like this won't be an elegant solution...

One method might be you style/build your own arrow by using IndexedFaceSet node, then group it with an id, alternatively you can also group a set of arrows, under one id of course: Here is an (2-D) example:
<x3d width="400px" height="400px">
<scene>
<group id="arrow">
<shape>
<appearance>
<material diffuseColor="0.25 0.75 0.755"></material>
</appearance>
<IndexedFaceSet solid="false" coordIndex="0 1 2 3 0 -1">
<coordinate point="0 0 0 1 0 0 1 1 0 0 1 0">
</coordinate>
</IndexedFaceSet>
</shape>
<shape>
<appearance>
<material diffuseColor="0.25 0.75 0.755"></material>
</appearance>
<IndexedFaceSet solid="false" coordIndex="0 1 2 3 0 -1">
<coordinate point="1 -0.5 0 2 0.5 0 2 0.5 0 1 1.5 0">
</coordinate>
</IndexedFaceSet>
</shape>
</group>
</scene>
</x3d>
One big benefit would be that you reduce the amount of points/draws a lot, thus you gain performance, if you use massive amount of arrows.

Related

unable to use svg in react

I am using a svg image by importing that from a folder but its showing empty then I tried ti give path directly but it does not solve the problem.
image.svg
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 480 360">
<defs><linearGradient id="a" x1="19.5%" x2="77.5%" y1="71.8%" y2="16.7%">
<stop offset="0%" stop-color="#00AB55"/><stop offset="100%" stop-color="#00AB55" stop-opacity="0"/>
</linearGradient></defs>
<path fill="url(#a)" d="M0 198.8c0 41.4 15 79.2 39.5 107.8A151.3 151.3 0 0 0 154.3 360a148.4 148.4 0 0
0 56.5-11c9-3.7 19.1-3.3 28 1a75.8 75.8 0 0 0 33.9 8 75.9 75.9 0 0 0 50.8-19.3 34.4 34.4 0 0 1 22.9-8.4h.1a129
129 0 0 0 74.5-23.7c19-13.4 34.5-31.7 44.9-53.3 9-18.7 14.1-40 14.1-62.3
0-77-59.8-139.3-133.5-139.3-7.5 0-14.9.6-22 1.9a107 107 0 0 0-92-53.6 103.7 103.7 0 0 0-45.9 10.7c-13.2 6.4-25
15.7-34.6 26.9-32.7.5-63 11.7-87.7 30.3C25.3 97.2 0 144.9 0 198.8z" opacity=".2"/><image height="300" x="322"
y="30" href="/assets/illustrations/characters/character_2.png"/><path fill="url(#b)" d="M216.3 138v108.3a4 4 0
0 1-4 4H195a4 4 0 0 1-4-4V138a4 4 0 0 1 4-4h17.3a4 4 0 0 1 4 4zm-55-68H144a4 4 0 0 0-4 4v176.3a4 4 0 0 0
4 4h17.3a4 4 0 0 0 4-4V74a4 4 0 0 0-4-4zm102 93H246a4 4 0 0 0-4 4v75.7a4 4 0 0 0 4 4h17.3a4 4 0 0 0 4-4V167a4
4 0 0 0-4-4z"/><path fill="#005249" d="M359.2 253.4a207 207 0 0 1-3.7 9.7l-15.2.4c-3.3.1-6.9.2-9.6 2.1-5.2 3.6-.7
6.1-1.3 9.6-.7 4.2-4.9 5.1-9 5.1-14.1.1-27.7 4.6-41.5 7.3s-28.9 3.5-41.2-3.4c-.8-.5-1.7-1-2-2-.6-1.6.9-3.2 2.3-4.2
3.2-2.2 6.7-3.7 10.5-4.5 2.2-.5 4.5-.8 6.5-2 1.9-1.2 3.3-3.7 2.3-5.8-32.1 2-64.1 4.8-96 8.4-41.1 4.8-81.8 12.9-123
15.9h-.4c-2.9-2.9-5.5-6-7.9-9.3l.6-.7c2-2.2 5-3.2 7.8-4.1 15.9-4.9 32.4-7.4 48.8-9.9 81.6-12.3 164.2-21.1 246.8-15.3a359
359 0 0 1 25.2 2.7z" opacity=".2"/><path fill="#DFE3E8" d="m81.7 204.2 74 11v60.7h8.5v3.6h-19.5v-2.3h8.7v-50.3l-70-13.
5v49h9.7v1.7H73.6V262h8.2v-57.8h-.1z"/><path fill="#C4CDD5" d="m80.6 204.2 74 11v60.7h8.5v3.6h-19.5v-2.3h8.7v-50.3l-70-13.
5v49H92v1.7H72.4V262h8.2v-57.8z"/><defs>
<linearGradient id="b" x1="140" x2="276.5" y1="98" y2="312.5" gradientUnits="userSpaceOnUse"><stop stop-color="#C8FACD"/>
<stop offset="1" stop-color="#007B55"/></linearGradient></defs></svg>
first I imported that image when it doesnot work I gave direct path in src,
// import { girlFlyIcon } from '../../utils/appSvg';
<Grid item>
<img src='../../svg/image.svg'
style={{
opacity: '0.8',
zIndex: '999'
}} alt='' />
</Grid>
How to resolve this....Thanks in advance...
use require in src prop of img like this
<img
src={require('../../svg/image.svg')}
... />
Instead of using image, try to use svg as component
import {ReactComponent as ImageSVG} from '../../svg/image.svg'
...
<ImageSVG/>

How to remove the yellow background in an svg img in react

Why there is that yellow background. It's occupying extra space in a container it's not sticking to extreme right can anyone explain how to remove that yellow background. It's an svg img there is no padding is given.
svg code
<svg width="312" height="570" viewBox="0 0 312 647" fill="none" xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_d)">
<path d="M111.684 14H312.453V605H306.088H134.021C70.667 543.769 28 428.795 28 297.056C28 181.475 60.8424 78.799 111.684 14Z" fill="#FCD400"/>
</g>
<defs>
<filter id="filter0_d" x="0.383177" y="0.191588" width="339.687" height="646.234" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
<feOffset dy="13.8084"/>
<feGaussianBlur stdDeviation="13.8084"/>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
</filter>

IndexedFaceSet creates extra faces in x3d file

I have created an x3d file using x3dom. Following is the structure of the file. Copy the following code into text editor and save it as .x3d file. For imgage texture you can consider any jpg file and place it at the same location as x3d.
<?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 profile='Interchange' version='3.0'
xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
<Scene>
<NavigationInfo type='"EXAMINE" "WALK" "FLY" "ANY"'/>
<DirectionalLight intensity="0.8" direction="0 1 0"/>
<DirectionalLight intensity="0.9" direction="0 -1 0"/>
<DirectionalLight intensity="0.6" direction="1 0 -1"/>
<DirectionalLight intensity="0.6" direction="-1 0 -1"/>
<DirectionalLight intensity="0.6" direction="-1 0 1"/>
<DirectionalLight intensity="0.6" direction="1 0 1"/>
<Shape>
<Appearance>
<Material ambientIntensity="0.2" diffuseColor="0.004 0.004 0.004" emissiveColor="0 0 0" shininess="0.2" specularColor="0 0 0" transparency="0"/>
<ImageTexture url="Penguins.jpg"/>
</Appearance>
<IndexedFaceSet convex="true" coordIndex="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 -1 " ccw="true">
<Coordinate point="132.2349 0 329.9732 123.0347 0 336.9273 109.9391 0 350.0229 102.985 0 359.223 82.26761 0 386.6317 69.30841 0 436.438 74.03987 0 470.4683 78.77134 0 504.4987 104.8261 0 548.8805 132.2349 0 569.598 191.8598 0 569.598 191.8598 0 689.9727 911.8589 0 689.9727 1032.234 0 569.598 1032.234 0 270.3483 852.2339 0 270.3483 852.2339 0 210.7232 371.8596 0 210.7232 371.8596 0 329.9732"/>
</IndexedFaceSet>
</Shape>
<Viewpoint description="Center of Space" fieldOfView="0.785" position="553.1368 60 450.348"/>
</Scene>
</X3D>
Looking it from the top view the 3D object looks like this,
enter image description here
And from the bottom view it looks like this,
enter image description here
I have checked all the points and they are in proper sequence but not sure why these two extra faces are created. Anything I am doing wrong here?
You draw a non-convex shape, therefor you need to set convex to false, in addition if you want to see your shape from "behind" you need to set solid to false.
This works:
<IndexedFaceSet convex="false" solid="false" coordIndex="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 -1">
(you dont need ccw, its true by default)

Draw a 3d rectangular box(rectangular prism ?) in wpf

I am using the following code to form a cube. It uses triangles for each face. How can I make a rectangular box by modifying its values. I dont have much idea on the indices property used here.
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions = "-1,-1,1 1,-1,1 1,1,1 -1,1,1"
TriangleIndices = "0 1 2 2,3,0"
TextureCoordinates="0,1 1,1 1,0 0,0"
/>
</GeometryModel3D.Geometry>
here you go
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions = "0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1"
TriangleIndices = "2 3 1 2 1 0 7 1 3 7 5 1 6 5 7 6 4 5 6 2 0 2 0 4 2 7 3 2 6 7 0 1 5 0 5 4"/>
</GeometryModel3D.Geometry>
this will produce a cube geometry
I would suggest you to understand how it work so you can make other objects too
here is a nice tutorial on WPF 3D
http://www.codeproject.com/Articles/24727/WPF-D-Part-of-n

X3D - How to color polygon faces in X3D

How do I color a polygon face - as in just color 1 face all red for example. I don't want linear interpolation occuring when I move on to color a neighboring face. I am able to color it with the following codes but the colors merge. When I turn colorPerVertex to false, the coloring looks weird. Please advice. Thank you.
<X3D>
<Scene>
<Shape>
<IndexedFaceSet solid="false" colorPerVertex="true"
coordIndex="0 3 4 1 -1
1 4 5 2 -1
3 6 7 4 -1
4 7 8 5 -1">
<Coordinate
point= "0 0 0, 1 0 0, 2 0 0
0 0 1, 1 3 1, 2 0 1
0 0 2, 1 0 2, 2 0 2" />
<Color color= "0 0 0, 1 0 0, 2 0 0
0 0 1, 1 3 1, 2 0 1
0 0 2, 1 0 2, 2 0 2" />
</IndexedFaceSet>
<Appearance>
<Material diffuseColor='1 0 0' />
</Appearance>
</Shape>
</Scene>
</X3D>
If colorPerVertex is FALSE AND the colorIndex field is not empty, then one colour is applied for each face of the IndexedFaceSet.
Therefore if you set colorPerVertex to FALSE in your example you should NOT have color interpolation between faces (tested).

Resources