Home › Forums › Programming › SVG “use” method in JavaScript problems
- This topic has 16 replies, 3 voices, and was last updated 4 years, 3 months ago by GLiFTeK.
-
AuthorPosts
-
2020-08-19 at 8:15 am #31721GLiFTeKCustomer
Hi all,
This all is very non-verge 3d, but dovetails into it as I’m trying to get SVG’s drawn to canvas into my 3d materials using SVG’s <use> method.NOTE: drawing simple SVG’s to canvas using the ways in the User Manual is working FINE. The problem is referencing them in the JS.
What I mean by the <use> method is shown here – https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use
My main SVG file begins with a number of shapes with their own id’s… Circles mainly.
Then after that, groups… (with their own id’s) using <use> to make different combos of those shapes mentioned above, those groups being often used composited complex designs used in the following…
Then the largest part of the file I have whole sections of the groups in different arrangements (and cataloged with serial numbers, in a separate spreadsheet/CSV) as symbols.
That’s all in <defs>.
THAT main SVG file doesn’t have anything after defs.
I use puzzles to concatenate it all with replacing the final </svg> with a <use href> to reference any of the svg symbols I want.
as seen here –
Mking an object, referenced as a var, then trying to pass my concatenated JS that var’s .src doesn’t work.
This has been my main goal in using Verge 3D. To have a dynamic library of SVG’s resourced from ONE source, able to represented and interacted with in 3D…
I’m ALLLLMOST there…
Any advice or help with this would be FANTASTIC!Thanks.
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-19 at 12:21 pm #31732Yuri KovelenovStaff2020-08-20 at 3:23 am #31756GLiFTeKCustomerHi,
what do your Puzzles print in the console?Eh… Too many to count..
I’ll post some that are currently the issue..”du jour”..I’m currently working on getting a basic understanding of having “canvg.js” run successfully, then attempt to apply it to the verge.3d. Project.
This problem of not being able to externally reference fraction url items it’s precisely why I went to getting into having css3d divs with svgs… However… I feel that’s going to be way too many problems in the future with things I want to do.
I can reference the symbols from the svg fine with the <svg> and <object> tags …in 2D!… Not in the JS .src tho or html img src…
But canvg.js claims it can so…
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-20 at 5:19 am #31757GLiFTeKCustomerWhat I’m attempting to use is, (finally found the official NAME for it)…
The <IRI> ( Internationalized Resource Identifier ) with a “#” Fragment Identifier” that references the designated <symbol> in the (XML) SVG sprite sheet library specified.
“non-local IRI references” to be specific. (External file fragment “#” reference)
EDIT: and on further reading through the SVG content types…
“URL
A Uniform Resource Locator.A URL is a sequence of Unicode characters, building an address to an internal or external resource.
Before SVG 2, the more limited IRI content type was used instead, because the URL specification was not standardized before.”
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-20 at 8:53 am #31774Yuri KovelenovStaff2020-08-22 at 6:02 pm #31855HoboCatCustomerHi all,
This all is very non-verge 3d, but dovetails into it as I’m trying to get SVG’s drawn to canvas into my 3d materials using SVG’s <use> method.NOTE: drawing simple SVG’s to canvas using the ways in the User Manual is working FINE. The problem is referencing them in the JS.
What I mean by the <use> method is shown here – https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use
My main SVG file begins with a number of shapes with their own id’s… Circles mainly.
Then after that, groups… (with their own id’s) using <use> to make different combos of those shapes mentioned above, those groups being often used composited complex designs used in the following…
Then the largest part of the file I have whole sections of the groups in different arrangements (and cataloged with serial numbers, in a separate spreadsheet/CSV) as symbols.
That’s all in <defs>.
THAT main SVG file doesn’t have anything after defs.
I use puzzles to concatenate it all with replacing the final </svg> with a <use href> to reference any of the svg symbols I want.
as seen here –
Mking an object, referenced as a var, then trying to pass my concatenated JS that var’s .src doesn’t work.
This has been my main goal in using Verge 3D. To have a dynamic library of SVG’s resourced from ONE source, able to represented and interacted with in 3D…
I’m ALLLLMOST there…
Any advice or help with this would be FANTASTIC!Thanks.
Hello, dont know if understood the problem corectly, but try changing all ‘#’ symbols with ‘%23’ in svg code.
I had made a customizator, where user is making changes in svg and every time a change is made in svg, a ‘replace texture’ puzzle is activated, which takes that modified svg from browser in url format. Im sure this would also work in your application.2020-08-23 at 3:36 am #31864GLiFTeKCustomerOh man!
Yeah I’ve been doing that with the # and the < and >. Also replacing ” with ‘.
Then wrapping the data: url with ”I guess my problem is the fact that the img has to be referenced in the html.
I’m VERY interested in your code Hobo!
Could you possibly zip a sample that shows the inner workings of everything here? (Unless of course it’s private)
Also have you joined the discord server?
What you’re describing would help our project out tremendously.
Is the “input” element the resulting formatted (encoded with %3E,C’s etc) ?
And had the clicked element been previously initiated by html puzzles?I look forward to your response!
Thanks!
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-23 at 12:52 pm #31884GLiFTeKCustomeri made this just to be sure..
cuz js encodeURIComponent() doesn’t do the “#”.
output reads well with this tho.(anyone know how to remove line breaks from text?)
i tried replacing /r/n with “” didn’t work. also CD for carriage return)Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-23 at 12:57 pm #31887GLiFTeKCustomer@HoboCat
going out on a wild limb here, …
im guessing type of element your “input” element is .. is an “input” element?
….oorrr is it a different type of element, (an img tag element? ) with the processed (encoded) result of an input element’s value?Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-24 at 6:20 am #31914HoboCatCustomerBasically you just need to make any kind of element in html, that would have a value that stores svg code in url format. ‘input’ is the name of that html element in my case it is a hidden form input.
2020-08-24 at 9:22 am #31919GLiFTeKCustomerBasically you just need to make any kind of element in html, that would have a value that stores svg code in url format. ‘input’ is the name of that html element in my case it is a hidden form input.
Right cool, so what are you having the svg code do after that? How are you displaying it? In 2d in an image in a div, or going to canvas?
Thanks!
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-24 at 10:35 am #31924HoboCatCustomerCheck the file I attached in my first post. The svg goes into replace image puzzle. You can also check my post in this thread to see how it is displayed on models:
2020-08-24 at 1:03 pm #31930GLiFTeKCustomerCheck the file I attached in my first post. The svg goes into replace image puzzle. You can also check my post in this thread to see how it is displayed on models:
<iframe class=”wp-embedded-content” sandbox=”allow-scripts” security=”restricted” style=”position: absolute; clip: rect(1px, 1px, 1px, 1px);” title=”“Generate normal map – documentation” — Soft8Soft” src=”https://www.soft8soft.com/topic/generate-normal-map-documentation/embed/#?secret=YRJFkDxOFF” data-secret=”YRJFkDxOFF” marginwidth=”0″ marginheight=”0″ scrolling=”no” width=”600″ height=”338″ frameborder=”0″></iframe>
hmmm.. yeah.. i think we’re talking about two different things man.
I’m talking about SVG, Scalable Vector Graphics.You can put them on canvas, then on an object texture.
you cna put them in a 2D div on the screen.
You can put them on CSS 3D Divs using Css3DRenderer
You can load them with the SVGLoader, or TextureLoader….But, forgive me if i’m mistaken and you’re REALLY doing this.. but i know the staff will back me up with this one.. you can’t just put an SVG on a texture using the standard puzzles except for the Canvas puzzle.
here’s me taking my old project and mixing it with yours…
a pic of it..and the zipped verge project attached if you want to look see.
I would loooove you to be right with this one tho.. I’m skeptical but curious as to what you have going on.
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-24 at 1:08 pm #31934GLiFTeKCustomerdouble post delete plz
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-08-24 at 4:55 pm #31942HoboCatCustomerNonono what I do is much simpler. All you need to do is make very simple puzzle like I posted in my first post. No canvas and so on. Then just grab this svg code and copy it into your “replace texture with” puzzle’s value:
data:image/svg+xml;utf8,<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns%23" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns%23" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" id="svg2" version="1.1" viewBox="0 0 74.764046 79.497093" height="79.497093mm" width="74.764046mm"> <defs> <style type="text/css"> </style></defs> <metadata id="metadata5"> <rdf:rdf> <cc:work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"></dc:type> <dc:title></dc:title> </cc:work> </rdf:rdf> </metadata> <g id="layer2"> <rect y="-0.002064982" x="0.0010355568" height="79.497841" width="74.765739" id="rect924" style="opacity:0.77999998;fill:%23ffffff;fill-opacity:1;stroke:none;stroke-width:0.10337228;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"></rect> </g> <g transform="translate(-38.512309,-63.715421)" id="layer1"> <flowroot transform="scale(0.26458333)" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:'Myanmar Text';-inkscape-font-specification:'Myanmar Text';letter-spacing:0px;word-spacing:0px;fill:%23000000;fill-opacity:1;stroke:none" id="flowRoot963" xml:space="preserve"><flowregion id="flowRegion965"><rect y="309.92493" x="121.74927" height="83.032066" width="357.78427" id="rect967"></rect></flowregion><flowpara id="flowPara969"></flowpara></flowroot> <text id="text906" y="106.85049" x="75.818047" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.8166666px;line-height:1.25;font-family:'Dancing Script';-inkscape-font-specification:'Dancing Script';text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:%23000000;fill-opacity:1;stroke:none;stroke-width:0.26458332" xml:space="preserve"><tspan style="font-size:14.8166666px;stroke-width:0.26458332" y="106.85049" x="75.818047" id="tspan904">Hello</tspan></text> </g></svg>
-
AuthorPosts
- You must be logged in to reply to this topic.