2016-08-19 13 views
2

我可以將幾何體轉換爲緩衝區幾何體,並且發現幾何體和材質都良好,但模型沒有顯示在窗口中。緩衝區幾何網格在使用網絡工作時不加載

這裏是我的代碼:

var myWorker = new Worker("js/respond.js"); 
myWorker.postMessage("horse.js"); 

myWorker.onmessage = function(e) { 
    geometry = new THREE.BufferGeometry(); 
    var colorattribute = new THREE.BufferAttribute(e.data.color, 3, false); 
    var uv = new THREE.BufferAttribute(e.data.uv, 3, false);//created buffer attribute with worker data 
    var normal = new THREE.BufferAttribute(e.data.normal, 3, false); 
    var position = new THREE.BufferAttribute(e.data.position, 3, false); 
    var morph = new THREE.BufferAttribute(e.data.morphAttributes, 3, false); 
    geometry.addAttribute('color', colorattribute); 
    geometry.addAttribute('uv', uv); 
    geometry.addAttribute('normal', normal); 
    geometry.addAttribute('position', position); 
    geometry.addGroup(e.data.groups[0].start, e.data.groups[0].count, e.data.groups[0].materialIndex); 
    geometry.morphAttributes.position = []; 
    geometry.morphAttributes.position.push(morph); 
    //console.log(e.data.morphAttributes); 

    // mixer = new THREE.AnimationMixer(mesh); 
    // clip = THREE.AnimationClip.CreateFromMorphTargetSequence('static', geometry.morphAttributes, 30); 
    console.log(geometry); 
    mesh = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial({color: 0xffffff, morphTargets: true})); 
    console.log(mesh); 
    scene.add(mesh); 
+0

你的問題是缺少什麼庫你使用的geomethry信息。對於大多數的圖書館來說,都有一個特殊的標籤,知道他們的人會遵循這些標籤。添加正確的庫標籤比添加正確的語言標籤要重要得多。我冒昧地添加了正確的標籤。另請注意,英文句子中只有一個「。」或三個「...」點是有效的,而不是八個。 –

回答

1

這是不可能使用庫,例如​​在網絡工作者three.js所。

可以做的是在一個工人中構建你的幾何圖形,然後將其輸入THREE.js中。從網絡工作者,您可以根據需要返回包含TypedArraysUInt32ArraysFloat32Arrays的對象以填充所有屬性。

這會導致性能提升,因爲數據已經以THREE.BufferGeometry的格式組織。