backup
parent
3b6a61ef69
commit
631115a875
File diff suppressed because one or more lines are too long
|
@ -235,7 +235,7 @@ GameLib.D3.ComponentInterface.prototype.onUpdate = function(
|
||||||
deltaTime,
|
deltaTime,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
//this.parentEntity.mesh.material.color = new THREE.Color(Math.random(), Math.random(), Math.random());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.ComponentInterface.prototype.onLateUpdate = function(
|
GameLib.D3.ComponentInterface.prototype.onLateUpdate = function(
|
||||||
|
@ -256,7 +256,7 @@ GameLib.D3.ComponentInterface.prototype.onSetParentEntity = function(
|
||||||
parentScene,
|
parentScene,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
//parentEntity.mesh.material = new THREE.MeshBasicMaterial();
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Engine Superset
|
* Engine Superset
|
||||||
|
@ -3187,15 +3187,16 @@ GameLib.D3.Scene = function(
|
||||||
}
|
}
|
||||||
this.entities = entities;
|
this.entities = entities;
|
||||||
|
|
||||||
|
// todo: remove this from the scene class
|
||||||
// changes
|
// changes
|
||||||
this.threeScene = new THREE.Scene();
|
//this.threeScene = new THREE.Scene();
|
||||||
this.threeScene.render = true;
|
//this.threeScene.render = true;
|
||||||
|
|
||||||
// assoc array
|
// assoc array
|
||||||
this.meshIdToMesh = {};
|
//this.meshIdToMesh = {};
|
||||||
|
|
||||||
// assoc array
|
// assoc array
|
||||||
this.componentIdToComponent = {};
|
//this.componentIdToComponent = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3864,14 +3865,13 @@ GameLib.D3.Shape = function(
|
||||||
numSegments,
|
numSegments,
|
||||||
heightmap
|
heightmap
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
|
|
||||||
this.engine.isNotCannonThrow();
|
this.engine.isNotCannonThrow();
|
||||||
|
|
||||||
this.shapeType = shapeType;
|
this.shapeType = shapeType;
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
|
||||||
|
|
||||||
if (typeof scale == 'undefined') {
|
if (typeof scale == 'undefined') {
|
||||||
scale = new GameLib.D3.Vector3(1, 1, 1)
|
scale = new GameLib.D3.Vector3(1, 1, 1)
|
||||||
}
|
}
|
||||||
|
@ -3922,6 +3922,7 @@ GameLib.D3.Shape = function(
|
||||||
}
|
}
|
||||||
this.heightmap = heightmap;
|
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) {
|
GameLib.D3.Vector2 = function(x, y) {
|
||||||
|
|
||||||
this.x = 0;
|
this.x = 0;
|
||||||
|
@ -5745,7 +5755,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShapeDivided = function(
|
||||||
/**
|
/**
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param graphicsMesh THREE.Mesh
|
* @param graphicsMesh THREE.Mesh
|
||||||
* @returns {GameLib.D3.RigidBody}
|
* @returns {GameLib.D3.Shape}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||||
|
@ -5767,7 +5777,6 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||||
vertex.y * graphicsMesh.scale.y,
|
vertex.y * graphicsMesh.scale.y,
|
||||||
vertex.z * graphicsMesh.scale.z
|
vertex.z * graphicsMesh.scale.z
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var triangleFaces = [];
|
var triangleFaces = [];
|
||||||
|
@ -5777,9 +5786,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||||
var i2 = graphicsMesh.geometry.faces[f].c;
|
var i2 = graphicsMesh.geometry.faces[f].c;
|
||||||
|
|
||||||
triangleFaces.push([
|
triangleFaces.push([
|
||||||
i0,
|
i0, i1, i2
|
||||||
i1,
|
|
||||||
i2
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5824,18 +5831,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||||
processedFaces++;
|
processedFaces++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var shape = GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, graphicsMesh.scale, vertices, faces);
|
return new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, {x : 1, y : 1, z : 1}, 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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5875,7 +5871,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
var raycastResult = new this.engine.instance.RaycastResult();
|
var raycastResult = new this.engine.instance.RaycastResult();
|
||||||
|
|
||||||
var brokenFaceIndicators = [];
|
var brokenFaceIndicators = [];
|
||||||
var wireframeMeshes = [];
|
|
||||||
|
|
||||||
var totalFaces = 0;
|
var totalFaces = 0;
|
||||||
var totalBrokenFaces = 0;
|
var totalBrokenFaces = 0;
|
||||||
|
@ -5883,7 +5878,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
var fixedTriangleMeshObjects = [];
|
var fixedTriangleMeshObjects = [];
|
||||||
|
|
||||||
for(var i in triangleMeshShapes) {
|
for(var i in triangleMeshShapes) {
|
||||||
var trimesh = triangleMeshShapes[i];
|
var trimesh = triangleMeshShapes[i].instance;
|
||||||
|
|
||||||
var brokenFaces = [];
|
var brokenFaces = [];
|
||||||
totalFaces += (trimesh.indices.length / 3);
|
totalFaces += (trimesh.indices.length / 3);
|
||||||
|
@ -5960,8 +5955,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
wireframeMesh.add( arrow );
|
wireframeMesh.add( arrow );
|
||||||
|
|
||||||
wireframeMeshes.add(wireframeMesh);
|
|
||||||
brokenFaceIndicators.push(wireframeMesh);
|
brokenFaceIndicators.push(wireframeMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6090,7 +6083,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
for(var e in bFaceIndexed) {
|
for(var e in bFaceIndexed) {
|
||||||
var element = bFaceIndexed[e];
|
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) {
|
if(createCompoundShape) {
|
||||||
triangleMeshBody.addShape(shape);
|
triangleMeshBody.addShape(shape);
|
||||||
|
@ -6098,13 +6091,11 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
|
|
||||||
var body = new GameLib.D3.RigidBody(this.engine, 0, 12);
|
var body = new GameLib.D3.RigidBody(this.engine, 0, 12);
|
||||||
body.addShape(shape);
|
body.addShape(shape);
|
||||||
this.instance.addRigidBody(body);
|
this.addRigidBody(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedTriangleMeshObjects.push(shape);
|
fixedTriangleMeshObjects.push(shape);
|
||||||
totalFixedFaces += element.indices.length / 3;
|
totalFixedFaces += element.indices.length / 3;
|
||||||
|
|
||||||
console.log("created mesh shape", element.indices.length / 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove duplicate indices
|
// TODO: remove duplicate indices
|
||||||
|
@ -6127,8 +6118,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
|
|
||||||
return {
|
return {
|
||||||
brokenFaceIndicators : brokenFaceIndicators,
|
brokenFaceIndicators : brokenFaceIndicators,
|
||||||
fixedTriangleMeshShapes : fixedTriangleMeshObjects,
|
fixedTriangleMeshShapes : fixedTriangleMeshObjects
|
||||||
wireframeMeshes : wireframeMeshes
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
|
|
|
@ -43,7 +43,7 @@ GameLib.D3.ComponentInterface.prototype.onUpdate = function(
|
||||||
deltaTime,
|
deltaTime,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
//this.parentEntity.mesh.material.color = new THREE.Color(Math.random(), Math.random(), Math.random());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.ComponentInterface.prototype.onLateUpdate = function(
|
GameLib.D3.ComponentInterface.prototype.onLateUpdate = function(
|
||||||
|
@ -64,5 +64,5 @@ GameLib.D3.ComponentInterface.prototype.onSetParentEntity = function(
|
||||||
parentScene,
|
parentScene,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
//parentEntity.mesh.material = new THREE.MeshBasicMaterial();
|
|
||||||
};
|
};
|
|
@ -81,6 +81,7 @@ GameLib.D3.Scene = function(
|
||||||
}
|
}
|
||||||
this.entities = entities;
|
this.entities = entities;
|
||||||
|
|
||||||
|
// todo: remove this from the scene class
|
||||||
// changes
|
// changes
|
||||||
this.threeScene = new THREE.Scene();
|
this.threeScene = new THREE.Scene();
|
||||||
this.threeScene.render = true;
|
this.threeScene.render = true;
|
||||||
|
|
|
@ -29,14 +29,13 @@ GameLib.D3.Shape = function(
|
||||||
numSegments,
|
numSegments,
|
||||||
heightmap
|
heightmap
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
|
|
||||||
this.engine.isNotCannonThrow();
|
this.engine.isNotCannonThrow();
|
||||||
|
|
||||||
this.shapeType = shapeType;
|
this.shapeType = shapeType;
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
|
||||||
|
|
||||||
if (typeof scale == 'undefined') {
|
if (typeof scale == 'undefined') {
|
||||||
scale = new GameLib.D3.Vector3(1, 1, 1)
|
scale = new GameLib.D3.Vector3(1, 1, 1)
|
||||||
}
|
}
|
||||||
|
@ -87,6 +86,7 @@ GameLib.D3.Shape = function(
|
||||||
}
|
}
|
||||||
this.heightmap = heightmap;
|
this.heightmap = heightmap;
|
||||||
|
|
||||||
|
this.instance = this.createInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,4 +8,13 @@ GameLib.D3.Utils.Extend = function(
|
||||||
child.prototype[prop] = parent.prototype[prop];
|
child.prototype[prop] = parent.prototype[prop];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Utils.Raycast = function (
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
options,
|
||||||
|
world
|
||||||
|
) {
|
||||||
|
console.log("not implemented yet");
|
||||||
};
|
};
|
|
@ -451,7 +451,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShapeDivided = function(
|
||||||
/**
|
/**
|
||||||
* @param graphics GameLib.D3.Graphics
|
* @param graphics GameLib.D3.Graphics
|
||||||
* @param graphicsMesh THREE.Mesh
|
* @param graphicsMesh THREE.Mesh
|
||||||
* @returns {GameLib.D3.RigidBody}
|
* @returns {GameLib.D3.Shape}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||||
|
@ -473,7 +473,6 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||||
vertex.y * graphicsMesh.scale.y,
|
vertex.y * graphicsMesh.scale.y,
|
||||||
vertex.z * graphicsMesh.scale.z
|
vertex.z * graphicsMesh.scale.z
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var triangleFaces = [];
|
var triangleFaces = [];
|
||||||
|
@ -483,9 +482,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||||
var i2 = graphicsMesh.geometry.faces[f].c;
|
var i2 = graphicsMesh.geometry.faces[f].c;
|
||||||
|
|
||||||
triangleFaces.push([
|
triangleFaces.push([
|
||||||
i0,
|
i0, i1, i2
|
||||||
i1,
|
|
||||||
i2
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,18 +527,7 @@ GameLib.D3.World.prototype.generateTriangleMeshShape = function(
|
||||||
processedFaces++;
|
processedFaces++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var shape = GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, graphicsMesh.scale, vertices, faces);
|
return new GameLib.D3.Shape(this.engine, GameLib.D3.Shape.SHAPE_TYPE_TRIMESH, {x : 1, y : 1, z : 1}, 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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,7 +567,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
var raycastResult = new this.engine.instance.RaycastResult();
|
var raycastResult = new this.engine.instance.RaycastResult();
|
||||||
|
|
||||||
var brokenFaceIndicators = [];
|
var brokenFaceIndicators = [];
|
||||||
var wireframeMeshes = [];
|
|
||||||
|
|
||||||
var totalFaces = 0;
|
var totalFaces = 0;
|
||||||
var totalBrokenFaces = 0;
|
var totalBrokenFaces = 0;
|
||||||
|
@ -589,7 +574,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
var fixedTriangleMeshObjects = [];
|
var fixedTriangleMeshObjects = [];
|
||||||
|
|
||||||
for(var i in triangleMeshShapes) {
|
for(var i in triangleMeshShapes) {
|
||||||
var trimesh = triangleMeshShapes[i];
|
var trimesh = triangleMeshShapes[i].instance;
|
||||||
|
|
||||||
var brokenFaces = [];
|
var brokenFaces = [];
|
||||||
totalFaces += (trimesh.indices.length / 3);
|
totalFaces += (trimesh.indices.length / 3);
|
||||||
|
@ -666,8 +651,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
wireframeMesh.add( arrow );
|
wireframeMesh.add( arrow );
|
||||||
|
|
||||||
wireframeMeshes.add(wireframeMesh);
|
|
||||||
brokenFaceIndicators.push(wireframeMesh);
|
brokenFaceIndicators.push(wireframeMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +779,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
for(var e in bFaceIndexed) {
|
for(var e in bFaceIndexed) {
|
||||||
var element = bFaceIndexed[e];
|
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) {
|
if(createCompoundShape) {
|
||||||
triangleMeshBody.addShape(shape);
|
triangleMeshBody.addShape(shape);
|
||||||
|
@ -804,13 +787,11 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
|
|
||||||
var body = new GameLib.D3.RigidBody(this.engine, 0, 12);
|
var body = new GameLib.D3.RigidBody(this.engine, 0, 12);
|
||||||
body.addShape(shape);
|
body.addShape(shape);
|
||||||
this.instance.addRigidBody(body);
|
this.addRigidBody(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedTriangleMeshObjects.push(shape);
|
fixedTriangleMeshObjects.push(shape);
|
||||||
totalFixedFaces += element.indices.length / 3;
|
totalFixedFaces += element.indices.length / 3;
|
||||||
|
|
||||||
console.log("created mesh shape", element.indices.length / 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove duplicate indices
|
// TODO: remove duplicate indices
|
||||||
|
@ -833,7 +814,6 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = function(
|
||||||
|
|
||||||
return {
|
return {
|
||||||
brokenFaceIndicators : brokenFaceIndicators,
|
brokenFaceIndicators : brokenFaceIndicators,
|
||||||
fixedTriangleMeshShapes : fixedTriangleMeshObjects,
|
fixedTriangleMeshShapes : fixedTriangleMeshObjects
|
||||||
wireframeMeshes : wireframeMeshes
|
|
||||||
};
|
};
|
||||||
};
|
};
|
Loading…
Reference in New Issue