ThreeJS& Blender - 从Blend导出的Mesh在ThreeJS中不可见

时间:2014-10-27 14:56:38

标签: three.js blender

我在搅拌机中有一个模型(从http://www.blendswap.com/blends/view/4120下载),我已经以ThreeJS格式导出了这个模型。这是结果:

{

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

"scale" : 1.000000,

"materials" : [ {
    "DbgColor" : 15658734,
    "DbgIndex" : 0,
    "DbgName" : "default",
    "vertexColors" : false
}],

"vertices" : [1.45304,-0.648216,-1.45304,1.45304,-0.648216,1.45304,-1.45304,-0.648216,1.45304,-1.45304,-0.648216,-1.45304,-1.45304,0.661309,-1.45304,-1.45304,0.661309,1.45304,1.45304,0.661309,1.45304,1.45304,0.661309,-1.45304],

"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" : [],

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

"bones" : [{"parent":-1,"name":"Base_Bone","pos":[-3.88462e-09,4.46118,-0.274544],"rotq":[-3.15207e-06,0.864534,-0.502575,-1.83529e-06],"scl":[4.54636,4.54636,4.54636]},{"parent":0,"name":"spine_Controller","pos":[3.18949e-06,-0.439404,-0.389735],"rotq":[0.00348749,0.256413,-0.966471,0.0131584],"scl":[1,1,1]},{"parent":0,"name":"spine.02","pos":[5.34277e-13,-7.07805e-08,-0.166904],"rotq":[-9.78041e-07,0.235622,-0.971845,3.54896e-06],"scl":[1,1,1]},{"parent":2,"name":"spine.03","pos":[-1.66533e-14,3.72529e-09,-0.162243],"rotq":[-0.232056,-1.50512e-08,3.26627e-08,0.972702],"scl":[1,1,1]},{"parent":3,"name":"spine.04","pos":[-4.81212e-14,-7.45058e-08,-0.090176],"rotq":[-0.0354694,-3.39888e-09,-7.51124e-10,0.999371],"scl":[1,1,1]},{"parent":4,"name":"shoulder.L","pos":[0.0140999,0.107349,-0.0880517],"rotq":[-0.366786,-0.569625,0.341051,0.651674],"scl":[1,1,1]},{"parent":5,"name":"upper_arm.L","pos":[-3.72529e-09,-4.54602e-08,-0.156786],"rotq":[-0.0604418,0.0502684,-0.697246,0.712508],"scl":[1,1,1]},{"parent":6,"name":"forearm.L","pos":[-1.37563e-07,-3.72529e-09,-0.241539],"rotq":[0.166252,0.0200298,0.00303399,0.985875],"scl":[1,1,1]},{"parent":7,"name":"hand.L","pos":[1.80804e-07,6.0536e-09,-0.216896],"rotq":[0.0466005,-0.0882202,-0.702521,0.704635],"scl":[1,1,1]},{"parent":8,"name":"thumb_Controller.L","pos":[-0.0683041,-0.0426754,-0.0293453],"rotq":[-0.752982,-0.000571995,-0.00587021,0.658015],"scl":[1,1,1]},{"parent":8,"name":"thumb.01.L","pos":[-0.0369044,0.00327038,-0.0188109],"rotq":[-0.0847829,0.40622,-0.634676,0.651907],"scl":[1,1,1]},{"parent":10,"name":"thumb.02.L","pos":[4.65661e-08,-1.86265e-08,-0.0632958],"rotq":[0.0671852,0.00867713,-0.0116558,0.997635],"scl":[1,1,1]},{"parent":11,"name":"thumb.03.L","pos":[8.47504e-08,-3.72529e-08,-0.030372],"rotq":[0.110427,-0.0121641,0.00563747,0.993794],"scl":[1,1,1]},{"parent":8,"name":"palm.01_Controller.L","pos":[-0.0250351,-0.0382581,-0.027615],"rotq":[-0.747863,-0.0030183,0.000928475,0.663845],"scl":[1,1,1]},{"parent":8,"name":"palm.01.L","pos":[-0.0247865,-0.00969828,-0.0305847],"rotq":[0.0116768,0.108972,-0.0166234,0.993837],"scl":[1,1,1]},{"parent":14,"name":"finger_index.01.L","pos":[1.39698e-09,-5.15138e-08,-0.087893],"rotq":[0.0261066,0.0194109,0.0626131,0.997508],"scl":[1,1,1]},{"parent":15,"name":"finger_index.02.L","pos":[-5.58794e-09,5.56465e-08,-0.051015],"rotq":[-0.00319226,-0.00446517,-0.00153367,0.999984],"scl":[1,1,1]},{"parent":16,"name":"finger_index.03.L","pos":[2.23517e-08,-3.95812e-08,-0.0288934],"rotq":[-0.000238375,0.00553013,0.00110929,0.999984],"scl":[1,1,1]},{"parent":8,"name":"palm.02_Controller.L","pos":[-0.00613564,-0.0379131,-0.0272735],"rotq":[-0.756765,-0.000373679,0.00286476,0.653681],"scl":[1,1,1]},{"parent":8,"name":"palm.02.L","pos":[-0.00588532,-0.0105999,-0.0329824],"rotq":[0.00861685,0.0305347,0.0379183,0.998777],"scl":[1,1,1]},{"parent":19,"name":"finger_middle.01.L","pos":[-1.30385e-08,-1.98954e-07,-0.0892504],"rotq":[0.0341296,-0.00789161,0.00228843,0.999384],"scl":[1,1,1]},{"parent":20,"name":"finger_middle.02.L","pos":[9.31323e-10,1.4191e-07,-0.0569209],"rotq":[-0.00105231,-0.00209317,-0.000288841,0.999997],"scl":[1,1,1]},{"parent":21,"name":"finger_middle.03.L","pos":[2.79397e-09,-2.04425e-07,-0.0321841],"rotq":[0.000510063,0.00255101,0.000783569,0.999996],"scl":[1,1,1]},{"parent":8,"name":"palm.03_Controller.L","pos":[0.0120405,-0.0379479,-0.0269506],"rotq":[-0.752674,-0.00061697,0.00287802,0.658387],"scl":[1,1,1]},{"parent":8,"name":"palm.03.L","pos":[0.0117112,-0.00811656,-0.0327077],"rotq":[0.0254185,-0.0423059,0.0370735,0.998093],"scl":[1,1,1]},{"parent":24,"name":"finger_ring.01.L","pos":[7.45058e-09,5.68107e-08,-0.0871205],"rotq":[0.0157294,-0.0196917,0.00517667,0.999669],"scl":[1,1,1]},{"parent":25,"name":"finger_ring.02.L","pos":[0,4.23752e-08,-0.0520437],"rotq":[0.00346145,0.000296477,-0.000712732,0.999994],"scl":[1,1,1]},{"parent":26,"name":"finger_ring.03.L","pos":[-3.72529e-09,-2.6077e-08,-0.0296788],"rotq":[0.0103584,-0.00126846,-8.82066e-05,0.999946],"scl":[1,1,1]},{"parent":8,"name":"palm.04_Controller.L","pos":[0.0294525,-0.0379501,-0.0273554],"rotq":[-0.75111,-0.00635432,0.00975096,0.660074],"scl":[1,1,1]},{"parent":8,"name":"palm.04.L","pos":[0.0294058,-0.00417163,-0.0313179],"rotq":[0.0281065,-0.0969915,0.0634148,0.992865],"scl":[1,1,1]},{"parent":29,"name":"finger_pinky.01.L","pos":[2.23517e-08,-8.6613e-08,-0.0803671],"rotq":[0.0195471,-0.064806,0.0353482,0.99708],"scl":[1,1,1]},{"parent":30,"name":"finger_pinky.02.L","pos":[1.49012e-08,3.72529e-09,-0.0447478],"rotq":[0.000326434,-0.000735238,0.000348568,1],"scl":[1,1,1]},{"parent":31,"name":"finger_pinky.03.L","pos":[-1.49012e-08,-1.15484e-07,-0.0230973],"rotq":[-0.00114785,-0.000621325,-0.00071641,0.999999],"scl":[1,1,1]},{"parent":4,"name":"shoulder.L.001","pos":[-0.0141001,0.107349,-0.0880517],"rotq":[-0.370994,0.566894,-0.345867,0.649131],"scl":[1,1,1]},{"parent":33,"name":"upper_arm.L.001","pos":[-9.31323e-10,1.71858e-07,-0.156786],"rotq":[0.0502957,-0.060419,-0.702424,0.707404],"scl":[1,1,1]},{"parent":34,"name":"forearm.L.001","pos":[-1.13796e-07,9.31323e-09,-0.241539],"rotq":[0.0204615,0.1662,0.985778,0.0141796],"scl":[1,1,1]},{"parent":35,"name":"hand.L.001","pos":[-4.01051e-08,2.79397e-09,-0.216896],"rotq":[-0.0884872,0.046091,-0.702563,0.704593],"scl":[1,1,1]},{"parent":36,"name":"thumb_Controller.L.001","pos":[-0.0684243,0.0424823,-0.0293454],"rotq":[0.00227442,0.752978,-0.657977,0.00921574],"scl":[1,1,1]},{"parent":36,"name":"thumb.01.L.001","pos":[-0.036895,-0.00337458,-0.018811],"rotq":[-0.41495,0.00439629,-0.761208,0.498357],"scl":[1,1,1]},{"parent":38,"name":"thumb.02.L.001","pos":[1.1269e-07,-3.72529e-08,-0.0632959],"rotq":[0.0644261,0.0209377,-0.0433643,0.99676],"scl":[1,1,1]},{"parent":39,"name":"thumb.03.L.001","pos":[4.28408e-08,9.31323e-08,-0.0303719],"rotq":[0.0918,0.0625677,0.00359743,0.993803],"scl":[1,1,1]},{"parent":36,"name":"palm.01_Controller.L.001","pos":[-0.0251431,0.0381872,-0.0276151],"rotq":[-0.0038138,0.74786,-0.663826,-0.00511879],"scl":[1,1,1]},{"parent":36,"name":"palm.01.L.001","pos":[-0.0248138,0.00962824,-0.0305848],"rotq":[-0.108579,-0.0148931,-0.993926,-0.00995566],"scl":[1,1,1]},{"parent":42,"name":"finger_index.01.L.001","pos":[1.11759e-08,3.29164e-08,-0.0878929],"rotq":[0.0256096,-0.0200615,0.0187849,0.999294],"scl":[1,1,1]},{"parent":43,"name":"finger_index.02.L.001","pos":[-5.58794e-09,1.00466e-07,-0.0510151],"rotq":[-0.00260987,0.00482873,0.0200336,0.999784],"scl":[1,1,1]},{"parent":44,"name":"finger_index.03.L.001","pos":[2.23517e-08,8.75443e-08,-0.0288934],"rotq":[-0.000932829,-0.00545569,-0.0185078,0.999813],"scl":[1,1,1]},{"parent":36,"name":"palm.02_Controller.L.001","pos":[-0.00624267,0.0378956,-0.0272735],"rotq":[0.00188735,0.756763,-0.653687,0.000288296],"scl":[1,1,1]},{"parent":36,"name":"palm.02.L.001","pos":[-0.00591523,0.0105831,-0.0329825],"rotq":[-0.0307926,-0.00764273,-0.999491,-0.00335627],"scl":[1,1,1]},{"parent":47,"name":"finger_middle.01.L.001","pos":[1.86265e-09,-1.07088e-07,-0.0892504],"rotq":[0.0345216,0.00594766,-0.012016,0.999314],"scl":[1,1,1]},{"parent":48,"name":"finger_middle.02.L.001","pos":[-2.79397e-09,1.67725e-07,-0.056921],"rotq":[-0.000937477,0.00214737,0.00759602,0.999968],"scl":[1,1,1]},{"parent":49,"name":"finger_middle.03.L.001","pos":[-3.72529e-09,-7.10133e-09,-0.0321842],"rotq":[0.000323665,-0.00258107,0.0103168,0.999943],"scl":[1,1,1]},{"parent":36,"name":"palm.03_Controller.L.001","pos":[0.0119334,0.0379818,-0.0269507],"rotq":[0.000784713,0.752674,-0.658393,-0.000872428],"scl":[1,1,1]},{"parent":36,"name":"palm.03.L.001","pos":[0.0116882,0.0081496,-0.0327077],"rotq":[-0.0417454,0.0263288,0.998702,0.0126219],"scl":[1,1,1]},{"parent":52,"name":"finger_ring.01.L.001","pos":[-7.45058e-09,-1.234e-07,-0.0871204],"rotq":[0.0164006,0.0191361,-0.0167514,0.999542],"scl":[1,1,1]},{"parent":53,"name":"finger_ring.02.L.001","pos":[-1.49012e-08,-2.54484e-07,-0.0520437],"rotq":[0.00344704,-0.000433122,0.017268,0.999845],"scl":[1,1,1]},{"parent":54,"name":"finger_ring.03.L.001","pos":[-1.39698e-09,-2.8871e-08,-0.0296789],"rotq":[0.010388,0.000998136,-0.0299645,0.999497],"scl":[1,1,1]},{"parent":36,"name":"palm.04_Controller.L.001","pos":[0.0293453,0.038033,-0.0273554],"rotq":[0.00503468,0.75112,-0.660085,-0.00904701],"scl":[1,1,1]},{"parent":36,"name":"palm.04.L.001","pos":[0.0293939,0.00425465,-0.0313179],"rotq":[-0.0966088,0.0293964,0.99376,0.0473721],"scl":[1,1,1]},{"parent":57,"name":"finger_pinky.01.L.001","pos":[-7.45058e-09,-6.51926e-09,-0.0803671],"rotq":[0.0243421,0.0631614,0.00997108,0.997657],"scl":[1,1,1]},{"parent":58,"name":"finger_pinky.02.L.001","pos":[-5.58794e-09,1.93715e-07,-0.0447477],"rotq":[0.000407814,0.000693327,-0.00687187,0.999976],"scl":[1,1,1]},{"parent":59,"name":"finger_pinky.03.L.001","pos":[1.86265e-08,-2.8871e-07,-0.0230975],"rotq":[-0.00108006,0.000732799,-0.00654066,0.999978],"scl":[1,1,1]},{"parent":0,"name":"neck_Controller","pos":[2.06795e-06,-0.295536,-0.59375],"rotq":[0.00405876,-0.261664,0.965034,0.0149668],"scl":[1,1,1]},{"parent":4,"name":"neck_base","pos":[-3.10862e-14,3.7253e-09,-0.0901205],"rotq":[0.345807,4.0891e-08,-4.81046e-09,0.938306],"scl":[1,1,1]},{"parent":62,"name":"neck.01","pos":[6.20892e-14,2.23517e-08,-0.0911808],"rotq":[0.0972022,1.04856e-07,7.97366e-08,0.995265],"scl":[1,1,1]},{"parent":63,"name":"neck.02","pos":[-8.21565e-15,-1.21072e-08,-0.0573017],"rotq":[-0.05593,4.79096e-09,-6.15004e-08,0.998435],"scl":[1,1,1]},{"parent":64,"name":"neck.03","pos":[-6.10623e-16,-2.98023e-08,-0.0608694],"rotq":[-0.145301,1.00167e-08,-1.33748e-08,0.989388],"scl":[1,1,1]},{"parent":0,"name":"thigh.L","pos":[-0.0654458,-0.0427966,-0.0914774],"rotq":[0.0303704,0.956932,0.267858,0.107753],"scl":[1,1,1]},{"parent":66,"name":"shin.L","pos":[-1.46538e-08,8.78208e-09,-0.463457],"rotq":[0.0683877,0.113482,-0.00769007,0.991154],"scl":[1,1,1]},{"parent":67,"name":"foot.L","pos":[7.80256e-09,3.71074e-09,-0.491625],"rotq":[-0.485727,-0.0120631,0.0334887,0.873386],"scl":[1,1,1]},{"parent":68,"name":"toe.L","pos":[-3.19415e-09,9.31323e-10,-0.136075],"rotq":[-0.317111,-0.00638343,-0.000738404,0.948367],"scl":[1,1,1]},{"parent":0,"name":"thigh.L.001","pos":[0.0654464,-0.0427956,-0.0914774],"rotq":[0.0299789,-0.956945,-0.267812,0.107866],"scl":[1,1,1]},{"parent":70,"name":"shin.L.001","pos":[-1.6691e-08,-9.96806e-10,-0.463458],"rotq":[0.0683197,-0.113523,0.00745817,0.991156],"scl":[1,1,1]},{"parent":71,"name":"foot.L.001","pos":[1.85082e-10,-6.60293e-09,-0.491626],"rotq":[-0.484508,0.036448,0.0101082,0.873969],"scl":[1,1,1]},{"parent":72,"name":"toe.L.001","pos":[9.25502e-09,-3.72529e-09,-0.136075],"rotq":[-0.316319,0.0233031,-0.0435689,0.947365],"scl":[1,1,1]}],

"skinIndices" : [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],

"skinWeights" : [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],

"animations" : []


}

我使用JSONLoader加载此模型,但我的浏览器中只有一个黑色方块,没有任何网格。

var WIDTH = window.innerWidth / 2,
    HEIGHT = window.innerHeight / 2;

var renderer = new THREE.WebGLRenderer();
renderer.setSize( WIDTH, HEIGHT );
document.body.appendChild( renderer.domElement );

scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, WIDTH / HEIGHT, 0.1, 1000 );

camera.position.z = 5;

var loader = new THREE.JSONLoader(); 
loader.load("avatar/skeleton.js", function( geometry, materials ) {

    mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );

    mesh.position.x = 0;
    mesh.position.y = 0;
    mesh.position.z = 0;

    scene.add( mesh );

    renderer.render( scene, camera );

});

有人知道我做错了什么吗?

由于

1 个答案:

答案 0 :(得分:0)

您需要为场景添加灯光,如下所示:

var directionalLight = new THREE.DirectionalLight(0xffffff, 1.2);
directionalLight.position.set(0, -1, 0);
scene.add(directionalLight);

这是我用来测试我的理论的小提琴,但如果你只是将它们添加到文件的顶部,它应该有用。

http://jsfiddle.net/dmt23/6qwswa25/