r3-legacy/src/game-lib-d3-api-geometry-to...

92 lines
2.1 KiB
JavaScript

/**
* GameLib.D3.API.Geometry.TorusKnot
* @param apiGeometry
* @param radius
* @param tube
* @param radialSegments
* @param tubularSegments
* @param p
* @param q
* @constructor
*/
GameLib.D3.API.Geometry.TorusKnot = function(
apiGeometry,
radius,
tube,
radialSegments,
tubularSegments,
p,
q
) {
if (GameLib.Utils.UndefinedOrNull(apiGeometry)) {
apiGeometry = {
geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT
};
}
if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) {
apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}
this.radius = radius;
if (GameLib.Utils.UndefinedOrNull(tube)) {
tube = 0.4;
}
this.tube = tube;
if (GameLib.Utils.UndefinedOrNull(radialSegments)) {
radialSegments = 8;
}
this.radialSegments = radialSegments;
if (GameLib.Utils.UndefinedOrNull(tubularSegments)) {
tubularSegments = 64;
}
this.tubularSegments = tubularSegments;
if (GameLib.Utils.UndefinedOrNull(p)) {
p = 2;
}
this.p = p;
if (GameLib.Utils.UndefinedOrNull(q)) {
q = 3;
}
this.q = q;
GameLib.D3.API.Geometry.call(
this,
apiGeometry.id,
apiGeometry.name,
apiGeometry.geometryType,
apiGeometry.parentEntity,
apiGeometry.boundingBox,
apiGeometry.boundingSphere,
apiGeometry.colors,
apiGeometry.faces,
apiGeometry.lineDistances,
apiGeometry.morphTargets,
apiGeometry.morphNormals,
apiGeometry.skinWeights,
apiGeometry.skinIndices,
apiGeometry.vertices,
apiGeometry.verticesNeedsUpdate,
apiGeometry.elementsNeedUpdate,
apiGeometry.uvsNeedUpdate,
apiGeometry.normalsNeedUpdate,
apiGeometry.colorsNeedUpdate,
apiGeometry.groupsNeedUpdate,
apiGeometry.lineDistancesNeedUpdate
);
};
GameLib.D3.API.Geometry.TorusKnot.prototype = Object.create(GameLib.D3.API.Geometry.prototype);
GameLib.D3.API.Geometry.TorusKnot.prototype.constructor = GameLib.D3.API.Geometry.TorusKnot;