no float32 array

beta.r3js.org
-=yb4f310 2017-11-29 22:13:27 +01:00
parent 1cdc2dd76c
commit 742614777e
3 changed files with 139 additions and 157 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) // COMPILE TIME DEFINITIONS (Generated via gulp)
var __DATE__ = "Wed Nov 29 2017 22:00:45 GMT+0100 (CET)"; var __DATE__ = "Wed Nov 29 2017 22:13:03 GMT+0100 (CET)";
// END COMPILE TIME DEFINITIONS // END COMPILE TIME DEFINITIONS
/** /**
@ -13730,25 +13730,21 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
* Setup mesh vertices positions * Setup mesh vertices positions
* @type {Float32Array} * @type {Float32Array}
*/ */
var vertices = new Float32Array( var vertices = this.faces.reduce(
function(result, face){
this.faces.reduce( result.push(this.vertices[face.v0index].position.x);
function(result, face){ result.push(this.vertices[face.v0index].position.y);
result.push(this.vertices[face.v0index].position.x); result.push(this.vertices[face.v0index].position.z);
result.push(this.vertices[face.v0index].position.y); result.push(this.vertices[face.v1index].position.x);
result.push(this.vertices[face.v0index].position.z); result.push(this.vertices[face.v1index].position.y);
result.push(this.vertices[face.v1index].position.x); result.push(this.vertices[face.v1index].position.z);
result.push(this.vertices[face.v1index].position.y); result.push(this.vertices[face.v2index].position.x);
result.push(this.vertices[face.v1index].position.z); result.push(this.vertices[face.v2index].position.y);
result.push(this.vertices[face.v2index].position.x); result.push(this.vertices[face.v2index].position.z);
result.push(this.vertices[face.v2index].position.y); return result;
result.push(this.vertices[face.v2index].position.z); }.bind(this),
return result; []
}.bind(this), );
[]
)
);
var geometry = null; var geometry = null;
@ -13762,71 +13758,66 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
/** /**
* Setyp mesh vertices colors * Setyp mesh vertices colors
*/ */
var colors = Float32Array.from( var colors = this.faces.reduce(
this.faces.reduce( function(result, face){
function(result, face){ result.push(1,1,1,1,1,1,1,1,1);
result.push(1,1,1,1,1,1,1,1,1); // result.push(face.color.r);
// result.push(face.color.r); // result.push(face.color.g);
// result.push(face.color.g); // result.push(face.color.b);
// result.push(face.color.b); // result.push(face.color.r);
// result.push(face.color.r); // result.push(face.color.g);
// result.push(face.color.g); // result.push(face.color.b);
// result.push(face.color.b); // result.push(face.color.r);
// result.push(face.color.r); // result.push(face.color.g);
// result.push(face.color.g); // result.push(face.color.b);
// result.push(face.color.b); return result;
return result; }.bind(this),
}.bind(this), []
[] );
)
);
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true)); geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true));
/** /**
* Setup face UVs * Setup face UVs
*/ */
var uvs = Float32Array.from( var uvs = this.faces.reduce(
this.faces.reduce( function(result, face) {
function(result, face) {
face.uvs[0].map( face.uvs[0].map(
function(uv) { function(uv) {
result.push(uv.x); result.push(uv.x);
result.push(uv.y); result.push(uv.y);
} }
); );
return result; return result;
}, },
[] []
) );
);
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2)); geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
var normals = Float32Array.from( var normals = this.faces.reduce(
this.faces.reduce( function(result, face) {
function(result, face) {
result.push( result.push(
face.normal.x, face.normal.x,
face.normal.y, face.normal.y,
face.normal.z face.normal.z
); );
result.push( result.push(
face.normal.x, face.normal.x,
face.normal.y, face.normal.y,
face.normal.z face.normal.z
); );
result.push( result.push(
face.normal.x, face.normal.x,
face.normal.y, face.normal.y,
face.normal.z face.normal.z
); );
return result; return result;
}, },
[] []
)
); );
geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 )); geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 ));
geometry.computeVertexNormals(); geometry.computeVertexNormals();

View File

@ -249,25 +249,21 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
* Setup mesh vertices positions * Setup mesh vertices positions
* @type {Float32Array} * @type {Float32Array}
*/ */
var vertices = new Float32Array( var vertices = this.faces.reduce(
function(result, face){
this.faces.reduce( result.push(this.vertices[face.v0index].position.x);
function(result, face){ result.push(this.vertices[face.v0index].position.y);
result.push(this.vertices[face.v0index].position.x); result.push(this.vertices[face.v0index].position.z);
result.push(this.vertices[face.v0index].position.y); result.push(this.vertices[face.v1index].position.x);
result.push(this.vertices[face.v0index].position.z); result.push(this.vertices[face.v1index].position.y);
result.push(this.vertices[face.v1index].position.x); result.push(this.vertices[face.v1index].position.z);
result.push(this.vertices[face.v1index].position.y); result.push(this.vertices[face.v2index].position.x);
result.push(this.vertices[face.v1index].position.z); result.push(this.vertices[face.v2index].position.y);
result.push(this.vertices[face.v2index].position.x); result.push(this.vertices[face.v2index].position.z);
result.push(this.vertices[face.v2index].position.y); return result;
result.push(this.vertices[face.v2index].position.z); }.bind(this),
return result; []
}.bind(this), );
[]
)
);
var geometry = null; var geometry = null;
@ -281,71 +277,66 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
/** /**
* Setyp mesh vertices colors * Setyp mesh vertices colors
*/ */
var colors = Float32Array.from( var colors = this.faces.reduce(
this.faces.reduce( function(result, face){
function(result, face){ result.push(1,1,1,1,1,1,1,1,1);
result.push(1,1,1,1,1,1,1,1,1); // result.push(face.color.r);
// result.push(face.color.r); // result.push(face.color.g);
// result.push(face.color.g); // result.push(face.color.b);
// result.push(face.color.b); // result.push(face.color.r);
// result.push(face.color.r); // result.push(face.color.g);
// result.push(face.color.g); // result.push(face.color.b);
// result.push(face.color.b); // result.push(face.color.r);
// result.push(face.color.r); // result.push(face.color.g);
// result.push(face.color.g); // result.push(face.color.b);
// result.push(face.color.b); return result;
return result; }.bind(this),
}.bind(this), []
[] );
)
);
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true)); geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true));
/** /**
* Setup face UVs * Setup face UVs
*/ */
var uvs = Float32Array.from( var uvs = this.faces.reduce(
this.faces.reduce( function(result, face) {
function(result, face) {
face.uvs[0].map( face.uvs[0].map(
function(uv) { function(uv) {
result.push(uv.x); result.push(uv.x);
result.push(uv.y); result.push(uv.y);
} }
); );
return result; return result;
}, },
[] []
) );
);
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2)); geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
var normals = Float32Array.from( var normals = this.faces.reduce(
this.faces.reduce( function(result, face) {
function(result, face) {
result.push( result.push(
face.normal.x, face.normal.x,
face.normal.y, face.normal.y,
face.normal.z face.normal.z
); );
result.push( result.push(
face.normal.x, face.normal.x,
face.normal.y, face.normal.y,
face.normal.z face.normal.z
); );
result.push( result.push(
face.normal.x, face.normal.x,
face.normal.y, face.normal.y,
face.normal.z face.normal.z
); );
return result; return result;
}, },
[] []
)
); );
geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 )); geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 ));
geometry.computeVertexNormals(); geometry.computeVertexNormals();