points material, raw shader, fixed aspect ratios for orthographic cams
parent
e06f7094ce
commit
3b18b59852
|
@ -397,8 +397,10 @@ GameLib.Component.SHADER = 0x9e;
|
||||||
GameLib.Component.SHADER_VERTEX = 0x9f;
|
GameLib.Component.SHADER_VERTEX = 0x9f;
|
||||||
GameLib.Component.SHADER_FRAGMENT = 0xa0;
|
GameLib.Component.SHADER_FRAGMENT = 0xa0;
|
||||||
GameLib.Component.GEOMETRY_BUFFER_INSTANCED = 0xa1;
|
GameLib.Component.GEOMETRY_BUFFER_INSTANCED = 0xa1;
|
||||||
|
GameLib.Component.MATERIAL_SHADER_RAW = 0xa2;
|
||||||
|
GameLib.Component.MATERIAL_POINTS = 0xa3;
|
||||||
|
|
||||||
GameLib.Component.MAX_COMPONENTS = 0xa2;
|
GameLib.Component.MAX_COMPONENTS = 0xa4;
|
||||||
|
|
||||||
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
|
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
|
||||||
GameLib.Component.PHYSICS_RUNTIME = 0x2;
|
GameLib.Component.PHYSICS_RUNTIME = 0x2;
|
||||||
|
@ -1385,6 +1387,18 @@ GameLib.Component.GetComponentInfo = function(number) {
|
||||||
constructor : GameLib.D3.Geometry.Buffer.Instanced,
|
constructor : GameLib.D3.Geometry.Buffer.Instanced,
|
||||||
apiConstructor : GameLib.D3.API.Geometry.Buffer.Instanced
|
apiConstructor : GameLib.D3.API.Geometry.Buffer.Instanced
|
||||||
};
|
};
|
||||||
|
case 0xa2 : return {
|
||||||
|
name : 'GameLib.D3.Material.Shader.Raw',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Material.Shader.Raw,
|
||||||
|
apiConstructor : GameLib.D3.API.Material.Shader.Raw
|
||||||
|
};
|
||||||
|
case 0xa3 : return {
|
||||||
|
name : 'GameLib.D3.Material.Points',
|
||||||
|
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
||||||
|
constructor : GameLib.D3.Material.Points,
|
||||||
|
apiConstructor : GameLib.D3.API.Material.Points
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ GameLib.Controls.prototype.updateInstance = function(property) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('default controls update instance');
|
GameLib.Component.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -98,7 +98,7 @@ GameLib.Controls.D3.Editor.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
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');
|
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);
|
GameLib.Controls.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,8 +46,8 @@ GameLib.Controls.Keyboard.prototype.createInstance = function() {
|
||||||
/**
|
/**
|
||||||
* Update Instance
|
* Update Instance
|
||||||
*/
|
*/
|
||||||
GameLib.Controls.Keyboard.prototype.updateInstance = function() {
|
GameLib.Controls.Keyboard.prototype.updateInstance = function(property) {
|
||||||
GameLib.Controls.prototype.updateInstance.call(this);
|
GameLib.Controls.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,8 +47,8 @@ GameLib.Controls.Touch.prototype.createInstance = function() {
|
||||||
/**
|
/**
|
||||||
* Update Instance
|
* Update Instance
|
||||||
*/
|
*/
|
||||||
GameLib.Controls.Touch.prototype.updateInstance = function() {
|
GameLib.Controls.Touch.prototype.updateInstance = function(property) {
|
||||||
GameLib.Controls.prototype.updateInstance.call(this);
|
GameLib.Controls.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,7 +58,6 @@ GameLib.D3.API.Camera = function(
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(aspect)) {
|
if (GameLib.Utils.UndefinedOrNull(aspect)) {
|
||||||
//aspect = new GameLib.API.Number(1, 0.001, 0, 5);
|
|
||||||
aspect = 1;
|
aspect = 1;
|
||||||
}
|
}
|
||||||
this.aspect = aspect;
|
this.aspect = aspect;
|
||||||
|
@ -91,9 +90,21 @@ GameLib.D3.API.Camera = function(
|
||||||
}
|
}
|
||||||
this.quaternion = quaternion;
|
this.quaternion = quaternion;
|
||||||
|
|
||||||
|
GameLib.API.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.D3.API.Camera.GetComponentType(this.cameraType),
|
||||||
|
parentEntity
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Camera.prototype = Object.create(GameLib.API.Component.prototype);
|
||||||
|
GameLib.D3.API.Camera.prototype.constructor = GameLib.D3.API.Camera;
|
||||||
|
|
||||||
|
GameLib.D3.API.Camera.GetComponentType = function(cameraType) {
|
||||||
|
|
||||||
var componentType = null;
|
var componentType = null;
|
||||||
|
|
||||||
switch (this.cameraType) {
|
switch (cameraType) {
|
||||||
case GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE :
|
case GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE :
|
||||||
componentType = GameLib.Component.CAMERA_PERSPECTIVE;
|
componentType = GameLib.Component.CAMERA_PERSPECTIVE;
|
||||||
break;
|
break;
|
||||||
|
@ -107,20 +118,16 @@ GameLib.D3.API.Camera = function(
|
||||||
componentType = GameLib.Component.CAMERA_CUBE;
|
componentType = GameLib.Component.CAMERA_CUBE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('unsupported camera type: ' + this.cameraType);
|
throw new Error('unsupported camera type: ' + cameraType);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
return componentType;
|
||||||
this,
|
|
||||||
componentType,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.prototype = Object.create(GameLib.API.Component.prototype);
|
};
|
||||||
GameLib.D3.API.Camera.prototype.constructor = GameLib.D3.API.Camera;
|
|
||||||
|
|
||||||
GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE = 0x1;
|
GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE = 0x1;
|
||||||
GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC = 0x2;
|
GameLib.D3.API.Camera.CAMERA_TYPE_ORTHOGRAPHIC = 0x2;
|
||||||
GameLib.D3.API.Camera.CAMERA_TYPE_STEREO = 0x3;
|
GameLib.D3.API.Camera.CAMERA_TYPE_STEREO = 0x3;
|
||||||
GameLib.D3.API.Camera.CAMERA_TYPE_CUBE = 0x4;
|
GameLib.D3.API.Camera.CAMERA_TYPE_CUBE = 0x4;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param apiCamera
|
* @param apiCamera
|
||||||
|
* @param aspectRatioMode
|
||||||
* @param width
|
* @param width
|
||||||
|
* @param height
|
||||||
* @param near
|
* @param near
|
||||||
* @param far
|
* @param far
|
||||||
* @param left
|
* @param left
|
||||||
|
@ -28,7 +30,11 @@
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.Camera.Orthographic = function(
|
GameLib.D3.API.Camera.Orthographic = function(
|
||||||
apiCamera,
|
apiCamera,
|
||||||
|
aspectRatioMode,
|
||||||
|
minWidth,
|
||||||
|
minHeight,
|
||||||
width,
|
width,
|
||||||
|
height,
|
||||||
near,
|
near,
|
||||||
far,
|
far,
|
||||||
left,
|
left,
|
||||||
|
@ -56,50 +62,67 @@ GameLib.D3.API.Camera.Orthographic = function(
|
||||||
apiCamera.lookAt = new GameLib.API.Vector3(0,0,-1);
|
apiCamera.lookAt = new GameLib.API.Vector3(0,0,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(aspectRatioMode)) {
|
||||||
|
aspectRatioMode = GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_BASED_ON_CURRENT;
|
||||||
|
}
|
||||||
|
this.aspectRatioMode = aspectRatioMode;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(minWidth)) {
|
||||||
|
minWidth = 10;
|
||||||
|
}
|
||||||
|
this.minWidth = minWidth;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(minHeight)) {
|
||||||
|
minHeight = 10;
|
||||||
|
}
|
||||||
|
this.minHeight = minHeight;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(height)) {
|
||||||
|
height = 10;
|
||||||
|
}
|
||||||
|
this.height = height;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(width)) {
|
if (GameLib.Utils.UndefinedOrNull(width)) {
|
||||||
//width = GameLib.API.Number(10, 1, 1, 2000);
|
|
||||||
width = 10;
|
width = 10;
|
||||||
}
|
}
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(height)) {
|
||||||
|
height = 10;
|
||||||
|
}
|
||||||
|
this.height = height;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(near)) {
|
if (GameLib.Utils.UndefinedOrNull(near)) {
|
||||||
//near = GameLib.API.Number(0.1, 0, 0.1, 2000);
|
|
||||||
near = 0.1;
|
near = 0.1;
|
||||||
}
|
}
|
||||||
this.near = near;
|
this.near = near;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(far)) {
|
if (GameLib.Utils.UndefinedOrNull(far)) {
|
||||||
// far = GameLib.API.Number(2000, 0, 0.1, 4000);
|
|
||||||
far = 2000;
|
far = 2000;
|
||||||
}
|
}
|
||||||
this.far = far;
|
this.far = far;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(left)) {
|
if (GameLib.Utils.UndefinedOrNull(left)) {
|
||||||
// left = GameLib.API.Number(-5, 1, -2000, 0);
|
|
||||||
left = -5;
|
left = -5;
|
||||||
}
|
}
|
||||||
this.left = left;
|
this.left = left;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(right)) {
|
if (GameLib.Utils.UndefinedOrNull(right)) {
|
||||||
//right = GameLib.API.Number(5, 1, 0, 2000);
|
|
||||||
right = 5;
|
right = 5;
|
||||||
}
|
}
|
||||||
this.right = right;
|
this.right = right;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(top)) {
|
if (GameLib.Utils.UndefinedOrNull(top)) {
|
||||||
//top = GameLib.API.Number(5, 1, 0, 2000);
|
|
||||||
top = 5;
|
top = 5;
|
||||||
}
|
}
|
||||||
this.top = top;
|
this.top = top;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(bottom)) {
|
if (GameLib.Utils.UndefinedOrNull(bottom)) {
|
||||||
// bottom = GameLib.API.Number(-5, 1, -2000, 0);
|
|
||||||
bottom = -5;
|
bottom = -5;
|
||||||
}
|
}
|
||||||
this.bottom = bottom;
|
this.bottom = bottom;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(zoom)) {
|
if (GameLib.Utils.UndefinedOrNull(zoom)) {
|
||||||
// zoom = new GameLib.API.Number(1, 0.01, 0, 10);
|
|
||||||
zoom = 1;
|
zoom = 1;
|
||||||
}
|
}
|
||||||
this.zoom = zoom;
|
this.zoom = zoom;
|
||||||
|
@ -120,3 +143,7 @@ GameLib.D3.API.Camera.Orthographic = function(
|
||||||
|
|
||||||
GameLib.D3.API.Camera.Orthographic.prototype = Object.create(GameLib.D3.API.Camera.prototype);
|
GameLib.D3.API.Camera.Orthographic.prototype = Object.create(GameLib.D3.API.Camera.prototype);
|
||||||
GameLib.D3.API.Camera.Orthographic.prototype.constructor = GameLib.D3.API.Camera.Orthographic;
|
GameLib.D3.API.Camera.Orthographic.prototype.constructor = GameLib.D3.API.Camera.Orthographic;
|
||||||
|
|
||||||
|
GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_NONE = 0x0;
|
||||||
|
GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_FIXED = 0x1;
|
||||||
|
GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_BASED_ON_CURRENT = 0x2;
|
||||||
|
|
|
@ -106,6 +106,12 @@ GameLib.D3.API.Material = function(
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER :
|
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER :
|
||||||
name = 'Material Shader';
|
name = 'Material Shader';
|
||||||
break;
|
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 :
|
default :
|
||||||
console.warn('no nice name for material');
|
console.warn('no nice name for material');
|
||||||
name = 'Material';
|
name = 'Material';
|
||||||
|
@ -219,7 +225,9 @@ GameLib.D3.API.Material = function(
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.materialType === GameLib.D3.API.Material.MATERIAL_TYPE_BASIC ||
|
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 ||
|
||||||
|
this.materialType === GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW ||
|
||||||
|
this.materialType === GameLib.D3.API.Material.MATERIAL_TYPE_POINTS
|
||||||
) {
|
) {
|
||||||
lights = false;
|
lights = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -322,6 +330,12 @@ GameLib.D3.API.Material.GetComponentType = function(materialType) {
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER :
|
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER :
|
||||||
componentType = GameLib.Component.MATERIAL_SHADER;
|
componentType = GameLib.Component.MATERIAL_SHADER;
|
||||||
break;
|
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 :
|
default :
|
||||||
throw new Error('unhandled material type: ' + materialType);
|
throw new Error('unhandled material type: ' + materialType);
|
||||||
}
|
}
|
||||||
|
@ -431,6 +445,7 @@ GameLib.D3.API.Material.MATERIAL_TYPE_POINTS = 0x9;
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_SPRITE = 0xa;
|
GameLib.D3.API.Material.MATERIAL_TYPE_SPRITE = 0xa;
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_TOON = 0xb;
|
GameLib.D3.API.Material.MATERIAL_TYPE_TOON = 0xb;
|
||||||
GameLib.D3.API.Material.MATERIAL_TYPE_SHADER = 0xc;
|
GameLib.D3.API.Material.MATERIAL_TYPE_SHADER = 0xc;
|
||||||
|
GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW = 0xd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Line Cap
|
* Line Cap
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Material.Points
|
||||||
|
* @param apiMaterial
|
||||||
|
* @param color
|
||||||
|
* @param diffuseMap
|
||||||
|
* @param size
|
||||||
|
* @param sizeAttenuation
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Material.Points = function(
|
||||||
|
apiMaterial,
|
||||||
|
color,
|
||||||
|
diffuseMap,
|
||||||
|
size,
|
||||||
|
sizeAttenuation
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterial)) {
|
||||||
|
apiMaterial = {
|
||||||
|
materialType: GameLib.D3.API.Material.MATERIAL_TYPE_POINTS
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterial.materialType)) {
|
||||||
|
apiMaterial.materialType = GameLib.D3.API.Material.MATERIAL_TYPE_POINTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(color)) {
|
||||||
|
color = new GameLib.API.Color(1, 1, 1, 1)
|
||||||
|
}
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(diffuseMap)) {
|
||||||
|
diffuseMap = null;
|
||||||
|
}
|
||||||
|
this.diffuseMap = diffuseMap;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(size)) {
|
||||||
|
size = 1;
|
||||||
|
}
|
||||||
|
this.size = size;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(sizeAttenuation)) {
|
||||||
|
sizeAttenuation = true;
|
||||||
|
}
|
||||||
|
this.sizeAttenuation = sizeAttenuation;
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.call(
|
||||||
|
this,
|
||||||
|
apiMaterial.id,
|
||||||
|
apiMaterial.name,
|
||||||
|
apiMaterial.materialType,
|
||||||
|
apiMaterial.parentEntity,
|
||||||
|
apiMaterial.parentMeshes,
|
||||||
|
apiMaterial.alphaTest,
|
||||||
|
apiMaterial.blendDst,
|
||||||
|
apiMaterial.blendDstAlpha,
|
||||||
|
apiMaterial.blendEquation,
|
||||||
|
apiMaterial.blendEquationAlpha,
|
||||||
|
apiMaterial.blending,
|
||||||
|
apiMaterial.blendSrc,
|
||||||
|
apiMaterial.blendSrcAlpha,
|
||||||
|
apiMaterial.clipIntersection,
|
||||||
|
apiMaterial.clippingPlanes,
|
||||||
|
apiMaterial.clipShadows,
|
||||||
|
apiMaterial.colorWrite,
|
||||||
|
apiMaterial.customDepthMaterial,
|
||||||
|
apiMaterial.customDistanceMaterial,
|
||||||
|
apiMaterial.defines,
|
||||||
|
apiMaterial.depthFunc,
|
||||||
|
apiMaterial.depthTest,
|
||||||
|
apiMaterial.depthWrite,
|
||||||
|
apiMaterial.fog,
|
||||||
|
apiMaterial.lights,
|
||||||
|
apiMaterial.opacity,
|
||||||
|
apiMaterial.overdraw,
|
||||||
|
apiMaterial.polygonOffset,
|
||||||
|
apiMaterial.polygonOffsetFactor,
|
||||||
|
apiMaterial.polygonOffsetUnits,
|
||||||
|
apiMaterial.precision,
|
||||||
|
apiMaterial.premultipliedAlpha,
|
||||||
|
apiMaterial.dithering,
|
||||||
|
apiMaterial.flatShading,
|
||||||
|
apiMaterial.side,
|
||||||
|
apiMaterial.transparent,
|
||||||
|
apiMaterial.vertexColors,
|
||||||
|
apiMaterial.visible
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.Points.prototype = Object.create(GameLib.D3.API.Material.prototype);
|
||||||
|
GameLib.D3.API.Material.Points.prototype.constructor = GameLib.D3.API.Material.Points;
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.API.Material.Shader.Raw
|
||||||
|
* @param apiMaterialShader
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.API.Material.Shader.Raw = function(
|
||||||
|
apiMaterialShader
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterialShader)) {
|
||||||
|
apiMaterialShader = {
|
||||||
|
materialType: GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterialShader.materialType)) {
|
||||||
|
apiMaterialShader.materialType = GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.Shader.call(
|
||||||
|
this,
|
||||||
|
apiMaterialShader,
|
||||||
|
apiMaterialShader.clipping,
|
||||||
|
apiMaterialShader.defaultAttributeValues,
|
||||||
|
apiMaterialShader.extensions,
|
||||||
|
apiMaterialShader.fog,
|
||||||
|
apiMaterialShader.fragmentShader,
|
||||||
|
apiMaterialShader.index0AttributeName,
|
||||||
|
apiMaterialShader.linewidth,
|
||||||
|
apiMaterialShader.morphTargets,
|
||||||
|
apiMaterialShader.morphNormals,
|
||||||
|
apiMaterialShader.program,
|
||||||
|
apiMaterialShader.skinning,
|
||||||
|
apiMaterialShader.uniforms,
|
||||||
|
apiMaterialShader.vertexColors,
|
||||||
|
apiMaterialShader.vertexShader,
|
||||||
|
apiMaterialShader.wireframe,
|
||||||
|
apiMaterialShader.wireframeLinewidth
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.Shader.Raw.prototype = Object.create(GameLib.D3.API.Material.Shader.prototype);
|
||||||
|
GameLib.D3.API.Material.Shader.Raw.prototype.constructor = GameLib.D3.API.Material.Shader.Raw;
|
|
@ -63,6 +63,9 @@ GameLib.D3.API.Mesh = function(
|
||||||
if (GameLib.Utils.UndefinedOrNull(name)) {
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||||||
|
|
||||||
switch (this.meshType) {
|
switch (this.meshType) {
|
||||||
|
case GameLib.D3.API.Mesh.MESH_TYPE_NORMAL :
|
||||||
|
name = 'Mesh';
|
||||||
|
break;
|
||||||
case GameLib.D3.API.Mesh.MESH_TYPE_BOX :
|
case GameLib.D3.API.Mesh.MESH_TYPE_BOX :
|
||||||
name = 'Mesh Box';
|
name = 'Mesh Box';
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -172,6 +172,8 @@ GameLib.D3.Animation.prototype.updateInstance = function(property, item) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameLib.Component.prototype.updateInstance.call(this, property);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -111,15 +111,14 @@ GameLib.D3.Camera.prototype.createInstance = function() {
|
||||||
this.instance.aspect = this.aspect;
|
this.instance.aspect = this.aspect;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.lookAt)) {
|
/**
|
||||||
if (this.instance.isCamera) {
|
* Only do lookAt for stereo and cube cameras
|
||||||
|
*/
|
||||||
/**
|
if (
|
||||||
* For some reason - cube camera does not think it is a camera - so it does a lookAt differently -
|
this.cameraType === GameLib.D3.API.Camera.CAMERA_TYPE_STEREO ||
|
||||||
* which messes up its rotation
|
this.cameraType === GameLib.D3.API.Camera.CAMERA_TYPE_PERSPECTIVE
|
||||||
*/
|
) {
|
||||||
this.instance.lookAt(this.lookAt.instance);
|
this.instance.lookAt(this.lookAt.instance);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
if (GameLib.Utils.Defined(this.instance.updateProjectionMatrix)) {
|
||||||
|
|
|
@ -23,7 +23,11 @@ GameLib.D3.Camera.Orthographic = function(
|
||||||
GameLib.D3.API.Camera.Orthographic.call(
|
GameLib.D3.API.Camera.Orthographic.call(
|
||||||
this,
|
this,
|
||||||
apiOrthographicCamera,
|
apiOrthographicCamera,
|
||||||
|
apiOrthographicCamera.aspectRatioMode,
|
||||||
|
apiOrthographicCamera.minWidth,
|
||||||
|
apiOrthographicCamera.minHeight,
|
||||||
apiOrthographicCamera.width,
|
apiOrthographicCamera.width,
|
||||||
|
apiOrthographicCamera.height,
|
||||||
apiOrthographicCamera.near,
|
apiOrthographicCamera.near,
|
||||||
apiOrthographicCamera.far,
|
apiOrthographicCamera.far,
|
||||||
apiOrthographicCamera.left,
|
apiOrthographicCamera.left,
|
||||||
|
@ -59,6 +63,21 @@ GameLib.D3.Camera.Orthographic.prototype.createInstance = function() {
|
||||||
this.far
|
this.far
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.aspectRatioMode === GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_FIXED ||
|
||||||
|
this.aspectRatioMode === GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_BASED_ON_CURRENT
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (this.aspectRatioMode === GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_BASED_ON_CURRENT) {
|
||||||
|
|
||||||
|
var size = GameLib.Utils.GetWindowSize();
|
||||||
|
|
||||||
|
this.aspect = size.width / size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateFromAspectRatio();
|
||||||
|
}
|
||||||
|
|
||||||
GameLib.D3.Camera.prototype.createInstance.call(this);
|
GameLib.D3.Camera.prototype.createInstance.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,32 +86,53 @@ GameLib.D3.Camera.Orthographic.prototype.createInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Camera.Orthographic.prototype.updateInstance = function(property) {
|
GameLib.D3.Camera.Orthographic.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
var width, height;
|
var size;
|
||||||
|
|
||||||
if (
|
if (property === 'aspectRatioMode') {
|
||||||
property === 'width' ||
|
|
||||||
property === 'aspect'
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (!this.fixedAspectRatio) {
|
if (this.aspectRatioMode === GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_NONE) {
|
||||||
console.warn('changing the aspect ratio when this camera is not in fixedAspectRatio mode has no effect');
|
this.updateFromDimensions();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
height = this.width / this.aspect;
|
if (this.aspectRatioMode === GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_FIXED) {
|
||||||
|
this.updateFromAspectRatio();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.left = this.width / -2;
|
if (this.aspectRatioMode === GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_BASED_ON_CURRENT) {
|
||||||
this.right = this.width / 2;
|
|
||||||
|
|
||||||
this.top = height / 2;
|
size = GameLib.Utils.GetWindowSize();
|
||||||
this.bottom = height / -2;
|
|
||||||
|
|
||||||
this.instance.left = this.left;
|
this.aspect = size.width / size.height;
|
||||||
this.instance.right = this.right;
|
|
||||||
this.instance.top = this.top;
|
|
||||||
this.instance.bottom = this.bottom;
|
|
||||||
|
|
||||||
this.instance.updateProjectionMatrix();
|
this.updateFromAspectRatio();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
property === 'width' ||
|
||||||
|
property === 'height' ||
|
||||||
|
property === 'minWidth' ||
|
||||||
|
property === 'minHeight' ||
|
||||||
|
property === 'aspect'
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.aspectRatioMode !== GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_FIXED &&
|
||||||
|
this.aspectRatioMode !== GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_BASED_ON_CURRENT
|
||||||
|
) {
|
||||||
|
console.warn('changing the this value when this camera is not in the right aspect ratio mode has no effect');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.aspectRatioMode === GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_BASED_ON_CURRENT) {
|
||||||
|
size = GameLib.Utils.GetWindowSize();
|
||||||
|
this.aspect = size.width / size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateFromAspectRatio();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -103,18 +143,25 @@ GameLib.D3.Camera.Orthographic.prototype.updateInstance = function(property) {
|
||||||
property === 'top' ||
|
property === 'top' ||
|
||||||
property === 'bottom'
|
property === 'bottom'
|
||||||
) {
|
) {
|
||||||
this.instance.left = this.left;
|
|
||||||
this.instance.right = this.right;
|
|
||||||
this.instance.top = this.top;
|
|
||||||
this.instance.bottom = this.bottom;
|
|
||||||
|
|
||||||
width = this.right - this.left;
|
if (
|
||||||
height = this.top - this.bottom;
|
this.aspectRatioMode === GameLib.D3.API.Camera.ASPECT_RATIO_MODE_FIXED ||
|
||||||
|
this.aspectRatioMode === GameLib.D3.API.Camera.ASPECT_RATIO_MODE_BASED_ON_CURRENT
|
||||||
|
) {
|
||||||
|
console.warn('changing this value within a fixed aspect ratio has no effect');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateFromDimensions();
|
||||||
|
|
||||||
this.aspect = width / height;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (property === 'zoom') {
|
||||||
|
this.instance.zoom = this.zoom;
|
||||||
|
this.instance.updateProjectionMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
GameLib.D3.Camera.prototype.updateInstance.call(this, property);
|
GameLib.D3.Camera.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,7 +175,11 @@ GameLib.D3.Camera.Orthographic.prototype.toApiObject = function() {
|
||||||
|
|
||||||
var apiOrthographicCamera = new GameLib.D3.API.Camera.Orthographic(
|
var apiOrthographicCamera = new GameLib.D3.API.Camera.Orthographic(
|
||||||
apiCamera,
|
apiCamera,
|
||||||
|
this.aspectRatioMode,
|
||||||
|
this.minWidth,
|
||||||
|
this.minHeight,
|
||||||
this.width,
|
this.width,
|
||||||
|
this.height,
|
||||||
this.near,
|
this.near,
|
||||||
this.far,
|
this.far,
|
||||||
this.left,
|
this.left,
|
||||||
|
@ -142,13 +193,77 @@ GameLib.D3.Camera.Orthographic.prototype.toApiObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Camera.Orthographic.prototype.updateFromInstance = function() {
|
GameLib.D3.Camera.Orthographic.prototype.updateFromInstance = function() {
|
||||||
this.width = this.instance.right - this.instance.left;
|
this.width = this.instance.right - this.instance.left;
|
||||||
this.near = this.instance.near;
|
this.height = this.instance.top - this.instance.bottom;
|
||||||
this.far = this.instance.far;
|
this.near = this.instance.near;
|
||||||
this.left = this.instance.left;
|
this.far = this.instance.far;
|
||||||
this.right = this.instance.right;
|
this.left = this.instance.left;
|
||||||
this.top = this.instance.top;
|
this.right = this.instance.right;
|
||||||
|
this.top = this.instance.top;
|
||||||
this.bottom = this.instance.bottom;
|
this.bottom = this.instance.bottom;
|
||||||
this.zoom = this.instance.zoom;
|
this.zoom = this.instance.zoom;
|
||||||
GameLib.D3.Camera.prototype.updateFromInstance.call(this);
|
GameLib.D3.Camera.prototype.updateFromInstance.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Camera.Orthographic.prototype.updateFromAspectRatio = function() {
|
||||||
|
|
||||||
|
if (this.aspect < 1) {
|
||||||
|
/**
|
||||||
|
* Make height dependend on width
|
||||||
|
*/
|
||||||
|
this.width = this.minWidth;
|
||||||
|
this.height = this.minWidth / this.aspect;
|
||||||
|
|
||||||
|
if (this.height < this.minHeight) {
|
||||||
|
/**
|
||||||
|
* We have a problem - our new height is less than our minimum height
|
||||||
|
*/
|
||||||
|
this.height = this.minHeight;
|
||||||
|
this.width = this.aspect * this.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/**
|
||||||
|
* Make width dependend on height
|
||||||
|
*/
|
||||||
|
this.height = this.minHeight;
|
||||||
|
this.width = this.aspect * this.minHeight;
|
||||||
|
|
||||||
|
if (this.width < this.minWidth) {
|
||||||
|
/**
|
||||||
|
* We have a problem - our new width is less than our minimum width
|
||||||
|
*/
|
||||||
|
this.width = this.minWidth;
|
||||||
|
this.height = this.width / this.aspect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.left = this.width / -2;
|
||||||
|
this.right = this.width / 2;
|
||||||
|
|
||||||
|
this.top = this.height / 2;
|
||||||
|
this.bottom = this.height / -2;
|
||||||
|
|
||||||
|
this.instance.left = this.left;
|
||||||
|
this.instance.right = this.right;
|
||||||
|
this.instance.top = this.top;
|
||||||
|
this.instance.bottom = this.bottom;
|
||||||
|
|
||||||
|
this.instance.updateProjectionMatrix();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Camera.Orthographic.prototype.updateFromDimensions = function() {
|
||||||
|
|
||||||
|
this.instance.left = this.left;
|
||||||
|
this.instance.right = this.right;
|
||||||
|
this.instance.top = this.top;
|
||||||
|
this.instance.bottom = this.bottom;
|
||||||
|
|
||||||
|
this.width = this.right - this.left;
|
||||||
|
this.height = this.top - this.bottom;
|
||||||
|
|
||||||
|
this.aspect = this.width / this.height;
|
||||||
|
|
||||||
|
this.instance.updateProjectionMatrix();
|
||||||
|
};
|
|
@ -100,9 +100,13 @@ GameLib.D3.Material = function(
|
||||||
linkedObjects.specularMap = GameLib.D3.Texture;
|
linkedObjects.specularMap = GameLib.D3.Texture;
|
||||||
break;
|
break;
|
||||||
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER :
|
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER :
|
||||||
|
case GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW :
|
||||||
linkedObjects.vertexShader = GameLib.D3.Shader.Vertex;
|
linkedObjects.vertexShader = GameLib.D3.Shader.Vertex;
|
||||||
linkedObjects.fragmentShader = GameLib.D3.Shader.Fragment;
|
linkedObjects.fragmentShader = GameLib.D3.Shader.Fragment;
|
||||||
break;
|
break;
|
||||||
|
case GameLib.D3.API.Material.MATERIAL_TYPE_POINTS :
|
||||||
|
linkedObjects.diffuseMap = GameLib.D3.Texture;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
throw new Error('unhandled material type: ' + this.materialType);
|
throw new Error('unhandled material type: ' + this.materialType);
|
||||||
|
|
||||||
|
|
|
@ -41,17 +41,11 @@ GameLib.D3.Material.Basic = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.alphaMap instanceof GameLib.D3.API.Texture) {
|
if (this.alphaMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.alphaMap = new GameLib.D3.Texture(
|
this.alphaMap = GameLib.Component.ConstructFromObject(this.alphaMap);
|
||||||
this.graphics,
|
|
||||||
this.alphaMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.aoMap instanceof GameLib.D3.API.Texture) {
|
if (this.aoMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.aoMap = new GameLib.D3.Texture(
|
this.aoMap = GameLib.Component.ConstructFromObject(this.aoMap);
|
||||||
this.graphics,
|
|
||||||
this.aoMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.color = new GameLib.Color(
|
this.color = new GameLib.Color(
|
||||||
|
@ -61,31 +55,19 @@ GameLib.D3.Material.Basic = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.envMap instanceof GameLib.D3.API.Texture) {
|
if (this.envMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.envMap = new GameLib.D3.Texture(
|
this.envMap = GameLib.Component.ConstructFromObject(this.envMap);
|
||||||
this.graphics,
|
|
||||||
this.envMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lightMap instanceof GameLib.D3.API.Texture) {
|
if (this.lightMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.lightMap = new GameLib.D3.Texture(
|
this.lightMap = GameLib.Component.ConstructFromObject(this.lightMap);
|
||||||
this.graphics,
|
|
||||||
this.lightMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.diffuseMap instanceof GameLib.D3.API.Texture) {
|
if (this.diffuseMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.diffuseMap = new GameLib.D3.Texture(
|
this.diffuseMap = GameLib.Component.ConstructFromObject(this.diffuseMap);
|
||||||
this.graphics,
|
|
||||||
this.diffuseMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.specularMap instanceof GameLib.D3.API.Texture) {
|
if (this.specularMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.specularMap = new GameLib.D3.Texture(
|
this.specularMap = GameLib.Component.ConstructFromObject(this.specularMap);
|
||||||
this.graphics,
|
|
||||||
this.specularMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Material.call(
|
GameLib.D3.Material.call(
|
||||||
|
|
|
@ -54,24 +54,15 @@ GameLib.D3.Material.Phong = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.alphaMap instanceof GameLib.D3.API.Texture) {
|
if (this.alphaMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.alphaMap = new GameLib.D3.Texture(
|
this.alphaMap = GameLib.Component.ConstructFromObject(this.alphaMap);
|
||||||
this.graphics,
|
|
||||||
this.alphaMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.aoMap instanceof GameLib.D3.API.Texture) {
|
if (this.aoMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.aoMap = new GameLib.D3.Texture(
|
this.aoMap = GameLib.Component.ConstructFromObject(this.aoMap);
|
||||||
this.graphics,
|
|
||||||
this.aoMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.bumpMap instanceof GameLib.D3.API.Texture) {
|
if (this.bumpMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.bumpMap = new GameLib.D3.Texture(
|
this.bumpMap = GameLib.Component.ConstructFromObject(this.bumpMap);
|
||||||
this.graphics,
|
|
||||||
this.bumpMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.color = new GameLib.Color(
|
this.color = new GameLib.Color(
|
||||||
|
@ -81,10 +72,7 @@ GameLib.D3.Material.Phong = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.displacementMap instanceof GameLib.D3.API.Texture) {
|
if (this.displacementMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.displacementMap = new GameLib.D3.Texture(
|
this.displacementMap = GameLib.Component.ConstructFromObject(this.displacementMap);
|
||||||
this.graphics,
|
|
||||||
this.displacementMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emissive = new GameLib.Color(
|
this.emissive = new GameLib.Color(
|
||||||
|
@ -94,38 +82,23 @@ GameLib.D3.Material.Phong = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.emissiveMap instanceof GameLib.D3.API.Texture) {
|
if (this.emissiveMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.emissiveMap = new GameLib.D3.Texture(
|
this.emissiveMap = GameLib.Component.ConstructFromObject(this.emissiveMap);
|
||||||
this.graphics,
|
|
||||||
this.emissiveMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.envMap instanceof GameLib.D3.API.Texture) {
|
if (this.envMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.envMap = new GameLib.D3.Texture(
|
this.envMap = GameLib.Component.ConstructFromObject(this.envMap);
|
||||||
this.graphics,
|
|
||||||
this.envMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lightMap instanceof GameLib.D3.API.Texture) {
|
if (this.lightMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.lightMap = new GameLib.D3.Texture(
|
this.lightMap = GameLib.Component.ConstructFromObject(this.lightMap);
|
||||||
this.graphics,
|
|
||||||
this.lightMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.diffuseMap instanceof GameLib.D3.API.Texture) {
|
if (this.diffuseMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.diffuseMap = new GameLib.D3.Texture(
|
this.diffuseMap = GameLib.Component.ConstructFromObject(this.diffuseMap);
|
||||||
this.graphics,
|
|
||||||
this.diffuseMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.normalMap instanceof GameLib.D3.API.Texture) {
|
if (this.normalMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.normalMap = new GameLib.D3.Texture(
|
this.normalMap = GameLib.Component.ConstructFromObject(this.normalMap);
|
||||||
this.graphics,
|
|
||||||
this.normalMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.specular = new GameLib.Color(
|
this.specular = new GameLib.Color(
|
||||||
|
@ -135,10 +108,7 @@ GameLib.D3.Material.Phong = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.specularMap instanceof GameLib.D3.API.Texture) {
|
if (this.specularMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.specularMap = new GameLib.D3.Texture(
|
this.specularMap = GameLib.Component.ConstructFromObject(this.specularMap);
|
||||||
this.graphics,
|
|
||||||
this.specularMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Material.call(
|
GameLib.D3.Material.call(
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.Material.Points
|
||||||
|
* @param graphics
|
||||||
|
* @param apiMaterialPoints
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Points = function(
|
||||||
|
graphics,
|
||||||
|
apiMaterialPoints
|
||||||
|
) {
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterialPoints)) {
|
||||||
|
apiMaterialPoints = {
|
||||||
|
materialType : GameLib.D3.API.Material.MATERIAL_TYPE_POINTS
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.Points.call(
|
||||||
|
this,
|
||||||
|
apiMaterialPoints,
|
||||||
|
apiMaterialPoints.color,
|
||||||
|
apiMaterialPoints.diffuseMap,
|
||||||
|
apiMaterialPoints.size,
|
||||||
|
apiMaterialPoints.sizeAttenuation
|
||||||
|
);
|
||||||
|
|
||||||
|
this.color = new GameLib.Color(
|
||||||
|
this.graphics,
|
||||||
|
this.color,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.diffuseMap instanceof GameLib.D3.API.Texture) {
|
||||||
|
this.diffuseMap = GameLib.Component.ConstructFromObject(this.diffuseMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.Material.call(
|
||||||
|
this,
|
||||||
|
this.graphics,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Material.Points.prototype = Object.create(GameLib.D3.Material.prototype);
|
||||||
|
GameLib.D3.Material.Points.prototype.constructor = GameLib.D3.Material.Points;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of our texture object
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Points.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
this.instance = new THREE.PointsMaterial(
|
||||||
|
{
|
||||||
|
color : this.color.instance,
|
||||||
|
map : this.diffuseMap ? this.diffuseMap.instance : null,
|
||||||
|
size : this.size,
|
||||||
|
sizeAttenuation : this.sizeAttenuation
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.D3.Material.prototype.createInstance.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance with the current state
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Points.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
|
if (property === 'color') {
|
||||||
|
this.instance.color = this.color.instance;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'diffuseMap') {
|
||||||
|
this.assignTexture('map', property);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'size') {
|
||||||
|
this.instance.size = this.size;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'sizeAttenuation') {
|
||||||
|
this.instance.sizeAttenuation = this.sizeAttenuation;
|
||||||
|
this.instance.needsUpdate = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.Material.prototype.updateInstance.call(this, property);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Material.Points to a GameLib.D3.API.Material.Points
|
||||||
|
* @returns {GameLib.D3.API.Material.Points}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Points.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiMaterial = GameLib.D3.Material.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
|
var apiMaterialPoints = new GameLib.D3.API.Material.Points(
|
||||||
|
apiMaterial,
|
||||||
|
this.color.toApiObject(),
|
||||||
|
GameLib.Utils.IdOrNull(this.diffuseMap),
|
||||||
|
this.size,
|
||||||
|
this.sizeAttenuation
|
||||||
|
);
|
||||||
|
|
||||||
|
return apiMaterialPoints;
|
||||||
|
};
|
|
@ -0,0 +1,99 @@
|
||||||
|
/**
|
||||||
|
* GameLib.D3.Material.Shader.Raw
|
||||||
|
* @param graphics
|
||||||
|
* @param apiMaterialShaderRaw
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Shader.Raw = function(
|
||||||
|
graphics,
|
||||||
|
apiMaterialShaderRaw
|
||||||
|
) {
|
||||||
|
this.graphics = graphics;
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(apiMaterialShaderRaw)) {
|
||||||
|
apiMaterialShaderRaw = {
|
||||||
|
materialType : GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.API.Material.Shader.Raw.call(
|
||||||
|
this,
|
||||||
|
apiMaterialShaderRaw
|
||||||
|
);
|
||||||
|
|
||||||
|
GameLib.D3.Material.Shader.call(
|
||||||
|
this,
|
||||||
|
this.graphics,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Material.Shader.Raw.prototype = Object.create(GameLib.D3.Material.Shader.prototype);
|
||||||
|
GameLib.D3.Material.Shader.Raw.prototype.constructor = GameLib.D3.Material.Shader.Raw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of our texture object
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Shader.Raw.prototype.createInstance = function() {
|
||||||
|
|
||||||
|
var fragmentShader = '';
|
||||||
|
var vertexShader = '';
|
||||||
|
|
||||||
|
if (this.fragmentShader && this.fragmentShader.instance) {
|
||||||
|
fragmentShader = this.fragmentShader.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.vertexShader && this.vertexShader.instance) {
|
||||||
|
vertexShader = this.vertexShader.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.instance = new THREE.RawShaderMaterial(
|
||||||
|
{
|
||||||
|
clipping : this.clipping,
|
||||||
|
defaultAttributeValues : this.defaultAttributeValues,
|
||||||
|
extensions : this.extensions,
|
||||||
|
fog : this.fog,
|
||||||
|
fragmentShader : fragmentShader,
|
||||||
|
linewidth : this.linewidth,
|
||||||
|
morphTargets : this.morphTargets,
|
||||||
|
morphNormals : this.morphNormals,
|
||||||
|
skinning : this.skinning,
|
||||||
|
uniforms : this.uniforms,
|
||||||
|
vertexColors : this.vertexColors,
|
||||||
|
vertexShader : vertexShader,
|
||||||
|
wireframe : this.wireframe,
|
||||||
|
wireframeLinewidth : this.wireframeLinewidth
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (GameLib.Utils.Defined(this.index0AttributeName)) {
|
||||||
|
this.instance.index0AttributeName = this.index0AttributeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.D3.Material.prototype.createInstance.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the instance with the current state
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Shader.Raw.prototype.updateInstance = function(property) {
|
||||||
|
GameLib.D3.Material.Shader.prototype.updateInstance.call(this, property);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a GameLib.D3.Material.Shader.Raw to a GameLib.D3.API.Material.Shader.Raw
|
||||||
|
* @returns {GameLib.D3.API.Material.Shader.Raw}
|
||||||
|
*/
|
||||||
|
GameLib.D3.Material.Shader.Raw.prototype.toApiObject = function() {
|
||||||
|
|
||||||
|
var apiMaterialShader = GameLib.D3.Material.Shader.prototype.toApiObject.call(this);
|
||||||
|
|
||||||
|
var apiMaterialShaderRaw = new GameLib.D3.API.Material.Shader.Raw(
|
||||||
|
apiMaterialShader
|
||||||
|
);
|
||||||
|
|
||||||
|
return apiMaterialShaderRaw;
|
||||||
|
};
|
|
@ -54,24 +54,15 @@ GameLib.D3.Material.Standard = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.alphaMap instanceof GameLib.D3.API.Texture) {
|
if (this.alphaMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.alphaMap = new GameLib.D3.Texture(
|
this.alphaMap = GameLib.Component.ConstructFromObject(this.alphaMap);
|
||||||
this.graphics,
|
|
||||||
this.alphaMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.aoMap instanceof GameLib.D3.API.Texture) {
|
if (this.aoMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.aoMap = new GameLib.D3.Texture(
|
this.aoMap = GameLib.Component.ConstructFromObject(this.aoMap);
|
||||||
this.graphics,
|
|
||||||
this.aoMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.bumpMap instanceof GameLib.D3.API.Texture) {
|
if (this.bumpMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.bumpMap = new GameLib.D3.Texture(
|
this.bumpMap = GameLib.Component.ConstructFromObject(this.bumpMap);
|
||||||
this.graphics,
|
|
||||||
this.bumpMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,10 +73,7 @@ GameLib.D3.Material.Standard = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.displacementMap instanceof GameLib.D3.API.Texture) {
|
if (this.displacementMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.displacementMap = new GameLib.D3.Texture(
|
this.displacementMap = GameLib.Component.ConstructFromObject(this.displacementMap);
|
||||||
this.graphics,
|
|
||||||
this.displacementMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emissive = new GameLib.Color(
|
this.emissive = new GameLib.Color(
|
||||||
|
@ -95,52 +83,31 @@ GameLib.D3.Material.Standard = function(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.emissiveMap instanceof GameLib.D3.API.Texture) {
|
if (this.emissiveMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.emissiveMap = new GameLib.D3.Texture(
|
this.emissiveMap = GameLib.Component.ConstructFromObject(this.emissiveMap);
|
||||||
this.graphics,
|
|
||||||
this.emissiveMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.envMap instanceof GameLib.D3.API.Texture) {
|
if (this.envMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.envMap = new GameLib.D3.Texture(
|
this.envMap = GameLib.Component.ConstructFromObject(this.envMap);
|
||||||
this.graphics,
|
|
||||||
this.envMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lightMap instanceof GameLib.D3.API.Texture) {
|
if (this.lightMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.lightMap = new GameLib.D3.Texture(
|
this.lightMap = GameLib.Component.ConstructFromObject(this.lightMap);
|
||||||
this.graphics,
|
|
||||||
this.lightMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.diffuseMap instanceof GameLib.D3.API.Texture) {
|
if (this.diffuseMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.diffuseMap = new GameLib.D3.Texture(
|
this.diffuseMap = GameLib.Component.ConstructFromObject(this.diffuseMap);
|
||||||
this.graphics,
|
|
||||||
this.diffuseMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.metalnessMap instanceof GameLib.D3.API.Texture) {
|
if (this.metalnessMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.metalnessMap = new GameLib.D3.Texture(
|
this.metalnessMap = GameLib.Component.ConstructFromObject(this.metalnessMap);
|
||||||
this.graphics,
|
|
||||||
this.metalnessMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.normalMap instanceof GameLib.D3.API.Texture) {
|
if (this.normalMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.normalMap = new GameLib.D3.Texture(
|
this.normalMap = GameLib.Component.ConstructFromObject(this.normalMap);
|
||||||
this.graphics,
|
|
||||||
this.normalMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.roughnessMap instanceof GameLib.D3.API.Texture) {
|
if (this.roughnessMap instanceof GameLib.D3.API.Texture) {
|
||||||
this.roughnessMap = new GameLib.D3.Texture(
|
this.roughnessMap = GameLib.Component.ConstructFromObject(this.roughnessMap);
|
||||||
this.graphics,
|
|
||||||
this.roughnessMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Material.call(
|
GameLib.D3.Material.call(
|
||||||
|
|
|
@ -190,12 +190,13 @@ GameLib.D3.Mesh.prototype.createInstance = function() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.parentScene)) {
|
if (
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.parentScene.instance)) {
|
GameLib.Utils.Defined(this.parentScene) &&
|
||||||
console.warn('parent scene not linked at time of create instance');
|
GameLib.Utils.Defined(this.parentScene.instance)
|
||||||
} else {
|
) {
|
||||||
this.parentScene.add(this.instance, this);
|
this.parentScene.addObject(this);
|
||||||
}
|
} else {
|
||||||
|
console.warn('parent scene not linked yet');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance.position.x = this.position.x;
|
this.instance.position.x = this.position.x;
|
||||||
|
|
|
@ -375,6 +375,8 @@ GameLib.D3.Scene.prototype.addObject = function(object) {
|
||||||
if (this.instance.children.indexOf(object.instance) === -1) {
|
if (this.instance.children.indexOf(object.instance) === -1) {
|
||||||
this.instance.add(object.instance);
|
this.instance.add(object.instance);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('either scene or mesh instance not ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (this.parentEntity) {
|
// if (this.parentEntity) {
|
||||||
|
@ -389,11 +391,21 @@ GameLib.D3.Scene.prototype.addClone = function(component) {
|
||||||
component instanceof GameLib.D3.Light
|
component instanceof GameLib.D3.Light
|
||||||
) {
|
) {
|
||||||
if (this.instance && component.instance) {
|
if (this.instance && component.instance) {
|
||||||
this.instance.add(component.instance);
|
if (this.instance.children.indexOf(component.instance) === -1) {
|
||||||
|
this.instance.add(component.instance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component.isClone = true;
|
||||||
|
|
||||||
GameLib.Utils.PushUnique(this.clones, component);
|
GameLib.Utils.PushUnique(this.clones, component);
|
||||||
|
|
||||||
|
var index = this.meshes.indexOf(component);
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
this.meshes.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
component.parentScene = this;
|
component.parentScene = this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -940,6 +940,18 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
} else if (property === 'aspectRatioMode') {
|
||||||
|
controllers.push(
|
||||||
|
folder.add(
|
||||||
|
object,
|
||||||
|
property,
|
||||||
|
{
|
||||||
|
'none' : GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_NONE,
|
||||||
|
'fixed' : GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_FIXED,
|
||||||
|
'based on current' : GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_BASED_ON_CURRENT
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
} else if (property === 'socketType') {
|
} else if (property === 'socketType') {
|
||||||
controllers.push(
|
controllers.push(
|
||||||
folder.add(
|
folder.add(
|
||||||
|
@ -1192,8 +1204,8 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
'standard': GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD,
|
'standard': GameLib.D3.API.Material.MATERIAL_TYPE_STANDARD,
|
||||||
'basic': GameLib.D3.API.Material.MATERIAL_TYPE_BASIC,
|
'basic': GameLib.D3.API.Material.MATERIAL_TYPE_BASIC,
|
||||||
'phong': GameLib.D3.API.Material.MATERIAL_TYPE_PHONG,
|
'phong': GameLib.D3.API.Material.MATERIAL_TYPE_PHONG,
|
||||||
'shader': GameLib.D3.API.Material.MATERIAL_TYPE_SHADER
|
'shader': GameLib.D3.API.Material.MATERIAL_TYPE_SHADER,
|
||||||
// 'points': GameLib.D3.API.Material.MATERIAL_TYPE_POINTS,
|
'points': GameLib.D3.API.Material.MATERIAL_TYPE_POINTS
|
||||||
// 'toon': GameLib.D3.API.Material.MATERIAL_TYPE_TOON,
|
// 'toon': GameLib.D3.API.Material.MATERIAL_TYPE_TOON,
|
||||||
// 'line basic' : GameLib.D3.API.Material.MATERIAL_TYPE_LINE_BASIC
|
// 'line basic' : GameLib.D3.API.Material.MATERIAL_TYPE_LINE_BASIC
|
||||||
}
|
}
|
||||||
|
@ -1655,7 +1667,8 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
) {
|
) {
|
||||||
controllers.push(folder.add(object, property, -2, 2, 0.0001));
|
controllers.push(folder.add(object, property, -2, 2, 0.0001));
|
||||||
} else if (
|
} else if (
|
||||||
property === 'arc'
|
property === 'arc' ||
|
||||||
|
property === 'size'
|
||||||
) {
|
) {
|
||||||
controllers.push(folder.add(object, property, 0, 200, 0.001));
|
controllers.push(folder.add(object, property, 0, 200, 0.001));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -244,6 +244,26 @@ GameLib.System.Render.prototype.windowResize = function(data) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Camera).map(
|
||||||
|
function(camera){
|
||||||
|
if (
|
||||||
|
camera instanceof GameLib.D3.Camera.Orthographic &&
|
||||||
|
camera.aspectRatioMode !== GameLib.D3.API.Camera.Orthographic.ASPECT_RATIO_MODE_NONE
|
||||||
|
) {
|
||||||
|
camera.updateInstance('aspect');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
camera instanceof GameLib.D3.Camera.Perspective ||
|
||||||
|
camera instanceof GameLib.D3.Camera.Stereo
|
||||||
|
) {
|
||||||
|
camera.aspect = data.width / data.height;
|
||||||
|
camera.updateInstance('aspect');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.COMPOSER).map(
|
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.COMPOSER).map(
|
||||||
function(composer){
|
function(composer){
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue