all api geometries in
parent
25d79e72ea
commit
20849ace15
|
@ -424,8 +424,8 @@ GameLib.Utils.InvertMeshWindingOrder = function(mesh) {
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
mesh.computeNormals = true;
|
//mesh.computeNormals = true;
|
||||||
mesh.createInstance();
|
//mesh.createInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -333,7 +333,37 @@ GameLib.Component.PASS_FXAA = 0x64;
|
||||||
GameLib.Component.RENDER_CONFIGURATION = 0x65;
|
GameLib.Component.RENDER_CONFIGURATION = 0x65;
|
||||||
GameLib.Component.MATERIAL_BASIC = 0x66;
|
GameLib.Component.MATERIAL_BASIC = 0x66;
|
||||||
GameLib.Component.TEXTURE = 0x67;
|
GameLib.Component.TEXTURE = 0x67;
|
||||||
GameLib.Component.MAX_COMPONENTS = 0x68;
|
GameLib.Component.MATERIAL_PHONG = 0x68;
|
||||||
|
|
||||||
|
GameLib.Component.GEOMETRY = 0x69;
|
||||||
|
GameLib.Component.GEOMETRY_BOX = 0x6a;
|
||||||
|
GameLib.Component.GEOMETRY_CIRCLE = 0x6b;
|
||||||
|
GameLib.Component.GEOMETRY_CONE = 0x6c;
|
||||||
|
GameLib.Component.GEOMETRY_CYLINDER = 0x6d;
|
||||||
|
GameLib.Component.GEOMETRY_DODECAHEDRON = 0x6e;
|
||||||
|
GameLib.Component.GEOMETRY_EDGES = 0x6f;
|
||||||
|
GameLib.Component.GEOMETRY_EXTRUDE = 0x70;
|
||||||
|
GameLib.Component.GEOMETRY_ICOSAHEDRON = 0x71;
|
||||||
|
GameLib.Component.GEOMETRY_LATHE = 0x72;
|
||||||
|
GameLib.Component.GEOMETRY_OCTAHEDRON = 0x73;
|
||||||
|
GameLib.Component.GEOMETRY_PARAMETRIC = 0x74;
|
||||||
|
GameLib.Component.GEOMETRY_PLANE = 0x75;
|
||||||
|
GameLib.Component.GEOMETRY_POLYHEDRON = 0x76;
|
||||||
|
GameLib.Component.GEOMETRY_RING = 0x77;
|
||||||
|
GameLib.Component.GEOMETRY_SHAPE = 0x78;
|
||||||
|
GameLib.Component.GEOMETRY_SPHERE = 0x79;
|
||||||
|
GameLib.Component.GEOMETRY_TETRAHEDRON = 0x7a;
|
||||||
|
GameLib.Component.GEOMETRY_TEXT = 0x7b;
|
||||||
|
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.GRAPHICS_RUNTIME = 0x1;
|
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
|
||||||
GameLib.Component.PHYSICS_RUNTIME = 0x2;
|
GameLib.Component.PHYSICS_RUNTIME = 0x2;
|
||||||
|
@ -972,6 +1002,174 @@ GameLib.Component.GetComponentInfo = function(number) {
|
||||||
constructor : GameLib.D3.Texture,
|
constructor : GameLib.D3.Texture,
|
||||||
apiConstructor : GameLib.D3.API.Texture
|
apiConstructor : GameLib.D3.API.Texture
|
||||||
};
|
};
|
||||||
|
case 0x68 : return {
|
||||||
|
name : 'GameLib.D3.Material.Phong',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Material.Phong,
|
||||||
|
apiConstructor : GameLib.D3.API.Material.Phong
|
||||||
|
};
|
||||||
|
case 0x69 : return {
|
||||||
|
name : 'GameLib.D3.Geometry',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry
|
||||||
|
};
|
||||||
|
case 0x6a : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Box',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Box,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Box
|
||||||
|
};
|
||||||
|
case 0x6b : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Circle',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Circle,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Circle
|
||||||
|
};
|
||||||
|
case 0x6c : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Cone',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Cone,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Cone
|
||||||
|
};
|
||||||
|
case 0x6d : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Cylinder',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Cylinder,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Cylinder
|
||||||
|
};
|
||||||
|
case 0x6e : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Dodecahedron',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Dodecahedron,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Dodecahedron
|
||||||
|
};
|
||||||
|
case 0x6f : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Edges',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Edges,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Edges
|
||||||
|
};
|
||||||
|
case 0x70 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Extrude',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Extrude,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Extrude
|
||||||
|
};
|
||||||
|
case 0x71 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Icosahedron',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Icosahedron,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Icosahedron
|
||||||
|
};
|
||||||
|
case 0x72 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Lathe',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Lathe,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Lathe
|
||||||
|
};
|
||||||
|
case 0x73 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Octahedron',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Octahedron,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Octahedron
|
||||||
|
};
|
||||||
|
case 0x74 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Parametric',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Parametric,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Parametric
|
||||||
|
};
|
||||||
|
case 0x75 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Plane',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Plane,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Plane
|
||||||
|
};
|
||||||
|
case 0x76 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Polyhedron',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Polyhedron,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Polyhedron
|
||||||
|
};
|
||||||
|
case 0x77 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Ring',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Ring,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Ring
|
||||||
|
};
|
||||||
|
case 0x78 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Shape',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Shape,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Shape
|
||||||
|
};
|
||||||
|
case 0x79 : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Sphere',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Sphere,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Sphere
|
||||||
|
};
|
||||||
|
case 0x7a : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Tetrahedron',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Tetrahedron,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Tetrahedron
|
||||||
|
};
|
||||||
|
case 0x7b : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Text',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Text,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Text
|
||||||
|
};
|
||||||
|
case 0x7c : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Torus',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Torus,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Torus
|
||||||
|
};
|
||||||
|
case 0x7d : return {
|
||||||
|
name : 'GameLib.D3.Geometry.TorusKnot',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.TorusKnot,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.TorusKnot
|
||||||
|
};
|
||||||
|
case 0x7e : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Tube',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Tube,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Tube
|
||||||
|
};
|
||||||
|
case 0x7f : return {
|
||||||
|
name : 'GameLib.D3.Geometry.Wireframe',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Geometry.Wireframe,
|
||||||
|
apiConstructor : GameLib.D3.API.Geometry.Wireframe
|
||||||
|
};
|
||||||
|
case 0x80 : return {
|
||||||
|
name : 'GameLib.Curve',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.Curve,
|
||||||
|
apiConstructor : GameLib.API.Curve
|
||||||
|
};
|
||||||
|
case 0x81 : return {
|
||||||
|
name : 'GameLib.Curve.Path',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.Curve.Path,
|
||||||
|
apiConstructor : GameLib.API.Curve.Path
|
||||||
|
};
|
||||||
|
case 0x82 : 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 {
|
||||||
|
name : 'GameLib.Curve.Path.D2.Shape',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.Curve.Path.D2.Shape,
|
||||||
|
apiConstructor : GameLib.API.Curve.Path.D2.Shape
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* GameLib.API.Box3
|
||||||
|
* @param min
|
||||||
|
* @param max
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.API.Box3 = function (
|
||||||
|
min,
|
||||||
|
max
|
||||||
|
) {
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(min)) {
|
||||||
|
min = new GameLib.API.Vector3(0,0,0);
|
||||||
|
}
|
||||||
|
this.min = min;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(max)) {
|
||||||
|
max = new GameLib.API.Vector3(1,1,1);
|
||||||
|
}
|
||||||
|
this.max = max;
|
||||||
|
};
|
|
@ -0,0 +1,89 @@
|
||||||
|
/**
|
||||||
|
* GameLib.API.Curve
|
||||||
|
* @param id
|
||||||
|
* @param name
|
||||||
|
* @param curveType
|
||||||
|
* @param parentEntity
|
||||||
|
* @param arcLenghDivisions
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.API.Curve = function (
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
curveType,
|
||||||
|
parentEntity,
|
||||||
|
arcLenghDivisions
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.Utils.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(curveType)) {
|
||||||
|
curveType = GameLib.API.Curve.CURVE_TYPE_NONE;
|
||||||
|
}
|
||||||
|
this.curveType = curveType;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||||
|
|
||||||
|
switch (this.curveType) {
|
||||||
|
case GameLib.API.Curve.CURVE_TYPE_NONE :
|
||||||
|
name = 'Curve';
|
||||||
|
break;
|
||||||
|
case GameLib.API.Curve.CURVE_TYPE_PATH :
|
||||||
|
name = 'Curve Path';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('no nice name for curve');
|
||||||
|
}
|
||||||
|
|
||||||
|
name += ' (' + this.id + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(arcLenghDivisions)) {
|
||||||
|
arcLenghDivisions = 200;
|
||||||
|
}
|
||||||
|
this.arcLenghDivisions = arcLenghDivisions;
|
||||||
|
|
||||||
|
GameLib.API.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.API.Curve.GetComponentType(this.curveType),
|
||||||
|
parentEntity
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.API.Curve.prototype = Object.create(GameLib.API.Curve.prototype);
|
||||||
|
GameLib.API.Curve.prototype.constructor = GameLib.API.Curve;
|
||||||
|
|
||||||
|
GameLib.API.Curve.GetComponentType = function(curveType) {
|
||||||
|
|
||||||
|
var componentType = null;
|
||||||
|
|
||||||
|
switch (curveType) {
|
||||||
|
case GameLib.API.Curve.CURVE_TYPE_NONE :
|
||||||
|
componentType = GameLib.Component.CURVE;
|
||||||
|
break;
|
||||||
|
case GameLib.API.Curve.CURVE_TYPE_PATH :
|
||||||
|
componentType = GameLib.Component.CURVE_PATH;
|
||||||
|
break;
|
||||||
|
case GameLib.API.Curve.CURVE_TYPE_PATH_2D :
|
||||||
|
componentType = GameLib.Component.CURVE_PATH_D2;
|
||||||
|
break;
|
||||||
|
case GameLib.API.Curve.CURVE_TYPE_PATH_2D_SHAPE :
|
||||||
|
componentType = GameLib.Component.CURVE_PATH_D2_SHAPE;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
throw new Error('unhandled curve type');
|
||||||
|
}
|
||||||
|
|
||||||
|
return componentType;
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.API.Curve.CURVE_TYPE_NONE = 0x0;
|
||||||
|
GameLib.API.Curve.CURVE_TYPE_PATH = 0x1;
|
||||||
|
GameLib.API.Curve.CURVE_TYPE_PATH_2D = 0x2;
|
||||||
|
GameLib.API.Curve.CURVE_TYPE_PATH_2D_SHAPE = 0x3;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* GameLib.API.Curve.Path
|
||||||
|
* @constructor
|
||||||
|
* @param apiCurve
|
||||||
|
* @param curves
|
||||||
|
* @param autoClose
|
||||||
|
*/
|
||||||
|
GameLib.API.Curve.Path = function (
|
||||||
|
apiCurve,
|
||||||
|
curves,
|
||||||
|
autoClose
|
||||||
|
) {
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurve)) {
|
||||||
|
apiCurve = {
|
||||||
|
curveType: GameLib.API.Curve.CURVE_TYPE_PATH
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurve.curveType)) {
|
||||||
|
apiCurve.curveType = GameLib.API.Curve.CURVE_TYPE_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(curves)) {
|
||||||
|
curves = [];
|
||||||
|
}
|
||||||
|
this.curves = curves;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(autoClose)) {
|
||||||
|
autoClose = false;
|
||||||
|
}
|
||||||
|
this.autoClose = autoClose;
|
||||||
|
|
||||||
|
GameLib.API.Curve.call(
|
||||||
|
this,
|
||||||
|
apiCurve.id,
|
||||||
|
apiCurve.name,
|
||||||
|
apiCurve.curveType,
|
||||||
|
apiCurve.parentEntity,
|
||||||
|
apiCurve.arcLenghDivisions
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.API.Curve.Path.prototype = Object.create(GameLib.API.Curve.prototype);
|
||||||
|
GameLib.API.Curve.Path.prototype.constructor = GameLib.API.Curve.Path;
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
* GameLib.API.Curve.Path.D2
|
||||||
|
* @constructor
|
||||||
|
* @param apiCurvePath
|
||||||
|
* @param points
|
||||||
|
*/
|
||||||
|
GameLib.API.Curve.Path.D2 = function (
|
||||||
|
apiCurvePath,
|
||||||
|
points
|
||||||
|
) {
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurvePath)) {
|
||||||
|
apiCurvePath = {
|
||||||
|
curveType: GameLib.API.Curve.CURVE_TYPE_PATH_2D
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurvePath.curveType)) {
|
||||||
|
apiCurvePath.curveType = GameLib.API.Curve.CURVE_TYPE_PATH_2D;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(points)) {
|
||||||
|
points = [];
|
||||||
|
}
|
||||||
|
this.points = points;
|
||||||
|
|
||||||
|
GameLib.API.Curve.Path.call(
|
||||||
|
this,
|
||||||
|
apiCurvePath,
|
||||||
|
apiCurvePath.curves,
|
||||||
|
apiCurvePath.autoClose
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.API.Curve.Path.D2.prototype = Object.create(GameLib.API.Curve.Path.prototype);
|
||||||
|
GameLib.API.Curve.Path.D2.prototype.constructor = GameLib.API.Curve.Path.D2;
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* GameLib.API.Curve.Path.D2.Shape
|
||||||
|
* @constructor
|
||||||
|
* @param apiCurvePathD2
|
||||||
|
*/
|
||||||
|
GameLib.API.Curve.Path.D2.Shape = function (
|
||||||
|
apiCurvePathD2
|
||||||
|
) {
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurvePathD2)) {
|
||||||
|
apiCurvePathD2 = {
|
||||||
|
curveType : GameLib.API.Curve.CURVE_TYPE_PATH_2D_SHAPE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurvePathD2.curveType)) {
|
||||||
|
apiCurvePathD2.curveType = GameLib.API.Curve.CURVE_TYPE_PATH_2D_SHAPE ;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.API.Curve.Path.call(
|
||||||
|
this,
|
||||||
|
apiCurvePathD2,
|
||||||
|
apiCurvePathD2.points
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.API.Curve.Path.D2.Shape.prototype = Object.create(GameLib.API.Curve.Path.D2.prototype);
|
||||||
|
GameLib.API.Curve.Path.D2.Shape.prototype.constructor = GameLib.API.Curve.Path.D2.Shape;
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* GameLib.API.Sphere
|
||||||
|
* @constructor
|
||||||
|
* @param center
|
||||||
|
* @param radius
|
||||||
|
*/
|
||||||
|
GameLib.API.Sphere = function (
|
||||||
|
center,
|
||||||
|
radius
|
||||||
|
) {
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(center)) {
|
||||||
|
center = new GameLib.API.Vector3(0,0,0);
|
||||||
|
}
|
||||||
|
this.center = center;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(radius)) {
|
||||||
|
radius = 1;
|
||||||
|
}
|
||||||
|
this.radius = radius;
|
||||||
|
};
|
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
* GameLib.Box3
|
||||||
|
* @param implementation
|
||||||
|
* @param apiBox3
|
||||||
|
* @param parentObject
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.Box3 = function (
|
||||||
|
implementation,
|
||||||
|
apiBox3,
|
||||||
|
parentObject
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.implementation = implementation;
|
||||||
|
this.implementation.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentObject)) {
|
||||||
|
parentObject = null;
|
||||||
|
}
|
||||||
|
this.parentObject = parentObject;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiBox3)) {
|
||||||
|
apiBox3 = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.API.Box3.call(
|
||||||
|
this,
|
||||||
|
apiBox3.min,
|
||||||
|
apiBox3.max
|
||||||
|
);
|
||||||
|
|
||||||
|
this.createInstance();
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.Box3.prototype = Object.create(GameLib.API.Box3.prototype);
|
||||||
|
GameLib.Box3.prototype.constructor = GameLib.Box3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance GameLib.Box3
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.Box3.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
this.instance = new THREE.Box3(
|
||||||
|
this.min.instance,
|
||||||
|
this.max.instance
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates GameLib.Box3 instance
|
||||||
|
* @param property
|
||||||
|
*/
|
||||||
|
GameLib.Box3.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (property === 'min') {
|
||||||
|
this.instance.min.x = this.min.x;
|
||||||
|
this.instance.min.y = this.min.y;
|
||||||
|
this.instance.min.z = this.min.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'max') {
|
||||||
|
this.instance.max.x = this.max.x;
|
||||||
|
this.instance.max.y = this.max.y;
|
||||||
|
this.instance.max.z = this.max.z;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GameLib.Box3 to GameLib.API.Box3
|
||||||
|
* @returns {GameLib.API.Box3}
|
||||||
|
*/
|
||||||
|
GameLib.Box3.prototype.toApiObject = function() {
|
||||||
|
return new GameLib.API.Box3(
|
||||||
|
this.min.toApiObject(),
|
||||||
|
this.max.toApiObject()
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,87 @@
|
||||||
|
/**
|
||||||
|
* GameLib.Curve
|
||||||
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
|
* @param apiCurve GameLib.API.Curve
|
||||||
|
* @property curveType
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.Curve = function(
|
||||||
|
graphics,
|
||||||
|
apiCurve
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurve)) {
|
||||||
|
apiCurve = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.API.Curve.call(
|
||||||
|
this,
|
||||||
|
apiCurve.id,
|
||||||
|
apiCurve.name,
|
||||||
|
apiCurve.curveType,
|
||||||
|
apiCurve.parentEntity,
|
||||||
|
apiCurve.arcLenghDivisions
|
||||||
|
);
|
||||||
|
|
||||||
|
var linkedObjects = {};
|
||||||
|
|
||||||
|
switch (this.curveType) {
|
||||||
|
case GameLib.API.Curve.CURVE_TYPE_PATH :
|
||||||
|
linkedObjects.curves = [GameLib.Curve];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
linkedObjects
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.Curve.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
GameLib.Curve.prototype.constructor = GameLib.Curve;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Instance
|
||||||
|
*/
|
||||||
|
GameLib.Curve.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
||||||
|
console.warn('you should not instantiate this curve object directly');
|
||||||
|
this.instance = new THREE.Curve();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.instance.arcLenghDivisions = this.arcLenghDivisions;
|
||||||
|
|
||||||
|
GameLib.Component.prototype.createInstance.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance with the current state
|
||||||
|
*/
|
||||||
|
GameLib.Curve.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (property === 'arcLenghDivisions') {
|
||||||
|
this.instance.arcLenghDivisions = this.arcLenghDivisions;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.Component.prototype.updateInstance.call(this, property);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.Curve to a new GameLib.API.Curve
|
||||||
|
* @returns {GameLib.API.Curve}
|
||||||
|
*/
|
||||||
|
GameLib.Curve.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
return new GameLib.API.Curve(
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.curveType,
|
||||||
|
GameLib.Utils.IdOrNull(this.parentEntity),
|
||||||
|
this.arcLenghDivisions
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
* GameLib.Curve.Path.D2
|
||||||
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
|
* @param apiCurvePathD2
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.D2.Shape = function(
|
||||||
|
graphics,
|
||||||
|
apiCurvePathD2
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurvePathD2)) {
|
||||||
|
apiCurvePathD2 = {
|
||||||
|
curveType : GameLib.API.Curve.CURVE_TYPE_PATH_2D_SHAPE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.API.Curve.Path.D2.call(
|
||||||
|
this,
|
||||||
|
apiCurvePathD2,
|
||||||
|
apiCurvePathD2.points
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.Curve.Path.D2.call(
|
||||||
|
this,
|
||||||
|
this.graphics,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.Curve.Path.D2.Shape.prototype = Object.create(GameLib.Curve.Path.D2.prototype);
|
||||||
|
GameLib.Curve.Path.D2.Shape.prototype.constructor = GameLib.Curve.Path.D2.Shape;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a camera instance
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.D2.Shape.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
this.instance = new THREE.Shape(
|
||||||
|
this.points.map(
|
||||||
|
function(point) {
|
||||||
|
return point.instance;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.Curve.Path.D2.prototype.createInstance.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance with the current state
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.D2.Shape.prototype.updateInstance = function(property) {
|
||||||
|
GameLib.Curve.Path.D2.prototype.updateInstance.call(this, property);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.Curve to a GameLib.API.Curve
|
||||||
|
* @returns {GameLib.API.Curve}
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.D2.Shape.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiCurvePathD2 = GameLib.Curve.Path.D2.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
|
return new GameLib.API.Curve.Path.D2.Shape(
|
||||||
|
apiCurvePathD2
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,101 @@
|
||||||
|
/**
|
||||||
|
* GameLib.Curve.Path.D2
|
||||||
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
|
* @param apiCurvePath
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.D2 = function(
|
||||||
|
graphics,
|
||||||
|
apiCurvePath
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurvePath)) {
|
||||||
|
apiCurvePath = {
|
||||||
|
curveType : GameLib.API.Curve.CURVE_TYPE_PATH_2D
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.API.Curve.Path.D2.call(
|
||||||
|
this,
|
||||||
|
apiCurvePath,
|
||||||
|
apiCurvePath.points
|
||||||
|
);
|
||||||
|
|
||||||
|
this.points = this.points.map(
|
||||||
|
function(point) {
|
||||||
|
return new GameLib.Vector2(
|
||||||
|
this.graphics,
|
||||||
|
point
|
||||||
|
);
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.Curve.Path.call(
|
||||||
|
this,
|
||||||
|
this.graphics,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.Curve.Path.D2.prototype = Object.create(GameLib.Curve.Path.prototype);
|
||||||
|
GameLib.Curve.Path.D2.prototype.constructor = GameLib.Curve.Path.D2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a camera instance
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.D2.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
||||||
|
this.instance = new THREE.Path(
|
||||||
|
this.points.map(
|
||||||
|
function(point) {
|
||||||
|
return point.instance;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.Curve.Path.prototype.createInstance.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance with the current state
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.D2.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (property === 'points') {
|
||||||
|
console.warn('todo: update points (and test it)');
|
||||||
|
this.instance.points = this.points.map(
|
||||||
|
function(point) {
|
||||||
|
return point.instance;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.Curve.Path.prototype.updateInstance.call(this, property);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.Curve to a GameLib.API.Curve
|
||||||
|
* @returns {GameLib.API.Curve}
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.D2.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiCurvePath = GameLib.Curve.Path.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
|
return new GameLib.API.Curve.Path.D2(
|
||||||
|
apiCurvePath,
|
||||||
|
this.points.map(
|
||||||
|
function(point) {
|
||||||
|
return point.toApiObject();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,109 @@
|
||||||
|
/**
|
||||||
|
* GameLib.Curve.Path
|
||||||
|
* @param graphics GameLib.GraphicsRuntime
|
||||||
|
* @param apiCurvePath
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path = function(
|
||||||
|
graphics,
|
||||||
|
apiCurvePath
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiCurvePath)) {
|
||||||
|
apiCurvePath = {
|
||||||
|
curveType : GameLib.API.Curve.CURVE_TYPE_PATH
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.API.Curve.Path.call(
|
||||||
|
this,
|
||||||
|
apiCurvePath,
|
||||||
|
apiCurvePath.curves,
|
||||||
|
apiCurvePath.autoClose
|
||||||
|
);
|
||||||
|
|
||||||
|
this.curves = this.curves.map(
|
||||||
|
function(curve) {
|
||||||
|
if (curve instanceof GameLib.API.Curve) {
|
||||||
|
return new GameLib.Curve(
|
||||||
|
this.graphics,
|
||||||
|
curve
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.Curve.call(
|
||||||
|
this,
|
||||||
|
this.graphics,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.Curve.Path.prototype = Object.create(GameLib.Curve.prototype);
|
||||||
|
GameLib.Curve.Path.prototype.constructor = GameLib.Curve.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a camera instance
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
||||||
|
console.warn('you should not instantiate this curve object directly');
|
||||||
|
this.instance = new THREE.CurvePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.instance.curves = this.curves.map(
|
||||||
|
function(curve) {
|
||||||
|
return curve.instance;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.instance.autoClose = this.autoClose;
|
||||||
|
|
||||||
|
GameLib.Curve.prototype.createInstance.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance with the current state
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (property === 'curves') {
|
||||||
|
console.warn('todo: update curves');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'autoClose') {
|
||||||
|
this.instance.autoClose = this.autoClose;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.Curve.prototype.updateInstance.call(this, property);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.Curve to a GameLib.API.Curve
|
||||||
|
* @returns {GameLib.API.Curve}
|
||||||
|
*/
|
||||||
|
GameLib.Curve.Path.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiCurve = GameLib.Curve.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
|
var apiCurvePath = new GameLib.API.Curve.Path(
|
||||||
|
apiCurve,
|
||||||
|
this.curves.map(
|
||||||
|
function(curve) {
|
||||||
|
return GameLib.Utils.IdOrNull(curve);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
this.autoClose
|
||||||
|
);
|
||||||
|
|
||||||
|
return apiCurvePath;
|
||||||
|
};
|
|
@ -5,6 +5,8 @@
|
||||||
* @param cameraType GameLib.D3.API.Camera.CAMERA_TYPE_*
|
* @param cameraType GameLib.D3.API.Camera.CAMERA_TYPE_*
|
||||||
* @param aspect
|
* @param aspect
|
||||||
* @param position GameLib.API.Vector3
|
* @param position GameLib.API.Vector3
|
||||||
|
* @param rotation
|
||||||
|
* @param quaternion
|
||||||
* @param lookAt GameLib.API.Vector3
|
* @param lookAt GameLib.API.Vector3
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -15,6 +17,8 @@ GameLib.D3.API.Camera = function(
|
||||||
cameraType,
|
cameraType,
|
||||||
aspect,
|
aspect,
|
||||||
position,
|
position,
|
||||||
|
rotation,
|
||||||
|
quaternion,
|
||||||
lookAt,
|
lookAt,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
@ -77,6 +81,16 @@ GameLib.D3.API.Camera = function(
|
||||||
}
|
}
|
||||||
this.lookAt = lookAt;
|
this.lookAt = lookAt;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(rotation)) {
|
||||||
|
rotation = new GameLib.API.Vector3();
|
||||||
|
}
|
||||||
|
this.rotation = rotation;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(quaternion)) {
|
||||||
|
quaternion = new GameLib.API.Quaternion();
|
||||||
|
}
|
||||||
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
var componentType = null;
|
var componentType = null;
|
||||||
|
|
||||||
switch (this.cameraType) {
|
switch (this.cameraType) {
|
||||||
|
|
|
@ -55,6 +55,8 @@ GameLib.D3.API.Camera.Cube = function(
|
||||||
apiCamera.cameraType,
|
apiCamera.cameraType,
|
||||||
1,
|
1,
|
||||||
apiCamera.position,
|
apiCamera.position,
|
||||||
|
apiCamera.rotation,
|
||||||
|
apiCamera.quaternion,
|
||||||
apiCamera.lookAt,
|
apiCamera.lookAt,
|
||||||
apiCamera.parentEntity
|
apiCamera.parentEntity
|
||||||
);
|
);
|
||||||
|
|
|
@ -111,6 +111,8 @@ GameLib.D3.API.Camera.Orthographic = function(
|
||||||
apiCamera.cameraType,
|
apiCamera.cameraType,
|
||||||
apiCamera.aspect,
|
apiCamera.aspect,
|
||||||
apiCamera.position,
|
apiCamera.position,
|
||||||
|
apiCamera.rotation,
|
||||||
|
apiCamera.quaternion,
|
||||||
apiCamera.lookAt,
|
apiCamera.lookAt,
|
||||||
apiCamera.parentEntity
|
apiCamera.parentEntity
|
||||||
);
|
);
|
||||||
|
|
|
@ -80,6 +80,8 @@ GameLib.D3.API.Camera.Perspective = function(
|
||||||
apiCamera.cameraType,
|
apiCamera.cameraType,
|
||||||
apiCamera.aspect,
|
apiCamera.aspect,
|
||||||
apiCamera.position,
|
apiCamera.position,
|
||||||
|
apiCamera.rotation,
|
||||||
|
apiCamera.quaternion,
|
||||||
apiCamera.lookAt,
|
apiCamera.lookAt,
|
||||||
apiCamera.parentEntity
|
apiCamera.parentEntity
|
||||||
);
|
);
|
||||||
|
|
|
@ -31,6 +31,8 @@ GameLib.D3.API.Camera.Stereo = function(
|
||||||
apiCamera.cameraType,
|
apiCamera.cameraType,
|
||||||
apiCamera.aspect,
|
apiCamera.aspect,
|
||||||
apiCamera.position,
|
apiCamera.position,
|
||||||
|
apiCamera.rotation,
|
||||||
|
apiCamera.quaternion,
|
||||||
apiCamera.lookAt,
|
apiCamera.lookAt,
|
||||||
apiCamera.parentEntity
|
apiCamera.parentEntity
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,351 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry
|
||||||
|
* @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
|
||||||
|
* @param skinWeights
|
||||||
|
* @param skinIndices
|
||||||
|
* @param vertices
|
||||||
|
* @param verticesNeedsUpdate
|
||||||
|
* @param elementsNeedUpdate
|
||||||
|
* @param uvsNeedUpdate
|
||||||
|
* @param normalsNeedUpdate
|
||||||
|
* @param colorsNeedUpdate
|
||||||
|
* @param groupsNeedUpdate
|
||||||
|
* @param lineDistancesNeedUpdate
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry = function(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
geometryType,
|
||||||
|
isBuffer,
|
||||||
|
parentEntity,
|
||||||
|
boundingBox,
|
||||||
|
boundingSphere,
|
||||||
|
colors,
|
||||||
|
faces,
|
||||||
|
faceVertexUvs,
|
||||||
|
lineDistances,
|
||||||
|
morphTargets,
|
||||||
|
morphNormals,
|
||||||
|
skinWeights,
|
||||||
|
skinIndices,
|
||||||
|
vertices,
|
||||||
|
verticesNeedsUpdate,
|
||||||
|
elementsNeedUpdate,
|
||||||
|
uvsNeedUpdate,
|
||||||
|
normalsNeedUpdate,
|
||||||
|
colorsNeedUpdate,
|
||||||
|
groupsNeedUpdate,
|
||||||
|
lineDistancesNeedUpdate
|
||||||
|
) {
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
|
id = GameLib.Utils.RandomId();
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(geometryType)) {
|
||||||
|
geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL;
|
||||||
|
}
|
||||||
|
this.geometryType = geometryType;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||||
|
|
||||||
|
switch (this.geometryType) {
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL :
|
||||||
|
name = 'Geometry';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX :
|
||||||
|
name = 'Geometry Box';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE :
|
||||||
|
name = 'Geometry Circle';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE :
|
||||||
|
name = 'Geometry Cone';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER :
|
||||||
|
name = 'Geometry Cylinder';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON :
|
||||||
|
name = 'Geometry Dodecahedron';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES :
|
||||||
|
name = 'Geometry Edges';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE :
|
||||||
|
name = 'Geometry Extrude';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON :
|
||||||
|
name = 'Geometry Icosahedron';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE :
|
||||||
|
name = 'Geometry Lathe';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON :
|
||||||
|
name = 'Geometry Octahedron';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC :
|
||||||
|
name = 'Geometry Parametric';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE :
|
||||||
|
name = 'Geometry Plane';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON :
|
||||||
|
name = 'Geometry Polyhedron';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING :
|
||||||
|
name = 'Geometry Ring';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE :
|
||||||
|
name = 'Geometry Shape';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE :
|
||||||
|
name = 'Geometry Sphere';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON :
|
||||||
|
name = 'Geometry Tetrahedron';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT :
|
||||||
|
name = 'Geometry Text';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS :
|
||||||
|
name = 'Geometry Torus';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT :
|
||||||
|
name = 'Geometry Torus Knot';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE :
|
||||||
|
name = 'Geometry Tube';
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME :
|
||||||
|
name = 'Geometry Wireframe';
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
console.warn('no nice name for geometry');
|
||||||
|
name = 'Geometry';
|
||||||
|
}
|
||||||
|
|
||||||
|
name += ' (' + id + ')';
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(isBuffer)) {
|
||||||
|
isBuffer = false;
|
||||||
|
}
|
||||||
|
this.isBuffer = isBuffer;
|
||||||
|
|
||||||
|
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(colors)) {
|
||||||
|
colors = [];
|
||||||
|
}
|
||||||
|
this.colors = colors;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(faces)) {
|
||||||
|
faces = [];
|
||||||
|
}
|
||||||
|
this.faces = faces;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(lineDistances)) {
|
||||||
|
lineDistances = [];
|
||||||
|
}
|
||||||
|
this.lineDistances = lineDistances;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(morphTargets)) {
|
||||||
|
morphTargets = [];
|
||||||
|
}
|
||||||
|
this.morphTargets = morphTargets;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(morphNormals)) {
|
||||||
|
morphTargets = [];
|
||||||
|
}
|
||||||
|
this.morphNormals = morphNormals;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(skinWeights)) {
|
||||||
|
skinWeights = [];
|
||||||
|
}
|
||||||
|
this.skinWeights = skinWeights;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(skinIndices)) {
|
||||||
|
skinIndices = [];
|
||||||
|
}
|
||||||
|
this.skinIndices = skinIndices;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(vertices)) {
|
||||||
|
vertices = [];
|
||||||
|
}
|
||||||
|
this.vertices = vertices;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(verticesNeedsUpdate)) {
|
||||||
|
verticesNeedsUpdate = false;
|
||||||
|
}
|
||||||
|
this.verticesNeedsUpdate = verticesNeedsUpdate;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(elementsNeedUpdate)) {
|
||||||
|
elementsNeedUpdate = false;
|
||||||
|
}
|
||||||
|
this.elementsNeedUpdate = elementsNeedUpdate;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(uvsNeedUpdate)) {
|
||||||
|
uvsNeedUpdate = false;
|
||||||
|
}
|
||||||
|
this.uvsNeedUpdate = uvsNeedUpdate;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(normalsNeedUpdate)) {
|
||||||
|
normalsNeedUpdate = false;
|
||||||
|
}
|
||||||
|
this.normalsNeedUpdate = normalsNeedUpdate;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(colorsNeedUpdate)) {
|
||||||
|
colorsNeedUpdate = false;
|
||||||
|
}
|
||||||
|
this.colorsNeedUpdate = colorsNeedUpdate;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(groupsNeedUpdate)) {
|
||||||
|
groupsNeedUpdate = false;
|
||||||
|
}
|
||||||
|
this.groupsNeedUpdate = groupsNeedUpdate;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(lineDistancesNeedUpdate)) {
|
||||||
|
lineDistancesNeedUpdate = false;
|
||||||
|
}
|
||||||
|
this.lineDistancesNeedUpdate = lineDistancesNeedUpdate;
|
||||||
|
|
||||||
|
GameLib.API.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.D3.API.Geometry.GetComponentType(this.geometryType),
|
||||||
|
parentEntity
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.prototype = Object.create(GameLib.API.Component.prototype);
|
||||||
|
GameLib.D3.API.Geometry.prototype.constructor = GameLib.D3.API.Geometry;
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.GetComponentType = function(geometryType) {
|
||||||
|
|
||||||
|
var componentType = null;
|
||||||
|
|
||||||
|
switch (geometryType) {
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL :
|
||||||
|
componentType = GameLib.Component.GEOMETRY;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_BOX;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_CIRCLE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_CONE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_CYLINDER;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_DODECAHEDRON;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_EDGES;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_EXTRUDE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_ICOSAHEDRON;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_LATHE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_OCTAHEDRON;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_PARAMETRIC;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_PLANE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_POLYHEDRON;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_RING;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_SHAPE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_SPHERE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_TETRAHEDRON;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_TEXT;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_TORUS;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_TORUS_KNOT;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_TUBE;
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME :
|
||||||
|
componentType = GameLib.Component.GEOMETRY_WIREFRAME;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error('unhandled geometry type: ' + geometryType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return componentType;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
|
@ -0,0 +1,91 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Box
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param width
|
||||||
|
* @param height
|
||||||
|
* @param depth
|
||||||
|
* @param widthSegments
|
||||||
|
* @param heightSegments
|
||||||
|
* @param depthSegments
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Box = function(
|
||||||
|
apiGeometry,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
depth,
|
||||||
|
widthSegments,
|
||||||
|
heightSegments,
|
||||||
|
depthSegments
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Box.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Box.prototype.constructor = GameLib.D3.API.Geometry.Box;
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Circle
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param segments
|
||||||
|
* @param thetaStart
|
||||||
|
* @param thetaLength
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Circle = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
segments,
|
||||||
|
thetaStart,
|
||||||
|
thetaLength
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Circle.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Circle.prototype.constructor = GameLib.D3.API.Geometry.Circle;
|
|
@ -0,0 +1,98 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Cone
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param height
|
||||||
|
* @param radialSegments
|
||||||
|
* @param heightSegments
|
||||||
|
* @param openEnded
|
||||||
|
* @param thetaStart
|
||||||
|
* @param thetaLength
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Cone = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
height,
|
||||||
|
radialSegments,
|
||||||
|
heightSegments,
|
||||||
|
openEnded,
|
||||||
|
thetaStart,
|
||||||
|
thetaLength
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Cone.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Cone.prototype.constructor = GameLib.D3.API.Geometry.Cone;
|
|
@ -0,0 +1,105 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Cylinder
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radiusTop
|
||||||
|
* @param radiusBottom
|
||||||
|
* @param height
|
||||||
|
* @param radialSegments
|
||||||
|
* @param heightSegments
|
||||||
|
* @param openEnded
|
||||||
|
* @param thetaStart
|
||||||
|
* @param thetaLength
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Cylinder = function(
|
||||||
|
apiGeometry,
|
||||||
|
radiusTop,
|
||||||
|
radiusBottom,
|
||||||
|
height,
|
||||||
|
radialSegments,
|
||||||
|
heightSegments,
|
||||||
|
openEnded,
|
||||||
|
thetaStart,
|
||||||
|
thetaLength
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Cylinder.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Cylinder.prototype.constructor = GameLib.D3.API.Geometry.Cylinder;
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Dodecahedron
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param detail
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Dodecahedron = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
detail
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Dodecahedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Dodecahedron.prototype.constructor = GameLib.D3.API.Geometry.Dodecahedron;
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Edges
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param geometry
|
||||||
|
* @param thresholdAngle (degrees)
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Edges = function(
|
||||||
|
apiGeometry,
|
||||||
|
geometry,
|
||||||
|
thresholdAngle
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(geometry)) {
|
||||||
|
geometry = null;
|
||||||
|
}
|
||||||
|
this.geometry = geometry;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(thresholdAngle)) {
|
||||||
|
thresholdAngle = 1;
|
||||||
|
}
|
||||||
|
this.thresholdAngle = thresholdAngle;
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Edges.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Edges.prototype.constructor = GameLib.D3.API.Geometry.Edges;
|
|
@ -0,0 +1,121 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Extrude
|
||||||
|
* @param apiGeometry
|
||||||
|
* @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.Geometry.Extrude = function(
|
||||||
|
apiGeometry,
|
||||||
|
shapes,
|
||||||
|
curveSegments,
|
||||||
|
steps,
|
||||||
|
amount,
|
||||||
|
bevelEnabled,
|
||||||
|
bevelThickness,
|
||||||
|
bevelSize,
|
||||||
|
bevelSegments,
|
||||||
|
extrudePath,
|
||||||
|
frames,
|
||||||
|
UVGenerator
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Extrude.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Extrude.prototype.constructor = GameLib.D3.API.Geometry.Extrude;
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Icosahedron
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param detail
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Icosahedron = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
detail
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Icosahedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Icosahedron.prototype.constructor = GameLib.D3.API.Geometry.Icosahedron;
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Lathe
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param points [GameLib.Vector2]
|
||||||
|
* @param segments
|
||||||
|
* @param phiStart
|
||||||
|
* @param phiLength
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Lathe = function(
|
||||||
|
apiGeometry,
|
||||||
|
points,
|
||||||
|
segments,
|
||||||
|
phiStart,
|
||||||
|
phiLength
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Lathe.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Lathe.prototype.constructor = GameLib.D3.API.Geometry.Lathe;
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Octahedron
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param detail
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Octahedron = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
detail
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Octahedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Octahedron.prototype.constructor = GameLib.D3.API.Geometry.Octahedron;
|
|
@ -0,0 +1,70 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Parametric
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param generatorFn(u,v) => returns Vector3, u and v is values between 0 and 1
|
||||||
|
* @param slices
|
||||||
|
* @param stacks
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Parametric = function(
|
||||||
|
apiGeometry,
|
||||||
|
generatorFn,
|
||||||
|
slices,
|
||||||
|
stacks
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Parametric.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Parametric.prototype.constructor = GameLib.D3.API.Geometry.Parametric;
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Plane
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param width
|
||||||
|
* @param height
|
||||||
|
* @param widthSegments
|
||||||
|
* @param heightSegments
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Plane = function(
|
||||||
|
apiGeometry,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
widthSegments,
|
||||||
|
heightSegments
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Plane.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Plane.prototype.constructor = GameLib.D3.API.Geometry.Plane;
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Polyhedron
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param vertices
|
||||||
|
* @param indices
|
||||||
|
* @param radius
|
||||||
|
* @param detail
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Polyhedron = function(
|
||||||
|
apiGeometry,
|
||||||
|
vertices,
|
||||||
|
indices,
|
||||||
|
radius,
|
||||||
|
detail
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Polyhedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Polyhedron.prototype.constructor = GameLib.D3.API.Geometry.Polyhedron;
|
|
@ -0,0 +1,91 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Ring
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param innerRadius
|
||||||
|
* @param outerRadius
|
||||||
|
* @param thetaSegments
|
||||||
|
* @param phiSegments
|
||||||
|
* @param thetaStart
|
||||||
|
* @param thetaLength
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Ring = function(
|
||||||
|
apiGeometry,
|
||||||
|
innerRadius,
|
||||||
|
outerRadius,
|
||||||
|
thetaSegments,
|
||||||
|
phiSegments,
|
||||||
|
thetaStart,
|
||||||
|
thetaLength
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Ring.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Ring.prototype.constructor = GameLib.D3.API.Geometry.Ring;
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Shape
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param shapes
|
||||||
|
* @param curveSegments
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Shape = function(
|
||||||
|
apiGeometry,
|
||||||
|
shapes,
|
||||||
|
curveSegments
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Shape.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Shape.prototype.constructor = GameLib.D3.API.Geometry.Shape;
|
|
@ -0,0 +1,98 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Sphere
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param widthSegments
|
||||||
|
* @param heightSegments
|
||||||
|
* @param phiStart
|
||||||
|
* @param phiLength
|
||||||
|
* @param thetaStart
|
||||||
|
* @param thetaLength
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Sphere = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
widthSegments,
|
||||||
|
heightSegments,
|
||||||
|
phiStart,
|
||||||
|
phiLength,
|
||||||
|
thetaStart,
|
||||||
|
thetaLength
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Sphere.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Sphere.prototype.constructor = GameLib.D3.API.Geometry.Sphere;
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Tetrahedron
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param detail
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Tetrahedron = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
detail
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Tetrahedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Tetrahedron.prototype.constructor = GameLib.D3.API.Geometry.Tetrahedron;
|
|
@ -0,0 +1,112 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Text
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param text
|
||||||
|
* @param font
|
||||||
|
* @param size
|
||||||
|
* @param height
|
||||||
|
* @param curveSegments
|
||||||
|
* @param bevelEnabled
|
||||||
|
* @param bevelThickness
|
||||||
|
* @param bevelSize
|
||||||
|
* @param bevelSegments
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Text = function(
|
||||||
|
apiGeometry,
|
||||||
|
text,
|
||||||
|
font,
|
||||||
|
size,
|
||||||
|
height,
|
||||||
|
curveSegments,
|
||||||
|
bevelEnabled,
|
||||||
|
bevelThickness,
|
||||||
|
bevelSize,
|
||||||
|
bevelSegments
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Text.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Text.prototype.constructor = GameLib.D3.API.Geometry.Text;
|
|
@ -0,0 +1,91 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.TorusKnot
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param tube
|
||||||
|
* @param radialSegments
|
||||||
|
* @param tubularSegments
|
||||||
|
* @param p
|
||||||
|
* @param q
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.TorusKnot = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
tube,
|
||||||
|
radialSegments,
|
||||||
|
tubularSegments,
|
||||||
|
p,
|
||||||
|
q
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.TorusKnot.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.TorusKnot.prototype.constructor = GameLib.D3.API.Geometry.TorusKnot;
|
|
@ -0,0 +1,84 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Torus
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param radius
|
||||||
|
* @param tube
|
||||||
|
* @param radialSegments
|
||||||
|
* @param tubularSegments
|
||||||
|
* @param arc
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Torus = function(
|
||||||
|
apiGeometry,
|
||||||
|
radius,
|
||||||
|
tube,
|
||||||
|
radialSegments,
|
||||||
|
tubularSegments,
|
||||||
|
arc
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Torus.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Torus.prototype.constructor = GameLib.D3.API.Geometry.Torus;
|
|
@ -0,0 +1,84 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Geometry.Tube
|
||||||
|
* @param apiGeometry
|
||||||
|
* @param path
|
||||||
|
* @param tubularSegments
|
||||||
|
* @param radius
|
||||||
|
* @param radialSegments
|
||||||
|
* @param closed
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Geometry.Tube = function(
|
||||||
|
apiGeometry,
|
||||||
|
path,
|
||||||
|
tubularSegments,
|
||||||
|
radius,
|
||||||
|
radialSegments,
|
||||||
|
closed
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
||||||
|
apiGeometry = {
|
||||||
|
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
||||||
|
apiGeometry.geometryType = GameLib.D3.API.Geometry.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.Geometry.call(
|
||||||
|
this,
|
||||||
|
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,
|
||||||
|
apiGeometry.skinWeights,
|
||||||
|
apiGeometry.skinIndices,
|
||||||
|
apiGeometry.vertices,
|
||||||
|
apiGeometry.verticesNeedsUpdate,
|
||||||
|
apiGeometry.elementsNeedUpdate,
|
||||||
|
apiGeometry.uvsNeedUpdate,
|
||||||
|
apiGeometry.normalsNeedUpdate,
|
||||||
|
apiGeometry.colorsNeedUpdate,
|
||||||
|
apiGeometry.groupsNeedUpdate,
|
||||||
|
apiGeometry.lineDistancesNeedUpdate
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Geometry.Tube.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
|
||||||
|
GameLib.D3.API.Geometry.Tube.prototype.constructor = GameLib.D3.API.Geometry.Tube;
|
|
@ -89,6 +89,12 @@ GameLib.D3.API.Light.Spot = function(
|
||||||
}
|
}
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update our intensity based on our power
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
apiLight.intensity = this.power / Math.PI;
|
||||||
|
|
||||||
GameLib.D3.API.Light.call(
|
GameLib.D3.API.Light.call(
|
||||||
this,
|
this,
|
||||||
apiLight.id,
|
apiLight.id,
|
||||||
|
|
|
@ -100,6 +100,9 @@ GameLib.D3.API.Material = function(
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD :
|
case GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD :
|
||||||
name = 'Material Standard';
|
name = 'Material Standard';
|
||||||
break;
|
break;
|
||||||
|
case GameLib.D3.API.Material.MATERIAL_TYPE_PHONG :
|
||||||
|
name = 'Material Phong';
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
console.warn('no nice name for material');
|
console.warn('no nice name for material');
|
||||||
name = 'Material';
|
name = 'Material';
|
||||||
|
@ -307,6 +310,9 @@ GameLib.D3.API.Material.GetComponentType = function(materialType) {
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_BASIC :
|
case GameLib.D3.API.Material.MATERIAL_TYPE_BASIC :
|
||||||
componentType = GameLib.Component.MATERIAL_BASIC;
|
componentType = GameLib.Component.MATERIAL_BASIC;
|
||||||
break;
|
break;
|
||||||
|
case GameLib.D3.API.Material.MATERIAL_TYPE_PHONG :
|
||||||
|
componentType = GameLib.Component.MATERIAL_PHONG;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
throw new Error('unhandled material type: ' + materialType);
|
throw new Error('unhandled material type: ' + materialType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,281 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Material.Phong
|
||||||
|
* @param apiMaterial
|
||||||
|
* @param alphaMap
|
||||||
|
* @param aoMap
|
||||||
|
* @param aoMapIntensity
|
||||||
|
* @param bumpMap
|
||||||
|
* @param bumpScale
|
||||||
|
* @param color
|
||||||
|
* @param combine
|
||||||
|
* @param displacementMap
|
||||||
|
* @param displacementScale
|
||||||
|
* @param displacementBias
|
||||||
|
* @param emissive
|
||||||
|
* @param emissiveMap
|
||||||
|
* @param emissiveIntensity
|
||||||
|
* @param envMap
|
||||||
|
* @param lightMap
|
||||||
|
* @param lightMapIntensity
|
||||||
|
* @param diffuseMap
|
||||||
|
* @param morphNormals
|
||||||
|
* @param morphTargets
|
||||||
|
* @param normalMap
|
||||||
|
* @param normalScale
|
||||||
|
* @param reflectivity
|
||||||
|
* @param refractionRatio
|
||||||
|
* @param shininess
|
||||||
|
* @param skinning
|
||||||
|
* @param specular
|
||||||
|
* @param specularMap
|
||||||
|
* @param wireframe
|
||||||
|
* @param wireframeLinecap
|
||||||
|
* @param wireframeLinejoin
|
||||||
|
* @param wireframeLinewidth
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Material.Phong = function(
|
||||||
|
apiMaterial,
|
||||||
|
alphaMap,
|
||||||
|
aoMap,
|
||||||
|
aoMapIntensity,
|
||||||
|
bumpMap,
|
||||||
|
bumpScale,
|
||||||
|
color,
|
||||||
|
combine,
|
||||||
|
displacementMap,
|
||||||
|
displacementScale,
|
||||||
|
displacementBias,
|
||||||
|
emissive,
|
||||||
|
emissiveMap,
|
||||||
|
emissiveIntensity,
|
||||||
|
envMap,
|
||||||
|
lightMap,
|
||||||
|
lightMapIntensity,
|
||||||
|
diffuseMap,
|
||||||
|
morphNormals,
|
||||||
|
morphTargets,
|
||||||
|
normalMap,
|
||||||
|
normalScale,
|
||||||
|
reflectivity,
|
||||||
|
refractionRatio,
|
||||||
|
shininess,
|
||||||
|
skinning,
|
||||||
|
specular,
|
||||||
|
specularMap,
|
||||||
|
wireframe,
|
||||||
|
wireframeLinecap,
|
||||||
|
wireframeLinejoin,
|
||||||
|
wireframeLinewidth
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterial)) {
|
||||||
|
apiMaterial = {
|
||||||
|
materialType: GameLib.D3.API.Material.MATERIAL_TYPE_PHONG
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterial.materialType)) {
|
||||||
|
apiMaterial.materialType = GameLib.D3.API.Material.MATERIAL_TYPE_PHONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(alphaMap)) {
|
||||||
|
alphaMap = null;
|
||||||
|
}
|
||||||
|
this.alphaMap = alphaMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(aoMap)) {
|
||||||
|
aoMap = null;
|
||||||
|
}
|
||||||
|
this.aoMap = aoMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(aoMapIntensity)) {
|
||||||
|
aoMapIntensity = 1;
|
||||||
|
}
|
||||||
|
this.aoMapIntensity = aoMapIntensity;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(bumpMap)) {
|
||||||
|
bumpMap = null;
|
||||||
|
}
|
||||||
|
this.bumpMap = bumpMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(bumpScale)) {
|
||||||
|
bumpScale = 1;
|
||||||
|
}
|
||||||
|
this.bumpScale = bumpScale;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(color)) {
|
||||||
|
color = new GameLib.API.Color(1, 1, 1, 1);
|
||||||
|
}
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(combine)) {
|
||||||
|
combine = GameLib.D3.API.Material.COMBINE_MULTIPLY_OPERATION;
|
||||||
|
}
|
||||||
|
this.combine = combine;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(displacementMap)) {
|
||||||
|
displacementMap = null;
|
||||||
|
}
|
||||||
|
this.displacementMap = displacementMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(displacementBias)) {
|
||||||
|
displacementBias = 0;
|
||||||
|
}
|
||||||
|
this.displacementBias = displacementBias;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(displacementScale)) {
|
||||||
|
displacementScale = 1;
|
||||||
|
}
|
||||||
|
this.displacementScale = displacementScale;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(emissive)) {
|
||||||
|
emissive = new GameLib.API.Color(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
this.emissive = emissive;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(emissiveMap)) {
|
||||||
|
emissiveMap = null;
|
||||||
|
}
|
||||||
|
this.emissiveMap = emissiveMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(emissiveIntensity)) {
|
||||||
|
emissiveIntensity = 1;
|
||||||
|
}
|
||||||
|
this.emissiveIntensity = emissiveIntensity;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(envMap)) {
|
||||||
|
envMap = null;
|
||||||
|
}
|
||||||
|
this.envMap = envMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(lightMap)) {
|
||||||
|
lightMap = null;
|
||||||
|
}
|
||||||
|
this.lightMap = lightMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(lightMapIntensity)) {
|
||||||
|
lightMapIntensity = 1;
|
||||||
|
}
|
||||||
|
this.lightMapIntensity = lightMapIntensity;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(diffuseMap)) {
|
||||||
|
diffuseMap = null;
|
||||||
|
}
|
||||||
|
this.diffuseMap = diffuseMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(morphNormals)) {
|
||||||
|
morphNormals = false;
|
||||||
|
}
|
||||||
|
this.morphNormals = morphNormals;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(morphTargets)) {
|
||||||
|
morphTargets = false;
|
||||||
|
}
|
||||||
|
this.morphTargets = morphTargets;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(normalMap)) {
|
||||||
|
normalMap = null;
|
||||||
|
}
|
||||||
|
this.normalMap = normalMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(normalScale)) {
|
||||||
|
normalScale = 1;
|
||||||
|
}
|
||||||
|
this.normalScale = normalScale;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(reflectivity)) {
|
||||||
|
reflectivity = 1;
|
||||||
|
}
|
||||||
|
this.reflectivity = reflectivity;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(refractionRatio)) {
|
||||||
|
refractionRatio = 0.98;
|
||||||
|
}
|
||||||
|
this.refractionRatio = refractionRatio;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(shininess)) {
|
||||||
|
shininess = 30;
|
||||||
|
}
|
||||||
|
this.shininess = shininess;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(skinning)) {
|
||||||
|
skinning = false;
|
||||||
|
}
|
||||||
|
this.skinning = skinning;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(specular)) {
|
||||||
|
specular = new GameLib.API.Color(0.06, 0.06, 0.06, 0);
|
||||||
|
}
|
||||||
|
this.specular = specular;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(specularMap)) {
|
||||||
|
specularMap = null;
|
||||||
|
}
|
||||||
|
this.specularMap = specularMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(wireframe)) {
|
||||||
|
wireframe = false;
|
||||||
|
}
|
||||||
|
this.wireframe = wireframe;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(wireframeLinecap)) {
|
||||||
|
wireframeLinecap = 'round';
|
||||||
|
}
|
||||||
|
this.wireframeLinecap = wireframeLinecap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(wireframeLinejoin)) {
|
||||||
|
wireframeLinejoin = 'round';
|
||||||
|
}
|
||||||
|
this.wireframeLinejoin = wireframeLinejoin;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(wireframeLinewidth)) {
|
||||||
|
wireframeLinewidth = 1;
|
||||||
|
}
|
||||||
|
this.wireframeLinewidth = wireframeLinewidth;
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.call(
|
||||||
|
this,
|
||||||
|
apiMaterial.id,
|
||||||
|
apiMaterial.name,
|
||||||
|
apiMaterial.materialType,
|
||||||
|
apiMaterial.parentEntity,
|
||||||
|
apiMaterial.parentMeshes,
|
||||||
|
apiMaterial.alphaTest,
|
||||||
|
apiMaterial.blendDst,
|
||||||
|
apiMaterial.blendDstAlpha,
|
||||||
|
apiMaterial.blendEquation,
|
||||||
|
apiMaterial.blendEquationAlpha,
|
||||||
|
apiMaterial.blending,
|
||||||
|
apiMaterial.blendSrc,
|
||||||
|
apiMaterial.blendSrcAlpha,
|
||||||
|
apiMaterial.clipIntersection,
|
||||||
|
apiMaterial.clippingPlanes,
|
||||||
|
apiMaterial.clipShadows,
|
||||||
|
apiMaterial.colorWrite,
|
||||||
|
apiMaterial.customDepthMaterial,
|
||||||
|
apiMaterial.customDistanceMaterial,
|
||||||
|
apiMaterial.defines,
|
||||||
|
apiMaterial.depthFunc,
|
||||||
|
apiMaterial.depthTest,
|
||||||
|
apiMaterial.depthWrite,
|
||||||
|
apiMaterial.fog,
|
||||||
|
apiMaterial.lights,
|
||||||
|
apiMaterial.opacity,
|
||||||
|
apiMaterial.overdraw,
|
||||||
|
apiMaterial.polygonOffset,
|
||||||
|
apiMaterial.polygonOffsetFactor,
|
||||||
|
apiMaterial.polygonOffsetUnits,
|
||||||
|
apiMaterial.precision,
|
||||||
|
apiMaterial.premultipliedAlpha,
|
||||||
|
apiMaterial.dithering,
|
||||||
|
apiMaterial.flatShading,
|
||||||
|
apiMaterial.side,
|
||||||
|
apiMaterial.transparent,
|
||||||
|
apiMaterial.vertexColors,
|
||||||
|
apiMaterial.visible
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.Phong.prototype = Object.create(GameLib.D3.API.Material.prototype);
|
||||||
|
GameLib.D3.API.Material.Phong.prototype.constructor = GameLib.D3.API.Material.Phong;
|
|
@ -23,6 +23,8 @@ GameLib.D3.Camera = function(
|
||||||
apiCamera.cameraType,
|
apiCamera.cameraType,
|
||||||
apiCamera.aspect,
|
apiCamera.aspect,
|
||||||
apiCamera.position,
|
apiCamera.position,
|
||||||
|
apiCamera.rotation,
|
||||||
|
apiCamera.quaternion,
|
||||||
apiCamera.lookAt,
|
apiCamera.lookAt,
|
||||||
apiCamera.parentEntity
|
apiCamera.parentEntity
|
||||||
);
|
);
|
||||||
|
@ -39,6 +41,18 @@ GameLib.D3.Camera = function(
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.rotation = new GameLib.Vector3(
|
||||||
|
graphics,
|
||||||
|
this.rotation,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
this.quaternion = new GameLib.Quaternion(
|
||||||
|
graphics,
|
||||||
|
this.quaternion,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
var linkedObjects = {};
|
var linkedObjects = {};
|
||||||
|
|
||||||
switch (apiCamera.cameraType) {
|
switch (apiCamera.cameraType) {
|
||||||
|
@ -76,6 +90,20 @@ GameLib.D3.Camera.prototype.createInstance = function() {
|
||||||
this.instance.position.z = this.position.z;
|
this.instance.position.z = this.position.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.instance.rotation)) {
|
||||||
|
this.instance.rotation.x = this.rotation.x;
|
||||||
|
this.instance.rotation.y = this.rotation.y;
|
||||||
|
this.instance.rotation.z = this.rotation.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.instance.quaternion)) {
|
||||||
|
this.instance.quaternion.x = this.quaternion.x;
|
||||||
|
this.instance.quaternion.y = this.quaternion.y;
|
||||||
|
this.instance.quaternion.z = this.quaternion.z;
|
||||||
|
this.instance.quaternion.w = this.quaternion.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not all implementations of camera has aspect ratio, we, however do have an aspect ratio for all our cameras
|
* Not all implementations of camera has aspect ratio, we, however do have an aspect ratio for all our cameras
|
||||||
*/
|
*/
|
||||||
|
@ -84,8 +112,15 @@ GameLib.D3.Camera.prototype.createInstance = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.lookAt)) {
|
if (GameLib.Utils.Defined(this.instance.lookAt)) {
|
||||||
|
if (this.instance.isCamera) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For some reason - cube camera does not think it is a camera - so it does a lookAt differently -
|
||||||
|
* which messes up its rotation
|
||||||
|
*/
|
||||||
this.instance.lookAt(this.lookAt.instance);
|
this.instance.lookAt(this.lookAt.instance);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
||||||
this.instance.updateProjectionMatrix();
|
this.instance.updateProjectionMatrix();
|
||||||
|
@ -156,6 +191,31 @@ GameLib.D3.Camera.prototype.updateInstance = function(property) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (property === 'rotation') {
|
||||||
|
|
||||||
|
this.instance.rotation.x = this.rotation.x;
|
||||||
|
this.instance.rotation.y = this.rotation.y;
|
||||||
|
this.instance.rotation.z = this.rotation.z;
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
||||||
|
this.instance.updateProjectionMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'quaternion') {
|
||||||
|
|
||||||
|
console.log('todo: update quaternion');
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
||||||
|
// this.instance.updateProjectionMatrix();
|
||||||
|
// }
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (property === 'lookAt') {
|
if (property === 'lookAt') {
|
||||||
|
|
||||||
this.lookAt.instance.x = this.lookAt.x;
|
this.lookAt.instance.x = this.lookAt.x;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -189,17 +189,20 @@ GameLib.D3.Light.Spot.prototype.updateInstance = function(property, oldTarget) {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Light.Spot.prototype.toApiObject = function() {
|
GameLib.D3.Light.Spot.prototype.toApiObject = function() {
|
||||||
|
|
||||||
var apiSpotLight = GameLib.D3.Light.prototype.toApiObject.call(this);
|
var apiLight = GameLib.D3.Light.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
apiSpotLight.position = this.position.toApiObject();
|
var apiSpotLight = new GameLib.D3.API.Light.Spot(
|
||||||
apiSpotLight.angle = this.angle;
|
apiLight,
|
||||||
apiSpotLight.castShadow = this.castShadow;
|
this.position.toApiObject(),
|
||||||
apiSpotLight.decay = this.decay;
|
this.angle,
|
||||||
apiSpotLight.distance = this.distance;
|
this.castShadow,
|
||||||
apiSpotLight.penumbra = this.penumbra;
|
this.decay,
|
||||||
apiSpotLight.power = this.power;
|
this.distance,
|
||||||
apiSpotLight.shadow = GameLib.Utils.IdOrNull(this.shadow);
|
this.penumbra,
|
||||||
apiSpotLight.target = GameLib.Utils.IdOrNull(this.target);
|
this.power,
|
||||||
|
GameLib.Utils.IdOrNull(this.shadow),
|
||||||
|
GameLib.Utils.IdOrNull(this.target)
|
||||||
|
);
|
||||||
|
|
||||||
return apiSpotLight;
|
return apiSpotLight;
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,6 +87,18 @@ GameLib.D3.Material = function(
|
||||||
linkedObjects.lightMap = GameLib.D3.Texture;
|
linkedObjects.lightMap = GameLib.D3.Texture;
|
||||||
linkedObjects.specularMap = GameLib.D3.Texture;
|
linkedObjects.specularMap = GameLib.D3.Texture;
|
||||||
break;
|
break;
|
||||||
|
case GameLib.D3.API.Material.MATERIAL_TYPE_PHONG :
|
||||||
|
linkedObjects.alphaMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.aoMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.bumpMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.diffuseMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.displacementMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.emissiveMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.envMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.lightMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.normalMap = GameLib.D3.Texture;
|
||||||
|
linkedObjects.specularMap = GameLib.D3.Texture;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
throw new Error('unhandled material type: ' + this.materialType);
|
throw new Error('unhandled material type: ' + this.materialType);
|
||||||
|
|
||||||
|
@ -108,11 +120,6 @@ GameLib.D3.Material.prototype.createInstance = function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance.id = this.id;
|
|
||||||
this.instance.name = this.name;
|
|
||||||
this.instance.materialType = this.materialType;
|
|
||||||
this.instance.parentEntity = this.parentEntity;
|
|
||||||
this.instance.parentMeshes = this.parentMeshes;
|
|
||||||
this.instance.alphaTest = this.alphaTest;
|
this.instance.alphaTest = this.alphaTest;
|
||||||
this.instance.blendDst = this.blendDst;
|
this.instance.blendDst = this.blendDst;
|
||||||
this.instance.blendDstAlpha = this.blendDstAlpha;
|
this.instance.blendDstAlpha = this.blendDstAlpha;
|
||||||
|
|
|
@ -157,6 +157,7 @@ GameLib.D3.Material.Basic.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (property === 'combine') {
|
if (property === 'combine') {
|
||||||
this.instance.combine = this.combine;
|
this.instance.combine = this.combine;
|
||||||
|
this.instance.needsUpdate = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,408 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.Material.Phong
|
||||||
|
* @param graphics
|
||||||
|
* @param apiMaterialPhong
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Phong = function(
|
||||||
|
graphics,
|
||||||
|
apiMaterialPhong
|
||||||
|
) {
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterialPhong)) {
|
||||||
|
apiMaterialPhong = {
|
||||||
|
materialType : GameLib.D3.API.Material.MATERIAL_TYPE_PHONG
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.Phong.call(
|
||||||
|
this,
|
||||||
|
apiMaterialPhong,
|
||||||
|
apiMaterialPhong.alphaMap,
|
||||||
|
apiMaterialPhong.aoMap,
|
||||||
|
apiMaterialPhong.aoMapIntensity,
|
||||||
|
apiMaterialPhong.bumpMap,
|
||||||
|
apiMaterialPhong.bumpScale,
|
||||||
|
apiMaterialPhong.color,
|
||||||
|
apiMaterialPhong.combine,
|
||||||
|
apiMaterialPhong.displacementMap,
|
||||||
|
apiMaterialPhong.displacementScale,
|
||||||
|
apiMaterialPhong.displacementBias,
|
||||||
|
apiMaterialPhong.emissive,
|
||||||
|
apiMaterialPhong.emissiveMap,
|
||||||
|
apiMaterialPhong.emissiveIntensity,
|
||||||
|
apiMaterialPhong.envMap,
|
||||||
|
apiMaterialPhong.lightMap,
|
||||||
|
apiMaterialPhong.lightMapIntensity,
|
||||||
|
apiMaterialPhong.diffuseMap,
|
||||||
|
apiMaterialPhong.morphNormals,
|
||||||
|
apiMaterialPhong.morphTargets,
|
||||||
|
apiMaterialPhong.normalMap,
|
||||||
|
apiMaterialPhong.normalScale,
|
||||||
|
apiMaterialPhong.reflectivity,
|
||||||
|
apiMaterialPhong.refractionRatio,
|
||||||
|
apiMaterialPhong.shininess,
|
||||||
|
apiMaterialPhong.skinning,
|
||||||
|
apiMaterialPhong.specular,
|
||||||
|
apiMaterialPhong.specularMap,
|
||||||
|
apiMaterialPhong.wireframe,
|
||||||
|
apiMaterialPhong.wireframeLinecap,
|
||||||
|
apiMaterialPhong.wireframeLinejoin,
|
||||||
|
apiMaterialPhong.wireframeLinewidth
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.alphaMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.alphaMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.alphaMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.aoMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.aoMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.aoMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.bumpMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.bumpMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.bumpMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.color = new GameLib.Color(
|
||||||
|
this.graphics,
|
||||||
|
this.color,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.displacementMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.displacementMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.displacementMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emissive = new GameLib.Color(
|
||||||
|
this.graphics,
|
||||||
|
this.emissive,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.emissiveMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.emissiveMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.emissiveMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.envMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.envMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.envMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.lightMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.lightMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.lightMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.diffuseMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.diffuseMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.diffuseMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.normalMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.normalMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.normalMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.specular = new GameLib.Color(
|
||||||
|
this.graphics,
|
||||||
|
this.specular,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.specularMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.specularMap = new GameLib.D3.Texture(
|
||||||
|
this.graphics,
|
||||||
|
this.specularMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.Material.call(
|
||||||
|
this,
|
||||||
|
this.graphics,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Material.Phong.prototype = Object.create(GameLib.D3.Material.prototype);
|
||||||
|
GameLib.D3.Material.Phong.prototype.constructor = GameLib.D3.Material.Phong;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of our texture object
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Phong.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
this.instance = new THREE.MeshPhongMaterial(
|
||||||
|
{
|
||||||
|
alphaMap : this.alphaMap ? this.alphaMap.instance : null,
|
||||||
|
aoMap : this.aoMap ? this.aoMap.instance : null,
|
||||||
|
aoMapIntensity : this.aoMapIntensity,
|
||||||
|
bumpMap : this.bumpMap ? this.bumpMap.instance : null,
|
||||||
|
bumpScale : this.bumpScale,
|
||||||
|
color : this.color.instance,
|
||||||
|
combine : this.combine,
|
||||||
|
displacementMap : this.displacementMap ? this.displacementMap.instance : null,
|
||||||
|
displacementScale : this.displacementScale,
|
||||||
|
displacementBias : this.displacementBias,
|
||||||
|
emissive : this.emissive.instance,
|
||||||
|
emissiveMap : this.emissiveMap ? this.emissiveMap.instance : null,
|
||||||
|
emissiveIntensity : this.emissiveIntensity,
|
||||||
|
envMap : this.envMap ? this.envMap.instance : null,
|
||||||
|
lightMap : this.lightMap ? this.lightMap.instance : null,
|
||||||
|
lightMapIntensity : this.lightMapIntensity,
|
||||||
|
map : this.diffuseMap ? this.diffuseMap.instance : null,
|
||||||
|
morphNormals : this.morphNormals,
|
||||||
|
morphTargets : this.morphTargets,
|
||||||
|
normalMap : this.normalMap ? this.normalMap.instance : null,
|
||||||
|
normalScale : this.normalScale,
|
||||||
|
reflectivity : this.reflectivity,
|
||||||
|
refractionRatio : this.refractionRatio,
|
||||||
|
shininess : this.shininess,
|
||||||
|
skinning : this.skinning,
|
||||||
|
specular : this.specular.instance,
|
||||||
|
specularMap : this.specularMap ? this.specularMap.instance : null,
|
||||||
|
wireframe : this.wireframe,
|
||||||
|
wireframeLinecap : this.wireframeLinecap,
|
||||||
|
wireframeLinejoin : this.wireframeLinejoin,
|
||||||
|
wireframeLinewidth : this.wireframeLinewidth
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.D3.Material.prototype.createInstance.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance with the current state
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Phong.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (property === 'alphaMap') {
|
||||||
|
this.assignTexture('alphaMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'aoMap') {
|
||||||
|
this.assignTexture('aoMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'aoMapIntensity') {
|
||||||
|
this.instance.aoMapIntensity = this.aoMapIntensity;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'bumpMap') {
|
||||||
|
this.assignTexture('bumpMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'bumpScale') {
|
||||||
|
this.instance.bumpScale = this.bumpScale;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'color') {
|
||||||
|
this.instance.color = this.color.instance;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'combine') {
|
||||||
|
this.instance.combine = this.combine;
|
||||||
|
this.instance.needsUpdate = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'displacementMap') {
|
||||||
|
this.assignTexture('displacementMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'displacementScale') {
|
||||||
|
this.instance.displacementScale = this.displacementScale;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'displacementBias') {
|
||||||
|
this.instance.displacementBias = this.displacementBias;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'emissive') {
|
||||||
|
this.instance.emissive = this.emissive.instance;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'emissiveMap') {
|
||||||
|
this.assignTexture('emissiveMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'emissiveIntensity') {
|
||||||
|
this.instance.emissiveIntensity = this.emissiveIntensity;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'envMap') {
|
||||||
|
this.assignTexture('envMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'lightMap') {
|
||||||
|
this.assignTexture('lightMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'lightMapIntensity') {
|
||||||
|
this.instance.lightMapIntensity = this.lightMapIntensity;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'diffuseMap') {
|
||||||
|
this.assignTexture('map', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'morphNormals') {
|
||||||
|
this.instance.morphNormals = this.morphNormals;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'morphTargets') {
|
||||||
|
this.instance.morphTargets = this.morphTargets;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'normalMap') {
|
||||||
|
this.assignTexture('normalMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'normalScale') {
|
||||||
|
this.instance.normalScale = this.normalScale;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'reflectivity') {
|
||||||
|
this.instance.reflectivity = this.reflectivity;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'refractionRatio') {
|
||||||
|
this.instance.refractionRatio = this.refractionRatio;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'shininess') {
|
||||||
|
this.instance.shininess = this.shininess;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'skinning') {
|
||||||
|
this.instance.skinning = this.skinning;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'specular') {
|
||||||
|
this.instance.specular = this.specular.instance;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'specularMap') {
|
||||||
|
this.assignTexture('specularMap', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'wireframe') {
|
||||||
|
this.instance.wireframe = this.wireframe;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'wireframeLinecap') {
|
||||||
|
this.instance.wireframeLinecap = this.wireframeLinecap;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'wireframeLinejoin') {
|
||||||
|
this.instance.wireframeLinejoin = this.wireframeLinejoin;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'wireframeLinewidth') {
|
||||||
|
this.instance.wireframeLinewidth = this.wireframeLinewidth;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.Material.prototype.updateInstance.call(this, property);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Material.Phong to a GameLib.D3.API.Material.Phong
|
||||||
|
* @returns {GameLib.D3.API.Material.Phong}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Phong.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiMaterial = GameLib.D3.Material.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
|
var apiMaterialPhong = new GameLib.D3.API.Material.Phong(
|
||||||
|
apiMaterial,
|
||||||
|
GameLib.Utils.IdOrNull(this.alphaMap),
|
||||||
|
GameLib.Utils.IdOrNull(this.aoMap),
|
||||||
|
this.aoMapIntensity,
|
||||||
|
GameLib.Utils.IdOrNull(this.bumpMap),
|
||||||
|
this.bumpScale,
|
||||||
|
this.color.toApiObject(),
|
||||||
|
this.combine,
|
||||||
|
GameLib.Utils.IdOrNull(this.displacementMap),
|
||||||
|
this.displacementScale,
|
||||||
|
this.displacementBias,
|
||||||
|
this.emissive.toApiObject(),
|
||||||
|
GameLib.Utils.IdOrNull(this.emissiveMap),
|
||||||
|
this.emissiveIntensity,
|
||||||
|
GameLib.Utils.IdOrNull(this.envMap),
|
||||||
|
GameLib.Utils.IdOrNull(this.lightMap),
|
||||||
|
this.lightMapIntensity,
|
||||||
|
GameLib.Utils.IdOrNull(this.diffuseMap),
|
||||||
|
this.morphNormals,
|
||||||
|
this.morphTargets,
|
||||||
|
GameLib.Utils.IdOrNull(this.normalMap),
|
||||||
|
this.normalScale,
|
||||||
|
this.reflectivity,
|
||||||
|
this.refractionRatio,
|
||||||
|
this.shininess,
|
||||||
|
this.skinning,
|
||||||
|
this.specular.toApiObject(),
|
||||||
|
GameLib.Utils.IdOrNull(this.specularMap),
|
||||||
|
this.wireframe,
|
||||||
|
this.wireframeLinecap,
|
||||||
|
this.wireframeLinejoin,
|
||||||
|
this.wireframeLinewidth
|
||||||
|
);
|
||||||
|
|
||||||
|
return apiMaterialPhong;
|
||||||
|
};
|
|
@ -183,7 +183,6 @@ GameLib.D3.Mesh.prototype.lookAt = function(vector) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||||
|
|
||||||
if (instanceGeometry instanceof THREE.Geometry) {
|
if (instanceGeometry instanceof THREE.Geometry) {
|
||||||
|
@ -441,7 +440,6 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||||
return geometry;
|
return geometry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a mesh instance or updates it
|
* Creates a mesh instance or updates it
|
||||||
*/
|
*/
|
||||||
|
@ -651,8 +649,32 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) {
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
GameLib.Component.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Mesh.prototype.invertWindingOrder = function() {
|
||||||
|
|
||||||
|
this.faces.forEach(
|
||||||
|
function (face) {
|
||||||
|
|
||||||
|
var tmpV1 = face.v1;
|
||||||
|
face.v1 = face.v2;
|
||||||
|
face.v2 = tmpV1;
|
||||||
|
|
||||||
|
var tmpV1uv = face.v1uv;
|
||||||
|
face.v1uv = face.v2uv;
|
||||||
|
face.v2uv = tmpV1uv;
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.instance) {
|
||||||
|
this.instance.geometry.computeVertexNormals();
|
||||||
|
this.instance.geometry.computeFaceNormals();
|
||||||
|
this.instance.geometry.normalsNeedUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply geometry data to our game-lib object from the geometry instance (reverse of applyVertexData)
|
* Apply geometry data to our GameLib object from the geometry instance (reverse of applyVertexData)
|
||||||
* @param geometryInstance
|
* @param geometryInstance
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.prototype.updateVerticesFromGeometryInstance = function(geometryInstance) {
|
GameLib.D3.Mesh.prototype.updateVerticesFromGeometryInstance = function(geometryInstance) {
|
||||||
|
@ -861,7 +883,6 @@ GameLib.D3.Mesh.prototype.updateVerticesFromGeometryInstance = function(geometry
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.applyBones = function(geometry) {
|
GameLib.D3.Mesh.prototype.applyBones = function(geometry) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1008,21 +1029,20 @@ GameLib.D3.Mesh.prototype.setParentMesh = function(parentMesh) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Mesh.prototype.getBoundingBox = function() {
|
||||||
|
|
||||||
// GameLib.D3.Mesh.prototype.getBoundingBox = function() {
|
this.instance.geometry.computeBoundingBox();
|
||||||
//
|
|
||||||
// this.instance.geometry.computeBoundingBox();
|
return new GameLib.Vector3(
|
||||||
//
|
this.graphics,
|
||||||
// return new GameLib.Vector3(
|
new GameLib.API.Vector3(
|
||||||
// this.graphics,
|
this.instance.geometry.boundingBox.max.x - this.instance.geometry.boundingBox.min.x,
|
||||||
// new GameLib.API.Vector3(
|
this.instance.geometry.boundingBox.max.y - this.instance.geometry.boundingBox.min.y,
|
||||||
// this.instance.geometry.boundingBox.max.x - this.instance.geometry.boundingBox.min.x,
|
this.instance.geometry.boundingBox.max.z - this.instance.geometry.boundingBox.min.z
|
||||||
// this.instance.geometry.boundingBox.max.y - this.instance.geometry.boundingBox.min.y,
|
)
|
||||||
// this.instance.geometry.boundingBox.max.z - this.instance.geometry.boundingBox.min.z
|
);
|
||||||
// )
|
|
||||||
// );
|
};
|
||||||
//
|
|
||||||
// };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
|
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
|
||||||
|
@ -1327,8 +1347,6 @@ GameLib.D3.Mesh.prototype.updateInstanceScale = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all children components of this Mesh (all linked objects only - no object references i.e. string ids)
|
* Gets all children components of this Mesh (all linked objects only - no object references i.e. string ids)
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/**
|
||||||
|
* GameLib.Sphere
|
||||||
|
* @param implementation
|
||||||
|
* @param apiSphere
|
||||||
|
* @param parentObject
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.Sphere = function (
|
||||||
|
implementation,
|
||||||
|
apiSphere,
|
||||||
|
parentObject
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.implementation = implementation;
|
||||||
|
this.implementation.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentObject)) {
|
||||||
|
parentObject = null;
|
||||||
|
}
|
||||||
|
this.parentObject = parentObject;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiSphere)) {
|
||||||
|
apiSphere = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.API.Sphere.call(
|
||||||
|
this,
|
||||||
|
apiSphere.center,
|
||||||
|
apiSphere.radius
|
||||||
|
);
|
||||||
|
|
||||||
|
this.createInstance();
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.Sphere.prototype = Object.create(GameLib.API.Sphere.prototype);
|
||||||
|
GameLib.Sphere.prototype.constructor = GameLib.Sphere;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance GameLib.Sphere
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.Sphere.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
this.instance = new THREE.Sphere(
|
||||||
|
this.center.instance,
|
||||||
|
this.radius
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates GameLib.Sphere instance
|
||||||
|
* @param property
|
||||||
|
*/
|
||||||
|
GameLib.Sphere.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (property === 'center') {
|
||||||
|
this.instance.center.x = this.center.x;
|
||||||
|
this.instance.center.y = this.center.y;
|
||||||
|
this.instance.center.z = this.center.z;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'radius') {
|
||||||
|
this.instance.radius = this.radius;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GameLib.Sphere to GameLib.API.Sphere
|
||||||
|
* @returns {GameLib.API.Sphere}
|
||||||
|
*/
|
||||||
|
GameLib.Sphere.prototype.toApiObject = function() {
|
||||||
|
return new GameLib.API.Sphere(
|
||||||
|
this.center.toApiObject(),
|
||||||
|
this.radius
|
||||||
|
);
|
||||||
|
};
|
|
@ -328,13 +328,30 @@ GameLib.System.GUI.prototype.controller = function(folder, object, property, sub
|
||||||
if (
|
if (
|
||||||
// property === 'chassisConnectionPointLocal' ||
|
// property === 'chassisConnectionPointLocal' ||
|
||||||
property === 'offset' ||
|
property === 'offset' ||
|
||||||
property === 'repeat'
|
property === 'repeat' ||
|
||||||
|
property === 'position'
|
||||||
) {
|
) {
|
||||||
min = -1000;
|
min = -1000;
|
||||||
max = 1000;
|
max = 1000;
|
||||||
step = 0.01;
|
step = 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
property === 'scale'
|
||||||
|
) {
|
||||||
|
min = -10;
|
||||||
|
max = 10;
|
||||||
|
step = 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
property === 'rotation'
|
||||||
|
) {
|
||||||
|
min = -Math.PI * 2;
|
||||||
|
max = Math.PI * 2;
|
||||||
|
step = 0.0001;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
property === 'mapSize'
|
property === 'mapSize'
|
||||||
) {
|
) {
|
||||||
|
@ -1161,8 +1178,8 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
property,
|
property,
|
||||||
{
|
{
|
||||||
'standard': GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD,
|
'standard': GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD,
|
||||||
'basic': GameLib.D3.API.Material.MATERIAL_TYPE_BASIC
|
'basic': GameLib.D3.API.Material.MATERIAL_TYPE_BASIC,
|
||||||
// 'phong': GameLib.D3.API.Material.MATERIAL_TYPE_PHONG,
|
'phong': GameLib.D3.API.Material.MATERIAL_TYPE_PHONG
|
||||||
// 'points': GameLib.D3.API.Material.MATERIAL_TYPE_POINTS,
|
// 'points': GameLib.D3.API.Material.MATERIAL_TYPE_POINTS,
|
||||||
// 'toon': GameLib.D3.API.Material.MATERIAL_TYPE_TOON,
|
// 'toon': GameLib.D3.API.Material.MATERIAL_TYPE_TOON,
|
||||||
// 'line basic' : GameLib.D3.API.Material.MATERIAL_TYPE_LINE_BASIC
|
// 'line basic' : GameLib.D3.API.Material.MATERIAL_TYPE_LINE_BASIC
|
||||||
|
@ -1606,7 +1623,8 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
) {
|
) {
|
||||||
controllers.push(folder.add(object, property, 0, 1, 0.0001));
|
controllers.push(folder.add(object, property, 0, 1, 0.0001));
|
||||||
} else if (
|
} else if (
|
||||||
property === 'strength'
|
property === 'strength' ||
|
||||||
|
property === 'power'
|
||||||
) {
|
) {
|
||||||
controllers.push(folder.add(object, property, 0, 50, 0.001));
|
controllers.push(folder.add(object, property, 0, 50, 0.001));
|
||||||
} else if (
|
} else if (
|
||||||
|
|
Loading…
Reference in New Issue