<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to use same  script with different targets ?]]></title><description><![CDATA[<p dir="auto">Hello, I'm deploying crafting resources on design section of my github account, and to do so I share several furniture designs, I have about 10 now, but I have lots more to add. For each of them I share the 3d model and links to open jscad scripts with them. I currently have almost the same using v1 and I wrote an html/js page to create jscad code with the good script and the good 3d model. I don't know how to do that with v2, so I'm trying something else.<br />
<img src="/assets/uploads/files/1606228474640-capture-d-%C3%A9cran-de-2020-11-24-15-22-23.png" alt="Capture d’écran de 2020-11-24 15-22-23.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">( can be seen here : <a href="https://github.com/gilboonet/designs/blob/master/MEUBLES/readme.md" rel="nofollow ugc">https://github.com/gilboonet/designs/blob/master/MEUBLES/readme.md</a> )</p>
<p dir="auto">For each design there's :</p>
<ul>
<li>direct link to the 3d model ("Fichier 3d" link)</li>
<li>link to view the 3d model with online 3d viewer ("Voir modèle" link)</li>
<li>link to my jscad script for skeleton 2 axis slicing with the 3d model</li>
<li>(and to come link to my html/js unflatten application)</li>
</ul>
<p dir="auto">I would like to replace the link to online 3d viewer by a link to a jscad script where it would be possible to rescale it, and show its dimensions, but the only solution that I have in mind is to write a script for that, and duplicate it for each 3d model. It's already what I am doing for the skeleton script.</p>
<p dir="auto">Do you think that for such case, I mean choose a model then a script to apply on it, there could be a mechanism. Locally I already use dynamic require from a text parameter and it works well, but on remote script I didn't manage to make it work. Maybe is there a way to run a script from a remote folder ? or a way to require an url ?</p>
]]></description><link>https://openjscad.nodebb.com/topic/201/how-to-use-same-script-with-different-targets</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 07:28:37 GMT</lastBuildDate><atom:link href="https://openjscad.nodebb.com/topic/201.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 24 Nov 2020 14:49:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to use same  script with different targets ? on Thu, 26 Nov 2020 08:00:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hrgdavor" aria-label="Profile: hrgdavor">@<bdi>hrgdavor</bdi></a> Thank you for your code, it would be great to be able to load code and data like that then fire it. I hope it will be possible, with v1 I used gProcessor.setJJsCad() on an html/js app but here it is directly a jscad script.</p>
]]></description><link>https://openjscad.nodebb.com/post/551</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/551</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Thu, 26 Nov 2020 08:00:38 GMT</pubDate></item><item><title><![CDATA[Reply to How to use same  script with different targets ? on Wed, 25 Nov 2020 20:19:20 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">No matter what you try, a website cannot '<strong>dynamically</strong>' load resources (scripts) from other external websites. There are many things that will bite you if you try. Browsers execute in a very tightly controlled work space, and only user interactions (drag and drop, etc) allow access to external resources. Everything else has a fence around it.</p>
</blockquote>
<p dir="auto">Actually, git gists have Allow-Origin headers so external include from github gist would work.</p>
<p dir="auto">I actualy created a small jscad file that loads <a class="plugin-mentions-user plugin-mentions-a" href="/user/gilboonet" aria-label="Profile: gilboonet">@<bdi>gilboonet</bdi></a> script and dump s it in the console,<br />
the issue then how to execute it and trigger re-render</p>
<pre><code class="language-js">const jscad = require('@jscad/modeling')

function main(){
 return sphere();
}

fetch('https://raw.githubusercontent.com/gilboonet/designs/master/MEUBLES/sq_ed0001.js')
  .then(r=&gt;r.text()).then(text=&gt;console.log('js file',text))

module.exports = {main}
</code></pre>
]]></description><link>https://openjscad.nodebb.com/post/550</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/550</guid><dc:creator><![CDATA[hrgdavor]]></dc:creator><pubDate>Wed, 25 Nov 2020 20:19:20 GMT</pubDate></item><item><title><![CDATA[Reply to How to use same  script with different targets ? on Wed, 25 Nov 2020 07:42:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/z3dev" aria-label="Profile: z3dev">@<bdi>z3dev</bdi></a> Thank you for your replies. That's good news that jscad accepts external formats, I will use it instead of this online viewer. I will certainly try do dig this further and try to make a little js/html wrapper to select target 3d model and script and pack them together into a script  as I already do for v1 of my website tools. I will certainly change the static images by animated gif created using jscad regl-renderer demo, but what would be great would be to be able to directly use jscad to have those little views alive.</p>
]]></description><link>https://openjscad.nodebb.com/post/549</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/549</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Wed, 25 Nov 2020 07:42:13 GMT</pubDate></item><item><title><![CDATA[Reply to How to use same  script with different targets ? on Wed, 25 Nov 2020 02:53:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gilboonet" aria-label="Profile: gilboonet">@<bdi>gilboonet</bdi></a> said in <a href="/post/544">How to use same script with different targets ?</a>:</p>
<blockquote>
<p dir="auto">Do you think that for such case, I mean choose a model then a script to apply on it, there could be a mechanism. Locally I already use dynamic require from a text parameter and it works well, but on remote script I didn't manage to make it work. Maybe is there a way to run a script from a remote folder ? or a way to require an url ?</p>
</blockquote>
<p dir="auto">No matter what you try, a website cannot '<strong>dynamically</strong>' load resources (scripts) from other external websites. There are many things that will bite you if you try. Browsers execute in a very tightly controlled work space, and only user interactions (drag and drop, etc) allow access to external resources. Everything else has a fence around it.</p>
<p dir="auto">The www.jscad.xyz website allows the use of hash (#) and query (?) parameters to pass a URL, but that must be a URL to a single file. And, as you probably already know, there's a backend piece that downloads the file, and presents it back to the website.</p>
<p dir="auto">Sorry. But currently, the only way is to 'pack' all the pieces into a single file.</p>
]]></description><link>https://openjscad.nodebb.com/post/547</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/547</guid><dc:creator><![CDATA[z3dev]]></dc:creator><pubDate>Wed, 25 Nov 2020 02:53:53 GMT</pubDate></item><item><title><![CDATA[Reply to How to use same  script with different targets ? on Wed, 25 Nov 2020 02:35:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gilboonet" aria-label="Profile: gilboonet">@<bdi>gilboonet</bdi></a> nice work.</p>
<p dir="auto">fyi, the jscad.xyz website can also accept links to external formats.</p>
<p dir="auto"><a href="https://www.jscad.xyz/#https://raw.githubusercontent.com/gilboonet/designs/master/MEUBLES/0001.obj" rel="nofollow ugc">https://www.jscad.xyz/#https://raw.githubusercontent.com/gilboonet/designs/master/MEUBLES/0001.obj</a></p>
]]></description><link>https://openjscad.nodebb.com/post/546</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/546</guid><dc:creator><![CDATA[z3dev]]></dc:creator><pubDate>Wed, 25 Nov 2020 02:35:34 GMT</pubDate></item></channel></rss>