3D源文件格式是stp,如何在页面上显示模型

3D文件stp格式如何在jquery项目中引用?在页面打开鼠标操作查看建模
类似:http://www.yanhuangxueyuan.com/3D/jixiezhuangpei/index.html

three.js

用threejs 加载模型 就行了. 如有帮助给个采纳谢谢

将3D文件(solidworks等工具导出的STL/DAE文件)在Web浏览器中加载展示

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>JUJON: 让做机器人变得简单!</title>
    <style type="text/css">
        html,
        body {
            margin: 0;
            height: 100%;
        }

        canvas {
            display: block;
        }
    </style>

</head>

<body onload="draw();">

</body>
<script src="../static/js/three.js"></script>
<script src="../static/js/OBJLoader.js"></script>
<script src="../static/js/MTLLoader.js"></script>
<script src="../static/js/OrbitControls.js"></script>
<script src="../static/js/stats.min.js"></script>
<script src="../static/js/dat.gui.min.js"></script>

<script>
    var renderer;
    function initRender() {
        renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        //告诉渲染器需要阴影效果
        renderer.setClearColor(0xffffff);
        document.body.appendChild(renderer.domElement);
    }

    var camera;
    function initCamera() {
        camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
        camera.position.set(0, 40, 50);
        camera.lookAt(new THREE.Vector3(0, 0, 0));
    }

    var scene;
    function initScene() {
        scene = new THREE.Scene();
    }

    //初始化dat.GUI简化试验流程
    var gui;
    function initGui() {
        //声明一个保存需求修改的相关数据的对象
        gui = {
        };
        var datGui = new dat.GUI();
        //将设置属性添加到gui当中,gui.add(对象,属性,最小值,最大值)
    }

    var light;
    function initLight() {
        scene.add(new THREE.AmbientLight(0x444444));

        light = new THREE.PointLight(0xffffff);
        light.position.set(0, 50, 0);

        //告诉平行光需要开启阴影投射
        light.castShadow = true;

        scene.add(light);
    }

    function initModel() {

        //辅助工具
        var helper = new THREE.AxesHelper(50);
        scene.add(helper);

        var mtlLoader = new THREE.MTLLoader();
        mtlLoader.setPath('../static/stl/');
        //加载mtl文件
        mtlLoader.load('lv.mtl', function (material) {
            var objLoader = new THREE.OBJLoader();
            //设置当前加载的纹理
            objLoader.setMaterials(material);
            objLoader.setPath('../static/stl/');
            objLoader.load('lv.obj', function (object) {

                //获取车体的位置
                var jujon2 = object.children[5];
                var jujon1 = object.children[4];

                //设置车体的透明度
                jujon1.material.opacity = 0.6;
                jujon1.material.transparent = true;
                jujon1.material.depthTest = false;
                jujon1.material.side = THREE.DoubleSide;

                jujon2.material.opacity = 0.6;
                jujon2.material.depthTest = false;
                jujon2.material.transparent = true;
                jujon2.material.side = THREE.DoubleSide;

                //将模型缩放并添加到场景当中
                object.scale.set(0.08, 0.08, 0.08);
                scene.add(object);
            })
        });
    }

    //初始化性能插件
    var stats;
    function initStats() {
        stats = new Stats();
        document.body.appendChild(stats.dom);
    }

    //用户交互插件 鼠标左键按住旋转,右键按住平移,滚轮缩放
    var controls;
    function initControls() {

        controls = new THREE.OrbitControls(camera, renderer.domElement);

        // 如果使用animate方法时,将此函数删除
        //controls.addEventListener( 'change', render );
        // 使动画循环使用时阻尼或自转 意思是否有惯性
        controls.enableDamping = true;
        //动态阻尼系数 就是鼠标拖拽旋转灵敏度
        //controls.dampingFactor = 0.25;
        //是否可以缩放
        controls.enableZoom = true;
        //是否自动旋转
        controls.autoRotate = true;
        //设置相机距离原点的最远距离
        controls.minDistance = 1;
        //设置相机距离原点的最远距离
        controls.maxDistance = 200;
        //是否开启右键拖拽
        controls.enablePan = true;
    }

    function render() {

        renderer.render(scene, camera);
    }

    //窗口变动触发的函数
    function onWindowResize() {

        camera.aspect = window.innerWidth / window.innerHeight;
        camera.updateProjectionMatrix();
        render();
        renderer.setSize(window.innerWidth, window.innerHeight);

    }

    function animate() {
        //更新控制器
        render();

        //更新性能插件
        stats.update();

        controls.update();

        requestAnimationFrame(animate);
    }

    function draw() {
        initGui();
        initRender();
        initScene();
        initCamera();
        initLight();
        initModel();
        initControls();
        initStats();
        animate();
        window.onresize = onWindowResize;
    }
</script>

</html>


需要使用CAD Exchanger这个软件把stl或者stp文件转换成mtl或者obj文件。之后,引入Three.js库进行加载和显示。
详细的实现代码,可以参考:
将3D文件(solidworks等工具导出的STL/DAE文件)在Web浏览器中加载展示:https://blog.csdn.net/qq_40695642/article/details/117792520

试试three.js

SolidWorks Online Viewer Sketchfab、NetFabb

如何将3D文件(solidworks等工具导出的STL/DAE文件)在Web浏览器中加载展示_怎么在html网页上显示solidworks 做的3d效果_冷色调的夏天的博客-CSDN博客 在前一篇博客中,我将3D文件导入到了Rviz中做机器人的模型展示,今天尝试下将3D文件放在Web浏览器中展示。在Web端渲染3D模型是比较麻烦的,但是好在有three.js等这样的Web3D引擎,才使得我们网页端渲染3D模型变为可能。首先我们需要使用CAD Exchanger这个软件把stl或者stp文件转换成mtl或者obj文件,然后按照下面的操作即可。话不多说,直接上代码,理解起来也不是很难,注意下面的stl文件路径改成你自己的路径。值得注意的是object.scale.set(0.08, 0.0_怎么在html网页上显示solidworks 做的3d效果 https://blog.csdn.net/qq_40695642/article/details/117792520