118 lines
2.9 KiB
JavaScript
118 lines
2.9 KiB
JavaScript
/**
|
|
* R3.D3.Geometry.Buffer.Cone
|
|
* @param graphics R3.GraphicsRuntime
|
|
* @param apiGeometryBufferCone
|
|
* @constructor
|
|
*/
|
|
R3.D3.Geometry.Buffer.Cone = function(
|
|
graphics,
|
|
apiGeometryBufferCone
|
|
) {
|
|
|
|
this.graphics = graphics;
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiGeometryBufferCone)) {
|
|
apiGeometryBufferCone = {
|
|
geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE
|
|
};
|
|
}
|
|
|
|
R3.D3.API.Geometry.Buffer.Cone.call(
|
|
this,
|
|
apiGeometryBufferCone,
|
|
apiGeometryBufferCone.radius,
|
|
apiGeometryBufferCone.height,
|
|
apiGeometryBufferCone.radialSegments,
|
|
apiGeometryBufferCone.heightSegments,
|
|
apiGeometryBufferCone.openEnded,
|
|
apiGeometryBufferCone.thetaStart,
|
|
apiGeometryBufferCone.thetaLength
|
|
);
|
|
|
|
R3.D3.Geometry.Buffer.call(
|
|
this,
|
|
this.graphics,
|
|
apiGeometryBufferCone
|
|
);
|
|
|
|
};
|
|
|
|
R3.D3.Geometry.Buffer.Cone.prototype = Object.create(R3.D3.Geometry.Buffer.prototype);
|
|
R3.D3.Geometry.Buffer.Cone.prototype.constructor = R3.D3.Geometry.Buffer.Cone;
|
|
|
|
/**
|
|
* Creates a light instance
|
|
* @returns {*}
|
|
*/
|
|
R3.D3.Geometry.Buffer.Cone.prototype.createInstance = function() {
|
|
|
|
this.instance = new THREE.ConeBufferGeometry(
|
|
this.radius,
|
|
this.height,
|
|
this.radialSegments,
|
|
this.heightSegments,
|
|
this.openEnded,
|
|
this.thetaStart,
|
|
this.thetaLength
|
|
);
|
|
|
|
this.computeVertexNormals();
|
|
|
|
R3.D3.Geometry.Buffer.prototype.createInstance.call(this);
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.D3.Geometry.Buffer.Cone.prototype.updateInstance = function(property) {
|
|
|
|
if (
|
|
property === 'radius' ||
|
|
property === 'height' ||
|
|
property === 'radialSegments' ||
|
|
property === 'heightSegments' ||
|
|
property === 'openEnded' ||
|
|
property === 'thetaStart' ||
|
|
property === 'thetaLength'
|
|
) {
|
|
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.Cone to a R3.D3.API.Geometry.Buffer.Cone
|
|
* @returns {R3.D3.API.Geometry.Buffer}
|
|
*/
|
|
R3.D3.Geometry.Buffer.Cone.prototype.toApiObject = function() {
|
|
|
|
var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this);
|
|
|
|
var apiGeometryBufferCone = new R3.D3.API.Geometry.Buffer.Cone(
|
|
apiBufferGeometry,
|
|
this.radius,
|
|
this.height,
|
|
this.radialSegments,
|
|
this.heightSegments,
|
|
this.openEnded,
|
|
this.thetaStart,
|
|
this.thetaLength
|
|
);
|
|
|
|
return apiGeometryBufferCone;
|
|
};
|