101 lines
2.4 KiB
JavaScript
101 lines
2.4 KiB
JavaScript
/**
|
|
* R3.D3.Geometry.Normal.Plane
|
|
* @param graphics R3.Runtime.Graphics
|
|
* @param apiGeometryNormalPlane
|
|
* @constructor
|
|
*/
|
|
R3.D3.Geometry.Normal.Plane = function(
|
|
graphics,
|
|
apiGeometryNormalPlane
|
|
) {
|
|
|
|
this.graphics = graphics;
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiGeometryNormalPlane)) {
|
|
apiGeometryNormalPlane = {
|
|
geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE
|
|
};
|
|
}
|
|
|
|
R3.D3.API.Geometry.Normal.Plane.call(
|
|
this,
|
|
apiGeometryNormalPlane,
|
|
apiGeometryNormalPlane.width,
|
|
apiGeometryNormalPlane.height,
|
|
apiGeometryNormalPlane.widthSegments,
|
|
apiGeometryNormalPlane.heightSegments
|
|
);
|
|
|
|
R3.D3.Geometry.Normal.call(
|
|
this,
|
|
this.graphics,
|
|
apiGeometryNormalPlane
|
|
);
|
|
|
|
};
|
|
|
|
R3.D3.Geometry.Normal.Plane.prototype = Object.create(R3.D3.Geometry.Normal.prototype);
|
|
R3.D3.Geometry.Normal.Plane.prototype.constructor = R3.D3.Geometry.Normal.Plane;
|
|
|
|
/**
|
|
* Creates a light instance
|
|
* @returns {*}
|
|
*/
|
|
R3.D3.Geometry.Normal.Plane.prototype.createInstance = function() {
|
|
|
|
this.instance = new THREE.PlaneGeometry(
|
|
this.width,
|
|
this.height,
|
|
this.widthSegments,
|
|
this.heightSegments
|
|
);
|
|
|
|
this.computeVertexNormals();
|
|
|
|
R3.D3.Geometry.Normal.prototype.createInstance.call(this);
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.D3.Geometry.Normal.Plane.prototype.updateInstance = function(property) {
|
|
|
|
if (
|
|
property === 'width' ||
|
|
property === 'height' ||
|
|
property === 'widthSegments' ||
|
|
property === 'heightSegments'
|
|
) {
|
|
this.instance.dispose();
|
|
this.createInstance();
|
|
|
|
if (this.parentMesh && this.parentMesh.instance) {
|
|
this.parentMesh.instance.geometry = this.instance;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
R3.D3.Geometry.Normal.prototype.updateInstance.call(this, property);
|
|
};
|
|
|
|
/**
|
|
* Converts a R3.D3.Geometry.Normal.Plane to a R3.D3.API.Geometry.Normal.Plane
|
|
* @returns {R3.D3.API.Geometry.Normal}
|
|
*/
|
|
R3.D3.Geometry.Normal.Plane.prototype.toApiObject = function() {
|
|
|
|
var apiNormalGeometry = R3.D3.Geometry.Normal.prototype.toApiObject.call(this);
|
|
|
|
var apiGeometryNormalPlane = new R3.D3.API.Geometry.Normal.Plane(
|
|
apiNormalGeometry,
|
|
this.width,
|
|
this.height,
|
|
this.widthSegments,
|
|
this.heightSegments
|
|
);
|
|
|
|
return apiGeometryNormalPlane;
|
|
};
|