How could I set more than one viewer on a web page?
Expected Behavior
Hello, everybody! I want to set up a web page contained more than one viewer just like this : (a modified viewer-minimal.html)
<body>
<div id="content" class="container">
<div class="row">
<div id="jscad-container" class="col-5 jscad-container">
<div oncontextmenu="return false;" id="viewerContext1" design-url="a.jscad"></div>
<div oncontextmenu="return false;" id="viewerContext2" design-url="b.jscad"></div>
</div>
<div id="control-container" class="col-2 order-first"></div>
<div id="result-container" class="col-5 order-last">
<div id="tail" style="display: none;">
<div id="statusdiv"></div>
</div>
</div>
</div>
</div>
</body>
while one div shows a.jscad and another one shows b.jscad,
Actual Behavior
I found that in min.js it queried #viewerContext to select one div for rendering, so it seems that the min.js is designed especially for pages which contain only one viewer. I can not find a way to include two viewers in a single web page, how should I do?
By the way, how could I pass parameters without using getParameterDefinitions() in .jscad file, sometimes, parameters cannot be obtained straightforwardly but can be obtained by using JavaScript or through some backend code.
Specifications
Version: 231d3c6 Platform: windows Environment: electron app/ web app
@LinGuanfu Thanks for the query. I think that @kaosat-dev can assist with the electron app.
Hello @LinGuanfu
- in V1 it is indeed only possible to create a single instance of jscad per page, the alpha of V2 however has that ability
- about
getParameterDefinitionscould you please clarify how you want to provide the parameters ?
@kaosat-dev Thank you for your reply.
Could you please give me some advice about creating more instances of jscad per page? Something like related functions or APIs in V2, which will be greatly helpful for me to understand how it works and make some custom modification.
As for getParameterDefinitions, my idea is to create a CAE-like(Computer-aided engineering) app if you know about it. Or the main process is that
-
provide initial parameters about the shape to create a design called model through
getParameterDefinitions(). -
upload experimental data about model to a server or localhost.
-
server or localhost use data to calculate deformation parameters.
-
use those deformation parameters and initial parameters to create a new instance of jscad on the same page.