/** * GameLib.D3.Mesh.Text * @param graphics GameLib.GraphicsRuntime * @param apiMeshText * @constructor */ GameLib.D3.Mesh.Text = function ( graphics, apiMeshText ) { this.graphics = graphics; this.graphics.isNotThreeThrow(); if (GameLib.Utils.UndefinedOrNull(apiMeshText)) { apiMeshText = { meshType : GameLib.D3.API.Mesh.MESH_TYPE_TEXT }; } GameLib.D3.API.Mesh.Text.call( this, apiMeshText, apiMeshText.text, apiMeshText.font, apiMeshText.size, apiMeshText.height, apiMeshText.curveSegments, apiMeshText.bevelEnabled, apiMeshText.bevelThickness, apiMeshText.bevelSize, apiMeshText.bevelSegments ); if (this.font instanceof GameLib.D3.API.Font) { this.font = new GameLib.D3.Font( this.graphics, this.font ) } GameLib.D3.Mesh.call( this, this.graphics, this ); }; GameLib.D3.Mesh.Text.prototype = Object.create(GameLib.D3.Mesh.prototype); GameLib.D3.Mesh.Text.prototype.constructor = GameLib.D3.Mesh.Text; GameLib.D3.Mesh.Text.prototype.createInstance = function() { var geometry = null; if (this.vertices.length === 0) { geometry = new THREE.TextGeometry( this.text, { font: this.font.instance, size: this.size, height: this.height, curveSegments: this.curveSegments, bevelEnabled: this.bevelEnabled, bevelThickness: this.bevelThickness, bevelSize: this.bevelSize, bevelSegments: this.bevelSegments } ); this.updateVerticesFromGeometryInstance(geometry); } GameLib.D3.Mesh.prototype.createInstance.call(this); }; GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) { if ( property === 'text' || property === 'font' || property === 'size' || property === 'height' || property === 'curveSegments' || property === 'bevelEnabled' || property === 'bevelThickness' || property === 'bevelSize' || property === 'bevelSegments' ) { var geometry = new THREE.TextGeometry( this.text, { font: this.font.instance, size: this.size, height: this.height, curveSegments: this.curveSegments, bevelEnabled: this.bevelEnabled, bevelThickness: this.bevelThickness, bevelSize: this.bevelSize, bevelSegments: this.bevelSegments } ); this.updateVerticesFromGeometryInstance(geometry); geometry = this.createInstanceGeometry(); this.instance.geometry = geometry; return; } GameLib.D3.Mesh.prototype.updateInstance.call(this, property); }; /** * Converts a GameLib.D3.Mesh.Text to a GameLib.D3.API.Mesh.Text * @returns {GameLib.D3.API.Mesh.Text} */ GameLib.D3.Mesh.Text.prototype.toApiObject = function() { var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this); var apiMeshText = new GameLib.D3.API.Mesh.Text( apiMesh, this.text, this.font, this.size, this.height, this.curveSegments, this.bevelEnabled, this.bevelThickness, this.bevelSize, this.bevelSegments ); return apiMeshText; };