lights working - cameras working too - support for stereo camera

beta.r3js.org
-=yb4f310 2018-01-30 15:02:47 +01:00
parent 7916ec376c
commit da67665771
37 changed files with 1020 additions and 820 deletions

View File

@ -98,7 +98,7 @@ GameLib.Event.CAST_SOURCE_CHANGED = 0x50;
GameLib.Event.ANIMATION_MESH_ADDED = 0x51;
GameLib.Event.ANIMATION_MESH_REMOVED = 0x52;
GameLib.Event.CANVAS_CHANGE = 0x53;
GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE = 0x54;
GameLib.Event.AFTER_WINDOW_RESIZE = 0x54;
GameLib.Event.LOAD_FONT = 0x55;
GameLib.Event.FONT_NOT_FOUND = 0x56;
GameLib.Event.STOP_ALL_AUDIO = 0x57;
@ -126,6 +126,7 @@ GameLib.Event.RECEIVE_DESTINATION_CHANGED = 0x6c;
GameLib.Event.SELECTION_MODE_CHANGE = 0x6d;
GameLib.Event.MESH_FACE_SELECTED = 0x6e;
GameLib.Event.MESH_FACE_DESELECTED = 0x6f;
GameLib.Event.BEFORE_WINDOW_RESIZE = 0x70;
/**
* Returns string name of event ID
@ -219,7 +220,7 @@ GameLib.Event.GetEventName = function(number) {
case 0x51 : return 'animation_mesh_added';
case 0x52 : return 'animation_mesh_removed';
case 0x53 : return 'dom_element_change';
case 0x54 : return 'custom_code_window_resize';
case 0x54 : return 'after_window_resize';
case 0x55 : return 'load_font';
case 0x56 : return 'font_not_found';
case 0x57 : return 'stop_all_audio';
@ -247,6 +248,7 @@ GameLib.Event.GetEventName = function(number) {
case 0x6d : return 'selection_mode_change';
case 0x6e : return 'mesh_face_selected';
case 0x6f : return 'mesh_face_deselected';
case 0x70 : return 'before_window_resize';
break;
}

View File

@ -481,7 +481,7 @@ GameLib.Component.GetComponentInfo = function(number) {
};
case 0x1c : return {
name : 'GameLib.D3.Shadow.Spot',
runtime : GameLib.Component.SHADOW_SPOT,
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Shadow.Spot,
apiConstructor : GameLib.D3.API.Shadow.Spot
};
@ -840,19 +840,19 @@ GameLib.Component.GetComponentInfo = function(number) {
};
case 0x58 : return {
name : 'GameLib.D3.Camera.Orthographic',
runtime : GameLib.Component.CAMERA_ORTHOGRAPHIC,
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Camera.Orthographic,
apiConstructor : GameLib.D3.API.Camera.Orthographic
};
case 0x59 : return {
name : 'GameLib.D3.Camera.Stereo',
runtime : GameLib.Component.CAMERA_STEREO,
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Camera.Stereo,
apiConstructor : GameLib.D3.API.Camera.Stereo
};
case 0x5a : return {
name : 'GameLib.D3.Camera.Cube',
runtime : GameLib.Component.CAMERA_CUBE,
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Camera.Cube,
apiConstructor : GameLib.D3.API.Camera.Cube
};

View File

@ -91,21 +91,3 @@ GameLib.Controls.D3.Editor.prototype.toApiObject = function() {
return apiControls;
};
/**
* Construct an Editor Controls object from data
* @param graphics
* @param objectControls
* @returns {GameLib.Controls.D3.Editor}
* @constructor
*/
GameLib.Controls.D3.Editor.FromObject = function(graphics, objectControls) {
var apiEditorControls = GameLib.API.Controls.D3.Editor.FromObject(objectControls);
return new GameLib.Controls.D3.Editor(
graphics,
apiEditorControls
);
};

View File

@ -3,12 +3,16 @@
* @constructor
* @param apiCamera
* @param eyeSep
* @param stereoMode
* @param main
* @param cameraL
* @param cameraR
*/
GameLib.D3.API.Camera.Stereo = function(
apiCamera,
eyeSep,
stereoMode,
main,
cameraL,
cameraR
) {
@ -29,6 +33,16 @@ GameLib.D3.API.Camera.Stereo = function(
}
this.eyeSep = eyeSep;
if (GameLib.Utils.UndefinedOrNull(stereoMode)) {
stereoMode = GameLib.D3.API.Camera.Stereo.STEREO_MODE_STEREO;
}
this.stereoMode = stereoMode;
if (GameLib.Utils.UndefinedOrNull(main)) {
main = new GameLib.D3.API.Camera.Perspective();
}
this.main = main;
if (GameLib.Utils.UndefinedOrNull(cameraL)) {
cameraL = new GameLib.D3.API.Camera.Perspective();
}
@ -44,12 +58,16 @@ GameLib.D3.API.Camera.Stereo = function(
apiCamera.id,
apiCamera.name,
apiCamera.cameraType,
apiCamera.position,
apiCamera.aspect,
apiCamera.position,
apiCamera.lookAt,
apiCamera.parentEntity
);
};
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.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;

View File

@ -1,5 +1,5 @@
/**
* Raw Mesh API object - should always correspond with the Mesh Schema
* GameLib.D3.API.Mesh
* @param id
* @param meshType
@ -22,13 +22,15 @@
* @param isBufferMesh
* @param useQuaternion
* @param visible
* @param castShadow
* @param receiveShadow
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Mesh = function(
id,
meshType,
name,
meshType,
vertices,
faces,
materials,
@ -47,6 +49,8 @@ GameLib.D3.API.Mesh = function(
isBufferMesh,
useQuaternion,
visible,
castShadow,
receiveShadow,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
@ -54,16 +58,16 @@ GameLib.D3.API.Mesh = function(
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(meshType)) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
}
this.meshType = meshType;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Mesh (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(meshType)) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
}
this.meshType = meshType;
if (GameLib.Utils.UndefinedOrNull(vertices)) {
vertices = [];
}
@ -154,6 +158,16 @@ GameLib.D3.API.Mesh = function(
}
this.visible = visible;
if (GameLib.Utils.UndefinedOrNull(castShadow)) {
castShadow = false;
}
this.castShadow = castShadow;
if (GameLib.Utils.UndefinedOrNull(receiveShadow)) {
receiveShadow = false;
}
this.receiveShadow = receiveShadow;
var componentType = GameLib.Component.MESH;
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_PLANE) {
@ -204,141 +218,3 @@ GameLib.D3.API.Mesh.MESH_TYPE_BOX = 0x5;
GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER = 0x6;
GameLib.D3.API.Mesh.MESH_TYPE_TEXT = 0x7;
GameLib.D3.API.Mesh.MESH_TYPE_LINE = 0x8;
/**
* Returns an API Mesh from an Object mesh
* @param objectMesh
* @constructor
*/
GameLib.D3.API.Mesh.FromObject = function (objectMesh){
var apiFaces = [];
if (objectMesh.faces) {
apiFaces = objectMesh.faces.map(
function(face) {
return GameLib.D3.API.Face.FromObject(face);
}
);
}
var apiSkeleton = null;
if (objectMesh.skeleton) {
apiSkeleton = GameLib.D3.API.Skeleton.FromObject(objectMesh.skeleton);
}
var apiMaterials = [];
if (objectMesh.materials) {
apiMaterials = objectMesh.materials.map(
function (objectMaterial) {
/**
* From blender we only get Ids to materials (strings)
*/
if (objectMaterial instanceof Object) {
return GameLib.D3.API.Material.FromObject(objectMaterial);
} else {
return objectMaterial
}
}
)
}
var apiVertices = [];
if (objectMesh.vertices) {
apiVertices = objectMesh.vertices.map(
function (objectVertex) {
return GameLib.D3.API.Vertex.FromObject(objectVertex);
}
)
}
var apiPosition = new GameLib.API.Vector3();
if (objectMesh.position) {
apiPosition = GameLib.API.Vector3.FromObject(objectMesh.position);
}
var apiRotation = new GameLib.API.Vector3();
if (objectMesh.rotation) {
apiRotation = GameLib.API.Vector3.FromObject(objectMesh.rotation);
}
var apiQuaternion = new GameLib.API.Quaternion();
if (objectMesh.quaternion) {
apiQuaternion = GameLib.API.Quaternion.FromObject(objectMesh.quaternion);
}
var apiScale = new GameLib.API.Vector3(1,1,1);
if (objectMesh.scale) {
apiScale = GameLib.API.Vector3.FromObject(objectMesh.scale);
}
var apiUp = new GameLib.API.Vector3(0,1,0);
if (objectMesh.up) {
apiUp = GameLib.API.Vector3.FromObject(objectMesh.up);
}
var apiModelMatrix = new GameLib.API.Matrix4();
if (objectMesh.modelMatrix) {
apiModelMatrix = GameLib.API.Matrix4.FromObject(objectMesh.modelMatrix);
}
var meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
if (objectMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_NORMAL ||
objectMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_SKINNED
) {
meshType = objectMesh.meshType;
}
if (objectMesh.componentType === GameLib.Component.MESH_PLANE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_PLANE;
}
if (objectMesh.componentType === GameLib.Component.MESH_SPHERE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_SPHERE;
}
if (objectMesh.componentType === GameLib.Component.MESH_CURVE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_CURVE;
}
if (objectMesh.componentType === GameLib.Component.MESH_BOX) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_BOX;
}
if (objectMesh.componentType === GameLib.Component.MESH_CYLINDER) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER;
}
if (objectMesh.componentType === GameLib.Component.MESH_TEXT) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_TEXT;
}
if (objectMesh.componentType === GameLib.Component.MESH_TYPE_LINE) {
meshType = GameLib.D3.API.Mesh.MESH_LINE;
}
return new GameLib.D3.API.Mesh(
objectMesh.id,
meshType,
objectMesh.name,
apiVertices,
apiFaces,
apiMaterials,
objectMesh.parentMesh,
objectMesh.parentScene,
apiSkeleton,
objectMesh.skinIndices,
objectMesh.skinWeights,
apiPosition,
apiQuaternion,
apiRotation,
apiScale,
apiUp,
apiModelMatrix,
objectMesh.renderOrder,
objectMesh.isBufferMesh,
objectMesh.useQuaternion,
objectMesh.visible,
objectMesh.parentEntity
);
};

View File

@ -0,0 +1,71 @@
/**
* GameLib.D3.API.Mesh.Box
* @constructor
* @param apiMesh
* @param width
* @param height
* @param depth
*/
GameLib.D3.API.Mesh.Box = function(
apiMesh,
width,
height,
depth
) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_BOX
};
}
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_BOX;
}
if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1;
}
this.width = width;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 1;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(depth)) {
depth = 1;
}
this.depth = depth;
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.name,
apiMesh.meshType,
apiMesh.vertices,
apiMesh.faces,
apiMesh.materials,
apiMesh.parentMesh,
apiMesh.parentScene,
apiMesh.skeleton,
apiMesh.skinIndices,
apiMesh.skinWeights,
apiMesh.position,
apiMesh.quaternion,
apiMesh.rotation,
apiMesh.scale,
apiMesh.up,
apiMesh.modelMatrix,
apiMesh.renderOrder,
apiMesh.isBufferMesh,
apiMesh.useQuaternion,
apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity
);
};
GameLib.D3.API.Mesh.Box.prototype = Object.create(GameLib.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Box.prototype.constructor = GameLib.D3.API.Mesh.Box;

View File

@ -0,0 +1,57 @@
/**
* GameLib.D3.API.Mesh.Curve
* @constructor
* @param apiMesh
* @param pointSize
*/
GameLib.D3.API.Mesh.Curve = function(
apiMesh,
pointSize
) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_CURVE
};
}
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_CURVE;
}
if (GameLib.Utils.UndefinedOrNull(pointSize)) {
pointSize = 1;
}
this.pointSize = pointSize;
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.name,
apiMesh.meshType,
apiMesh.vertices,
apiMesh.faces,
apiMesh.materials,
apiMesh.parentMesh,
apiMesh.parentScene,
apiMesh.skeleton,
apiMesh.skinIndices,
apiMesh.skinWeights,
apiMesh.position,
apiMesh.quaternion,
apiMesh.rotation,
apiMesh.scale,
apiMesh.up,
apiMesh.modelMatrix,
apiMesh.renderOrder,
apiMesh.isBufferMesh,
apiMesh.useQuaternion,
apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity
);
};
GameLib.D3.API.Mesh.Curve.prototype = Object.create(GameLib.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Curve.prototype.constructor = GameLib.D3.API.Mesh.Curve;

View File

@ -1,5 +1,5 @@
/**
* Raw Mesh.Cylinder API object
* GameLib.D3.API.Mesh.Cylinder
* @constructor
* @param apiMesh
* @param radiusTop
@ -22,13 +22,16 @@ GameLib.D3.API.Mesh.Cylinder = function(
thetaStart,
thetaLength
) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER
};
}
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER;
}
if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1;
}
@ -72,8 +75,8 @@ GameLib.D3.API.Mesh.Cylinder = function(
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.meshType,
apiMesh.name,
apiMesh.meshType,
apiMesh.vertices,
apiMesh.faces,
apiMesh.materials,
@ -92,6 +95,8 @@ GameLib.D3.API.Mesh.Cylinder = function(
apiMesh.isBufferMesh,
apiMesh.useQuaternion,
apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity
);
};

View File

@ -0,0 +1,57 @@
/**
* GameLib.D3.API.Mesh.Line
* @constructor
* @param apiMesh
* @param lineWidth
*/
GameLib.D3.API.Mesh.Line = function(
apiMesh,
lineWidth
) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_LINE
};
}
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_LINE;
}
if (GameLib.Utils.UndefinedOrNull(lineWidth)) {
lineWidth = 1;
}
this.lineWidth = lineWidth;
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.name,
apiMesh.meshType,
apiMesh.vertices,
apiMesh.faces,
apiMesh.materials,
apiMesh.parentMesh,
apiMesh.parentScene,
apiMesh.skeleton,
apiMesh.skinIndices,
apiMesh.skinWeights,
apiMesh.position,
apiMesh.quaternion,
apiMesh.rotation,
apiMesh.scale,
apiMesh.up,
apiMesh.modelMatrix,
apiMesh.renderOrder,
apiMesh.isBufferMesh,
apiMesh.useQuaternion,
apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity
);
};
GameLib.D3.API.Mesh.Line.prototype = Object.create(GameLib.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Line.prototype.constructor = GameLib.D3.API.Mesh.Line;

View File

@ -1,5 +1,5 @@
/**
* Raw Mesh.Plane API object
* GameLib.D3.API.Mesh.Plane
* @constructor
* @param apiMesh
* @param width
@ -35,6 +35,10 @@ GameLib.D3.API.Mesh.Plane = function(
};
}
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_PLANE;
}
if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1;
}
@ -93,8 +97,8 @@ GameLib.D3.API.Mesh.Plane = function(
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.meshType,
apiMesh.name,
apiMesh.meshType,
apiMesh.vertices,
apiMesh.faces,
apiMesh.materials,
@ -113,6 +117,8 @@ GameLib.D3.API.Mesh.Plane = function(
apiMesh.isBufferMesh,
apiMesh.useQuaternion,
apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity
);
};

View File

@ -0,0 +1,71 @@
/**
* GameLib.D3.API.Mesh.Sphere
* @constructor
* @param apiMesh
* @param radius
* @param widthSegments
* @param heightSegments
*/
GameLib.D3.API.Mesh.Sphere = function(
apiMesh,
radius,
widthSegments,
heightSegments
) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_SPHERE
};
}
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_SPHERE;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(widthSegments)) {
widthSegments = 5;
}
this.widthSegments = widthSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 5;
}
this.heightSegments = heightSegments;
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.name,
apiMesh.meshType,
apiMesh.vertices,
apiMesh.faces,
apiMesh.materials,
apiMesh.parentMesh,
apiMesh.parentScene,
apiMesh.skeleton,
apiMesh.skinIndices,
apiMesh.skinWeights,
apiMesh.position,
apiMesh.quaternion,
apiMesh.rotation,
apiMesh.scale,
apiMesh.up,
apiMesh.modelMatrix,
apiMesh.renderOrder,
apiMesh.isBufferMesh,
apiMesh.useQuaternion,
apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity
);
};
GameLib.D3.API.Mesh.Sphere.prototype = Object.create(GameLib.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Sphere.prototype.constructor = GameLib.D3.API.Mesh.Sphere;

View File

@ -0,0 +1,113 @@
/**
* GameLib.D3.API.Mesh.Text
* @constructor
* @param apiMesh
* @param text
* @param font
* @param size
* @param height
* @param curveSegments
* @param bevelEnabled
* @param bevelThickness
* @param bevelSize
* @param bevelSegments
*/
GameLib.D3.API.Mesh.Text = function(
apiMesh,
text,
font,
size,
height,
curveSegments,
bevelEnabled,
bevelThickness,
bevelSize,
bevelSegments
) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_TEXT
};
}
if (GameLib.Utils.UndefinedOrNull(apiMesh.meshType)) {
apiMesh.meshType = GameLib.D3.API.Mesh.MESH_TYPE_TEXT;
}
if (GameLib.Utils.UndefinedOrNull(text)) {
text = '-=<yb4f310';
}
this.text = text;
if (GameLib.Utils.UndefinedOrNull(font)) {
font = new GameLib.D3.API.Font()
}
this.font = font;
if (GameLib.Utils.UndefinedOrNull(size)) {
size = 100;
}
this.size = size;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 50;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(curveSegments)) {
curveSegments = 12;
}
this.curveSegments = curveSegments;
if (GameLib.Utils.UndefinedOrNull(bevelEnabled)) {
bevelEnabled = false;
}
this.bevelEnabled = bevelEnabled;
if (GameLib.Utils.UndefinedOrNull(bevelThickness)) {
bevelThickness = 10;
}
this.bevelThickness = bevelThickness;
if (GameLib.Utils.UndefinedOrNull(bevelSize)) {
bevelSize = 8;
}
this.bevelSize = bevelSize;
if (GameLib.Utils.UndefinedOrNull(bevelSegments)) {
bevelSegments = 3;
}
this.bevelSegments = bevelSegments;
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.name,
apiMesh.meshType,
apiMesh.vertices,
apiMesh.faces,
apiMesh.materials,
apiMesh.parentMesh,
apiMesh.parentScene,
apiMesh.skeleton,
apiMesh.skinIndices,
apiMesh.skinWeights,
apiMesh.position,
apiMesh.quaternion,
apiMesh.rotation,
apiMesh.scale,
apiMesh.up,
apiMesh.modelMatrix,
apiMesh.renderOrder,
apiMesh.isBufferMesh,
apiMesh.useQuaternion,
apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity
);
};
GameLib.D3.API.Mesh.Text.prototype = Object.create(GameLib.D3.API.Mesh.prototype);
GameLib.D3.API.Mesh.Text.prototype.constructor = GameLib.D3.API.Mesh.Text;

View File

@ -32,8 +32,10 @@
* @param preserveDrawingBuffer
* @param depth
* @param logarithmicDepthBuffer
* @param fullscreen
* @param windowSize
* @param aspectRatio
* @param scaleMode
* @param logicalSize
* @param offset
* @param canvas
* @param renderTarget
@ -82,8 +84,10 @@ GameLib.D3.API.Renderer = function (
depth,
logarithmicDepthBuffer,
localClippingEnabled,
fullscreen,
aspectRatio,
scaleMode,
windowSize,
logicalSize,
offset,
canvas,
renderTarget,
@ -261,10 +265,15 @@ GameLib.D3.API.Renderer = function (
}
this.localClippingEnabled = localClippingEnabled;
if (GameLib.Utils.UndefinedOrNull(fullscreen)) {
fullscreen = true;
if (GameLib.Utils.UndefinedOrNull(aspectRatio)) {
aspectRatio = GameLib.D3.API.Renderer.ASPECT_RATIO_3_2;
}
this.fullscreen = fullscreen;
this.aspectRatio = aspectRatio;
if (GameLib.Utils.UndefinedOrNull(scaleMode)) {
scaleMode = GameLib.D3.API.Renderer.SCALE_MODE_LETTERBOX;
}
this.scaleMode = scaleMode;
if (GameLib.Utils.UndefinedOrNull(windowSize)) {
windowSize = new GameLib.API.Vector2(
@ -274,6 +283,14 @@ GameLib.D3.API.Renderer = function (
}
this.windowSize = windowSize;
if (GameLib.Utils.UndefinedOrNull(logicalSize)) {
logicalSize = new GameLib.API.Vector2(
480,
320
);
}
this.logicalSize = logicalSize;
if (GameLib.Utils.UndefinedOrNull(offset)) {
offset = new GameLib.API.Vector2(0,0);
}
@ -305,20 +322,20 @@ GameLib.D3.API.Renderer = function (
this.clearColor = clearColor;
if (GameLib.Utils.UndefinedOrNull(camera)) {
camera = new GameLib.D3.API.Camera.Perspective(
camera = new GameLib.D3.API.Camera.Stereo(
{
name : 'Render Camera',
aspect : this.width / this.height
aspect : 3 / 2
}
);
}
this.camera = camera;
if (GameLib.Utils.UndefinedOrNull(editCamera)) {
editCamera = new GameLib.D3.API.Camera.Perspective(
editCamera = new GameLib.D3.API.Camera.Stereo(
{
name : 'Edit Camera',
aspect : this.width / this.height
aspect : 3 / 2
}
);
}
@ -371,59 +388,14 @@ GameLib.D3.API.Renderer.TONE_MAPPING_REINHARD = 2;
GameLib.D3.API.Renderer.TONE_MAPPING_UNCHARTED_2 = 3;
GameLib.D3.API.Renderer.TONE_MAPPING_CINEON = 4;
GameLib.D3.API.Renderer.ASPECT_RATIO_NONE = 0x1;
GameLib.D3.API.Renderer.ASPECT_RATIO_4_3 = 0x2;
GameLib.D3.API.Renderer.ASPECT_RATIO_3_2 = 0x3;
GameLib.D3.API.Renderer.ASPECT_RATIO_16_10 = 0x4;
GameLib.D3.API.Renderer.ASPECT_RATIO_17_10 = 0x5;
GameLib.D3.API.Renderer.ASPECT_RATIO_16_9 = 0x6;
/**
* Object to GameLib.D3.API.Renderer
* @param objectRenderer
* @constructor
*/
GameLib.D3.API.Renderer.FromObject = function(objectRenderer) {
return new GameLib.D3.API.Renderer(
objectRenderer.id,
objectRenderer.name,
objectRenderer.width,
objectRenderer.height,
objectRenderer.renderMode,
objectRenderer.lastRenderMode,
objectRenderer.autoClear,
objectRenderer.autoClearColor,
objectRenderer.autoClearDepth,
objectRenderer.autoClearStencil,
objectRenderer.gammaFactor,
objectRenderer.gammaInput,
objectRenderer.gammaOutput,
objectRenderer.maxMorphTargets,
objectRenderer.maxMorphNormals,
objectRenderer.physicallyCorrectLights,
objectRenderer.shadowMapEnabled,
objectRenderer.shadowMapAutoUpdate,
objectRenderer.shadowMapNeedsUpdate,
objectRenderer.shadowMapType,
objectRenderer.shadowMapRenderReverseSided,
objectRenderer.shadowMapRenderSingleSided,
objectRenderer.sortObjects,
objectRenderer.toneMapping,
objectRenderer.toneMappingExposure,
objectRenderer.toneMappingWhitePoint,
objectRenderer.premultipliedAlpha,
objectRenderer.antialias,
objectRenderer.stencil,
objectRenderer.preserveDrawingBuffer,
objectRenderer.depth,
objectRenderer.logarithmicDepthBuffer,
objectRenderer.localClippingEnabled,
objectRenderer.fullscreen,
GameLib.API.Vector2.FromObject(objectRenderer.windowSize),
GameLib.API.Vector2.FromObject(objectRenderer.offset),
objectRenderer.canvas,
objectRenderer.renderTarget,
objectRenderer.clippingPlanes,
GameLib.API.Color.FromObject(objectRenderer.clearColor),
objectRenderer.camera,
objectRenderer.editCamera,
objectRenderer.scenes,
objectRenderer.defaultScene,
objectRenderer.viewports,
objectRenderer.parentEntity
);
};
GameLib.D3.API.Renderer.SCALE_MODE_NONE = 0x1;
GameLib.D3.API.Renderer.SCALE_MODE_LETTERBOX = 0x2;
GameLib.D3.API.Renderer.SCALE_MODE_ZOOM_TO_BIGGER = 0x3;
GameLib.D3.API.Renderer.SCALE_MODE_NON_UNIFORM = 0x4;

View File

@ -30,7 +30,7 @@ GameLib.D3.API.Shadow.Directional = function(
)
}
GameLib.API.Shadow.call(
GameLib.D3.API.Shadow.call(
this,
apiDirectionalShadow.id,
apiDirectionalShadow.name,

View File

@ -30,7 +30,7 @@ GameLib.D3.API.Shadow.Spot = function(
)
}
GameLib.API.Shadow.call(
GameLib.D3.API.Shadow.call(
this,
apiSpotShadow.id,
apiSpotShadow.name,

View File

@ -38,11 +38,6 @@ GameLib.D3.Camera = function(
this.lookAt,
this
);
//
// this.aspect = new GameLib.Number(
// this.aspect,
// this
// );
var linkedObjects = {};
@ -51,8 +46,9 @@ GameLib.D3.Camera = function(
linkedObjects.renderTarget = GameLib.D3.RenderTarget;
break;
case GameLib.D3.API.Camera.CAMERA_TYPE_STEREO :
linkedObjects.cameraL = GameLib.D3.Camera.Perspective;
linkedObjects.cameraR = GameLib.D3.Camera.Perspective;
linkedObjects.main = GameLib.D3.Camera.Perspective;
linkedObjects.cameraL = GameLib.D3.Camera.Perspective;
linkedObjects.cameraR = GameLib.D3.Camera.Perspective;
break;
default :
break;
@ -73,9 +69,14 @@ GameLib.D3.Camera.prototype.constructor = GameLib.D3.Camera;
*/
GameLib.D3.Camera.prototype.createInstance = function() {
this.instance.position.x = this.position.x;
this.instance.position.y = this.position.y;
this.instance.position.z = this.position.z;
/**
* Not all implementations of camera has a position (Stereo camera gets its position on update)
*/
// if (GameLib.Utils.Defined(this.instance.position)) {
this.instance.position.x = this.position.x;
this.instance.position.y = this.position.y;
this.instance.position.z = this.position.z;
// }
/**
* Not all implementations of camera has aspect ratio, we, however do have an aspect ratio for all our cameras
@ -84,9 +85,10 @@ GameLib.D3.Camera.prototype.createInstance = function() {
this.instance.aspect = this.aspect;
}
this.instance.lookAt(this.lookAt.instance);
this.instance.updateProjectionMatrix();
//if (GameLib.Utils.Defined(this.instance.lookAt)) {
this.instance.lookAt(this.lookAt.instance);
this.instance.updateProjectionMatrix();
//}
GameLib.Component.prototype.createInstance.call(this);
};
@ -131,6 +133,7 @@ GameLib.D3.Camera.prototype.updateInstance = function(property) {
if (property === 'aspect') {
if (GameLib.Utils.Defined(this.instance.aspect)) {
this.instance.aspect = this.aspect;
this.instance.updateProjectionMatrix();
} else {
console.warn('updating the aspect ratio of this type of camera has no effect.');
}
@ -176,7 +179,7 @@ GameLib.D3.Camera.prototype.toApiObject = function() {
this.id,
this.name,
this.cameraType,
this.aspect.toApiObject(),
this.aspect,
this.position.toApiObject(),
this.lookAt.toApiObject(),
GameLib.Utils.IdOrNull(this.parentEntity)

View File

@ -27,25 +27,10 @@ GameLib.D3.Camera.Cube = function(
apiCubeCamera.renderTarget
);
// this.near = new GameLib.Number(
// this.near,
// this
// );
//
// this.far = new GameLib.Number(
// this.far,
// this
// );
//
// this.cubeResolution = new GameLib.Number(
// this.cubeResolution,
// this
// );
GameLib.D3.Camera.call(
this,
this.graphics,
apiCubeCamera
this
);
};
@ -76,11 +61,6 @@ GameLib.D3.Camera.Cube.prototype.createInstance = function() {
* Updates the instance with the current state
*/
GameLib.D3.Camera.Cube.prototype.updateInstance = function(property) {
if (property === 'aspect') {
console.warn('changing the aspect ratio of a cube camera has no effect - its always 1');
return;
}
if (property === 'fov') {
console.warn('changing the fov of a cube camera has no effect - its always 90');

View File

@ -32,51 +32,11 @@ GameLib.D3.Camera.Orthographic = function(
apiOrthographicCamera.bottom,
apiOrthographicCamera.zoom
);
//
// this.width = new GameLib.Number(
// this.width,
// this
// );
//
// this.near = new GameLib.Number(
// this.near,
// this
// );
//
// this.far = new GameLib.Number(
// this.far,
// this
// );
//
// this.left = new GameLib.Number(
// this.left,
// this
// );
//
// this.right = new GameLib.Number(
// this.right,
// this
// );
//
// this.top = new GameLib.Number(
// this.top,
// this
// );
//
// this.bottom = new GameLib.Number(
// this.bottom,
// this
// );
//
// this.zoom = new GameLib.Number(
// this.zoom,
// this
// );
GameLib.D3.Camera.call(
this,
this.graphics,
apiOrthographicCamera
this
);
};
@ -132,6 +92,8 @@ GameLib.D3.Camera.Orthographic.prototype.updateInstance = function(property) {
this.instance.top = this.top;
this.instance.bottom = this.bottom;
this.instance.updateProjectionMatrix();
return;
}

View File

@ -30,45 +30,10 @@ GameLib.D3.Camera.Perspective = function(
apiPerspectiveCamera.zoom
);
// this.near = new GameLib.Number(
// this.near,
// this
// );
//
// this.far = new GameLib.Number(
// this.far,
// this
// );
//
// this.fov = new GameLib.Number(
// this.fov,
// this
// );
//
// this.filmGauge = new GameLib.Number(
// this.filmGauge,
// this
// );
//
// this.filmOffset = new GameLib.Number(
// this.filmOffset,
// this
// );
//
// this.focus = new GameLib.Number(
// this.focus,
// this
// );
//
// this.zoom = new GameLib.Number(
// this.zoom,
// this
// );
GameLib.D3.Camera.call(
this,
this.graphics,
apiPerspectiveCamera
this
);
};
@ -101,11 +66,6 @@ GameLib.D3.Camera.Perspective.prototype.createInstance = function() {
* Updates the instance with the current state
*/
GameLib.D3.Camera.Perspective.prototype.updateInstance = function(property) {
if (property === 'aspect') {
this.instance.aspect = this.aspect;
return;
}
if (property === 'near') {
this.instance.near = this.near;

View File

@ -22,10 +22,19 @@ GameLib.D3.Camera.Stereo = function(
this,
apiStereoCamera,
apiStereoCamera.eyeSep,
apiStereoCamera.stereoMode,
apiStereoCamera.main,
apiStereoCamera.cameraL,
apiStereoCamera.cameraR
);
if (this.main instanceof GameLib.D3.API.Camera.Perspective) {
this.main = new GameLib.D3.Camera.Perspective(
this.graphics,
this.main
);
}
if (this.cameraL instanceof GameLib.D3.API.Camera.Perspective) {
this.cameraL = new GameLib.D3.Camera.Perspective(
this.graphics,
@ -39,16 +48,11 @@ GameLib.D3.Camera.Stereo = function(
this.cameraR
);
}
//
// this.eyeSep = new GameLib.Number(
// this.eyeSep,
// this
// );
GameLib.D3.Camera.call(
this,
this.graphics,
apiStereoCamera
this
);
};
@ -62,7 +66,20 @@ GameLib.D3.Camera.Stereo.prototype.constructor = GameLib.D3.Camera.Stereo;
*/
GameLib.D3.Camera.Stereo.prototype.createInstance = function() {
this.instance = new THREE.StereoCamera();
this.instance = this.main.instance;
var instance = new THREE.StereoCamera();
for (var property in instance) {
this.instance[property] = instance[property];
}
//
//
// Object.keys(instance).map(
// function(property) {
// this.instance[property] = instance[property];
// }.bind(this)
// );
this.instance.aspect = this.aspect;
@ -81,18 +98,23 @@ GameLib.D3.Camera.Stereo.prototype.updateInstance = function(property) {
return;
}
if (property === 'aspect') {
this.instance.aspect = this.aspect;
if (property === 'stereoMode') {
console.warn('experimental update stereo mode');
return;
}
if (property === 'main') {
console.warn('experimental update stereo camera main instance');
return;
}
if (property === 'cameraL') {
console.warn('update stereo camera cameraL instance');
console.warn('experimental update stereo camera cameraL instance');
return;
}
if (property === 'cameraR') {
console.warn('update stereo camera cameraR instance');
console.warn('experimental update stereo camera cameraR instance');
return;
}
@ -110,6 +132,8 @@ GameLib.D3.Camera.Stereo.prototype.toApiObject = function() {
var apiStereoCamera = new GameLib.D3.API.Camera.Stereo(
apiCamera,
this.eyeSep,
this.stereoMode,
GameLib.Utils.IdOrNull(this.main),
GameLib.Utils.IdOrNull(this.cameraL),
GameLib.Utils.IdOrNull(this.cameraR)
);

View File

@ -9,6 +9,9 @@ GameLib.D3.Light = function(
apiLight
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiLight)) {
apiLight = {};
}
@ -24,6 +27,12 @@ GameLib.D3.Light = function(
apiLight.parentEntity
);
this.color = new GameLib.Color(
this.graphics,
this.color,
this
);
var linkedObjects = {
'parentScene' : GameLib.D3.Scene
};

View File

@ -1020,6 +1020,11 @@ GameLib.D3.Material.prototype.updateInstance = function(property) {
console.warn('not yet implemented (material type = ' + this.materialType + ')');
}
if (property === 'needsUpdate') {
this.instance.needsUpdate = true;
this.needsUpate = false;
}
this.instance.needsUpdate = true;
};

View File

@ -1,5 +1,5 @@
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* GameLib.D3.Mesh
* @param graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh
* @constructor
@ -20,8 +20,8 @@ GameLib.D3.Mesh = function (
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.meshType,
apiMesh.name,
apiMesh.meshType,
apiMesh.vertices,
apiMesh.faces,
apiMesh.materials,
@ -40,6 +40,8 @@ GameLib.D3.Mesh = function (
apiMesh.isBufferMesh,
apiMesh.useQuaternion,
apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity
);
@ -132,11 +134,11 @@ GameLib.D3.Mesh = function (
'skeleton' : GameLib.D3.Skeleton
};
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_PLANE) {
if (apiMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_PLANE) {
linkedObjects.dotObject = GameLib.D3.Mesh;
}
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_TEXT) {
if (apiMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_TEXT) {
linkedObjects.font = GameLib.D3.Font;
}
@ -524,6 +526,10 @@ GameLib.D3.Mesh.prototype.createInstance = function() {
this.instance.visible = this.visible;
this.instance.castShadow = this.castShadow;
this.instance.receiveShadow = this.receiveShadow;
GameLib.Component.prototype.createInstance.call(this);
};
@ -607,6 +613,14 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) {
this.instance.visible = this.visible;
}
if (property === 'castShadow') {
this.instance.castShadow = this.castShadow;
}
if (property === 'receiveShadow') {
this.instance.receiveShadow = this.receiveShadow;
}
if (this.helper) {
this.removeHelper();
this.createHelper();
@ -1019,8 +1033,8 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
var apiMesh = new GameLib.D3.API.Mesh(
this.id,
this.meshType,
this.name,
this.meshType,
this.vertices.map(
function (vertex) {
return vertex.toApiObject();
@ -1043,29 +1057,14 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
this.isBufferMesh,
this.useQuaternion,
this.visible,
this.castShadow,
this.receiveShadow,
GameLib.Utils.IdOrNull(this.parentEntity)
);
return apiMesh;
};
/**
* Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object}
* @constructor
*/
GameLib.D3.Mesh.FromObject = function(graphics, objectMesh) {
var apiMesh = GameLib.D3.API.Mesh.FromObject(objectMesh);
return new GameLib.D3.Mesh(
graphics,
apiMesh
);
};
/**
* Centers the mesh around origin
*/

View File

@ -1,47 +1,34 @@
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* GameLib.D3.Mesh.Box
* @param graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh
* @param width
* @param height
* @param depth
* @param apiMeshBox
* @constructor
*/
GameLib.D3.Mesh.Box = function (
graphics,
apiMesh,
width,
height,
depth
apiMeshBox
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
if (GameLib.Utils.UndefinedOrNull(apiMeshBox)) {
apiMeshBox = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_BOX
};
}
if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1;
}
this.width = width;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 1;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(depth)) {
depth = 1;
}
this.depth = depth;
GameLib.D3.API.Mesh.Box.call(
this,
apiMeshBox,
apiMeshBox.width,
apiMeshBox.height,
apiMeshBox.depth
);
GameLib.D3.Mesh.call(
this,
this.graphics,
apiMesh
this
);
};
@ -53,6 +40,7 @@ GameLib.D3.Mesh.Box.prototype.createInstance = function() {
var geometry = null;
if (this.vertices.length === 0) {
geometry = new THREE.BoxGeometry(
this.width,
this.height,
@ -63,23 +51,15 @@ GameLib.D3.Mesh.Box.prototype.createInstance = function() {
}
GameLib.D3.Mesh.prototype.createInstance.call(this);
this.instance.userData.width = this.width;
this.instance.userData.height = this.height;
this.instance.userData.depth = this.depth;
};
GameLib.D3.Mesh.Box.prototype.updateInstance = function(property) {
if (
this.instance.userData.width !== this.width ||
this.instance.userData.height !== this.height ||
this.instance.userData.depth !== this.depth
property === 'width' ||
property === 'height' ||
property === 'depth'
) {
this.instance.userData.width = this.width;
this.instance.userData.height = this.height;
this.instance.userData.depth = this.depth;
var geometry = new THREE.BoxGeometry(
this.width,
this.height,
@ -91,43 +71,27 @@ GameLib.D3.Mesh.Box.prototype.updateInstance = function(property) {
geometry = this.createInstanceGeometry();
this.instance.geometry = geometry;
return;
}
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
};
/**
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
* @returns {GameLib.D3.API.Mesh}
* Converts a GameLib.D3.Mesh.Box to a GameLib.D3.API.Mesh.Box
* @returns {GameLib.D3.API.Mesh.Box}
*/
GameLib.D3.Mesh.Box.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.width = this.width;
apiMesh.height = this.height;
apiMesh.depth = this.depth;
return apiMesh;
};
/**
* Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object}
* @constructor
*/
GameLib.D3.Mesh.Box.FromObject = function(graphics, objectMesh) {
var apiMesh = GameLib.D3.API.Mesh.FromObject(objectMesh);
return new GameLib.D3.Mesh.Box(
graphics,
var apiMeshBox = new GameLib.D3.API.Mesh.Box(
apiMesh,
objectMesh.width,
objectMesh.height,
objectMesh.depth
this.width,
this.height,
this.depth
);
};
return apiMeshBox;
};

View File

@ -1,26 +1,32 @@
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* GameLib.D3.Mesh.Curve
* @param graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh
* @param apiMeshCurve
* @constructor
*/
GameLib.D3.Mesh.Curve = function (
graphics,
apiMesh
apiMeshCurve
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
if (GameLib.Utils.UndefinedOrNull(apiMeshCurve)) {
apiMeshCurve = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_CURVE
};
}
GameLib.D3.API.Mesh.Curve.call(
this,
apiMeshCurve,
apiMeshCurve.pointSize
);
GameLib.D3.Mesh.call(
this,
this.graphics,
apiMesh
this
);
};
@ -30,16 +36,38 @@ GameLib.D3.Mesh.Curve.prototype.constructor = GameLib.D3.Mesh.Curve;
GameLib.D3.Mesh.Curve.prototype.createInstance = function() {
var geometry = new THREE.Geometry();
console.warn('todo: not fully implemented');
/**
* Setup vertices
*/
this.applyVertexDataToInstance(geometry);
this.instance = true;
var instance = new THREE.Points(geometry);
return;
// var geometry = new THREE.Geometry();
//
// /**
// * Setup vertices
// */
// this.applyVertexDataToInstance(geometry);
//
// var instance = new THREE.Points(geometry);
//
// this.createInstanceDefaults(instance);
//
// return instance;
};
this.createInstanceDefaults(instance);
/**
* Converts a GameLib.D3.Mesh.Curve to a GameLib.D3.API.Mesh.Curve
* @returns {GameLib.D3.API.Mesh.Curve}
*/
GameLib.D3.Mesh.Curve.prototype.toApiObject = function() {
return instance;
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshCurve = new GameLib.D3.API.Mesh.Curve(
apiMesh,
this.pointSize
);
return apiMeshCurve;
};

View File

@ -33,7 +33,7 @@ GameLib.D3.Mesh.Cylinder = function (
GameLib.D3.Mesh.call(
this,
graphics,
apiMeshCylinder
this
);
};
@ -94,23 +94,26 @@ GameLib.D3.Mesh.Cylinder.prototype.updateInstance = function(property) {
};
/**
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
* @returns {GameLib.D3.API.Mesh}
* Converts a GameLib.D3.Mesh.Cylinder to a GameLib.D3.API.Mesh.Cylinder
* @returns {GameLib.D3.API.Mesh.Cylinder}
*/
GameLib.D3.Mesh.Cylinder.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.radiusTop = this.radiusTop;
apiMesh.radiusBottom = this.radiusBottom;
apiMesh.height = this.height;
apiMesh.radiusSegments = this.radiusSegments;
apiMesh.heightSegments = this.heightSegments;
apiMesh.openEnded = this.openEnded;
apiMesh.thetaStart = this.thetaStart;
apiMesh.thetaLength = this.thetaLength;
var apiMeshCylinder = new GameLib.D3.API.Mesh.Cylinder(
apiMesh,
this.radiusTop,
this.radiusBottom,
this.height,
this.radiusSegments,
this.heightSegments,
this.openEnded,
this.thetaStart,
this.thetaLength
);
return apiMesh;
return apiMeshCylinder;
};
/**

View File

@ -1,33 +1,32 @@
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh
* @param lineWidth
* @param apiMeshLine
* @constructor
*/
GameLib.D3.Mesh.Line = function (
graphics,
apiMesh,
lineWidth
apiMeshLine
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
if (GameLib.Utils.UndefinedOrNull(apiMeshLine)) {
apiMeshLine = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_LINE
};
}
if (GameLib.Utils.UndefinedOrNull(lineWidth)) {
lineWidth = 1;
}
this.lineWidth = lineWidth;
GameLib.D3.API.Mesh.Line.call(
this,
apiMeshLine,
apiMeshLine.lineWidth
);
GameLib.D3.Mesh.call(
this,
this.graphics,
apiMesh
this
);
};
@ -62,32 +61,17 @@ GameLib.D3.Mesh.Line.prototype.updateInstance = function(property) {
};
/**
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
* @returns {GameLib.D3.API.Mesh}
* Converts a GameLib.D3.Mesh.Line to a GameLib.D3.API.Mesh.Line
* @returns {GameLib.D3.API.Mesh.Line}
*/
GameLib.D3.Mesh.Line.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.lineWidth = this.lineWidth;
return apiMesh;
};
/**
* Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object}
* @constructor
*/
GameLib.D3.Mesh.Line.FromObject = function(graphics, objectMesh) {
var apiMesh = GameLib.D3.API.Mesh.FromObject(objectMesh);
return new GameLib.D3.Mesh.Line(
graphics,
var apiMeshLine = new GameLib.D3.API.Mesh.Line(
apiMesh,
objectMesh.lineWidth
this.lineWidth
);
return apiMeshLine;
};

View File

@ -160,13 +160,15 @@ GameLib.D3.Mesh.Plane.prototype.updateInstance = function(property) {
};
/**
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
* @returns {GameLib.D3.API.Mesh}
* Converts a GameLib.D3.Mesh.Plane to a GameLib.D3.API.Mesh.Plane
* @returns {GameLib.D3.API.Mesh.Plane}
*/
GameLib.D3.Mesh.Plane.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshPlane = new GameLib.D3.API.Mesh.Plane(
GameLib.D3.Mesh.prototype.toApiObject.call(this),
apiMesh,
this.width,
this.height,
this.widthSegments,
@ -183,6 +185,7 @@ GameLib.D3.Mesh.Plane.prototype.toApiObject = function() {
return apiMeshPlane;
};
GameLib.D3.Mesh.Plane.prototype.getHeightData = function() {
var i;

View File

@ -1,47 +1,34 @@
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* GameLib.D3.Mesh.Sphere
* @param graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh
* @param radius
* @param widthSegments
* @param heightSegments
* @param apiMeshSphere
* @constructor
*/
GameLib.D3.Mesh.Sphere = function (
graphics,
apiMesh,
radius,
widthSegments,
heightSegments
apiMeshSphere
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
if (GameLib.Utils.UndefinedOrNull(apiMeshSphere)) {
apiMeshSphere = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_SPHERE
};
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(widthSegments)) {
widthSegments = 5;
}
this.widthSegments = widthSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 5;
}
this.heightSegments = heightSegments;
GameLib.D3.API.Mesh.Sphere.call(
this,
apiMeshSphere,
apiMeshSphere.radius,
apiMeshSphere.widthSegments,
apiMeshSphere.heightSegments
);
GameLib.D3.Mesh.call(
this,
this.graphics,
apiMesh
this
);
};
@ -62,25 +49,16 @@ GameLib.D3.Mesh.Sphere.prototype.createInstance = function() {
}
GameLib.D3.Mesh.prototype.createInstance.call(this);
this.instance.userData.radius = this.radius;
this.instance.userData.widthSegments = this.widthSegments;
this.instance.userData.heightSegments = this.heightSegments;
};
GameLib.D3.Mesh.Sphere.prototype.updateInstance = function(property) {
if (
this.instance.userData.widthSegments !== this.widthSegments ||
this.instance.userData.heightSegments !== this.heightSegments ||
this.instance.userData.radius !== this.radius
property === 'radius' ||
property === 'widthSegments' ||
property === 'heightSegments'
) {
this.instance.userData.widthSegments = this.widthSegments;
this.instance.userData.heightSegments = this.heightSegments;
this.instance.userData.radius = this.radius;
var geometry = new THREE.SphereGeometry(
this.radius,
this.widthSegments,
@ -92,25 +70,29 @@ GameLib.D3.Mesh.Sphere.prototype.updateInstance = function(property) {
geometry = this.createInstanceGeometry();
this.instance.geometry = geometry;
return;
}
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
};
/**
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
* @returns {GameLib.D3.API.Mesh}
* Converts a GameLib.D3.Mesh.Sphere to a GameLib.D3.API.Mesh.Sphere
* @returns {GameLib.D3.API.Mesh.Sphere}
*/
GameLib.D3.Mesh.Sphere.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.radius = this.radius;
apiMesh.widthSegments = this.widthSegments;
apiMesh.heightSegments = this.heightSegments;
var apiMeshSphere = new GameLib.D3.API.Mesh.Sphere(
apiMesh,
this.radius,
this.widthSegments,
this.heightSegments
);
return apiMesh;
return apiMeshSphere;
};
GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {

View File

@ -1,91 +1,47 @@
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* GameLib.D3.Mesh.Text
* @param graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh
* @param font
* @param size
* @param height
* @param curveSegments
* @param bevelEnabled
* @param bevelThickness
* @param bevelSize
* @param bevelSegments
* @param text
* @param apiMeshText
* @constructor
*/
GameLib.D3.Mesh.Text = function (
graphics,
apiMesh,
text,
font,
size,
height,
curveSegments,
bevelEnabled,
bevelThickness,
bevelSize,
bevelSegments
apiMeshText
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
if (GameLib.Utils.UndefinedOrNull(apiMeshText)) {
apiMeshText = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_TEXT
};
}
if (GameLib.Utils.UndefinedOrNull(text)) {
text = '-=<yb4f310';
}
this.text = text;
GameLib.D3.API.Mesh.Text.call(
this,
apiMeshText,
apiMeshText.text,
apiMeshText.font,
apiMeshText.size,
apiMeshText.height,
apiMeshText.curveSegments,
apiMeshText.bevelEnabled,
apiMeshText.bevelThickness,
apiMeshText.bevelSize,
apiMeshText.bevelSegments
);
if (GameLib.Utils.UndefinedOrNull(font)) {
font = new GameLib.D3.Font(
this.graphics
);
if (this.font instanceof GameLib.D3.API.Font) {
this.font = new GameLib.D3.Font(
this.graphics,
this.font
)
}
this.font = font;
if (GameLib.Utils.UndefinedOrNull(size)) {
size = 100;
}
this.size = size;
if (GameLib.Utils.UndefinedOrNull(height)) {
height = 50;
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(curveSegments)) {
curveSegments = 12;
}
this.curveSegments = curveSegments;
if (GameLib.Utils.UndefinedOrNull(bevelEnabled)) {
bevelEnabled = false;
}
this.bevelEnabled = bevelEnabled;
if (GameLib.Utils.UndefinedOrNull(bevelThickness)) {
bevelThickness = 10;
}
this.bevelThickness = bevelThickness;
if (GameLib.Utils.UndefinedOrNull(bevelSize)) {
bevelSize = 8;
}
this.bevelSize = bevelSize;
if (GameLib.Utils.UndefinedOrNull(bevelSegments)) {
bevelSegments = 3;
}
this.bevelSegments = bevelSegments;
GameLib.D3.Mesh.call(
this,
this.graphics,
apiMesh
this
);
};
@ -116,39 +72,21 @@ GameLib.D3.Mesh.Text.prototype.createInstance = function() {
}
GameLib.D3.Mesh.prototype.createInstance.call(this);
this.instance.userData.font = this.font;
this.instance.userData.size = this.size;
this.instance.userData.height = this.height;
this.instance.userData.curveSegments = this.curveSegments;
this.instance.userData.bevelEnabled = this.bevelEnabled;
this.instance.userData.bevelThickness = this.bevelThickness;
this.instance.userData.bevelSize = this.bevelSize;
this.instance.userData.bevelSegments = this.bevelSegments;
};
GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) {
if (
this.instance.userData.text !== this.text ||
this.instance.userData.font !== this.font ||
this.instance.userData.size !== this.size ||
this.instance.userData.height !== this.height ||
this.instance.userData.curveSegments !== this.curveSegments ||
this.instance.userData.bevelEnabled !== this.bevelEnabled ||
this.instance.userData.bevelThickness !== this.bevelThickness ||
this.instance.userData.bevelSize !== this.bevelSize ||
this.instance.userData.bevelSegments !== this.bevelSegments
property === 'text' ||
property === 'font' ||
property === 'size' ||
property === 'height' ||
property === 'curveSegments' ||
property === 'bevelEnabled' ||
property === 'bevelThickness' ||
property === 'bevelSize' ||
property === 'bevelSegments'
) {
this.instance.userData.text = this.text;
this.instance.userData.font = this.font;
this.instance.userData.size = this.size;
this.instance.userData.height = this.height;
this.instance.userData.curveSegments = this.curveSegments;
this.instance.userData.bevelEnabled = this.bevelEnabled;
this.instance.userData.bevelThickness = this.bevelThickness;
this.instance.userData.bevelSize = this.bevelSize;
this.instance.userData.bevelSegments = this.bevelSegments;
var geometry = new THREE.TextGeometry(
this.text,
@ -169,6 +107,8 @@ GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) {
geometry = this.createInstanceGeometry();
this.instance.geometry = geometry;
return;
}
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
@ -176,48 +116,25 @@ GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) {
};
/**
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
* @returns {GameLib.D3.API.Mesh}
* Converts a GameLib.D3.Mesh.Text to a GameLib.D3.API.Mesh.Text
* @returns {GameLib.D3.API.Mesh.Text}
*/
GameLib.D3.Mesh.Text.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.text = this.text;
apiMesh.font = GameLib.Utils.IdOrNull(this.font);
apiMesh.size = this.size;
apiMesh.height = this.height;
apiMesh.curveSegments = this.curveSegments;
apiMesh.bevelEnabled = this.bevelEnabled;
apiMesh.bevelThickness = this.bevelThickness;
apiMesh.bevelSize = this.bevelSize;
apiMesh.bevelSegments = this.bevelSegments;
return apiMesh;
};
/**
* Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object}
* @constructor
*/
GameLib.D3.Mesh.Text.FromObject = function(graphics, objectMesh) {
var apiMesh = GameLib.D3.API.Mesh.FromObject(objectMesh);
return new GameLib.D3.Mesh.Text(
graphics,
var apiMeshText = new GameLib.D3.API.Mesh.Text(
apiMesh,
objectMesh.text,
objectMesh.font,
objectMesh.size,
objectMesh.height,
objectMesh.curveSegments,
objectMesh.bevelEnabled,
objectMesh.bevelThickness,
objectMesh.bevelSize,
objectMesh.bevelSegments
this.text,
this.font,
this.size,
this.height,
this.curveSegments,
this.bevelEnabled,
this.bevelThickness,
this.bevelSize,
this.bevelSegments
);
return apiMeshText;
};

View File

@ -51,8 +51,10 @@ GameLib.D3.Renderer = function (
apiRenderer.depth,
apiRenderer.logarithmicDepthBuffer,
apiRenderer.localClippingEnabled,
apiRenderer.fullscreen,
apiRenderer.aspectRatio,
apiRenderer.scaleMode,
apiRenderer.windowSize,
apiRenderer.logicalSize,
apiRenderer.offset,
apiRenderer.canvas,
apiRenderer.renderTarget,
@ -72,6 +74,12 @@ GameLib.D3.Renderer = function (
this
);
this.logicalSize = new GameLib.Vector2(
this.graphics,
this.logicalSize,
this
);
this.offset = new GameLib.Vector2(
this.graphics,
this.offset,
@ -108,15 +116,15 @@ GameLib.D3.Renderer = function (
this
);
if (this.camera instanceof GameLib.D3.API.Camera.Perspective) {
this.camera = new GameLib.D3.Camera.Perspective(
if (this.camera instanceof GameLib.D3.API.Camera.Stereo) {
this.camera = new GameLib.D3.Camera.Stereo(
this.graphics,
this.camera
)
}
if (this.editCamera instanceof GameLib.D3.API.Camera.Perspective) {
this.editCamera = new GameLib.D3.Camera.Perspective(
if (this.editCamera instanceof GameLib.D3.API.Camera.Stereo) {
this.editCamera = new GameLib.D3.Camera.Stereo(
this.graphics,
this.editCamera
)
@ -278,181 +286,217 @@ GameLib.D3.Renderer.prototype.updateInstance = function(property) {
var trueHeight;
if (property === 'width') {
trueWidth = this.width * this.windowSize.x;
trueHeight = this.height * this.windowSize.y;
this.canvas.width = trueWidth;
this.canvas.updateInstance('width');
this.camera.aspect = trueWidth / trueHeight;
this.camera.updateInstance('aspect');
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
this.instance.setSize(trueWidth, trueHeight, false);
this.updateInstance('windowSize');
return;
}
if (property === 'height') {
trueWidth = this.width * this.windowSize.x;
trueHeight = this.height * this.windowSize.y;
this.canvas.height = trueHeight;
this.canvas.updateInstance('height');
this.camera.aspect = trueWidth / trueHeight;
this.camera.updateInstance('aspect');
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
this.instance.setSize(trueWidth, trueHeight, false);
}
if (property === 'widthheight') {
trueWidth = this.width * this.windowSize.x;
trueHeight = this.height * this.windowSize.y;
this.canvas.width = trueWidth;
this.canvas.height = trueHeight;
this.canvas.updateInstance('width');
this.canvas.updateInstance('height');
this.camera.aspect = trueWidth / trueHeight;
this.camera.updateInstance('aspect');
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
this.instance.setSize(trueWidth, trueHeight, false);
this.updateInstance('windowSize');
return;
}
if (property === 'renderMode') {
if (this.renderMode !== GameLib.D3.API.Renderer.MODE_EDIT) {
this.lastRenderMode = this.renderMode;
}
return;
}
if (property === 'autoClear') {
this.instance.autoClear = this.autoClear;
return;
}
if (property === 'autoClearColor') {
this.instance.autoClearColor = this.autoClearColor;
return;
}
if (property === 'autoClearDepth') {
this.instance.autoClearDepth = this.autoClearDepth;
return;
}
if (property === 'autoClearStencil') {
this.instance.autoClearStencil = this.autoClearStencil;
return;
}
if (property === 'gammaFactor') {
this.instance.gammaFactor = this.gammaFactor;
return;
}
if (property === 'gammaInput') {
this.instance.gammaInput = this.gammaInput;
return;
}
if (property === 'gammaOutput') {
this.instance.gammaOutput = this.gammaOutput;
return;
}
if (property === 'maxMorphTargets') {
this.instance.maxMorphTargets = this.maxMorphTargets;
return;
}
if (property === 'maxMorphNormals') {
this.instance.maxMorphNormals = this.maxMorphNormals;
return;
}
if (property === 'physicallyCorrectLights') {
this.instance.physicallyCorrectLights = this.physicallyCorrectLights;
return;
}
if (property === 'shadowMapEnabled') {
this.instance.shadowMap.enabled = this.shadowMapEnabled;
return;
}
if (property === 'shadowMapAutoUpdate') {
this.instance.shadowMap.autoUpdate = this.shadowMapAutoUpdate;
return;
}
if (property === 'shadowMapNeedsUpdate') {
this.instance.shadowMap.needsUpdate = this.shadowMapNeedsUpdate;
return;
}
if (property === 'shadowMapType') {
this.instance.shadowMap.type = this.shadowMapType;
return;
}
if (property === 'shadowMapRenderReverseSided') {
this.instance.shadowMap.renderReverseSided = this.shadowMapRenderReverseSided;
return;
}
if (property === 'shadowMapRenderSingleSided') {
this.instance.shadowMap.renderSingleSided = this.shadowMapRenderSingleSided;
return;
}
if (property === 'sortObjects') {
this.instance.sortObjects = this.sortObjects;
return;
}
if (property === 'toneMapping') {
this.instance.toneMapping = this.toneMapping;
return;
}
if (property === 'toneMappingExposure') {
this.instance.toneMappingExposure = this.toneMappingExposure;
return;
}
if (property === 'toneMappingWhitePoint') {
this.instance.toneMappingWhitePoint = this.toneMappingWhitePoint;
return;
}
if (property === 'premultipliedAlpha') {
this.instance.premultipliedAlpha = this.premultipliedAlpha;
return;
}
if (property === 'premultipliedAlpha') {
this.instance.premultipliedAlpha = this.premultipliedAlpha;
return;
}
if (property === 'antialias') {
this.instance.antialias = this.antialias;
return;
}
if (property === 'stencil') {
this.instance.stencil = this.stencil;
return;
}
if (property === 'preserveDrawingBuffer') {
this.instance.preserveDrawingBuffer = this.preserveDrawingBuffer;
return;
}
if (property === 'depth') {
this.instance.depth = this.depth;
return;
}
if (property === 'logarithmicDepthBuffer') {
this.instance.logarithmicDepthBuffer = this.logarithmicDepthBuffer;
return;
}
if (property === 'localClippingEnabled') {
this.instance.localClippingEnabled = this.localClippingEnabled;
return;
}
if (property === 'aspectRatio') {
if (this.scaleMode === GameLib.D3.API.Renderer.SCALE_MODE_LETTERBOX) {
if (this.windowSize.x === this.windowSize.y) {
/**
* Square
*/
// this.camera.aspect = 1;
// this.editCamera.aspect = 1;
console.log('square');
}
if (this.windowSize.x > this.windowSize.y) {
/**
* Landscape Mode
*/
// this.camera.aspect = this.windowSize.x / this.windowSize.y;
// this.editCamera.aspect = this.windowSize.x / this.windowSize.y;
console.log('landscape');
}
if (this.windowSize.x < this.windowSize.y) {
/**
* Portrait Mode
*/
// this.camera.aspect = this.windowSize.y / this.windowSize.x;
// this.editCamera.aspect = this.windowSize.y / this.windowSize.x;
console.log('portrait');
}
this.camera.aspect = this.windowSize.x / this.windowSize.y;
this.editCamera.aspect = this.windowSize.x / this.windowSize.y;
this.camera.updateInstance('aspect');
this.editCamera.updateInstance('aspect');
return;
}
console.warn('todo : update aspect ratio for scale mode : ' + this.scaleMode);
return;
}
if (property === 'scaleMode') {
this.updateInstance('aspectRatio');
return;
}
if (property === 'windowSize') {
trueWidth = this.width * this.windowSize.x;
trueHeight = this.height * this.windowSize.y;
trueWidth = this.width * this.windowSize.x;
trueHeight = this.height * this.windowSize.y;
this.canvas.width = trueWidth;
this.canvas.height = trueHeight;
@ -467,32 +511,38 @@ GameLib.D3.Renderer.prototype.updateInstance = function(property) {
);
this.canvas.instance.style.left = (this.offset.x * this.windowSize.x) + 'px';
this.canvas.instance.style.top = (this.offset.y * this.windowSize.y) + 'px';
this.canvas.instance.style.top = (this.offset.y * this.windowSize.y) + 'px';
this.camera.aspect = trueWidth / trueHeight;
this.camera.updateInstance('aspect');
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
this.updateInstance('aspectRatio');
return;
}
if (property === 'logicalSize') {
this.updateInstance('aspectRatio');
return;
}
if (property === 'offset') {
this.canvas.instance.style.left = (this.offset.x * this.windowSize.x) + 'px';
this.canvas.instance.style.top = (this.offset.y * this.windowSize.y) + 'px';
return;
}
if (property === 'canvas') {
console.warn('experimental canvas change for renderer');
this.instance.dispose();
this.createInstance();
return;
}
if (property === 'renderTarget') {
console.warn('todo: render target change');
return;
}
if (property === 'clippingPlanes') {
console.warn('todo: clipping planes change');
return;
}
if (property === 'clearColor') {
@ -504,6 +554,7 @@ GameLib.D3.Renderer.prototype.updateInstance = function(property) {
),
1 - this.clearColor.a
);
return;
}
if (property === 'camera') {
@ -575,8 +626,10 @@ GameLib.D3.Renderer.prototype.toApiObject = function() {
this.depth,
this.logarithmicDepthBuffer,
this.localClippingEnabled,
this.fullscreen,
this.aspectRatio,
this.scaleMode,
this.windowSize.toApiObject(),
this.logicalSize.toApiObject(),
this.offset.toApiObject(),
GameLib.Utils.IdOrNull(this.canvas),
GameLib.Utils.IdOrNull(this.renderTarget),
@ -604,21 +657,3 @@ GameLib.D3.Renderer.prototype.toApiObject = function() {
return apiRenderer;
};
/**
*
* @param graphics
* @param objectComponent
* @returns {GameLib.D3.Renderer}
* @constructor
*/
GameLib.D3.Renderer.FromObject = function(graphics, objectComponent) {
var apiRenderer = GameLib.D3.API.Renderer.FromObject(objectComponent);
return new GameLib.D3.Renderer(
graphics,
apiRenderer
);
};

View File

@ -37,6 +37,12 @@ GameLib.D3.Shadow = function(
)
}
this.mapSize = new GameLib.Vector2(
this.graphics,
this.mapSize,
this
);
GameLib.Component.call(this);
};
@ -120,7 +126,8 @@ GameLib.D3.Shadow.prototype.toApiObject = function() {
GameLib.D3.Shadow.prototype.updateFromInstance = function() {
this.bias = this.instance.bias;
this.mapSize = this.instance.mapSize;
this.mapSize.x = this.instance.mapSize.x;
this.mapSize.y = this.instance.mapSize.y;
this.radius = this.instance.radius;
this.camera.instance = this.instance.camera;
this.camera.updateFromInstance();

View File

@ -33,7 +33,7 @@ GameLib.D3.Shadow.Directional = function(
GameLib.D3.Shadow.call(
this,
this.graphics,
apiDirectionalShadow
this
);
};

View File

@ -59,7 +59,7 @@ GameLib.D3.Shadow.Spot.prototype.updateInstance = function(property) {
if (property === 'camera') {
console.warn('todo: updateInstance for directional shadow camera instance');
console.warn('todo: updateInstance for spot shadow camera instance');
return;
}

View File

@ -72,6 +72,8 @@ GameLib.System.GUI.prototype.initialize = function(gui) {
gui.instance.domElement.style.right = '0px';
gui.domElement.instance.parentElement.appendChild(gui.instance.domElement);
gui.instance.domElement.getElementsByTagName('ul')[0].style.maxHeight = window.screen.availHeight - 93 + 'px';
};
GameLib.System.GUI.prototype.instanceCreated = function(data) {
@ -915,6 +917,18 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
}
)
);
} else if (property === 'stereoMode') {
controllers.push(
folder.add(
object,
property,
{
'stereo' : GameLib.D3.API.Camera.Stereo.STEREO_MODE_STEREO,
'anaglyph' : GameLib.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH,
'parallax' : GameLib.D3.API.Camera.Stereo.STEREO_MODE_PARALLAX
}
)
);
} else if (property === 'socketType') {
controllers.push(
folder.add(
@ -1386,7 +1400,35 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
}
)
);
} else if (property === 'encoding') {
} else if (property === 'aspectRatio') {
controllers.push(
folder.add(
object,
property,
{
'none': GameLib.D3.API.Renderer.ASPECT_RATIO_NONE,
'4:3 (1.3333)': GameLib.D3.API.Renderer.ASPECT_RATIO_4_3,
'3:2 (1.5)': GameLib.D3.API.Renderer.ASPECT_RATIO_3_2,
'16:10 (1.6667)': GameLib.D3.API.Renderer.ASPECT_RATIO_16_10,
'17:10 (1.7)': GameLib.D3.API.Renderer.ASPECT_RATIO_17_10,
'16:9 (1.7778)': GameLib.D3.API.Renderer.ASPECT_RATIO_16_9
}
)
);
} else if (property === 'scaleMode') {
controllers.push(
folder.add(
object,
property,
{
'none': GameLib.D3.API.Renderer.SCALE_MODE_NONE,
'letterbox': GameLib.D3.API.Renderer.SCALE_MODE_LETTERBOX,
'zoom-bigger': GameLib.D3.API.Renderer.SCALE_MODE_ZOOM_TO_BIGGER,
'non-uniform': GameLib.D3.API.Renderer.SCALE_MODE_NON_UNIFORM
}
)
);
} else if (property === 'encoding') {
controllers.push(
folder.add(
object,

View File

@ -1083,6 +1083,24 @@ GameLib.System.Input.prototype.onMouseMoveEdit = function(event) {
mouse.y = event.clientY;
}
)
this.editorControls.map(
function(editorControl) {
editorControl.camera.position.x = editorControl.camera.instance.position.x;
editorControl.camera.position.y = editorControl.camera.instance.position.y;
editorControl.camera.position.z = editorControl.camera.instance.position.z;
//
// editorControl.camera.quaternion.x = editorControl.camera.instance.quaternion.x;
// editorControl.camera.quaternion.y = editorControl.camera.instance.quaternion.y;
// editorControl.camera.quaternion.z = editorControl.camera.instance.quaternion.z;
// editorControl.camera.quaternion.w = editorControl.camera.instance.quaternion.w;
editorControl.camera.lookAt.x = editorControl.instance.center.x;
editorControl.camera.lookAt.y = editorControl.instance.center.y;
editorControl.camera.lookAt.z = editorControl.instance.center.z;
editorControl.camera.lookAt.instance.copy(editorControl.instance.center);
}
);
};
/**
@ -1100,7 +1118,13 @@ GameLib.System.Input.prototype.onMouseUpEdit = function(event) {
* @param event
*/
GameLib.System.Input.prototype.onMouseWheelEdit = function(event) {
this.editorControls.map(
function(editorControl) {
editorControl.camera.position.x = editorControl.camera.instance.position.x;
editorControl.camera.position.y = editorControl.camera.instance.position.y;
editorControl.camera.position.z = editorControl.camera.instance.position.z;
}
);
};
GameLib.System.Input.prototype.selectFace = function(mesh, face) {

View File

@ -58,25 +58,25 @@ GameLib.System.Render.prototype.start = function() {
this.windowResize
);
window.addEventListener(
'resize',
this.nativeWindowResize,
false
);
// window.addEventListener(
// 'resize',
// this.nativeWindowResize,
// false
// );
window.addEventListener(
"orientationchangeend",
this.nativeWindowResize,
false
);
// window.addEventListener(
// "orientationchangeend",
// this.nativeWindowResize,
// false
// );
GameLib.Event.Emit(
GameLib.Event.WINDOW_RESIZE,
{
width : window.screen.availWidth,
height : window.screen.availHeight
}
);
// GameLib.Event.Emit(
// GameLib.Event.WINDOW_RESIZE,
// {
// width : window.screen.availWidth,
// height : window.screen.availHeight
// }
// );
this.run();
@ -97,15 +97,15 @@ GameLib.System.Render.prototype.run = function() {
};
GameLib.System.Render.prototype.nativeWindowResize = function() {
GameLib.Event.Emit(
GameLib.Event.WINDOW_RESIZE,
{
width : window.screen.availWidth,
height : window.screen.availHeight
}
);
};
// GameLib.System.Render.prototype.nativeWindowResize = function() {
// GameLib.Event.Emit(
// GameLib.Event.WINDOW_RESIZE,
// {
// width : window.screen.availWidth,
// height : window.screen.availHeight
// }
// );
// };
GameLib.System.Render.prototype.getOffset = function (el) {
var rect = el.getBoundingClientRect(),
@ -116,6 +116,11 @@ GameLib.System.Render.prototype.getOffset = function (el) {
GameLib.System.Render.prototype.windowResize = function(data) {
GameLib.Event.Emit(
GameLib.Event.BEFORE_WINDOW_RESIZE,
data
);
var renderers = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.RENDERER);
renderers.map(
@ -129,11 +134,8 @@ GameLib.System.Render.prototype.windowResize = function(data) {
);
GameLib.Event.Emit(
GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE,
{
width : data.width,
height : data.height
}
GameLib.Event.AFTER_WINDOW_RESIZE,
data
);
};
@ -272,7 +274,7 @@ GameLib.System.Render.prototype.render = function(data) {
trueHeight
);
var aspect = trueWidth / trueHeight;
//var aspect = trueWidth / trueHeight;
renderer.scenes.map(
function (scene) {
@ -325,10 +327,41 @@ GameLib.System.Render.prototype.render = function(data) {
camera.instance
);
} else if (renderer.renderMode === GameLib.D3.API.Renderer.MODE_EDIT) {
renderer.instance.render(
scene.instance,
camera.instance
)
if (camera instanceof GameLib.D3.Camera.Stereo) {
var size = renderer.instance.getSize();
scene.instance.updateMatrixWorld();
camera.instance.updateMatrixWorld();
camera.instance.update(camera.main.instance);
renderer.instance.clear();
renderer.instance.setScissorTest(true);
renderer.instance.setScissor(0, 0, size.width / 2, size.height);
renderer.instance.setViewport(0, 0, size.width / 2, size.height);
renderer.instance.render(scene.instance, camera.instance.cameraL);
renderer.instance.setScissor(size.width / 2, 0, size.width / 2, size.height);
renderer.instance.setViewport(size.width / 2, 0, size.width / 2, size.height);
renderer.instance.render(scene.instance, camera.instance.cameraR);
renderer.instance.setScissorTest(false);
} else {
renderer.instance.render(
scene.instance,
camera.instance
)
}
} else {
console.warn('unknown render mode:' + renderer.renderMode);
}
@ -368,11 +401,17 @@ GameLib.System.Render.prototype.stop = function() {
this.renderSubscription.remove();
window.removeEventListener(
'resize',
this.nativeWindowResize,
false
);
// window.removeEventListener(
// 'resize',
// this.nativeWindowResize,
// false
// );
// window.removeEventListener(
// 'orientationchangeend',
// this.nativeWindowResize,
// false
// );
this.windowResizeSubscription.remove();