GithubHelp home page GithubHelp logo

pissang / claygl Goto Github PK

View Code? Open in Web Editor NEW
2.8K 2.8K 299.0 58.88 MB

A WebGL graphic library for building scalable Web3D applications

Home Page: http://claygl.xyz/

License: BSD 2-Clause "Simplified" License

JavaScript 77.09% CSS 0.02% HTML 13.31% GLSL 6.65% Python 2.93%
3d gltf visualization webgl

claygl's People

Contributors

birdinforest avatar bjvanminnen avatar chchwy avatar fmmoret avatar fuzhenn avatar nickkraakman avatar pissang avatar samueltallet avatar scarletsky avatar xalien95 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  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

claygl's Issues

add eslint

Recommend to add eslint config to avoid typos or unused varibles in the first place, like the one in PR #36

[discussion] move TBN to vertex shader

探讨:

目前standard.glsl中,TBN是在fragment shader中计算和应用的。

如果转为在vertex shader中计算TBN,并将所需的normal/light direction/eye direction等在vertex shader中提前转换为TBN坐标后再传递给fragment shader, 这样fragment shader中就不需要做TBN矩阵乘法,应该能提升一些性能。

只是我一点不成熟的想法,不知道是否可行:

  • 如果有parallax occlusion或normal map时,在vertex shader中计算TBN,并将相关的uniform和TBN相乘,传递给fragment shader,例如light direction,view direction等
  • 在fragment shader中计算时,直接应用vertex shader中提前计算好的TBN uniform

祝好

ByteStride is missing from BufferView output

Looks like the ByteStride attribute was never finished for the bufferview output (line 1155), or was for some reason commented out? I cannot find where the stride is computed or recorded, so I guess this is still a todo. But this library, as nice as it is, will not work without the bytestride being output.

Technically i guess you don't need stride if you're creating a separate buffer view for each accessor type, but I don't see that happening either...looks like its just incomplete implementation of the GLTF spec...

add ci tests

有没有考虑给qtek增加CI tests?

测试的难点是如何测试结果判定(特别是需要比对绘制结果时), 我想可以如下进行:

  • 每个案例都尽量简单, 保证运行结果不会有随机性
  • 如果案例无需比对绘制结果, 用断言函数正常测试即可
  • 如果案例需比对绘制结果, 可以预先给案例生成正确的基准fixture图片, 以后每次运行测试时, 都实时生成新的fixture图片并与基准fixture作比对

上述的fixture比对测试, 可以基于headless-gl来做. 测试过程类似于这个webgl测试框架jest-gl里的例子.

如果有了测试, 就能放心大胆的重构/增加新功能了.

如果有兴趣增加回归测试, 愿效犬马之劳~

AmbientLight contructor

The applications createAmbientLight does some parsing and checking to create an AmbientLight.

This code can more less directly go into the AmbientLight constructor. As it checks for null this means no change to the api. Just easier to use the class.

If you want i can make the change

TypeError: 'int' object is not iterable

Hi, just updated to the latest fbx2gltf.py (thanks again!), but my test FBX file now returns TypeError: 'int' object is not iterable. Here is the stack trace:

$ python fbx2gltf.py /tests/test.FBX
Traceback (most recent call last):
  File "fbx2gltf.py", line 1474, in <module>
    args.binary
  File "fbx2gltf.py", line 1329, in Convert
    lSceneIdx = ConvertScene(lScene, poseTime)
  File "fbx2gltf.py", line 904, in ConvertScene
    lNodeIdx = ConvertSceneNode(pScene, lRoot.GetChild(i), pPoseTime)
  File "fbx2gltf.py", line 889, in ConvertSceneNode
    lChildNodeIdx = ConvertSceneNode(pScene, pNode.GetChild(i), pPoseTime)
  File "fbx2gltf.py", line 854, in ConvertSceneNode
    lGLTFMesh['primitives'] += ConvertMesh(pScene, lNodeAttribute, pNode, lGLTFSkin, lClusters)
  File "fbx2gltf.py", line 639, in ConvertMesh
    lTmpIndex, lScaleU, lScaleV, lTranslationU, lTranslationV = ConvertToPBRMaterial(lMaterial)
TypeError: 'int' object is not iterable

This same FBX file worked with the previous version of fbx2gltf.py, and this FBX file can be opened with the official FBX Review tool. I tried different FBX files, and those did convert correctly and without errors.

Any idea what the problem could be?

precision problem in Matrix4

目前clay.math.Matrix4中默认用Float32Array创建的array,造成矩阵计算过程中,如果中间结果的精度超过32位float时,会出现精度丢失的问题。

是否考虑把Matrix4改为用普通的数组来实现,在调用gl方法时,再转为Float32Array?

其他的math下的类同理(Matrix*, Vector*)

作为参考,THREE中的Matrix4是基于普通数组来实现的

dota模型的项目

当我试图加载两个或以上模型的时候,FPS降低到只有5,有没有什么方式可以解决么??

OrbitControl plugin - Zoom is not working on Firefox

OS: Windows 10.1709 (64 bits)
Browser: Firefox 59.0.2 (64 bits)
ClayGL: 1.2.0

First, thanks for your great library!

I have an issue with orbit control:
Zoom doesn't work on Firefox. I found this error in console but I suppose it is not related: Error: WebGL warning: texImage2D: Alpha-premult and y-flip are deprecated for non-DOM-Element uploads.

Note: Zoom works on Chrome 😮

can't run script on mac/python 3.6.4

I installed python 3.6.4,
I run script with command: python3 fbx2gltf.py
I have message:
"You need to copy the content in compatible subfolder under /lib/python into your python install folder such as "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages" folder."

PBR implementation?

Hi,
I saw you've added PBR support and it is standard shader now, it is fully implemented?
I saw functions like G_Smith, D_GGX never called?
Whats missing?

Thanks

Illegal image formats in resulting GLTF file.

When converting a FBX to a GLTF file, either binary or JSON gltf, the script(fbx2gltf.py) should do image transformation to PNG or JPEG in order to support most rendering engines. To reproduce the bug, try to transform a FBX with reference to a TGA image.

Samba Dancing glTF model contains many errors

I tested the Samba Dancing glTF model used in the sample below with glTF-Validator.

http://examples.claygl.xyz/examples/basicModelAnimation.html
https://github.com/pissang/claygl/blob/master/example/assets/models/SambaDancing/SambaDancing.gltf

However, the Samba Dancing glTF model seems to report many errors.
For reference below I will post the first 3 errors.

Code Message Pointer
MESH_PRIMITIVE_ACCESSOR_WITHOUT_BYTESTRIDE bufferView.byteStride must be defined when two or more accessors use the same buffer view. /meshes/0/primitives/0/attributes/NORMAL
MESH_PRIMITIVE_ACCESSOR_WITHOUT_BYTESTRIDE bufferView.byteStride must be defined when two or more accessors use the same buffer view. /meshes/0/primitives/0/attributes/POSITION
MESH_PRIMITIVE_ACCESSOR_WITHOUT_BYTESTRIDE bufferView.byteStride must be defined when two or more accessors use the same buffer view. /meshes/0/primitives/0/attributes/TEXCOORD_0

I do not know the cause of this error, but there seem to be cases in which Samba Dancing glTF Model can not be displayed in other libraries.
CesiumGS/cesium#6433

咨询一个echarts的问题

hi, Yi Shen,你好,请教你一个echarts的问题。

我现在的一个需求是图表的可以在X轴方向上可以拖动,在Y轴不可以。

我的dataZoom事件设置‘inside’(因为项目需求,只能用inside,不能用slider),设置了zoomLock 为true后,现在我发现在移动端,Y轴方向拖动屏幕时,dataZoom事件会跟原生的拖动事件冲突,造成在图表区域内Y轴方向拖动时,不能拖动屏幕。我想取消dataZoom在Y轴上的事件,请问我改怎么做呢。
盼回复,谢谢!!

Conversion Tool: AttributeError: 'FbxTime' object has no attribute 'SetSecondDouble'

I'm attempting to convert a fbx file and I come up with this error. I'm running python 3.6 because 3.3 is EOL. I'm not sure if this is the issue or not. Not sure where the issue lies.

Traceback (most recent call last):
  File "/Users/rsfpgd/Desktop/HololensStuff/claygl/tools/fbx2gltf.py", line 1461, in
    lPoseTime.SetSecondDouble(float(args.pose))
AttributeError: 'FbxTime' object has no attribute 'SetSecondDouble'

Application do_render method

Just noticed that the method takes three arguments, but

  • it doesn't really need the first two, as they are instance variables
  • it doesn't use the third parameter

Again, this is simple enough, i could do it if you want

clay.application is undefined

Uncaught TypeError: Cannot read property 'create' of undefined
at claygl.html:10

Here is my code.

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="claygl.min.js"></script>
</head>
<body>
    <canvas id="main"></canvas>

    <script>
        clay.application.create('#main', {

            width: window.innerWidth,

            height: window.innerHeight,

            init: function (renderer, scene, timeline) {
                // Create camera
                var camera = new clay.camera.Perspective();
                camera.position.set(0, 2, 5);
                camera.lookAt(clay.math.Vector3.ZERO);
                scene.add(camera);

                // Create cube
                this._cube = clay.application.createCube();
                scene.add(this._cube);

                // Create light
                var light = new clay.light.Directional();
                light.position.set(1, 1, 1);
                light.lookAt(this._cube.position);
                scene.add(light);
            },

            loop: function (renderer, scene, timeline) {
                this._cube.rotation.rotateY(this.frameTime / 1000);
            }
        });
    </script>
</body>
</html>

Tree shaking

Hi
this looks like a great project, thanks for sharing.

It doesn't look to big for starters, but i was curious how to achieve the 40k zipped.
I'm not a js buff (don't know the tooling, like rollup), maybe you could share a simple example.

I have been coding for a while, if there is any small boring tasks you want to offload, just say.

Scene.removeFromScene

调用scene.removeFromScene(mesh)后,mesh没被移除,依然继续会被绘制
以下就能正常移除:

scene.removeFromScene(mesh);
scene.remove(mesh);

是不是应该在removeFromScene中调用一下 this.remove(node) ?

If shading type is "unknown" a TypeError is thrown

There is no try/catch to try and fix or report on this error. On line 425, in the ConvertToPBRMaterial function, there is an early return that does not follow the method signature of returning a tuple of 5 values. The calling line 638 in the function ConvertMesh requires a tuple return value. If this does not happen, EG, the early return executes in ConvertToPBRMaterial, the python script throws a TypeError: 'int' object is not iterable.

Not sure what the intention was here, but if you are expecting a the 'unknown' material shading type and doing an early return, at a minimum the calling code should check for that and either try/catch with a descriptive error message, better yet, write the code to recover and continue on. As it is I cannot decipher what the code-writer's intent was from reading the functions, so some code-comments in there would also be a big improvement.

建议

这个很厉害啊,要是能有个教程就更完美了

Fog support?

Any plan to add fog support? Linear, exp, exp2 etc?

How to use quaternions?

Below is a sample of Quaternion using Three.js.
http://jsdo.it/cx20/qqSi

function render() {

    // rotate
    mesh1.rotation.x += Math.PI / 180;
    mesh1.rotation.y += Math.PI / 180;
    mesh1.rotation.z += Math.PI / 180;
    
    // quaternion
    var axis = new THREE.Vector3(1,1,1).normalize();
    angle += Math.PI / 180;
    var q = new THREE.Quaternion();
    q.setFromAxisAngle(axis,angle);
    mesh2.quaternion.copy(q);

    // render
    renderer.render( scene, camera );

}

How can I write code in QTEK to do the same?

Geometry and transferable

Serialize geometry to JSON-like object with transferable list

To transfer geometry from-to web worker

Textures not copying while converting to non-binary gltf

While doing PR I found out that when textures are matched and the URI is changed in the non-binary GLTF, the images are not moved to the output directory.

Example: fbx2gltf.py model.fbx -o ./subdir/model.gltf

Here, all images in the local directory will stay in the local directory and not copy to ./subdir along the gltf file, which breaks the URI of the generated gltf file.

Several examples do not work (missing lib/require.js)

Hi,

Several examples do not work because the require.js file can't be found:

No directory of lib exists with the required Require.js file.

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <script type="text/javascript" src="lib/require.js"></script>
    </head>

Possible other files that are missing the lib folder can be found using the following search query:
https://github.com/pissang/qtek/search?utf8=%E2%9C%93&q=%2Flib%2Frequire.js&type=

Thank you for the great library, it has been a great inspiration.

Tim

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.