Render multiple stl files on windows machine

2019-09-19 09:07发布

I can find several tutorials on how to render stl files to something that looks like thingiverse renderings but I can't seem to get anything to work on a windows machine. Anyone know how I can do this?

标签: render
1条回答
唯我独甜
2楼-- · 2019-09-19 09:46

Well someone obviously doesn't like the question but I am sure others have had the problem so here is how I solved it.

I created a web page that rendered the image using jsc3d

<html>
    <header>



        <link rel="stylesheet" href="/web_inc/all.css">
        <script type="text/JavaScript" src="/web_inc/jquery-1.11.3.min.js"></script>
        <script type="text/javascript" src="/web_inc/jquery.form.min.js"></script> 
        <link rel="stylesheet" href="/web_inc/bootstrap.min.css">
        <link rel="stylesheet" href="/web_inc/bootstrap-theme.min.css">
        <script type="text/javascript" src="/web_inc/bootstrap.min.js"></script>
        <script type="text/javascript" src="/web_inc/jsc3d.js"></script>
        <script type="text/javascript" src="/web_inc/jsc3d.console.js"></script>
        <script type="text/javascript" src="/web_inc/jsc3d.webgl.js"></script>
        <script type="text/javascript" src="/web_inc/jsc3d.touch.js"></script> 
        <script type="text/javascript">
            $(document).ready(function(){ 
                var canvas = document.getElementById('cv');
                canvas.width=1200;
                canvas.height=900;
                var viewer = new JSC3D.Viewer(canvas);
                viewer.setParameter('SceneUrl', '/model/1.stl');
                viewer.setParameter('InitRotationX', 0);
                viewer.setParameter('InitRotationY', 30);
                viewer.setParameter('InitRotationZ', 0);
                viewer.setParameter('ModelColor', '#57524C');
                viewer.setParameter('BackgroundColor1', '#FFFFFF');
                viewer.setParameter('BackgroundColor2', '#999999');
                viewer.setParameter('RenderMode', 'flat');
                viewer.setParameter('MipMapping', 'on');
                viewer.setParameter('Renderer', 'webgl');
                viewer.setParameter('Definition', 'high');
                viewer.init();
                viewer.update();
            });

            function savePreview() {
                var canvas = document.getElementById("cv");
                $("#imageData").val(canvas.toDataURL("image/png"));     
                $("#uploadForm").ajaxSubmit({url: '/ajax_update_sim.php', type: 'post'});
            }

        </script>
    </header>
    <body>


        <canvas id="cv" class="viewerCanvas"></canvas>
        <form action="/ajax_upload_sim.php" method="post" enctype="multipart/form-data" id="uploadForm">
            <input type="hidden" name="id" value="1">
            <input type="hidden" name="data" id="imageData">
        </form>

        <input type="button" class="button" value="Save Preview" onclick="savePreview();"/>
    </body>
</html>

I then created a php file to save the results

$src="img/1.png"
file_put_contents($src, base64_decode(explode(",", $_REQUEST['data'])[1]));
查看更多
登录 后发表回答