114 lines
2.8 KiB
JavaScript
114 lines
2.8 KiB
JavaScript
/**
|
|
* R3.D3.Geometry.Normal.Lathe
|
|
* @param graphics R3.Runtime.Graphics
|
|
* @param apiGeometryNormalLathe
|
|
* @constructor
|
|
*/
|
|
R3.D3.Geometry.Normal.Lathe = function(
|
|
graphics,
|
|
apiGeometryNormalLathe
|
|
) {
|
|
|
|
this.graphics = graphics;
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiGeometryNormalLathe)) {
|
|
apiGeometryNormalLathe = {
|
|
geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE
|
|
};
|
|
}
|
|
|
|
R3.D3.API.Geometry.Normal.Lathe.call(
|
|
this,
|
|
apiGeometryNormalLathe,
|
|
apiGeometryNormalLathe.points,
|
|
apiGeometryNormalLathe.segments,
|
|
apiGeometryNormalLathe.phiStart,
|
|
apiGeometryNormalLathe.phiLength
|
|
);
|
|
|
|
R3.D3.Geometry.Normal.call(
|
|
this,
|
|
this.graphics,
|
|
apiGeometryNormalLathe
|
|
);
|
|
|
|
};
|
|
|
|
R3.D3.Geometry.Normal.Lathe.prototype = Object.create(R3.D3.Geometry.Normal.prototype);
|
|
R3.D3.Geometry.Normal.Lathe.prototype.constructor = R3.D3.Geometry.Normal.Lathe;
|
|
|
|
/**
|
|
* Creates a light instance
|
|
* @returns {*}
|
|
*/
|
|
R3.D3.Geometry.Normal.Lathe.prototype.createInstance = function() {
|
|
|
|
this.instance = new THREE.LatheGeometry(
|
|
this.points.map(
|
|
function(point) {
|
|
return point.instance;
|
|
}
|
|
),
|
|
this.segments,
|
|
this.phiStart,
|
|
this.phiLength
|
|
);
|
|
|
|
this.computeVertexNormals();
|
|
|
|
R3.D3.Geometry.Normal.prototype.createInstance.call(this);
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.D3.Geometry.Normal.Lathe.prototype.updateInstance = function(property) {
|
|
|
|
if (
|
|
property === 'points' ||
|
|
property === 'segments' ||
|
|
property === 'phiStart' ||
|
|
property === 'phiLength'
|
|
) {
|
|
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.Normal.prototype.updateInstance.call(this, property);
|
|
};
|
|
|
|
/**
|
|
* Converts a R3.D3.Geometry.Normal.Lathe to a R3.D3.API.Geometry.Normal.Lathe
|
|
* @returns {R3.D3.API.Geometry.Normal}
|
|
*/
|
|
R3.D3.Geometry.Normal.Lathe.prototype.toApiObject = function() {
|
|
|
|
var apiNormalGeometry = R3.D3.Geometry.Normal.prototype.toApiObject.call(this);
|
|
|
|
var apiGeometryNormalLathe = new R3.D3.API.Geometry.Normal.Lathe(
|
|
apiNormalGeometry,
|
|
this.points.map(
|
|
function(point) {
|
|
return point.toApiObject();
|
|
}
|
|
),
|
|
this.segments,
|
|
this.phiStart,
|
|
this.phiLength
|
|
);
|
|
|
|
return apiGeometryNormalLathe;
|
|
};
|