Giter Club home page Giter Club logo

clay-viewer's Introduction

Clay Viewer

3D model viewer with high quality rendering based on ClayGL and glTF2.0/GLB export.

App

Download App on Windows and macOS with FBX/DAE/OBj import and glTF2.0/GLB export. Use it as a common model preview tool!

Editor

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');
    });

Here is the full graphic configuration

Converter

ClayGL provide a python tool for converting FBX to glTF 2.0.

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

Needs python3.3 and 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.

Seperate scene and animation

Export scene

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

Export animation

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

Load scene and animation asynchronously

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');
    });

Build

npm install
# Build loader
npm run build
# Build editor
webpack --config editor/webpack.config.js

clay-viewer's People

Contributors

pissang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clay-viewer's Issues

The alpha parameter does not work when the object has just loaded the program

Environment:
CPU: I5-3337U, RAM: 6Gb, GPU: NVIDIA 710M
Windows 10 x64, build 1607.
Build
qtek-model-viewer-0.1.1-win
Description:
When loading objects that have been modified and saved in zip format, the Alpha effect is not displayed until at least one of the material parameters is changed.
The images below: 1) the expected image, 2) when downloaded after saving in zip format.
sphere_2_
sphere_2__
sphere_2.zip

Cannot be rotated by an angle greater than 180 degrees

Environment:
CPU: I5-3337U, RAM: 6Gb, GPU: NVIDIA 710M
Windows 10 x64, build 1607.
Build
qtek-model-viewer-0.1.1-win
Description:
Cannot be rotated by an angle greater than 180 degrees around the axes that are orthogonal to the z axis.
See attached image.
rotated_x_or_y_axis

The program starts with error and warning

Environment:
CPU: I5-3337U, RAM: 6Gb, GPU: NVIDIA 710M
Windows 10 x64, build 1607.
Build
qtek-model-viewer-0.1.1-win
Description:
The program starts with error and warning. Similar message when the Reset button is pressed inside the program.
console_run

I can not open all file formats except gLTF

I tried to open all types of formats (fbx, dae, obj, gLTF).

All gLTF files downloaded from here https://sketchfab.com/features/gltf, open without problems.
 
Files downloaded from other directories https://sketchfab.com and automatically converted directly to the site (for example https://sketchfab.com/models/1a9db900738d44298b0bc59f68123393 and https://sketchfab.com/models/faed84a829114e378be255414a7826ca) are also downloaded to the program. At the same time, the last file (Cathedral), apparently, is very large and slows the system. This seems to be a question related to #21 in the hardware part.

But the same models in obj - original format, as well as models in the formats fbx, dae, obj, downloaded from other sites (for example, https://free3d.com) do not open and produce the following messages.

dae
fbx_failed
obj

Win10 1709. 16299.125
Installed:

  1. https://www.python.org/ftp/python/3.6.4/python-3.6.4.exe
  2. FBX SDK 2018.1.1 Python -http://download.autodesk.com/us/fbx/2018/2018.1.1/fbx20181_1_fbxpythonsdk_win.exe

What could be the reason?

EmaSimpleSkin.gltf is not displayed

I tried to display the following model in QMV.js.
https://github.com/cx20/jsdo-static-contents/tree/master/models/gltf/2.0/EmaSimpleSkin_blender/glTF
emasimpleskin

However, it does not appear to be displayed.
http://jsdo.it/cx20/SpgU

I tried with each browser, the following warning was displayed on the console.

Chrome:

GL ERROR :GL_INVALID_OPERATION : glDrawElements: range out of bounds for buffer

Firefox:

QMV.js:14017:21
WebGL warning: drawElements: Bound element array buffer is too small for given count and offset.

Some model polygons transparency remains unchanged.

Environment:
CPU: I5-3337U, RAM: 6Gb, GPU: NVIDIA 710M
Windows 10 x64, build 1607.
Build qtek-model-viewer-0.1.1-win
Description:
When you change alpha parameters values, some model polygons transparency remains unchanged.
See attached image and model in zip-archive.
avocado_polygons
model.zip

How to provide metalness and roughness if they are in one image?

Hello guys,

First I do feel this is a pretty good project. Thank you.

https://github.com/KhronosGroup/glTF-WebGL-PBR As shown here, KhornosGroup propose to merge metallic and roughness into one image (metalness in Blue channel and roughness in green channel). However, in your viewer the two texture need to provide separately. Does the model viewer support this packing of metallic-roughness for now? Or I have to find a way to separate them?

Thank you.

Textures issue

Hi,

While using your converter, we ran into a significant bug where textures are not correctly included in the GLB or not correctly referenced in the glTF, depending on your output settings.

The problem
The default behavior of the converter is to output a .gltf and .bin file in the same directory as the input file. So if your folder structure is:

test.fbx
textures/texture.png

You end up with a .gltf file which correctly references the textures/texture.png file. However, problems arise when...

  1. You use the -o option to output to a different directory, since the .gltf still references textures/texture.png, but these files are still located in the original directory, not in the output directory you specified, and so loading the .gltf file in a viewer results in a "can't find textures" error.
  2. You use the -b option to output a GLB file, since the textures are not properly included in the GLB, as you can see in this example: test.glb.zip. If you open this GLB in ClayGL viewer, it has materials, but no textures. If you check the file size (1.9MB), you see that it does not include (all) textures, since that should result in a file around 3MB. If you try to open this GLB in Paint3D, it says the file can't be opened at all, suggesting something is wrong with the file.
  3. You use a .zip file as input, which contains both an FBX and a /textures folder, resulting in a "Can't find texture file in the folder" error, because the Autodesk FBX SDK does not unzip the textures in the same folder as the zip file, but instead it unzips them to a temp folder, which is why the FindFileinDir() function can't find the textures.

To replicate this issue you could download our example FBX model: test.zip

Please let me know if you need more info to resolve this issue.

Thanks in advance for your help!

Nick

Rotate of the model

I noticed strange reaction of the workplace to my action.

Steps to reproduce:

  1. Clamp the left button at the workplace;
  2. Drag the cursor out of the program field with clamped button;
  3. Unclamp left button and try to rotate the model. You can do it.

Is it a bug or a feature?

11112

No "alphaMode" in materials?

Hi,

I'm trying to use qtek viewer to convert fbx->gltf(2) and it doesn't appear to add an "alphaMode":"BLEND" property to non-opaque materials.

Am I doing something wrong or is this a bug?

Bye!
Mark

Incorrect behavior of number inputs

It is related to controlkit and its weird validation of such fields. If you place caret left from decimal point and press Delete key, the number in the field will be multiplied by 100. It works with all fields.
Eg: 0.50 -> 50.00, 1.23 -> 123.00 etc.

Alpha rendering artefacts.

Environment:
CPU: I5-3337U, RAM: 6Gb, GPU: NVIDIA 710M
Windows 10 x64, build 1607.
Build
qtek-model-viewer-0.1.1-win
Description:
Hello.
Alpha rendering artefacts. When alpha value is set less 1.0 some rendering artefacts appear. These artefacts like at horizontal lines. See attached image and model in zip-archive.
rend_artft
model_sphere.zip

Mouse interaction with model view

Environment:
CPU: I5-3337U, RAM: 6Gb, GPU: NVIDIA 710M
Windows 10 x64, build 1607.
Build
qtek-model-viewer-0.1.1-win
Description:
Hello.
When you are change model view by pressed any mouse button and then move mouse cursor outside program window and release button, program saves mouse button state. And when you return back mouse cursor to program window you get model view changing without mouse pressed button.

Binary glTF

Very impressive work, @pissang ! Would love to have the option to convert to binary glTF as well. Is this something you will add soon?

FBX/DAE/OBJ models support

Web version doesn't support these ones but desktop (at least Windows verstion) do. However I faced quite a few problems when tried to load models. I mainly used free models from Sketchfab and there was only a small amount of models which loaded correctly.
Sometimes textures don't apply at all, sometimes I can see only a part of model (eg body without a head or limbs), some animated models weren't play animation properly. And the application stopped responding because of the one huge obj model (~80mb). At the same time if I use gltf models (Sketchfab allows to autoconvert them) I don't face these problems.
What is the current status of supporting such models?

Digital filed

In addition to problems with NUMPAD #19, all digital fields do not allow performing copy / paste operations.
And also in materials, when you try to change the value in the digital fields with the up and down arrows, the change occurs only by an integer. At the same time, the slider can be changed to fractional values.

LoadDialog and SaveDialog is empty

Environment:
CPU: I5-3337U, RAM: 6Gb, GPU: NVIDIA 710M
Windows 10 x64, build 1607.
Build: qtek-model-viewer-0.1.1-win
Description:
Hello.
In the materials and the settings windows, when you click the load or save button, an empty window opens.
Video in zip file.
Save_Load.zip

0.1.1 macOS version application doesn't run

Environment: MacBook Pro 13 2015, Air 13 2015 - macOS 10.13.3
Description: This ver. of the app does not work. Endless waiting for the opening.
Note: 0.1.0 version of the app rarely opens. To run it is necessary to install additional software or hardware should be more powerful?

1

Numpad

Hello!
The program does not work properly with numpad. I can only add the highest digit to a number but the program does not respond to other actions.

Alpha not loading correctly and difference between gltf and fbx.

  1. I'm testing this model (autoconverted gLTF) and found strange bug, when I load it, part of the model seems to have Alpha less than 1, and when I change it from 1 to 1, it's becomes normal.

before
screenshot_2

after
screenshot_3

  1. Is it normal that body parts in different formats refer to different zones?
    And in general why they are so located?
    (autoconverted gLTF from fbx)
    screenshot_4

(fbx) face is clearly bad loaded
screenshot_5

Unable to build QMV.js

I tried the following command.

npm install
npm run build

However, an error occurred.

C:\home\edu\javascript\library\qtek-model-viewer-master>npm run build

> qtek-model-viewer@0.1.0 build C:\home\edu\javascript\library\qtek-model-viewer-master
> npm run glsl2js && rollup -c && uglifyjs -c -m -- dist/QMV.js > dist/QMV.min.js


> qtek-model-viewer@0.1.0 glsl2js C:\home\edu\javascript\library\qtek-model-viewer-master
> node build/glsl2js.js


C:\home\edu\javascript\library\qtek-model-viewer-master/index.js → dist/QMV.js...
[!] Error: 'default' is not exported by node_modules\zrender\lib\core\util.js
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
src\Viewer.js (23:7)
21: import SceneHelper from './graphic/SceneHelper';
22: import defaultSceneConfig from './defaultSceneConfig';
23: import zrUtil from 'zrender/lib/core/util';
           ^
24:
25: import getBoundingBoxWithSkinning from './util/getBoundingBoxWithSkinning';

The environment used for the build is the Windows 10 command prompt.
I also tried Bash on Windows, but the result was an error similar to the previous one.

How can I create the latest version of QMV.js?

Suzanne.gltf is displayed dark

I tried to display the following model.
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Suzanne

However, it appears to be quite dark.

QMV.js + Suzanne.gltf result:
image

I tried setting the light intensity to 10 times, and it got a little brighter.

    viewer.setMainLight({
        intensity: 1*10,
        color: '#fff',
        alpha: 45,
        beta: 45
    });
    viewer.setAmbientLight({
        intensity: 0.8*10
    });

However, things like molds are now displayed.

image

Perhaps the usage of the light may be incorrect. In that case, please tell me how to set it.

unreadable message

If no model or texture file is selected, when trying to click on the "Download" button, we get an unreadable message.
default

Minimum requirements for hardware and software.

The model in Windows 7 x64 (WS2008r2 as workstation) is not correctly displayed. Apparently for Windows it is required DX12, as on Win10, with a weak hardware all is normal. What are the minimum requirements for hardware and software?

001

emty window

Buttons "save" "load" open an empty window without the possibility of its functioning
default

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.