compute normals for buffer geometries

beta.r3js.org
-=yb4f310 2017-11-29 21:52:10 +01:00
parent 06c21a992a
commit 73fa43a27d
3 changed files with 69 additions and 11 deletions

20
build/game-lib-min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
// COMPILE TIME DEFINITIONS (Generated via gulp)
var __DATE__ = "Tue Nov 28 2017 09:16:36 GMT+0100 (CET)";
var __DATE__ = "Wed Nov 29 2017 21:51:13 GMT+0100 (CET)";
// END COMPILE TIME DEFINITIONS
/**
@ -13803,6 +13803,35 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
);
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
var normals = Float32Array.from(
this.faces.reduce(
function(result, face) {
result.push(
face.normal.x,
face.normal.y,
face.normal.z
);
result.push(
face.normal.x,
face.normal.y,
face.normal.z
);
result.push(
face.normal.x,
face.normal.y,
face.normal.z
);
return result;
},
[]
)
);
geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 ));
geometry.computeVertexNormals();
/**
* Setup material groups - this means creating a new group for each material index change
* We know faces are sorted according to material index

View File

@ -322,6 +322,35 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
);
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
var normals = Float32Array.from(
this.faces.reduce(
function(result, face) {
result.push(
face.normal.x,
face.normal.y,
face.normal.z
);
result.push(
face.normal.x,
face.normal.y,
face.normal.z
);
result.push(
face.normal.x,
face.normal.y,
face.normal.z
);
return result;
},
[]
)
);
geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 ));
geometry.computeVertexNormals();
/**
* Setup material groups - this means creating a new group for each material index change
* We know faces are sorted according to material index