• 正文概述
  • GitHub – pissang/clay-viewer:具有高质量渲染和 glTF2.0/GLB 导出功能的 3D 模型查看器

    存储库文件导航

    粘土查看器

    基于 ClayGL 和 glTF2.0/GLB 导出的高质量渲染的 3D 模型查看器。

    应用程序

    在 Windows 和 macOS 上下载应用程序,具有 FBX/DAE/OBj 导入和 glTF2.0/GLB 导出功能。将其用作常用模型预览工具!

    编辑 器

    自动草稿 图像描述

    Loader

    var viewer = new ClayViewer(document.getElementById('main'), {
        // Full config at
        // https://github.com/pissang/clay-viewer/blob/master/src/defaultSceneConfig.js
        devicePixelRatio: 1,
        // Enable shadow
        shadow: true,
        shadowQuality: 'high',
        // Environment panorama texture url.
        environment: 'env.jpg',
        mainLight: {
            intensity: 2.0
        },
        ambientCubemapLight: {
            exposure: 1,
            diffuseIntensity: 0.2,
            texture: 'asset/texture/example1.jpg'
        },
        postEffect: {
            // Enable post effect
            enable: true,
            bloom: {
                // Enable bloom
                enable: true
            },
            screenSpaceAmbientOcculusion: {
                // Enable screen space ambient occulusion
                enable: true
            }
        }
    });
    
    // Load a glTF model
    // Model will be fit in 10x10x10 automatically after load.
    // Return an eventful object.
    viewer.loadModel('asset/xiniu/xiniu_walk_as.gltf', {
            // Shading mode. 'standard'|'lambert'
            shader: 'standard'
        })
        // Model loaded. not include textures.
        .on('loadmodel', function (modelStat) {
            // Set camera options.
            viewer.setCameraControl({
                // Alpha is rotation from bottom to up.
                alpha: 10,
                // Beta is rotation from left to right.
                beta: 30,
                distance: 20,
                // Min distance of zoom.
                minDistance: 1,
                // Max distance of zoom.
                maxDistance: 100,
    
                // Center of target.
                center: [0, 0, 0],
    
                // If auto rotate.
                autoRotate: false,
    
                // Degree per second.
                autoRotateSpeed: 60,
    
                // Direction of autoRotate. cw or ccw when looking top down.
                autoRotateDirection: 'cw',
    
                // Start auto rotating after still for the given time
                autoRotateAfterStill: 30
            });
    
            // Set main light options.
            viewer.setMainLight({
                // Main light intensity
                intensity: 1,
                // Main light color string
                color: '#fff',
                // Alpha is rotation from bottom to up.
                alpha: 45,
                // Beta is rotation from left to right.
                beta: 45
            });
            // Set ambient light options
            viewer.setAmbientLight({
                // Ambient light intensity
                intensity: 0.8
            });
    
            viewer.start();
    
            // Load extra animation glTF
            viewer.loadAnimation('asset/xiniu/xiniu_stand_as.gltf')
                .on('success', function () {
                    console.log('Changed animation')
                });
            // Animation pause and start
            viewer.pauseAnimation();
            viewer.resumeAnimation();
    
            // Print model stat.
            console.log('Model loaded:');
            console.log('三角面:', modelStat.triangleCount);
            console.log('顶点:', modelStat.vertexCount);
            console.log('场景节点:', modelStat.nodeCount);
            console.log('Mesh:', modelStat.meshCount);
            console.log('材质:', modelStat.materialCount);
            console.log('纹理:', modelStat.textureCount);
        })
        .on('ready', function () {
            console.log('All loaded inlcuding textures.');
        })
        .on('error', function () {
            console.log('Model load error');
        });

    这是完整的图形配置

    转炉

    ClayGL提供了一个python工具,用于将FBX转换为glTF 2.0。

    https://github.com/pissang/claygl/blob/master/tools/fbx2gltf.py

    需要 python3.3 和 FBX SDK 2018.1.1

    usage: fbx2gltf.py [-h] [-e EXCLUDE] [-t TIMERANGE] [-o OUTPUT]
                        [-f FRAMERATE] [-p POSE] [-q] [-b]
                        file
    
    FBX to glTF converter
    
    positional arguments:
      file
    
    optional arguments:
      -h, --help            show this help message and exit
      -e EXCLUDE, --exclude EXCLUDE
                            Data excluded. Can be: scene,animation
      -t TIMERANGE, --timerange TIMERANGE
                            Export animation time, in format
                            'startSecond,endSecond'
      -o OUTPUT, --output OUTPUT
                            Ouput glTF file path
      -f FRAMERATE, --framerate FRAMERATE
                            Animation frame per second
      -p POSE, --pose POSE  Start pose time
      -q, --quantize        Quantize accessors with WEB3D_quantized_attributes
                            extension
      -b, --binary          Export glTF-binary
      --beautify            Beautify json output.
      --noflipv             If not flip v in texcoord.
    

    分离场景和动画

    导出场景

    # exclude animation
    fbx2gltf2.py -e animation -p 0 xxx.fbx

    导出动画

    # exclude scene, 0 to 20 second, 20 framerate.
    fbx2gltf2.py -e scene -t 0,20 -f 20 -o xxx_ani.gltf xxx.fbx

    异步加载场景和动画

    viewer.loadModel('asset/xiniu/xiniu.gltf')
        // Model loaded. not include textures.
        .on('loadmodel', function (modelStat) {
            viewer.start();
            // Load extra animation glTF
            viewer.loadAnimation('asset/xiniu/xiniu_ani.gltf');
        });

    npm install
    # Build loader
    npm run build
    # Build editor
    webpack --config editor/webpack.config.js
    1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
    2. 分享目的仅供大家学习和交流,请不要用于商业用途!
    3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入!
    4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
    5. 如有链接无法下载、失效或广告,请联系管理员处理!
    6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
    7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员!
    8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载
    声明如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性

    GLB下载网 - GLB/GLTF模型与格式资源免费下载,支持在线浏览与转换 » 具有高质量渲染和 glTF2.0/GLB 导出功能的 3D 模型查看器

    常见问题FAQ

    免费下载或者VIP会员专享资源能否直接商用?
    本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
    提示下载要提取码
    百度网盘提取码都是gltf。
    分享过期和重复下载怎么办
    分享过期请使用备份下载,重复下载是不另扣费的,请放心下载。
    模型和平台不兼容怎么办
    可以用网站在线编辑功能,修改模型属性,大小,方向,坐标,中心,透明等问题,然后重新导出既可https://glbxz.com/38636.html
    开通VIP 享更多特权,建议使用 QQ 登录