API geometry classes done

beta.r3js.org
-=yb4f310 2018-02-09 20:37:11 +01:00
parent 20849ace15
commit 1eb67b69f5
59 changed files with 3024 additions and 1423 deletions

View File

@ -358,12 +358,38 @@ GameLib.Component.GEOMETRY_TORUS = 0x7c;
GameLib.Component.GEOMETRY_TORUS_KNOT = 0x7d;
GameLib.Component.GEOMETRY_TUBE = 0x7e;
GameLib.Component.GEOMETRY_WIREFRAME = 0x7f;
GameLib.Component.CURVE = 0x80;
GameLib.Component.CURVE_PATH = 0x81;
GameLib.Component.CURVE_PATH_D2 = 0x82;
GameLib.Component.CURVE_PATH_D2_SHAPE = 0x83;
GameLib.Component.MAX_COMPONENTS = 0x84;
GameLib.Component.BUFFER_GEOMETRY = 0x80;
GameLib.Component.BUFFER_GEOMETRY_BOX = 0x81;
GameLib.Component.BUFFER_GEOMETRY_CIRCLE = 0x82;
GameLib.Component.BUFFER_GEOMETRY_CONE = 0x83;
GameLib.Component.BUFFER_GEOMETRY_CYLINDER = 0x84;
GameLib.Component.BUFFER_GEOMETRY_DODECAHEDRON = 0x85;
GameLib.Component.BUFFER_GEOMETRY_EXTRUDE = 0x86;
GameLib.Component.BUFFER_GEOMETRY_ICOSAHEDRON = 0x87;
GameLib.Component.BUFFER_GEOMETRY_LATHE = 0x88;
GameLib.Component.BUFFER_GEOMETRY_OCTAHEDRON = 0x89;
GameLib.Component.BUFFER_GEOMETRY_PARAMETRIC = 0x8a;
GameLib.Component.BUFFER_GEOMETRY_PLANE = 0x8b;
GameLib.Component.BUFFER_GEOMETRY_POLYHEDRON = 0x8c;
GameLib.Component.BUFFER_GEOMETRY_RING = 0x8d;
GameLib.Component.BUFFER_GEOMETRY_SHAPE = 0x8e;
GameLib.Component.BUFFER_GEOMETRY_SPHERE = 0x8f;
GameLib.Component.BUFFER_GEOMETRY_TETRAHEDRON = 0x90;
GameLib.Component.BUFFER_GEOMETRY_TEXT = 0x91;
GameLib.Component.BUFFER_GEOMETRY_TORUS = 0x92;
GameLib.Component.BUFFER_GEOMETRY_TORUS_KNOT = 0x93;
GameLib.Component.BUFFER_GEOMETRY_TUBE = 0x94;
GameLib.Component.CURVE = 0x95;
GameLib.Component.CURVE_PATH = 0x96;
GameLib.Component.CURVE_PATH_D2 = 0x97;
GameLib.Component.CURVE_PATH_D2_SHAPE = 0x98;
GameLib.Component.BOX3 = 0x99;
GameLib.Component.DRAW_RANGE = 0x9a;
GameLib.Component.GROUP = 0x9b;
GameLib.Component.MAX_COMPONENTS = 0x9c;
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
GameLib.Component.PHYSICS_RUNTIME = 0x2;
@ -1147,29 +1173,173 @@ GameLib.Component.GetComponentInfo = function(number) {
apiConstructor : GameLib.D3.API.Geometry.Wireframe
};
case 0x80 : return {
name : 'GameLib.D3.BufferGeometry',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry,
apiConstructor : GameLib.D3.API.BufferGeometry
};
case 0x81 : return {
name : 'GameLib.D3.BufferGeometry.Box',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Box,
apiConstructor : GameLib.D3.API.BufferGeometry.Box
};
case 0x82 : return {
name : 'GameLib.D3.BufferGeometry.Circle',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Circle,
apiConstructor : GameLib.D3.API.BufferGeometry.Circle
};
case 0x83 : return {
name : 'GameLib.D3.BufferGeometry.Cone',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Cone,
apiConstructor : GameLib.D3.API.BufferGeometry.Cone
};
case 0x84 : return {
name : 'GameLib.D3.BufferGeometry.Cylinder',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Cylinder,
apiConstructor : GameLib.D3.API.BufferGeometry.Cylinder
};
case 0x85 : return {
name : 'GameLib.D3.BufferGeometry.Dodecahedron',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Dodecahedron,
apiConstructor : GameLib.D3.API.BufferGeometry.Dodecahedron
};
case 0x86 : return {
name : 'GameLib.D3.BufferGeometry.Extrude',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Extrude,
apiConstructor : GameLib.D3.API.BufferGeometry.Extrude
};
case 0x87 : return {
name : 'GameLib.D3.BufferGeometry.Icosahedron',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Icosahedron,
apiConstructor : GameLib.D3.API.BufferGeometry.Icosahedron
};
case 0x88 : return {
name : 'GameLib.D3.BufferGeometry.Lathe',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Lathe,
apiConstructor : GameLib.D3.API.BufferGeometry.Lathe
};
case 0x89 : return {
name : 'GameLib.D3.BufferGeometry.Octahedron',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Octahedron,
apiConstructor : GameLib.D3.API.BufferGeometry.Octahedron
};
case 0x8a : return {
name : 'GameLib.D3.BufferGeometry.Parametric',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Parametric,
apiConstructor : GameLib.D3.API.BufferGeometry.Parametric
};
case 0x8b : return {
name : 'GameLib.D3.BufferGeometry.Plane',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Plane,
apiConstructor : GameLib.D3.API.BufferGeometry.Plane
};
case 0x8c : return {
name : 'GameLib.D3.BufferGeometry.Polyhedron',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Polyhedron,
apiConstructor : GameLib.D3.API.BufferGeometry.Polyhedron
};
case 0x8d : return {
name : 'GameLib.D3.BufferGeometry.Ring',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Ring,
apiConstructor : GameLib.D3.API.BufferGeometry.Ring
};
case 0x8e : return {
name : 'GameLib.D3.BufferGeometry.Shape',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Shape,
apiConstructor : GameLib.D3.API.BufferGeometry.Shape
};
case 0x8f : return {
name : 'GameLib.D3.BufferGeometry.Sphere',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Sphere,
apiConstructor : GameLib.D3.API.BufferGeometry.Sphere
};
case 0x90 : return {
name : 'GameLib.D3.BufferGeometry.Tetrahedron',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Tetrahedron,
apiConstructor : GameLib.D3.API.BufferGeometry.Tetrahedron
};
case 0x91 : return {
name : 'GameLib.D3.BufferGeometry.Text',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Text,
apiConstructor : GameLib.D3.API.BufferGeometry.Text
};
case 0x92 : return {
name : 'GameLib.D3.BufferGeometry.Torus',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Torus,
apiConstructor : GameLib.D3.API.BufferGeometry.Torus
};
case 0x93 : return {
name : 'GameLib.D3.BufferGeometry.TorusKnot',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.TorusKnot,
apiConstructor : GameLib.D3.API.BufferGeometry.TorusKnot
};
case 0x94 : return {
name : 'GameLib.D3.BufferGeometry.Tube',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.BufferGeometry.Tube,
apiConstructor : GameLib.D3.API.BufferGeometry.Tube
};
case 0x95 : return {
name : 'GameLib.Curve',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Curve,
apiConstructor : GameLib.API.Curve
};
case 0x81 : return {
case 0x96 : return {
name : 'GameLib.Curve.Path',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Curve.Path,
apiConstructor : GameLib.API.Curve.Path
};
case 0x82 : return {
case 0x97 : return {
name : 'GameLib.Curve.Path.D2',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Curve.Path.D2,
apiConstructor : GameLib.API.Curve.Path.D2
};
case 0x82 : return {
case 0x98 : return {
name : 'GameLib.Curve.Path.D2.Shape',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Curve.Path.D2.Shape,
apiConstructor : GameLib.API.Curve.Path.D2.Shape
};
case 0x99 : return {
name : 'GameLib.Box3',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Box3,
apiConstructor : GameLib.API.Box3
};
case 0x9a : return {
name : 'GameLib.DrawRange',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.DrawRange,
apiConstructor : GameLib.API.DrawRange
};
case 0x9b : return {
name : 'GameLib.Group',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Group,
apiConstructor : GameLib.API.Group
};
break;
}

View File

@ -1,13 +1,29 @@
/**
* GameLib.API.Box3
* @param id
* @param name
* @param parentEntity
* @param min
* @param max
* @constructor
*/
GameLib.API.Box3 = function (
id,
name,
parentEntity,
min,
max
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Box (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(min)) {
min = new GameLib.API.Vector3(0,0,0);
}
@ -17,4 +33,13 @@ GameLib.API.Box3 = function (
max = new GameLib.API.Vector3(1,1,1);
}
this.max = max;
GameLib.API.Component.call(
this,
GameLib.Component.BOX3,
parentEntity
)
};
GameLib.API.Box3.prototype = Object.create(GameLib.API.Component.prototype);
GameLib.API.Box3.prototype.constructor = GameLib.API.Box3;

View File

@ -0,0 +1,45 @@
/**
* GameLib.API.Box3
* @constructor
* @param id
* @param name
* @param parentEntity
* @param start
* @param count
*/
GameLib.API.DrawRange = function (
id,
name,
parentEntity,
start,
count
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'DrawRange (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(start)) {
start = 0;
}
this.start = start;
if (GameLib.Utils.UndefinedOrNull(count)) {
count = Infinity;
}
this.count = count;
GameLib.API.Component.call(
this,
GameLib.Component.DRAW_RANGE,
parentEntity
)
};
GameLib.API.DrawRange.prototype = Object.create(GameLib.API.Component.prototype);
GameLib.API.DrawRange.prototype.constructor = GameLib.API.DrawRange;

52
src/game-lib-api-group.js Normal file
View File

@ -0,0 +1,52 @@
/**
* GameLib.API.Group
* @constructor
* @param id
* @param name
* @param parentEntity
* @param start
* @param count
* @param materialIndex
*/
GameLib.API.Group = function (
id,
name,
parentEntity,
start,
count,
materialIndex
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Group (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(start)) {
start = 0;
}
this.start = start;
if (GameLib.Utils.UndefinedOrNull(count)) {
count = 0;
}
this.count = count;
if (GameLib.Utils.UndefinedOrNull(materialIndex)) {
materialIndex = 0;
}
this.materialIndex = materialIndex;
GameLib.API.Component.call(
this,
GameLib.Component.GROUP,
parentEntity
)
};
GameLib.API.Group.prototype = Object.create(GameLib.API.Component.prototype);
GameLib.API.Group.prototype.constructor = GameLib.API.Group;

View File

@ -25,6 +25,9 @@ GameLib.Box3 = function (
GameLib.API.Box3.call(
this,
apiBox3.id,
apiBox3.name,
apiBox3.parentEntity,
apiBox3.min,
apiBox3.max
);
@ -32,7 +35,7 @@ GameLib.Box3 = function (
this.createInstance();
};
GameLib.Box3.prototype = Object.create(GameLib.API.Box3.prototype);
GameLib.Box3.prototype = Object.create(GameLib.Component.prototype);
GameLib.Box3.prototype.constructor = GameLib.Box3;
/**
@ -73,6 +76,9 @@ GameLib.Box3.prototype.updateInstance = function(property) {
*/
GameLib.Box3.prototype.toApiObject = function() {
return new GameLib.API.Box3(
this.id,
this.name,
GameLib.Utils.IdOrNull(this.parentEntity),
this.min.toApiObject(),
this.max.toApiObject()
);

View File

@ -0,0 +1,267 @@
/**
* GameLib.D3.API.BufferGeometry
* @param id
* @param name
* @param bufferGeometryType
* @param parentEntity
* @param faces
* @param vertices
* @param attributes
* @param boundingBox
* @param boundingSphere
* @param drawRange
* @param groups
* @param index
* @param morphAttributes
* @constructor
*/
GameLib.D3.API.BufferGeometry = function(
id,
name,
bufferGeometryType,
parentEntity,
faces,
vertices,
attributes,
boundingBox,
boundingSphere,
drawRange,
groups,
index,
morphAttributes
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(bufferGeometryType)) {
bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE;
}
this.bufferGeometryType = bufferGeometryType;
if (GameLib.Utils.UndefinedOrNull(name)) {
switch (this.bufferGeometryType) {
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE :
name = 'BufferGeometry';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX :
name = 'BufferGeometry Box';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE :
name = 'BufferGeometry Circle';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE :
name = 'BufferGeometry Cone';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER :
name = 'BufferGeometry Cylinder';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON :
name = 'BufferGeometry Dodecahedron';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE :
name = 'BufferGeometry Extrude';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON :
name = 'BufferGeometry Icosahedron';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE :
name = 'BufferGeometry Lathe';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON :
name = 'BufferGeometry Octahedron';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC :
name = 'BufferGeometry Parametric';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE :
name = 'BufferGeometry Plane';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON :
name = 'BufferGeometry Polyhedron';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING :
name = 'BufferGeometry Ring';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE :
name = 'BufferGeometry Shape';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE :
name = 'BufferGeometry Sphere';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON :
name = 'BufferGeometry Tetrahedron';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT :
name = 'BufferGeometry Text';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS :
name = 'BufferGeometry Torus';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT :
name = 'BufferGeometry Torus Knot';
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE :
name = 'BufferGeometry Tube';
break;
default :
console.warn('no nice name for geometry');
name = 'BufferGeometry';
}
name += ' (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(attributes)) {
attributes = [];
}
this.attributes = attributes;
if (GameLib.Utils.UndefinedOrNull(boundingBox)) {
boundingBox = new GameLib.API.Box3();
}
this.boundingBox = boundingBox;
if (GameLib.Utils.UndefinedOrNull(boundingSphere)) {
boundingSphere = new GameLib.API.Sphere();
}
this.boundingSphere = boundingSphere;
if (GameLib.Utils.UndefinedOrNull(groups)) {
groups = [];
}
this.groups = groups;
if (GameLib.Utils.UndefinedOrNull(index)) {
index = null;
}
this.index = index;
if (GameLib.Utils.UndefinedOrNull(morphAttributes)) {
morphAttributes = null;
}
this.morphAttributes = morphAttributes;
if (GameLib.Utils.UndefinedOrNull(faces)) {
faces = [];
}
this.faces = faces;
if (GameLib.Utils.UndefinedOrNull(vertices)) {
vertices = [];
}
this.vertices = vertices;
GameLib.API.Component.call(
this,
GameLib.D3.API.BufferGeometry.GetComponentType(this.bufferGeometryType),
parentEntity
);
};
GameLib.D3.API.BufferGeometry.prototype = Object.create(GameLib.API.Component.prototype);
GameLib.D3.API.BufferGeometry.prototype.constructor = GameLib.D3.API.BufferGeometry;
GameLib.D3.API.BufferGeometry.GetComponentType = function(bufferGeometryType) {
var componentType = null;
switch (bufferGeometryType) {
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE :
componentType = GameLib.Component.BUFFER_GEOMETRY;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX :
componentType = GameLib.Component.BUFFER_GEOMETRY_BOX;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE :
componentType = GameLib.Component.BUFFER_GEOMETRY_CIRCLE;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE :
componentType = GameLib.Component.BUFFER_GEOMETRY_CONE;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER :
componentType = GameLib.Component.BUFFER_GEOMETRY_CYLINDER;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON :
componentType = GameLib.Component.BUFFER_GEOMETRY_DODECAHEDRON;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE :
componentType = GameLib.Component.BUFFER_GEOMETRY_EXTRUDE;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON :
componentType = GameLib.Component.BUFFER_GEOMETRY_ICOSAHEDRON;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE :
componentType = GameLib.Component.BUFFER_GEOMETRY_LATHE;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON :
componentType = GameLib.Component.BUFFER_GEOMETRY_OCTAHEDRON;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC:
componentType = GameLib.Component.BUFFER_GEOMETRY_PARAMETRIC;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE :
componentType = GameLib.Component.BUFFER_GEOMETRY_PLANE;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON :
componentType = GameLib.Component.BUFFER_GEOMETRY_POLYHEDRON;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING:
componentType = GameLib.Component.BUFFER_GEOMETRY_RING;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE :
componentType = GameLib.Component.BUFFER_GEOMETRY_SHAPE;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE :
componentType = GameLib.Component.BUFFER_GEOMETRY_SPHERE;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON :
componentType = GameLib.Component.BUFFER_GEOMETRY_TETRAHEDRON;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT :
componentType = GameLib.Component.BUFFER_GEOMETRY_TEXT;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS :
componentType = GameLib.Component.BUFFER_GEOMETRY_TORUS;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT :
componentType = GameLib.Component.BUFFER_GEOMETRY_TORUS_KNOT;
break;
case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE :
componentType = GameLib.Component.BUFFER_GEOMETRY_TUBE;
break;
default:
throw new Error('unhandled geometry type: ' + bufferGeometryType);
}
return componentType;
};
/**
* BufferGeometry Type
* @type {number}
*/
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE = 0x1;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX = 0x2;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE = 0x3;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE = 0x4;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER = 0x5;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON = 0x6;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE = 0x7;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON = 0x8;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE = 0x9;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON = 0xa;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC = 0xb;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE = 0xc;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON = 0xd;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING = 0xe;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE = 0xf;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE = 0x10;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON = 0x11;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT = 0x12;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS = 0x13;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT = 0x14;
GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE = 0x15;

View File

@ -0,0 +1,81 @@
/**
* GameLib.D3.API.BufferGeometry.Box
* @param apiBufferGeometry
* @param width
* @param height
* @param depth
* @param widthSegments
* @param heightSegments
* @param depthSegments
* @constructor
*/
GameLib.D3.API.BufferGeometry.Box = function(
apiBufferGeometry,
width,
height,
depth,
widthSegments,
heightSegments,
depthSegments
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX;
}
if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1;
}
this.width = width;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 1;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(depth)) {
depth = 1;
}
this.depth = depth;
if (GameLib.Utils.UndefinedOrNull(widthSegments)) {
widthSegments = 1;
}
this.widthSegments = widthSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 1;
}
this.heightSegments = heightSegments;
if (GameLib.Utils.UndefinedOrNull(depthSegments)) {
depthSegments = 1;
}
this.depthSegments = depthSegments;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Box.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Box.prototype.constructor = GameLib.D3.API.BufferGeometry.Box;

View File

@ -0,0 +1,67 @@
/**
* GameLib.D3.API.BufferGeometry.Circle
* @param apiBufferGeometry
* @param radius
* @param segments
* @param thetaStart
* @param thetaLength
* @constructor
*/
GameLib.D3.API.BufferGeometry.Circle = function(
apiBufferGeometry,
radius,
segments,
thetaStart,
thetaLength
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(segments)) {
segments = 8;
}
this.segments = segments;
if (GameLib.Utils.UndefinedOrNull(thetaStart)) {
thetaStart = 0;
}
this.thetaStart = thetaStart;
if (GameLib.Utils.UndefinedOrNull(thetaLength)) {
thetaLength = Math.PI * 2;
}
this.thetaLength = thetaLength;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Circle.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Circle.prototype.constructor = GameLib.D3.API.BufferGeometry.Circle;

View File

@ -0,0 +1,88 @@
/**
* GameLib.D3.API.BufferGeometry.Cone
* @param apiBufferGeometry
* @param radius
* @param height
* @param radialSegments
* @param heightSegments
* @param openEnded
* @param thetaStart
* @param thetaLength
* @constructor
*/
GameLib.D3.API.BufferGeometry.Cone = function(
apiBufferGeometry,
radius,
height,
radialSegments,
heightSegments,
openEnded,
thetaStart,
thetaLength
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 100;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(radialSegments)) {
radialSegments = 8;
}
this.radialSegments = radialSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 1;
}
this.heightSegments = heightSegments;
if (GameLib.Utils.UndefinedOrNull(openEnded)) {
openEnded = false;
}
this.openEnded = openEnded;
if (GameLib.Utils.UndefinedOrNull(thetaStart)) {
thetaStart = 0;
}
this.thetaStart = thetaStart;
if (GameLib.Utils.UndefinedOrNull(thetaLength)) {
thetaLength = Math.PI * 2;
}
this.thetaLength = thetaLength;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Cone.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Cone.prototype.constructor = GameLib.D3.API.BufferGeometry.Cone;

View File

@ -0,0 +1,95 @@
/**
* GameLib.D3.API.BufferGeometry.Cylinder
* @param apiBufferGeometry
* @param radiusTop
* @param radiusBottom
* @param height
* @param radialSegments
* @param heightSegments
* @param openEnded
* @param thetaStart
* @param thetaLength
* @constructor
*/
GameLib.D3.API.BufferGeometry.Cylinder = function(
apiBufferGeometry,
radiusTop,
radiusBottom,
height,
radialSegments,
heightSegments,
openEnded,
thetaStart,
thetaLength
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER;
}
if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1;
}
this.radiusTop = radiusTop;
if (GameLib.Utils.UndefinedOrNull(radiusBottom)) {
radiusBottom = 1;
}
this.radiusBottom = radiusBottom;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 100;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(radialSegments)) {
radialSegments = 8;
}
this.radialSegments = radialSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 1;
}
this.heightSegments = heightSegments;
if (GameLib.Utils.UndefinedOrNull(openEnded)) {
openEnded = false;
}
this.openEnded = openEnded;
if (GameLib.Utils.UndefinedOrNull(thetaStart)) {
thetaStart = 0;
}
this.thetaStart = thetaStart;
if (GameLib.Utils.UndefinedOrNull(thetaLength)) {
thetaLength = Math.PI * 2;
}
this.thetaLength = thetaLength;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Cylinder.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Cylinder.prototype.constructor = GameLib.D3.API.BufferGeometry.Cylinder;

View File

@ -0,0 +1,53 @@
/**
* GameLib.D3.API.BufferGeometry.Dodecahedron
* @param apiBufferGeometry
* @param radius
* @param detail
* @constructor
*/
GameLib.D3.API.BufferGeometry.Dodecahedron = function(
apiBufferGeometry,
radius,
detail
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(detail)) {
detail = 0;
}
this.detail = detail;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Dodecahedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Dodecahedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Dodecahedron;

View File

@ -0,0 +1,111 @@
/**
* GameLib.D3.API.BufferGeometry.Extrude
* @param apiBufferGeometry
* @param shapes
* @param curveSegments
* @param steps
* @param amount
* @param bevelEnabled
* @param bevelThickness
* @param bevelSize
* @param bevelSegments
* @param extrudePath
* @param frames
* @param UVGenerator
* @constructor
*/
GameLib.D3.API.BufferGeometry.Extrude = function(
apiBufferGeometry,
shapes,
curveSegments,
steps,
amount,
bevelEnabled,
bevelThickness,
bevelSize,
bevelSegments,
extrudePath,
frames,
UVGenerator
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE;
}
if (GameLib.Utils.UndefinedOrNull(shapes)) {
shapes = [];
}
this.shapes = shapes;
if (GameLib.Utils.UndefinedOrNull(curveSegments)) {
curveSegments = 12;
}
this.curveSegments = curveSegments;
if (GameLib.Utils.UndefinedOrNull(steps)) {
steps = 1;
}
this.steps = steps;
if (GameLib.Utils.UndefinedOrNull(amount)) {
amount = 100;
}
this.amount = amount;
if (GameLib.Utils.UndefinedOrNull(bevelEnabled)) {
bevelEnabled = true;
}
this.bevelEnabled = bevelEnabled;
if (GameLib.Utils.UndefinedOrNull(bevelThickness)) {
bevelThickness = 6;
}
this.bevelThickness = bevelThickness;
if (GameLib.Utils.UndefinedOrNull(bevelSegments)) {
bevelSegments = 3;
}
this.bevelSegments = bevelSegments;
if (GameLib.Utils.UndefinedOrNull(extrudePath)) {
extrudePath = null;
}
this.extrudePath = extrudePath;
if (GameLib.Utils.UndefinedOrNull(frames)) {
frames = null;
}
this.frames = frames;
if (GameLib.Utils.UndefinedOrNull(UVGenerator)) {
UVGenerator = null;
}
this.UVGenerator = UVGenerator;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Extrude.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Extrude.prototype.constructor = GameLib.D3.API.BufferGeometry.Extrude;

View File

@ -0,0 +1,53 @@
/**
* GameLib.D3.API.BufferGeometry.Icosahedron
* @param apiBufferGeometry
* @param radius
* @param detail
* @constructor
*/
GameLib.D3.API.BufferGeometry.Icosahedron = function(
apiBufferGeometry,
radius,
detail
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(detail)) {
detail = 0;
}
this.detail = detail;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Icosahedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Icosahedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Icosahedron;

View File

@ -0,0 +1,67 @@
/**
* GameLib.D3.API.BufferGeometry.Lathe
* @param apiBufferGeometry
* @param points [GameLib.Vector2]
* @param segments
* @param phiStart
* @param phiLength
* @constructor
*/
GameLib.D3.API.BufferGeometry.Lathe = function(
apiBufferGeometry,
points,
segments,
phiStart,
phiLength
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE;
}
if (GameLib.Utils.UndefinedOrNull(points)) {
points = [];
}
this.points = points;
if (GameLib.Utils.UndefinedOrNull(segments)) {
segments = 12;
}
this.segments = segments;
if (GameLib.Utils.UndefinedOrNull(phiStart)) {
phiStart = 0;
}
this.phiStart = phiStart;
if (GameLib.Utils.UndefinedOrNull(phiLength)) {
phiLength = Math.PI * 2;
}
this.phiLength = phiLength;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Lathe.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Lathe.prototype.constructor = GameLib.D3.API.BufferGeometry.Lathe;

View File

@ -0,0 +1,53 @@
/**
* GameLib.D3.API.BufferGeometry.Octahedron
* @param apiBufferGeometry
* @param radius
* @param detail
* @constructor
*/
GameLib.D3.API.BufferGeometry.Octahedron = function(
apiBufferGeometry,
radius,
detail
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(detail)) {
detail = 0;
}
this.detail = detail;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Octahedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Octahedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Octahedron;

View File

@ -0,0 +1,60 @@
/**
* GameLib.D3.API.BufferGeometry.Parametric
* @param apiBufferGeometry
* @param generatorFn(u,v) => returns Vector3, u and v is values between 0 and 1
* @param slices
* @param stacks
* @constructor
*/
GameLib.D3.API.BufferGeometry.Parametric = function(
apiBufferGeometry,
generatorFn,
slices,
stacks
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC;
}
if (GameLib.Utils.UndefinedOrNull(generatorFn)) {
generatorFn = '';
}
this.generatorFn = generatorFn;
if (GameLib.Utils.UndefinedOrNull(slices)) {
slices = 20;
}
this.slices = slices;
if (GameLib.Utils.UndefinedOrNull(stacks)) {
stacks = 20;
}
this.stacks = stacks;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Parametric.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Parametric.prototype.constructor = GameLib.D3.API.BufferGeometry.Parametric;

View File

@ -0,0 +1,67 @@
/**
* GameLib.D3.API.BufferGeometry.Plane
* @param apiBufferGeometry
* @param width
* @param height
* @param widthSegments
* @param heightSegments
* @constructor
*/
GameLib.D3.API.BufferGeometry.Plane = function(
apiBufferGeometry,
width,
height,
widthSegments,
heightSegments
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE;
}
if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1;
}
this.width = width;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 1;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(widthSegments)) {
widthSegments = 1;
}
this.widthSegments = widthSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 1;
}
this.heightSegments = heightSegments;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Plane.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Plane.prototype.constructor = GameLib.D3.API.BufferGeometry.Plane;

View File

@ -0,0 +1,67 @@
/**
* GameLib.D3.API.BufferGeometry.Polyhedron
* @param apiBufferGeometry
* @param vertices
* @param indices
* @param radius
* @param detail
* @constructor
*/
GameLib.D3.API.BufferGeometry.Polyhedron = function(
apiBufferGeometry,
vertices,
indices,
radius,
detail
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON;
}
if (GameLib.Utils.UndefinedOrNull(vertices)) {
vertices = [];
}
this.vertices = vertices;
if (GameLib.Utils.UndefinedOrNull(indices)) {
indices = 1;
}
this.indices = indices;
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 5;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(detail)) {
detail = 0;
}
this.detail = detail;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Polyhedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Polyhedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Polyhedron;

View File

@ -0,0 +1,81 @@
/**
* GameLib.D3.API.BufferGeometry.Ring
* @param apiBufferGeometry
* @param innerRadius
* @param outerRadius
* @param thetaSegments
* @param phiSegments
* @param thetaStart
* @param thetaLength
* @constructor
*/
GameLib.D3.API.BufferGeometry.Ring = function(
apiBufferGeometry,
innerRadius,
outerRadius,
thetaSegments,
phiSegments,
thetaStart,
thetaLength
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING;
}
if (GameLib.Utils.UndefinedOrNull(innerRadius)) {
innerRadius = 0.5;
}
this.innerRadius = innerRadius;
if (GameLib.Utils.UndefinedOrNull(outerRadius)) {
outerRadius = 1;
}
this.outerRadius = outerRadius;
if (GameLib.Utils.UndefinedOrNull(thetaSegments)) {
thetaSegments = 8;
}
this.thetaSegments = thetaSegments;
if (GameLib.Utils.UndefinedOrNull(phiSegments)) {
phiSegments = 8;
}
this.phiSegments = phiSegments;
if (GameLib.Utils.UndefinedOrNull(thetaStart)) {
thetaStart = 0;
}
this.thetaStart = thetaStart;
if (GameLib.Utils.UndefinedOrNull(thetaLength)) {
thetaLength = Math.PI * 2;
}
this.thetaLength = thetaLength;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Ring.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Ring.prototype.constructor = GameLib.D3.API.BufferGeometry.Ring;

View File

@ -0,0 +1,53 @@
/**
* GameLib.D3.API.BufferGeometry.Shape
* @param apiBufferGeometry
* @param shapes
* @param curveSegments
* @constructor
*/
GameLib.D3.API.BufferGeometry.Shape = function(
apiBufferGeometry,
shapes,
curveSegments
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE;
}
if (GameLib.Utils.UndefinedOrNull(shapes)) {
shapes = [];
}
this.shapes = shapes;
if (GameLib.Utils.UndefinedOrNull(curveSegments)) {
curveSegments = 12;
}
this.curveSegments = curveSegments;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Shape.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Shape.prototype.constructor = GameLib.D3.API.BufferGeometry.Shape;

View File

@ -0,0 +1,88 @@
/**
* GameLib.D3.API.BufferGeometry.Sphere
* @param apiBufferGeometry
* @param radius
* @param widthSegments
* @param heightSegments
* @param phiStart
* @param phiLength
* @param thetaStart
* @param thetaLength
* @constructor
*/
GameLib.D3.API.BufferGeometry.Sphere = function(
apiBufferGeometry,
radius,
widthSegments,
heightSegments,
phiStart,
phiLength,
thetaStart,
thetaLength
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(widthSegments)) {
widthSegments = 8;
}
this.widthSegments = widthSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 6;
}
this.heightSegments = heightSegments;
if (GameLib.Utils.UndefinedOrNull(phiStart)) {
phiStart = 0;
}
this.phiStart = phiStart;
if (GameLib.Utils.UndefinedOrNull(phiLength)) {
phiLength = Math.PI * 2;
}
this.phiLength = phiLength;
if (GameLib.Utils.UndefinedOrNull(thetaStart)) {
thetaStart = 0;
}
this.thetaStart = thetaStart;
if (GameLib.Utils.UndefinedOrNull(thetaLength)) {
thetaLength = Math.PI * 2;
}
this.thetaLength = thetaLength;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Sphere.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Sphere.prototype.constructor = GameLib.D3.API.BufferGeometry.Sphere;

View File

@ -0,0 +1,53 @@
/**
* GameLib.D3.API.BufferGeometry.Tetrahedron
* @param apiBufferGeometry
* @param radius
* @param detail
* @constructor
*/
GameLib.D3.API.BufferGeometry.Tetrahedron = function(
apiBufferGeometry,
radius,
detail
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(detail)) {
detail = 0;
}
this.detail = detail;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Tetrahedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Tetrahedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Tetrahedron;

View File

@ -0,0 +1,102 @@
/**
* GameLib.D3.API.BufferGeometry.Text
* @param apiBufferGeometry
* @param text
* @param font
* @param size
* @param height
* @param curveSegments
* @param bevelEnabled
* @param bevelThickness
* @param bevelSize
* @param bevelSegments
* @constructor
*/
GameLib.D3.API.BufferGeometry.Text = function(
apiBufferGeometry,
text,
font,
size,
height,
curveSegments,
bevelEnabled,
bevelThickness,
bevelSize,
bevelSegments
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT;
}
if (GameLib.Utils.UndefinedOrNull(text)) {
text = '-=<yb4f310';
}
this.text = text;
if (GameLib.Utils.UndefinedOrNull(font)) {
font = null;
}
this.font = font;
if (GameLib.Utils.UndefinedOrNull(size)) {
size = 100;
}
this.size = size;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 50;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(curveSegments)) {
curveSegments = 12;
}
this.curveSegments = curveSegments;
if (GameLib.Utils.UndefinedOrNull(bevelEnabled)) {
bevelEnabled = false;
}
this.bevelEnabled = bevelEnabled;
if (GameLib.Utils.UndefinedOrNull(bevelThickness)) {
bevelThickness = 10;
}
this.bevelThickness = bevelThickness;
if (GameLib.Utils.UndefinedOrNull(bevelSize)) {
bevelSize = 8;
}
this.bevelSize = bevelSize;
if (GameLib.Utils.UndefinedOrNull(bevelSegments)) {
bevelSegments = 3;
}
this.bevelSegments = bevelSegments;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Text.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Text.prototype.constructor = GameLib.D3.API.BufferGeometry.Text;

View File

@ -0,0 +1,81 @@
/**
* GameLib.D3.API.BufferGeometry.TorusKnot
* @param apiBufferGeometry
* @param radius
* @param tube
* @param radialSegments
* @param tubularSegments
* @param p
* @param q
* @constructor
*/
GameLib.D3.API.BufferGeometry.TorusKnot = function(
apiBufferGeometry,
radius,
tube,
radialSegments,
tubularSegments,
p,
q
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(tube)) {
tube = 0.4;
}
this.tube = tube;
if (GameLib.Utils.UndefinedOrNull(radialSegments)) {
radialSegments = 8;
}
this.radialSegments = radialSegments;
if (GameLib.Utils.UndefinedOrNull(tubularSegments)) {
tubularSegments = 64;
}
this.tubularSegments = tubularSegments;
if (GameLib.Utils.UndefinedOrNull(p)) {
p = 2;
}
this.p = p;
if (GameLib.Utils.UndefinedOrNull(q)) {
q = 3;
}
this.q = q;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.TorusKnot.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.TorusKnot.prototype.constructor = GameLib.D3.API.BufferGeometry.TorusKnot;

View File

@ -0,0 +1,74 @@
/**
* GameLib.D3.API.BufferGeometry.Torus
* @param apiBufferGeometry
* @param radius
* @param tube
* @param radialSegments
* @param tubularSegments
* @param arc
* @constructor
*/
GameLib.D3.API.BufferGeometry.Torus = function(
apiBufferGeometry,
radius,
tube,
radialSegments,
tubularSegments,
arc
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(tube)) {
tube = 0.4;
}
this.tube = tube;
if (GameLib.Utils.UndefinedOrNull(radialSegments)) {
radialSegments = 8;
}
this.radialSegments = radialSegments;
if (GameLib.Utils.UndefinedOrNull(tubularSegments)) {
tubularSegments = 6;
}
this.tubularSegments = tubularSegments;
if (GameLib.Utils.UndefinedOrNull(arc)) {
arc = Math.PI * 2;
}
this.arc = arc;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Torus.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Torus.prototype.constructor = GameLib.D3.API.BufferGeometry.Torus;

View File

@ -0,0 +1,74 @@
/**
* GameLib.D3.API.BufferGeometry.Tube
* @param apiBufferGeometry
* @param path
* @param tubularSegments
* @param radius
* @param radialSegments
* @param closed
* @constructor
*/
GameLib.D3.API.BufferGeometry.Tube = function(
apiBufferGeometry,
path,
tubularSegments,
radius,
radialSegments,
closed
) {
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) {
apiBufferGeometry = {
bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE
};
}
if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) {
apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE;
}
if (GameLib.Utils.UndefinedOrNull(path)) {
path = null;
}
this.path = path;
if (GameLib.Utils.UndefinedOrNull(tubularSegments)) {
tubularSegments = 64;
}
this.tubularSegments = tubularSegments;
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(radialSegments)) {
radialSegments = 8;
}
this.radialSegments = radialSegments;
if (GameLib.Utils.UndefinedOrNull(closed)) {
closed = false;
}
this.closed = closed;
GameLib.D3.API.BufferGeometry.call(
this,
apiBufferGeometry.id,
apiBufferGeometry.name,
apiBufferGeometry.bufferGeometryType,
apiBufferGeometry.parentEntity,
apiBufferGeometry.faces,
apiBufferGeometry.vertices,
apiBufferGeometry.attributes,
apiBufferGeometry.boundingBox,
apiBufferGeometry.boundingSphere,
apiBufferGeometry.drawRange,
apiBufferGeometry.groups,
apiBufferGeometry.index,
apiBufferGeometry.morphAttributes
);
};
GameLib.D3.API.BufferGeometry.Tube.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype);
GameLib.D3.API.BufferGeometry.Tube.prototype.constructor = GameLib.D3.API.BufferGeometry.Tube;

View File

@ -12,6 +12,8 @@
* @param vertexNormals
* @param normal
* @param selected
* @param parentGeometry
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Face = function(
@ -27,7 +29,7 @@ GameLib.D3.API.Face = function(
vertexNormals,
normal,
selected,
parentMesh,
parentGeometry,
parentEntity
) {
@ -91,10 +93,10 @@ GameLib.D3.API.Face = function(
}
this.selected = selected;
if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
parentMesh = null;
if (GameLib.Utils.UndefinedOrNull(parentGeometry)) {
parentGeometry = null;
}
this.parentMesh = parentMesh;
this.parentGeometry = parentGeometry;
GameLib.API.Component.call(
this,

View File

@ -3,13 +3,11 @@
* @param id
* @param name
* @param geometryType
* @param isBuffer
* @param parentEntity
* @param boundingBox
* @param boundingSphere
* @param colors
* @param faces
* @param faceVertexUvs
* @param lineDistances
* @param morphTargets
* @param morphNormals
@ -29,13 +27,11 @@ GameLib.D3.API.Geometry = function(
id,
name,
geometryType,
isBuffer,
parentEntity,
boundingBox,
boundingSphere,
colors,
faces,
faceVertexUvs,
lineDistances,
morphTargets,
morphNormals,
@ -141,11 +137,6 @@ GameLib.D3.API.Geometry = function(
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(isBuffer)) {
isBuffer = false;
}
this.isBuffer = isBuffer;
if (GameLib.Utils.UndefinedOrNull(boundingBox)) {
boundingBox = new GameLib.API.Box3();
}
@ -177,7 +168,7 @@ GameLib.D3.API.Geometry = function(
this.morphTargets = morphTargets;
if (GameLib.Utils.UndefinedOrNull(morphNormals)) {
morphTargets = [];
morphNormals = [];
}
this.morphNormals = morphNormals;
@ -326,26 +317,26 @@ GameLib.D3.API.Geometry.GetComponentType = function(geometryType) {
* Geometry Type
* @type {number}
*/
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL = 0x0;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX = 0x1;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE = 0x2;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE = 0x3;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER = 0x4;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON = 0x5;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES = 0x6;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE = 0x7;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON = 0x8;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE = 0x9;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON = 0xa;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC = 0xb;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE = 0xc;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON = 0xd;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING = 0xe;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE = 0xf;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE = 0x10;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON = 0x11;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT = 0x12;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS = 0x13;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT = 0x14;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE = 0x15;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME = 0x16;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL = 0x0;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX = 0x1;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE = 0x2;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE = 0x3;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER = 0x4;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON = 0x5;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES = 0x6;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE = 0x7;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON = 0x8;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE = 0x9;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON = 0xa;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC = 0xb;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE = 0xc;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON = 0xd;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING = 0xe;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE = 0xf;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE = 0x10;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON = 0x11;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT = 0x12;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS = 0x13;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT = 0x14;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE = 0x15;
GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME = 0x16;

View File

@ -64,13 +64,13 @@ GameLib.D3.API.Geometry.Box = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -50,13 +50,13 @@ GameLib.D3.API.Geometry.Circle = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -71,13 +71,13 @@ GameLib.D3.API.Geometry.Cone = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -78,13 +78,13 @@ GameLib.D3.API.Geometry.Cylinder = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -36,13 +36,13 @@ GameLib.D3.API.Geometry.Dodecahedron = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -36,13 +36,13 @@ GameLib.D3.API.Geometry.Edges = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -94,13 +94,13 @@ GameLib.D3.API.Geometry.Extrude = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -36,13 +36,13 @@ GameLib.D3.API.Geometry.Icosahedron = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -50,13 +50,13 @@ GameLib.D3.API.Geometry.Lathe = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -36,13 +36,13 @@ GameLib.D3.API.Geometry.Octahedron = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -43,13 +43,13 @@ GameLib.D3.API.Geometry.Parametric = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -50,13 +50,13 @@ GameLib.D3.API.Geometry.Plane = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -50,13 +50,13 @@ GameLib.D3.API.Geometry.Polyhedron = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -64,13 +64,13 @@ GameLib.D3.API.Geometry.Ring = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -36,13 +36,13 @@ GameLib.D3.API.Geometry.Shape = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -71,13 +71,13 @@ GameLib.D3.API.Geometry.Sphere = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -36,13 +36,13 @@ GameLib.D3.API.Geometry.Tetrahedron = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -85,13 +85,13 @@ GameLib.D3.API.Geometry.Text = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -64,13 +64,13 @@ GameLib.D3.API.Geometry.TorusKnot = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -57,13 +57,13 @@ GameLib.D3.API.Geometry.Torus = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -57,13 +57,13 @@ GameLib.D3.API.Geometry.Tube = function(
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.isBuffer,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.faceVertexUvs,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,

View File

@ -0,0 +1,54 @@
/**
* GameLib.D3.API.Geometry.Wireframe
* @param apiGeometry
* @param geometry
* @constructor
*/
GameLib.D3.API.Geometry.Wireframe = function(
apiGeometry,
geometry
) {
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
apiGeometry = {
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME
};
}
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME;
}
if (GameLib.Utils.UndefinedOrNull(geometry)) {
geometry = null;
}
this.geometry = geometry;
GameLib.D3.API.Geometry.call(
this,
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,
apiGeometry.skinWeights,
apiGeometry.skinIndices,
apiGeometry.vertices,
apiGeometry.verticesNeedsUpdate,
apiGeometry.elementsNeedUpdate,
apiGeometry.uvsNeedUpdate,
apiGeometry.normalsNeedUpdate,
apiGeometry.colorsNeedUpdate,
apiGeometry.groupsNeedUpdate,
apiGeometry.lineDistancesNeedUpdate
);
};
GameLib.D3.API.Geometry.Wireframe.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
GameLib.D3.API.Geometry.Wireframe.prototype.constructor = GameLib.D3.API.Geometry.Wireframe;

View File

@ -1,57 +1,46 @@
/**
* GameLib.D3.API.Mesh
* @param id
* @param meshType
* @param name
* @param vertices
* @param faces
* @param meshType
* @param parentEntity
* @param excludeFromEnvironment
* @param materials
* @param parentMesh
* @param parentScene
* @param skeleton
* @param skinIndices
* @param skinWeights
* @param position
* @param quaternion
* @param rotation
* @param scale
* @param up
* @param modelMatrix
* @param renderOrder
* @param isBufferMesh
* @param useQuaternion
* @param visible
* @param castShadow
* @param receiveShadow
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Mesh = function(
id,
name,
meshType,
parentEntity,
excludeFromEnvironment,
vertices,
faces,
materials,
parentMesh,
parentScene,
skeleton,
skinIndices,
skinWeights,
position,
quaternion,
rotation,
scale,
up,
modelMatrix,
renderOrder,
isBufferMesh,
useQuaternion,
visible,
castShadow,
receiveShadow,
parentEntity
receiveShadow
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();

View File

@ -19,19 +19,3 @@ GameLib.D3.API.Vertex = function(
}
this.boneWeights = boneWeights;
};
/**
* Creates an API vertex from an Object vertex
* @param objectVertex
* @constructor
*/
GameLib.D3.API.Vertex.FromObject = function(objectVertex) {
return new GameLib.D3.API.Vertex(
GameLib.API.Vector3.FromObject(objectVertex.position),
objectVertex.boneWeights.map(
function(boneWeight) {
return GameLib.D3.API.BoneWeight.FromObject(boneWeight);
}
)
);
};

View File

@ -36,7 +36,7 @@ GameLib.D3.Face = function Face(
apiFace.vertexNormals,
apiFace.normal,
apiFace.selected,
apiFace.parentMesh,
apiFace.parentGeometry,
apiFace.parentEntity
);
@ -119,9 +119,9 @@ GameLib.D3.Face.prototype.constructor = GameLib.D3.Face;
/**
* We don't follow the standard procedure for Faces - We don't want them in the EntityManager registry - so
* they don't call component createinstance
* @param parentMesh
* @param parentGeometry
*/
GameLib.D3.Face.prototype.createInstance = function(parentMesh) {
GameLib.D3.Face.prototype.createInstance = function(parentGeometry) {
this.instance = new THREE.Face3(
this.v0index,
@ -147,17 +147,17 @@ GameLib.D3.Face.prototype.createInstance = function(parentMesh) {
this.instance.materialIndex = this.materialIndex;
if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
if (GameLib.Utils.UndefinedOrNull(parentGeometry)) {
console.warn('please pass a parentmesh to face createInstance()');
}
this.parentMesh = parentMesh;
this.parentGeometry = parentGeometry;
};
GameLib.D3.Face.prototype.updateInstance = function(property, uvSet, uvIndex) {
if (property === 'materialIndex') {
this.instance.materialIndex = this.materialIndex;
this.parentMesh.instance.geometry.groupsNeedUpdate = true;
this.parentGeometry.instance.groupsNeedUpdate = true;
return;
}
@ -165,7 +165,7 @@ GameLib.D3.Face.prototype.updateInstance = function(property, uvSet, uvIndex) {
this.uvs[uvSet][uvIndex].instance.x = this.uvs[uvSet][uvIndex].x;
this.uvs[uvSet][uvIndex].instance.y = this.uvs[uvSet][uvIndex].y;
this.parentMesh.instance.geometry.uvsNeedUpdate = true;
this.parentGeometry.instance.uvsNeedUpdate = true;
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,258 @@
/**
* GameLib.D3.Geometry.Buffer
* @param graphics
* @param apiGeometry
* @property geometryType
* @constructor
*/
GameLib.D3.BufferGeometry = function(
graphics,
apiGeometry
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
apiGeometry = {
geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER
};
}
GameLib.D3.Geometry.call(
this,
apiGeometry
);
};
GameLib.D3.Geometry.Buffer.prototype = Object.create(GameLib.D3.Geometry.prototype);
GameLib.D3.Geometry.Buffer.prototype.constructor = GameLib.D3.Geometry.Buffer;
GameLib.D3.Geometry.Buffer.prototype.createInstance = function() {
/**
* First we try it this way - we setup things the old-school way
*/
GameLib.D3.Geometry.prototype.createInstance.call(this);
/**
* Then we convert to the new BufferGeometry type
*/
this.instance = new THREE.BufferGeometry().fromGeometry(this.instance);
// /**
// * Setup mesh vertices positions
// * @type {Float32Array}
// */
// 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);
// result.push(this.vertices[face.v0index].position.z);
// result.push(this.vertices[face.v1index].position.x);
// result.push(this.vertices[face.v1index].position.y);
// result.push(this.vertices[face.v1index].position.z);
// result.push(this.vertices[face.v2index].position.x);
// result.push(this.vertices[face.v2index].position.y);
// result.push(this.vertices[face.v2index].position.z);
// return result;
// }.bind(this),
// []
// )
//
// );
//
// this.instance.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
//
// /**
// * Setyp mesh vertices colors
// */
// var colors = new Float32Array(
// this.faces.reduce(
// function(result, face){
// result.push(1,1,1,1,1,1,1,1,1);
// // result.push(face.color.r);
// // result.push(face.color.g);
// // result.push(face.color.b);
// // result.push(face.color.r);
// // result.push(face.color.g);
// // result.push(face.color.b);
// // result.push(face.color.r);
// // result.push(face.color.g);
// // result.push(face.color.b);
// return result;
// }.bind(this),
// []
// )
// );
// geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true));
//
// /**
// * Setup face UVs
// */
// var uvs = new Float32Array(
// this.faces.reduce(
// function(result, face) {
//
// face.uvs[0].map(
// function(uv) {
// result.push(uv.x);
// result.push(uv.y);
// }
// );
//
// return result;
// },
// []
// )
// );
// geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
//
// var normals = new Float32Array(
// 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('normal', new THREE.BufferAttribute( normals, 3 ));
//
// geometry.computeVertexNormals();
//
//
// /**
// * Setup material groups - this means creating a new group for each material index change
// * We know faces are sorted according to material index
// */
// var groupIndexCounts = this.faces.reduce(
// function(result, face) {
//
// var currentGroup = result.pop();
//
// if (currentGroup.index !== face.materialIndex) {
// /**
// * We have a new group
// */
// result.push(currentGroup);
// result.push({
// index: face.materialIndex,
// count: 3
// })
// } else {
// currentGroup.count += 3;
// result.push(currentGroup);
// }
//
// return result;
// },
// [
// {
// index : 0,
// count : 0
// }
// ]
// );
//
// groupIndexCounts.reduce(
// function(start, group) {
// geometry.addGroup(start, group.count, group.index);
// return start + group.count;
// },
// 0
// );
//
//
// } else {
//
//
// }
};
GameLib.D3.Geometry.Buffer.prototype.updateInstance = function(property) {
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
console.warn('no geometry instance');
return;
}
GameLib.D3.Geometry.prototype.updateInstance.call(this, property);
};
/**
* Converts a GameLib.D3.Geometry to a GameLib.D3.API.Geometry
* @returns {GameLib.D3.API.Geometry}
*/
GameLib.D3.Geometry.Buffer.prototype.toApiObject = function() {
var apiGeometry = new GameLib.D3.API.Geometry(
this.id,
this.name,
this.geometryType,
this.isBufferGeometry,
GameLib.Utils.IdOrNull(this.parentEntity),
this.boundingBox.toApiObject(),
this.boundingSphere.toApiObject(),
this.colors.map(
function(color) {
return color.toApiObject();
}
),
this.faces.map(
function(face) {
return face.toApiObject();
}
),
this.lineDistances,
this.morphTargets,
this.morphNormals,
this.skinWeights.map(
function(skinWeight) {
return skinWeight.toApiObject();
}
),
this.skinIndices.map(
function(skinIndex) {
return skinIndex.toApiObject();
}
),
this.vertices.map(
function (vertex) {
return vertex.toApiObject();
}
),
this.verticesNeedsUpdate,
this.elementsNeedUpdate,
this.uvsNeedUpdate,
this.normalsNeedUpdate,
this.colorsNeedUpdate,
this.groupsNeedUpdate,
this.lineDistancesNeedUpdate
);
return apiGeometry;
};

View File

@ -187,255 +187,13 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
if (instanceGeometry instanceof THREE.Geometry) {
this.computeBoundingBox(instanceGeometry);
if (this.isBufferMesh) {
return new THREE.BufferGeometry().fromGeometry(instanceGeometry);
}
}
/**
* Setup face indexes - first we sort according to the material index, because later we will create
* groups for each vertice group
*/
this.faces.sort(function(a, b){
if (a.materialIndex < b.materialIndex) {
return -1;
}
if (a.materialIndex > b.materialIndex) {
return 1;
}
return 0;
});
/**
* Setup mesh vertices positions
* @type {Float32Array}
*/
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);
result.push(this.vertices[face.v0index].position.z);
result.push(this.vertices[face.v1index].position.x);
result.push(this.vertices[face.v1index].position.y);
result.push(this.vertices[face.v1index].position.z);
result.push(this.vertices[face.v2index].position.x);
result.push(this.vertices[face.v2index].position.y);
result.push(this.vertices[face.v2index].position.z);
return result;
}.bind(this),
[]
)
);
var geometry = null;
if (this.isBufferMesh) {
geometry = new THREE.BufferGeometry();
geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
/**
* Setyp mesh vertices colors
*/
var colors = new Float32Array(
this.faces.reduce(
function(result, face){
result.push(1,1,1,1,1,1,1,1,1);
// result.push(face.color.r);
// result.push(face.color.g);
// result.push(face.color.b);
// result.push(face.color.r);
// result.push(face.color.g);
// result.push(face.color.b);
// result.push(face.color.r);
// result.push(face.color.g);
// result.push(face.color.b);
return result;
}.bind(this),
[]
)
);
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true));
/**
* Setup face UVs
*/
var uvs = new Float32Array(
this.faces.reduce(
function(result, face) {
face.uvs[0].map(
function(uv) {
result.push(uv.x);
result.push(uv.y);
}
);
return result;
},
[]
)
);
geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2));
var normals = new Float32Array(
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('normal', new THREE.BufferAttribute( normals, 3 ));
geometry.computeVertexNormals();
/**
* Setup material groups - this means creating a new group for each material index change
* We know faces are sorted according to material index
*/
var groupIndexCounts = this.faces.reduce(
function(result, face) {
var currentGroup = result.pop();
if (currentGroup.index !== face.materialIndex) {
/**
* We have a new group
*/
result.push(currentGroup);
result.push({
index: face.materialIndex,
count: 3
})
} else {
currentGroup.count += 3;
result.push(currentGroup);
}
return result;
},
[
{
index : 0,
count : 0
}
]
);
groupIndexCounts.reduce(
function(start, group) {
geometry.addGroup(start, group.count, group.index);
return start + group.count;
},
0
);
} else {
geometry = new THREE.Geometry();
var standardUvs = [];
/**
* Face data
* @type {Array}
*/
geometry.faces = this.faces.map(
function (face) {
if (face.uvs[0].length > 0) {
standardUvs.push(
face.uvs[0].map(
function(uv) {
return uv.instance;
}
)
);
}
if (!face.instance) {
face.createInstance(this);
}
return face.instance;
}.bind(this)
);
/**
* Vertex data
* @type {Array}
*/
geometry.vertices = this.vertices.map(
function (vertex) {
return new THREE.Vector3(
vertex.position.x,
vertex.position.y,
vertex.position.z
)
}
);
geometry.verticesNeedUpdate = true;
/**
* UV data - but only if it exists
*/
if (standardUvs.length > 0) {
geometry.faceVertexUvs = [standardUvs];
}
/**
* Re-compute normals - we don't do this for buffer geometry because it assigns to every vertex normal the face
* normal - essentially disabling 'smooth shading'
*/
geometry.computeFaceNormals();
// geometry.computeBoundingBox();
geometry.computeVertexNormals();
// geometry.verticesNeedUpdate = true;
// geometry.elementsNeedUpdate = true;
// geometry.morphTargetsNeedUpdate = true;
// geometry.uvsNeedUpdate = true;
// geometry.normalsNeedUpdate = true;
// geometry.colorsNeedUpdate = true;
// geometry.tangentsNeedUpdate = true;
}
/**
* Apply skin indices
*/
// this.applyBones(geometry);
this.computeBoundingBox(geometry);
return geometry;
};
@ -1050,26 +808,6 @@ GameLib.D3.Mesh.prototype.getBoundingBox = function() {
*/
GameLib.D3.Mesh.prototype.toApiObject = function() {
var apiSkeleton = null;
if (this.skeleton) {
apiSkeleton = this.skeleton.id;
}
var apiMaterials = null;
if (this.materials) {
apiMaterials = this.materials.map(
function(material) {
return material.id;
}
)
}
var apiFaces = this.faces.map(
function(face){
return face.toApiObject();
}
);
var apiMesh = new GameLib.D3.API.Mesh(
this.id,
this.name,
@ -1080,11 +818,19 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
return vertex.toApiObject();
}
),
apiFaces,
apiMaterials,
this.faces.map(
function(face){
return face.toApiObject();
}
),
this.materials.map(
function(material) {
return GameLib.Utils.IdOrNull(material);
}
),
GameLib.Utils.IdOrNull(this.parentMesh),
GameLib.Utils.IdOrNull(this.parentScene),
apiSkeleton,
GameLib.Utils.IdOrNull(this.skeleton),
this.skinIndices,
this.skinWeights,
this.position.toApiObject(),
@ -1496,20 +1242,3 @@ GameLib.D3.Mesh.prototype.removeHelper = function() {
this.helper = null;
};
GameLib.D3.Mesh.prototype.computeBoundingBox = function(geometry) {
if (GameLib.Utils.UndefinedOrNull(geometry)) {
if (this.instance && this.instance.geometry) {
geometry = this.instance.geometry;
} else {
console.log('no instance geometry to compute bounding box');
}
}
geometry.computeBoundingBox();
this.dimensions.x = geometry.boundingBox.getSize().x;
this.dimensions.y = geometry.boundingBox.getSize().y;
this.dimensions.z = geometry.boundingBox.getSize().z;
};

View File

@ -1,21 +1,15 @@
/**
* Runtime Vertex
* @constructor
* GameLib.D3.Vertex
* @param implementation
* @param apiVertex
* @constructor
*/
GameLib.D3.Vertex = function Vertex(
implementation,
apiVertex
) {
this.implementation = implementation;
if (implementation instanceof GameLib.GraphicsRuntime) {
this.implementation.isNotThreeThrow();
} else if (implementation instanceof GameLib.PhysicsRuntime) {
this.implementation.isNotCannonThrow();
} else {
throw new Error('Unhandled implementation : ' + implementation);
}
this.implementation.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiVertex)) {
apiVertex = {};
@ -30,19 +24,18 @@ GameLib.D3.Vertex = function Vertex(
this.position = new GameLib.Vector3(
this.implementation,
this.position,
null
this
);
this.boneWeights = this.boneWeights.map(
function(boneWeight) {
return new GameLib.Vector4(
this.graphics,
boneWeight
)
}
);
if (implementation instanceof GameLib.GraphicsRuntime) {
this.boneWeights = this.boneWeights.map(
function(apiBoneWeight) {
return new GameLib.D3.BoneWeight(
this.implementation,
apiBoneWeight
)
}.bind(this)
)
}
};
GameLib.D3.Vertex.prototype = Object.create(GameLib.Component.prototype);
@ -56,28 +49,11 @@ GameLib.D3.Vertex.prototype.toApiObject = function() {
return new GameLib.D3.API.Vertex(
this.position.toApiObject(),
this.boneWeights.map(function(boneWeight){
return boneWeight.toApiObject();
})
this.boneWeights.map(
function(boneWeight){
return boneWeight.toApiObject();
}
)
);
};
/**
* Returns a GameLib.D3.Vertex from a vertex Object
* @param implementation (graphics or physics object)
* @param objectVertex Object
* @returns {GameLib.D3.Vertex}
* @constructor
*/
GameLib.D3.Vertex.FromObject = function(
implementation,
objectVertex
) {
var apiVertex = GameLib.D3.API.Vertex.FromObject(objectVertex);
return new GameLib.D3.Vertex(
implementation,
apiVertex
);
};

View File

@ -0,0 +1,82 @@
/**
* GameLib.DrawRange
* @param implementation
* @param apiDrawRange
* @param parentGeometry
* @constructor
*/
GameLib.DrawRange = function (
implementation,
apiDrawRange,
parentGeometry
) {
this.implementation = implementation;
this.implementation.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiDrawRange)) {
apiDrawRange = {};
}
if (GameLib.Utils.UndefinedOrNull(parentGeometry)) {
parentGeometry = null;
}
this.parentGeometry = parentGeometry;
GameLib.API.DrawRange.call(
this,
apiDrawRange.id,
apiDrawRange.name,
apiDrawRange.parentEntity,
apiDrawRange.start,
apiDrawRange.count
);
this.createInstance();
};
GameLib.DrawRange.prototype = Object.create(GameLib.Component.prototype);
GameLib.DrawRange.prototype.constructor = GameLib.DrawRange;
/**
* Creates an instance GameLib.DrawRange
* @returns {*}
*/
GameLib.DrawRange.prototype.createInstance = function() {
this.instance = {
start : this.start,
count : this.count
}
};
/**
* Updates GameLib.DrawRange instance
* @param property
*/
GameLib.DrawRange.prototype.updateInstance = function(property) {
console.warn('update the geometry instead');
if (property === 'start') {
}
if (property === 'count') {
}
};
/**
* GameLib.DrawRange to GameLib.API.DrawRange
* @returns {GameLib.API.DrawRange}
*/
GameLib.DrawRange.prototype.toApiObject = function() {
return new GameLib.API.DrawRange(
this.id,
this.name,
GameLib.Utils.IdOrNull(this.parentEntity),
this.start,
this.count
);
};

88
src/game-lib-group.js Normal file
View File

@ -0,0 +1,88 @@
/**
* GameLib.Group
* @param implementation
* @param apiGroup
* @param parentGeometry
* @constructor
*/
GameLib.Group = function (
implementation,
apiGroup,
parentGeometry
) {
this.implementation = implementation;
this.implementation.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(parentGeometry)) {
parentGeometry = null;
}
this.parentGeometry = parentGeometry;
if (GameLib.Utils.UndefinedOrNull(apiGroup)) {
apiGroup = {};
}
GameLib.API.Group.call(
this,
apiGroup.id,
apiGroup.name,
apiGroup.parentEntity,
apiGroup.start,
apiGroup.count,
apiGroup.materialIndex
);
this.createInstance();
};
GameLib.Group.prototype = Object.create(GameLib.Component.prototype);
GameLib.Group.prototype.constructor = GameLib.Group;
/**
* Creates an instance GameLib.Group
* @returns {*}
*/
GameLib.Group.prototype.createInstance = function() {
this.instance = {
start : this.start,
count : this.count,
materialIndex : this.materialIndex
}
};
/**
* Updates GameLib.Group instance
* @param property
*/
GameLib.Group.prototype.updateInstance = function(property) {
console.warn('update the geometry instead');
if (property === 'start') {
}
if (property === 'count') {
}
if (property === 'materialIndex') {
}
};
/**
* GameLib.Group to GameLib.API.Group
* @returns {GameLib.API.Group}
*/
GameLib.Group.prototype.toApiObject = function() {
return new GameLib.API.Group(
this.id,
this.name,
GameLib.Utils.IdOrNull(this.parentEntity),
this.start,
this.count,
this.materialIndex
);
};