compute normals for buffer geometries
parent
06c21a992a
commit
73fa43a27d
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
// 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
|
// END COMPILE TIME DEFINITIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13803,6 +13803,35 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||||
);
|
);
|
||||||
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
|
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
|
* Setup material groups - this means creating a new group for each material index change
|
||||||
* We know faces are sorted according to material index
|
* We know faces are sorted according to material index
|
||||||
|
|
|
@ -322,6 +322,35 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||||
);
|
);
|
||||||
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
|
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
|
* Setup material groups - this means creating a new group for each material index change
|
||||||
* We know faces are sorted according to material index
|
* We know faces are sorted according to material index
|
||||||
|
|
Loading…
Reference in New Issue