beta.r3js.org
polygonboutique 2016-11-01 16:08:22 +01:00
parent 3b6a61ef69
commit 631115a875
7 changed files with 48 additions and 68 deletions

File diff suppressed because one or more lines are too long

View File

@ -235,7 +235,7 @@ GameLib.D3.ComponentInterface.prototype.onUpdate = function(
deltaTime,
parentEntity
) {
//this.parentEntity.mesh.material.color = new THREE.Color(Math.random(), Math.random(), Math.random());
};
GameLib.D3.ComponentInterface.prototype.onLateUpdate = function(
@ -256,7 +256,7 @@ GameLib.D3.ComponentInterface.prototype.onSetParentEntity = function(
parentScene,
parentEntity
) {
//parentEntity.mesh.material = new THREE.MeshBasicMaterial();
};
/**
* Engine Superset
@ -3187,15 +3187,16 @@ GameLib.D3.Scene = function(
}
this.entities = entities;
// todo: remove this from the scene class
// changes
this.threeScene = new THREE.Scene();
this.threeScene.render = true;
//this.threeScene = new THREE.Scene();
//this.threeScene.render = true;
// assoc array
this.meshIdToMesh = {};
//this.meshIdToMesh = {};
// assoc array
this.componentIdToComponent = {};
//this.componentIdToComponent = {};
};
/**
@ -3864,14 +3865,13 @@ GameLib.D3.Shape = function(
numSegments,
heightmap
) {
this.engine = engine;
this.engine.isNotCannonThrow();
this.shapeType = shapeType;
this.instance = this.createInstance();
if (typeof scale == 'undefined') {
scale = new GameLib.D3.Vector3(1, 1, 1)
}
@ -3922,6 +3922,7 @@ GameLib.D3.Shape = function(
}
this.heightmap = heightmap;
this.instance = this.createInstance();
};
/**
@ -4792,6 +4793,15 @@ GameLib.D3.Utils.Extend = function(
}
}
};
GameLib.D3.Utils.Raycast = function (
from,
to,
options,
world
) {
console.log("not implemented yet");
};
GameLib.D3.Vector2 = function(x, y) {
this.x = 0;
@ -5745,7 +5755,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShapeDivided = function(
/**
* @param graphics GameLib.D3.Graphics
* @param graphicsMesh THREE.Mesh
* @returns {GameLib.D3.RigidBody}
* @returns {GameLib.D3.Shape}
* @constructor
*/
GameLib.D3.World.prototype.generateTriangleMeshShape = function(
@ -5767,7 +5777,6 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
vertex.y * graphicsMesh.scale.y,
vertex.z * graphicsMesh.scale.z
));
}
var triangleFaces = [];
@ -5777,9 +5786,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
var i2 = graphicsMesh.geometry.faces[f].c;
triangleFaces.push([
i0,
i1,
i2
i0, i1, i2
]);
}
@ -5824,18 +5831,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
processedFaces++;
}
var shape = GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, graphicsMesh.scale, vertices, faces);
var body = GameLib.D3.RigidBody(this.engine, 0, 12);
body.addShape(shape);
this.addRigidBody(body);
// process the mesh children recursively
for(var c in graphicsMesh.children) {
this.generateTriangleMeshShape(graphics, graphicsMesh.children[c]);
}
return body;
return new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, {x : 1, y : 1, z : 1}, vertices, faces);
};
/**
@ -5875,7 +5871,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
var raycastResult = new this.engine.instance.RaycastResult();
var brokenFaceIndicators = [];
var wireframeMeshes = [];
var totalFaces = 0;
var totalBrokenFaces = 0;
@ -5883,7 +5878,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
var fixedTriangleMeshObjects = [];
for(var i in triangleMeshShapes) {
var trimesh = triangleMeshShapes[i];
var trimesh = triangleMeshShapes[i].instance;
var brokenFaces = [];
totalFaces += (trimesh.indices.length / 3);
@ -5960,8 +5955,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
);
wireframeMesh.add( arrow );
wireframeMeshes.add(wireframeMesh);
brokenFaceIndicators.push(wireframeMesh);
}
@ -6090,7 +6083,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
for(var e in bFaceIndexed) {
var element = bFaceIndexed[e];
var shape = new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, null, element.vertices, element.indices);
var shape = new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, { x : 1, y : 1, z : 1 }, element.vertices, element.indices);
if(createCompoundShape) {
triangleMeshBody.addShape(shape);
@ -6098,13 +6091,11 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
var body = new GameLib.D3.RigidBody(this.engine, 0, 12);
body.addShape(shape);
this.instance.addRigidBody(body);
this.addRigidBody(body);
}
fixedTriangleMeshObjects.push(shape);
totalFixedFaces += element.indices.length / 3;
console.log("created mesh shape", element.indices.length / 3);
}
// TODO: remove duplicate indices
@ -6127,8 +6118,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
return {
brokenFaceIndicators : brokenFaceIndicators,
fixedTriangleMeshShapes : fixedTriangleMeshObjects,
wireframeMeshes : wireframeMeshes
fixedTriangleMeshShapes : fixedTriangleMeshObjects
};
};
if (typeof module !== 'undefined') {

View File

@ -43,7 +43,7 @@ GameLib.D3.ComponentInterface.prototype.onUpdate = function(
deltaTime,
parentEntity
) {
//this.parentEntity.mesh.material.color = new THREE.Color(Math.random(), Math.random(), Math.random());
};
GameLib.D3.ComponentInterface.prototype.onLateUpdate = function(
@ -64,5 +64,5 @@ GameLib.D3.ComponentInterface.prototype.onSetParentEntity = function(
parentScene,
parentEntity
) {
//parentEntity.mesh.material = new THREE.MeshBasicMaterial();
};

View File

@ -81,6 +81,7 @@ GameLib.D3.Scene = function(
}
this.entities = entities;
// todo: remove this from the scene class
// changes
this.threeScene = new THREE.Scene();
this.threeScene.render = true;

View File

@ -29,14 +29,13 @@ GameLib.D3.Shape = function(
numSegments,
heightmap
) {
this.engine = engine;
this.engine.isNotCannonThrow();
this.shapeType = shapeType;
this.instance = this.createInstance();
if (typeof scale == 'undefined') {
scale = new GameLib.D3.Vector3(1, 1, 1)
}
@ -87,6 +86,7 @@ GameLib.D3.Shape = function(
}
this.heightmap = heightmap;
this.instance = this.createInstance();
};
/**

View File

@ -8,4 +8,13 @@ GameLib.D3.Utils.Extend = function(
child.prototype[prop] = parent.prototype[prop];
}
}
};
GameLib.D3.Utils.Raycast = function (
from,
to,
options,
world
) {
console.log("not implemented yet");
};

View File

@ -451,7 +451,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShapeDivided = function(
/**
* @param graphics GameLib.D3.Graphics
* @param graphicsMesh THREE.Mesh
* @returns {GameLib.D3.RigidBody}
* @returns {GameLib.D3.Shape}
* @constructor
*/
GameLib.D3.World.prototype.generateTriangleMeshShape = function(
@ -473,7 +473,6 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
vertex.y * graphicsMesh.scale.y,
vertex.z * graphicsMesh.scale.z
));
}
var triangleFaces = [];
@ -483,9 +482,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
var i2 = graphicsMesh.geometry.faces[f].c;
triangleFaces.push([
i0,
i1,
i2
i0, i1, i2
]);
}
@ -530,18 +527,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
processedFaces++;
}
var shape = GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, graphicsMesh.scale, vertices, faces);
var body = GameLib.D3.RigidBody(this.engine, 0, 12);
body.addShape(shape);
this.addRigidBody(body);
// process the mesh children recursively
for(var c in graphicsMesh.children) {
this.generateTriangleMeshShape(graphics, graphicsMesh.children[c]);
}
return body;
return new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, {x : 1, y : 1, z : 1}, vertices, faces);
};
/**
@ -581,7 +567,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
var raycastResult = new this.engine.instance.RaycastResult();
var brokenFaceIndicators = [];
var wireframeMeshes = [];
var totalFaces = 0;
var totalBrokenFaces = 0;
@ -589,7 +574,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
var fixedTriangleMeshObjects = [];
for(var i in triangleMeshShapes) {
var trimesh = triangleMeshShapes[i];
var trimesh = triangleMeshShapes[i].instance;
var brokenFaces = [];
totalFaces += (trimesh.indices.length / 3);
@ -666,8 +651,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
);
wireframeMesh.add( arrow );
wireframeMeshes.add(wireframeMesh);
brokenFaceIndicators.push(wireframeMesh);
}
@ -796,7 +779,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
for(var e in bFaceIndexed) {
var element = bFaceIndexed[e];
var shape = new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, null, element.vertices, element.indices);
var shape = new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, { x : 1, y : 1, z : 1 }, element.vertices, element.indices);
if(createCompoundShape) {
triangleMeshBody.addShape(shape);
@ -804,13 +787,11 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
var body = new GameLib.D3.RigidBody(this.engine, 0, 12);
body.addShape(shape);
this.instance.addRigidBody(body);
this.addRigidBody(body);
}
fixedTriangleMeshObjects.push(shape);
totalFixedFaces += element.indices.length / 3;
console.log("created mesh shape", element.indices.length / 3);
}
// TODO: remove duplicate indices
@ -833,7 +814,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
return {
brokenFaceIndicators : brokenFaceIndicators,
fixedTriangleMeshShapes : fixedTriangleMeshObjects,
wireframeMeshes : wireframeMeshes
fixedTriangleMeshShapes : fixedTriangleMeshObjects
};
};