rudimentary uv editing capabilities - face select mode

beta.r3js.org
-=yb4f310 2018-01-19 15:04:54 +01:00
parent 3bc46a2d6f
commit b3d9556461
21 changed files with 630 additions and 426 deletions

View File

@ -97,7 +97,7 @@ GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED = 0x4f;
GameLib.Event.CAST_SOURCE_CHANGED = 0x50;
GameLib.Event.ANIMATION_MESH_ADDED = 0x51;
GameLib.Event.ANIMATION_MESH_REMOVED = 0x52;
GameLib.Event.DOM_ELEMENT_CHANGE = 0x53;
GameLib.Event.CANVAS_CHANGE = 0x53;
GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE = 0x54;
GameLib.Event.LOAD_FONT = 0x55;
GameLib.Event.FONT_NOT_FOUND = 0x56;
@ -123,6 +123,9 @@ GameLib.Event.CUSTOM_GAME_START = 0x69;
GameLib.Event.AUDIO_MUTED = 0x6a;
GameLib.Event.AUDIO_UNMUTED = 0x6b;
GameLib.Event.RECEIVE_DESTINATION_CHANGED = 0x6c;
GameLib.Event.SELECTION_MODE_CHANGE = 0x6d;
GameLib.Event.MESH_FACE_SELECTED = 0x6e;
GameLib.Event.MESH_FACE_DESELECTED = 0x6f;
/**
* Returns string name of event ID
@ -241,6 +244,9 @@ GameLib.Event.GetEventName = function(number) {
case 0x6a : return 'audio_muted';
case 0x6b : return 'audio_unmuted';
case 0x6c : return 'receive_destination_changed';
case 0x6d : return 'selection_mode_change';
case 0x6e : return 'mesh_face_selected';
case 0x6f : return 'mesh_face_deselected';
break;
}

View File

@ -220,7 +220,7 @@ GameLib.Component.PASS = 0xd;
GameLib.Component.SCENE = 0xe;
GameLib.Component.RAYCASTER = 0xf;
GameLib.Component.TEXT = 0x10;
//GameLib.Component.EDITOR = 0x11;
GameLib.Component.FACE = 0x11;
GameLib.Component.VIEWPORT = 0x12;
GameLib.Component.SYSTEM = 0x13;
GameLib.Component.GRAPHICS = 0x14;
@ -405,7 +405,12 @@ GameLib.Component.GetComponentInfo = function(number) {
constructor : GameLib.D3.Text,
apiConstructor : GameLib.D3.API.Text
};
case 0x11 : return null;
case 0x11 : return {
name : 'GameLib.D3.Face',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Face,
apiConstructor : GameLib.D3.API.Face
};
case 0x12 : return {
name : 'GameLib.D3.Viewport',
runtime : GameLib.Component.GRAPHICS_RUNTIME,

View File

@ -3,7 +3,7 @@
* @param id
* @param controlsType
* @param name
* @param domElement
* @param canvas
* @param parentEntity
* @constructor
*/
@ -11,7 +11,7 @@ GameLib.API.Controls = function(
id,
name,
controlsType,
domElement,
canvas,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
@ -65,10 +65,10 @@ GameLib.API.Controls = function(
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElement)) {
domElement = null;
if (GameLib.Utils.UndefinedOrNull(canvas)) {
canvas = null;
}
this.domElement = domElement;
this.canvas = canvas;
var componentType = GameLib.Component.CONTROLS;
@ -108,19 +108,3 @@ GameLib.API.Controls.CONTROLS_TYPE_EDITOR = 0x0;
GameLib.API.Controls.CONTROLS_TYPE_TOUCH = 0x1;
GameLib.API.Controls.CONTROLS_TYPE_KEYBOARD = 0x2;
GameLib.API.Controls.CONTROLS_TYPE_MOUSE = 0x3;
/**
* Returns an API Controls from an Object
* @param objectControls
* @constructor
*/
GameLib.API.Controls.FromObject = function (objectControls){
return new GameLib.API.Controls(
objectControls.id,
objectControls.name,
objectControls.controlsType,
objectControls.domElement,
objectControls.parentEntity
);
};

View File

@ -21,7 +21,7 @@ GameLib.API.Controls.D3.Editor = function(
apiControls.id,
apiControls.name,
apiControls.controlsType,
apiControls.domElement,
apiControls.canvas,
apiControls.parentEntity
);
@ -43,19 +43,3 @@ GameLib.API.Controls.D3.Editor = function(
GameLib.API.Controls.D3.Editor.prototype = Object.create(GameLib.API.Controls.prototype);
GameLib.API.Controls.D3.Editor.prototype.constructor = GameLib.API.Controls.D3.Editor;
/**
* Creates an API.Controls.D3.Editor from an Object Cast
* @param objectControls
* @constructor
*/
GameLib.API.Controls.D3.Editor.FromObject = function(objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.API.Controls.D3.Editor(
apiControls,
objectControls.raycaster,
objectControls.camera
);
};

View File

@ -17,7 +17,7 @@ GameLib.API.Controls.Keyboard = function(
apiControls.id,
apiControls.name,
apiControls.controlsType,
apiControls.domElement,
apiControls.canvas,
apiControls.parentEntity
);
@ -29,17 +29,3 @@ GameLib.API.Controls.Keyboard = function(
GameLib.API.Controls.Keyboard.prototype = Object.create(GameLib.API.Controls.prototype);
GameLib.API.Controls.Keyboard.prototype.constructor = GameLib.API.Controls.Keyboard;
/**
* Creates an API.Controls.Keyboard from an Object Cast
* @param objectControls
* @constructor
*/
GameLib.API.Controls.Keyboard.FromObject = function(objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.API.Controls.Keyboard(
apiControls
);
};

View File

@ -17,7 +17,7 @@ GameLib.API.Controls.Mouse = function(
apiControls.id,
apiControls.name,
apiControls.controlsType,
apiControls.domElement,
apiControls.canvas,
apiControls.parentEntity
);
@ -30,16 +30,3 @@ GameLib.API.Controls.Mouse = function(
GameLib.API.Controls.Mouse.prototype = Object.create(GameLib.API.Controls.prototype);
GameLib.API.Controls.Mouse.prototype.constructor = GameLib.API.Controls.Mouse;
/**
* Creates an API.Controls.Mouse from an Object Cast
* @param objectControls
* @constructor
*/
GameLib.API.Controls.Mouse.FromObject = function(objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.API.Controls.Mouse(
apiControls
);
};

View File

@ -19,7 +19,7 @@ GameLib.API.Controls.Touch = function(
apiControls.id,
apiControls.name,
apiControls.controlsType,
apiControls.domElement,
apiControls.canvas,
apiControls.parentEntity
);
@ -36,18 +36,3 @@ GameLib.API.Controls.Touch = function(
GameLib.API.Controls.Touch.prototype = Object.create(GameLib.API.Controls.prototype);
GameLib.API.Controls.Touch.prototype.constructor = GameLib.API.Controls.Touch;
/**
* Creates an API.Controls.Touch from an Object Cast
* @param objectControls
* @constructor
*/
GameLib.API.Controls.Touch.FromObject = function(objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.API.Controls.Touch(
apiControls,
objectControls.sensitivity
);
};

View File

@ -16,12 +16,12 @@ GameLib.Controls = function (
apiControls.id,
apiControls.name,
apiControls.controlsType,
apiControls.domElement,
apiControls.canvas,
apiControls.parentEntity
);
var linkedObjects = {
domElement : GameLib.Canvas
canvas : GameLib.Canvas
};
var delayed = false;
@ -58,9 +58,9 @@ GameLib.Controls.prototype.createInstance = function() {
*/
GameLib.Controls.prototype.updateInstance = function(property) {
if (property === 'domElement') {
if (property === 'canvas') {
GameLib.Event.Emit(
GameLib.Event.DOM_ELEMENT_CHANGE,
GameLib.Event.CANVAS_CHANGE,
{
component: this
}
@ -80,24 +80,9 @@ GameLib.Controls.prototype.toApiObject = function() {
this.id,
this.name,
this.controlsType,
GameLib.Utils.IdOrNull(this.domElement),
GameLib.Utils.IdOrNull(this.canvas),
GameLib.Utils.IdOrNull(this.parentEntity)
);
return apiControls;
};
/**
* Converts a data object to a GameLib.Controls
* @param objectControls {Object}
* @constructor
*/
GameLib.Controls.FromObject = function(objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.Controls(
apiControls
);
};

View File

@ -63,13 +63,13 @@ GameLib.Controls.D3.Editor.prototype.createInstance = function() {
throw new Error('No camera at time of instance');
}
if (!this.domElement || !this.domElement.instance) {
throw new Error('No dom element at time of instance');
if (!this.canvas || !this.canvas.instance) {
throw new Error('No canvas at time of instance');
}
this.instance = new THREE.EditorControls(
this.camera.instance,
this.domElement.instance
this.canvas.instance
);
GameLib.Controls.prototype.createInstance.call(this);

View File

@ -11,6 +11,7 @@
* @param vertexColors
* @param vertexNormals
* @param normal
* @param selected
* @constructor
*/
GameLib.D3.API.Face = function(
@ -24,7 +25,10 @@ GameLib.D3.API.Face = function(
color,
vertexColors,
vertexNormals,
normal
normal,
selected,
parentMesh,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
@ -81,96 +85,111 @@ GameLib.D3.API.Face = function(
normal = null;
}
this.normal = normal;
if (GameLib.Utils.UndefinedOrNull(selected)) {
selected = false;
}
this.selected = selected;
if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
parentMesh = null;
}
this.parentMesh = parentMesh;
GameLib.API.Component.call(
this,
GameLib.Component.FACE,
parentEntity
);
};
/**
* We don't inherit from component - it makes the entitymanager too heavy - all faces end up in the register etc..
*/
// GameLib.D3.API.Face.prototype = Object.create(GameLib.API.Component.prototype);
// GameLib.D3.API.Face.prototype.constructor = GameLib.D3.API.Face;
GameLib.D3.API.Face.prototype = Object.create(GameLib.API.Component.prototype);
GameLib.D3.API.Face.prototype.constructor = GameLib.D3.API.Face;
/**
* Returns an API Face from a data object
* @constructor
* @param objectFace
*/
GameLib.D3.API.Face.FromObject = function(objectFace) {
var apiUvs = objectFace.uvs.reduce(
function(result, uvArray, index) {
result[index] = uvArray.reduce(
function(uvResult, uv) {
uvResult.push(GameLib.API.Vector2.FromObject(uv));
return uvResult;
},
[]
);
return result;
},
[]
);
var apiVertexColors = objectFace.vertexColors.map(
function(vertexColor) {
return GameLib.API.Color.FromObject(vertexColor);
}
);
var apiColor = null;
if (objectFace.color) {
apiColor = GameLib.API.Color.FromObject(objectFace.color);
}
var apiVertexNormals = objectFace.vertexNormals.map(
function(vertexNormal) {
return GameLib.API.Vector3.FromObject(vertexNormal);
}
);
var apiNormal = null;
if (objectFace.normal) {
apiNormal = GameLib.API.Vector3.FromObject(objectFace.normal);
}
return new GameLib.D3.API.Face(
objectFace.id,
objectFace.name,
objectFace.v0index,
objectFace.v1index,
objectFace.v2index,
objectFace.materialIndex,
apiUvs,
apiColor,
apiVertexColors,
apiVertexNormals,
apiNormal
);
};
/**
* Clone a Face
* @returns {GameLib.D3.API.Face}
*/
GameLib.D3.API.Face.prototype.clone = function(){
return new GameLib.D3.API.Face(
this.id,
this.name,
this.v0index,
this.v1index,
this.v2index,
this.materialIndex,
this.uvs,
this.color,
this.vertexColors,
this.vertexNormals,
this.normal
);
};
// GameLib.D3.API.Face.FromObject = function(objectFace) {
//
// var apiUvs = objectFace.uvs.reduce(
//
// function(result, uvArray, index) {
//
// result[index] = uvArray.reduce(
// function(uvResult, uv) {
// uvResult.push(GameLib.API.Vector2.FromObject(uv));
// return uvResult;
// },
// []
// );
//
// return result;
// },
// []
// );
//
// var apiVertexColors = objectFace.vertexColors.map(
// function(vertexColor) {
// return GameLib.API.Color.FromObject(vertexColor);
// }
// );
//
// var apiColor = null;
// if (objectFace.color) {
// apiColor = GameLib.API.Color.FromObject(objectFace.color);
// }
//
// var apiVertexNormals = objectFace.vertexNormals.map(
// function(vertexNormal) {
// return GameLib.API.Vector3.FromObject(vertexNormal);
// }
// );
//
// var apiNormal = null;
// if (objectFace.normal) {
// apiNormal = GameLib.API.Vector3.FromObject(objectFace.normal);
// }
//
// return new GameLib.D3.API.Face(
// objectFace.id,
// objectFace.name,
// objectFace.v0index,
// objectFace.v1index,
// objectFace.v2index,
// objectFace.materialIndex,
// apiUvs,
// apiColor,
// apiVertexColors,
// apiVertexNormals,
// apiNormal
// );
// };
//
// /**
// * Clone a Face
// * @returns {GameLib.D3.API.Face}
// */
// GameLib.D3.API.Face.prototype.clone = function(){
// return new GameLib.D3.API.Face(
// this.id,
// this.name,
// this.v0index,
// this.v1index,
// this.v2index,
// this.materialIndex,
// this.uvs,
// this.color,
// this.vertexColors,
// this.vertexNormals,
// this.normal
// );
// };
/**
* Returns true if two triangles are equal (their vertex indices match in some order)

View File

@ -249,7 +249,7 @@ GameLib.D3.API.Material = function(
this.wireframeLineJoin = wireframeLineJoin;
if (GameLib.Utils.UndefinedOrNull(vertexColors)) {
vertexColors = GameLib.D3.Material.TYPE_NO_COLORS;
vertexColors = GameLib.D3.Material.TYPE_FACE_COLORS;
}
this.vertexColors = vertexColors;

View File

@ -308,7 +308,7 @@ GameLib.D3.API.Renderer = function (
camera = new GameLib.D3.API.Camera(
null,
GameLib.D3.API.Camera.PERSPECTIVE_CAMERA,
null,
'Render Camera',
null,
this.width / this.height
);
@ -319,7 +319,7 @@ GameLib.D3.API.Renderer = function (
editCamera = new GameLib.D3.API.Camera(
null,
GameLib.D3.API.Camera.PERSPECTIVE_CAMERA,
null,
'Edit Camera',
null,
this.width / this.height
);

View File

@ -89,7 +89,7 @@ GameLib.D3.API.Scene = function(
this.gridSize = gridSize;
if (GameLib.Utils.UndefinedOrNull(gridColor)) {
gridColor = new GameLib.API.Color(0.1, 0.1, 0.1);
gridColor = new GameLib.API.Color(0.14117641, 0.576470588, 0.882352941);
}
this.gridColor = gridColor;

View File

@ -34,7 +34,10 @@ GameLib.D3.Face = function Face(
apiFace.color,
apiFace.vertexColors,
apiFace.vertexNormals,
apiFace.normal
apiFace.normal,
apiFace.selected,
apiFace.parentMesh,
apiFace.parentEntity
);
if (this.implementation instanceof GameLib.GraphicsRuntime) {
@ -77,9 +80,9 @@ GameLib.D3.Face = function Face(
this.uvs = this.uvs.reduce(
function(result, uvArray, index) {
function(result, uvs, uvSet) {
result[index] = uvArray.reduce(
result[uvSet] = uvs.reduce(
function(uvResult, uv) {
uvResult.push(
@ -113,12 +116,60 @@ GameLib.D3.Face = function Face(
GameLib.D3.Face.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.Face.prototype.constructor = GameLib.D3.Face;
GameLib.D3.Face.prototype.createInstance = function() {
/**
* We don't follow the standard procedure for Faces - We don't want them in the EntityManager registry - so
* they don't call component createinstance
* @param parentMesh
*/
GameLib.D3.Face.prototype.createInstance = function(parentMesh) {
this.instance = new THREE.Face3(
this.v0index,
this.v1index,
this.v2index
);
if (this.normal) {
this.instance.normal = new THREE.Vector3(
this.normal.x,
this.normal.y,
this.normal.z
);
}
if (this.color) {
this.instance.color = new THREE.Color(
this.color.r,
this.color.g,
this.color.b
)
}
this.instance.materialIndex = this.materialIndex;
if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
console.warn('please pass a parentmesh to face createInstance()');
}
this.parentMesh = parentMesh;
};
GameLib.D3.Face.prototype.updateInstance = function() {
GameLib.D3.Face.prototype.updateInstance = function(property, uvSet, uvIndex) {
if (property === 'materialIndex') {
this.instance.materialIndex = this.materialIndex;
this.parentMesh.instance.geometry.groupsNeedUpdate = true;
return;
}
if (property === 'uvs') {
this.uvs[uvSet][uvIndex].instance.x = this.uvs[uvSet][uvIndex].x;
this.uvs[uvSet][uvIndex].instance.y = this.uvs[uvSet][uvIndex].y;
this.parentMesh.instance.geometry.uvsNeedUpdate = true;
return;
}
console.warn('todo: update face property: ' + property);
};
GameLib.D3.Face.prototype.toApiObject = function() {
@ -159,20 +210,60 @@ GameLib.D3.Face.prototype.toApiObject = function() {
this.vertexNormals.map(function(vertexNormal){
return vertexNormal.toApiObject();
}),
this.normal.toApiObject()
this.normal.toApiObject(),
this.selected
);
};
/**
* @param implementation
* @param objectFace
* @returns {GameLib.D3.Face}
* @constructor
*/
GameLib.D3.Face.FromObject = function(implementation, objectFace) {
return new GameLib.D3.Face(
implementation,
GameLib.D3.API.Face.FromObject(objectFace)
);
GameLib.D3.Face.prototype.createHelper = function(mesh) {
this.backupProperties = {
color : {
r: this.color.r,
g: this.color.g,
b: this.color.b
},
material : {
emissive : {
r: mesh.materials[this.materialIndex].emissive.r,
g: mesh.materials[this.materialIndex].emissive.g,
b: mesh.materials[this.materialIndex].emissive.b
}
},
vertexColors : mesh.materials[this.materialIndex].vertexColors
};
this.instance.color.r = 1;
this.instance.color.g = 0;
this.instance.color.b = 0;
mesh.instance.geometry.colorsNeedUpdate = true;
//
// mesh.materials[this.materialIndex].emissive.r = 0.5;
// mesh.materials[this.materialIndex].emissive.g = 0.5;
// mesh.materials[this.materialIndex].emissive.b = 0.5;
// mesh.materials[this.materialIndex].updateInstance('emissive');
mesh.materials[this.materialIndex].vertexColors = GameLib.D3.Material.TYPE_FACE_COLORS;
mesh.materials[this.materialIndex].updateInstance('vertexColors');
};
GameLib.D3.Face.prototype.removeHelper = function(mesh) {
this.instance.color.r = this.backupProperties.color.r;
this.instance.color.g = this.backupProperties.color.g;
this.instance.color.b = this.backupProperties.color.b;
mesh.instance.geometry.colorsNeedUpdate = true;
// mesh.materials[this.materialIndex].emissive.r = this.backupProperties.material.emissive.r;
// mesh.materials[this.materialIndex].emissive.g = this.backupProperties.material.emissive.g;
// mesh.materials[this.materialIndex].emissive.b = this.backupProperties.material.emissive.b;
// mesh.materials[this.materialIndex].updateInstance('emissive');
mesh.materials[this.materialIndex].vertexColors = this.backupProperties.vertexColors;
mesh.materials[this.materialIndex].updateInstance('vertexColors');
};

View File

@ -382,7 +382,7 @@ GameLib.D3.Material.prototype.createToonMaterialInstance = function() {
wireframeLinewidth: this.wireframeLineWidth,
wireframeLinecap: this.wireframeLineCap,
wireframeLinejoin: this.wireframeLineJoin,
vertexColors: GameLib.D3.Material.TYPE_VERTEX_COLORS,
vertexColors: this.vertexColors,
skinning: this.skinning,
morphTargets: this.morphTargets,
morphNormals: this.morphNormals
@ -428,7 +428,7 @@ GameLib.D3.Material.prototype.createStandardMaterialInstance = function() {
wireframeLinewidth: this.wireframeLineWidth,
wireframeLinecap: this.wireframeLineCap,
wireframeLinejoin: this.wireframeLineJoin,
vertexColors: GameLib.D3.Material.TYPE_VERTEX_COLORS,
vertexColors: this.vertexColors,
skinning: this.skinning,
morphTargets: this.morphTargets,
morphNormals: this.morphNormals
@ -554,7 +554,7 @@ GameLib.D3.Material.prototype.createPhongMaterialInstance = function() {
wireframeLinewidth: this.wireframeLineWidth,
wireframeLinecap: this.wireframeLineCap,
wireframeLinejoin: this.wireframeLineJoin,
vertexColors: GameLib.D3.Material.TYPE_VERTEX_COLORS,
vertexColors: this.vertexColors,
skinning: this.skinning,
morphTargets: this.morphTargets,
morphNormals: this.morphNormals
@ -583,7 +583,7 @@ GameLib.D3.Material.prototype.createMeshBasicMaterialInstance = function() {
visible: this.visible,
side: this.side,
color: this.color.instance,
vertexColors: GameLib.D3.Material.TYPE_VERTEX_COLORS,
vertexColors: this.vertexColors,
fog: this.fog
});
};
@ -713,7 +713,7 @@ GameLib.D3.Material.prototype.updateToonMaterialInstance = function(property) {
this.instance.wireframeLinewidth = this.wireframeLineWidth;
this.instance.wireframeLinecap = this.wireframeLineCap;
this.instance.wireframeLinejoin = this.wireframeLineJoin;
this.instance.vertexColors = GameLib.D3.Material.TYPE_VERTEX_COLORS;
this.instance.vertexColors = this.vertexColors;
this.instance.skinning = this.skinning;
this.instance.morphTargets = this.morphTargets;
this.instance.morphNormals = this.morphNormals;
@ -757,7 +757,7 @@ GameLib.D3.Material.prototype.updateStandardMaterialInstance = function(property
this.instance.wireframeLinewidth = this.wireframeLineWidth;
this.instance.wireframeLinecap = this.wireframeLineCap;
this.instance.wireframeLinejoin = this.wireframeLineJoin;
this.instance.vertexColors = GameLib.D3.Material.TYPE_VERTEX_COLORS;
this.instance.vertexColors = this.vertexColors;
this.instance.skinning = this.skinning;
this.instance.morphTargets = this.morphTargets;
this.instance.morphNormals = this.morphNormals;
@ -786,7 +786,7 @@ GameLib.D3.Material.prototype.updatePointsMaterialInstance = function(property)
this.instance.color = this.color.instance;
this.instance.size = this.pointSize;
this.instance.sizeAttenuation = this.pointSizeAttenuation;
//this.instance.vertexColors = GameLib.D3.Material.TYPE_VERTEX_COLORS;
//this.instance.vertexColors = this.vertexColors;
//this.instance.fog = this.fog;
};
@ -837,7 +837,7 @@ GameLib.D3.Material.prototype.updateLineBasicMaterialInstance = function(propert
this.instance.linecap = linecap;
this.instance.linejoin = linejoin;
//this.instance.vertexColors = GameLib.D3.Material.TYPE_VERTEX_COLORS;
//this.instance.vertexColors = this.vertexColors;
//this.instance.fog = this.fog;
};
@ -881,7 +881,7 @@ GameLib.D3.Material.prototype.updatePhongMaterialInstance = function(property) {
this.instance.wireframeLinewidth = this.wireframeLineWidth;
this.instance.wireframeLinecap = this.wireframeLineCap;
this.instance.wireframeLinejoin = this.wireframeLineJoin;
this.instance.vertexColors = GameLib.D3.Material.TYPE_VERTEX_COLORS;
this.instance.vertexColors = this.vertexColors;
this.instance.skinning = this.skinning;
this.instance.morphTargets = this.morphTargets;
this.instance.morphNormals = this.morphNormals;
@ -908,7 +908,7 @@ GameLib.D3.Material.prototype.updateMeshBasicMaterialInstance = function(propert
this.instance.visible = this.visible;
this.instance.side = this.side;
this.instance.color = this.color.instance;
this.instance.vertexColors = GameLib.D3.Material.TYPE_VERTEX_COLORS;
this.instance.vertexColors = this.vertexColors;
this.instance.fog = this.fog;
};
@ -994,6 +994,16 @@ GameLib.D3.Material.prototype.updateInstance = function(property) {
this.updateTextures();
}
if (property === 'emissive') {
this.emissive.instance.r = this.emissive.r;
this.emissive.instance.g = this.emissive.g;
this.emissive.instance.b = this.emissive.b;
this.instance.emissive.copy(this.emissive.instance);
return;
}
if (this.materialType === GameLib.D3.Material.MATERIAL_TYPE_STANDARD) {
this.updateStandardMaterialInstance(property);
} else if (this.materialType === GameLib.D3.Material.MATERIAL_TYPE_POINTS) {

View File

@ -372,41 +372,18 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
standardUvs.push(
face.uvs[0].map(
function(uv) {
return new THREE.Vector2(
uv.x,
uv.y
)
return uv.instance;
}
)
);
}
var faceInstance = new THREE.Face3(
face.v0index,
face.v1index,
face.v2index
);
if (!face.instance) {
face.createInstance(this);
}
if (face.normal) {
faceInstance.normal = new THREE.Vector3(
face.normal.x,
face.normal.y,
face.normal.z
);
}
if (face.color) {
faceInstance.color = new THREE.Color(
face.color.r,
face.color.g,
face.color.b
)
}
faceInstance.materialIndex = face.materialIndex;
return faceInstance;
}
return face.instance;
}.bind(this)
);
/**

View File

@ -180,7 +180,9 @@ GameLib.D3.Raycaster.prototype.getIntersectedObjects = function(meshes) {
result.push(
{
mesh: mesh,
distance : intersects[0].distance
distance : intersects[0].distance,
face: mesh.faces[intersects[0].faceIndex],
faceIndex: intersects[0].faceIndex
}
);
}

View File

@ -29,7 +29,7 @@ GameLib.Mouse.prototype.constructor = GameLib.Mouse;
* createInstance
*/
GameLib.Mouse.prototype.createInstance = function() {
this.instance = true;
this.instance = {};
GameLib.Component.prototype.createInstance.call(this);
};
@ -38,9 +38,15 @@ GameLib.Mouse.prototype.createInstance = function() {
* @param property
*/
GameLib.Mouse.prototype.updateInstance = function(property) {
if (GameLib.Utils.UndefinedOrNull(property)) {
console.warn('unknown property update for Mouse: ' + property);
if (property === 'x') {
this.instance.x = this.x;
}
if (property === 'y') {
this.instance.y = this.y;
}
};
/**
@ -56,15 +62,3 @@ GameLib.Mouse.prototype.toApiObject = function() {
this.parentEntity
);
};
/**
* GameLib.Mouse from Object
* @param objectMouse
* @returns {GameLib.Mouse}
* @constructor
*/
GameLib.Mouse.FromObject = function(objectMouse) {
return new GameLib.Mouse(
GameLib.API.Mouse.FromObject(objectMouse)
);
};

View File

@ -22,6 +22,8 @@ GameLib.System.GUI = function(
*/
this.backupComponents = [];
this.faces = [];
this.exclusiveMode = false;
this.buildGUISubscription = null;
@ -43,7 +45,11 @@ GameLib.System.GUI = function(
this.removeComponentSubscription = null;
this.windowResizeSubscription = null;
this.meshFaceSelectedSubscription = null;
this.meshFaceDeselectedSubscription = null;
};
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
@ -112,6 +118,16 @@ GameLib.System.GUI.prototype.start = function() {
this.windowResize.bind(this)
);
this.meshFaceSelectedSubscription = GameLib.Event.Subscribe(
GameLib.Event.MESH_FACE_SELECTED,
this.meshFaceSelected.bind(this)
);
this.meshFaceDeselectedSubscription = GameLib.Event.Subscribe(
GameLib.Event.MESH_FACE_DESELECTED,
this.meshFaceDeselected.bind(this)
);
this.guis = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.GUI);
this.guis.map(
function(gui){
@ -539,14 +555,14 @@ GameLib.System.GUI.prototype.buildParentSelectionControl = function(folder, comp
};
GameLib.System.GUI.prototype.buildArrayManagerControl = function(
folder,
componentTemplate,
property
folder,
componentTemplate,
property
) {
var constructors = componentTemplate.template.linkedObjects[property];
var constructors = componentTemplate.template.linkedObjects[property];
if (constructors instanceof Array) {
if (constructors instanceof Array) {
/**
* All good
*/
@ -558,49 +574,49 @@ GameLib.System.GUI.prototype.buildArrayManagerControl = function(
return;
}
var object = componentTemplate.template;
var object = componentTemplate.template;
var array = object[property];
var array = object[property];
var addArrayItem = function(item, index){
var addArrayItem = function(item, index){
var name = 'invalid item';
var name = 'invalid item';
if (item && item.name) {
name = item.name;
if (item && item.name) {
name = item.name;
}
var controller = folder.add(
{
'remove' : function() {
componentTemplate.affected.map(function(component){
component[property].splice(index, 1);
folder.remove(controller);
});
}
},
'remove'
).name('remove ' + property + '[' + index + '] - ' + name);
var controller = folder.add(
{
'remove' : function() {
componentTemplate.affected.map(function(component){
component[property].splice(index, 1);
folder.remove(controller);
});
}
},
'remove'
).name('remove ' + property + '[' + index + '] - ' + name);
folder.updateDisplay();
};
folder.updateDisplay();
};
array.map(addArrayItem);
array.map(addArrayItem);
var idObject = {};
var idObject = {};
var selectionObject = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructors).reduce(
function(result, component) {
result[component.name] = component;
idObject[component.id] = component;
return result;
},
{
'none' : null
}
);
var selectionObject = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructors).reduce(
function(result, component) {
result[component.name] = component;
idObject[component.id] = component;
return result;
},
{
'none' : null
}
);
var activeSelection = {
var activeSelection = {
component: null,
add: function () {
@ -629,17 +645,60 @@ GameLib.System.GUI.prototype.buildArrayManagerControl = function(
}
};
folder.add(activeSelection, 'component', selectionObject).name('select ' + property).onChange(
function(value){
if (value === 'null') {
activeSelection['component'] = null;
} else {
activeSelection['component'] = idObject[value];
}
}
).listen();
folder.add(activeSelection, 'component', selectionObject).name('select ' + property).onChange(
function(value){
if (value === 'null') {
activeSelection['component'] = null;
} else {
activeSelection['component'] = idObject[value];
}
}
).listen();
folder.add(activeSelection, 'add').name('add to ' + property);
};
/**
* This is only for uvs right now
*/
GameLib.System.GUI.prototype.buildUVManagerControl = function(
folder,
componentTemplate,
property
) {
var object = componentTemplate.template;
var array = object[property];
array.map(
function(uvs, uvSet) {
/**
* uvs should be an array of three vector2's
*/
uvs.map(
function(uv, uvIndex) {
var onChange = function(__uvSet, __uvIndex, __property) {
return function(value) {
componentTemplate.affected.map(
function (component) {
component.uvs[__uvSet][__uvIndex][__property] = value;
component.updateInstance('uvs', __uvSet, __uvIndex);
}
);
}
};
folder.add(uv, 'x').name('uvs[' + uvSet + '][' + uvIndex +'].x').onChange(onChange(uvSet, uvIndex, 'x')).listen();
folder.add(uv, 'y').name('uvs[' + uvSet + '][' + uvIndex +'].y').onChange(onChange(uvSet, uvIndex, 'y')).listen();
}
)
}
);
folder.add(activeSelection, 'add').name('add to ' + property);
};
@ -1566,6 +1625,33 @@ GameLib.System.GUI.prototype.meshDeslected = function(data) {
};
GameLib.System.GUI.prototype.meshFaceSelected = function(data) {
this.faces.push(data.face);
this.buildGUI({
components : this.faces
})
};
GameLib.System.GUI.prototype.meshFaceDeselected = function(data) {
var index = this.faces.indexOf(data.face);
if (index !== -1) {
this.faces.splice(index, 1);
if (this.faces.length === 0) {
this.buildGUI({});
} else {
this.buildGUI({components : this.faces})
}
} else {
console.warn('could not remove face');
}
};
/**
* This function responds to the BUILD_GUI event, data contains the components to build a GUI for data.
*
@ -1938,6 +2024,10 @@ GameLib.System.GUI.prototype.buildGUI = function(data) {
continue;
}
if (templateProperty === 'uvs') {
this.buildUVManagerControl(folder, componentTemplate, templateProperty);
}
if (
componentTemplate.template.linkedObjects &&
componentTemplate.template.linkedObjects[templateProperty] instanceof Array
@ -2045,6 +2135,10 @@ GameLib.System.GUI.prototype.stop = function() {
this.windowResizeSubscription.remove();
this.meshFaceSelectedSubscription.remove();
this.meshFaceDeselectedSubscription.remove();
this.guis = [];
};

View File

@ -62,7 +62,10 @@ GameLib.System.Input = function(
this.delayedInstanceEncounteredSubscription = null;
this.instanceCreatedSubscription = null;
this.removeComponentSubscription = null;
this.domElementChangeSubscription = null;
this.canvasChangeSubscription = null;
this.selectionModeChangeSubscription = null;
this.selectionMode = GameLib.System.Input.SELECTION_MODE_DEFAULT;
this.mouse = new GameLib.Mouse();
};
@ -70,6 +73,10 @@ GameLib.System.Input = function(
GameLib.System.Input.prototype = Object.create(GameLib.System.prototype);
GameLib.System.Input.prototype.constructor = GameLib.System.Input;
GameLib.System.Input.SELECTION_MODE_MESH = 0x1;
GameLib.System.Input.SELECTION_MODE_FACE = 0x2;
GameLib.System.Input.SELECTION_MODE_DEFAULT = 0x1;
/**
*
*/
@ -92,9 +99,14 @@ GameLib.System.Input.prototype.start = function() {
this.delayedInstanceEncountered.bind(this)
);
this.domElementChangeSubscription = GameLib.Event.Subscribe(
GameLib.Event.DOM_ELEMENT_CHANGE,
this.domElementChange.bind(this)
this.canvasChangeSubscription = GameLib.Event.Subscribe(
GameLib.Event.CANVAS_CHANGE,
this.canvasChange.bind(this)
);
this.selectionModeChangeSubscription = GameLib.Event.Subscribe(
GameLib.Event.SELECTION_MODE_CHANGE,
this.selectionModeChange.bind(this)
);
this.editorControls = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.CONTROLS_EDITOR);
@ -147,7 +159,9 @@ GameLib.System.Input.prototype.stop = function() {
this.delayedInstanceEncounteredSubscription.remove();
this.domElementChangeSubscription.remove();
this.canvasChangeSubscription.remove();
this.selectionModeChangeSubscription.remove();
this.touchControls.map(
function(touchControl){
@ -187,12 +201,20 @@ GameLib.System.Input.prototype.stop = function() {
*
* @param data
*/
GameLib.System.Input.prototype.domElementChange = function(data) {
GameLib.System.Input.prototype.canvasChange = function(data) {
if (data.component instanceof GameLib.Controls) {
console.log('todo: implement dom element change');
}
};
/**
* Changes the selection mode from face to mesh etc.
* @param data
*/
GameLib.System.Input.prototype.selectionModeChange = function(data) {
this.selectionMode = data.selectionMode;
};
/**
* From now on we want to track everything about a component, only from the systems that are active
* @param data
@ -330,28 +352,28 @@ GameLib.System.Input.prototype.delayedInstanceEncountered = function(data) {
GameLib.System.Input.prototype.registerTouchControls = function(touchControl) {
if (!touchControl.domElement || !touchControl.domElement.instance) {
console.warn('no domElement at time of registration of touch controls - this part will be skipped');
if (!touchControl.canvas || !touchControl.canvas.instance) {
console.warn('no canvas at time of registration of touch controls - this part will be skipped');
return;
}
touchControl.domElement.instance.addEventListener(
touchControl.canvas.instance.addEventListener(
'touchstart',
this.touchStart,
true
);
touchControl.domElement.instance.addEventListener(
touchControl.canvas.instance.addEventListener(
'touchmove',
this.touchMove,
true
);
touchControl.domElement.instance.addEventListener(
touchControl.canvas.instance.addEventListener(
'touchend',
this.touchEnd,
true
);
touchControl.domElement.instance.addEventListener(
touchControl.canvas.instance.addEventListener(
'touchcancel',
this.touchCancel,
true
@ -360,18 +382,18 @@ GameLib.System.Input.prototype.registerTouchControls = function(touchControl) {
GameLib.System.Input.prototype.registerKeyboardControls = function(keyboardControl) {
if (!keyboardControl.domElement || !keyboardControl.domElement.instance) {
console.warn('no domElement at time of registration of keyboard controls - this part will be skipped');
if (!keyboardControl.canvas || !keyboardControl.canvas.instance) {
console.warn('no canvas at time of registration of keyboard controls - this part will be skipped');
return;
}
keyboardControl.domElement.instance.addEventListener(
keyboardControl.canvas.instance.addEventListener(
'keyup',
this.keyboardKeyUp,
true
);
keyboardControl.domElement.instance.addEventListener(
keyboardControl.canvas.instance.addEventListener(
'keydown',
this.keyboardKeyDown,
true
@ -380,30 +402,30 @@ GameLib.System.Input.prototype.registerKeyboardControls = function(keyboardContr
GameLib.System.Input.prototype.registerMouseControls = function(mouseControl) {
if (!mouseControl.domElement || !mouseControl.domElement.instance) {
console.warn('no domElement at time of registration of mouse controls - this part will be skipped');
if (!mouseControl.canvas || !mouseControl.canvas.instance) {
console.warn('no canvas at time of registration of mouse controls - this part will be skipped');
return;
}
mouseControl.domElement.instance.addEventListener(
mouseControl.canvas.instance.addEventListener(
'mousedown',
this.mouseDown,
false
);
mouseControl.domElement.instance.addEventListener(
mouseControl.canvas.instance.addEventListener(
'mousemove',
this.mouseMove,
false
);
mouseControl.domElement.instance.addEventListener(
mouseControl.canvas.instance.addEventListener(
'wheel',
this.mouseWheel,
false
);
mouseControl.domElement.instance.addEventListener(
mouseControl.canvas.instance.addEventListener(
'mouseup',
this.mouseUp,
false
@ -422,7 +444,7 @@ GameLib.System.Input.prototype.registerEditorControls = function(editorControl)
*/
// this.mouseControls.map(
// function(mouseControl) {
// if (mouseControl.domElement.instance === editorControl.domElement.instance) {
// if (mouseControl.canvas.instance === editorControl.canvas.instance) {
// this.deRegisterMouseControls(mouseControl);
// }
// }.bind(this)
@ -433,36 +455,36 @@ GameLib.System.Input.prototype.registerEditorControls = function(editorControl)
*/
this.keyboardControls.map(
function(keyboardControl) {
if (keyboardControl.domElement.instance === editorControl.domElement.instance) {
if (keyboardControl.canvas.instance === editorControl.canvas.instance) {
this.deRegisterKeyboardControls(keyboardControl);
}
}.bind(this)
);
if (!editorControl.domElement || !editorControl.domElement.instance) {
console.warn('no domElement at time of registration of editor controls - are you sure you know what you are doing?');
if (!editorControl.canvas || !editorControl.canvas.instance) {
console.warn('no canvas at time of registration of editor controls - are you sure you know what you are doing?');
return;
}
editorControl.domElement.instance.addEventListener(
editorControl.canvas.instance.addEventListener(
'mousedown',
this.mouseDownEdit,
true
);
editorControl.domElement.instance.addEventListener(
editorControl.canvas.instance.addEventListener(
'mousemove',
this.mouseMoveEdit,
true
);
editorControl.domElement.instance.addEventListener(
editorControl.canvas.instance.addEventListener(
'keydown',
this.keyDown,
true
);
editorControl.domElement.instance.addEventListener(
editorControl.canvas.instance.addEventListener(
'keyup',
this.keyUp,
true
@ -473,13 +495,13 @@ GameLib.System.Input.prototype.registerEditorControls = function(editorControl)
*/
editorControl.createInstance();
editorControl.domElement.instance.addEventListener(
editorControl.canvas.instance.addEventListener(
'wheel',
this.mouseWheelEdit,
true
);
editorControl.domElement.instance.addEventListener(
editorControl.canvas.instance.addEventListener(
'mouseup',
this.mouseUpEdit,
true
@ -488,25 +510,25 @@ GameLib.System.Input.prototype.registerEditorControls = function(editorControl)
GameLib.System.Input.prototype.deRegisterEditorControls = function(editorControl) {
editorControl.domElement.instance.removeEventListener(
editorControl.canvas.instance.removeEventListener(
'mousedown',
this.mouseDownEdit,
true
);
editorControl.domElement.instance.removeEventListener(
editorControl.canvas.instance.removeEventListener(
'mousemove',
this.mouseMoveEdit,
true
);
editorControl.domElement.instance.removeEventListener(
editorControl.canvas.instance.removeEventListener(
'keydown',
this.keyDown,
true
);
editorControl.domElement.instance.removeEventListener(
editorControl.canvas.instance.removeEventListener(
'keyup',
this.keyUp,
true
@ -514,13 +536,13 @@ GameLib.System.Input.prototype.deRegisterEditorControls = function(editorControl
editorControl.instance.dispose();
editorControl.domElement.instance.removeEventListener(
editorControl.canvas.instance.removeEventListener(
'wheel',
this.mouseWheelEdit,
true
);
editorControl.domElement.instance.removeEventListener(
editorControl.canvas.instance.removeEventListener(
'mouseup',
this.mouseUpEdit,
true
@ -530,25 +552,25 @@ GameLib.System.Input.prototype.deRegisterEditorControls = function(editorControl
GameLib.System.Input.prototype.deRegisterTouchControls = function(touchControl) {
touchControl.domElement.instance.removeEventListener(
touchControl.canvas.instance.removeEventListener(
'touchstart',
this.touchStart,
true
);
touchControl.domElement.instance.removeEventListener(
touchControl.canvas.instance.removeEventListener(
'touchmove',
this.touchMove,
true
);
touchControl.domElement.instance.removeEventListener(
touchControl.canvas.instance.removeEventListener(
'touchend',
this.touchEnd,
true
);
touchControl.domElement.instance.removeEventListener(
touchControl.canvas.instance.removeEventListener(
'touchcancel',
this.touchCancel,
true
@ -558,13 +580,13 @@ GameLib.System.Input.prototype.deRegisterTouchControls = function(touchControl)
GameLib.System.Input.prototype.deRegisterKeyboardControls = function(keyboardControl) {
keyboardControl.domElement.instance.removeEventListener(
keyboardControl.canvas.instance.removeEventListener(
'keydown',
this.keyboardKeyDown,
true
);
keyboardControl.domElement.instance.removeEventListener(
keyboardControl.canvas.instance.removeEventListener(
'keyup',
this.keyboardKeyUp,
true
@ -575,25 +597,25 @@ GameLib.System.Input.prototype.deRegisterKeyboardControls = function(keyboardCon
GameLib.System.Input.prototype.deRegisterMouseControls = function(mouseControl) {
mouseControl.domElement.instance.removeEventListener(
mouseControl.canvas.instance.removeEventListener(
'mousedown',
this.mouseDown,
false
);
mouseControl.domElement.instance.removeEventListener(
mouseControl.canvas.instance.removeEventListener(
'mousemove',
this.mouseMove,
false
);
mouseControl.domElement.instance.removeEventListener(
mouseControl.canvas.instance.removeEventListener(
'wheel',
this.mouseWheel,
false
);
mouseControl.domElement.instance.removeEventListener(
mouseControl.canvas.instance.removeEventListener(
'mouseup',
this.mouseUp,
false
@ -859,15 +881,20 @@ GameLib.System.Input.prototype.onKeyDown = function(event) {
this.selectAll = !this.selectAll;
meshes = GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Mesh);
if (this.selectionMode === GameLib.System.Input.SELECTION_MODE_MESH) {
meshes.map(function(mesh){
if (this.selectAll) {
this.selectMesh(mesh);
} else {
this.deSelectMesh(mesh);
}
}.bind(this));
meshes = GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Mesh);
meshes.map(function (mesh) {
if (this.selectAll) {
this.selectMesh(mesh);
} else {
this.deselectMesh(mesh);
}
}.bind(this));
} else {
console.warn('todo: implement face select all');
}
GameLib.Event.Emit(
GameLib.Event.BUILD_GUI,
@ -950,74 +977,96 @@ GameLib.System.Input.prototype.onMouseDownEdit = function(event) {
this.mouse.x = (event.offsetX / event.target.width ) * 2 - 1;
this.mouse.y = -(event.offsetY / event.target.height) * 2 + 1;
var scenes = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SCENE);
var renderers = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.RENDERER);
var intersects = scenes.reduce(
renderers.map(
function(renderer) {
function (result, scene) {
var intersects = renderer.scenes.reduce(
editorControl.raycaster.instance.setFromCamera(
this.mouse,
editorControl.camera.instance
function (result, scene) {
editorControl.raycaster.setFromCamera(
this.mouse,
renderer.editCamera
);
intersects = editorControl.raycaster.getIntersectedObjects(scene.meshes);
intersects.map(function (intersect) {
result.push(intersect);
});
return result;
}.bind(this),
[]
);
intersects = editorControl.raycaster.getIntersectedObjects(scene.meshes);
intersects.map(function (intersect) {
result.push(intersect);
});
return result;
}.bind(this),
[]
);
intersects.sort(
function (a, b) {
if (a.distance < b.distance) {
return -1;
if (intersects.length < 1) {
return;
}
if (a.distance > b.distance) {
return 1;
/**
* Find the closest intersected mesh
*/
intersects.sort(
function (a, b) {
if (a.distance < b.distance) {
return -1;
}
if (a.distance > b.distance) {
return 1;
}
return 0;
}
);
var mesh = intersects[0].mesh;
var face = intersects[0].face;
var faceIndex = intersects[0].faceIndex;
/**
* Prevent default action (like context menu or whatever)
*/
event.preventDefault();
/**
* Prevent other event listeners for 'mousedown' from executing their actions
*/
event.stopImmediatePropagation();
if (this.selectionMode === GameLib.System.Input.SELECTION_MODE_MESH) {
if (mesh.selected) {
this.deselectMesh(mesh);
} else {
this.selectMesh(mesh);
}
} else {
if (face.selected) {
this.deselectFace(mesh, face);
} else {
this.selectFace(mesh, face);
}
}
return 0;
}
/**
* Notify our GUI system to build a GUI
*/
GameLib.Event.Emit(
GameLib.Event.BUILD_GUI,
null
)
}.bind(this)
);
var meshes = intersects.map(function (intersect) {
return intersect.mesh;
});
var mesh = meshes[0];
if (mesh) {
/**
* Prevent default action (like context menu or whatever)
*/
event.preventDefault();
/**
* Prevent other event listeners for 'mousedown' from executing their actions
*/
event.stopImmediatePropagation();
if (mesh.selected) {
this.deSelectMesh(mesh);
} else {
this.selectMesh(mesh);
}
/**
* Notify our GUI system to build a GUI
*/
GameLib.Event.Emit(
GameLib.Event.BUILD_GUI,
null
)
}
}.bind(this)
);
}
@ -1028,7 +1077,12 @@ GameLib.System.Input.prototype.onMouseDownEdit = function(event) {
* @param event
*/
GameLib.System.Input.prototype.onMouseMoveEdit = function(event) {
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.MOUSE).map(
function(mouse) {
mouse.x = event.clientX;
mouse.y = event.clientY;
}
)
};
/**
@ -1071,6 +1125,32 @@ GameLib.System.Input.prototype.onMouseWheelEdit = function(event) {
);
};
GameLib.System.Input.prototype.selectFace = function(mesh, face) {
/**
* If mesh is already selected, do nothing
*/
if (face.selected === true) {
return;
}
/**
* Notify our component as being 'selected'
* @type {boolean}
*/
face.selected = true;
face.createHelper(mesh);
GameLib.Event.Emit(
GameLib.Event.MESH_FACE_SELECTED,
{
mesh : mesh,
face : face
}
);
};
GameLib.System.Input.prototype.selectMesh = function(mesh) {
/**
@ -1096,7 +1176,22 @@ GameLib.System.Input.prototype.selectMesh = function(mesh) {
);
};
GameLib.System.Input.prototype.deSelectMesh = function(mesh) {
GameLib.System.Input.prototype.deselectFace = function(mesh, face) {
face.selected = false;
face.removeHelper(mesh);
GameLib.Event.Emit(
GameLib.Event.MESH_FACE_DESELECTED,
{
mesh : mesh,
face : face
}
);
};
GameLib.System.Input.prototype.deselectMesh = function(mesh) {
mesh.selected = false;

View File

@ -380,7 +380,7 @@ GameLib.System.Render.prototype.stop = function() {
function(renderer) {
if (renderer.statistics) {
renderer.statistics.resize();
renderer.domElement.instance.parentElement.removeChild(renderer.statistics.instance.dom);
renderer.canvas.instance.parentElement.removeChild(renderer.statistics.instance.dom);
}
}
);