/** * 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(name)) { name = 'Shadow (' + id + ')'; } this.name = name; if (GameLib.Utils.UndefinedOrNull(shadowType)) { shadowType = GameLib.D3.API.Shadow.SHADOW_TYPE_NORMAL; } this.shadowType = shadowType; if (GameLib.Utils.UndefinedOrNull(camera)) { camera = new GameLib.D3.API.Camera.Perspective( { 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;