/** * R3.D3.Geometry.Buffer.TorusKnot * @param graphics R3.Runtime.Graphics * @param apiGeometryBufferTorusKnot * @constructor */ R3.D3.Geometry.Buffer.TorusKnot = function( graphics, apiGeometryBufferTorusKnot ) { this.graphics = graphics; this.graphics.isNotThreeThrow(); if (R3.Utils.UndefinedOrNull(apiGeometryBufferTorusKnot)) { apiGeometryBufferTorusKnot = { geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT }; } R3.D3.API.Geometry.Buffer.TorusKnot.call( this, apiGeometryBufferTorusKnot, apiGeometryBufferTorusKnot.radius, apiGeometryBufferTorusKnot.tube, apiGeometryBufferTorusKnot.radialSegments, apiGeometryBufferTorusKnot.tubularSegments, apiGeometryBufferTorusKnot.p, apiGeometryBufferTorusKnot.q ); R3.D3.Geometry.Buffer.call( this, this.graphics, apiGeometryBufferTorusKnot ); }; R3.D3.Geometry.Buffer.TorusKnot.prototype = Object.create(R3.D3.Geometry.Buffer.prototype); R3.D3.Geometry.Buffer.TorusKnot.prototype.constructor = R3.D3.Geometry.Buffer.TorusKnot; /** * Creates a light instance * @returns {*} */ R3.D3.Geometry.Buffer.TorusKnot.prototype.createInstance = function() { this.instance = new THREE.TorusKnotBufferGeometry( this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q ); this.computeVertexNormals(); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; /** * Updates the instance with the current state */ R3.D3.Geometry.Buffer.TorusKnot.prototype.updateInstance = function(property) { if ( property === 'radius' || property === 'tube' || property === 'radialSegments' || property === 'tubularSegments' || property === 'p' || property === 'q' ) { this.instance.dispose(); this.createInstance(); if (this.parentMesh && this.parentMesh.instance) { this.parentMesh.instance.geometry = this.instance; if (this.parentMesh.helper) { this.parentMesh.removeHelper(); this.parentMesh.createHelper(); } } return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; /** * Converts a R3.D3.Geometry.Buffer.TorusKnot to a R3.D3.API.Geometry.Buffer.TorusKnot * @returns {R3.D3.API.Geometry.Buffer} */ R3.D3.Geometry.Buffer.TorusKnot.prototype.toApiObject = function() { var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); var apiGeometryBufferTorusKnot = new R3.D3.API.Geometry.Buffer.TorusKnot( apiBufferGeometry, this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q ); return apiGeometryBufferTorusKnot; };