keep float arrays - have to find another solution

beta.r3js.org
-=yb4f310 2017-11-29 22:24:34 +01:00
parent f185e8b1ef
commit 1b2af2fba8
3 changed files with 171 additions and 153 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__ = "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
/**
@ -13730,7 +13730,9 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
* Setup mesh vertices positions
* @type {Float32Array}
*/
var vertices = this.faces.reduce(
var vertices = new Float32Array(
this.faces.reduce(
function(result, face){
result.push(this.vertices[face.v0index].position.x);
result.push(this.vertices[face.v0index].position.y);
@ -13744,6 +13746,8 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
return result;
}.bind(this),
[]
)
);
var geometry = null;
@ -13753,12 +13757,13 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
geometry = new THREE.BufferGeometry();
geometry.addAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
/**
* Setyp mesh vertices colors
*/
var colors = this.faces.reduce(
var colors = Float32Array.from(
this.faces.reduce(
function(result, face){
result.push(1,1,1,1,1,1,1,1,1);
// result.push(face.color.r);
@ -13773,13 +13778,15 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
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
*/
var uvs = this.faces.reduce(
var uvs = Float32Array.from(
this.faces.reduce(
function(result, face) {
face.uvs[0].map(
@ -13792,10 +13799,12 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
return result;
},
[]
)
);
geometry.addAttribute('uv', new THREE.Float32BufferAttribute(uvs, 2));
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
var normals = this.faces.reduce(
var normals = Float32Array.from(
this.faces.reduce(
function(result, face) {
result.push(
@ -13816,11 +13825,11 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
return result;
},
[]
)
);
geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 ));
geometry.addAttribute('normal', new THREE.Float32BufferAttribute( normals, 3 ));
geometry.computeVertexNormals();
geometry.computeFaceNormals();
/**

View File

@ -249,7 +249,9 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
* Setup mesh vertices positions
* @type {Float32Array}
*/
var vertices = this.faces.reduce(
var vertices = new Float32Array(
this.faces.reduce(
function(result, face){
result.push(this.vertices[face.v0index].position.x);
result.push(this.vertices[face.v0index].position.y);
@ -263,6 +265,8 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
return result;
}.bind(this),
[]
)
);
var geometry = null;
@ -272,12 +276,13 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
geometry = new THREE.BufferGeometry();
geometry.addAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
/**
* Setyp mesh vertices colors
*/
var colors = this.faces.reduce(
var colors = Float32Array.from(
this.faces.reduce(
function(result, face){
result.push(1,1,1,1,1,1,1,1,1);
// result.push(face.color.r);
@ -292,13 +297,15 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
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
*/
var uvs = this.faces.reduce(
var uvs = Float32Array.from(
this.faces.reduce(
function(result, face) {
face.uvs[0].map(
@ -311,10 +318,12 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
return result;
},
[]
)
);
geometry.addAttribute('uv', new THREE.Float32BufferAttribute(uvs, 2));
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
var normals = this.faces.reduce(
var normals = Float32Array.from(
this.faces.reduce(
function(result, face) {
result.push(
@ -335,11 +344,11 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
return result;
},
[]
)
);
geometry.addAttribute('normal', new THREE.BufferAttribute( normals, 3 ));
geometry.addAttribute('normal', new THREE.Float32BufferAttribute( normals, 3 ));
geometry.computeVertexNormals();
geometry.computeFaceNormals();
/**