105 lines
2.6 KiB
JavaScript
105 lines
2.6 KiB
JavaScript
/**
|
|
* R3.D3.Geometry.Normal.Wireframe
|
|
* @param graphics R3.GraphicsRuntime
|
|
* @param apiGeometryNormalWireframe
|
|
* @constructor
|
|
*/
|
|
R3.D3.Geometry.Normal.Wireframe = function(
|
|
graphics,
|
|
apiGeometryNormalWireframe
|
|
) {
|
|
|
|
this.graphics = graphics;
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiGeometryNormalWireframe)) {
|
|
apiGeometryNormalWireframe = {
|
|
geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME
|
|
};
|
|
}
|
|
|
|
R3.D3.API.Geometry.Normal.Wireframe.call(
|
|
this,
|
|
apiGeometryNormalWireframe,
|
|
apiGeometryNormalWireframe.geometry
|
|
);
|
|
|
|
R3.D3.Geometry.Normal.call(
|
|
this,
|
|
this.graphics,
|
|
apiGeometryNormalWireframe
|
|
);
|
|
|
|
};
|
|
|
|
R3.D3.Geometry.Normal.Wireframe.prototype = Object.create(R3.D3.Geometry.Normal.prototype);
|
|
R3.D3.Geometry.Normal.Wireframe.prototype.constructor = R3.D3.Geometry.Normal.Wireframe;
|
|
|
|
/**
|
|
* Creates a light instance
|
|
* @returns {*}
|
|
*/
|
|
R3.D3.Geometry.Normal.Wireframe.prototype.createInstance = function() {
|
|
|
|
if (!this.geometry || !this.geometry.instance) {
|
|
console.warn('geometry not ready');
|
|
return;
|
|
}
|
|
|
|
this.instance = new THREE.WireframeGeometry(
|
|
this.geometry.instance
|
|
);
|
|
|
|
console.log('wireframe instance created');
|
|
|
|
R3.D3.Geometry.Normal.prototype.createInstance.call(this);
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.D3.Geometry.Normal.Wireframe.prototype.updateInstance = function(property) {
|
|
|
|
if (
|
|
property === 'geometry'
|
|
) {
|
|
/**
|
|
* Could be that geometry was not ready
|
|
*/
|
|
if (this.instance) {
|
|
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.Wireframe to a R3.D3.API.Geometry.Normal.Wireframe
|
|
* @returns {R3.D3.API.Geometry.Normal}
|
|
*/
|
|
R3.D3.Geometry.Normal.Wireframe.prototype.toApiObject = function() {
|
|
|
|
var apiNormalGeometry = R3.D3.Geometry.Normal.prototype.toApiObject.call(this);
|
|
|
|
var apiGeometryNormalWireframe = new R3.D3.API.Geometry.Normal.Wireframe(
|
|
apiNormalGeometry,
|
|
R3.Utils.IdOrNull(this.geometry)
|
|
);
|
|
|
|
return apiGeometryNormalWireframe;
|
|
};
|