2017-04-12 148 views
0

我從PLY文件(超過60Mb)加載非常複雜的3D模型。在我的項目中,我需要使用軌道控制來移動物體。顯然,由於大文件的操作在一些couputers中非常緩慢。爲了加快事情有點我想我的幾何圖形轉換成一個緩衝的幾何形狀與下面的代碼行:加載PLY文件時THREE JS從Geometry轉換爲BufferGeometry不工作

this.loader.load('assets/data/GuyFawkesMask.ply', function (geometry) { 
     var bufferGeometry = new THREE.BufferGeometry().fromGeometry(geometry); 

     console.log(bufferGeometry); 

     // Create object 
     let object = 
      new THREE.Mesh(bufferGeometry, 
      new THREE.MeshPhongMaterial(
       { 
        color: 0xFFFFFF, 
        //vertexColors: THREE.VertexColors, 
        shading: THREE.FlatShading, 
        shininess: 0 
       }) 
      ); 

     _this.add(object); 
    }); 

但我收到以下錯誤:

TypeError: Cannot read property '0' of undefined at DirectGeometry.fromGeometry (three.module.js:12219) at BufferGeometry.fromGeometry (three.module.js:14307) at threed-viewer.component.ts:379 at index.js:52 at XMLHttpRequest. (three.module.js:29263) at ZoneDelegate.webpackJsonp.818.ZoneDelegate.invokeTask (zone.js:367) at Object.onInvokeTask (ng_zone.js:264) at ZoneDelegate.webpackJsonp.818.ZoneDelegate.invokeTask (zone.js:366) at Zone.webpackJsonp.818.Zone.runTask (zone.js:166) at XMLHttpRequest.ZoneTask.invoke (zone.js:420)

任何想法?

謝謝

迪諾

+0

如果我得到它的權利,尋找到'PLYLoader的源代碼。 js',回調函數返回的'geometry'已經是'THREE.BufferGeometry()'。 – prisoner849

+0

天哪,你是對的! – Dino

回答

0

剛剛發佈以供將來參考prisoner849評論(作爲一個答案):

If I get it right, looking into the source code of PLYLoader.js, the geometry, which the callback function returns, is already of THREE.BufferGeometry()