/** * Raw Mesh API object - should always correspond with the Mesh Schema * @param id * @param meshType * @param name * @param vertices GameLib.D3.Vertex[] * @param faces GameLib.D3.TriangleFace[] * @param faceVertexUvs * @param materials GameLib.D3.API.Material[] * @param parentMeshId * @param parentSceneId * @param skeleton * @param skinIndices * @param skinWeights * @param position GameLib.API.Vector3 * @param quaternion GameLib.API.Quaternion * @param scale GameLib.API.Vector3 * @param localPosition GameLib.API.Vector3 * @param localRotation GameLib.API.Vector3 * @param localScale GameLib.API.Vector3 * @param up * @constructor */ GameLib.D3.API.Mesh = function( id, meshType, name, vertices, faces, faceVertexUvs, materials, parentMeshId, parentSceneId, skeleton, skinIndices, skinWeights, position, quaternion, scale, localPosition, localRotation, localScale, up ) { if (GameLib.Utils.UndefinedOrNull(id)) { id = GameLib.Utils.RandomId(); } this.id = id; if (GameLib.Utils.UndefinedOrNull(meshType)) { meshType = GameLib.D3.Mesh.TYPE_NORMAL; } this.meshType = meshType; if (GameLib.Utils.UndefinedOrNull(name)) { name = 'Mesh (' + meshType + ')'; } this.name = name; if (GameLib.Utils.UndefinedOrNull(vertices)) { throw new Error('Cannot create a mesh with no vertices'); } this.vertices = vertices; if (GameLib.Utils.UndefinedOrNull(faces)) { throw new Error('Cannot create a mesh with no faces'); } this.faces = faces; if (GameLib.Utils.UndefinedOrNull(parentMeshId)) { parentMeshId = null; } this.parentMeshId = parentMeshId; if (GameLib.Utils.UndefinedOrNull(parentSceneId)) { parentSceneId = null; } this.parentSceneId = parentSceneId; if (GameLib.Utils.UndefinedOrNull(skeleton)) { skeleton = null; } this.skeleton = skeleton; if (GameLib.Utils.UndefinedOrNull(faceVertexUvs)) { faceVertexUvs = []; } this.faceVertexUvs = faceVertexUvs; if (GameLib.Utils.UndefinedOrNull(skinIndices)) { skinIndices = []; } this.skinIndices = skinIndices; if (GameLib.Utils.UndefinedOrNull(skinWeights)) { skinWeights = []; } this.skinWeights = skinWeights; if (GameLib.Utils.UndefinedOrNull(materials)) { materials = []; } this.materials = materials; if (GameLib.Utils.UndefinedOrNull(position)) { position = new GameLib.API.Vector3(0,0,0); } this.position = position; if (GameLib.Utils.UndefinedOrNull(quaternion)) { quaternion = new GameLib.API.Quaternion(); } this.quaternion = quaternion; if (GameLib.Utils.UndefinedOrNull(scale)) { scale = new GameLib.API.Vector3(1,1,1); } this.scale = scale; if (GameLib.Utils.UndefinedOrNull(localPosition)) { localPosition = new GameLib.API.Vector3(0,0,0); } this.localPosition = localPosition; if (GameLib.Utils.UndefinedOrNull(localRotation)) { localRotation = new GameLib.API.Vector3(0,0,0); } this.localRotation = localRotation; if (GameLib.Utils.UndefinedOrNull(localScale)) { localScale = new GameLib.API.Vector3(1,1,1); } this.localScale = localScale; if (GameLib.Utils.UndefinedOrNull(up)) { up = new GameLib.API.Vector3(0,1,0); } this.up = up; };