keep float arrays - have to find another solution
parent
f185e8b1ef
commit
1b2af2fba8
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__ = "Wed Nov 29 2017 22:17:53 GMT+0100 (CET)";
|
var __DATE__ = "Wed Nov 29 2017 22:24:30 GMT+0100 (CET)";
|
||||||
// END COMPILE TIME DEFINITIONS
|
// END COMPILE TIME DEFINITIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13730,21 +13730,25 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||||
* Setup mesh vertices positions
|
* Setup mesh vertices positions
|
||||||
* @type {Float32Array}
|
* @type {Float32Array}
|
||||||
*/
|
*/
|
||||||
var vertices = this.faces.reduce(
|
var vertices = new Float32Array(
|
||||||
function(result, face){
|
|
||||||
result.push(this.vertices[face.v0index].position.x);
|
this.faces.reduce(
|
||||||
result.push(this.vertices[face.v0index].position.y);
|
function(result, face){
|
||||||
result.push(this.vertices[face.v0index].position.z);
|
result.push(this.vertices[face.v0index].position.x);
|
||||||
result.push(this.vertices[face.v1index].position.x);
|
result.push(this.vertices[face.v0index].position.y);
|
||||||
result.push(this.vertices[face.v1index].position.y);
|
result.push(this.vertices[face.v0index].position.z);
|
||||||
result.push(this.vertices[face.v1index].position.z);
|
result.push(this.vertices[face.v1index].position.x);
|
||||||
result.push(this.vertices[face.v2index].position.x);
|
result.push(this.vertices[face.v1index].position.y);
|
||||||
result.push(this.vertices[face.v2index].position.y);
|
result.push(this.vertices[face.v1index].position.z);
|
||||||
result.push(this.vertices[face.v2index].position.z);
|
result.push(this.vertices[face.v2index].position.x);
|
||||||
return result;
|
result.push(this.vertices[face.v2index].position.y);
|
||||||
}.bind(this),
|
result.push(this.vertices[face.v2index].position.z);
|
||||||
[]
|
return result;
|
||||||
);
|
}.bind(this),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
var geometry = null;
|
var geometry = null;
|
||||||
|
|
||||||
|
@ -13753,74 +13757,79 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||||
|
|
||||||
geometry = new THREE.BufferGeometry();
|
geometry = new THREE.BufferGeometry();
|
||||||
|
|
||||||
geometry.addAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
|
geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setyp mesh vertices colors
|
* Setyp mesh vertices colors
|
||||||
*/
|
*/
|
||||||
var colors = this.faces.reduce(
|
var colors = Float32Array.from(
|
||||||
function(result, face){
|
this.faces.reduce(
|
||||||
result.push(1,1,1,1,1,1,1,1,1);
|
function(result, face){
|
||||||
// result.push(face.color.r);
|
result.push(1,1,1,1,1,1,1,1,1);
|
||||||
// result.push(face.color.g);
|
// result.push(face.color.r);
|
||||||
// result.push(face.color.b);
|
// result.push(face.color.g);
|
||||||
// result.push(face.color.r);
|
// result.push(face.color.b);
|
||||||
// result.push(face.color.g);
|
// result.push(face.color.r);
|
||||||
// result.push(face.color.b);
|
// result.push(face.color.g);
|
||||||
// result.push(face.color.r);
|
// result.push(face.color.b);
|
||||||
// result.push(face.color.g);
|
// result.push(face.color.r);
|
||||||
// result.push(face.color.b);
|
// result.push(face.color.g);
|
||||||
return result;
|
// result.push(face.color.b);
|
||||||
}.bind(this),
|
return result;
|
||||||
[]
|
}.bind(this),
|
||||||
);
|
[]
|
||||||
geometry.addAttribute('color', new THREE.Float32BufferAttribute(colors, 3, true));
|
)
|
||||||
|
);
|
||||||
|
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup face UVs
|
* Setup face UVs
|
||||||
*/
|
*/
|
||||||
var uvs = this.faces.reduce(
|
var uvs = Float32Array.from(
|
||||||
function(result, face) {
|
this.faces.reduce(
|
||||||
|
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));
|
||||||
|
|
||||||
|
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('uv', new THREE.Float32BufferAttribute(uvs, 2));
|
geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 ));
|
||||||
|
|
||||||
var normals = this.faces.reduce(
|
geometry.computeFaceNormals();
|
||||||
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.Float32BufferAttribute( normals, 3 ));
|
|
||||||
|
|
||||||
geometry.computeVertexNormals();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -249,21 +249,25 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||||
* Setup mesh vertices positions
|
* Setup mesh vertices positions
|
||||||
* @type {Float32Array}
|
* @type {Float32Array}
|
||||||
*/
|
*/
|
||||||
var vertices = this.faces.reduce(
|
var vertices = new Float32Array(
|
||||||
function(result, face){
|
|
||||||
result.push(this.vertices[face.v0index].position.x);
|
this.faces.reduce(
|
||||||
result.push(this.vertices[face.v0index].position.y);
|
function(result, face){
|
||||||
result.push(this.vertices[face.v0index].position.z);
|
result.push(this.vertices[face.v0index].position.x);
|
||||||
result.push(this.vertices[face.v1index].position.x);
|
result.push(this.vertices[face.v0index].position.y);
|
||||||
result.push(this.vertices[face.v1index].position.y);
|
result.push(this.vertices[face.v0index].position.z);
|
||||||
result.push(this.vertices[face.v1index].position.z);
|
result.push(this.vertices[face.v1index].position.x);
|
||||||
result.push(this.vertices[face.v2index].position.x);
|
result.push(this.vertices[face.v1index].position.y);
|
||||||
result.push(this.vertices[face.v2index].position.y);
|
result.push(this.vertices[face.v1index].position.z);
|
||||||
result.push(this.vertices[face.v2index].position.z);
|
result.push(this.vertices[face.v2index].position.x);
|
||||||
return result;
|
result.push(this.vertices[face.v2index].position.y);
|
||||||
}.bind(this),
|
result.push(this.vertices[face.v2index].position.z);
|
||||||
[]
|
return result;
|
||||||
);
|
}.bind(this),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
var geometry = null;
|
var geometry = null;
|
||||||
|
|
||||||
|
@ -272,74 +276,79 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||||
|
|
||||||
geometry = new THREE.BufferGeometry();
|
geometry = new THREE.BufferGeometry();
|
||||||
|
|
||||||
geometry.addAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
|
geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setyp mesh vertices colors
|
* Setyp mesh vertices colors
|
||||||
*/
|
*/
|
||||||
var colors = this.faces.reduce(
|
var colors = Float32Array.from(
|
||||||
function(result, face){
|
this.faces.reduce(
|
||||||
result.push(1,1,1,1,1,1,1,1,1);
|
function(result, face){
|
||||||
// result.push(face.color.r);
|
result.push(1,1,1,1,1,1,1,1,1);
|
||||||
// result.push(face.color.g);
|
// result.push(face.color.r);
|
||||||
// result.push(face.color.b);
|
// result.push(face.color.g);
|
||||||
// result.push(face.color.r);
|
// result.push(face.color.b);
|
||||||
// result.push(face.color.g);
|
// result.push(face.color.r);
|
||||||
// result.push(face.color.b);
|
// result.push(face.color.g);
|
||||||
// result.push(face.color.r);
|
// result.push(face.color.b);
|
||||||
// result.push(face.color.g);
|
// result.push(face.color.r);
|
||||||
// result.push(face.color.b);
|
// result.push(face.color.g);
|
||||||
return result;
|
// result.push(face.color.b);
|
||||||
}.bind(this),
|
return result;
|
||||||
[]
|
}.bind(this),
|
||||||
);
|
[]
|
||||||
geometry.addAttribute('color', new THREE.Float32BufferAttribute(colors, 3, true));
|
)
|
||||||
|
);
|
||||||
|
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup face UVs
|
* Setup face UVs
|
||||||
*/
|
*/
|
||||||
var uvs = this.faces.reduce(
|
var uvs = Float32Array.from(
|
||||||
function(result, face) {
|
this.faces.reduce(
|
||||||
|
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));
|
||||||
|
|
||||||
|
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('uv', new THREE.Float32BufferAttribute(uvs, 2));
|
geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 ));
|
||||||
|
|
||||||
var normals = this.faces.reduce(
|
geometry.computeFaceNormals();
|
||||||
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.Float32BufferAttribute( normals, 3 ));
|
|
||||||
|
|
||||||
geometry.computeVertexNormals();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue