118 lines
3.0 KiB
JavaScript
118 lines
3.0 KiB
JavaScript
/**
|
|
* R3.D3.Geometry.Normal.Sphere
|
|
* @param graphics R3.GraphicsRuntime
|
|
* @param apiGeometryNormalSphere
|
|
* @constructor
|
|
*/
|
|
R3.D3.Geometry.Normal.Sphere = function(
|
|
graphics,
|
|
apiGeometryNormalSphere
|
|
) {
|
|
|
|
this.graphics = graphics;
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiGeometryNormalSphere)) {
|
|
apiGeometryNormalSphere = {
|
|
geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE
|
|
};
|
|
}
|
|
|
|
R3.D3.API.Geometry.Normal.Sphere.call(
|
|
this,
|
|
apiGeometryNormalSphere,
|
|
apiGeometryNormalSphere.radius,
|
|
apiGeometryNormalSphere.widthSegments,
|
|
apiGeometryNormalSphere.heightSegments,
|
|
apiGeometryNormalSphere.phiStart,
|
|
apiGeometryNormalSphere.phiLength,
|
|
apiGeometryNormalSphere.thetaStart,
|
|
apiGeometryNormalSphere.thetaLength
|
|
);
|
|
|
|
R3.D3.Geometry.Normal.call(
|
|
this,
|
|
this.graphics,
|
|
apiGeometryNormalSphere
|
|
);
|
|
|
|
};
|
|
|
|
R3.D3.Geometry.Normal.Sphere.prototype = Object.create(R3.D3.Geometry.Normal.prototype);
|
|
R3.D3.Geometry.Normal.Sphere.prototype.constructor = R3.D3.Geometry.Normal.Sphere;
|
|
|
|
/**
|
|
* Creates a light instance
|
|
* @returns {*}
|
|
*/
|
|
R3.D3.Geometry.Normal.Sphere.prototype.createInstance = function() {
|
|
|
|
this.instance = new THREE.SphereGeometry(
|
|
this.radius,
|
|
this.widthSegments,
|
|
this.heightSegments,
|
|
this.phiStart,
|
|
this.phiLength,
|
|
this.thetaStart,
|
|
this.thetaLength
|
|
);
|
|
|
|
this.computeVertexNormals();
|
|
|
|
R3.D3.Geometry.Normal.prototype.createInstance.call(this);
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.D3.Geometry.Normal.Sphere.prototype.updateInstance = function(property) {
|
|
|
|
if (
|
|
property === 'radius' ||
|
|
property === 'widthSegments' ||
|
|
property === 'heightSegments' ||
|
|
property === 'phiStart' ||
|
|
property === 'phiLength' ||
|
|
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.Normal.prototype.updateInstance.call(this, property);
|
|
};
|
|
|
|
/**
|
|
* Converts a R3.D3.Geometry.Normal.Sphere to a R3.D3.API.Geometry.Normal.Sphere
|
|
* @returns {R3.D3.API.Geometry.Normal}
|
|
*/
|
|
R3.D3.Geometry.Normal.Sphere.prototype.toApiObject = function() {
|
|
|
|
var apiNormalGeometry = R3.D3.Geometry.Normal.prototype.toApiObject.call(this);
|
|
|
|
var apiGeometryNormalSphere = new R3.D3.API.Geometry.Normal.Sphere(
|
|
apiNormalGeometry,
|
|
this.radius,
|
|
this.widthSegments,
|
|
this.heightSegments,
|
|
this.phiStart,
|
|
this.phiLength,
|
|
this.thetaStart,
|
|
this.thetaLength
|
|
);
|
|
|
|
return apiGeometryNormalSphere;
|
|
};
|