THREE.JS 从搅拌机导出 JSON 模型(包括纹理)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15246598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 18:46:59  来源:igfitidea点击:

THREE.JS Exporting JSON models from blender (including textures)

javascriptjsonexportthree.jsblender

提问by sparkyspider

I'm using the mrdoob Blender Export Plugin (io_mesh_threejs) to Export to Three JS, but the exported .js or .dae objects do not contain any reference to the texture map files. Is there a special way I need to export the object? Alternatively, is there a special way I need to apply the map to the object in Blender 2.65 in order for the exporter to include it. Lastly, if there is not a way, can I manually add the texture in the JS file?

我正在使用 mrdoob Blender 导出插件 (io_mesh_threejs) 导出到三个 JS,但导出的 .js 或 .dae 对象不包含对纹理贴图文件的任何引用。是否有特殊的方式需要导出对象?或者,是否有一种特殊的方式我需要将贴图应用到 Blender 2.65 中的对象,以便导出器包含它。最后,如果没有办法,我可以在JS文件中手动添加纹理吗?



Blender Before Export

导出前的搅拌机

enter image description here

在此处输入图片说明



JSON Object Exported (without reference to texture)

导出的 JSON 对象(不参考纹理)

{

    "metadata" :
    {
        "formatVersion" : 3.1,
        "generatedBy"   : "Blender 2.65 Exporter",
        "vertices"      : 8,
        "faces"         : 6,
        "normals"       : 8,
        "colors"        : 0,
        "uvs"           : [4],
        "materials"     : 1,
        "morphTargets"  : 0,
        "bones"         : 0
    },

    "scale" : 1.000000,

    "materials" : [ {
        "DbgColor" : 15658734,
        "DbgIndex" : 0,
        "DbgName" : "Material",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.6400000190734865, 0.6400000190734865, 0.6400000190734865],
        "colorDiffuse" : [0.6400000190734865, 0.6400000190734865, 0.6400000190734865],
        "colorSpecular" : [0.5, 0.5, 0.5],
        "depthTest" : true,
        "depthWrite" : true,
        "shading" : "Lambert",
        "specularCoef" : 50,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    }],

    "vertices" : [1,-0.988938,-1,1,-0.988938,1,-1,-0.988938,1,-1,-0.988938,-1,1,1.01106,-0.999999,0.999999,1.01106,1,-1,1.01106,1,-1,1.01106,-1],

    "morphTargets" : [],

    "normals" : [0.577349,-0.577349,-0.577349,0.577349,-0.577349,0.577349,-0.577349,-0.577349,0.577349,-0.577349,-0.577349,-0.577349,0.577349,0.577349,-0.577349,-0.577349,0.577349,-0.577349,-0.577349,0.577349,0.577349,0.577349,0.577349,0.577349],

    "colors" : [],

    "uvs" : [[1,-0,1,1,0,1,-0,0]],

    "faces" : [43,0,1,2,3,0,0,1,2,3,0,1,2,3,43,4,7,6,5,0,0,1,2,3,4,5,6,7,43,0,4,5,1,0,0,1,2,3,0,4,7,1,43,1,5,6,2,0,0,1,2,3,1,7,6,2,43,2,6,7,3,0,0,1,2,3,2,6,5,3,43,4,0,3,7,0,2,3,0,1,4,0,3,5],

    "bones" : [],

    "skinIndices" : [],

    "skinWeights" : [],

    "animation" : {}


}


Code To Load JSON Object

加载 JSON 对象的代码

var object;
var loader = new THREE.JSONLoader();          

loader.load( "./quirk_logo.js", function(geometry, materials) {
     var material = new THREE.MeshFaceMaterial(materials);
     object = new THREE.Mesh(geometry, materials);

     object.scale.set(1, 1, 1);
     scene.add(object)
     render();
});

回答by Manhhailua

I think you can first export your model to .objfrom your Blender and then follow the rest part of this tutorial to get your right .jsonmodel.
http://bkcore.com/blog/3d/webgl-three-js-workflow-tips.html

我认为您可以先从.objBlender导出模型,然后按照本教程的其余部分来获取正确的.json模型。
http://bkcore.com/blog/3d/webgl-three-js-workflow-tips.html

回答by Atul

Take a look at the example i cooked up .

看一看我编造的例子。

https://github.com/master-atul/blender3js

https://github.com/master-atul/blender3js

U can see the working example here :

你可以在这里看到工作示例:

http://www.atulr.com/blender3js

http://www.atulr.com/blender3js

You can check out my code from my repo link.

您可以从我的 repo 链接中查看我的代码。

And if you wish to know the export options i used :

如果您想知道我使用的导出选项:

I directly exported the animations and everything from blender with options described here.

我使用此处描述的选项直接从搅拌机导出动画和所有内容。

https://devmatrix.wordpress.com/2013/02/27/creating-skeletal-animation-in-blender-and-exporting-it-to-three-js/

https://devmatrix.wordpress.com/2013/02/27/creating-skeletal-animation-in-blender-and-exporting-it-to-three-js/

Hope this helps Cheers :)

希望这有助于干杯:)

回答by Yazuka

This should be what you are looking for.

这应该是你正在寻找的。

http://graphic-sim.com/B_basic_export.html

http://graphic-sim.com/B_basic_export.html