Merge branch 'r3' of bitbucket.org:cybafelo/r3 into r3
commit
142c51b558
|
@ -1,59 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib Namespace
|
|
||||||
*/
|
|
||||||
if (typeof GameLib === 'undefined') {
|
|
||||||
function GameLib() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3 Namespace
|
|
||||||
*/
|
|
||||||
if (typeof GameLib.D3 === 'undefined') {
|
|
||||||
GameLib.D3 = function(){};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.API Namespace
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
if (typeof GameLib.D3.API === 'undefined') {
|
|
||||||
GameLib.D3.API = function(){};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.API Namespace
|
|
||||||
*/
|
|
||||||
if (typeof GameLib.API === 'undefined') {
|
|
||||||
GameLib.API = function(){};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.Runtime Namespace
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
if (typeof GameLib.D3.Runtime === 'undefined') {
|
|
||||||
GameLib.D3.Runtime = function(){};
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (typeof Q === 'undefined') {
|
|
||||||
//
|
|
||||||
// if (typeof require === 'undefined') {
|
|
||||||
// console.warn('You need the Q promise library for the GameLib.D3');
|
|
||||||
// throw new Error('You need the Q promise library for the GameLib.D3');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var Q = require('q');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (typeof _ === 'undefined') {
|
|
||||||
//
|
|
||||||
// if (typeof require === 'undefined') {
|
|
||||||
// console.warn('You need the lodash library for the GameLib.D3');
|
|
||||||
// throw new Error('You need the lodash library for the GameLib.D3');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var _ = require('lodash');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// This gets injected by gulp
|
|
||||||
console.log("Loading GameLib compiled at: " + __DATE__);
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,45 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.Box3
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param parentEntity
|
|
||||||
* @param min
|
|
||||||
* @param max
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Box3 = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
parentEntity,
|
|
||||||
min,
|
|
||||||
max
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Box (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(min)) {
|
|
||||||
min = new GameLib.API.Vector3(0,0,0);
|
|
||||||
}
|
|
||||||
this.min = min;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(max)) {
|
|
||||||
max = new GameLib.API.Vector3(1,1,1);
|
|
||||||
}
|
|
||||||
this.max = max;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.BOX3,
|
|
||||||
parentEntity
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Box3.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.Box3.prototype.constructor = GameLib.API.Box3;
|
|
|
@ -1,115 +0,0 @@
|
||||||
/**
|
|
||||||
* Raw Controls API object
|
|
||||||
* @param id
|
|
||||||
* @param controlsType
|
|
||||||
* @param name
|
|
||||||
* @param canvas
|
|
||||||
* @param parentEntity
|
|
||||||
* @property controlsType
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Controls = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
controlsType,
|
|
||||||
canvas,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(controlsType)) {
|
|
||||||
controlsType = GameLib.API.Controls.CONTROLS_TYPE_NONE;
|
|
||||||
}
|
|
||||||
this.controlsType = controlsType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
name = 'Controls';
|
|
||||||
|
|
||||||
switch (this.controlsType) {
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_TOUCH :
|
|
||||||
name = 'Controls Editor';
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_KEYBOARD :
|
|
||||||
name = 'Controls Keyboard';
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_MOUSE :
|
|
||||||
name = 'Controls Mouse';
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_EDITOR :
|
|
||||||
name = 'Controls Editor';
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_FIRST_PERSON :
|
|
||||||
name = 'Controls First Person';
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_ORBIT :
|
|
||||||
name = 'Controls Orbit';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
name += ' (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(canvas)) {
|
|
||||||
canvas = null;
|
|
||||||
}
|
|
||||||
this.canvas = canvas;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.API.Controls.GetComponentType(this.controlsType),
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Controls.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.Controls.prototype.constructor = GameLib.API.Controls;
|
|
||||||
|
|
||||||
GameLib.API.Controls.GetComponentType = function(controlsType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (controlsType) {
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_NONE :
|
|
||||||
componentType = GameLib.Component.CONTROLS;
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_TOUCH :
|
|
||||||
componentType = GameLib.Component.CONTROLS_TOUCH;
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_KEYBOARD :
|
|
||||||
componentType = GameLib.Component.CONTROLS_KEYBOARD;
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_MOUSE :
|
|
||||||
componentType = GameLib.Component.CONTROLS_MOUSE;
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_EDITOR :
|
|
||||||
componentType = GameLib.Component.CONTROLS_EDITOR;
|
|
||||||
break;
|
|
||||||
case GameLib.API.Controls.CONTROLS_TYPE_ORBIT :
|
|
||||||
componentType = GameLib.Component.CONTROLS_ORBIT;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
throw new Error('unhandled controls type: ' + controlsType);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Controls.D3 = function() {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controls Type
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.API.Controls.CONTROLS_TYPE_NONE = 0x0;
|
|
||||||
GameLib.API.Controls.CONTROLS_TYPE_TOUCH = 0x1;
|
|
||||||
GameLib.API.Controls.CONTROLS_TYPE_KEYBOARD = 0x2;
|
|
||||||
GameLib.API.Controls.CONTROLS_TYPE_MOUSE = 0x3;
|
|
||||||
GameLib.API.Controls.CONTROLS_TYPE_EDITOR = 0x4;
|
|
||||||
GameLib.API.Controls.CONTROLS_TYPE_FIRST_PERSON = 0x5;
|
|
||||||
GameLib.API.Controls.CONTROLS_TYPE_ORBIT = 0x6;
|
|
|
@ -1,44 +0,0 @@
|
||||||
/**
|
|
||||||
* @param apiControls
|
|
||||||
* @param raycaster
|
|
||||||
* @param camera
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Controls.D3.Editor = function(
|
|
||||||
apiControls,
|
|
||||||
raycaster,
|
|
||||||
camera
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls)) {
|
|
||||||
apiControls = {
|
|
||||||
controlsType : GameLib.API.Controls.CONTROLS_TYPE_EDITOR
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls.controlsType)) {
|
|
||||||
apiControls.controlsType = GameLib.API.Controls.CONTROLS_TYPE_EDITOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(raycaster)) {
|
|
||||||
raycaster = new GameLib.D3.API.Raycaster();
|
|
||||||
}
|
|
||||||
this.raycaster = raycaster;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(camera)) {
|
|
||||||
camera = null;
|
|
||||||
}
|
|
||||||
this.camera = camera;
|
|
||||||
|
|
||||||
GameLib.API.Controls.call(
|
|
||||||
this,
|
|
||||||
apiControls.id,
|
|
||||||
apiControls.name,
|
|
||||||
apiControls.controlsType,
|
|
||||||
apiControls.canvas,
|
|
||||||
apiControls.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Controls.D3.Editor.prototype = Object.create(GameLib.API.Controls.prototype);
|
|
||||||
GameLib.API.Controls.D3.Editor.prototype.constructor = GameLib.API.Controls.D3.Editor;
|
|
|
@ -1,30 +0,0 @@
|
||||||
/**
|
|
||||||
* @param apiControls
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Controls.Keyboard = function(
|
|
||||||
apiControls
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls)) {
|
|
||||||
apiControls = {
|
|
||||||
controlsType : GameLib.API.Controls.CONTROLS_TYPE_KEYBOARD
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls.controlsType)) {
|
|
||||||
apiControls.controlsType = GameLib.API.Controls.CONTROLS_TYPE_KEYBOARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Controls.call(
|
|
||||||
this,
|
|
||||||
apiControls.id,
|
|
||||||
apiControls.name,
|
|
||||||
apiControls.controlsType,
|
|
||||||
apiControls.canvas,
|
|
||||||
apiControls.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Controls.Keyboard.prototype = Object.create(GameLib.API.Controls.prototype);
|
|
||||||
GameLib.API.Controls.Keyboard.prototype.constructor = GameLib.API.Controls.Keyboard;
|
|
|
@ -1,31 +0,0 @@
|
||||||
/**
|
|
||||||
* @param apiControls
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Controls.Mouse = function(
|
|
||||||
apiControls
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls)) {
|
|
||||||
apiControls = {
|
|
||||||
controlsType : GameLib.API.Controls.CONTROLS_TYPE_MOUSE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls.controlsType)) {
|
|
||||||
apiControls.controlsType = GameLib.API.Controls.CONTROLS_TYPE_MOUSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Controls.call(
|
|
||||||
this,
|
|
||||||
apiControls.id,
|
|
||||||
apiControls.name,
|
|
||||||
apiControls.controlsType,
|
|
||||||
apiControls.canvas,
|
|
||||||
apiControls.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Controls.Mouse.prototype = Object.create(GameLib.API.Controls.prototype);
|
|
||||||
GameLib.API.Controls.Mouse.prototype.constructor = GameLib.API.Controls.Mouse;
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
/**
|
|
||||||
* @param apiControls
|
|
||||||
* @param sensitivity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Controls.Touch = function(
|
|
||||||
apiControls,
|
|
||||||
sensitivity
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls)) {
|
|
||||||
apiControls = {
|
|
||||||
controlsType : GameLib.API.Controls.CONTROLS_TYPE_TOUCH
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls.controlsType)) {
|
|
||||||
apiControls.controlsType = GameLib.API.Controls.CONTROLS_TYPE_TOUCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(sensitivity)) {
|
|
||||||
sensitivity = 5;
|
|
||||||
}
|
|
||||||
this.sensitivity = sensitivity;
|
|
||||||
|
|
||||||
GameLib.API.Controls.call(
|
|
||||||
this,
|
|
||||||
apiControls.id,
|
|
||||||
apiControls.name,
|
|
||||||
apiControls.controlsType,
|
|
||||||
apiControls.canvas,
|
|
||||||
apiControls.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Controls.Touch.prototype = Object.create(GameLib.API.Controls.prototype);
|
|
||||||
GameLib.API.Controls.Touch.prototype.constructor = GameLib.API.Controls.Touch;
|
|
|
@ -1,89 +0,0 @@
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/**
|
|
||||||
* 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;
|
|
|
@ -1,35 +0,0 @@
|
||||||
/**
|
|
||||||
* 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;
|
|
|
@ -1,27 +0,0 @@
|
||||||
/**
|
|
||||||
* 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;
|
|
|
@ -1,45 +0,0 @@
|
||||||
/**
|
|
||||||
* Custom Code Component
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param eventId
|
|
||||||
* @param code
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.CustomCode = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
eventId,
|
|
||||||
code,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'CustomCode (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(eventId)) {
|
|
||||||
eventId = 42;
|
|
||||||
}
|
|
||||||
this.eventId = eventId;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(code)) {
|
|
||||||
code = "return null;\n//@ sourceURL=" + this.name + ".js";
|
|
||||||
}
|
|
||||||
this.code = code;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.CUSTOM_CODE,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.CustomCode.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.CustomCode.prototype.constructor = GameLib.API.CustomCode;
|
|
|
@ -1,45 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.Box3
|
|
||||||
* @constructor
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param parentEntity
|
|
||||||
* @param start
|
|
||||||
* @param count
|
|
||||||
*/
|
|
||||||
GameLib.API.DrawRange = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
parentEntity,
|
|
||||||
start,
|
|
||||||
count
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'DrawRange (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(start)) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
this.start = start;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(count)) {
|
|
||||||
count = Infinity;
|
|
||||||
}
|
|
||||||
this.count = count;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.DRAW_RANGE,
|
|
||||||
parentEntity
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.DrawRange.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.DrawRange.prototype.constructor = GameLib.API.DrawRange;
|
|
|
@ -1,64 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.GraphicsRuntime
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param graphicsType
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.GraphicsRuntime = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
graphicsType,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Graphics Runtime (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(graphicsType)) {
|
|
||||||
graphicsType = null;
|
|
||||||
}
|
|
||||||
this.graphicsType = graphicsType;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.API.GraphicsRuntime.GetComponentType(this.graphicsType),
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.GraphicsRuntime.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.GraphicsRuntime.prototype.constructor = GameLib.API.GraphicsRuntime;
|
|
||||||
|
|
||||||
GameLib.API.GraphicsRuntime.GetComponentType = function(graphicsType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (graphicsType) {
|
|
||||||
case GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_NONE :
|
|
||||||
componentType = GameLib.Component.GRAPHICS;
|
|
||||||
break;
|
|
||||||
case GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_THREE_JS :
|
|
||||||
componentType = GameLib.Component.GRAPHICS_THREE;
|
|
||||||
break;
|
|
||||||
case GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_IMPACT_JS :
|
|
||||||
componentType = GameLib.Component.GRAPHICS_IMPACT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error('Invalid graphics type');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_NONE = 0x0;
|
|
||||||
GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_THREE_JS = 0x1;
|
|
||||||
GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_IMPACT_JS = 0x2;
|
|
|
@ -1,30 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.GraphicsRuntime.Impact
|
|
||||||
* @constructor
|
|
||||||
* @param apiGraphicsRuntime
|
|
||||||
*/
|
|
||||||
GameLib.API.GraphicsRuntime.Impact = function(
|
|
||||||
apiGraphicsRuntime
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGraphicsRuntime)) {
|
|
||||||
apiGraphicsRuntime = {
|
|
||||||
graphicsType : GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_IMPACT_JS
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGraphicsRuntime.graphicsType)) {
|
|
||||||
apiGraphicsRuntime.graphicsType = GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_IMPACT_JS;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.GraphicsRuntime.call(
|
|
||||||
this,
|
|
||||||
apiGraphicsRuntime.id,
|
|
||||||
apiGraphicsRuntime.name,
|
|
||||||
apiGraphicsRuntime.graphicsType,
|
|
||||||
apiGraphicsRuntime.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.GraphicsRuntime.Impact.prototype = Object.create(GameLib.API.GraphicsRuntime.prototype);
|
|
||||||
GameLib.API.GraphicsRuntime.Impact.prototype.constructor = GameLib.API.GraphicsRuntime.Impact;
|
|
|
@ -1,30 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.GraphicsRuntime.Three
|
|
||||||
* @constructor
|
|
||||||
* @param apiGraphicsRuntime
|
|
||||||
*/
|
|
||||||
GameLib.API.GraphicsRuntime.Three = function(
|
|
||||||
apiGraphicsRuntime
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGraphicsRuntime)) {
|
|
||||||
apiGraphicsRuntime = {
|
|
||||||
graphicsType : GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_THREE_JS
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGraphicsRuntime.graphicsType)) {
|
|
||||||
apiGraphicsRuntime.graphicsType = GameLib.API.GraphicsRuntime.GRAPHICS_TYPE_THREE_JS;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.GraphicsRuntime.call(
|
|
||||||
this,
|
|
||||||
apiGraphicsRuntime.id,
|
|
||||||
apiGraphicsRuntime.name,
|
|
||||||
apiGraphicsRuntime.graphicsType,
|
|
||||||
apiGraphicsRuntime.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.GraphicsRuntime.Three.prototype = Object.create(GameLib.API.GraphicsRuntime.prototype);
|
|
||||||
GameLib.API.GraphicsRuntime.Three.prototype.constructor = GameLib.API.GraphicsRuntime.Three;
|
|
|
@ -1,52 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.Group
|
|
||||||
* @constructor
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param parentEntity
|
|
||||||
* @param start
|
|
||||||
* @param count
|
|
||||||
* @param materialIndex
|
|
||||||
*/
|
|
||||||
GameLib.API.Group = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
parentEntity,
|
|
||||||
start,
|
|
||||||
count,
|
|
||||||
materialIndex
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Group (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(start)) {
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
this.start = start;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(count)) {
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
this.count = count;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(materialIndex)) {
|
|
||||||
materialIndex = 0;
|
|
||||||
}
|
|
||||||
this.materialIndex = materialIndex;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.GROUP,
|
|
||||||
parentEntity
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Group.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.Group.prototype.constructor = GameLib.API.Group;
|
|
|
@ -1,159 +0,0 @@
|
||||||
/**
|
|
||||||
* Api Matrix 4
|
|
||||||
* @param row0 GameLib.API.Vector4
|
|
||||||
* @param row1 GameLib.API.Vector4
|
|
||||||
* @param row2 GameLib.API.Vector4
|
|
||||||
* @param row3 GameLib.API.Vector4
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Matrix4 = function ApiMatrix4(
|
|
||||||
row0,
|
|
||||||
row1,
|
|
||||||
row2,
|
|
||||||
row3
|
|
||||||
) {
|
|
||||||
this.rows = [];
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(row0)) {
|
|
||||||
row0 = new GameLib.API.Vector4(1, 0, 0, 0);
|
|
||||||
}
|
|
||||||
this.rows[0] = row0;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(row1)) {
|
|
||||||
row1 = new GameLib.API.Vector4(0, 1, 0, 0);
|
|
||||||
}
|
|
||||||
this.rows[1] = row1;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(row2)) {
|
|
||||||
row2 = new GameLib.API.Vector4(0, 0, 1, 0);
|
|
||||||
}
|
|
||||||
this.rows[2] = row2;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(row3)) {
|
|
||||||
row3 = new GameLib.API.Vector4(0, 0, 0, 1);
|
|
||||||
}
|
|
||||||
this.rows[3] = row3;
|
|
||||||
|
|
||||||
this.temp = [];
|
|
||||||
this.temp.push(
|
|
||||||
new GameLib.API.Vector4()
|
|
||||||
);
|
|
||||||
|
|
||||||
this.temp.push(
|
|
||||||
new GameLib.API.Vector4()
|
|
||||||
);
|
|
||||||
|
|
||||||
this.temp.push(
|
|
||||||
new GameLib.API.Vector4()
|
|
||||||
);
|
|
||||||
|
|
||||||
this.temp.push(
|
|
||||||
new GameLib.API.Vector4()
|
|
||||||
);
|
|
||||||
|
|
||||||
this.forward = new GameLib.API.Vector4();
|
|
||||||
this.left = new GameLib.API.Vector4();
|
|
||||||
this.up = new GameLib.API.Vector4();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an API matrix from an Object matrix
|
|
||||||
* @param objectMatrix
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Matrix4.FromObject = function(objectMatrix) {
|
|
||||||
|
|
||||||
if (objectMatrix.rows) {
|
|
||||||
return new GameLib.API.Matrix4(
|
|
||||||
GameLib.API.Vector4.FromObject(objectMatrix.rows[0]),
|
|
||||||
GameLib.API.Vector4.FromObject(objectMatrix.rows[1]),
|
|
||||||
GameLib.API.Vector4.FromObject(objectMatrix.rows[2]),
|
|
||||||
GameLib.API.Vector4.FromObject(objectMatrix.rows[3])
|
|
||||||
);
|
|
||||||
} else if (objectMatrix instanceof Array) {
|
|
||||||
return new GameLib.API.Matrix4(
|
|
||||||
GameLib.API.Vector4.FromObject(objectMatrix[0]),
|
|
||||||
GameLib.API.Vector4.FromObject(objectMatrix[1]),
|
|
||||||
GameLib.API.Vector4.FromObject(objectMatrix[2]),
|
|
||||||
GameLib.API.Vector4.FromObject(objectMatrix[3])
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.warn('Unsupported object matrix type - whats your DB version?');
|
|
||||||
throw new Error('Unsupported object matrix type - whats your DB version?');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Matrix4.prototype.rotationMatrixX = function (radians) {
|
|
||||||
this.identity();
|
|
||||||
this.rows[1] = new GameLib.API.Vector4(0, Math.cos(radians), -1 * Math.sin(radians), 0);
|
|
||||||
this.rows[2] = new GameLib.API.Vector4(0, Math.sin(radians), Math.cos(radians), 0);
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Matrix4.prototype.rotationMatrixY = function (radians) {
|
|
||||||
this.identity();
|
|
||||||
this.rows[0] = new GameLib.API.Vector4(
|
|
||||||
Math.cos(radians),
|
|
||||||
0,
|
|
||||||
Math.sin(radians),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
this.rows[2] = new GameLib.API.Vector4(
|
|
||||||
-1 * Math.sin(radians),
|
|
||||||
0,
|
|
||||||
Math.cos(radians),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Matrix4.prototype.rotationMatrixZ = function (radians) {
|
|
||||||
this.identity();
|
|
||||||
this.rows[0] = new GameLib.API.Vector4(Math.cos(radians), -1 * Math.sin(radians), 0, 0);
|
|
||||||
this.rows[1] = new GameLib.API.Vector4(Math.sin(radians), Math.cos(radians), 0, 0);
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Matrix4.prototype.rotateX = function (radians, point) {
|
|
||||||
this.identity();
|
|
||||||
this.rotationMatrixX(radians);
|
|
||||||
return this.multiply(point);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Matrix4.prototype.rotateY = function (radians, point) {
|
|
||||||
this.identity();
|
|
||||||
this.rotationMatrixY(radians);
|
|
||||||
return this.multiply(point);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Matrix4.prototype.rotateZ = function (radians, point) {
|
|
||||||
this.identity();
|
|
||||||
this.rotationMatrixZ(radians);
|
|
||||||
return this.multiply(point);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Matrix4.prototype.multiply = function (mvp) {
|
|
||||||
if (mvp instanceof GameLib.API.Quaternion || mvp instanceof GameLib.API.Vector4) {
|
|
||||||
return new GameLib.API.Quaternion(
|
|
||||||
this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z + this.rows[0].w * mvp.w,
|
|
||||||
this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z + this.rows[1].w * mvp.w,
|
|
||||||
this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + this.rows[2].w * mvp.w,
|
|
||||||
this.rows[3].x * mvp.x + this.rows[3].y * mvp.y + this.rows[3].z * mvp.z + this.rows[3].w * mvp.w
|
|
||||||
);
|
|
||||||
} else if (mvp instanceof GameLib.API.Vector3) {
|
|
||||||
return new GameLib.API.Vector3(
|
|
||||||
this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z,
|
|
||||||
this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z,
|
|
||||||
this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Matrix4.prototype.identity = function () {
|
|
||||||
this.rows = [
|
|
||||||
new GameLib.API.Vector4(1, 0, 0, 0),
|
|
||||||
new GameLib.API.Vector4(0, 1, 0, 0),
|
|
||||||
new GameLib.API.Vector4(0, 0, 1, 0),
|
|
||||||
new GameLib.API.Vector4(0, 0, 0, 1)
|
|
||||||
];
|
|
||||||
};
|
|
|
@ -1,45 +0,0 @@
|
||||||
/**
|
|
||||||
* API Mouse
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param parentEntity
|
|
||||||
* @param x
|
|
||||||
* @param y
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Mouse = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
parentEntity,
|
|
||||||
x,
|
|
||||||
y
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Mouse (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(x)) {
|
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
this.x = x;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(y)) {
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
this.y = y;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.MOUSE,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Mouse.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.Mouse.prototype.constructor = GameLib.API.Mouse;
|
|
|
@ -1,53 +0,0 @@
|
||||||
GameLib.API.Plane = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
normal,
|
|
||||||
constant,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Plane (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(normal)) {
|
|
||||||
normal = new GameLib.API.Vector3(1,0,0);
|
|
||||||
}
|
|
||||||
this.normal = normal;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(constant)) {
|
|
||||||
constant = 0;
|
|
||||||
}
|
|
||||||
this.constant = constant;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.PLANE,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.API.Plane.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.Plane.prototype.constructor = GameLib.API.Plane;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an API vector from an Object vector
|
|
||||||
* @param objectPlane
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Plane.FromObject = function (objectPlane) {
|
|
||||||
return new GameLib.API.Plane(
|
|
||||||
objectPlane.id,
|
|
||||||
objectPlane.name,
|
|
||||||
GameLib.API.Vector3.FromObject(objectPlane.normal),
|
|
||||||
objectPlane.constant,
|
|
||||||
objectPlane.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,117 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.RenderConfiguration
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param parentEntity
|
|
||||||
* @param logicalSize
|
|
||||||
* @param aspectRatio
|
|
||||||
* @param scaleMode
|
|
||||||
* @param activeCamera
|
|
||||||
* @param activeScenes
|
|
||||||
* @param activeComposer
|
|
||||||
* @param activeEffect
|
|
||||||
* @param activeRenderer
|
|
||||||
* @param enableComposer
|
|
||||||
* @param enableEffect
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.RenderConfiguration = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
parentEntity,
|
|
||||||
logicalSize,
|
|
||||||
aspectRatio,
|
|
||||||
scaleMode,
|
|
||||||
activeCamera,
|
|
||||||
activeScenes,
|
|
||||||
activeRenderer,
|
|
||||||
activeComposer,
|
|
||||||
activeEffect,
|
|
||||||
enableComposer,
|
|
||||||
enableEffect
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = "RenderConfiguration (" + this.id + ")";
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(logicalSize)) {
|
|
||||||
logicalSize = new GameLib.API.Vector2(
|
|
||||||
480,
|
|
||||||
320
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.logicalSize = logicalSize;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(aspectRatio)) {
|
|
||||||
aspectRatio = GameLib.API.Renderer.ASPECT_RATIO_3_2;
|
|
||||||
}
|
|
||||||
this.aspectRatio = aspectRatio;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scaleMode)) {
|
|
||||||
scaleMode = GameLib.API.Renderer.SCALE_MODE_LETTERBOX;
|
|
||||||
}
|
|
||||||
this.scaleMode = scaleMode;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(activeCamera)) {
|
|
||||||
activeCamera = null;
|
|
||||||
}
|
|
||||||
this.activeCamera = activeCamera;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(activeScenes)) {
|
|
||||||
activeScenes = [];
|
|
||||||
}
|
|
||||||
this.activeScenes = activeScenes;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(activeRenderer)) {
|
|
||||||
activeRenderer = null;
|
|
||||||
}
|
|
||||||
this.activeRenderer = activeRenderer;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(activeComposer)) {
|
|
||||||
activeComposer = null;
|
|
||||||
}
|
|
||||||
this.activeComposer = activeComposer;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(activeEffect)) {
|
|
||||||
activeEffect = null;
|
|
||||||
}
|
|
||||||
this.activeEffect = activeEffect;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(enableComposer)) {
|
|
||||||
enableComposer = false;
|
|
||||||
}
|
|
||||||
this.enableComposer = enableComposer;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(enableEffect)) {
|
|
||||||
enableEffect = false;
|
|
||||||
}
|
|
||||||
this.enableEffect = enableEffect;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.RENDER_CONFIGURATION,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.RenderConfiguration.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.RenderConfiguration.prototype.constructor = GameLib.API.RenderConfiguration;
|
|
||||||
|
|
||||||
GameLib.API.RenderConfiguration.ASPECT_RATIO_NONE = 0x1;
|
|
||||||
GameLib.API.RenderConfiguration.ASPECT_RATIO_4_3 = 0x2;
|
|
||||||
GameLib.API.RenderConfiguration.ASPECT_RATIO_3_2 = 0x3;
|
|
||||||
GameLib.API.RenderConfiguration.ASPECT_RATIO_16_10 = 0x4;
|
|
||||||
GameLib.API.RenderConfiguration.ASPECT_RATIO_17_10 = 0x5;
|
|
||||||
GameLib.API.RenderConfiguration.ASPECT_RATIO_16_9 = 0x6;
|
|
||||||
|
|
||||||
GameLib.API.RenderConfiguration.SCALE_MODE_NONE = 0x1;
|
|
||||||
GameLib.API.RenderConfiguration.SCALE_MODE_LETTERBOX = 0x2;
|
|
||||||
GameLib.API.RenderConfiguration.SCALE_MODE_ZOOM_TO_BIGGER = 0x3;
|
|
||||||
GameLib.API.RenderConfiguration.SCALE_MODE_NON_UNIFORM = 0x4;
|
|
|
@ -1,122 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.Renderer
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param rendererType
|
|
||||||
* @param parentEntity
|
|
||||||
* @param width
|
|
||||||
* @param height
|
|
||||||
* @param offset
|
|
||||||
* @param canvas
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Renderer = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
rendererType,
|
|
||||||
parentEntity,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
offset,
|
|
||||||
canvas
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(rendererType)) {
|
|
||||||
rendererType = GameLib.API.Renderer.RENDERER_TYPE_NONE;
|
|
||||||
}
|
|
||||||
this.rendererType = rendererType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
switch (this.rendererType) {
|
|
||||||
case GameLib.API.Renderer.RENDERER_TYPE_NONE :
|
|
||||||
name = "Renderer";
|
|
||||||
break;
|
|
||||||
case GameLib.API.Renderer.RENDERER_TYPE_2D :
|
|
||||||
name = "Renderer 2D";
|
|
||||||
break;
|
|
||||||
case GameLib.API.Renderer.RENDERER_TYPE_3D :
|
|
||||||
name = "Renderer 3D";
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('no nice name for renderer');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
name += " (" + this.id + ")";
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(width)) {
|
|
||||||
width = 1;
|
|
||||||
}
|
|
||||||
this.width = width;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
|
||||||
height = 1;
|
|
||||||
}
|
|
||||||
this.height = height;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(offset)) {
|
|
||||||
offset = new GameLib.API.Vector2(0,0);
|
|
||||||
}
|
|
||||||
this.offset = offset;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(canvas)) {
|
|
||||||
canvas = new GameLib.API.Canvas();
|
|
||||||
}
|
|
||||||
this.canvas = canvas;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.API.Renderer.GetComponentType(this.rendererType),
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Renderer.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.Renderer.prototype.constructor = GameLib.API.Renderer;
|
|
||||||
|
|
||||||
GameLib.API.Renderer.GetComponentType = function(rendererType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (rendererType) {
|
|
||||||
case GameLib.API.Renderer.RENDERER_TYPE_NONE :
|
|
||||||
componentType = GameLib.Component.RENDERER;
|
|
||||||
break;
|
|
||||||
case GameLib.API.Renderer.RENDERER_TYPE_2D :
|
|
||||||
componentType = GameLib.Component.RENDERER_D2;
|
|
||||||
break;
|
|
||||||
case GameLib.API.Renderer.RENDERER_TYPE_3D :
|
|
||||||
componentType = GameLib.Component.RENDERER_D3;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('could not determine component type');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Renderer.RENDERER_TYPE_NONE = 0x0;
|
|
||||||
GameLib.API.Renderer.RENDERER_TYPE_2D = 0x1;
|
|
||||||
GameLib.API.Renderer.RENDERER_TYPE_3D = 0x2;
|
|
||||||
|
|
||||||
GameLib.API.Renderer.MODE_CANVAS = 0x1;
|
|
||||||
GameLib.API.Renderer.MODE_TARGET = 0x2;
|
|
||||||
GameLib.API.Renderer.MODE_CANVAS_AND_TARGET = 0x3;
|
|
||||||
|
|
||||||
GameLib.API.Renderer.SHADOW_MAP_TYPE_BASIC = 0;
|
|
||||||
GameLib.API.Renderer.SHADOW_MAP_TYPE_PCF = 1;
|
|
||||||
GameLib.API.Renderer.SHADOW_MAP_TYPE_PCF_SOFT = 2;
|
|
||||||
|
|
||||||
GameLib.API.Renderer.TONE_MAPPING_LINEAR = 1;
|
|
||||||
GameLib.API.Renderer.TONE_MAPPING_REINHARD = 2;
|
|
||||||
GameLib.API.Renderer.TONE_MAPPING_UNCHARTED_2 = 3;
|
|
||||||
GameLib.API.Renderer.TONE_MAPPING_CINEON = 4;
|
|
|
@ -1,35 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.API.Renderer.D2
|
|
||||||
* @constructor
|
|
||||||
* @param apiRenderer
|
|
||||||
*/
|
|
||||||
GameLib.API.Renderer.D2 = function (
|
|
||||||
apiRenderer
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiRenderer)) {
|
|
||||||
apiRenderer = {
|
|
||||||
rendererType : GameLib.API.Renderer.RENDERER_TYPE_2D
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiRenderer.rendererType)) {
|
|
||||||
apiRenderer.rendererType = GameLib.API.Renderer.RENDERER_TYPE_2D;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Renderer.call(
|
|
||||||
this,
|
|
||||||
apiRenderer.id,
|
|
||||||
apiRenderer.name,
|
|
||||||
apiRenderer.rendererType,
|
|
||||||
apiRenderer.parentEntity,
|
|
||||||
apiRenderer.width,
|
|
||||||
apiRenderer.height,
|
|
||||||
apiRenderer.offset,
|
|
||||||
apiRenderer.canvas
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Renderer.D2.prototype = Object.create(GameLib.API.Renderer.prototype);
|
|
||||||
GameLib.API.Renderer.D2.prototype.constructor = GameLib.API.Renderer.D2;
|
|
|
@ -1,93 +0,0 @@
|
||||||
/**
|
|
||||||
* Raw Socket API object - should always correspond with the Socket Schema
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param socketType
|
|
||||||
* @param roomId
|
|
||||||
* @param peerId
|
|
||||||
* @param server GameLib.Server
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Socket = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
socketType,
|
|
||||||
roomId,
|
|
||||||
peerId,
|
|
||||||
server,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Socket (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(socketType)) {
|
|
||||||
socketType = GameLib.API.Socket.TYPE_NONE;
|
|
||||||
}
|
|
||||||
this.socketType = socketType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(roomId)) {
|
|
||||||
roomId = 'room_' + GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.roomId = roomId;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(peerId)) {
|
|
||||||
peerId = null;
|
|
||||||
}
|
|
||||||
this.peerId = peerId;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(server)) {
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
this.server = server;
|
|
||||||
|
|
||||||
var componentType = GameLib.Component.SOCKET;
|
|
||||||
|
|
||||||
if (this.socketType === GameLib.API.Socket.TYPE_CAST) {
|
|
||||||
componentType = GameLib.Component.SOCKET_CAST;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.socketType === GameLib.API.Socket.TYPE_RECEIVE) {
|
|
||||||
componentType = GameLib.Component.SOCKET_RECEIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Socket.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.Socket.prototype.constructor = GameLib.API.Socket;
|
|
||||||
|
|
||||||
GameLib.API.Socket.TYPE_NONE = 0x1;
|
|
||||||
GameLib.API.Socket.TYPE_CAST = 0x2;
|
|
||||||
GameLib.API.Socket.TYPE_RECEIVE = 0x3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an API Socket from an Object Socket
|
|
||||||
* @param objectSocket
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Socket.FromObject = function(objectSocket) {
|
|
||||||
|
|
||||||
return new GameLib.API.Socket(
|
|
||||||
objectSocket.id,
|
|
||||||
objectSocket.name,
|
|
||||||
objectSocket.socketType,
|
|
||||||
objectSocket.roomId,
|
|
||||||
objectSocket.peerId,
|
|
||||||
objectSocket.server,
|
|
||||||
objectSocket.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,78 +0,0 @@
|
||||||
/**
|
|
||||||
* Raw Cast API object - should always correspond with the Cast Schema
|
|
||||||
* @param apiSocket
|
|
||||||
* @param castType
|
|
||||||
* @param source
|
|
||||||
* @param sourceProperties
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Socket.Cast = function(
|
|
||||||
apiSocket,
|
|
||||||
castType,
|
|
||||||
source,
|
|
||||||
sourceProperties
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiSocket)) {
|
|
||||||
apiSocket = {
|
|
||||||
socketType : GameLib.API.Socket.SOCKET_CAST
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Socket.call(
|
|
||||||
this,
|
|
||||||
apiSocket.id,
|
|
||||||
apiSocket.name,
|
|
||||||
apiSocket.socketType,
|
|
||||||
apiSocket.roomId,
|
|
||||||
apiSocket.peerId,
|
|
||||||
apiSocket.server,
|
|
||||||
apiSocket.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(castType)) {
|
|
||||||
castType = GameLib.API.Socket.Cast.CAST_TYPE_ROOM;
|
|
||||||
}
|
|
||||||
this.castType = castType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(source)) {
|
|
||||||
source = null;
|
|
||||||
}
|
|
||||||
this.source = source;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(sourceProperties)) {
|
|
||||||
sourceProperties = null;
|
|
||||||
}
|
|
||||||
this.sourceProperties = sourceProperties;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.SOCKET_CAST
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.Socket.Cast.prototype = Object.create(GameLib.API.Socket.prototype);
|
|
||||||
GameLib.API.Socket.Cast.prototype.constructor = GameLib.API.Socket.Cast.Receive;
|
|
||||||
|
|
||||||
GameLib.API.Socket.Cast.CAST_TYPE_ROOM = 0x1;
|
|
||||||
GameLib.API.Socket.Cast.CAST_TYPE_PEER = 0x2;
|
|
||||||
GameLib.API.Socket.Cast.CAST_TYPE_ALL = 0x3;
|
|
||||||
GameLib.API.Socket.Cast.CAST_TYPE_ALL_BUT_PEER = 0x4;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an API.Socket.Cast from an Object Cast
|
|
||||||
* @param objectSocketCast
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.Socket.Cast.FromObject = function(objectSocketCast) {
|
|
||||||
|
|
||||||
var apiSocket = GameLib.API.Socket.FromObject(objectSocketCast);
|
|
||||||
|
|
||||||
return new GameLib.API.Socket.Cast(
|
|
||||||
apiSocket,
|
|
||||||
objectSocketCast.castType,
|
|
||||||
objectSocketCast.source,
|
|
||||||
objectSocketCast.sourceProperties
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,20 +0,0 @@
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
};
|
|
|
@ -1,104 +0,0 @@
|
||||||
/**
|
|
||||||
* This component renders a scene
|
|
||||||
* @param id String
|
|
||||||
* @param name String
|
|
||||||
* @param systemType
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.System = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
systemType,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = "System (" + this.id + ")";
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(systemType)) {
|
|
||||||
systemType = GameLib.System.SYSTEM_TYPE_NONE;
|
|
||||||
}
|
|
||||||
this.systemType = systemType;
|
|
||||||
|
|
||||||
var componentType = GameLib.Component.SYSTEM;
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_NONE) {
|
|
||||||
componentType = GameLib.Component.SYSTEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_ANIMATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_CUSTOM) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_CUSTOM_CODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_GUI) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_GUI;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_INPUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_LINKING) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_LINKING;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_PHYSICS) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_PHYSICS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_RENDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_STORAGE) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_STORAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_VISUALIZATION) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_VISUALIZATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_PARTICLE) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_PARTICLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemType === GameLib.System.SYSTEM_TYPE_AUDIO) {
|
|
||||||
componentType = GameLib.Component.SYSTEM_AUDIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.API.System.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.API.System.prototype.constructor = GameLib.API.System;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Object to GameLib.D3.API.System
|
|
||||||
* @param objectComponent
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.API.System.FromObject = function(objectComponent) {
|
|
||||||
return new GameLib.API.System(
|
|
||||||
objectComponent.id,
|
|
||||||
objectComponent.name,
|
|
||||||
objectComponent.systemType,
|
|
||||||
objectComponent.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,96 +0,0 @@
|
||||||
/**
|
|
||||||
* Creates a Clock object
|
|
||||||
* @param graphics
|
|
||||||
* @param apiClock GameLib.API.Clock
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Clock = function(
|
|
||||||
graphics,
|
|
||||||
apiClock
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiClock)) {
|
|
||||||
apiClock = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Clock.call(
|
|
||||||
this,
|
|
||||||
apiClock.id,
|
|
||||||
apiClock.name,
|
|
||||||
apiClock.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.Component.call(this);
|
|
||||||
} ;
|
|
||||||
|
|
||||||
GameLib.Clock.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.Clock.prototype.constructor = GameLib.Clock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a camera instance of 'graphics' type (only THREE for now)
|
|
||||||
* @returns {THREE.Clock}
|
|
||||||
*/
|
|
||||||
GameLib.Clock.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
this.instance = new THREE.Clock();
|
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.Clock.prototype.updateInstance = function() {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.Clock.prototype.getDelta = function() {
|
|
||||||
|
|
||||||
var delta = this.instance.getDelta();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clamp the delta to 1/60
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (delta > (1 / 30.0)) {
|
|
||||||
// console.log('clipped ' + (delta - (1/30.0)) + ' seconds - essentially lost time');
|
|
||||||
delta = (1 / 30.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return delta;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.Clock to a new GameLib.API.Clock
|
|
||||||
* @returns {GameLib.API.Clock}
|
|
||||||
*/
|
|
||||||
GameLib.Clock.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
return new GameLib.API.Clock(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts from an Object camera to a GameLib.Clock
|
|
||||||
* @param graphics GameLib.Graphics
|
|
||||||
* @param objectClock Object
|
|
||||||
* @returns {GameLib.Clock}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Clock.FromObject = function(graphics, objectClock) {
|
|
||||||
|
|
||||||
var apiClock = GameLib.API.Clock.FromObject(objectClock);
|
|
||||||
|
|
||||||
return new GameLib.Clock(
|
|
||||||
graphics,
|
|
||||||
apiClock
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,100 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.Controls
|
|
||||||
* @param apiControls
|
|
||||||
* @property controlsType
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Controls = function (
|
|
||||||
apiControls
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiControls)) {
|
|
||||||
apiControls = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Controls.call(
|
|
||||||
this,
|
|
||||||
apiControls.id,
|
|
||||||
apiControls.name,
|
|
||||||
apiControls.controlsType,
|
|
||||||
apiControls.canvas,
|
|
||||||
apiControls.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
var linkedObjects = {
|
|
||||||
canvas : GameLib.Canvas
|
|
||||||
};
|
|
||||||
|
|
||||||
var delayed = false;
|
|
||||||
|
|
||||||
switch (this.controlsType) {
|
|
||||||
case (GameLib.API.Controls.CONTROLS_TYPE_EDITOR) :
|
|
||||||
linkedObjects.raycaster = GameLib.D3.Raycaster;
|
|
||||||
linkedObjects.camera = GameLib.D3.Camera;
|
|
||||||
delayed = true;
|
|
||||||
break;
|
|
||||||
case (GameLib.API.Controls.CONTROLS_TYPE_FIRST_PERSON) :
|
|
||||||
linkedObjects.camera = GameLib.D3.Camera;
|
|
||||||
delayed = true;
|
|
||||||
break;
|
|
||||||
case (GameLib.API.Controls.CONTROLS_TYPE_ORBIT) :
|
|
||||||
linkedObjects.camera = GameLib.D3.Camera;
|
|
||||||
linkedObjects.target = GameLib.Component;
|
|
||||||
delayed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
linkedObjects,
|
|
||||||
delayed
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.Controls.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.Controls.prototype.constructor = GameLib.Controls;
|
|
||||||
|
|
||||||
GameLib.Controls.D3 = function() {};
|
|
||||||
GameLib.Controls.D3.prototype = Object.create(GameLib.Controls.prototype);
|
|
||||||
GameLib.Controls.D3.prototype.constructor = GameLib.Controls.D3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a mesh instance or updates it
|
|
||||||
*/
|
|
||||||
GameLib.Controls.prototype.createInstance = function() {
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the mesh instance
|
|
||||||
*/
|
|
||||||
GameLib.Controls.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (property === 'canvas') {
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.CANVAS_CHANGE,
|
|
||||||
{
|
|
||||||
component: this
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.Controls to a GameLib.API.Controls
|
|
||||||
* @returns {GameLib.API.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiControls = new GameLib.API.Controls(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
this.controlsType,
|
|
||||||
GameLib.Utils.IdOrNull(this.canvas),
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiControls;
|
|
||||||
};
|
|
|
@ -1,116 +0,0 @@
|
||||||
/**
|
|
||||||
* Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiEditorControls
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Controls.D3.Editor = function (
|
|
||||||
graphics,
|
|
||||||
apiEditorControls
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiEditorControls)) {
|
|
||||||
apiEditorControls = {
|
|
||||||
controlsType : GameLib.API.Controls.CONTROLS_TYPE_EDITOR
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull()) {
|
|
||||||
apiEditorControls.controlsType = GameLib.API.Controls.CONTROLS_TYPE_EDITOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Controls.D3.Editor.call(
|
|
||||||
this,
|
|
||||||
apiEditorControls,
|
|
||||||
apiEditorControls.raycaster,
|
|
||||||
apiEditorControls.camera
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.raycaster instanceof GameLib.D3.API.Raycaster) {
|
|
||||||
this.raycaster = new GameLib.D3.Raycaster(
|
|
||||||
this.graphics,
|
|
||||||
this.raycaster
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Controls.call(
|
|
||||||
this,
|
|
||||||
apiEditorControls
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inheritance
|
|
||||||
* @type {GameLib.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.D3.Editor.prototype = Object.create(GameLib.Controls.D3.prototype);
|
|
||||||
GameLib.Controls.D3.Editor.prototype.constructor = GameLib.Controls.D3.Editor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Instance
|
|
||||||
*/
|
|
||||||
GameLib.Controls.D3.Editor.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
if (
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.camera) ||
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.camera.instance)
|
|
||||||
) {
|
|
||||||
console.warn('no camera at time of editor-controls create instance');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.canvas) ||
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.canvas.instance)
|
|
||||||
) {
|
|
||||||
console.warn('no canvas at time of editor-controls create instance');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance = new THREE.EditorControls(
|
|
||||||
this.camera.instance,
|
|
||||||
this.canvas.instance
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.Controls.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Instance
|
|
||||||
*/
|
|
||||||
GameLib.Controls.D3.Editor.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (
|
|
||||||
property === 'canvas' ||
|
|
||||||
property === 'camera'
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
|
||||||
this.createInstance();
|
|
||||||
} else {
|
|
||||||
this.instance.dispose();
|
|
||||||
this.createInstance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.warn('an update instance was called on editor controls - which, if not called from within a running system at the right time will affect the order of input event handling and cause system instability');
|
|
||||||
|
|
||||||
GameLib.Controls.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.Controls.D3.Editor to a GameLib.D3.API.Mesh
|
|
||||||
* @returns {GameLib.API.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.D3.Editor.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
apiControls.raycaster = GameLib.Utils.IdOrNull(this.raycaster);
|
|
||||||
apiControls.camera = GameLib.Utils.IdOrNull(this.camera);
|
|
||||||
|
|
||||||
return apiControls;
|
|
||||||
};
|
|
|
@ -1,79 +0,0 @@
|
||||||
/**
|
|
||||||
* Keyboard Controls
|
|
||||||
* @param apiKeyboardControls GameLib.API.Controls
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Keyboard = function (
|
|
||||||
apiKeyboardControls
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiKeyboardControls)) {
|
|
||||||
apiKeyboardControls = {
|
|
||||||
controlsType : GameLib.API.Controls.CONTROLS_TYPE_KEYBOARD
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Controls.Keyboard.call(
|
|
||||||
this,
|
|
||||||
apiKeyboardControls
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.Controls.call(
|
|
||||||
this,
|
|
||||||
apiKeyboardControls
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inheritance
|
|
||||||
* @type {GameLib.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Keyboard.prototype = Object.create(GameLib.Controls.prototype);
|
|
||||||
GameLib.Controls.Keyboard.prototype.constructor = GameLib.Controls.Keyboard;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Instance
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Keyboard.prototype.createInstance = function() {
|
|
||||||
/**
|
|
||||||
* Set instance to true to indicate no dependencies to other components
|
|
||||||
*/
|
|
||||||
this.instance = true;
|
|
||||||
GameLib.Controls.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Instance
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Keyboard.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.Controls.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.Controls.Keyboard to a GameLib.API.Controls
|
|
||||||
* @returns {GameLib.API.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Keyboard.prototype.toApiObject = function() {
|
|
||||||
var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
|
|
||||||
/**
|
|
||||||
* add other properties here as this component develops...
|
|
||||||
*/
|
|
||||||
return apiControls;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an Keyboard Controls object from data
|
|
||||||
* @param objectControls
|
|
||||||
* @returns {GameLib.Controls.Keyboard}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Keyboard.FromObject = function(objectControls) {
|
|
||||||
|
|
||||||
var apiKeyboardControls = GameLib.API.Controls.Keyboard.FromObject(objectControls);
|
|
||||||
|
|
||||||
return new GameLib.Controls.Keyboard(
|
|
||||||
apiKeyboardControls
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,79 +0,0 @@
|
||||||
/**
|
|
||||||
* Mouse Controls
|
|
||||||
* @param apiMouseControls GameLib.API.Controls
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Mouse = function (
|
|
||||||
apiMouseControls
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiMouseControls)) {
|
|
||||||
apiMouseControls = {
|
|
||||||
controlsType : GameLib.API.Controls.CONTROLS_TYPE_MOUSE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Controls.Mouse.call(
|
|
||||||
this,
|
|
||||||
apiMouseControls
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.Controls.call(
|
|
||||||
this,
|
|
||||||
apiMouseControls
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inheritance
|
|
||||||
* @type {GameLib.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Mouse.prototype = Object.create(GameLib.Controls.prototype);
|
|
||||||
GameLib.Controls.Mouse.prototype.constructor = GameLib.Controls.Mouse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Instance
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Mouse.prototype.createInstance = function() {
|
|
||||||
/**
|
|
||||||
* Set instance to true to indicate no dependencies to other components
|
|
||||||
*/
|
|
||||||
this.instance = true;
|
|
||||||
GameLib.Controls.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Instance
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Mouse.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.Controls.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.Controls.Mouse to a GameLib.API.Controls
|
|
||||||
* @returns {GameLib.API.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Mouse.prototype.toApiObject = function() {
|
|
||||||
var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
|
|
||||||
/**
|
|
||||||
* add other properties here as this component develops...
|
|
||||||
*/
|
|
||||||
return apiControls;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an Mouse Controls object from data
|
|
||||||
* @param objectControls
|
|
||||||
* @returns {GameLib.Controls.Mouse}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Mouse.FromObject = function(objectControls) {
|
|
||||||
|
|
||||||
var apiMouseControls = GameLib.API.Controls.Mouse.FromObject(objectControls);
|
|
||||||
|
|
||||||
return new GameLib.Controls.Mouse(
|
|
||||||
apiMouseControls
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,82 +0,0 @@
|
||||||
/**
|
|
||||||
* Touch Controls
|
|
||||||
* @constructor
|
|
||||||
* @param apiTouchControls
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Touch = function (
|
|
||||||
apiTouchControls
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiTouchControls)) {
|
|
||||||
apiTouchControls = {
|
|
||||||
controlsType : GameLib.API.Controls.CONTROLS_TYPE_TOUCH
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Controls.Touch.call(
|
|
||||||
this,
|
|
||||||
apiTouchControls,
|
|
||||||
apiTouchControls.sensitivity
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.Controls.call(
|
|
||||||
this,
|
|
||||||
apiTouchControls
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inheritance
|
|
||||||
* @type {GameLib.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Touch.prototype = Object.create(GameLib.Controls.prototype);
|
|
||||||
GameLib.Controls.Touch.prototype.constructor = GameLib.Controls.Touch;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Instance
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Touch.prototype.createInstance = function() {
|
|
||||||
/**
|
|
||||||
* Set instance to true to indicate no dependencies to other components
|
|
||||||
*/
|
|
||||||
this.instance = true;
|
|
||||||
GameLib.Controls.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Instance
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Touch.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.Controls.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.Controls.Touch to a GameLib.API.Controls
|
|
||||||
* @returns {GameLib.API.Controls}
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Touch.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
apiControls.sensitivity = this.sensitivity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add other properties here as this component develops...
|
|
||||||
*/
|
|
||||||
return apiControls;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an Touch Controls object from data
|
|
||||||
* @param objectControls
|
|
||||||
* @returns {GameLib.Controls.Touch}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.Controls.Touch.FromObject = function(objectControls) {
|
|
||||||
|
|
||||||
var apiTouchControls = GameLib.API.Controls.Touch.FromObject(objectControls);
|
|
||||||
|
|
||||||
return new GameLib.Controls.Touch(apiTouchControls);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,74 +0,0 @@
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,173 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Object
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param objectType
|
|
||||||
* @param parentEntity
|
|
||||||
* @param useQuaternion
|
|
||||||
* @param position
|
|
||||||
* @param quaternion
|
|
||||||
* @param rotation
|
|
||||||
* @param scale
|
|
||||||
* @param up
|
|
||||||
* @param lookAt
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Object = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
objectType,
|
|
||||||
parentEntity,
|
|
||||||
useQuaternion,
|
|
||||||
position,
|
|
||||||
quaternion,
|
|
||||||
rotation,
|
|
||||||
scale,
|
|
||||||
up,
|
|
||||||
lookAt
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(objectType)) {
|
|
||||||
objectType = 0;
|
|
||||||
}
|
|
||||||
this.objectType = objectType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
switch (this.objectType) {
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_NONE :
|
|
||||||
name = 'Object';
|
|
||||||
break;
|
|
||||||
/**
|
|
||||||
* Cameras
|
|
||||||
*/
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA :
|
|
||||||
name = 'Camera';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC :
|
|
||||||
name = 'Camera Orthographic';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE :
|
|
||||||
name = 'Camera Perspective';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE :
|
|
||||||
name = 'Camera Cube';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO :
|
|
||||||
name = 'Camera Stereo';
|
|
||||||
break;
|
|
||||||
/**
|
|
||||||
* Meshes
|
|
||||||
*/
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_MESH :
|
|
||||||
name = 'Mesh';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
name += ' (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(useQuaternion)) {
|
|
||||||
useQuaternion = true;
|
|
||||||
}
|
|
||||||
this.useQuaternion = useQuaternion;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.API.Vector3();
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(quaternion)) {
|
|
||||||
quaternion = new GameLib.API.Quaternion();
|
|
||||||
}
|
|
||||||
this.quaternion = quaternion;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = new GameLib.API.Vector3();
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scale)) {
|
|
||||||
scale = new GameLib.API.Vector3(1,1,1);
|
|
||||||
}
|
|
||||||
this.scale = scale;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(up)) {
|
|
||||||
up = new GameLib.API.Vector3(0,1,0);
|
|
||||||
}
|
|
||||||
this.up = up;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(lookAt)) {
|
|
||||||
lookAt = new GameLib.API.Vector3();
|
|
||||||
}
|
|
||||||
this.lookAt = lookAt;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.D3.API.Object.GetComponentType(this.objectType),
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Object.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Object.prototype.constructor = GameLib.D3.API.Object;
|
|
||||||
|
|
||||||
GameLib.D3.API.Object.GetComponentType = function(objectType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (objectType) {
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_NONE :
|
|
||||||
componentType = GameLib.Component.OBJECT;
|
|
||||||
break;
|
|
||||||
/**
|
|
||||||
* Cameras
|
|
||||||
*/
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA :
|
|
||||||
componentType = GameLib.Component.CAMERA;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE :
|
|
||||||
componentType = GameLib.Component.CAMERA_PERSPECTIVE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC :
|
|
||||||
componentType = GameLib.Component.CAMERA_ORTHOGRAPHIC;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO :
|
|
||||||
componentType = GameLib.Component.CAMERA_STEREO;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE :
|
|
||||||
componentType = GameLib.Component.CAMERA_CUBE;
|
|
||||||
break;
|
|
||||||
/**
|
|
||||||
* Meshes
|
|
||||||
*/
|
|
||||||
case GameLib.D3.API.Object.OBJECT_TYPE_MESH :
|
|
||||||
componentType = GameLib.Component.MESH;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error('unsupported camera type: ' + objectType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Object.OBJECT_TYPE_NONE = 0x0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cameras
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA = 0x11;
|
|
||||||
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE = 0x12;//0x1;
|
|
||||||
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC = 0x13;//0x2;
|
|
||||||
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO = 0x14;//0x3;
|
|
||||||
GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE = 0x15;//0x4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Meshes
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Object.OBJECT_TYPE_MESH = 0x21;
|
|
|
@ -1,93 +0,0 @@
|
||||||
/**
|
|
||||||
* Bone Superset
|
|
||||||
* @param id
|
|
||||||
* @param name string
|
|
||||||
* @param childBoneIds
|
|
||||||
* @param parentBoneIds
|
|
||||||
* @param quaternion GameLib.API.Quaternion
|
|
||||||
* @param position GameLib.API.Vector3
|
|
||||||
* @param scale GameLib.API.Vector3
|
|
||||||
* @param up GameLib.API.Vector3
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Bone = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
childBoneIds,
|
|
||||||
parentBoneIds,
|
|
||||||
position,
|
|
||||||
quaternion,
|
|
||||||
scale,
|
|
||||||
up,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Bone (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(childBoneIds)) {
|
|
||||||
childBoneIds = [];
|
|
||||||
}
|
|
||||||
this.childBoneIds = childBoneIds;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentBoneIds)) {
|
|
||||||
parentBoneIds = [];
|
|
||||||
}
|
|
||||||
this.parentBoneIds = parentBoneIds;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.API.Vector3();
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(quaternion)) {
|
|
||||||
quaternion = new GameLib.API.Quaternion();
|
|
||||||
}
|
|
||||||
this.quaternion = quaternion;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scale)) {
|
|
||||||
scale = new GameLib.API.Vector3(1,1,1);
|
|
||||||
}
|
|
||||||
this.scale = scale;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(up)) {
|
|
||||||
up = new GameLib.API.Vector3(0,1,0);
|
|
||||||
}
|
|
||||||
this.up = up;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.BONE,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Bone.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Bone.prototype.constructor = GameLib.D3.API.Bone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an API bone from an Object bone
|
|
||||||
* @param objectBone
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Bone.FromObject = function(objectBone) {
|
|
||||||
return new GameLib.D3.API.Bone(
|
|
||||||
objectBone.id,
|
|
||||||
objectBone.name,
|
|
||||||
objectBone.childBoneIds,
|
|
||||||
objectBone.parentBoneIds,
|
|
||||||
GameLib.API.Vector3.FromObject(objectBone.position),
|
|
||||||
GameLib.API.Quaternion.FromObject(objectBone.quaternion),
|
|
||||||
GameLib.API.Vector3.FromObject(objectBone.scale),
|
|
||||||
GameLib.API.Vector3.FromObject(objectBone.up),
|
|
||||||
objectBone.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,52 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Camera
|
|
||||||
* @param apiD3Object
|
|
||||||
* @param aspect
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Camera = function(
|
|
||||||
apiD3Object,
|
|
||||||
aspect
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3Object)) {
|
|
||||||
apiD3Object = {
|
|
||||||
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3Object.objectType)) {
|
|
||||||
apiD3Object.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(aspect)) {
|
|
||||||
aspect = 1;
|
|
||||||
}
|
|
||||||
this.aspect = aspect;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3Object.position)) {
|
|
||||||
apiD3Object.position = new GameLib.API.Vector3(
|
|
||||||
15,
|
|
||||||
15,
|
|
||||||
15
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Object.call(
|
|
||||||
this,
|
|
||||||
apiD3Object.id,
|
|
||||||
apiD3Object.name,
|
|
||||||
apiD3Object.objectType,
|
|
||||||
apiD3Object.parentEntity,
|
|
||||||
apiD3Object.useQuaternion,
|
|
||||||
apiD3Object.position,
|
|
||||||
apiD3Object.quaternion,
|
|
||||||
apiD3Object.rotation,
|
|
||||||
apiD3Object.scale,
|
|
||||||
apiD3Object.up,
|
|
||||||
apiD3Object.lookAt
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.prototype = Object.create(GameLib.D3.API.Object.prototype);
|
|
||||||
GameLib.D3.API.Camera.prototype.constructor = GameLib.D3.API.Camera;
|
|
|
@ -1,59 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Camera.Cube
|
|
||||||
* @constructor
|
|
||||||
* @param apiD3ObjectCamera
|
|
||||||
* @param near
|
|
||||||
* @param far
|
|
||||||
* @param cubeResolution
|
|
||||||
* @param renderTarget
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Camera.Cube = function(
|
|
||||||
apiD3ObjectCamera,
|
|
||||||
near,
|
|
||||||
far,
|
|
||||||
cubeResolution,
|
|
||||||
renderTarget
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera)) {
|
|
||||||
apiD3ObjectCamera = {
|
|
||||||
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.objectType)) {
|
|
||||||
apiD3ObjectCamera.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(near)) {
|
|
||||||
near = 0.1;
|
|
||||||
}
|
|
||||||
this.near = near;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(far)) {
|
|
||||||
far = 2000;
|
|
||||||
}
|
|
||||||
this.far = far;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(cubeResolution)) {
|
|
||||||
cubeResolution = 128;
|
|
||||||
}
|
|
||||||
this.cubeResolution = cubeResolution;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(renderTarget)) {
|
|
||||||
renderTarget = null;
|
|
||||||
}
|
|
||||||
this.renderTarget = renderTarget;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CubeCamera's have hardcoded fov=90 and aspect=1
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Camera.call(
|
|
||||||
this,
|
|
||||||
apiD3ObjectCamera,
|
|
||||||
apiD3ObjectCamera.aspect
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Cube.prototype = Object.create(GameLib.D3.API.Camera.prototype);
|
|
||||||
GameLib.D3.API.Camera.Cube.prototype.constructor = GameLib.D3.API.Camera.Cube;
|
|
|
@ -1,84 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Camera.Perspective
|
|
||||||
* @constructor
|
|
||||||
* @param apiD3ObjectCamera
|
|
||||||
* @param fov
|
|
||||||
* @param near
|
|
||||||
* @param far
|
|
||||||
* @param filmGauge
|
|
||||||
* @param filmOffset
|
|
||||||
* @param focus
|
|
||||||
* @param zoom
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Camera.Perspective = function(
|
|
||||||
apiD3ObjectCamera,
|
|
||||||
near,
|
|
||||||
far,
|
|
||||||
fov,
|
|
||||||
filmGauge,
|
|
||||||
filmOffset,
|
|
||||||
focus,
|
|
||||||
zoom
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera)) {
|
|
||||||
apiD3ObjectCamera = {
|
|
||||||
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.objectType)) {
|
|
||||||
apiD3ObjectCamera.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(near)) {
|
|
||||||
// near = new GameLib.API.Number(0.1, 0.001, 0.001, 2000);
|
|
||||||
near = 0.1;
|
|
||||||
}
|
|
||||||
this.near = near;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(far)) {
|
|
||||||
// far = new GameLib.API.Number(2000, 1, 1, 4000);
|
|
||||||
far = 2000;
|
|
||||||
}
|
|
||||||
this.far = far;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(fov)) {
|
|
||||||
// fov = new GameLib.API.Number(50, 1, 0, 180);
|
|
||||||
fov = 50;
|
|
||||||
}
|
|
||||||
this.fov = fov;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(filmGauge)) {
|
|
||||||
// filmGauge = new GameLib.API.Number(35, 1, 0, 200);
|
|
||||||
filmGauge = 35;
|
|
||||||
}
|
|
||||||
this.filmGauge = filmGauge;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(filmOffset)) {
|
|
||||||
// filmOffset = new GameLib.API.Number(0, 1, 0, 200);
|
|
||||||
filmOffset = 0;
|
|
||||||
}
|
|
||||||
this.filmOffset = filmOffset;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(focus)) {
|
|
||||||
// focus = new GameLib.API.Number(10, 0.1, 0, 200);
|
|
||||||
focus = 10;
|
|
||||||
}
|
|
||||||
this.focus = focus;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(zoom)) {
|
|
||||||
// zoom = new GameLib.API.Number(1, 0.01, 0, 10);
|
|
||||||
zoom = 1;
|
|
||||||
}
|
|
||||||
this.zoom = zoom;
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.call(
|
|
||||||
this,
|
|
||||||
apiD3ObjectCamera,
|
|
||||||
apiD3ObjectCamera.aspect
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Perspective.prototype = Object.create(GameLib.D3.API.Camera.prototype);
|
|
||||||
GameLib.D3.API.Camera.Perspective.prototype.constructor = GameLib.D3.API.Camera.Perspective;
|
|
|
@ -1,40 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Camera.Stereo
|
|
||||||
* @constructor
|
|
||||||
* @param apiD3ObjectCamera
|
|
||||||
* @param stereoMode
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Camera.Stereo = function(
|
|
||||||
apiD3ObjectCamera,
|
|
||||||
stereoMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera)) {
|
|
||||||
apiD3ObjectCamera = {
|
|
||||||
objectType : GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiD3ObjectCamera.objectType)) {
|
|
||||||
apiD3ObjectCamera.objectType = GameLib.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(stereoMode)) {
|
|
||||||
stereoMode = GameLib.D3.API.Camera.Stereo.STEREO_MODE_STEREO;
|
|
||||||
}
|
|
||||||
this.stereoMode = stereoMode;
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.call(
|
|
||||||
this,
|
|
||||||
apiD3ObjectCamera,
|
|
||||||
apiD3ObjectCamera.aspect
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Stereo.prototype = Object.create(GameLib.D3.API.Camera.prototype);
|
|
||||||
GameLib.D3.API.Camera.Stereo.prototype.constructor = GameLib.D3.API.Camera.Stereo;
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Stereo.STEREO_MODE_STEREO = 0x1;
|
|
||||||
GameLib.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH = 0x2;
|
|
||||||
GameLib.D3.API.Camera.Stereo.STEREO_MODE_PARALLAX = 0x3;
|
|
|
@ -1,100 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Effect
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param effectType
|
|
||||||
* @param parentEntity
|
|
||||||
* @param renderer
|
|
||||||
* @param width
|
|
||||||
* @param height
|
|
||||||
*
|
|
||||||
* @property effectType
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Effect = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
effectType,
|
|
||||||
parentEntity,
|
|
||||||
renderer,
|
|
||||||
width,
|
|
||||||
height
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(effectType)) {
|
|
||||||
effectType = GameLib.D3.API.Effect.EFFECT_TYPE_NONE;
|
|
||||||
}
|
|
||||||
this.effectType = effectType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
switch (this.effectType) {
|
|
||||||
case GameLib.D3.API.Effect.EFFECT_TYPE_ANAGLYPH :
|
|
||||||
name = 'Effect Anaglyph';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Effect.EFFECT_TYPE_PARALLAX :
|
|
||||||
name = 'Effect Parallax';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Effect.EFFECT_TYPE_STEREO :
|
|
||||||
name = 'Effect Stereo';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('no nice name for effect');
|
|
||||||
name = 'Effect';
|
|
||||||
}
|
|
||||||
|
|
||||||
name += ' (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(renderer)) {
|
|
||||||
renderer = null;
|
|
||||||
}
|
|
||||||
this.renderer = renderer;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(width)) {
|
|
||||||
width = 512;
|
|
||||||
}
|
|
||||||
this.width = width;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
|
||||||
height = 512;
|
|
||||||
}
|
|
||||||
this.height = height;
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (this.effectType) {
|
|
||||||
case GameLib.D3.API.Effect.EFFECT_TYPE_STEREO :
|
|
||||||
componentType = GameLib.Component.EFFECT_STEREO;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Effect.EFFECT_TYPE_ANAGLYPH :
|
|
||||||
componentType = GameLib.Component.EFFECT_ANAGLYPH;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Effect.EFFECT_TYPE_PARALLAX :
|
|
||||||
componentType = GameLib.Component.EFFECT_PARALLAX;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error('unsupported effect type: ' + this.effectType);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Effect.prototype.constructor = GameLib.D3.API.Effect;
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.EFFECT_TYPE_NONE = 0x0;
|
|
||||||
GameLib.D3.API.Effect.EFFECT_TYPE_STEREO = 0x1;
|
|
||||||
GameLib.D3.API.Effect.EFFECT_TYPE_ANAGLYPH = 0x2;
|
|
||||||
GameLib.D3.API.Effect.EFFECT_TYPE_PARALLAX = 0x3;
|
|
|
@ -1,34 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Effect.Anaglyph
|
|
||||||
* @constructor
|
|
||||||
* @param apiEffect
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Effect.Anaglyph = function(
|
|
||||||
apiEffect
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiEffect)) {
|
|
||||||
apiEffect = {
|
|
||||||
effectType : GameLib.D3.API.Effect.EFFECT_TYPE_ANAGLYPH
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiEffect.cameraType)) {
|
|
||||||
apiEffect.effectType = GameLib.D3.API.Effect.EFFECT_TYPE_ANAGLYPH;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.call(
|
|
||||||
this,
|
|
||||||
apiEffect.id,
|
|
||||||
apiEffect.name,
|
|
||||||
apiEffect.effectType,
|
|
||||||
apiEffect.parentEntity,
|
|
||||||
apiEffect.renderer,
|
|
||||||
apiEffect.width,
|
|
||||||
apiEffect.height
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.Anaglyph.prototype = Object.create(GameLib.D3.API.Effect.prototype);
|
|
||||||
GameLib.D3.API.Effect.Anaglyph.prototype.constructor = GameLib.D3.API.Effect.Anaglyph;
|
|
|
@ -1,34 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Effect.Parallax
|
|
||||||
* @constructor
|
|
||||||
* @param apiEffect
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Effect.Parallax = function(
|
|
||||||
apiEffect
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiEffect)) {
|
|
||||||
apiEffect = {
|
|
||||||
effectType : GameLib.D3.API.Effect.EFFECT_TYPE_PARALLAX
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiEffect.cameraType)) {
|
|
||||||
apiEffect.effectType = GameLib.D3.API.Effect.EFFECT_TYPE_PARALLAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.call(
|
|
||||||
this,
|
|
||||||
apiEffect.id,
|
|
||||||
apiEffect.name,
|
|
||||||
apiEffect.effectType,
|
|
||||||
apiEffect.parentEntity,
|
|
||||||
apiEffect.renderer,
|
|
||||||
apiEffect.width,
|
|
||||||
apiEffect.height
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.Parallax.prototype = Object.create(GameLib.D3.API.Effect.prototype);
|
|
||||||
GameLib.D3.API.Effect.Parallax.prototype.constructor = GameLib.D3.API.Effect.Parallax;
|
|
|
@ -1,41 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Effect.Stereo
|
|
||||||
* @constructor
|
|
||||||
* @param apiEffect
|
|
||||||
* @param eyeSeperation
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Effect.Stereo = function(
|
|
||||||
apiEffect,
|
|
||||||
eyeSeperation
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiEffect)) {
|
|
||||||
apiEffect = {
|
|
||||||
effectType : GameLib.D3.API.Effect.EFFECT_TYPE_STEREO
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiEffect.cameraType)) {
|
|
||||||
apiEffect.effectType = GameLib.D3.API.Effect.EFFECT_TYPE_STEREO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(eyeSeperation)) {
|
|
||||||
eyeSeperation = 0.064;
|
|
||||||
}
|
|
||||||
this.eyeSeperation = eyeSeperation;
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.call(
|
|
||||||
this,
|
|
||||||
apiEffect.id,
|
|
||||||
apiEffect.name,
|
|
||||||
apiEffect.effectType,
|
|
||||||
apiEffect.parentEntity,
|
|
||||||
apiEffect.renderer,
|
|
||||||
apiEffect.width,
|
|
||||||
apiEffect.height
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.Stereo.prototype = Object.create(GameLib.D3.API.Effect.prototype);
|
|
||||||
GameLib.D3.API.Effect.Stereo.prototype.constructor = GameLib.D3.API.Effect.Stereo;
|
|
|
@ -1,413 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param geometryType
|
|
||||||
* @param parentEntity
|
|
||||||
* @param parentMesh
|
|
||||||
* @param boundingBox
|
|
||||||
* @param boundingSphere
|
|
||||||
* @param faces
|
|
||||||
* @param vertices
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
geometryType,
|
|
||||||
parentEntity,
|
|
||||||
parentMesh,
|
|
||||||
boundingBox,
|
|
||||||
boundingSphere,
|
|
||||||
faces,
|
|
||||||
vertices
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(geometryType)) {
|
|
||||||
geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NONE;
|
|
||||||
}
|
|
||||||
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_NORMAL_BOX :
|
|
||||||
name = 'Geometry Normal Box';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE :
|
|
||||||
name = 'Geometry Normal Circle';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE :
|
|
||||||
name = 'Geometry Normal Cone';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER :
|
|
||||||
name = 'Geometry Normal Cylinder';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON :
|
|
||||||
name = 'Geometry Normal Dodecahedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES :
|
|
||||||
name = 'Geometry Normal Edges';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE :
|
|
||||||
name = 'Geometry Normal Extrude';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON :
|
|
||||||
name = 'Geometry Normal Icosahedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE :
|
|
||||||
name = 'Geometry Normal Lathe';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON :
|
|
||||||
name = 'Geometry Normal Octahedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC :
|
|
||||||
name = 'Geometry Normal Parametric';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE :
|
|
||||||
name = 'Geometry Normal Plane';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON :
|
|
||||||
name = 'Geometry Normal Polyhedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING :
|
|
||||||
name = 'Geometry Normal Ring';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE :
|
|
||||||
name = 'Geometry Normal Shape';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE :
|
|
||||||
name = 'Geometry Normal Sphere';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON :
|
|
||||||
name = 'Geometry Normal Tetrahedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT :
|
|
||||||
name = 'Geometry Normal Text';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS :
|
|
||||||
name = 'Geometry Normal Torus';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT :
|
|
||||||
name = 'Geometry Normal Torus Knot';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE :
|
|
||||||
name = 'Geometry Normal Tube';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME :
|
|
||||||
name = 'Geometry Normal Wireframe';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER :
|
|
||||||
name = 'Geometry Buffer';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX :
|
|
||||||
name = 'Geometry Buffer Box';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE :
|
|
||||||
name = 'Geometry Buffer Circle';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE :
|
|
||||||
name = 'Geometry Buffer Cone';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER :
|
|
||||||
name = 'Geometry Buffer Cylinder';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON :
|
|
||||||
name = 'Geometry Buffer Dodecahedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE :
|
|
||||||
name = 'Geometry Buffer Extrude';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON :
|
|
||||||
name = 'Geometry Buffer Icosahedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE :
|
|
||||||
name = 'Geometry Buffer Lathe';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON :
|
|
||||||
name = 'Geometry Buffer Octahedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC :
|
|
||||||
name = 'Geometry Buffer Parametric';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE :
|
|
||||||
name = 'Geometry Buffer Plane';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON :
|
|
||||||
name = 'Geometry Buffer Polyhedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING :
|
|
||||||
name = 'Geometry Buffer Ring';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE :
|
|
||||||
name = 'Geometry Buffer Shape';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE :
|
|
||||||
name = 'Geometry Buffer Sphere';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON :
|
|
||||||
name = 'Geometry Buffer Tetrahedron';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT :
|
|
||||||
name = 'Geometry Buffer Text';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS :
|
|
||||||
name = 'Geometry Buffer Torus';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT :
|
|
||||||
name = 'Geometry Buffer Torus Knot';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE :
|
|
||||||
name = 'Geometry Buffer Tube';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_INSTANCED :
|
|
||||||
name = 'Geometry Buffer Instanced';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('no nice name for geometry');
|
|
||||||
name = 'Geometry';
|
|
||||||
}
|
|
||||||
|
|
||||||
name += ' (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
|
|
||||||
parentMesh = null;
|
|
||||||
}
|
|
||||||
this.parentMesh = parentMesh;
|
|
||||||
|
|
||||||
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(faces)) {
|
|
||||||
faces = [];
|
|
||||||
}
|
|
||||||
this.faces = faces;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(vertices)) {
|
|
||||||
vertices = [];
|
|
||||||
}
|
|
||||||
this.vertices = vertices;
|
|
||||||
|
|
||||||
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_NORMAL;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_BOX :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_BOX;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_CIRCLE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_CONE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_CYLINDER;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_DODECAHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_EDGES;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_EXTRUDE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_ICOSAHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_LATHE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_OCTAHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_PARAMETRIC;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_PLANE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_POLYHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_RING;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_SHAPE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_SPHERE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_TETRAHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_TEXT;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_TORUS;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_TORUS_KNOT;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_TUBE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_NORMAL_WIREFRAME;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_BOX;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_CIRCLE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_CONE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_CYLINDER;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_DODECAHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_EXTRUDE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_ICOSAHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_LATHE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_OCTAHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC:
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_PARAMETRIC;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_PLANE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_POLYHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING:
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_RING;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_SHAPE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_SPHERE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_TETRAHEDRON;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_TEXT;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_TORUS;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_TORUS_KNOT;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_TUBE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_INSTANCED :
|
|
||||||
componentType = GameLib.Component.GEOMETRY_BUFFER_INSTANCED;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error('unhandled geometry type: ' + geometryType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Geometry Type
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NONE = 0x0;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL = 0x1;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_BOX = 0x2;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE = 0x3;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE = 0x4;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER = 0x5;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON = 0x6;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES = 0x7;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE = 0x8;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON = 0x9;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE = 0xa;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON = 0xb;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC = 0xc;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE = 0xd;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON = 0xe;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING = 0xf;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE = 0x10;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE = 0x11;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON = 0x12;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT = 0x13;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS = 0x14;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT = 0x15;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE = 0x16;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME = 0x17;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER = 0x18;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX = 0x19;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE = 0x1a;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE = 0x1b;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER = 0x1c;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON = 0x1d;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE = 0x1e;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON = 0x1f;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE = 0x20;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON = 0x21;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC = 0x22;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE = 0x23;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON = 0x24;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING = 0x25;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE = 0x26;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE = 0x27;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON = 0x28;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT = 0x29;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS = 0x2a;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT = 0x2b;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE = 0x2c;
|
|
||||||
GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_INSTANCED = 0x2d;
|
|
|
@ -1,74 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Box
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param width
|
|
||||||
* @param height
|
|
||||||
* @param depth
|
|
||||||
* @param widthSegments
|
|
||||||
* @param heightSegments
|
|
||||||
* @param depthSegments
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Box = function(
|
|
||||||
apiGeometry,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
depth,
|
|
||||||
widthSegments,
|
|
||||||
heightSegments,
|
|
||||||
depthSegments
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Box.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Box.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Box;
|
|
|
@ -1,60 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Circle
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param radius
|
|
||||||
* @param segments
|
|
||||||
* @param thetaStart
|
|
||||||
* @param thetaLength
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Circle = function(
|
|
||||||
apiGeometry,
|
|
||||||
radius,
|
|
||||||
segments,
|
|
||||||
thetaStart,
|
|
||||||
thetaLength
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Circle.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Circle.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Circle;
|
|
|
@ -1,46 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Dodecahedron
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param radius
|
|
||||||
* @param detail
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Dodecahedron = function(
|
|
||||||
apiGeometry,
|
|
||||||
radius,
|
|
||||||
detail
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Dodecahedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Dodecahedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Dodecahedron;
|
|
|
@ -1,46 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Icosahedron
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param radius
|
|
||||||
* @param detail
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Icosahedron = function(
|
|
||||||
apiGeometry,
|
|
||||||
radius,
|
|
||||||
detail
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Icosahedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Icosahedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Icosahedron;
|
|
|
@ -1,39 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Instanced
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param maxInstancedCount
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Instanced = function(
|
|
||||||
apiGeometry,
|
|
||||||
maxInstancedCount
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_INSTANCED
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_INSTANCED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(maxInstancedCount)) {
|
|
||||||
maxInstancedCount = null;
|
|
||||||
}
|
|
||||||
this.maxInstancedCount = maxInstancedCount;
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Instanced.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Instanced.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Instanced;
|
|
|
@ -1,60 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Lathe
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param points [GameLib.Vector2] (x must be larger than 0)
|
|
||||||
* @param segments
|
|
||||||
* @param phiStart
|
|
||||||
* @param phiLength
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Lathe = function(
|
|
||||||
apiGeometry,
|
|
||||||
points,
|
|
||||||
segments,
|
|
||||||
phiStart,
|
|
||||||
phiLength
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Lathe.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Lathe.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Lathe;
|
|
|
@ -1,46 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Octahedron
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param radius
|
|
||||||
* @param detail
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Octahedron = function(
|
|
||||||
apiGeometry,
|
|
||||||
radius,
|
|
||||||
detail
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Octahedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Octahedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Octahedron;
|
|
|
@ -1,53 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.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.Buffer.Parametric = function(
|
|
||||||
apiGeometry,
|
|
||||||
generatorFn,
|
|
||||||
slices,
|
|
||||||
stacks
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Parametric.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Parametric.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Parametric;
|
|
|
@ -1,60 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Plane
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param width
|
|
||||||
* @param height
|
|
||||||
* @param widthSegments
|
|
||||||
* @param heightSegments
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Plane = function(
|
|
||||||
apiGeometry,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
widthSegments,
|
|
||||||
heightSegments
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Plane.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Plane.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Plane;
|
|
|
@ -1,60 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Polyhedron
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param vertices
|
|
||||||
* @param indices
|
|
||||||
* @param radius
|
|
||||||
* @param detail
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Polyhedron = function(
|
|
||||||
apiGeometry,
|
|
||||||
vertices,
|
|
||||||
indices,
|
|
||||||
radius,
|
|
||||||
detail
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Polyhedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Polyhedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Polyhedron;
|
|
|
@ -1,46 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Shape
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param shapes
|
|
||||||
* @param curveSegments
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Shape = function(
|
|
||||||
apiGeometry,
|
|
||||||
shapes,
|
|
||||||
curveSegments
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(shapes)) {
|
|
||||||
shapes = [];
|
|
||||||
}
|
|
||||||
this.shapes = shapes;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(curveSegments)) {
|
|
||||||
curveSegments = 12;
|
|
||||||
}
|
|
||||||
this.curveSegments = curveSegments;
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Shape.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Shape.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Shape;
|
|
|
@ -1,46 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Tetrahedron
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param radius
|
|
||||||
* @param detail
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Tetrahedron = function(
|
|
||||||
apiGeometry,
|
|
||||||
radius,
|
|
||||||
detail
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Tetrahedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Tetrahedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Tetrahedron;
|
|
|
@ -1,74 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.TorusKnot
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param radius
|
|
||||||
* @param tube
|
|
||||||
* @param radialSegments
|
|
||||||
* @param tubularSegments
|
|
||||||
* @param p
|
|
||||||
* @param q
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.TorusKnot = function(
|
|
||||||
apiGeometry,
|
|
||||||
radius,
|
|
||||||
tube,
|
|
||||||
radialSegments,
|
|
||||||
tubularSegments,
|
|
||||||
p,
|
|
||||||
q
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.TorusKnot.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.TorusKnot.prototype.constructor = GameLib.D3.API.Geometry.Buffer.TorusKnot;
|
|
|
@ -1,67 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Torus
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param radius
|
|
||||||
* @param tube
|
|
||||||
* @param radialSegments
|
|
||||||
* @param tubularSegments
|
|
||||||
* @param arc
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Torus = function(
|
|
||||||
apiGeometry,
|
|
||||||
radius,
|
|
||||||
tube,
|
|
||||||
radialSegments,
|
|
||||||
tubularSegments,
|
|
||||||
arc
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Torus.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Torus.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Torus;
|
|
|
@ -1,67 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Geometry.Buffer.Tube
|
|
||||||
* @param apiGeometry
|
|
||||||
* @param path
|
|
||||||
* @param tubularSegments
|
|
||||||
* @param radius
|
|
||||||
* @param radialSegments
|
|
||||||
* @param closed
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Tube = function(
|
|
||||||
apiGeometry,
|
|
||||||
path,
|
|
||||||
tubularSegments,
|
|
||||||
radius,
|
|
||||||
radialSegments,
|
|
||||||
closed
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
|
|
||||||
apiGeometry = {
|
|
||||||
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
|
|
||||||
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_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.Buffer.call(
|
|
||||||
this,
|
|
||||||
apiGeometry,
|
|
||||||
apiGeometry.attributes,
|
|
||||||
apiGeometry.drawRange,
|
|
||||||
apiGeometry.groups,
|
|
||||||
apiGeometry.index,
|
|
||||||
apiGeometry.morphAttributes
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Tube.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Tube.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Tube;
|
|
|
@ -1,127 +0,0 @@
|
||||||
/**
|
|
||||||
* Raw Light API object - should always correspond with the Light Schema
|
|
||||||
* @param id
|
|
||||||
* @param lightType
|
|
||||||
* @param name
|
|
||||||
* @param color
|
|
||||||
* @param intensity
|
|
||||||
* @param parentScene
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Light = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
lightType,
|
|
||||||
color,
|
|
||||||
intensity,
|
|
||||||
parentScene,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(lightType)) {
|
|
||||||
lightType = GameLib.D3.API.Light.LIGHT_TYPE_AMBIENT;
|
|
||||||
}
|
|
||||||
this.lightType = lightType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
switch (this.lightType) {
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_SPOT :
|
|
||||||
name = 'Light Spot';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_RECT_AREA :
|
|
||||||
name = 'Light RectArea';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_POINT :
|
|
||||||
name = 'Light Point';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_DIRECTIONAL :
|
|
||||||
name = 'Light Directional';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_HEMISPHERE :
|
|
||||||
name = 'Light Hemisphere';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_AMBIENT :
|
|
||||||
name = 'Light Ambient';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('no nice name for light');
|
|
||||||
name = 'Light';
|
|
||||||
}
|
|
||||||
|
|
||||||
name += ' (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(color)) {
|
|
||||||
color = new GameLib.API.Color(1,1,1);
|
|
||||||
}
|
|
||||||
this.color = color;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(intensity)) {
|
|
||||||
intensity = 1;
|
|
||||||
}
|
|
||||||
this.intensity = intensity;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentScene)) {
|
|
||||||
parentScene = null;
|
|
||||||
}
|
|
||||||
this.parentScene = parentScene;
|
|
||||||
|
|
||||||
var componentType = GameLib.D3.API.Light.GetComponentType(this.lightType);
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Light.GetComponentType = function(lightType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (lightType) {
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_AMBIENT :
|
|
||||||
componentType = GameLib.Component.LIGHT_AMBIENT;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_DIRECTIONAL :
|
|
||||||
componentType = GameLib.Component.LIGHT_DIRECTIONAL;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_POINT :
|
|
||||||
componentType = GameLib.Component.LIGHT_POINT;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_SPOT :
|
|
||||||
componentType = GameLib.Component.LIGHT_SPOT;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_HEMISPHERE :
|
|
||||||
componentType = GameLib.Component.LIGHT_HEMISPHERE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Light.LIGHT_TYPE_RECT_AREA :
|
|
||||||
componentType = GameLib.Component.LIGHT_RECT_AREA;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.error('could not determine light component type');
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Light.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Light.prototype.constructor = GameLib.D3.API.Light;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Light Types
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Light.LIGHT_TYPE_AMBIENT = 0x1;
|
|
||||||
GameLib.D3.API.Light.LIGHT_TYPE_DIRECTIONAL = 0x2;
|
|
||||||
GameLib.D3.API.Light.LIGHT_TYPE_POINT = 0x3;
|
|
||||||
GameLib.D3.API.Light.LIGHT_TYPE_SPOT = 0x4;
|
|
||||||
GameLib.D3.API.Light.LIGHT_TYPE_HEMISPHERE = 0x5;
|
|
||||||
GameLib.D3.API.Light.LIGHT_TYPE_RECT_AREA = 0x6;
|
|
|
@ -1,33 +0,0 @@
|
||||||
/**
|
|
||||||
* Raw Light API object - should always correspond with the Light Schema
|
|
||||||
* @constructor
|
|
||||||
* @param apiLight
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Light.Ambient = function(
|
|
||||||
apiLight
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiLight)) {
|
|
||||||
apiLight = {
|
|
||||||
lightType : GameLib.D3.API.Light.LIGHT_TYPE_AMBIENT
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiLight.lightType)) {
|
|
||||||
apiLight.lightType = GameLib.D3.API.Light.LIGHT_TYPE_AMBIENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Light.call(
|
|
||||||
this,
|
|
||||||
apiLight.id,
|
|
||||||
apiLight.name,
|
|
||||||
apiLight.lightType,
|
|
||||||
apiLight.color,
|
|
||||||
apiLight.intensity,
|
|
||||||
apiLight.parentScene,
|
|
||||||
apiLight.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Light.Ambient.prototype = Object.create(GameLib.D3.API.Light.prototype);
|
|
||||||
GameLib.D3.API.Light.Ambient.prototype.constructor = GameLib.D3.API.Light.Ambient;
|
|
|
@ -1,50 +0,0 @@
|
||||||
/**
|
|
||||||
* Raw Light API object - should always correspond with the Light Schema
|
|
||||||
* @constructor
|
|
||||||
* @param apiLight
|
|
||||||
* @param position
|
|
||||||
* @param groundColor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Light.Hemisphere = function(
|
|
||||||
apiLight,
|
|
||||||
position,
|
|
||||||
groundColor
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiLight)) {
|
|
||||||
apiLight = {
|
|
||||||
lightType : GameLib.D3.API.Light.LIGHT_TYPE_HEMISPHERE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiLight.lightType)) {
|
|
||||||
apiLight.lightType = GameLib.D3.API.Light.LIGHT_TYPE_HEMISPHERE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Light shines from the top
|
|
||||||
*/
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.API.Vector3(0,1,0);
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(groundColor)) {
|
|
||||||
groundColor = new GameLib.API.Color(1,1,1);
|
|
||||||
}
|
|
||||||
this.groundColor = groundColor;
|
|
||||||
|
|
||||||
GameLib.D3.API.Light.call(
|
|
||||||
this,
|
|
||||||
apiLight.id,
|
|
||||||
apiLight.name,
|
|
||||||
apiLight.lightType,
|
|
||||||
apiLight.color,
|
|
||||||
apiLight.intensity,
|
|
||||||
apiLight.parentScene,
|
|
||||||
apiLight.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Light.Hemisphere.prototype = Object.create(GameLib.D3.API.Light.prototype);
|
|
||||||
GameLib.D3.API.Light.Hemisphere.prototype.constructor = GameLib.D3.API.Light.Hemisphere;
|
|
|
@ -1,464 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Material
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param materialType
|
|
||||||
* @param parentEntity
|
|
||||||
* @param parentMeshes
|
|
||||||
* @param alphaTest
|
|
||||||
* @param blendDst
|
|
||||||
* @param blendDstAlpha
|
|
||||||
* @param blendEquation
|
|
||||||
* @param blendEquationAlpha
|
|
||||||
* @param blending
|
|
||||||
* @param blendSrc
|
|
||||||
* @param blendSrcAlpha
|
|
||||||
* @param clipIntersection
|
|
||||||
* @param clippingPlanes
|
|
||||||
* @param clipShadows
|
|
||||||
* @param colorWrite
|
|
||||||
* @param customDepthMaterial
|
|
||||||
* @param customDistanceMaterial
|
|
||||||
* @param defines
|
|
||||||
* @param depthFunc
|
|
||||||
* @param depthTest
|
|
||||||
* @param depthWrite
|
|
||||||
* @param fog
|
|
||||||
* @param lights
|
|
||||||
* @param opacity
|
|
||||||
* @param overdraw
|
|
||||||
* @param polygonOffset
|
|
||||||
* @param polygonOffsetFactor
|
|
||||||
* @param polygonOffsetUnits
|
|
||||||
* @param precision
|
|
||||||
* @param premultipliedAlpha
|
|
||||||
* @param dithering
|
|
||||||
* @param flatShading
|
|
||||||
* @param side
|
|
||||||
* @param transparent
|
|
||||||
* @param vertexColors
|
|
||||||
* @param visible
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
materialType,
|
|
||||||
parentEntity,
|
|
||||||
parentMeshes,
|
|
||||||
alphaTest,
|
|
||||||
blendDst,
|
|
||||||
blendDstAlpha,
|
|
||||||
blendEquation,
|
|
||||||
blendEquationAlpha,
|
|
||||||
blending,
|
|
||||||
blendSrc,
|
|
||||||
blendSrcAlpha,
|
|
||||||
clipIntersection,
|
|
||||||
clippingPlanes,
|
|
||||||
clipShadows,
|
|
||||||
colorWrite,
|
|
||||||
customDepthMaterial,
|
|
||||||
customDistanceMaterial,
|
|
||||||
defines,
|
|
||||||
depthFunc,
|
|
||||||
depthTest,
|
|
||||||
depthWrite,
|
|
||||||
fog,
|
|
||||||
lights,
|
|
||||||
opacity,
|
|
||||||
overdraw,
|
|
||||||
polygonOffset,
|
|
||||||
polygonOffsetFactor,
|
|
||||||
polygonOffsetUnits,
|
|
||||||
precision,
|
|
||||||
premultipliedAlpha,
|
|
||||||
dithering,
|
|
||||||
flatShading,
|
|
||||||
side,
|
|
||||||
transparent,
|
|
||||||
vertexColors,
|
|
||||||
visible
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(materialType)) {
|
|
||||||
materialType = GameLib.D3.API.Material.MATERIAL_TYPE_NONE;
|
|
||||||
}
|
|
||||||
this.materialType = materialType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
switch (this.materialType) {
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_BASIC :
|
|
||||||
name = 'Material Basic';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD :
|
|
||||||
name = 'Material Standard';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_PHONG :
|
|
||||||
name = 'Material Phong';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER :
|
|
||||||
name = 'Material Shader';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW :
|
|
||||||
name = 'Material Shader Raw';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_POINTS :
|
|
||||||
name = 'Material Points';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('no nice name for material');
|
|
||||||
name = 'Material';
|
|
||||||
}
|
|
||||||
|
|
||||||
name += ' (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentMeshes)) {
|
|
||||||
parentMeshes = [];
|
|
||||||
}
|
|
||||||
this.parentMeshes = parentMeshes;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(alphaTest)) {
|
|
||||||
alphaTest = 0;
|
|
||||||
}
|
|
||||||
this.alphaTest = alphaTest;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(blendDst)) {
|
|
||||||
blendDst = GameLib.D3.API.Material.TYPE_ONE_MINUS_SRC_ALPHA_FACTOR;
|
|
||||||
}
|
|
||||||
this.blendDst = blendDst;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(blendDstAlpha)) {
|
|
||||||
blendDstAlpha = null;
|
|
||||||
}
|
|
||||||
this.blendDstAlpha = blendDstAlpha;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(blendEquation)) {
|
|
||||||
blendEquation = GameLib.D3.API.Material.TYPE_ADD_EQUATION;
|
|
||||||
}
|
|
||||||
this.blendEquation = blendEquation;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(blendEquationAlpha)) {
|
|
||||||
blendEquationAlpha = null;
|
|
||||||
}
|
|
||||||
this.blendEquationAlpha = blendEquationAlpha;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(blending)) {
|
|
||||||
blending = GameLib.D3.API.Material.TYPE_NORMAL_BLENDING;
|
|
||||||
}
|
|
||||||
this.blending = blending;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(blendSrc)) {
|
|
||||||
blendSrc = GameLib.D3.API.Material.TYPE_SRC_ALPHA_FACTOR;
|
|
||||||
}
|
|
||||||
this.blendSrc = blendSrc;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(blendSrcAlpha)) {
|
|
||||||
blendSrcAlpha = null;
|
|
||||||
}
|
|
||||||
this.blendSrcAlpha = blendSrcAlpha;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(clipIntersection)) {
|
|
||||||
clipIntersection = false;
|
|
||||||
}
|
|
||||||
this.clipIntersection = clipIntersection;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(clippingPlanes)) {
|
|
||||||
clippingPlanes = [];
|
|
||||||
}
|
|
||||||
this.clippingPlanes = clippingPlanes;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(clipShadows)) {
|
|
||||||
clipShadows = false;
|
|
||||||
}
|
|
||||||
this.clipShadows = clipShadows;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(colorWrite)) {
|
|
||||||
colorWrite = true;
|
|
||||||
}
|
|
||||||
this.colorWrite = colorWrite;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(customDepthMaterial)) {
|
|
||||||
customDepthMaterial = null;
|
|
||||||
}
|
|
||||||
this.customDepthMaterial = customDepthMaterial;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(customDistanceMaterial)) {
|
|
||||||
customDistanceMaterial = null;
|
|
||||||
}
|
|
||||||
this.customDistanceMaterial = customDistanceMaterial;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(defines)) {
|
|
||||||
defines = null;
|
|
||||||
}
|
|
||||||
this.defines = defines;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(depthFunc)) {
|
|
||||||
depthFunc = GameLib.D3.API.Material.TYPE_LESS_EQUAL_DEPTH;
|
|
||||||
}
|
|
||||||
this.depthFunc = depthFunc;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(depthTest)) {
|
|
||||||
depthTest = true;
|
|
||||||
}
|
|
||||||
this.depthTest = depthTest;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(depthWrite)) {
|
|
||||||
depthWrite = true;
|
|
||||||
}
|
|
||||||
this.depthWrite = depthWrite;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(fog)) {
|
|
||||||
fog = true;
|
|
||||||
}
|
|
||||||
this.fog = fog;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(lights)) {
|
|
||||||
|
|
||||||
if (
|
|
||||||
this.materialType === GameLib.D3.API.Material.MATERIAL_TYPE_BASIC ||
|
|
||||||
this.materialType === GameLib.D3.API.Material.MATERIAL_TYPE_SHADER ||
|
|
||||||
this.materialType === GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW ||
|
|
||||||
this.materialType === GameLib.D3.API.Material.MATERIAL_TYPE_POINTS
|
|
||||||
) {
|
|
||||||
lights = false;
|
|
||||||
} else {
|
|
||||||
lights = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.lights = lights;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(opacity)) {
|
|
||||||
opacity = 1.0;
|
|
||||||
}
|
|
||||||
this.opacity = opacity;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(overdraw)) {
|
|
||||||
overdraw = 0;
|
|
||||||
}
|
|
||||||
this.overdraw = overdraw;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(polygonOffset)) {
|
|
||||||
polygonOffset = false;
|
|
||||||
}
|
|
||||||
this.polygonOffset = polygonOffset;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(polygonOffsetFactor)) {
|
|
||||||
polygonOffsetFactor = 0;
|
|
||||||
}
|
|
||||||
this.polygonOffsetFactor = polygonOffsetFactor;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(polygonOffsetUnits)) {
|
|
||||||
polygonOffsetUnits = 0;
|
|
||||||
}
|
|
||||||
this.polygonOffsetUnits = polygonOffsetUnits;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(precision)) {
|
|
||||||
precision = null;
|
|
||||||
}
|
|
||||||
this.precision = precision;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(premultipliedAlpha)) {
|
|
||||||
premultipliedAlpha = false;
|
|
||||||
}
|
|
||||||
this.premultipliedAlpha = premultipliedAlpha;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(dithering)) {
|
|
||||||
dithering = false;
|
|
||||||
}
|
|
||||||
this.dithering = dithering;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(flatShading)) {
|
|
||||||
flatShading = false;
|
|
||||||
}
|
|
||||||
this.flatShading = flatShading;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(side)) {
|
|
||||||
side = GameLib.D3.API.Material.TYPE_FRONT_SIDE;
|
|
||||||
}
|
|
||||||
this.side = side;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(transparent)) {
|
|
||||||
transparent = false;
|
|
||||||
}
|
|
||||||
this.transparent = transparent;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(vertexColors)) {
|
|
||||||
vertexColors = GameLib.D3.API.Material.TYPE_NO_COLORS;
|
|
||||||
}
|
|
||||||
this.vertexColors = vertexColors;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(visible)) {
|
|
||||||
visible = true;
|
|
||||||
}
|
|
||||||
this.visible = visible;
|
|
||||||
|
|
||||||
var componentType = GameLib.D3.API.Material.GetComponentType(this.materialType);
|
|
||||||
|
|
||||||
this.needsUpdate = false;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Material.GetComponentType = function(materialType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (materialType) {
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD :
|
|
||||||
componentType = GameLib.Component.MATERIAL_STANDARD;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_BASIC :
|
|
||||||
componentType = GameLib.Component.MATERIAL_BASIC;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_PHONG :
|
|
||||||
componentType = GameLib.Component.MATERIAL_PHONG;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER :
|
|
||||||
componentType = GameLib.Component.MATERIAL_SHADER;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW :
|
|
||||||
componentType = GameLib.Component.MATERIAL_SHADER_RAW;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_POINTS :
|
|
||||||
componentType = GameLib.Component.MATERIAL_POINTS;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
throw new Error('unhandled material type: ' + materialType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Material.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Material.prototype.constructor = GameLib.D3.API.Material;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Combine Method
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.COMBINE_MULTIPLY_OPERATION = 0;
|
|
||||||
GameLib.D3.API.Material.COMBINE_MIX_OPERATION = 1;
|
|
||||||
GameLib.D3.API.Material.COMBINE_ADD_OPERATION = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vertex Color Mode
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.TYPE_NO_COLORS = 0;
|
|
||||||
GameLib.D3.API.Material.TYPE_FACE_COLORS = 1;
|
|
||||||
GameLib.D3.API.Material.TYPE_VERTEX_COLORS = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Blending Mode
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.TYPE_NO_BLENDING = 0;
|
|
||||||
GameLib.D3.API.Material.TYPE_NORMAL_BLENDING = 1;
|
|
||||||
GameLib.D3.API.Material.TYPE_ADDITIVE_BLENDING = 2;
|
|
||||||
GameLib.D3.API.Material.TYPE_SUBTRACTIVE_BLENDING = 3;
|
|
||||||
GameLib.D3.API.Material.TYPE_MULTIPLY_BLENDING = 4;
|
|
||||||
GameLib.D3.API.Material.TYPE_CUSTOM_BLENDING = 5;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Blend Source and Destination
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.TYPE_ZERO_FACTOR = 200;
|
|
||||||
GameLib.D3.API.Material.TYPE_ONE_FACTOR = 201;
|
|
||||||
GameLib.D3.API.Material.TYPE_SRC_COLOR_FACTOR = 202;
|
|
||||||
GameLib.D3.API.Material.TYPE_ONE_MINUS_SRC_COLOR_FACTOR = 203;
|
|
||||||
GameLib.D3.API.Material.TYPE_SRC_ALPHA_FACTOR = 204;
|
|
||||||
GameLib.D3.API.Material.TYPE_ONE_MINUS_SRC_ALPHA_FACTOR = 205;
|
|
||||||
GameLib.D3.API.Material.TYPE_DST_ALPHA_FACTOR = 206;
|
|
||||||
GameLib.D3.API.Material.TYPE_ONE_MINUS_DST_ALPHA_FACTOR = 207;
|
|
||||||
GameLib.D3.API.Material.TYPE_DST_COLOR_FACTOR = 208;
|
|
||||||
GameLib.D3.API.Material.TYPE_ONE_MINUS_DST_COLOR_FACTOR = 209;
|
|
||||||
GameLib.D3.API.Material.TYPE_SRC_ALPHA_SATURATE_FACTOR = 210;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Blend Operation
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.TYPE_ADD_EQUATION = 100;
|
|
||||||
GameLib.D3.API.Material.TYPE_SUBTRACT_EQUATION = 101;
|
|
||||||
GameLib.D3.API.Material.TYPE_REVERSE_SUBTRACT_EQUATION = 102;
|
|
||||||
GameLib.D3.API.Material.TYPE_MIN_EQUATION = 103;
|
|
||||||
GameLib.D3.API.Material.TYPE_MAX_EQUATION = 104;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Depth Function
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.TYPE_NEVER_DEPTH = 0;
|
|
||||||
GameLib.D3.API.Material.TYPE_ALWAYS_DEPTH = 1;
|
|
||||||
GameLib.D3.API.Material.TYPE_LESS_DEPTH = 2;
|
|
||||||
GameLib.D3.API.Material.TYPE_LESS_EQUAL_DEPTH = 3;
|
|
||||||
GameLib.D3.API.Material.TYPE_EQUAL_DEPTH = 4;
|
|
||||||
GameLib.D3.API.Material.TYPE_GREATER_EQUAL_DEPTH = 5;
|
|
||||||
GameLib.D3.API.Material.TYPE_GREATER_DEPTH = 6;
|
|
||||||
GameLib.D3.API.Material.TYPE_NOT_EQUAL_DEPTH = 7;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Culling Mode
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.TYPE_FRONT_SIDE = 0;
|
|
||||||
GameLib.D3.API.Material.TYPE_BACK_SIDE = 1;
|
|
||||||
GameLib.D3.API.Material.TYPE_DOUBLE_SIDE = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shading Type
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.TYPE_FLAT_SHADING = 1;
|
|
||||||
GameLib.D3.API.Material.TYPE_SMOOTH_SHADING = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Material Type
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_NONE = 0x0;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_LINE_BASIC = 0x1;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_LINE_DASHED = 0x2;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_BASIC = 0x3;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_DEPTH = 0x4;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_LAMBERT = 0x5;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_NORMAL = 0x6;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_PHONG = 0x7;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD = 0x8;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_POINTS = 0x9;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_SPRITE = 0xa;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_TOON = 0xb;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_SHADER = 0xc;
|
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW = 0xd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Line Cap
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.LINE_CAP_BUTT = 0x1;//'butt';
|
|
||||||
GameLib.D3.API.Material.LINE_CAP_ROUND = 0x2;//'round';
|
|
||||||
GameLib.D3.API.Material.LINE_CAP_SQUARE = 0x3;//'square';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Line Join
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Material.LINE_JOIN_ROUND = 0x1;//'round';
|
|
||||||
GameLib.D3.API.Material.LINE_JOIN_BEVEL = 0x2;//'bevel';
|
|
||||||
GameLib.D3.API.Material.LINE_JOIN_MITER = 0x3;//'miter';
|
|
|
@ -1,229 +0,0 @@
|
||||||
/**
|
|
||||||
* Raw Particle API object - should always correspond with the Particle Schema
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param lifeTime
|
|
||||||
* @param elapsed
|
|
||||||
* @param mesh
|
|
||||||
* @param opacityType
|
|
||||||
* @param fadeInFactor
|
|
||||||
* @param fadeOutFactor
|
|
||||||
* @param fadeInAfter
|
|
||||||
* @param fadeOutAfter
|
|
||||||
* @param positionOffsetType
|
|
||||||
* @param positionOffset
|
|
||||||
* @param positionOffsetFn
|
|
||||||
* @param directionType
|
|
||||||
* @param rotation
|
|
||||||
* @param scale
|
|
||||||
* @param direction
|
|
||||||
* @param directionFn
|
|
||||||
* @param speedType
|
|
||||||
* @param speed
|
|
||||||
* @param scaleFn
|
|
||||||
* @param scaleType
|
|
||||||
* @param rotationType
|
|
||||||
* @param rotationFn
|
|
||||||
* @param parentParticleEngine
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Particle = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
lifeTime,
|
|
||||||
elapsed,
|
|
||||||
mesh,
|
|
||||||
opacityType,
|
|
||||||
fadeInFactor,
|
|
||||||
fadeOutFactor,
|
|
||||||
fadeInAfter,
|
|
||||||
fadeOutAfter,
|
|
||||||
positionOffsetType,
|
|
||||||
positionOffset,
|
|
||||||
positionOffsetFn,
|
|
||||||
directionType,
|
|
||||||
direction,
|
|
||||||
directionFn,
|
|
||||||
speedType,
|
|
||||||
speed,
|
|
||||||
scaleType,
|
|
||||||
scale,
|
|
||||||
scaleFn,
|
|
||||||
rotationType,
|
|
||||||
rotation,
|
|
||||||
rotationFn,
|
|
||||||
parentParticleEngine,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Particle (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(lifeTime)) {
|
|
||||||
lifeTime = 10;
|
|
||||||
}
|
|
||||||
this.lifeTime = lifeTime;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(elapsed)) {
|
|
||||||
elapsed = 0;
|
|
||||||
}
|
|
||||||
this.elapsed = elapsed;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(mesh)) {
|
|
||||||
mesh = null;
|
|
||||||
}
|
|
||||||
this.mesh = mesh;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(opacityType)) {
|
|
||||||
opacityType = GameLib.D3.API.Particle.OPACITY_TYPE_CONSTANT;
|
|
||||||
}
|
|
||||||
this.opacityType = opacityType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(fadeInFactor)) {
|
|
||||||
fadeInFactor = 0.01;
|
|
||||||
}
|
|
||||||
this.fadeInFactor = fadeInFactor;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(fadeOutFactor)) {
|
|
||||||
fadeOutFactor = 0.01;
|
|
||||||
}
|
|
||||||
this.fadeOutFactor = fadeOutFactor;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(fadeInAfter)) {
|
|
||||||
fadeInAfter = 0;
|
|
||||||
}
|
|
||||||
this.fadeInAfter = fadeInAfter;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(fadeOutAfter)) {
|
|
||||||
fadeOutAfter = 0;
|
|
||||||
}
|
|
||||||
this.fadeOutAfter = fadeOutAfter;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(positionOffsetType)) {
|
|
||||||
positionOffsetType = GameLib.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT;
|
|
||||||
}
|
|
||||||
this.positionOffsetType = positionOffsetType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(positionOffset)) {
|
|
||||||
positionOffset = new GameLib.API.Vector3(0, 0, 0);
|
|
||||||
}
|
|
||||||
this.positionOffset = positionOffset;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(positionOffsetFn)) {
|
|
||||||
positionOffsetFn = '//@ sourceURL=positionOffsetFn.js';
|
|
||||||
}
|
|
||||||
this.positionOffsetFn = positionOffsetFn;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(directionType)) {
|
|
||||||
directionType = GameLib.D3.API.Particle.DIRECTION_TYPE_CONSTANT;
|
|
||||||
}
|
|
||||||
this.directionType = directionType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(direction)) {
|
|
||||||
direction = new GameLib.API.Vector3(0, 1, 0);
|
|
||||||
}
|
|
||||||
this.direction = direction;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(directionFn)) {
|
|
||||||
directionFn = '//@ sourceURL=directionFn.js';
|
|
||||||
}
|
|
||||||
this.directionFn = directionFn;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(speedType)) {
|
|
||||||
speedType = GameLib.D3.API.Particle.SPEED_TYPE_CONSTANT;
|
|
||||||
}
|
|
||||||
this.speedType = speedType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(speed)) {
|
|
||||||
speed = 1;
|
|
||||||
}
|
|
||||||
this.speed = speed;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scaleType)) {
|
|
||||||
scaleType = GameLib.D3.API.Particle.SCALE_TYPE_CONSTANT;
|
|
||||||
}
|
|
||||||
this.scaleType = scaleType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scale)) {
|
|
||||||
scale = new GameLib.API.Vector3(1, 1, 1);
|
|
||||||
}
|
|
||||||
this.scale = scale;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scaleFn)) {
|
|
||||||
scaleFn = '//@ sourceURL=scaleFn.js';
|
|
||||||
}
|
|
||||||
this.scaleFn = scaleFn;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(rotationType)) {
|
|
||||||
rotationType = GameLib.D3.API.Particle.ROTATION_TYPE_CONSTANT;
|
|
||||||
}
|
|
||||||
this.rotationType = rotationType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = new GameLib.API.Vector3(0, 0, 0);
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(rotationFn)) {
|
|
||||||
rotationFn = '//@ sourceURL=rotationFn.js';
|
|
||||||
}
|
|
||||||
this.rotationFn = rotationFn;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentParticleEngine)) {
|
|
||||||
parentParticleEngine = null;
|
|
||||||
}
|
|
||||||
this.parentParticleEngine = parentParticleEngine;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.PARTICLE,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Particle.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Particle.prototype.constructor = GameLib.D3.API.Particle;
|
|
||||||
|
|
||||||
GameLib.D3.API.Particle.OPACITY_TYPE_CONSTANT = 0x1;
|
|
||||||
GameLib.D3.API.Particle.OPACITY_TYPE_FADE_OUT_LINEAR = 0x2;
|
|
||||||
GameLib.D3.API.Particle.OPACITY_TYPE_FADE_IN_LINEAR = 0x3;
|
|
||||||
GameLib.D3.API.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR = 0x4;
|
|
||||||
|
|
||||||
GameLib.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT = 0x1;
|
|
||||||
GameLib.D3.API.Particle.POSITION_OFFSET_TYPE_RANDOM = 0x2;
|
|
||||||
GameLib.D3.API.Particle.POSITION_OFFSET_TYPE_FUNCTION = 0x3;
|
|
||||||
|
|
||||||
GameLib.D3.API.Particle.DIRECTION_TYPE_CONSTANT = 0x1;
|
|
||||||
GameLib.D3.API.Particle.DIRECTION_TYPE_RANDOM = 0x2;
|
|
||||||
GameLib.D3.API.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED = 0x3;
|
|
||||||
GameLib.D3.API.Particle.DIRECTION_TYPE_FUNCTION = 0x4;
|
|
||||||
|
|
||||||
GameLib.D3.API.Particle.SCALE_TYPE_CONSTANT = 0x1;
|
|
||||||
GameLib.D3.API.Particle.SCALE_TYPE_LINEAR = 0x2;
|
|
||||||
GameLib.D3.API.Particle.SCALE_TYPE_EXPONENTIAL = 0x3;
|
|
||||||
GameLib.D3.API.Particle.SCALE_TYPE_RANDOM = 0x4;
|
|
||||||
GameLib.D3.API.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y = 0x6;
|
|
||||||
GameLib.D3.API.Particle.SCALE_TYPE_FUNCTION = 0x7;
|
|
||||||
|
|
||||||
GameLib.D3.API.Particle.SPEED_TYPE_CONSTANT = 0x1;
|
|
||||||
GameLib.D3.API.Particle.SPEED_TYPE_LINEAR = 0x2;
|
|
||||||
GameLib.D3.API.Particle.SPEED_TYPE_EXPONENTIAL = 0x3;
|
|
||||||
GameLib.D3.API.Particle.SPEED_TYPE_LOGARITHMIC = 0x4;
|
|
||||||
GameLib.D3.API.Particle.SPEED_TYPE_ONE_OVER_LOG = 0x5;
|
|
||||||
GameLib.D3.API.Particle.SPEED_TYPE_EXP = 0x6;
|
|
||||||
GameLib.D3.API.Particle.SPEED_TYPE_ONE_OVER_EXP = 0x7;
|
|
||||||
|
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_CONSTANT = 0x1;
|
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM = 0x2;
|
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_X = 0x3;
|
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_Y = 0x4;
|
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_RANDOM_Z = 0x5;
|
|
||||||
GameLib.D3.API.Particle.ROTATION_TYPE_FUNCTION = 0x6;
|
|
|
@ -1,95 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Pass
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param passType
|
|
||||||
* @param parentEntity
|
|
||||||
* @param renderToScreen
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Pass = function (
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
passType,
|
|
||||||
parentEntity,
|
|
||||||
renderToScreen
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(passType)) {
|
|
||||||
passType = GameLib.D3.API.Pass.PASS_TYPE_RENDER;
|
|
||||||
}
|
|
||||||
this.passType = passType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
switch (this.passType) {
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_RENDER:
|
|
||||||
name = 'Pass Render';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_FXAA:
|
|
||||||
name = 'Pass FXAA';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_BLOOM:
|
|
||||||
name = 'Pass Bloom';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_SSAO:
|
|
||||||
name = 'Pass SSAO';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.warn('no custom pass name');
|
|
||||||
name = 'Pass';
|
|
||||||
}
|
|
||||||
|
|
||||||
name += ' (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(renderToScreen)) {
|
|
||||||
renderToScreen = false;
|
|
||||||
}
|
|
||||||
this.renderToScreen = renderToScreen;
|
|
||||||
|
|
||||||
var componentType = GameLib.D3.API.Pass.GetComponentType(this.passType);
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.GetComponentType = function(passType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (passType) {
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_RENDER:
|
|
||||||
componentType = GameLib.Component.PASS_RENDER;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_SSAO:
|
|
||||||
componentType = GameLib.Component.PASS_SSAO;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_BLOOM:
|
|
||||||
componentType = GameLib.Component.PASS_BLOOM;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_FXAA:
|
|
||||||
componentType = GameLib.Component.PASS_FXAA;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
throw new Error('unsupported pass type: ' + passType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Pass.prototype.constructor = GameLib.D3.API.Pass;
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.PASS_TYPE_NONE = 0x0;
|
|
||||||
GameLib.D3.API.Pass.PASS_TYPE_RENDER = 0x1;
|
|
||||||
GameLib.D3.API.Pass.PASS_TYPE_SSAO = 0x2;
|
|
||||||
GameLib.D3.API.Pass.PASS_TYPE_BLOOM = 0x3;
|
|
||||||
GameLib.D3.API.Pass.PASS_TYPE_FXAA = 0x4;
|
|
|
@ -1,51 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Pass.FXAA
|
|
||||||
* @param apiPass
|
|
||||||
* @param autoUpdateSize
|
|
||||||
* @param width
|
|
||||||
* @param height
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Pass.FXAA = function (
|
|
||||||
apiPass,
|
|
||||||
autoUpdateSize,
|
|
||||||
width,
|
|
||||||
height
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiPass)) {
|
|
||||||
apiPass = {
|
|
||||||
passType: GameLib.D3.API.Pass.PASS_TYPE_FXAA
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiPass.passType)) {
|
|
||||||
apiPass.passType = GameLib.D3.API.Pass.PASS_TYPE_FXAA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(autoUpdateSize)) {
|
|
||||||
autoUpdateSize = true;
|
|
||||||
}
|
|
||||||
this.autoUpdateSize = autoUpdateSize;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(width)) {
|
|
||||||
width = 512;
|
|
||||||
}
|
|
||||||
this.width = width;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
|
||||||
height = 512;
|
|
||||||
}
|
|
||||||
this.height = height;
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.call(
|
|
||||||
this,
|
|
||||||
apiPass.id,
|
|
||||||
apiPass.name,
|
|
||||||
apiPass.passType,
|
|
||||||
apiPass.parentEntity,
|
|
||||||
apiPass.renderToScreen
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.FXAA.prototype = Object.create(GameLib.D3.API.Pass.prototype);
|
|
||||||
GameLib.D3.API.Pass.FXAA.prototype.constructor = GameLib.D3.API.Pass.FXAA;
|
|
|
@ -1,44 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Pass.Render
|
|
||||||
* @param apiPass
|
|
||||||
* @param camera
|
|
||||||
* @param scene
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Pass.Render = function (
|
|
||||||
apiPass,
|
|
||||||
scene,
|
|
||||||
camera
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiPass)) {
|
|
||||||
apiPass = {
|
|
||||||
passType: GameLib.D3.API.Pass.PASS_TYPE_RENDER
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiPass.passType)) {
|
|
||||||
apiPass.passType = GameLib.D3.API.Pass.PASS_TYPE_RENDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(scene)) {
|
|
||||||
scene = null;
|
|
||||||
}
|
|
||||||
this.scene = scene;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(camera)) {
|
|
||||||
camera = null;
|
|
||||||
}
|
|
||||||
this.camera = camera;
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.call(
|
|
||||||
this,
|
|
||||||
apiPass.id,
|
|
||||||
apiPass.name,
|
|
||||||
apiPass.passType,
|
|
||||||
apiPass.parentEntity,
|
|
||||||
apiPass.renderToScreen
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.Render.prototype = Object.create(GameLib.D3.API.Pass.prototype);
|
|
||||||
GameLib.D3.API.Pass.Render.prototype.constructor = GameLib.D3.API.Pass.Render;
|
|
|
@ -1,46 +0,0 @@
|
||||||
/**
|
|
||||||
* Raycaster for GameLib.D3
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param position GameLib.API.Vector3
|
|
||||||
* @param direction GameLib.API.Vector3
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Raycaster = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
parentEntity,
|
|
||||||
position,
|
|
||||||
direction
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Raycaster (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.API.Vector3();
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(direction)) {
|
|
||||||
direction = new GameLib.API.Vector3(0, -1, 0);
|
|
||||||
}
|
|
||||||
this.direction = direction;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.RAYCASTER,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Raycaster.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Raycaster.prototype.constructor = GameLib.D3.API.Raycaster;
|
|
|
@ -1,52 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.RenderTarget.Cube
|
|
||||||
* @constructor
|
|
||||||
* @param apiRenderTarget
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.RenderTarget.Cube = function (
|
|
||||||
apiRenderTarget
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiRenderTarget)) {
|
|
||||||
apiRenderTarget = {
|
|
||||||
renderTargetType : GameLib.D3.API.RenderTarget.TARGET_TYPE_CUBE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiRenderTarget.renderTargetType)) {
|
|
||||||
apiRenderTarget.renderTargetType = GameLib.D3.API.RenderTarget.TARGET_TYPE_CUBE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiRenderTarget.textureParameters)) {
|
|
||||||
apiRenderTarget.textureParameters = {
|
|
||||||
minFilter : GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiRenderTarget.textureParameters.minFilter)) {
|
|
||||||
apiRenderTarget.textureParameters.minFilter = GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.RenderTarget.call(
|
|
||||||
this,
|
|
||||||
apiRenderTarget.id,
|
|
||||||
apiRenderTarget.name,
|
|
||||||
apiRenderTarget.renderTargetType,
|
|
||||||
apiRenderTarget.parentEntity,
|
|
||||||
apiRenderTarget.autoUpdateSize,
|
|
||||||
apiRenderTarget.width,
|
|
||||||
apiRenderTarget.height,
|
|
||||||
apiRenderTarget.scissor,
|
|
||||||
apiRenderTarget.scissorTest,
|
|
||||||
apiRenderTarget.viewport,
|
|
||||||
apiRenderTarget.texture,
|
|
||||||
apiRenderTarget.depthBuffer,
|
|
||||||
apiRenderTarget.depthTexture,
|
|
||||||
apiRenderTarget.stencilBuffer,
|
|
||||||
apiRenderTarget.textureParameters
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.RenderTarget.Cube.prototype = Object.create(GameLib.D3.API.RenderTarget.prototype);
|
|
||||||
GameLib.D3.API.RenderTarget.Cube.prototype.constructor = GameLib.D3.API.RenderTarget.Cube;
|
|
|
@ -1,32 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Shader.Fragment
|
|
||||||
* @param apiShader
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Shader.Fragment = function(
|
|
||||||
apiShader
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiShader)) {
|
|
||||||
apiShader = {
|
|
||||||
shaderType: GameLib.D3.API.Shader.SHADER_TYPE_FRAGMENT
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiShader.materialType)) {
|
|
||||||
apiShader.shaderType = GameLib.D3.API.Shader.SHADER_TYPE_FRAGMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Shader.call(
|
|
||||||
this,
|
|
||||||
apiShader.id,
|
|
||||||
apiShader.name,
|
|
||||||
apiShader.shaderType,
|
|
||||||
apiShader.parentEntity,
|
|
||||||
apiShader.parentMaterialShader,
|
|
||||||
apiShader.code
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Shader.Fragment.prototype = Object.create(GameLib.D3.API.Shader.prototype);
|
|
||||||
GameLib.D3.API.Shader.Fragment.prototype.constructor = GameLib.D3.API.Shader.Fragment;
|
|
|
@ -1,32 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Shader.Vertex
|
|
||||||
* @param apiShader
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Shader.Vertex = function(
|
|
||||||
apiShader
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiShader)) {
|
|
||||||
apiShader = {
|
|
||||||
shaderType: GameLib.D3.API.Shader.SHADER_TYPE_VERTEX
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiShader.materialType)) {
|
|
||||||
apiShader.shaderType = GameLib.D3.API.Shader.SHADER_TYPE_VERTEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Shader.call(
|
|
||||||
this,
|
|
||||||
apiShader.id,
|
|
||||||
apiShader.name,
|
|
||||||
apiShader.shaderType,
|
|
||||||
apiShader.parentEntity,
|
|
||||||
apiShader.parentMaterialShader,
|
|
||||||
apiShader.code
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Shader.Vertex.prototype = Object.create(GameLib.D3.API.Shader.prototype);
|
|
||||||
GameLib.D3.API.Shader.Vertex.prototype.constructor = GameLib.D3.API.Shader.Vertex;
|
|
|
@ -1,133 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Shadow
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param shadowType
|
|
||||||
* @param camera
|
|
||||||
* @param bias
|
|
||||||
* @param mapSize
|
|
||||||
* @param radius
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Shadow = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
shadowType,
|
|
||||||
camera,
|
|
||||||
bias,
|
|
||||||
mapSize,
|
|
||||||
radius,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(shadowType)) {
|
|
||||||
shadowType = GameLib.D3.API.Shadow.SHADOW_TYPE_NORMAL;
|
|
||||||
}
|
|
||||||
this.shadowType = shadowType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
switch (this.shadowType) {
|
|
||||||
case GameLib.D3.API.Shadow.SHADOW_TYPE_NORMAL :
|
|
||||||
name = 'Shadow Normal';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Shadow.SHADOW_TYPE_DIRECTIONAL :
|
|
||||||
name = 'Shadow Directional';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Shadow.SHADOW_TYPE_SPOT :
|
|
||||||
name = 'Shadow Spot';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.warn('no nice name for shadow');
|
|
||||||
name = 'Shadow';
|
|
||||||
}
|
|
||||||
|
|
||||||
name += ' (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(camera)) {
|
|
||||||
|
|
||||||
var cameraName = 'Camera ' + this.name;
|
|
||||||
|
|
||||||
if (this.shadowType === GameLib.D3.API.Shadow.SHADOW_TYPE_DIRECTIONAL) {
|
|
||||||
camera = new GameLib.D3.API.Camera.Orthographic(
|
|
||||||
{
|
|
||||||
name : cameraName
|
|
||||||
},
|
|
||||||
10,
|
|
||||||
0.5,
|
|
||||||
500,
|
|
||||||
-5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
-5
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
camera = new GameLib.D3.API.Camera.Perspective(
|
|
||||||
{
|
|
||||||
name: cameraName,
|
|
||||||
aspect: 1
|
|
||||||
},
|
|
||||||
0.5,
|
|
||||||
500,
|
|
||||||
90
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.camera = camera;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(bias)) {
|
|
||||||
bias = 0;//new GameLib.API.Number(0, 0.0001, -0.1, 0.1);
|
|
||||||
}
|
|
||||||
this.bias = bias;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(mapSize)) {
|
|
||||||
mapSize = new GameLib.API.Vector2(512, 512);
|
|
||||||
}
|
|
||||||
this.mapSize = mapSize;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(radius)) {
|
|
||||||
radius = 1;//new GameLib.API.Number(1, 0.01, 0, 5);
|
|
||||||
}
|
|
||||||
this.radius = radius;
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (this.shadowType) {
|
|
||||||
case GameLib.D3.API.Shadow.SHADOW_TYPE_NORMAL :
|
|
||||||
componentType = GameLib.Component.SHADOW;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Shadow.SHADOW_TYPE_DIRECTIONAL :
|
|
||||||
componentType = GameLib.Component.SHADOW_DIRECTIONAL;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Shadow.SHADOW_TYPE_SPOT :
|
|
||||||
componentType = GameLib.Component.SHADOW_SPOT;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
console.error('could not determine shadow component type');
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Shadow.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Shadow.prototype.constructor = GameLib.D3.API.Shadow;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shadow Types
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Shadow.SHADOW_TYPE_NORMAL = 0x1;
|
|
||||||
GameLib.D3.API.Shadow.SHADOW_TYPE_DIRECTIONAL = 0x2;
|
|
||||||
GameLib.D3.API.Shadow.SHADOW_TYPE_SPOT = 0x3;
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Shadow
|
|
||||||
* @constructor
|
|
||||||
* @param apiDirectionalShadow
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Shadow.Directional = function(
|
|
||||||
apiDirectionalShadow
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiDirectionalShadow)) {
|
|
||||||
apiDirectionalShadow = {
|
|
||||||
shadowType : GameLib.D3.API.Shadow.SHADOW_TYPE_DIRECTIONAL
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiDirectionalShadow.shadowType)) {
|
|
||||||
apiDirectionalShadow.shadowType = GameLib.D3.API.Shadow.SHADOW_TYPE_DIRECTIONAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Shadow.call(
|
|
||||||
this,
|
|
||||||
apiDirectionalShadow.id,
|
|
||||||
apiDirectionalShadow.name,
|
|
||||||
apiDirectionalShadow.shadowType,
|
|
||||||
apiDirectionalShadow.camera,
|
|
||||||
apiDirectionalShadow.bias,
|
|
||||||
apiDirectionalShadow.mapSize,
|
|
||||||
apiDirectionalShadow.radius,
|
|
||||||
apiDirectionalShadow.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Shadow.Directional.prototype = Object.create(GameLib.D3.API.Shadow.prototype);
|
|
||||||
GameLib.D3.API.Shadow.Directional.prototype.constructor = GameLib.D3.API.Shadow.Directional;
|
|
|
@ -1,154 +0,0 @@
|
||||||
/**
|
|
||||||
* Raw Shape API object - should always correspond with the Shape Schema
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param shapeType
|
|
||||||
* @param boundingSphereRadius
|
|
||||||
* @param collisionResponse
|
|
||||||
* @param frictionMaterial
|
|
||||||
* @param parentMesh
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Shape = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
shapeType,
|
|
||||||
boundingSphereRadius,
|
|
||||||
collisionResponse,
|
|
||||||
frictionMaterial,
|
|
||||||
parentMesh,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(shapeType)) {
|
|
||||||
shapeType = GameLib.D3.API.Shape.SHAPE_TYPE_NONE;
|
|
||||||
}
|
|
||||||
this.shapeType = shapeType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
name = 'Shape (' + this.id + ')';
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_BOX) {
|
|
||||||
name = 'Shape Box (' + this.id + ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL) {
|
|
||||||
name = 'Shape Convex Hull (' + this.id + ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER) {
|
|
||||||
name = 'Shape Convex Hull Cylinder (' + this.id + ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP) {
|
|
||||||
name = 'Shape HeightMap (' + this.id + ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_PLANE) {
|
|
||||||
name = 'Shape Plane (' + this.id + ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE) {
|
|
||||||
name = 'Shape Sphere (' + this.id + ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH) {
|
|
||||||
name = 'Shape TriMesh (' + this.id + ')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(boundingSphereRadius)) {
|
|
||||||
boundingSphereRadius = 0;
|
|
||||||
}
|
|
||||||
this.boundingSphereRadius = boundingSphereRadius;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(collisionResponse)) {
|
|
||||||
collisionResponse = true;
|
|
||||||
}
|
|
||||||
this.collisionResponse = collisionResponse;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(frictionMaterial)) {
|
|
||||||
frictionMaterial = null;
|
|
||||||
}
|
|
||||||
this.frictionMaterial = frictionMaterial;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
|
|
||||||
parentMesh = null;
|
|
||||||
}
|
|
||||||
this.parentMesh = parentMesh;
|
|
||||||
|
|
||||||
var componentType = GameLib.Component.SHAPE;
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_BOX) {
|
|
||||||
componentType = GameLib.Component.SHAPE_BOX;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL) {
|
|
||||||
componentType = GameLib.Component.SHAPE_CONVEX_HULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER) {
|
|
||||||
componentType = GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP) {
|
|
||||||
componentType = GameLib.Component.SHAPE_HEIGHT_MAP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_PLANE) {
|
|
||||||
componentType = GameLib.Component.SHAPE_PLANE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE) {
|
|
||||||
componentType = GameLib.Component.SHAPE_SPHERE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH) {
|
|
||||||
componentType = GameLib.Component.SHAPE_TRI_MESH;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Shape.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Shape.prototype.constructor = GameLib.D3.API.Shape;
|
|
||||||
|
|
||||||
GameLib.D3.API.Shape.SHAPE_TYPE_NONE = 0x0;
|
|
||||||
GameLib.D3.API.Shape.SHAPE_TYPE_BOX = 0x1;
|
|
||||||
GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL = 0x2;
|
|
||||||
GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER = 0x3;
|
|
||||||
GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP = 0x4;
|
|
||||||
GameLib.D3.API.Shape.SHAPE_TYPE_PLANE = 0x5;
|
|
||||||
GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE = 0x6;
|
|
||||||
GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH = 0x7;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an API Shape from an Object Shape
|
|
||||||
* @param objectShape
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Shape.FromObject = function(objectShape) {
|
|
||||||
return new GameLib.D3.API.Shape(
|
|
||||||
objectShape.id,
|
|
||||||
objectShape.name,
|
|
||||||
objectShape.shapeType,
|
|
||||||
objectShape.boundingSphereRadius,
|
|
||||||
objectShape.collisionResponse,
|
|
||||||
objectShape.frictionMaterial,
|
|
||||||
objectShape.parentMesh,
|
|
||||||
objectShape.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/**
|
|
||||||
* API Spline
|
|
||||||
* @param id String
|
|
||||||
* @param name String
|
|
||||||
* @param vertices GameLib.API.Vector3[]
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Spline = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
vertices,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Spline (' + this.id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(vertices)) {
|
|
||||||
vertices = [];
|
|
||||||
}
|
|
||||||
this.vertices = vertices;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.SPLINE,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Spline.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Spline.prototype.constructor = GameLib.D3.API.Spline;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Object to GameLib.D3.API.Spline
|
|
||||||
* @param objectComponent
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Spline.FromObject = function(objectComponent) {
|
|
||||||
return new GameLib.D3.API.Spline(
|
|
||||||
objectComponent.id,
|
|
||||||
objectComponent.name,
|
|
||||||
objectComponent.vertices.map(
|
|
||||||
function (objectVertex) {
|
|
||||||
return GameLib.API.Vector3.FromObject(objectVertex);
|
|
||||||
}
|
|
||||||
),
|
|
||||||
objectComponent.parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,327 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.API.Texture
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param textureType
|
|
||||||
* @param parentEntity
|
|
||||||
* @param parentMaterials
|
|
||||||
* @param mipmaps
|
|
||||||
* @param mapping
|
|
||||||
* @param wrapS
|
|
||||||
* @param wrapT
|
|
||||||
* @param magFilter
|
|
||||||
* @param minFilter
|
|
||||||
* @param anisotropy
|
|
||||||
* @param format
|
|
||||||
* @param storageType
|
|
||||||
* @param offset
|
|
||||||
* @param repeat
|
|
||||||
* @param rotation
|
|
||||||
* @param center
|
|
||||||
* @param matrixAutoUpdate
|
|
||||||
* @param generateMipMaps
|
|
||||||
* @param premultiplyAlpha
|
|
||||||
* @param flipY
|
|
||||||
* @param unpackAlignment
|
|
||||||
* @param encoding
|
|
||||||
* @param version
|
|
||||||
* @param animated
|
|
||||||
* @param reverseAnimation
|
|
||||||
* @param forward
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Texture = function(
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
textureType,
|
|
||||||
parentEntity,
|
|
||||||
parentMaterials,
|
|
||||||
mipmaps,
|
|
||||||
mapping,
|
|
||||||
wrapS,
|
|
||||||
wrapT,
|
|
||||||
magFilter,
|
|
||||||
minFilter,
|
|
||||||
anisotropy,
|
|
||||||
format,
|
|
||||||
storageType,
|
|
||||||
offset,
|
|
||||||
repeat,
|
|
||||||
rotation,
|
|
||||||
center,
|
|
||||||
matrixAutoUpdate,
|
|
||||||
generateMipMaps,
|
|
||||||
premultiplyAlpha,
|
|
||||||
flipY,
|
|
||||||
unpackAlignment,
|
|
||||||
encoding,
|
|
||||||
version,
|
|
||||||
animated,
|
|
||||||
reverseAnimation,
|
|
||||||
forward
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(textureType)) {
|
|
||||||
textureType = GameLib.D3.API.Texture.TEXTURE_TYPE_NONE;
|
|
||||||
}
|
|
||||||
this.textureType = textureType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
|
|
||||||
switch (this.textureType) {
|
|
||||||
case GameLib.D3.API.Texture.TEXTURE_TYPE_IMAGE :
|
|
||||||
name = 'Texture Image';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Texture.TEXTURE_TYPE_CANVAS :
|
|
||||||
name = 'Texture Canvas';
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Texture.TEXTURE_TYPE_CUBE :
|
|
||||||
name = 'Texture Cube';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
name = 'Texture';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
name += ' (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentMaterials)) {
|
|
||||||
parentMaterials = [];
|
|
||||||
}
|
|
||||||
this.parentMaterials = parentMaterials;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(mipmaps)) {
|
|
||||||
mipmaps = [];
|
|
||||||
}
|
|
||||||
this.mipmaps = mipmaps;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(mapping)) {
|
|
||||||
mapping = GameLib.D3.API.Texture.TYPE_UV_MAPPING;
|
|
||||||
}
|
|
||||||
this.mapping = mapping;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(wrapS)) {
|
|
||||||
wrapS = GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING;
|
|
||||||
}
|
|
||||||
this.wrapS = wrapS;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(wrapT)) {
|
|
||||||
wrapT = GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING;
|
|
||||||
}
|
|
||||||
this.wrapT = wrapT;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(magFilter)) {
|
|
||||||
magFilter = GameLib.D3.API.Texture.TYPE_LINEAR_FILTER;
|
|
||||||
}
|
|
||||||
this.magFilter = magFilter;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(minFilter)) {
|
|
||||||
minFilter = GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER;
|
|
||||||
}
|
|
||||||
this.minFilter = minFilter;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(anisotropy)) {
|
|
||||||
anisotropy = 1;
|
|
||||||
}
|
|
||||||
this.anisotropy = anisotropy;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(format)) {
|
|
||||||
format = GameLib.D3.API.Texture.TYPE_RGBA_FORMAT;
|
|
||||||
}
|
|
||||||
this.format = format;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(storageType)) {
|
|
||||||
storageType = GameLib.D3.API.Texture.TYPE_UNSIGNED_BYTE;
|
|
||||||
}
|
|
||||||
this.storageType = storageType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(offset)) {
|
|
||||||
offset = new GameLib.API.Vector2(0, 0);
|
|
||||||
}
|
|
||||||
this.offset = offset;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(repeat)) {
|
|
||||||
repeat = new GameLib.API.Vector2(1, 1);
|
|
||||||
}
|
|
||||||
this.repeat = repeat;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(rotation)) {
|
|
||||||
rotation = 0;
|
|
||||||
}
|
|
||||||
this.rotation = rotation;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(center)) {
|
|
||||||
center = new GameLib.API.Vector2(0.5, 0.5);
|
|
||||||
}
|
|
||||||
this.center = center;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(matrixAutoUpdate)) {
|
|
||||||
matrixAutoUpdate = true;
|
|
||||||
}
|
|
||||||
this.matrixAutoUpdate = matrixAutoUpdate;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(generateMipMaps)) {
|
|
||||||
generateMipMaps = true;
|
|
||||||
}
|
|
||||||
this.generateMipMaps = generateMipMaps;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(premultiplyAlpha)) {
|
|
||||||
premultiplyAlpha = false;
|
|
||||||
}
|
|
||||||
this.premultiplyAlpha = premultiplyAlpha;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(flipY)) {
|
|
||||||
flipY = true;
|
|
||||||
}
|
|
||||||
this.flipY = flipY;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(unpackAlignment)) {
|
|
||||||
unpackAlignment = 4;
|
|
||||||
}
|
|
||||||
this.unpackAlignment = unpackAlignment;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(encoding)) {
|
|
||||||
encoding = GameLib.D3.API.Texture.TYPE_LINEAR_ENCODING;
|
|
||||||
}
|
|
||||||
this.encoding = encoding;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(version)) {
|
|
||||||
version = 0
|
|
||||||
}
|
|
||||||
this.version = version;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(animated)) {
|
|
||||||
animated = false;
|
|
||||||
}
|
|
||||||
this.animated = animated;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(reverseAnimation)) {
|
|
||||||
reverseAnimation = false;
|
|
||||||
}
|
|
||||||
this.reverseAnimation = reverseAnimation;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(forward)) {
|
|
||||||
forward = true;
|
|
||||||
}
|
|
||||||
this.forward = forward;
|
|
||||||
|
|
||||||
this.needsUpdate = false;
|
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.D3.API.Texture.GetComponentType(this.textureType),
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Texture.GetComponentType = function(textureType) {
|
|
||||||
|
|
||||||
var componentType = null;
|
|
||||||
|
|
||||||
switch (textureType) {
|
|
||||||
case GameLib.D3.API.Texture.TEXTURE_TYPE_NONE :
|
|
||||||
componentType = GameLib.Component.TEXTURE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Texture.TEXTURE_TYPE_IMAGE :
|
|
||||||
componentType = GameLib.Component.TEXTURE_IMAGE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Texture.TEXTURE_TYPE_CUBE :
|
|
||||||
componentType = GameLib.Component.TEXTURE_CUBE;
|
|
||||||
break;
|
|
||||||
case GameLib.D3.API.Texture.TEXTURE_TYPE_CANVAS :
|
|
||||||
componentType = GameLib.Component.TEXTURE_CANVAS;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
throw new Error('unhandled texture type: ' + textureType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return componentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Texture.prototype = Object.create(GameLib.API.Component.prototype);
|
|
||||||
GameLib.D3.API.Texture.prototype.constructor = GameLib.D3.API.Texture;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Texture Formats
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Texture.TYPE_ALPHA_FORMAT = 1019;
|
|
||||||
GameLib.D3.API.Texture.TYPE_RGB_FORMAT = 1020;
|
|
||||||
GameLib.D3.API.Texture.TYPE_RGBA_FORMAT = 1021;
|
|
||||||
GameLib.D3.API.Texture.TYPE_LUMINANCE_FORMAT = 1022;
|
|
||||||
GameLib.D3.API.Texture.TYPE_LUMINANCE_ALPHA_FORMAT = 1023;
|
|
||||||
GameLib.D3.API.Texture.TYPE_DEPTH_FORMAT = 1026;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping modes
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Texture.TYPE_UV_MAPPING = 300;
|
|
||||||
GameLib.D3.API.Texture.TYPE_CUBE_REFLECTION_MAPPING = 301;
|
|
||||||
GameLib.D3.API.Texture.TYPE_CUBE_REFRACTION_MAPPING = 302;
|
|
||||||
GameLib.D3.API.Texture.TYPE_EQUI_RECTANGULAR_REFLECTION_MAPPING = 303;
|
|
||||||
GameLib.D3.API.Texture.TYPE_EQUI_RECTANGULAR_REFRACTION_MAPPING = 304;
|
|
||||||
GameLib.D3.API.Texture.TYPE_SPHERICAL_REFLECTION_MAPPING = 305;
|
|
||||||
GameLib.D3.API.Texture.TYPE_CUBE_UV_REFLECTION_MAPPING = 306;
|
|
||||||
GameLib.D3.API.Texture.TYPE_CUBE_UV_REFRACTION_MAPPING = 307;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapping Modes
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING = 1000;
|
|
||||||
GameLib.D3.API.Texture.TYPE_CLAMP_TO_EDGE_WRAPPING = 1001;
|
|
||||||
GameLib.D3.API.Texture.TYPE_MIRRORED_REPEAT_WRAPPING = 1002;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mipmap Filters
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Texture.TYPE_NEAREST_FILTER = 1003;
|
|
||||||
GameLib.D3.API.Texture.TYPE_NEAREST_MIPMAP_NEAREST_FILTER = 1004;
|
|
||||||
GameLib.D3.API.Texture.TYPE_NEAREST_MIPMAP_LINEAR_FILTER = 1005;
|
|
||||||
GameLib.D3.API.Texture.TYPE_LINEAR_FILTER = 1006;
|
|
||||||
GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_NEAREST_FILTER = 1007;
|
|
||||||
GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER = 1008;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Texture Data Types
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Texture.TYPE_UNSIGNED_BYTE = 1009;
|
|
||||||
GameLib.D3.API.Texture.TYPE_BYTE = 1010;
|
|
||||||
GameLib.D3.API.Texture.TYPE_SHORT = 1011;
|
|
||||||
GameLib.D3.API.Texture.TYPE_UNSIGNED_SHORT = 1012;
|
|
||||||
GameLib.D3.API.Texture.TYPE_INT = 1013;
|
|
||||||
GameLib.D3.API.Texture.TYPE_UNSIGNED_INT = 1014;
|
|
||||||
GameLib.D3.API.Texture.TYPE_FLOAT = 1015;
|
|
||||||
GameLib.D3.API.Texture.TYPE_HALF_FLOAT = 1025;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encoding Modes
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Texture.TYPE_LINEAR_ENCODING = 3000; // NO ENCODING AT ALL.
|
|
||||||
GameLib.D3.API.Texture.TYPE_SRGB_ENCODING = 3001;
|
|
||||||
GameLib.D3.API.Texture.TYPE_GAMMA_ENCODING = 3007; // USES GAMMA_FACTOR, FOR BACKWARDS COMPATIBILITY WITH WEBGLRENDERER.GAMMAINPUT/GAMMAOUTPUT
|
|
||||||
GameLib.D3.API.Texture.TYPE_RGBE_ENCODING = 3002; // AKA RADIANCE.
|
|
||||||
GameLib.D3.API.Texture.TYPE_LOG_LUV_ENCODING = 3003;
|
|
||||||
GameLib.D3.API.Texture.TYPE_RGBM7_ENCODING = 3004;
|
|
||||||
GameLib.D3.API.Texture.TYPE_RGBM16_ENCODING = 3005;
|
|
||||||
GameLib.D3.API.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Texture Component Types
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Texture.TEXTURE_TYPE_NONE = 0x0;
|
|
||||||
GameLib.D3.API.Texture.TEXTURE_TYPE_IMAGE = 0x1;
|
|
||||||
GameLib.D3.API.Texture.TEXTURE_TYPE_CUBE = 0x2;
|
|
||||||
GameLib.D3.API.Texture.TEXTURE_TYPE_CANVAS = 0x3;
|
|
|
@ -1,21 +0,0 @@
|
||||||
/**
|
|
||||||
* API Vertex
|
|
||||||
* @param position GameLib.API.Vector3
|
|
||||||
* @param boneWeights GameLib.API.BoneWeight[]
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Vertex = function(
|
|
||||||
position,
|
|
||||||
boneWeights
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(position)) {
|
|
||||||
position = new GameLib.API.Vector3();
|
|
||||||
}
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(boneWeights)) {
|
|
||||||
boneWeights = [];
|
|
||||||
}
|
|
||||||
this.boneWeights = boneWeights;
|
|
||||||
};
|
|
|
@ -1,40 +0,0 @@
|
||||||
/**
|
|
||||||
* BoneWeight Superset
|
|
||||||
* @constructor
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiBoneWeight GameLib.D3.API.BoneWeight
|
|
||||||
*/
|
|
||||||
GameLib.D3.BoneWeight = function (
|
|
||||||
graphics,
|
|
||||||
apiBoneWeight
|
|
||||||
) {
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiBoneWeight)) {
|
|
||||||
apiBoneWeight = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.BoneWeight.call(
|
|
||||||
this,
|
|
||||||
apiBoneWeight.boneIndex,
|
|
||||||
apiBoneWeight.weight
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.BoneWeight.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.D3.BoneWeight.prototype.constructor = GameLib.D3.BoneWeight;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.BoneWeight to GameLib.D3.API.BoneWeight
|
|
||||||
* @returns {GameLib.D3.API.BoneWeight}
|
|
||||||
*/
|
|
||||||
GameLib.D3.BoneWeight.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiBoneWeight = new GameLib.D3.API.BoneWeight(
|
|
||||||
this.boneIndex,
|
|
||||||
this.weight
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiBoneWeight;
|
|
||||||
};
|
|
|
@ -1,118 +0,0 @@
|
||||||
/**
|
|
||||||
* Broadphase Runtime
|
|
||||||
* @param physics GameLib.GraphicsRuntime
|
|
||||||
* @param apiBroadphase GameLib.D3.API.Broadphase
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Broadphase = function (
|
|
||||||
physics,
|
|
||||||
apiBroadphase
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.physics = physics;
|
|
||||||
this.physics.isNotCannonThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiBroadphase)) {
|
|
||||||
apiBroadphase = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Broadphase.call(
|
|
||||||
this,
|
|
||||||
apiBroadphase.id,
|
|
||||||
apiBroadphase.name,
|
|
||||||
apiBroadphase.broadphaseType,
|
|
||||||
apiBroadphase.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.Component.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Broadphase.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.D3.Broadphase.prototype.constructor = GameLib.D3.Broadphase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadphase Types
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE = 0x1;
|
|
||||||
GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID = 0x2;
|
|
||||||
GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP = 0x3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Broadphase.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
if (this.broadphaseType === GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE) {
|
|
||||||
this.instance = new CANNON.NaiveBroadphase();
|
|
||||||
} else if (this.broadphaseType === GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID) {
|
|
||||||
this.instance = new CANNON.GridBroadphase();
|
|
||||||
} else if (this.broadphaseType === GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP) {
|
|
||||||
this.instance = new CANNON.SAPBroadphase();
|
|
||||||
} else {
|
|
||||||
console.warn('Unsupported broadphase type: ' + this.broadphaseType);
|
|
||||||
throw new Error('Unsupported broadphase type: ' + this.broadphaseType);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
GameLib.D3.Broadphase.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (this.broadphaseType === GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE) {
|
|
||||||
if (!(this.instance instanceof CANNON.NaiveBroadphase)) {
|
|
||||||
this.createInstance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.broadphaseType === GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID) {
|
|
||||||
if (!(this.instance instanceof CANNON.GridBroadphase)) {
|
|
||||||
this.createInstance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.broadphaseType === GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP) {
|
|
||||||
if (!(this.instance instanceof CANNON.SAPBroadphase)) {
|
|
||||||
this.createInstance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.Broadphase to GameLib.D3.API.Broadphase
|
|
||||||
* @returns {GameLib.D3.API.Broadphase}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Broadphase.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiBroadphase = new GameLib.D3.API.Broadphase(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
this.broadphaseType,
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiBroadphase;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.Broadphase from Object Broadphase
|
|
||||||
* @param graphics
|
|
||||||
* @param objectComponent
|
|
||||||
* @returns {GameLib.D3.Broadphase}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Broadphase.FromObject = function(graphics, objectComponent) {
|
|
||||||
|
|
||||||
var apiBroadphase = GameLib.D3.API.Broadphase.FromObject(objectComponent);
|
|
||||||
|
|
||||||
return new GameLib.D3.Broadphase(
|
|
||||||
graphics,
|
|
||||||
apiBroadphase
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,80 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Effect.Anaglyph
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiAnaglyphEffect
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Anaglyph = function(
|
|
||||||
graphics,
|
|
||||||
apiAnaglyphEffect
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiAnaglyphEffect)) {
|
|
||||||
apiAnaglyphEffect = {
|
|
||||||
effectType : GameLib.D3.API.Effect.EFFECT_TYPE_ANAGLYPH
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.Anaglyph.call(
|
|
||||||
this,
|
|
||||||
apiAnaglyphEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.Effect.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Effect.Anaglyph.prototype = Object.create(GameLib.D3.Effect.prototype);
|
|
||||||
GameLib.D3.Effect.Anaglyph.prototype.constructor = GameLib.D3.Effect.Anaglyph;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a camera instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Anaglyph.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
if (
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.renderer) ||
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.renderer.instance)
|
|
||||||
) {
|
|
||||||
console.warn('anaglyph not ready for instance - needs a renderer');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance = new THREE.AnaglyphEffect(
|
|
||||||
this.renderer.instance
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('anaglyph effect instance created');
|
|
||||||
|
|
||||||
GameLib.D3.Effect.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Anaglyph.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.D3.Effect.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Effect to a GameLib.D3.API.Effect
|
|
||||||
* @returns {GameLib.D3.API.Effect}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Anaglyph.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiEffect = GameLib.D3.Effect.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
var apiAnaglyphEffect = new GameLib.D3.API.Effect.Anaglyph(
|
|
||||||
apiEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiAnaglyphEffect;
|
|
||||||
};
|
|
|
@ -1,80 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Effect.Parallax
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiParallaxEffect
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Parallax = function(
|
|
||||||
graphics,
|
|
||||||
apiParallaxEffect
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiParallaxEffect)) {
|
|
||||||
apiParallaxEffect = {
|
|
||||||
effectType : GameLib.D3.API.Effect.EFFECT_TYPE_PARALLAX
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.Parallax.call(
|
|
||||||
this,
|
|
||||||
apiParallaxEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.Effect.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Effect.Parallax.prototype = Object.create(GameLib.D3.Effect.prototype);
|
|
||||||
GameLib.D3.Effect.Parallax.prototype.constructor = GameLib.D3.Effect.Parallax;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a camera instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Parallax.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
if (
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.renderer) ||
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.renderer.instance)
|
|
||||||
) {
|
|
||||||
console.warn('parallax not ready for instance - needs a renderer');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance = new THREE.ParallaxBarrierEffect(
|
|
||||||
this.renderer.instance
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('parallax effect instance created');
|
|
||||||
|
|
||||||
GameLib.D3.Effect.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Parallax.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.D3.Effect.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Effect to a GameLib.D3.API.Effect
|
|
||||||
* @returns {GameLib.D3.API.Effect}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Parallax.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiEffect = GameLib.D3.Effect.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
var apiParallaxEffect = new GameLib.D3.API.Effect.Parallax(
|
|
||||||
apiEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiParallaxEffect;
|
|
||||||
};
|
|
|
@ -1,90 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Effect.Stereo
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiStereoEffect
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Stereo = function(
|
|
||||||
graphics,
|
|
||||||
apiStereoEffect
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiStereoEffect)) {
|
|
||||||
apiStereoEffect = {
|
|
||||||
effectType : GameLib.D3.API.Effect.EFFECT_TYPE_STEREO
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Effect.Stereo.call(
|
|
||||||
this,
|
|
||||||
apiStereoEffect,
|
|
||||||
apiStereoEffect.eyeSeperation
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.Effect.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Effect.Stereo.prototype = Object.create(GameLib.D3.Effect.prototype);
|
|
||||||
GameLib.D3.Effect.Stereo.prototype.constructor = GameLib.D3.Effect.Stereo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a camera instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Stereo.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
if (
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.renderer) ||
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.renderer.instance)
|
|
||||||
) {
|
|
||||||
console.warn('stereo effect not ready for instance - needs a renderer');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance = new THREE.StereoEffect(
|
|
||||||
this.renderer.instance
|
|
||||||
);
|
|
||||||
|
|
||||||
this.instance.setEyeSeparation(this.eyeSeperation);
|
|
||||||
|
|
||||||
console.log('stereo effect instance created');
|
|
||||||
|
|
||||||
GameLib.D3.Effect.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Stereo.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (property === 'eyeSeperation') {
|
|
||||||
this.instance.setEyeSeparation(this.eyeSeperation);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Effect.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Effect to a GameLib.D3.API.Effect
|
|
||||||
* @returns {GameLib.D3.API.Effect}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Effect.Stereo.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiEffect = GameLib.D3.Effect.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
var apiStereoEffect = new GameLib.D3.API.Effect.Stereo(
|
|
||||||
apiEffect,
|
|
||||||
this.eyeSeperation
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiStereoEffect;
|
|
||||||
};
|
|
|
@ -1,97 +0,0 @@
|
||||||
/**
|
|
||||||
* Font Superset - The apiFont properties get moved into the Font object itself, and then the instance is created
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiFont GameLib.D3.API.Font
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Font = function(
|
|
||||||
graphics,
|
|
||||||
apiFont
|
|
||||||
) {
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiFont)) {
|
|
||||||
apiFont = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Font.call(
|
|
||||||
this,
|
|
||||||
apiFont.id,
|
|
||||||
apiFont.name,
|
|
||||||
apiFont.url,
|
|
||||||
apiFont.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.Component.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Font.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.D3.Font.prototype.constructor = GameLib.D3.Font;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a light instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Font.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.LOAD_FONT,
|
|
||||||
{
|
|
||||||
font : this
|
|
||||||
},
|
|
||||||
function(fontInstance) {
|
|
||||||
this.instance = fontInstance;
|
|
||||||
|
|
||||||
console.log('font instance loaded');
|
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
}.bind(this),
|
|
||||||
function(error) {
|
|
||||||
console.error(error);
|
|
||||||
this.instance = null;
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Font.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (property === 'url') {
|
|
||||||
this.createInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Font to a GameLib.D3.API.Font
|
|
||||||
* @returns {GameLib.D3.API.Font}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Font.prototype.toApiObject = function() {
|
|
||||||
return new GameLib.D3.API.Font(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
this.url,
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new GameLib.D3.Font from a GameLib.D3.API.Font
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param objectFont GameLib.D3.API.Font
|
|
||||||
* @returns {GameLib.D3.Font}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Font.FromObject = function(graphics, objectFont) {
|
|
||||||
|
|
||||||
return new GameLib.D3.Font(
|
|
||||||
graphics,
|
|
||||||
GameLib.D3.API.Font.FromObject(objectFont)
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,90 +0,0 @@
|
||||||
/**
|
|
||||||
* FrictionMaterial Runtime
|
|
||||||
* @param physics GameLib.GraphicsRuntime
|
|
||||||
* @param apiFrictionMaterial GameLib.D3.API.FrictionMaterial
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.FrictionMaterial = function (
|
|
||||||
physics,
|
|
||||||
apiFrictionMaterial
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.physics = physics;
|
|
||||||
this.physics.isNotCannonThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiFrictionMaterial)) {
|
|
||||||
apiFrictionMaterial = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.FrictionMaterial.call(
|
|
||||||
this,
|
|
||||||
apiFrictionMaterial.id,
|
|
||||||
apiFrictionMaterial.name,
|
|
||||||
apiFrictionMaterial.friction,
|
|
||||||
apiFrictionMaterial.restitution,
|
|
||||||
apiFrictionMaterial.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.Component.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.FrictionMaterial.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.D3.FrictionMaterial.prototype.constructor = GameLib.D3.FrictionMaterial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create instance
|
|
||||||
*/
|
|
||||||
GameLib.D3.FrictionMaterial.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
this.instance = new CANNON.Material(
|
|
||||||
this.name
|
|
||||||
);
|
|
||||||
|
|
||||||
this.instance.friction = this.friction;
|
|
||||||
this.instance.restitution = this.restitution;
|
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
GameLib.D3.FrictionMaterial.prototype.updateInstance = function() {
|
|
||||||
this.instance.friction = this.friction;
|
|
||||||
this.instance.restitution = this.restitution;
|
|
||||||
this.instance.name = this.name;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.FrictionMaterial to GameLib.D3.API.FrictionMaterial
|
|
||||||
* @returns {GameLib.D3.API.FrictionMaterial}
|
|
||||||
*/
|
|
||||||
GameLib.D3.FrictionMaterial.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiFrictionMaterial = new GameLib.D3.API.FrictionMaterial(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
this.friction,
|
|
||||||
this.restitution,
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiFrictionMaterial;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.FrictionMaterial from Object FrictionMaterial
|
|
||||||
* @param physics
|
|
||||||
* @param objectComponent
|
|
||||||
* @returns {GameLib.D3.FrictionMaterial}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.FrictionMaterial.FromObject = function(physics, objectComponent) {
|
|
||||||
|
|
||||||
var apiFrictionMaterial = GameLib.D3.API.FrictionMaterial.FromObject(objectComponent);
|
|
||||||
|
|
||||||
return new GameLib.D3.FrictionMaterial(
|
|
||||||
physics,
|
|
||||||
apiFrictionMaterial
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,82 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Geometry.Buffer.Instanced
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiGeometryBufferInstanced
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Geometry.Buffer.Instanced = function(
|
|
||||||
graphics,
|
|
||||||
apiGeometryBufferInstanced
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferInstanced)) {
|
|
||||||
apiGeometryBufferInstanced = {
|
|
||||||
geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_INSTANCED
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Geometry.Buffer.Instanced.call(
|
|
||||||
this,
|
|
||||||
apiGeometryBufferInstanced,
|
|
||||||
apiGeometryBufferInstanced.maxInstancedCount
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.Geometry.Buffer.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
apiGeometryBufferInstanced
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Geometry.Buffer.Instanced.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype);
|
|
||||||
GameLib.D3.Geometry.Buffer.Instanced.prototype.constructor = GameLib.D3.Geometry.Buffer.Instanced;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a light instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Geometry.Buffer.Instanced.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
this.instance = new THREE.InstancedBufferGeometry();
|
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.maxInstancedCount)) {
|
|
||||||
this.instance.maxInstancedCount = this.maxInstancedCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Geometry.Buffer.Instanced.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (
|
|
||||||
property === 'maxInstancedCount'
|
|
||||||
) {
|
|
||||||
this.instance.maxInstancedCount = this.maxInstancedCount;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Geometry.Buffer.Instanced to a GameLib.D3.API.Geometry.Buffer.Instanced
|
|
||||||
* @returns {GameLib.D3.API.Geometry.Buffer}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Geometry.Buffer.Instanced.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
var apiGeometryBufferInstanced = new GameLib.D3.API.Geometry.Buffer.Instanced(
|
|
||||||
apiBufferGeometry,
|
|
||||||
this.maxInstancedCount
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiGeometryBufferInstanced;
|
|
||||||
};
|
|
|
@ -1,159 +0,0 @@
|
||||||
/**
|
|
||||||
* Helpers for displaying outlines or making 'invisible' scene objects visible
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param id
|
|
||||||
* @param name
|
|
||||||
* @param object
|
|
||||||
* @param helperType
|
|
||||||
* @param parentEntity
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Helper = function(
|
|
||||||
graphics,
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
object,
|
|
||||||
helperType,
|
|
||||||
parentEntity
|
|
||||||
) {
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
||||||
id = GameLib.Utils.RandomId();
|
|
||||||
}
|
|
||||||
this.id = id;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
||||||
name = 'Helper (' + id + ')';
|
|
||||||
}
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(object)) {
|
|
||||||
console.warn('Cannot create a helper for an Object which does not exist');
|
|
||||||
throw new Error('Cannot create a helper for an Object which does not exist');
|
|
||||||
}
|
|
||||||
this.object = object;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(helperType)) {
|
|
||||||
|
|
||||||
helperType = GameLib.D3.Helper.HELPER_TYPE_NONE;
|
|
||||||
|
|
||||||
if (
|
|
||||||
object instanceof GameLib.D3.Mesh &&
|
|
||||||
object.meshType !== GameLib.D3.API.Object.OBJECT_TYPE_MESH_CURVE
|
|
||||||
) {
|
|
||||||
helperType = GameLib.D3.Helper.HELPER_TYPE_EDGES;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object instanceof GameLib.D3.Light) {
|
|
||||||
if (object.lightType === GameLib.D3.API.Light.LIGHT_TYPE_DIRECTIONAL) {
|
|
||||||
helperType = GameLib.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object.lightType === GameLib.D3.API.Light.LIGHT_TYPE_POINT) {
|
|
||||||
helperType = GameLib.D3.Helper.HELPER_TYPE_POINT_LIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object.lightType === GameLib.D3.API.Light.LIGHT_TYPE_SPOT) {
|
|
||||||
helperType = GameLib.D3.Helper.HELPER_TYPE_SPOT_LIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object instanceof GameLib.D3.Skeleton) {
|
|
||||||
helperType = GameLib.D3.Helper.HELPER_TYPE_SKELETON;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.helperType = helperType;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
|
||||||
parentEntity = null;
|
|
||||||
}
|
|
||||||
this.parentEntity = parentEntity;
|
|
||||||
|
|
||||||
this.createInstance();
|
|
||||||
/**
|
|
||||||
* A helper as a component - does this make sense at all?
|
|
||||||
*/
|
|
||||||
// GameLib.Component.call(
|
|
||||||
// this,
|
|
||||||
// GameLib.Component.HELPER
|
|
||||||
// );
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Helper.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.D3.Helper.prototype.constructor = GameLib.D3.Helper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper types
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Helper.HELPER_TYPE_NONE = 0x0;
|
|
||||||
GameLib.D3.Helper.HELPER_TYPE_EDGES = 0x1;
|
|
||||||
GameLib.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT = 0x2;
|
|
||||||
GameLib.D3.Helper.HELPER_TYPE_SPOT_LIGHT = 0x3;
|
|
||||||
GameLib.D3.Helper.HELPER_TYPE_POINT_LIGHT = 0x4;
|
|
||||||
GameLib.D3.Helper.HELPER_TYPE_WIREFRAME = 0x5;
|
|
||||||
GameLib.D3.Helper.HELPER_TYPE_SKELETON = 0x6;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a helper instance
|
|
||||||
*/
|
|
||||||
GameLib.D3.Helper.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
if (this.helperType === GameLib.D3.Helper.HELPER_TYPE_EDGES) {
|
|
||||||
this.instance = new THREE.LineSegments(
|
|
||||||
new THREE.EdgesGeometry(
|
|
||||||
this.object.instance.geometry
|
|
||||||
),
|
|
||||||
new THREE.LineBasicMaterial(
|
|
||||||
{
|
|
||||||
color:0x00ff00,
|
|
||||||
linewidth:2
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.updateInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.helperType === GameLib.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT) {
|
|
||||||
this.instance = new THREE.DirectionalLightHelper(this.object.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.helperType === GameLib.D3.Helper.HELPER_TYPE_POINT_LIGHT) {
|
|
||||||
this.instance = new THREE.PointLightHelper(this.object.instance, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.helperType === GameLib.D3.Helper.HELPER_TYPE_SPOT_LIGHT) {
|
|
||||||
this.instance = new THREE.SpotLightHelper(this.object.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.helperType === GameLib.D3.Helper.HELPER_TYPE_WIREFRAME) {
|
|
||||||
this.instance = new THREE.WireframeGeometry(this.object.instance, 0x00FF00);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.helperType === GameLib.D3.Helper.HELPER_TYPE_SKELETON) {
|
|
||||||
this.instance = new THREE.SkeletonHelper(this.object.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Helper.prototype.updateInstance = function() {
|
|
||||||
|
|
||||||
this.instance.position.copy(this.object.instance.position);
|
|
||||||
this.instance.scale.copy(this.object.instance.scale);
|
|
||||||
this.instance.quaternion.copy(this.object.instance.quaternion);
|
|
||||||
|
|
||||||
if (this.object.parentMesh && this.object.parentMesh.instance) {
|
|
||||||
this.object.parentMesh.instance.add(this.instance);
|
|
||||||
|
|
||||||
this.instance.applyMatrix(this.object.instance.matrix);
|
|
||||||
this.instance.updateMatrix();
|
|
||||||
|
|
||||||
this.instance.updateMatrixWorld();
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,64 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Light.Ambient
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiAmbientLight
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Light.Ambient = function(
|
|
||||||
graphics,
|
|
||||||
apiAmbientLight
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiAmbientLight)) {
|
|
||||||
apiAmbientLight = {
|
|
||||||
lightType : GameLib.D3.API.Light.LIGHT_TYPE_AMBIENT
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Light.Ambient.call(
|
|
||||||
this,
|
|
||||||
apiAmbientLight
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.Light.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
apiAmbientLight
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Light.Ambient.prototype = Object.create(GameLib.D3.Light.prototype);
|
|
||||||
GameLib.D3.Light.Ambient.prototype.constructor = GameLib.D3.Light.Ambient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a light instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Light.Ambient.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
this.instance = new THREE.AmbientLight();
|
|
||||||
|
|
||||||
GameLib.D3.Light.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Light.Ambient.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.D3.Light.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Light to a GameLib.D3.API.Light
|
|
||||||
* @returns {GameLib.D3.API.Light}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Light.Ambient.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiLight = GameLib.D3.Light.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
return apiLight;
|
|
||||||
};
|
|
|
@ -1,114 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Pass
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiPass GameLib.D3.API.Pass
|
|
||||||
* @property passType
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass = function (
|
|
||||||
graphics,
|
|
||||||
apiPass
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiPass)) {
|
|
||||||
apiPass = {
|
|
||||||
passType : GameLib.D3.API.Pass.PASS_TYPE_NONE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.call(
|
|
||||||
this,
|
|
||||||
apiPass.id,
|
|
||||||
apiPass.name,
|
|
||||||
apiPass.passType,
|
|
||||||
apiPass.parentEntity,
|
|
||||||
apiPass.renderToScreen
|
|
||||||
);
|
|
||||||
|
|
||||||
var linkedObjects = {};
|
|
||||||
|
|
||||||
switch (this.passType) {
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_RENDER:
|
|
||||||
case GameLib.D3.API.Pass.PASS_TYPE_SSAO:
|
|
||||||
linkedObjects.scene = GameLib.D3.Scene;
|
|
||||||
linkedObjects.camera = GameLib.D3.Camera;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
linkedObjects
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Pass.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.D3.Pass.prototype.constructor = GameLib.D3.Pass;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Pass instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
|
||||||
console.warn('no instance - call the child createInstance() first');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance.renderToScreen = this.renderToScreen;
|
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Pass instance
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
|
|
||||||
if (property === 'passType') {
|
|
||||||
|
|
||||||
var componentType = GameLib.D3.API.Pass.GetComponentType(this.passType);
|
|
||||||
|
|
||||||
this.replace(componentType);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'renderToScreen') {
|
|
||||||
this.instance.renderToScreen = this.renderToScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Not all passes have setSize, but this is just a safety function in case someone calls setSize on a pass component
|
|
||||||
* @param property
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass.prototype.setSize = function(property) {
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.Pass to GameLib.D3.API.Pass
|
|
||||||
* @returns {GameLib.D3.API.Pass}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiPass = new GameLib.D3.API.Pass(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
this.passType,
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity),
|
|
||||||
this.renderToScreen
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiPass;
|
|
||||||
};
|
|
|
@ -1,130 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Pass.Render
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiPassRender GameLib.D3.API.Pass.Render
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass.Render = function (
|
|
||||||
graphics,
|
|
||||||
apiPassRender
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiPassRender)) {
|
|
||||||
apiPassRender = {
|
|
||||||
passType : GameLib.D3.API.Pass.PASS_TYPE_RENDER
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Pass.Render.call(
|
|
||||||
this,
|
|
||||||
apiPassRender,
|
|
||||||
apiPassRender.scene,
|
|
||||||
apiPassRender.camera
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.scene instanceof GameLib.D3.API.Scene) {
|
|
||||||
this.scene = new GameLib.D3.Scene(
|
|
||||||
this.graphics,
|
|
||||||
this.scene
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.camera instanceof GameLib.D3.API.Camera) {
|
|
||||||
this.camera = new GameLib.D3.Camera(
|
|
||||||
this.graphics,
|
|
||||||
this.camera
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Pass.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Pass.Render.prototype = Object.create(GameLib.D3.Pass.prototype);
|
|
||||||
GameLib.D3.Pass.Render.prototype.constructor = GameLib.D3.Pass.Render;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Pass.Render instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass.Render.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.scene) ||
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.scene.instance)
|
|
||||||
) {
|
|
||||||
console.warn('scene not ready');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.camera) ||
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.camera.instance)
|
|
||||||
) {
|
|
||||||
console.warn('camera not ready');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance = new THREE.RenderPass(
|
|
||||||
this.scene.instance,
|
|
||||||
this.camera.instance
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('Constructed a render pass instance');
|
|
||||||
|
|
||||||
GameLib.D3.Pass.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Pass.Render instance
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass.Render.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (property === 'scene') {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
|
||||||
this.createInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.instance && this.scene.instance) {
|
|
||||||
this.instance.scene = this.scene.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property === 'camera') {
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
|
|
||||||
this.createInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.instance && this.camera.instance) {
|
|
||||||
this.instance.camera = this.camera.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Pass.prototype.updateInstance.call(this, property);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.Pass.Render to GameLib.D3.API.Pass.Render
|
|
||||||
* @returns {GameLib.D3.API.Pass.Render}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Pass.Render.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiPass = GameLib.D3.Pass.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
var apiRenderPass = new GameLib.D3.API.Pass.Render(
|
|
||||||
apiPass,
|
|
||||||
GameLib.Utils.IdOrNull(this.scene),
|
|
||||||
GameLib.Utils.IdOrNull(this.camera)
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiRenderPass;
|
|
||||||
};
|
|
|
@ -1,173 +0,0 @@
|
||||||
/**
|
|
||||||
* RaycastVehicle Runtime
|
|
||||||
* @param physics GameLib.GraphicsRuntime
|
|
||||||
* @param apiRaycastVehicle GameLib.D3.API.RaycastVehicle
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.RaycastVehicle = function (
|
|
||||||
physics,
|
|
||||||
apiRaycastVehicle
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.physics = physics;
|
|
||||||
this.physics.isNotCannonThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiRaycastVehicle)) {
|
|
||||||
apiRaycastVehicle = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.RaycastVehicle.call(
|
|
||||||
this,
|
|
||||||
apiRaycastVehicle.id,
|
|
||||||
apiRaycastVehicle.name,
|
|
||||||
apiRaycastVehicle.chassis,
|
|
||||||
apiRaycastVehicle.wheels,
|
|
||||||
apiRaycastVehicle.raycastWheels,
|
|
||||||
apiRaycastVehicle.parentPhysicsWorld,
|
|
||||||
apiRaycastVehicle.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.chassis instanceof GameLib.D3.API.RaycastVehicle) {
|
|
||||||
this.chassis = new GameLib.D3.RaycastVehicle(
|
|
||||||
this.physics,
|
|
||||||
this.chassis
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.wheels = this.wheels.map(function(wheel){
|
|
||||||
if (wheel instanceof GameLib.D3.API.RigidBody) {
|
|
||||||
return new GameLib.D3.RigidBody(
|
|
||||||
this.physics,
|
|
||||||
wheel
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return wheel;
|
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
this.raycastWheels = this.raycastWheels.map(function(raycastWheel){
|
|
||||||
if (raycastWheel instanceof GameLib.D3.API.RaycastWheel) {
|
|
||||||
return new GameLib.D3.RaycastWheel(
|
|
||||||
this.physics,
|
|
||||||
raycastWheel
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return raycastWheel;
|
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
{
|
|
||||||
'chassis' : GameLib.D3.RigidBody,
|
|
||||||
'wheels' : [GameLib.D3.RigidBody],
|
|
||||||
'raycastWheels' : [GameLib.D3.RaycastWheel],
|
|
||||||
'parentPhysicsWorld' : GameLib.D3.PhysicsWorld
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.RaycastVehicle.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.D3.RaycastVehicle.prototype.constructor = GameLib.D3.RaycastVehicle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* At this point - even though this component exists - the chassis could maybe not been have assigned, failed to
|
|
||||||
* register as a dependency, and therefore is not present at the time of createInstance() - we will need to call
|
|
||||||
* delayedInstance somehow...
|
|
||||||
* @type {GameLib.D3.RaycastVehicle|GameLib.D3.API.RaycastVehicle|*}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.chassis)) {
|
|
||||||
throw new Error('no chassis');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.chassis.instance)) {
|
|
||||||
throw new Error('no chassis instance');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.parentPhysicsWorld)) {
|
|
||||||
throw new Error('no parent world');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.parentPhysicsWorld.instance)) {
|
|
||||||
throw new Error('no parent world instance');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance = new CANNON.RaycastVehicle({
|
|
||||||
chassisBody: this.chassis.instance
|
|
||||||
});
|
|
||||||
|
|
||||||
this.raycastWheels.map(
|
|
||||||
function(wheel){
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(wheel)) {
|
|
||||||
throw new Error('no wheel');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(wheel.instance)) {
|
|
||||||
throw new Error('no wheel instance');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.instance.addWheel(wheel.instance);
|
|
||||||
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.instance.addToWorld(this.parentPhysicsWorld.instance);
|
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.RaycastVehicle.prototype.updateInstance = function(property) {
|
|
||||||
// this.instance.chassisBody = this.chassis.instance;
|
|
||||||
//TODO: add / remove wheels?
|
|
||||||
console.log('TODO: update raycast vehicle instance');
|
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.RaycastVehicle to GameLib.D3.API.RaycastVehicle
|
|
||||||
* @returns {GameLib.D3.API.RaycastVehicle}
|
|
||||||
*/
|
|
||||||
GameLib.D3.RaycastVehicle.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiRaycastVehicle = new GameLib.D3.API.RaycastVehicle(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
GameLib.Utils.IdOrNull(this.chassis),
|
|
||||||
this.wheels.map(function(wheel){
|
|
||||||
return GameLib.Utils.IdOrNull(wheel);
|
|
||||||
}),
|
|
||||||
this.raycastWheels.map(function(raycastWheel){
|
|
||||||
return GameLib.Utils.IdOrNull(raycastWheel);
|
|
||||||
}),
|
|
||||||
GameLib.Utils.IdOrNull(this.parentPhysicsWorld),
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiRaycastVehicle;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameLib.D3.RaycastVehicle from Object RaycastVehicle
|
|
||||||
* @param physics
|
|
||||||
* @param objectComponent
|
|
||||||
* @returns {GameLib.D3.RaycastVehicle}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.RaycastVehicle.FromObject = function(physics, objectComponent) {
|
|
||||||
|
|
||||||
var apiRaycastVehicle = GameLib.D3.API.RaycastVehicle.FromObject(objectComponent);
|
|
||||||
|
|
||||||
return new GameLib.D3.RaycastVehicle(
|
|
||||||
physics,
|
|
||||||
apiRaycastVehicle
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,73 +0,0 @@
|
||||||
/**
|
|
||||||
* Renders a scene with a camera
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiRenderTargetCube GameLib.D3.API.RenderTarget.Cube
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.RenderTarget.Cube = function (
|
|
||||||
graphics,
|
|
||||||
apiRenderTargetCube
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiRenderTargetCube)) {
|
|
||||||
apiRenderTargetCube = {
|
|
||||||
renderTargetType : GameLib.D3.API.RenderTarget.TARGET_TYPE_CUBE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.RenderTarget.Cube.call(
|
|
||||||
this,
|
|
||||||
apiRenderTargetCube
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.RenderTarget.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.RenderTarget.Cube.prototype = Object.create(GameLib.D3.RenderTarget.prototype);
|
|
||||||
GameLib.D3.RenderTarget.Cube.prototype.constructor = GameLib.D3.RenderTarget.Cube;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a Render Target instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.RenderTarget.Cube.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
this.instance = new THREE.WebGLRenderTargetCube(
|
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.textureParameters
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.RenderTarget.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updates instance
|
|
||||||
*/
|
|
||||||
GameLib.D3.RenderTarget.Cube.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.D3.RenderTarget.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render Target to API Render Target
|
|
||||||
* @returns {GameLib.D3.API.RenderTarget.Cube}
|
|
||||||
*/
|
|
||||||
GameLib.D3.RenderTarget.Cube.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiRenderTarget = GameLib.D3.RenderTarget.prototype.toApiObject.call(
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
var apiRenderTargetCube = new GameLib.D3.API.RenderTarget.Cube(
|
|
||||||
apiRenderTarget
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiRenderTargetCube;
|
|
||||||
};
|
|
|
@ -1,59 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Shader.Fragment
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiFragmentShader
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shader.Fragment = function(
|
|
||||||
graphics,
|
|
||||||
apiFragmentShader
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiFragmentShader)) {
|
|
||||||
apiFragmentShader = {
|
|
||||||
shaderType : GameLib.D3.API.Shader.SHADER_TYPE_FRAGMENT
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Shader.Fragment.call(
|
|
||||||
this,
|
|
||||||
apiFragmentShader
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.Shader.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
apiFragmentShader
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shader.Fragment.prototype = Object.create(GameLib.D3.Shader.prototype);
|
|
||||||
GameLib.D3.Shader.Fragment.prototype.constructor = GameLib.D3.Shader.Fragment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a shader instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shader.Fragment.prototype.createInstance = function() {
|
|
||||||
GameLib.D3.Shader.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shader.Fragment.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.D3.Shader.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Shader to a GameLib.D3.API.Shader
|
|
||||||
* @returns {GameLib.D3.API.Shader}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shader.Fragment.prototype.toApiObject = function() {
|
|
||||||
var apiShader = GameLib.D3.Shader.prototype.toApiObject.call(this);
|
|
||||||
return apiShader;
|
|
||||||
};
|
|
|
@ -1,59 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Shader.Vertex
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiVertexShader
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shader.Vertex = function(
|
|
||||||
graphics,
|
|
||||||
apiVertexShader
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiVertexShader)) {
|
|
||||||
apiVertexShader = {
|
|
||||||
shaderType : GameLib.D3.API.Shader.SHADER_TYPE_VERTEX
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Shader.Vertex.call(
|
|
||||||
this,
|
|
||||||
apiVertexShader
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.Shader.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
apiVertexShader
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shader.Vertex.prototype = Object.create(GameLib.D3.Shader.prototype);
|
|
||||||
GameLib.D3.Shader.Vertex.prototype.constructor = GameLib.D3.Shader.Vertex;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a shader instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shader.Vertex.prototype.createInstance = function() {
|
|
||||||
GameLib.D3.Shader.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shader.Vertex.prototype.updateInstance = function(property) {
|
|
||||||
GameLib.D3.Shader.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Shader to a GameLib.D3.API.Shader
|
|
||||||
* @returns {GameLib.D3.API.Shader}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shader.Vertex.prototype.toApiObject = function() {
|
|
||||||
var apiShader = GameLib.D3.Shader.prototype.toApiObject.call(this);
|
|
||||||
return apiShader;
|
|
||||||
};
|
|
|
@ -1,90 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Shadow.Directional
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiDirectionalShadow
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shadow.Directional = function(
|
|
||||||
graphics,
|
|
||||||
apiDirectionalShadow
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiDirectionalShadow)) {
|
|
||||||
apiDirectionalShadow = {
|
|
||||||
shadowType : GameLib.D3.API.Shadow.SHADOW_TYPE_DIRECTIONAL
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Shadow.Directional.call(
|
|
||||||
this,
|
|
||||||
apiDirectionalShadow
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.camera instanceof GameLib.D3.API.Camera.Orthographic) {
|
|
||||||
this.camera = new GameLib.D3.Camera.Orthographic(
|
|
||||||
this.graphics,
|
|
||||||
this.camera
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.Directional.prototype = Object.create(GameLib.D3.Shadow.prototype);
|
|
||||||
GameLib.D3.Shadow.Directional.prototype.constructor = GameLib.D3.Shadow.Directional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a shadow instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shadow.Directional.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
this.instance = {};
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shadow.Directional.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (property === 'camera') {
|
|
||||||
|
|
||||||
//console.warn('todo: updateInstance for directional shadow camera instance');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Shadow to a GameLib.D3.API.Shadow
|
|
||||||
* @returns {GameLib.D3.API.Shadow}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shadow.Directional.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiShadow = GameLib.D3.Shadow.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
var apiDirectionalShadow = new GameLib.D3.API.Shadow.Directional(
|
|
||||||
apiShadow
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiDirectionalShadow;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.Directional.prototype.updateFromInstance = function() {
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.prototype.updateFromInstance.call(this);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,83 +0,0 @@
|
||||||
/**
|
|
||||||
* GameLib.D3.Shadow.Spot
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param apiSpotShadow
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shadow.Spot = function(
|
|
||||||
graphics,
|
|
||||||
apiSpotShadow
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.graphics = graphics;
|
|
||||||
this.graphics.isNotThreeThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiSpotShadow)) {
|
|
||||||
apiSpotShadow = {
|
|
||||||
shadowType : GameLib.D3.API.Shadow.SHADOW_TYPE_SPOT
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Shadow.Spot.call(
|
|
||||||
this,
|
|
||||||
apiSpotShadow
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.camera instanceof GameLib.D3.API.Camera.Perspective) {
|
|
||||||
this.camera = new GameLib.D3.Camera.Perspective(
|
|
||||||
this.graphics,
|
|
||||||
this.camera
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.call(
|
|
||||||
this,
|
|
||||||
this.graphics,
|
|
||||||
apiSpotShadow
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.Spot.prototype = Object.create(GameLib.D3.Shadow.prototype);
|
|
||||||
GameLib.D3.Shadow.Spot.prototype.constructor = GameLib.D3.Shadow.Spot;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a shadow instance
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shadow.Spot.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
this.instance = {};
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the instance with the current state
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shadow.Spot.prototype.updateInstance = function(property) {
|
|
||||||
|
|
||||||
if (property === 'camera') {
|
|
||||||
|
|
||||||
console.warn('todo: updateInstance for spot shadow camera instance');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Shadow.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Shadow to a GameLib.D3.API.Shadow
|
|
||||||
* @returns {GameLib.D3.API.Shadow}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shadow.Spot.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiShadow = GameLib.D3.Shadow.prototype.toApiObject.call(this);
|
|
||||||
|
|
||||||
var apiSpotShadow = new GameLib.D3.API.Shadow.Spot(
|
|
||||||
apiShadow
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiSpotShadow;
|
|
||||||
};
|
|
|
@ -1,108 +0,0 @@
|
||||||
/**
|
|
||||||
* Shape Superset - The apiShape properties get moved into the Shape object itself, and then the instance is created
|
|
||||||
* @param physics GameLib.PhysicsRuntime
|
|
||||||
* @param apiShape GameLib.D3.API.Shape
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape = function (
|
|
||||||
physics,
|
|
||||||
apiShape
|
|
||||||
) {
|
|
||||||
this.physics = physics;
|
|
||||||
this.physics.isNotCannonThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
|
|
||||||
apiShape = {
|
|
||||||
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_NONE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.API.Shape.call(
|
|
||||||
this,
|
|
||||||
apiShape.id,
|
|
||||||
apiShape.name,
|
|
||||||
apiShape.shapeType,
|
|
||||||
apiShape.boundingSphereRadius,
|
|
||||||
apiShape.collisionResponse,
|
|
||||||
apiShape.frictionMaterial,
|
|
||||||
apiShape.parentMesh,
|
|
||||||
apiShape.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
var linkedObjects = {
|
|
||||||
frictionMaterial : GameLib.D3.FrictionMaterial,
|
|
||||||
parentMesh : GameLib.D3.Mesh
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
linkedObjects
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.prototype = Object.create(GameLib.Component.prototype);
|
|
||||||
GameLib.D3.Shape.prototype.constructor = GameLib.D3.Shape;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a shape instance or updates it
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape.prototype.createInstance = function() {
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the mesh instance
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape.prototype.updateInstance = function(property) {
|
|
||||||
throw new Error('Do not instantiate this class directly - use a child class instead');
|
|
||||||
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a GameLib.D3.Shape to a GameLib.D3.API.Shape
|
|
||||||
* @returns {GameLib.D3.API.Shape}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape.prototype.toApiObject = function() {
|
|
||||||
|
|
||||||
var apiShape = new GameLib.D3.API.Shape(
|
|
||||||
this.id,
|
|
||||||
this.name,
|
|
||||||
this.shapeType,
|
|
||||||
this.boundingSphereRadius,
|
|
||||||
this.collisionResponse,
|
|
||||||
GameLib.Utils.IdOrNull(this.frictionMaterial),
|
|
||||||
GameLib.Utils.IdOrNull(this.parentMesh),
|
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
||||||
);
|
|
||||||
|
|
||||||
return apiShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a standard object mesh to a GameLib.D3.Shape
|
|
||||||
* @param physics GameLib.PhysicsRuntime
|
|
||||||
* @param objectShape {Object}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape.FromObject = function(physics, objectShape) {
|
|
||||||
throw ('not implemented');
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.prototype.stopVisualize = function() {
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.STOP_VISUALIZE,
|
|
||||||
{
|
|
||||||
mesh : this.mesh
|
|
||||||
}
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.prototype.visualize = function() {
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.VISUALIZE,
|
|
||||||
{
|
|
||||||
shape : this
|
|
||||||
}
|
|
||||||
)
|
|
||||||
};
|
|
|
@ -1,53 +0,0 @@
|
||||||
/**
|
|
||||||
* Shape Superset - The apiShape properties get moved into the Shape object itself, and then the instance is created
|
|
||||||
* @param physics
|
|
||||||
* @param apiShape GameLib.D3.API.Shape
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape.Plane = function (
|
|
||||||
physics,
|
|
||||||
apiShape
|
|
||||||
) {
|
|
||||||
this.physics = physics;
|
|
||||||
this.physics.isNotCannonThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
|
|
||||||
apiShape = {
|
|
||||||
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_PLANE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Shape.call(
|
|
||||||
this,
|
|
||||||
this.physics,
|
|
||||||
apiShape
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.Plane.prototype = Object.create(GameLib.D3.Shape.prototype);
|
|
||||||
GameLib.D3.Shape.Plane.prototype.constructor = GameLib.D3.Shape.Plane;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {GameLib.D3.Shape.Plane|*|SEA3D.Plane}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape.Plane.prototype.createInstance = function() {
|
|
||||||
/**
|
|
||||||
* A plane is just a plane at z = 0, to rotate it put it inside a rigid body and rotate the body
|
|
||||||
*/
|
|
||||||
this.instance = new CANNON.Plane();
|
|
||||||
GameLib.D3.Shape.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.Plane.prototype.updateInstance = function() {
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.Plane.FromObject = function(physics, objectShape) {
|
|
||||||
|
|
||||||
var apiShape = GameLib.D3.API.Shape.FromObject(objectShape);
|
|
||||||
|
|
||||||
return new GameLib.D3.Shape.Plane(
|
|
||||||
physics,
|
|
||||||
apiShape
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -1,71 +0,0 @@
|
||||||
/**
|
|
||||||
* Shape Superset - The apiShape properties get moved into the Shape object itself, and then the instance is created
|
|
||||||
* @param physics
|
|
||||||
* @param apiShape GameLib.D3.API.Shape
|
|
||||||
* @param radius
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape.Sphere = function (
|
|
||||||
physics,
|
|
||||||
apiShape,
|
|
||||||
radius
|
|
||||||
) {
|
|
||||||
this.physics = physics;
|
|
||||||
this.physics.isNotCannonThrow();
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
|
|
||||||
apiShape = {
|
|
||||||
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(radius)) {
|
|
||||||
radius = 1;
|
|
||||||
}
|
|
||||||
this.radius = radius;
|
|
||||||
|
|
||||||
GameLib.D3.Shape.call(
|
|
||||||
this,
|
|
||||||
this.physics,
|
|
||||||
apiShape
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.Sphere.prototype = Object.create(GameLib.D3.Shape.prototype);
|
|
||||||
GameLib.D3.Shape.Sphere.prototype.constructor = GameLib.D3.Shape.Sphere;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {GameLib.D3.Shape.Sphere|*|SEA3D.Sphere}
|
|
||||||
*/
|
|
||||||
GameLib.D3.Shape.Sphere.prototype.createInstance = function() {
|
|
||||||
|
|
||||||
this.instance = new CANNON.Sphere(
|
|
||||||
this.radius
|
|
||||||
);
|
|
||||||
|
|
||||||
GameLib.D3.Shape.prototype.createInstance.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.Sphere.prototype.updateInstance = function() {
|
|
||||||
this.instance.radius = this.radius;
|
|
||||||
this.instance.updateBoundingSphereRadius();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Shape.Sphere.prototype.toApiObject = function() {
|
|
||||||
var apiShape = GameLib.D3.Shape.prototype.toApiObject.call(this);
|
|
||||||
apiShape.radius = this.radius;
|
|
||||||
return apiShape;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.Shape.Sphere.FromObject = function(physics, objectShape) {
|
|
||||||
|
|
||||||
var apiShape = GameLib.D3.API.Shape.FromObject(objectShape);
|
|
||||||
|
|
||||||
return new GameLib.D3.Shape.Sphere(
|
|
||||||
physics,
|
|
||||||
apiShape,
|
|
||||||
objectShape.radius
|
|
||||||
);
|
|
||||||
};
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue