2017-12-09 4 views
0

이 문제를 해결하기 위해 이미 몇 가지 질문을했지만, 여전히 외부 객체 (블렌더)를로드 할 수 없습니다.은 3JS 장면에서 블렌더 모델을로드 할 수 없습니다.

Basicly을 나는 ThreeJS JSON 파일로 수출이 내 JSON 파일입니다 : 내가 법선 배열에 일부 데이터를 생략

{ 
    "textures":[], 
    "animations":[{ 
     "fps":24, 
     "tracks":[], 
     "name":"default" 
    }], 
    "geometries":[{ 
     "materials":[{ 
      "colorEmissive":[0,0,0], 
      "DbgName":"Material.113", 
      "DbgIndex":0, 
      "shading":"phong", 
      "specularCoef":50, 
      "transparent":false, 
      "visible":true, 
      "blending":1, 
      "depthWrite":true, 
      "DbgColor":15658734, 
      "doubleSided":false, 
      "wireframe":false, 
      "colorSpecular":[0.5,0.5,0.5], 
      "opacity":1, 
      "depthTest":true, 
      "colorDiffuse":[0.0396404,0.0396404,0.0396404] 
     },{ 
      "colorEmissive":[0,0,0], 
      "DbgName":"Material.112", 
      "DbgIndex":1, 
      "shading":"lambert", 
      "transparent":false, 
      "visible":true, 
      "blending":1, 
      "depthWrite":true, 
      "DbgColor":15597568, 
      "doubleSided":false, 
      "wireframe":false, 
      "opacity":1, 
      "depthTest":true, 
      "colorDiffuse":[0.8,0.443066,0.182712] 
     },{ 
      "colorEmissive":[0,0,0], 
      "DbgName":"Material.114", 
      "DbgIndex":2, 
      "shading":"phong", 
      "specularCoef":50, 
      "transparent":false, 
      "visible":true, 
      "blending":1, 
      "depthWrite":true, 
      "DbgColor":60928, 
      "doubleSided":false, 
      "wireframe":false, 
      "colorSpecular":[0.5,0.5,0.5], 
      "opacity":1, 
      "depthTest":true, 
      "colorDiffuse":[0.8,0.614231,0.407028] 
     }], 
     "data":{ 
      "uvs":[], 
      "normals":[-0,0,1,-1,-0,0,1,-0,-0,-0,-1,0,-1,4.76837e-07,0,-1,-0,0,-2.38419e-07,-1,2.38419e-07,-2.38419e-07,-1,2.38419e-07,-2.38419e-07,-1,2.38419e-07 }, 
     "type":"Geometry", 
     "uuid":"639CD2C2-56FB-4D8F-B53B-B8C3E040803C", 
     "name":"Cube.111Geometry.4" 
    }], 
    "object":{ 
     "children":[{ 
      "name":"Cube.001", 
      "uuid":"1213E565-1F93-497F-B4F0-843C1F17BCAD", 
      "matrix":[-0.6,0,0,0,0,0,0.6,0,0,0.6,0,0,-0.866864,0.6,2.6259,1], 
      "visible":true, 
      "type":"Mesh", 
      "material":["87C3E87D-CD72-4A6F-963A-84474DFE4059","FABD8A0F-02B0-4665-A21E-5CD1E4DDD518","E4331AC2-6CAC-4BCE-A5BD-89A811DD4D76"], 
      "castShadow":true, 
      "receiveShadow":true, 
      "geometry":"639CD2C2-56FB-4D8F-B53B-B8C3E040803C" 
     }], 
     "matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1], 
     "type":"Scene", 
     "uuid":"23736546-1486-4089-967C-6DA05CB3F49C" 
    }, 
    "materials":[{ 
     "vertexColors":0, 
     "color":13398062, 
     "uuid":"FABD8A0F-02B0-4665-A21E-5CD1E4DDD518", 
     "depthWrite":true, 
     "depthTest":true, 
     "type":"MeshLambertMaterial", 
     "blending":1, 
     "emissive":0, 
     "name":"Material.112" 
    },{ 
     "vertexColors":0, 
     "shininess":50, 
     "color":657930, 
     "uuid":"87C3E87D-CD72-4A6F-963A-84474DFE4059", 
     "specular":8355711, 
     "depthWrite":true, 
     "depthTest":true, 
     "type":"MeshPhongMaterial", 
     "blending":1, 
     "emissive":0, 
     "name":"Material.113" 
    },{ 
     "vertexColors":0, 
     "shininess":50, 
     "color":13409383, 
     "uuid":"E4331AC2-6CAC-4BCE-A5BD-89A811DD4D76", 
     "specular":8355711, 
     "depthWrite":true, 
     "depthTest":true, 
     "type":"MeshPhongMaterial", 
     "blending":1, 
     "emissive":0, 
     "name":"Material.114" 
    }], 
    "metadata":{ 
     "generator":"io_three", 
     "sourceFile":"DAMA1.blend", 
     "version":4.4, 
     "type":"Object" 
    }, 
    "images":[] 
} 

하지만 basicly 나는이처럼로드하려고 :

var objLoader =new THREE.ObjectLoader(); 
objLoader.load('assets/dama.json', function (geometry) { 
    this.scene.add(geometry); 
}); 

이 파일을 발견한다 그러나 나는이 같은 오류가 발생합니다 : 가 정의되지 않은

의 특성 '현장'을 읽을 수 없습니다 어쩌면 뭔가있다 내 보낸 설정으로 처리하지만 이미 버퍼 지형을 기하학으로 변경하고 장면 체크 상자를 추가했는데 잘못 무엇을 했습니까? S

답변

0

잘 모르겠습니다. 하지만 당신은

var scope = this; 
var objLoader =new THREE.ObjectLoader(); 
objLoader.load('assets/dama.json', function (geometry) { 
    scope.scene.add(geometry); 
}); 

나는 장면이 객체의 속성입니다 당신이 this.scene로 불리는 이유가 이유가 될 수 있다는 희망이 시도 할 수 있습니다. 이 문제는 이라고 할 때이로드 함수 안에 넣으면 THREE.ObjectLoader을 참조합니다. 따라서 을 사용하여 기본 객체를 참조해야하는 경우 먼저 사본을 가져와 사용해야합니다.

당신이 장면을 개최 객체를 사용하지 않는 경우, 단지 대신 scope.scene.add()scene.add(geometry)this.scene.add()

전화
관련 문제