|
@@ -1302,170 +1302,53 @@
|
|
|
}
|
|
|
|
|
|
// Torus (Code from SharpDX.org)
|
|
|
- public static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
|
|
|
- public static CreateTorus(name: string, options: { diameter?: number, thickness?: number, tessellation?: number, updatable?: boolean, sideOrientation?: number }, scene: any): Mesh;
|
|
|
- public static CreateTorus(name: string, options: any, thicknessOrScene: any, tessellation?: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh {
|
|
|
- if (thicknessOrScene instanceof Scene) {
|
|
|
- scene = thicknessOrScene;
|
|
|
- updatable = options.updatable;
|
|
|
- } else {
|
|
|
- var diameter = options;
|
|
|
- options = {
|
|
|
- diameter: diameter,
|
|
|
- thickness: thicknessOrScene,
|
|
|
- tessellation: tessellation,
|
|
|
- sideOrientation: sideOrientation
|
|
|
- }
|
|
|
+ public static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh {
|
|
|
+ var options = {
|
|
|
+ diameter: diameter,
|
|
|
+ thickness: thickness,
|
|
|
+ tessellation: tessellation,
|
|
|
+ sideOrientation: sideOrientation,
|
|
|
+ updatable: updatable
|
|
|
}
|
|
|
- var torus = new Mesh(name, scene);
|
|
|
- var vertexData = VertexData.CreateTorus(options);
|
|
|
|
|
|
- vertexData.applyToMesh(torus, updatable);
|
|
|
-
|
|
|
- return torus;
|
|
|
+ return MeshBuilder.CreateTorus(name, options, scene);
|
|
|
}
|
|
|
|
|
|
- public static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
|
|
|
- public static CreateTorusKnot(name: string, options: { radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, p?: number, q?: number, updatable?: boolean, sideOrientation?: number }, scene: any): Mesh;
|
|
|
- public static CreateTorusKnot(name: string, options: any, tubeOrScene: any, radialSegments?: number, tubularSegments?: number, p?: number, q?: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh {
|
|
|
- if (tubeOrScene instanceof Scene) {
|
|
|
- scene = tubeOrScene;
|
|
|
- updatable = options.updatable;
|
|
|
- } else {
|
|
|
- var radius = options;
|
|
|
- options = {
|
|
|
- radius: radius,
|
|
|
- tube: tubeOrScene,
|
|
|
- radialSegments: radialSegments,
|
|
|
- tubularSegments: tubularSegments,
|
|
|
- p: p,
|
|
|
- q: q,
|
|
|
- sideOrientation: sideOrientation
|
|
|
- }
|
|
|
+ public static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh {
|
|
|
+ var options = {
|
|
|
+ radius: radius,
|
|
|
+ tube: tube,
|
|
|
+ radialSegments: radialSegments,
|
|
|
+ tubularSegments: tubularSegments,
|
|
|
+ p: p,
|
|
|
+ q: q,
|
|
|
+ sideOrientation: sideOrientation,
|
|
|
+ updatable: updatable
|
|
|
}
|
|
|
- var torusKnot = new Mesh(name, scene);
|
|
|
- var vertexData = VertexData.CreateTorusKnot(options);
|
|
|
-
|
|
|
- vertexData.applyToMesh(torusKnot, updatable);
|
|
|
|
|
|
- return torusKnot;
|
|
|
+ return MeshBuilder.CreateTorusKnot(name, options, scene);
|
|
|
}
|
|
|
|
|
|
// Lines
|
|
|
- public static CreateLines(name: string, points: Vector3[], scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh;
|
|
|
- public static CreateLines(name: string, options: { points: Vector3[], updatable?: boolean, instance?: LinesMesh }, scene: Scene): LinesMesh;
|
|
|
- public static CreateLines(name: string, options: any, scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh {
|
|
|
- var points: Vector3[];
|
|
|
- if (Array.isArray(options)) {
|
|
|
- points = options;
|
|
|
- if (!instance) {
|
|
|
- options = {
|
|
|
- points: points
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- instance = options.instance;
|
|
|
- points = options.points;
|
|
|
- }
|
|
|
-
|
|
|
- if (instance) { // lines update
|
|
|
- var positionFunction = positions => {
|
|
|
- var i = 0;
|
|
|
- for (var p = 0; p < points.length; p++) {
|
|
|
- positions[i] = points[p].x;
|
|
|
- positions[i + 1] = points[p].y;
|
|
|
- positions[i + 2] = points[p].z;
|
|
|
- i += 3;
|
|
|
- }
|
|
|
- };
|
|
|
- instance.updateMeshPositions(positionFunction, false);
|
|
|
- return instance;
|
|
|
+ public static CreateLines(name: string, points: Vector3[], scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh {
|
|
|
+ var options = {
|
|
|
+ points: points,
|
|
|
+ updatable: updatable,
|
|
|
+ instance: instance
|
|
|
}
|
|
|
-
|
|
|
- // lines creation
|
|
|
- var lines = new LinesMesh(name, scene);
|
|
|
- var vertexData = VertexData.CreateLines(options);
|
|
|
- vertexData.applyToMesh(lines, updatable || options.updatable);
|
|
|
- return lines;
|
|
|
+ return MeshBuilder.CreateLines(name, options, scene);
|
|
|
}
|
|
|
|
|
|
// Dashed Lines
|
|
|
- public static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh;
|
|
|
- public static CreateDashedLines(name: string, options: { points: Vector3[], dashSize?: number, gapSize?: number, dashNb?: number, updatable?: boolean, instance?: LinesMesh }, scene: Scene): LinesMesh;
|
|
|
- public static CreateDashedLines(name: string, options: any, dashSizeOrScene: any, gapSize?: number, dashNb?: number, scene?: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh {
|
|
|
- var points: Vector3[];
|
|
|
- var dashSize: number;
|
|
|
- if (Array.isArray(options)) {
|
|
|
- points = options;
|
|
|
- dashSize = dashSizeOrScene;
|
|
|
- if (!instance) {
|
|
|
- options = {
|
|
|
- points: points,
|
|
|
- dashSize: dashSize,
|
|
|
- gapSize: gapSize,
|
|
|
- dashNb: dashNb
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- scene = dashSizeOrScene,
|
|
|
- points = options.points;
|
|
|
- instance = options.instance;
|
|
|
- gapSize = options.gapSize;
|
|
|
- dashNb = options.dashNb;
|
|
|
- dashSize = options.dashSize;
|
|
|
- }
|
|
|
- if (instance) { // dashed lines update
|
|
|
- var positionFunction = (positions: number[]): void => {
|
|
|
- var curvect = Vector3.Zero();
|
|
|
- var nbSeg = positions.length / 6;
|
|
|
- var lg = 0;
|
|
|
- var nb = 0;
|
|
|
- var shft = 0;
|
|
|
- var dashshft = 0;
|
|
|
- var curshft = 0;
|
|
|
- var p = 0;
|
|
|
- var i = 0;
|
|
|
- var j = 0;
|
|
|
- for (i = 0; i < points.length - 1; i++) {
|
|
|
- points[i + 1].subtractToRef(points[i], curvect);
|
|
|
- lg += curvect.length();
|
|
|
- }
|
|
|
- shft = lg / nbSeg;
|
|
|
- dashshft = (<any>instance).dashSize * shft / ((<any>instance).dashSize + (<any>instance).gapSize);
|
|
|
- for (i = 0; i < points.length - 1; i++) {
|
|
|
- points[i + 1].subtractToRef(points[i], curvect);
|
|
|
- nb = Math.floor(curvect.length() / shft);
|
|
|
- curvect.normalize();
|
|
|
- j = 0;
|
|
|
- while (j < nb && p < positions.length) {
|
|
|
- curshft = shft * j;
|
|
|
- positions[p] = points[i].x + curshft * curvect.x;
|
|
|
- positions[p + 1] = points[i].y + curshft * curvect.y;
|
|
|
- positions[p + 2] = points[i].z + curshft * curvect.z;
|
|
|
- positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
|
|
|
- positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
|
|
|
- positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
|
|
|
- p += 6;
|
|
|
- j++;
|
|
|
- }
|
|
|
- }
|
|
|
- while (p < positions.length) {
|
|
|
- positions[p] = points[i].x;
|
|
|
- positions[p + 1] = points[i].y;
|
|
|
- positions[p + 2] = points[i].z;
|
|
|
- p += 3;
|
|
|
- }
|
|
|
- };
|
|
|
- instance.updateMeshPositions(positionFunction, false);
|
|
|
- return instance;
|
|
|
+ public static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh {
|
|
|
+ var options = {
|
|
|
+ points: points,
|
|
|
+ dashSize: dashSize,
|
|
|
+ gapSize: gapSize,
|
|
|
+ dashNb: dashNb,
|
|
|
+ updatable: updatable
|
|
|
}
|
|
|
- // dashed lines creation
|
|
|
- var dashedLines = new LinesMesh(name, scene);
|
|
|
- var vertexData = VertexData.CreateDashedLines(options);
|
|
|
- vertexData.applyToMesh(dashedLines, updatable || options.updatable);
|
|
|
- (<any>dashedLines).dashSize = dashSize;
|
|
|
- (<any>dashedLines).gapSize = gapSize;
|
|
|
- return dashedLines;
|
|
|
+ return MeshBuilder.CreateDashedLines(name, options, scene);
|
|
|
}
|
|
|
|
|
|
// Extrusion
|