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

View File

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

View File

@ -91,21 +91,3 @@ GameLib.Controls.D3.Editor.prototype.toApiObject = function() {
return apiControls; 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 * @constructor
* @param apiCamera * @param apiCamera
* @param eyeSep * @param eyeSep
* @param stereoMode
* @param main
* @param cameraL * @param cameraL
* @param cameraR * @param cameraR
*/ */
GameLib.D3.API.Camera.Stereo = function( GameLib.D3.API.Camera.Stereo = function(
apiCamera, apiCamera,
eyeSep, eyeSep,
stereoMode,
main,
cameraL, cameraL,
cameraR cameraR
) { ) {
@ -29,6 +33,16 @@ GameLib.D3.API.Camera.Stereo = function(
} }
this.eyeSep = eyeSep; 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)) { if (GameLib.Utils.UndefinedOrNull(cameraL)) {
cameraL = new GameLib.D3.API.Camera.Perspective(); cameraL = new GameLib.D3.API.Camera.Perspective();
} }
@ -44,12 +58,16 @@ GameLib.D3.API.Camera.Stereo = function(
apiCamera.id, apiCamera.id,
apiCamera.name, apiCamera.name,
apiCamera.cameraType, apiCamera.cameraType,
apiCamera.position,
apiCamera.aspect, apiCamera.aspect,
apiCamera.position,
apiCamera.lookAt, apiCamera.lookAt,
apiCamera.parentEntity apiCamera.parentEntity
); );
}; };
GameLib.D3.API.Camera.Stereo.prototype = Object.create(GameLib.D3.API.Camera.prototype); 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 id
* @param meshType * @param meshType
@ -22,13 +22,15 @@
* @param isBufferMesh * @param isBufferMesh
* @param useQuaternion * @param useQuaternion
* @param visible * @param visible
* @param castShadow
* @param receiveShadow
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Mesh = function( GameLib.D3.API.Mesh = function(
id, id,
meshType,
name, name,
meshType,
vertices, vertices,
faces, faces,
materials, materials,
@ -47,6 +49,8 @@ GameLib.D3.API.Mesh = function(
isBufferMesh, isBufferMesh,
useQuaternion, useQuaternion,
visible, visible,
castShadow,
receiveShadow,
parentEntity parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
@ -54,16 +58,16 @@ GameLib.D3.API.Mesh = function(
} }
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(meshType)) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
}
this.meshType = meshType;
if (GameLib.Utils.UndefinedOrNull(name)) { if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Mesh (' + id + ')'; name = 'Mesh (' + id + ')';
} }
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(meshType)) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
}
this.meshType = meshType;
if (GameLib.Utils.UndefinedOrNull(vertices)) { if (GameLib.Utils.UndefinedOrNull(vertices)) {
vertices = []; vertices = [];
} }
@ -154,6 +158,16 @@ GameLib.D3.API.Mesh = function(
} }
this.visible = visible; 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; var componentType = GameLib.Component.MESH;
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_PLANE) { 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_CYLINDER = 0x6;
GameLib.D3.API.Mesh.MESH_TYPE_TEXT = 0x7; GameLib.D3.API.Mesh.MESH_TYPE_TEXT = 0x7;
GameLib.D3.API.Mesh.MESH_TYPE_LINE = 0x8; 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 * @constructor
* @param apiMesh * @param apiMesh
* @param radiusTop * @param radiusTop
@ -22,13 +22,16 @@ GameLib.D3.API.Mesh.Cylinder = function(
thetaStart, thetaStart,
thetaLength thetaLength
) { ) {
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = { apiMesh = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER 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)) { if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1; radiusTop = 1;
} }
@ -72,8 +75,8 @@ GameLib.D3.API.Mesh.Cylinder = function(
GameLib.D3.API.Mesh.call( GameLib.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.meshType,
apiMesh.name, apiMesh.name,
apiMesh.meshType,
apiMesh.vertices, apiMesh.vertices,
apiMesh.faces, apiMesh.faces,
apiMesh.materials, apiMesh.materials,
@ -92,6 +95,8 @@ GameLib.D3.API.Mesh.Cylinder = function(
apiMesh.isBufferMesh, apiMesh.isBufferMesh,
apiMesh.useQuaternion, apiMesh.useQuaternion,
apiMesh.visible, apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity 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 * @constructor
* @param apiMesh * @param apiMesh
* @param width * @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)) { if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1; width = 1;
} }
@ -93,8 +97,8 @@ GameLib.D3.API.Mesh.Plane = function(
GameLib.D3.API.Mesh.call( GameLib.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.meshType,
apiMesh.name, apiMesh.name,
apiMesh.meshType,
apiMesh.vertices, apiMesh.vertices,
apiMesh.faces, apiMesh.faces,
apiMesh.materials, apiMesh.materials,
@ -113,6 +117,8 @@ GameLib.D3.API.Mesh.Plane = function(
apiMesh.isBufferMesh, apiMesh.isBufferMesh,
apiMesh.useQuaternion, apiMesh.useQuaternion,
apiMesh.visible, apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity 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 preserveDrawingBuffer
* @param depth * @param depth
* @param logarithmicDepthBuffer * @param logarithmicDepthBuffer
* @param fullscreen
* @param windowSize * @param windowSize
* @param aspectRatio
* @param scaleMode
* @param logicalSize
* @param offset * @param offset
* @param canvas * @param canvas
* @param renderTarget * @param renderTarget
@ -82,8 +84,10 @@ GameLib.D3.API.Renderer = function (
depth, depth,
logarithmicDepthBuffer, logarithmicDepthBuffer,
localClippingEnabled, localClippingEnabled,
fullscreen, aspectRatio,
scaleMode,
windowSize, windowSize,
logicalSize,
offset, offset,
canvas, canvas,
renderTarget, renderTarget,
@ -261,10 +265,15 @@ GameLib.D3.API.Renderer = function (
} }
this.localClippingEnabled = localClippingEnabled; this.localClippingEnabled = localClippingEnabled;
if (GameLib.Utils.UndefinedOrNull(fullscreen)) { if (GameLib.Utils.UndefinedOrNull(aspectRatio)) {
fullscreen = true; 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)) { if (GameLib.Utils.UndefinedOrNull(windowSize)) {
windowSize = new GameLib.API.Vector2( windowSize = new GameLib.API.Vector2(
@ -274,6 +283,14 @@ GameLib.D3.API.Renderer = function (
} }
this.windowSize = windowSize; this.windowSize = windowSize;
if (GameLib.Utils.UndefinedOrNull(logicalSize)) {
logicalSize = new GameLib.API.Vector2(
480,
320
);
}
this.logicalSize = logicalSize;
if (GameLib.Utils.UndefinedOrNull(offset)) { if (GameLib.Utils.UndefinedOrNull(offset)) {
offset = new GameLib.API.Vector2(0,0); offset = new GameLib.API.Vector2(0,0);
} }
@ -305,20 +322,20 @@ GameLib.D3.API.Renderer = function (
this.clearColor = clearColor; this.clearColor = clearColor;
if (GameLib.Utils.UndefinedOrNull(camera)) { if (GameLib.Utils.UndefinedOrNull(camera)) {
camera = new GameLib.D3.API.Camera.Perspective( camera = new GameLib.D3.API.Camera.Stereo(
{ {
name : 'Render Camera', name : 'Render Camera',
aspect : this.width / this.height aspect : 3 / 2
} }
); );
} }
this.camera = camera; this.camera = camera;
if (GameLib.Utils.UndefinedOrNull(editCamera)) { if (GameLib.Utils.UndefinedOrNull(editCamera)) {
editCamera = new GameLib.D3.API.Camera.Perspective( editCamera = new GameLib.D3.API.Camera.Stereo(
{ {
name : 'Edit Camera', 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_UNCHARTED_2 = 3;
GameLib.D3.API.Renderer.TONE_MAPPING_CINEON = 4; 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;
/** GameLib.D3.API.Renderer.SCALE_MODE_NONE = 0x1;
* Object to GameLib.D3.API.Renderer GameLib.D3.API.Renderer.SCALE_MODE_LETTERBOX = 0x2;
* @param objectRenderer GameLib.D3.API.Renderer.SCALE_MODE_ZOOM_TO_BIGGER = 0x3;
* @constructor GameLib.D3.API.Renderer.SCALE_MODE_NON_UNIFORM = 0x4;
*/
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
);
};

View File

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

View File

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

View File

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

View File

@ -27,25 +27,10 @@ GameLib.D3.Camera.Cube = function(
apiCubeCamera.renderTarget 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( GameLib.D3.Camera.call(
this, this,
this.graphics, this.graphics,
apiCubeCamera this
); );
}; };
@ -76,11 +61,6 @@ GameLib.D3.Camera.Cube.prototype.createInstance = function() {
* Updates the instance with the current state * Updates the instance with the current state
*/ */
GameLib.D3.Camera.Cube.prototype.updateInstance = function(property) { 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') { if (property === 'fov') {
console.warn('changing the fov of a cube camera has no effect - its always 90'); 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.bottom,
apiOrthographicCamera.zoom 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( GameLib.D3.Camera.call(
this, this,
this.graphics, this.graphics,
apiOrthographicCamera this
); );
}; };
@ -132,6 +92,8 @@ GameLib.D3.Camera.Orthographic.prototype.updateInstance = function(property) {
this.instance.top = this.top; this.instance.top = this.top;
this.instance.bottom = this.bottom; this.instance.bottom = this.bottom;
this.instance.updateProjectionMatrix();
return; return;
} }

View File

@ -30,45 +30,10 @@ GameLib.D3.Camera.Perspective = function(
apiPerspectiveCamera.zoom 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( GameLib.D3.Camera.call(
this, this,
this.graphics, this.graphics,
apiPerspectiveCamera this
); );
}; };
@ -101,11 +66,6 @@ GameLib.D3.Camera.Perspective.prototype.createInstance = function() {
* Updates the instance with the current state * Updates the instance with the current state
*/ */
GameLib.D3.Camera.Perspective.prototype.updateInstance = function(property) { GameLib.D3.Camera.Perspective.prototype.updateInstance = function(property) {
if (property === 'aspect') {
this.instance.aspect = this.aspect;
return;
}
if (property === 'near') { if (property === 'near') {
this.instance.near = this.near; this.instance.near = this.near;

View File

@ -22,10 +22,19 @@ GameLib.D3.Camera.Stereo = function(
this, this,
apiStereoCamera, apiStereoCamera,
apiStereoCamera.eyeSep, apiStereoCamera.eyeSep,
apiStereoCamera.stereoMode,
apiStereoCamera.main,
apiStereoCamera.cameraL, apiStereoCamera.cameraL,
apiStereoCamera.cameraR 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) { if (this.cameraL instanceof GameLib.D3.API.Camera.Perspective) {
this.cameraL = new GameLib.D3.Camera.Perspective( this.cameraL = new GameLib.D3.Camera.Perspective(
this.graphics, this.graphics,
@ -39,16 +48,11 @@ GameLib.D3.Camera.Stereo = function(
this.cameraR this.cameraR
); );
} }
//
// this.eyeSep = new GameLib.Number(
// this.eyeSep,
// this
// );
GameLib.D3.Camera.call( GameLib.D3.Camera.call(
this, this,
this.graphics, 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() { 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; this.instance.aspect = this.aspect;
@ -81,18 +98,23 @@ GameLib.D3.Camera.Stereo.prototype.updateInstance = function(property) {
return; return;
} }
if (property === 'aspect') { if (property === 'stereoMode') {
this.instance.aspect = this.aspect; console.warn('experimental update stereo mode');
return;
}
if (property === 'main') {
console.warn('experimental update stereo camera main instance');
return; return;
} }
if (property === 'cameraL') { if (property === 'cameraL') {
console.warn('update stereo camera cameraL instance'); console.warn('experimental update stereo camera cameraL instance');
return; return;
} }
if (property === 'cameraR') { if (property === 'cameraR') {
console.warn('update stereo camera cameraR instance'); console.warn('experimental update stereo camera cameraR instance');
return; return;
} }
@ -110,6 +132,8 @@ GameLib.D3.Camera.Stereo.prototype.toApiObject = function() {
var apiStereoCamera = new GameLib.D3.API.Camera.Stereo( var apiStereoCamera = new GameLib.D3.API.Camera.Stereo(
apiCamera, apiCamera,
this.eyeSep, this.eyeSep,
this.stereoMode,
GameLib.Utils.IdOrNull(this.main),
GameLib.Utils.IdOrNull(this.cameraL), GameLib.Utils.IdOrNull(this.cameraL),
GameLib.Utils.IdOrNull(this.cameraR) GameLib.Utils.IdOrNull(this.cameraR)
); );

View File

@ -9,6 +9,9 @@ GameLib.D3.Light = function(
apiLight apiLight
) { ) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiLight)) { if (GameLib.Utils.UndefinedOrNull(apiLight)) {
apiLight = {}; apiLight = {};
} }
@ -24,6 +27,12 @@ GameLib.D3.Light = function(
apiLight.parentEntity apiLight.parentEntity
); );
this.color = new GameLib.Color(
this.graphics,
this.color,
this
);
var linkedObjects = { var linkedObjects = {
'parentScene' : GameLib.D3.Scene '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 + ')'); console.warn('not yet implemented (material type = ' + this.materialType + ')');
} }
if (property === 'needsUpdate') {
this.instance.needsUpdate = true;
this.needsUpate = false;
}
this.instance.needsUpdate = true; 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 graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @constructor * @constructor
@ -20,8 +20,8 @@ GameLib.D3.Mesh = function (
GameLib.D3.API.Mesh.call( GameLib.D3.API.Mesh.call(
this, this,
apiMesh.id, apiMesh.id,
apiMesh.meshType,
apiMesh.name, apiMesh.name,
apiMesh.meshType,
apiMesh.vertices, apiMesh.vertices,
apiMesh.faces, apiMesh.faces,
apiMesh.materials, apiMesh.materials,
@ -40,6 +40,8 @@ GameLib.D3.Mesh = function (
apiMesh.isBufferMesh, apiMesh.isBufferMesh,
apiMesh.useQuaternion, apiMesh.useQuaternion,
apiMesh.visible, apiMesh.visible,
apiMesh.castShadow,
apiMesh.receiveShadow,
apiMesh.parentEntity apiMesh.parentEntity
); );
@ -132,11 +134,11 @@ GameLib.D3.Mesh = function (
'skeleton' : GameLib.D3.Skeleton '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; 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; linkedObjects.font = GameLib.D3.Font;
} }
@ -524,6 +526,10 @@ GameLib.D3.Mesh.prototype.createInstance = function() {
this.instance.visible = this.visible; this.instance.visible = this.visible;
this.instance.castShadow = this.castShadow;
this.instance.receiveShadow = this.receiveShadow;
GameLib.Component.prototype.createInstance.call(this); GameLib.Component.prototype.createInstance.call(this);
}; };
@ -607,6 +613,14 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) {
this.instance.visible = this.visible; this.instance.visible = this.visible;
} }
if (property === 'castShadow') {
this.instance.castShadow = this.castShadow;
}
if (property === 'receiveShadow') {
this.instance.receiveShadow = this.receiveShadow;
}
if (this.helper) { if (this.helper) {
this.removeHelper(); this.removeHelper();
this.createHelper(); this.createHelper();
@ -1019,8 +1033,8 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
var apiMesh = new GameLib.D3.API.Mesh( var apiMesh = new GameLib.D3.API.Mesh(
this.id, this.id,
this.meshType,
this.name, this.name,
this.meshType,
this.vertices.map( this.vertices.map(
function (vertex) { function (vertex) {
return vertex.toApiObject(); return vertex.toApiObject();
@ -1043,29 +1057,14 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
this.isBufferMesh, this.isBufferMesh,
this.useQuaternion, this.useQuaternion,
this.visible, this.visible,
this.castShadow,
this.receiveShadow,
GameLib.Utils.IdOrNull(this.parentEntity) GameLib.Utils.IdOrNull(this.parentEntity)
); );
return apiMesh; 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 * 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 graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMeshBox
* @param width
* @param height
* @param depth
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Box = function ( GameLib.D3.Mesh.Box = function (
graphics, graphics,
apiMesh, apiMeshBox
width,
height,
depth
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMeshBox)) {
apiMesh = { apiMeshBox = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_BOX meshType: GameLib.D3.API.Mesh.MESH_TYPE_BOX
}; };
} }
if (GameLib.Utils.UndefinedOrNull(width)) { GameLib.D3.API.Mesh.Box.call(
width = 1; this,
} apiMeshBox,
this.width = width; apiMeshBox.width,
apiMeshBox.height,
if (GameLib.Utils.UndefinedOrNull(height)) { apiMeshBox.depth
height = 1; );
}
this.height = height;
if (GameLib.Utils.UndefinedOrNull(depth)) {
depth = 1;
}
this.depth = depth;
GameLib.D3.Mesh.call( GameLib.D3.Mesh.call(
this, this,
this.graphics, this.graphics,
apiMesh this
); );
}; };
@ -53,6 +40,7 @@ GameLib.D3.Mesh.Box.prototype.createInstance = function() {
var geometry = null; var geometry = null;
if (this.vertices.length === 0) { if (this.vertices.length === 0) {
geometry = new THREE.BoxGeometry( geometry = new THREE.BoxGeometry(
this.width, this.width,
this.height, this.height,
@ -63,23 +51,15 @@ GameLib.D3.Mesh.Box.prototype.createInstance = function() {
} }
GameLib.D3.Mesh.prototype.createInstance.call(this); 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) { GameLib.D3.Mesh.Box.prototype.updateInstance = function(property) {
if ( if (
this.instance.userData.width !== this.width || property === 'width' ||
this.instance.userData.height !== this.height || property === 'height' ||
this.instance.userData.depth !== this.depth 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( var geometry = new THREE.BoxGeometry(
this.width, this.width,
this.height, this.height,
@ -91,43 +71,27 @@ GameLib.D3.Mesh.Box.prototype.updateInstance = function(property) {
geometry = this.createInstanceGeometry(); geometry = this.createInstanceGeometry();
this.instance.geometry = geometry; this.instance.geometry = geometry;
return;
} }
GameLib.D3.Mesh.prototype.updateInstance.call(this, property); GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
}; };
/** /**
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh * Converts a GameLib.D3.Mesh.Box to a GameLib.D3.API.Mesh.Box
* @returns {GameLib.D3.API.Mesh} * @returns {GameLib.D3.API.Mesh.Box}
*/ */
GameLib.D3.Mesh.Box.prototype.toApiObject = function() { GameLib.D3.Mesh.Box.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.width = this.width; var apiMeshBox = new GameLib.D3.API.Mesh.Box(
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,
apiMesh, apiMesh,
objectMesh.width, this.width,
objectMesh.height, this.height,
objectMesh.depth 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 graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMeshCurve
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Curve = function ( GameLib.D3.Mesh.Curve = function (
graphics, graphics,
apiMesh apiMeshCurve
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMeshCurve)) {
apiMesh = { apiMeshCurve = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_CURVE meshType: GameLib.D3.API.Mesh.MESH_TYPE_CURVE
}; };
} }
GameLib.D3.API.Mesh.Curve.call(
this,
apiMeshCurve,
apiMeshCurve.pointSize
);
GameLib.D3.Mesh.call( GameLib.D3.Mesh.call(
this, this,
this.graphics, 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() { GameLib.D3.Mesh.Curve.prototype.createInstance = function() {
var geometry = new THREE.Geometry(); console.warn('todo: not fully implemented');
/** this.instance = true;
* Setup vertices
*/
this.applyVertexDataToInstance(geometry);
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( GameLib.D3.Mesh.call(
this, this,
graphics, 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 * Converts a GameLib.D3.Mesh.Cylinder to a GameLib.D3.API.Mesh.Cylinder
* @returns {GameLib.D3.API.Mesh} * @returns {GameLib.D3.API.Mesh.Cylinder}
*/ */
GameLib.D3.Mesh.Cylinder.prototype.toApiObject = function() { GameLib.D3.Mesh.Cylinder.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.radiusTop = this.radiusTop; var apiMeshCylinder = new GameLib.D3.API.Mesh.Cylinder(
apiMesh.radiusBottom = this.radiusBottom; apiMesh,
apiMesh.height = this.height; this.radiusTop,
apiMesh.radiusSegments = this.radiusSegments; this.radiusBottom,
apiMesh.heightSegments = this.heightSegments; this.height,
apiMesh.openEnded = this.openEnded; this.radiusSegments,
apiMesh.thetaStart = this.thetaStart; this.heightSegments,
apiMesh.thetaLength = this.thetaLength; 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 * Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics GameLib.GraphicsRuntime * @param graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMeshLine
* @param lineWidth
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Line = function ( GameLib.D3.Mesh.Line = function (
graphics, graphics,
apiMesh, apiMeshLine
lineWidth
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMeshLine)) {
apiMesh = { apiMeshLine = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_LINE meshType: GameLib.D3.API.Mesh.MESH_TYPE_LINE
}; };
} }
if (GameLib.Utils.UndefinedOrNull(lineWidth)) { GameLib.D3.API.Mesh.Line.call(
lineWidth = 1; this,
} apiMeshLine,
this.lineWidth = lineWidth; apiMeshLine.lineWidth
);
GameLib.D3.Mesh.call( GameLib.D3.Mesh.call(
this, this,
this.graphics, 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 * Converts a GameLib.D3.Mesh.Line to a GameLib.D3.API.Mesh.Line
* @returns {GameLib.D3.API.Mesh} * @returns {GameLib.D3.API.Mesh.Line}
*/ */
GameLib.D3.Mesh.Line.prototype.toApiObject = function() { GameLib.D3.Mesh.Line.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.lineWidth = this.lineWidth; var apiMeshLine = new GameLib.D3.API.Mesh.Line(
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,
apiMesh, 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 * Converts a GameLib.D3.Mesh.Plane to a GameLib.D3.API.Mesh.Plane
* @returns {GameLib.D3.API.Mesh} * @returns {GameLib.D3.API.Mesh.Plane}
*/ */
GameLib.D3.Mesh.Plane.prototype.toApiObject = function() { GameLib.D3.Mesh.Plane.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshPlane = new GameLib.D3.API.Mesh.Plane( var apiMeshPlane = new GameLib.D3.API.Mesh.Plane(
GameLib.D3.Mesh.prototype.toApiObject.call(this), apiMesh,
this.width, this.width,
this.height, this.height,
this.widthSegments, this.widthSegments,
@ -183,6 +185,7 @@ GameLib.D3.Mesh.Plane.prototype.toApiObject = function() {
return apiMeshPlane; return apiMeshPlane;
}; };
GameLib.D3.Mesh.Plane.prototype.getHeightData = function() { GameLib.D3.Mesh.Plane.prototype.getHeightData = function() {
var i; 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 graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMeshSphere
* @param radius
* @param widthSegments
* @param heightSegments
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Sphere = function ( GameLib.D3.Mesh.Sphere = function (
graphics, graphics,
apiMesh, apiMeshSphere
radius,
widthSegments,
heightSegments
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMeshSphere)) {
apiMesh = { apiMeshSphere = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_SPHERE meshType: GameLib.D3.API.Mesh.MESH_TYPE_SPHERE
}; };
} }
if (GameLib.Utils.UndefinedOrNull(radius)) { GameLib.D3.API.Mesh.Sphere.call(
radius = 1; this,
} apiMeshSphere,
this.radius = radius; apiMeshSphere.radius,
apiMeshSphere.widthSegments,
if (GameLib.Utils.UndefinedOrNull(widthSegments)) { apiMeshSphere.heightSegments
widthSegments = 5; );
}
this.widthSegments = widthSegments;
if (GameLib.Utils.UndefinedOrNull(heightSegments)) {
heightSegments = 5;
}
this.heightSegments = heightSegments;
GameLib.D3.Mesh.call( GameLib.D3.Mesh.call(
this, this,
this.graphics, this.graphics,
apiMesh this
); );
}; };
@ -62,25 +49,16 @@ GameLib.D3.Mesh.Sphere.prototype.createInstance = function() {
} }
GameLib.D3.Mesh.prototype.createInstance.call(this); 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) { GameLib.D3.Mesh.Sphere.prototype.updateInstance = function(property) {
if ( if (
this.instance.userData.widthSegments !== this.widthSegments || property === 'radius' ||
this.instance.userData.heightSegments !== this.heightSegments || property === 'widthSegments' ||
this.instance.userData.radius !== this.radius 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( var geometry = new THREE.SphereGeometry(
this.radius, this.radius,
this.widthSegments, this.widthSegments,
@ -92,25 +70,29 @@ GameLib.D3.Mesh.Sphere.prototype.updateInstance = function(property) {
geometry = this.createInstanceGeometry(); geometry = this.createInstanceGeometry();
this.instance.geometry = geometry; this.instance.geometry = geometry;
return;
} }
GameLib.D3.Mesh.prototype.updateInstance.call(this, property); GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
}; };
/** /**
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh * Converts a GameLib.D3.Mesh.Sphere to a GameLib.D3.API.Mesh.Sphere
* @returns {GameLib.D3.API.Mesh} * @returns {GameLib.D3.API.Mesh.Sphere}
*/ */
GameLib.D3.Mesh.Sphere.prototype.toApiObject = function() { GameLib.D3.Mesh.Sphere.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.radius = this.radius; var apiMeshSphere = new GameLib.D3.API.Mesh.Sphere(
apiMesh.widthSegments = this.widthSegments; apiMesh,
apiMesh.heightSegments = this.heightSegments; this.radius,
this.widthSegments,
this.heightSegments
);
return apiMesh; return apiMeshSphere;
}; };
GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() { 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 graphics GameLib.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMeshText
* @param font
* @param size
* @param height
* @param curveSegments
* @param bevelEnabled
* @param bevelThickness
* @param bevelSize
* @param bevelSegments
* @param text
* @constructor * @constructor
*/ */
GameLib.D3.Mesh.Text = function ( GameLib.D3.Mesh.Text = function (
graphics, graphics,
apiMesh, apiMeshText
text,
font,
size,
height,
curveSegments,
bevelEnabled,
bevelThickness,
bevelSize,
bevelSegments
) { ) {
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMeshText)) {
apiMesh = { apiMeshText = {
meshType : GameLib.D3.API.Mesh.MESH_TYPE_TEXT meshType : GameLib.D3.API.Mesh.MESH_TYPE_TEXT
}; };
} }
if (GameLib.Utils.UndefinedOrNull(text)) { GameLib.D3.API.Mesh.Text.call(
text = '-=<yb4f310'; this,
} apiMeshText,
this.text = text; apiMeshText.text,
apiMeshText.font,
apiMeshText.size,
apiMeshText.height,
apiMeshText.curveSegments,
apiMeshText.bevelEnabled,
apiMeshText.bevelThickness,
apiMeshText.bevelSize,
apiMeshText.bevelSegments
);
if (GameLib.Utils.UndefinedOrNull(font)) { if (this.font instanceof GameLib.D3.API.Font) {
font = new GameLib.D3.Font( this.font = new GameLib.D3.Font(
this.graphics 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( GameLib.D3.Mesh.call(
this, this,
this.graphics, this.graphics,
apiMesh this
); );
}; };
@ -116,39 +72,21 @@ GameLib.D3.Mesh.Text.prototype.createInstance = function() {
} }
GameLib.D3.Mesh.prototype.createInstance.call(this); 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) { GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) {
if ( if (
this.instance.userData.text !== this.text || property === 'text' ||
this.instance.userData.font !== this.font || property === 'font' ||
this.instance.userData.size !== this.size || property === 'size' ||
this.instance.userData.height !== this.height || property === 'height' ||
this.instance.userData.curveSegments !== this.curveSegments || property === 'curveSegments' ||
this.instance.userData.bevelEnabled !== this.bevelEnabled || property === 'bevelEnabled' ||
this.instance.userData.bevelThickness !== this.bevelThickness || property === 'bevelThickness' ||
this.instance.userData.bevelSize !== this.bevelSize || property === 'bevelSize' ||
this.instance.userData.bevelSegments !== this.bevelSegments 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( var geometry = new THREE.TextGeometry(
this.text, this.text,
@ -169,6 +107,8 @@ GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) {
geometry = this.createInstanceGeometry(); geometry = this.createInstanceGeometry();
this.instance.geometry = geometry; this.instance.geometry = geometry;
return;
} }
GameLib.D3.Mesh.prototype.updateInstance.call(this, property); 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 * Converts a GameLib.D3.Mesh.Text to a GameLib.D3.API.Mesh.Text
* @returns {GameLib.D3.API.Mesh} * @returns {GameLib.D3.API.Mesh.Text}
*/ */
GameLib.D3.Mesh.Text.prototype.toApiObject = function() { GameLib.D3.Mesh.Text.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
apiMesh.text = this.text; var apiMeshText = new GameLib.D3.API.Mesh.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,
apiMesh, apiMesh,
objectMesh.text, this.text,
objectMesh.font, this.font,
objectMesh.size, this.size,
objectMesh.height, this.height,
objectMesh.curveSegments, this.curveSegments,
objectMesh.bevelEnabled, this.bevelEnabled,
objectMesh.bevelThickness, this.bevelThickness,
objectMesh.bevelSize, this.bevelSize,
objectMesh.bevelSegments this.bevelSegments
); );
return apiMeshText;
}; };

View File

@ -51,8 +51,10 @@ GameLib.D3.Renderer = function (
apiRenderer.depth, apiRenderer.depth,
apiRenderer.logarithmicDepthBuffer, apiRenderer.logarithmicDepthBuffer,
apiRenderer.localClippingEnabled, apiRenderer.localClippingEnabled,
apiRenderer.fullscreen, apiRenderer.aspectRatio,
apiRenderer.scaleMode,
apiRenderer.windowSize, apiRenderer.windowSize,
apiRenderer.logicalSize,
apiRenderer.offset, apiRenderer.offset,
apiRenderer.canvas, apiRenderer.canvas,
apiRenderer.renderTarget, apiRenderer.renderTarget,
@ -72,6 +74,12 @@ GameLib.D3.Renderer = function (
this this
); );
this.logicalSize = new GameLib.Vector2(
this.graphics,
this.logicalSize,
this
);
this.offset = new GameLib.Vector2( this.offset = new GameLib.Vector2(
this.graphics, this.graphics,
this.offset, this.offset,
@ -108,15 +116,15 @@ GameLib.D3.Renderer = function (
this this
); );
if (this.camera instanceof GameLib.D3.API.Camera.Perspective) { if (this.camera instanceof GameLib.D3.API.Camera.Stereo) {
this.camera = new GameLib.D3.Camera.Perspective( this.camera = new GameLib.D3.Camera.Stereo(
this.graphics, this.graphics,
this.camera this.camera
) )
} }
if (this.editCamera instanceof GameLib.D3.API.Camera.Perspective) { if (this.editCamera instanceof GameLib.D3.API.Camera.Stereo) {
this.editCamera = new GameLib.D3.Camera.Perspective( this.editCamera = new GameLib.D3.Camera.Stereo(
this.graphics, this.graphics,
this.editCamera this.editCamera
) )
@ -278,181 +286,217 @@ GameLib.D3.Renderer.prototype.updateInstance = function(property) {
var trueHeight; var trueHeight;
if (property === 'width') { if (property === 'width') {
this.updateInstance('windowSize');
trueWidth = this.width * this.windowSize.x; return;
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);
} }
if (property === 'height') { if (property === 'height') {
this.updateInstance('windowSize');
trueWidth = this.width * this.windowSize.x; return;
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);
} }
if (property === 'renderMode') { if (property === 'renderMode') {
if (this.renderMode !== GameLib.D3.API.Renderer.MODE_EDIT) { if (this.renderMode !== GameLib.D3.API.Renderer.MODE_EDIT) {
this.lastRenderMode = this.renderMode; this.lastRenderMode = this.renderMode;
} }
return;
} }
if (property === 'autoClear') { if (property === 'autoClear') {
this.instance.autoClear = this.autoClear; this.instance.autoClear = this.autoClear;
return;
} }
if (property === 'autoClearColor') { if (property === 'autoClearColor') {
this.instance.autoClearColor = this.autoClearColor; this.instance.autoClearColor = this.autoClearColor;
return;
} }
if (property === 'autoClearDepth') { if (property === 'autoClearDepth') {
this.instance.autoClearDepth = this.autoClearDepth; this.instance.autoClearDepth = this.autoClearDepth;
return;
} }
if (property === 'autoClearStencil') { if (property === 'autoClearStencil') {
this.instance.autoClearStencil = this.autoClearStencil; this.instance.autoClearStencil = this.autoClearStencil;
return;
} }
if (property === 'gammaFactor') { if (property === 'gammaFactor') {
this.instance.gammaFactor = this.gammaFactor; this.instance.gammaFactor = this.gammaFactor;
return;
} }
if (property === 'gammaInput') { if (property === 'gammaInput') {
this.instance.gammaInput = this.gammaInput; this.instance.gammaInput = this.gammaInput;
return;
} }
if (property === 'gammaOutput') { if (property === 'gammaOutput') {
this.instance.gammaOutput = this.gammaOutput; this.instance.gammaOutput = this.gammaOutput;
return;
} }
if (property === 'maxMorphTargets') { if (property === 'maxMorphTargets') {
this.instance.maxMorphTargets = this.maxMorphTargets; this.instance.maxMorphTargets = this.maxMorphTargets;
return;
} }
if (property === 'maxMorphNormals') { if (property === 'maxMorphNormals') {
this.instance.maxMorphNormals = this.maxMorphNormals; this.instance.maxMorphNormals = this.maxMorphNormals;
return;
} }
if (property === 'physicallyCorrectLights') { if (property === 'physicallyCorrectLights') {
this.instance.physicallyCorrectLights = this.physicallyCorrectLights; this.instance.physicallyCorrectLights = this.physicallyCorrectLights;
return;
} }
if (property === 'shadowMapEnabled') { if (property === 'shadowMapEnabled') {
this.instance.shadowMap.enabled = this.shadowMapEnabled; this.instance.shadowMap.enabled = this.shadowMapEnabled;
return;
} }
if (property === 'shadowMapAutoUpdate') { if (property === 'shadowMapAutoUpdate') {
this.instance.shadowMap.autoUpdate = this.shadowMapAutoUpdate; this.instance.shadowMap.autoUpdate = this.shadowMapAutoUpdate;
return;
} }
if (property === 'shadowMapNeedsUpdate') { if (property === 'shadowMapNeedsUpdate') {
this.instance.shadowMap.needsUpdate = this.shadowMapNeedsUpdate; this.instance.shadowMap.needsUpdate = this.shadowMapNeedsUpdate;
return;
} }
if (property === 'shadowMapType') { if (property === 'shadowMapType') {
this.instance.shadowMap.type = this.shadowMapType; this.instance.shadowMap.type = this.shadowMapType;
return;
} }
if (property === 'shadowMapRenderReverseSided') { if (property === 'shadowMapRenderReverseSided') {
this.instance.shadowMap.renderReverseSided = this.shadowMapRenderReverseSided; this.instance.shadowMap.renderReverseSided = this.shadowMapRenderReverseSided;
return;
} }
if (property === 'shadowMapRenderSingleSided') { if (property === 'shadowMapRenderSingleSided') {
this.instance.shadowMap.renderSingleSided = this.shadowMapRenderSingleSided; this.instance.shadowMap.renderSingleSided = this.shadowMapRenderSingleSided;
return;
} }
if (property === 'sortObjects') { if (property === 'sortObjects') {
this.instance.sortObjects = this.sortObjects; this.instance.sortObjects = this.sortObjects;
return;
} }
if (property === 'toneMapping') { if (property === 'toneMapping') {
this.instance.toneMapping = this.toneMapping; this.instance.toneMapping = this.toneMapping;
return;
} }
if (property === 'toneMappingExposure') { if (property === 'toneMappingExposure') {
this.instance.toneMappingExposure = this.toneMappingExposure; this.instance.toneMappingExposure = this.toneMappingExposure;
return;
} }
if (property === 'toneMappingWhitePoint') { if (property === 'toneMappingWhitePoint') {
this.instance.toneMappingWhitePoint = this.toneMappingWhitePoint; this.instance.toneMappingWhitePoint = this.toneMappingWhitePoint;
return;
} }
if (property === 'premultipliedAlpha') { if (property === 'premultipliedAlpha') {
this.instance.premultipliedAlpha = this.premultipliedAlpha; this.instance.premultipliedAlpha = this.premultipliedAlpha;
return;
} }
if (property === 'premultipliedAlpha') { if (property === 'premultipliedAlpha') {
this.instance.premultipliedAlpha = this.premultipliedAlpha; this.instance.premultipliedAlpha = this.premultipliedAlpha;
return;
} }
if (property === 'antialias') { if (property === 'antialias') {
this.instance.antialias = this.antialias; this.instance.antialias = this.antialias;
return;
} }
if (property === 'stencil') { if (property === 'stencil') {
this.instance.stencil = this.stencil; this.instance.stencil = this.stencil;
return;
} }
if (property === 'preserveDrawingBuffer') { if (property === 'preserveDrawingBuffer') {
this.instance.preserveDrawingBuffer = this.preserveDrawingBuffer; this.instance.preserveDrawingBuffer = this.preserveDrawingBuffer;
return;
} }
if (property === 'depth') { if (property === 'depth') {
this.instance.depth = this.depth; this.instance.depth = this.depth;
return;
} }
if (property === 'logarithmicDepthBuffer') { if (property === 'logarithmicDepthBuffer') {
this.instance.logarithmicDepthBuffer = this.logarithmicDepthBuffer; this.instance.logarithmicDepthBuffer = this.logarithmicDepthBuffer;
return;
} }
if (property === 'localClippingEnabled') { if (property === 'localClippingEnabled') {
this.instance.localClippingEnabled = this.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') { if (property === 'windowSize') {
trueWidth = this.width * this.windowSize.x; trueWidth = this.width * this.windowSize.x;
trueHeight = this.height * this.windowSize.y; trueHeight = this.height * this.windowSize.y;
this.canvas.width = trueWidth; this.canvas.width = trueWidth;
this.canvas.height = trueHeight; 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.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.updateInstance('aspectRatio');
this.camera.updateInstance('aspect'); return;
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
} }
if (property === 'logicalSize') {
this.updateInstance('aspectRatio');
return;
}
if (property === 'offset') { if (property === 'offset') {
this.canvas.instance.style.left = (this.offset.x * this.windowSize.x) + 'px'; 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';
return;
} }
if (property === 'canvas') { if (property === 'canvas') {
console.warn('experimental canvas change for renderer'); console.warn('experimental canvas change for renderer');
this.instance.dispose(); this.instance.dispose();
this.createInstance(); this.createInstance();
return;
} }
if (property === 'renderTarget') { if (property === 'renderTarget') {
console.warn('todo: render target change'); console.warn('todo: render target change');
return;
} }
if (property === 'clippingPlanes') { if (property === 'clippingPlanes') {
console.warn('todo: clipping planes change'); console.warn('todo: clipping planes change');
return;
} }
if (property === 'clearColor') { if (property === 'clearColor') {
@ -504,6 +554,7 @@ GameLib.D3.Renderer.prototype.updateInstance = function(property) {
), ),
1 - this.clearColor.a 1 - this.clearColor.a
); );
return;
} }
if (property === 'camera') { if (property === 'camera') {
@ -575,8 +626,10 @@ GameLib.D3.Renderer.prototype.toApiObject = function() {
this.depth, this.depth,
this.logarithmicDepthBuffer, this.logarithmicDepthBuffer,
this.localClippingEnabled, this.localClippingEnabled,
this.fullscreen, this.aspectRatio,
this.scaleMode,
this.windowSize.toApiObject(), this.windowSize.toApiObject(),
this.logicalSize.toApiObject(),
this.offset.toApiObject(), this.offset.toApiObject(),
GameLib.Utils.IdOrNull(this.canvas), GameLib.Utils.IdOrNull(this.canvas),
GameLib.Utils.IdOrNull(this.renderTarget), GameLib.Utils.IdOrNull(this.renderTarget),
@ -604,21 +657,3 @@ GameLib.D3.Renderer.prototype.toApiObject = function() {
return apiRenderer; 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); GameLib.Component.call(this);
}; };
@ -120,7 +126,8 @@ GameLib.D3.Shadow.prototype.toApiObject = function() {
GameLib.D3.Shadow.prototype.updateFromInstance = function() { GameLib.D3.Shadow.prototype.updateFromInstance = function() {
this.bias = this.instance.bias; 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.radius = this.instance.radius;
this.camera.instance = this.instance.camera; this.camera.instance = this.instance.camera;
this.camera.updateFromInstance(); this.camera.updateFromInstance();

View File

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

View File

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

View File

@ -72,6 +72,8 @@ GameLib.System.GUI.prototype.initialize = function(gui) {
gui.instance.domElement.style.right = '0px'; gui.instance.domElement.style.right = '0px';
gui.domElement.instance.parentElement.appendChild(gui.instance.domElement); 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) { 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') { } else if (property === 'socketType') {
controllers.push( controllers.push(
folder.add( 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( controllers.push(
folder.add( folder.add(
object, object,

View File

@ -1083,6 +1083,24 @@ GameLib.System.Input.prototype.onMouseMoveEdit = function(event) {
mouse.y = event.clientY; 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 * @param event
*/ */
GameLib.System.Input.prototype.onMouseWheelEdit = function(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) { GameLib.System.Input.prototype.selectFace = function(mesh, face) {

View File

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