|
@@ -1474,772 +1474,4 @@ export class Geometry implements IGetSetVerticesData {
|
|
|
|
|
|
return geometry;
|
|
return geometry;
|
|
}
|
|
}
|
|
-}
|
|
|
|
-
|
|
|
|
-// Primitives
|
|
|
|
-
|
|
|
|
-/// Abstract class
|
|
|
|
-/**
|
|
|
|
- * Abstract class used to provide common services for all typed geometries
|
|
|
|
- * @hidden
|
|
|
|
- */
|
|
|
|
-export class _PrimitiveGeometry extends Geometry {
|
|
|
|
-
|
|
|
|
- private _beingRegenerated: boolean;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new typed geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- */
|
|
|
|
- constructor(id: string, scene: Scene, private _canBeRegenerated: boolean = false, mesh: Nullable<Mesh> = null) {
|
|
|
|
- super(id, scene, undefined, false, mesh); // updatable = false to be sure not to update vertices
|
|
|
|
- this._beingRegenerated = true;
|
|
|
|
- this.regenerate();
|
|
|
|
- this._beingRegenerated = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @returns true if the geometry can be regenerated
|
|
|
|
- */
|
|
|
|
- public canBeRegenerated(): boolean {
|
|
|
|
- return this._canBeRegenerated;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
|
|
|
|
- */
|
|
|
|
- public regenerate(): void {
|
|
|
|
- if (!this._canBeRegenerated) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._beingRegenerated = true;
|
|
|
|
- this.setAllVerticesData(this._regenerateVertexData(), false);
|
|
|
|
- this._beingRegenerated = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Clone the geometry
|
|
|
|
- * @param id defines the unique ID of the new geometry
|
|
|
|
- * @returns the new geometry
|
|
|
|
- */
|
|
|
|
- public asNewGeometry(id: string): Geometry {
|
|
|
|
- return super.copy(id);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // overrides
|
|
|
|
- public setAllVerticesData(vertexData: VertexData, updatable?: boolean): void {
|
|
|
|
- if (!this._beingRegenerated) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- super.setAllVerticesData(vertexData, false);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void {
|
|
|
|
- if (!this._beingRegenerated) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- super.setVerticesData(kind, data, false);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // to override
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- throw new Error("Abstract method");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- throw new Error("Must be overriden in sub-classes.");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public serialize(): any {
|
|
|
|
- var serializationObject = super.serialize();
|
|
|
|
-
|
|
|
|
- serializationObject.canBeRegenerated = this.canBeRegenerated();
|
|
|
|
-
|
|
|
|
- return serializationObject;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a ribbon geometry
|
|
|
|
- * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
|
|
|
|
- */
|
|
|
|
-export class RibbonGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a ribbon geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param pathArray defines the array of paths to use
|
|
|
|
- * @param closeArray defines if the last path and the first path must be joined
|
|
|
|
- * @param closePath defines if the last and first points of each path in your pathArray must be joined
|
|
|
|
- * @param offset defines the offset between points
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the array of paths to use
|
|
|
|
- */
|
|
|
|
- public pathArray: Vector3[][],
|
|
|
|
- /**
|
|
|
|
- * Defines if the last and first points of each path in your pathArray must be joined
|
|
|
|
- */
|
|
|
|
- public closeArray: boolean,
|
|
|
|
- /**
|
|
|
|
- * Defines if the last and first points of each path in your pathArray must be joined
|
|
|
|
- */
|
|
|
|
- public closePath: boolean,
|
|
|
|
- /**
|
|
|
|
- * Defines the offset between points
|
|
|
|
- */
|
|
|
|
- public offset: number,
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh?: Mesh,
|
|
|
|
- /**
|
|
|
|
- * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- public side: number = VertexData.DEFAULTSIDE) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateRibbon({ pathArray: this.pathArray, closeArray: this.closeArray, closePath: this.closePath, offset: this.offset, sideOrientation: this.side });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new RibbonGeometry(id, this.getScene(), this.pathArray, this.closeArray, this.closePath, this.offset, this.canBeRegenerated(), undefined, this.side);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a box geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#box
|
|
|
|
- */
|
|
|
|
-export class BoxGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a box geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param size defines the zise of the box (width, height and depth are the same)
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the zise of the box (width, height and depth are the same)
|
|
|
|
- */
|
|
|
|
- public size: number,
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh: Nullable<Mesh> = null,
|
|
|
|
- /**
|
|
|
|
- * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- public side: number = VertexData.DEFAULTSIDE) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateBox({ size: this.size, sideOrientation: this.side });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new BoxGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), undefined, this.side);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public serialize(): any {
|
|
|
|
- var serializationObject = super.serialize();
|
|
|
|
-
|
|
|
|
- serializationObject.size = this.size;
|
|
|
|
-
|
|
|
|
- return serializationObject;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry> {
|
|
|
|
- if (scene.getGeometryByID(parsedBox.id)) {
|
|
|
|
- return null; // null since geometry could be something else than a box...
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var box = new BoxGeometry(parsedBox.id, scene, parsedBox.size, parsedBox.canBeRegenerated, null);
|
|
|
|
- if (Tags) {
|
|
|
|
- Tags.AddTagsTo(box, parsedBox.tags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- scene.pushGeometry(box, true);
|
|
|
|
-
|
|
|
|
- return box;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a sphere geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
|
|
|
|
- */
|
|
|
|
-export class SphereGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Create a new sphere geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param segments defines the number of segments to use to create the sphere
|
|
|
|
- * @param diameter defines the diameter of the sphere
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the number of segments to use to create the sphere
|
|
|
|
- */
|
|
|
|
- public segments: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the diameter of the sphere
|
|
|
|
- */
|
|
|
|
- public diameter: number,
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh: Nullable<Mesh> = null,
|
|
|
|
- /**
|
|
|
|
- * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- public side: number = VertexData.DEFAULTSIDE) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateSphere({ segments: this.segments, diameter: this.diameter, sideOrientation: this.side });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new SphereGeometry(id, this.getScene(), this.segments, this.diameter, this.canBeRegenerated(), null, this.side);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public serialize(): any {
|
|
|
|
- var serializationObject = super.serialize();
|
|
|
|
-
|
|
|
|
- serializationObject.segments = this.segments;
|
|
|
|
- serializationObject.diameter = this.diameter;
|
|
|
|
-
|
|
|
|
- return serializationObject;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry> {
|
|
|
|
- if (scene.getGeometryByID(parsedSphere.id)) {
|
|
|
|
- return null; // null since geometry could be something else than a sphere...
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var sphere = new SphereGeometry(parsedSphere.id, scene, parsedSphere.segments, parsedSphere.diameter, parsedSphere.canBeRegenerated, null);
|
|
|
|
- if (Tags) {
|
|
|
|
- Tags.AddTagsTo(sphere, parsedSphere.tags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- scene.pushGeometry(sphere, true);
|
|
|
|
-
|
|
|
|
- return sphere;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a disc geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
|
|
|
|
- */
|
|
|
|
-export class DiscGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new disc geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param radius defines the radius of the disc
|
|
|
|
- * @param tessellation defines the tesselation factor to apply to the disc
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the radius of the disc
|
|
|
|
- */
|
|
|
|
- public radius: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the tesselation factor to apply to the disc
|
|
|
|
- */
|
|
|
|
- public tessellation: number,
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh: Nullable<Mesh> = null,
|
|
|
|
- /**
|
|
|
|
- * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- public side: number = VertexData.DEFAULTSIDE) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateDisc({ radius: this.radius, tessellation: this.tessellation, sideOrientation: this.side });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new DiscGeometry(id, this.getScene(), this.radius, this.tessellation, this.canBeRegenerated(), null, this.side);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a new cylinder geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
|
|
|
|
- */
|
|
|
|
-export class CylinderGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new cylinder geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param height defines the height of the cylinder
|
|
|
|
- * @param diameterTop defines the diameter of the cylinder's top cap
|
|
|
|
- * @param diameterBottom defines the diameter of the cylinder's bottom cap
|
|
|
|
- * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
|
|
|
|
- * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the height of the cylinder
|
|
|
|
- */
|
|
|
|
- public height: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the diameter of the cylinder's top cap
|
|
|
|
- */
|
|
|
|
- public diameterTop: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the diameter of the cylinder's bottom cap
|
|
|
|
- */
|
|
|
|
- public diameterBottom: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the tessellation factor to apply to the cylinder
|
|
|
|
- */
|
|
|
|
- public tessellation: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the number of subdivisions to apply to the cylinder (1 by default)
|
|
|
|
- */
|
|
|
|
- public subdivisions: number = 1,
|
|
|
|
- canBeRegenerated?: boolean, mesh:
|
|
|
|
- Nullable<Mesh> = null,
|
|
|
|
- /**
|
|
|
|
- * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- public side: number = VertexData.DEFAULTSIDE) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateCylinder({ height: this.height, diameterTop: this.diameterTop, diameterBottom: this.diameterBottom, tessellation: this.tessellation, subdivisions: this.subdivisions, sideOrientation: this.side });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new CylinderGeometry(id, this.getScene(), this.height, this.diameterTop, this.diameterBottom, this.tessellation, this.subdivisions, this.canBeRegenerated(), null, this.side);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public serialize(): any {
|
|
|
|
- var serializationObject = super.serialize();
|
|
|
|
-
|
|
|
|
- serializationObject.height = this.height;
|
|
|
|
- serializationObject.diameterTop = this.diameterTop;
|
|
|
|
- serializationObject.diameterBottom = this.diameterBottom;
|
|
|
|
- serializationObject.tessellation = this.tessellation;
|
|
|
|
-
|
|
|
|
- return serializationObject;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry> {
|
|
|
|
- if (scene.getGeometryByID(parsedCylinder.id)) {
|
|
|
|
- return null; // null since geometry could be something else than a cylinder...
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var cylinder = new CylinderGeometry(parsedCylinder.id, scene, parsedCylinder.height, parsedCylinder.diameterTop, parsedCylinder.diameterBottom, parsedCylinder.tessellation, parsedCylinder.subdivisions, parsedCylinder.canBeRegenerated, null);
|
|
|
|
- if (Tags) {
|
|
|
|
- Tags.AddTagsTo(cylinder, parsedCylinder.tags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- scene.pushGeometry(cylinder, true);
|
|
|
|
-
|
|
|
|
- return cylinder;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a new torus geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
|
|
|
|
- */
|
|
|
|
-export class TorusGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new torus geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param diameter defines the diameter of the torus
|
|
|
|
- * @param thickness defines the thickness of the torus (ie. internal diameter)
|
|
|
|
- * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the diameter of the torus
|
|
|
|
- */
|
|
|
|
- public diameter: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the thickness of the torus (ie. internal diameter)
|
|
|
|
- */
|
|
|
|
- public thickness: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the tesselation factor to apply to the torus
|
|
|
|
- */
|
|
|
|
- public tessellation: number,
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh: Nullable<Mesh> = null,
|
|
|
|
- /**
|
|
|
|
- * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- public side: number = VertexData.DEFAULTSIDE) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateTorus({ diameter: this.diameter, thickness: this.thickness, tessellation: this.tessellation, sideOrientation: this.side });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new TorusGeometry(id, this.getScene(), this.diameter, this.thickness, this.tessellation, this.canBeRegenerated(), null, this.side);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public serialize(): any {
|
|
|
|
- var serializationObject = super.serialize();
|
|
|
|
-
|
|
|
|
- serializationObject.diameter = this.diameter;
|
|
|
|
- serializationObject.thickness = this.thickness;
|
|
|
|
- serializationObject.tessellation = this.tessellation;
|
|
|
|
-
|
|
|
|
- return serializationObject;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry> {
|
|
|
|
- if (scene.getGeometryByID(parsedTorus.id)) {
|
|
|
|
- return null; // null since geometry could be something else than a torus...
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var torus = new TorusGeometry(parsedTorus.id, scene, parsedTorus.diameter, parsedTorus.thickness, parsedTorus.tessellation, parsedTorus.canBeRegenerated, null);
|
|
|
|
- if (Tags) {
|
|
|
|
- Tags.AddTagsTo(torus, parsedTorus.tags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- scene.pushGeometry(torus, true);
|
|
|
|
-
|
|
|
|
- return torus;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a new ground geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
|
|
|
|
- */
|
|
|
|
-export class GroundGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a new ground geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param width defines the width of the ground
|
|
|
|
- * @param height defines the height of the ground
|
|
|
|
- * @param subdivisions defines the subdivisions to apply to the ground
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the width of the ground
|
|
|
|
- */
|
|
|
|
- public width: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the height of the ground
|
|
|
|
- */
|
|
|
|
- public height: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the subdivisions to apply to the ground
|
|
|
|
- */
|
|
|
|
- public subdivisions: number,
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh: Nullable<Mesh> = null) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateGround({ width: this.width, height: this.height, subdivisions: this.subdivisions });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new GroundGeometry(id, this.getScene(), this.width, this.height, this.subdivisions, this.canBeRegenerated(), null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public serialize(): any {
|
|
|
|
- var serializationObject = super.serialize();
|
|
|
|
-
|
|
|
|
- serializationObject.width = this.width;
|
|
|
|
- serializationObject.height = this.height;
|
|
|
|
- serializationObject.subdivisions = this.subdivisions;
|
|
|
|
-
|
|
|
|
- return serializationObject;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry> {
|
|
|
|
- if (scene.getGeometryByID(parsedGround.id)) {
|
|
|
|
- return null; // null since geometry could be something else than a ground...
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var ground = new GroundGeometry(parsedGround.id, scene, parsedGround.width, parsedGround.height, parsedGround.subdivisions, parsedGround.canBeRegenerated, null);
|
|
|
|
- if (Tags) {
|
|
|
|
- Tags.AddTagsTo(ground, parsedGround.tags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- scene.pushGeometry(ground, true);
|
|
|
|
-
|
|
|
|
- return ground;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a tiled ground geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
|
|
|
|
- */
|
|
|
|
-export class TiledGroundGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a tiled ground geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param xmin defines the minimum value on X axis
|
|
|
|
- * @param zmin defines the minimum value on Z axis
|
|
|
|
- * @param xmax defines the maximum value on X axis
|
|
|
|
- * @param zmax defines the maximum value on Z axis
|
|
|
|
- * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
|
|
|
|
- * @param precision defines the precision to use when computing the tiles
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the minimum value on X axis
|
|
|
|
- */
|
|
|
|
- public xmin: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the minimum value on Z axis
|
|
|
|
- */
|
|
|
|
- public zmin: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the maximum value on X axis
|
|
|
|
- */
|
|
|
|
- public xmax: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the maximum value on Z axis
|
|
|
|
- */
|
|
|
|
- public zmax: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the subdivisions to apply to the ground
|
|
|
|
- */
|
|
|
|
- public subdivisions: { w: number; h: number; },
|
|
|
|
- /**
|
|
|
|
- * Defines the precision to use when computing the tiles
|
|
|
|
- */
|
|
|
|
- public precision: { w: number; h: number; },
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh: Nullable<Mesh> = null) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateTiledGround({ xmin: this.xmin, zmin: this.zmin, xmax: this.xmax, zmax: this.zmax, subdivisions: this.subdivisions, precision: this.precision });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new TiledGroundGeometry(id, this.getScene(), this.xmin, this.zmin, this.xmax, this.zmax, this.subdivisions, this.precision, this.canBeRegenerated(), null);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a plane geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
|
|
|
|
- */
|
|
|
|
-export class PlaneGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a plane geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param size defines the size of the plane (width === height)
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the size of the plane (width === height)
|
|
|
|
- */
|
|
|
|
- public size: number,
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh: Nullable<Mesh> = null,
|
|
|
|
- /**
|
|
|
|
- * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- public side: number = VertexData.DEFAULTSIDE) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreatePlane({ size: this.size, sideOrientation: this.side });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new PlaneGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public serialize(): any {
|
|
|
|
- var serializationObject = super.serialize();
|
|
|
|
-
|
|
|
|
- serializationObject.size = this.size;
|
|
|
|
-
|
|
|
|
- return serializationObject;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry> {
|
|
|
|
- if (scene.getGeometryByID(parsedPlane.id)) {
|
|
|
|
- return null; // null since geometry could be something else than a ground...
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var plane = new PlaneGeometry(parsedPlane.id, scene, parsedPlane.size, parsedPlane.canBeRegenerated, null);
|
|
|
|
- if (Tags) {
|
|
|
|
- Tags.AddTagsTo(plane, parsedPlane.tags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- scene.pushGeometry(plane, true);
|
|
|
|
-
|
|
|
|
- return plane;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Creates a torus knot geometry
|
|
|
|
- * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
|
|
|
|
- */
|
|
|
|
-export class TorusKnotGeometry extends _PrimitiveGeometry {
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Creates a torus knot geometry
|
|
|
|
- * @param id defines the unique ID of the geometry
|
|
|
|
- * @param scene defines the hosting scene
|
|
|
|
- * @param radius defines the radius of the torus knot
|
|
|
|
- * @param tube defines the thickness of the torus knot tube
|
|
|
|
- * @param radialSegments defines the number of radial segments
|
|
|
|
- * @param tubularSegments defines the number of tubular segments
|
|
|
|
- * @param p defines the first number of windings
|
|
|
|
- * @param q defines the second number of windings
|
|
|
|
- * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
|
|
|
|
- * @param mesh defines the hosting mesh (can be null)
|
|
|
|
- * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- constructor(
|
|
|
|
- id: string, scene: Scene,
|
|
|
|
- /**
|
|
|
|
- * Defines the radius of the torus knot
|
|
|
|
- */
|
|
|
|
- public radius: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the thickness of the torus knot tube
|
|
|
|
- */
|
|
|
|
- public tube: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the number of radial segments
|
|
|
|
- */
|
|
|
|
- public radialSegments: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the number of tubular segments
|
|
|
|
- */
|
|
|
|
- public tubularSegments: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the first number of windings
|
|
|
|
- */
|
|
|
|
- public p: number,
|
|
|
|
- /**
|
|
|
|
- * Defines the second number of windings
|
|
|
|
- */
|
|
|
|
- public q: number,
|
|
|
|
- canBeRegenerated?: boolean,
|
|
|
|
- mesh: Nullable<Mesh> = null,
|
|
|
|
- /**
|
|
|
|
- * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
|
|
|
|
- */
|
|
|
|
- public side: number = VertexData.DEFAULTSIDE) {
|
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /** @hidden */
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
|
- return VertexData.CreateTorusKnot({ radius: this.radius, tube: this.tube, radialSegments: this.radialSegments, tubularSegments: this.tubularSegments, p: this.p, q: this.q, sideOrientation: this.side });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
|
- return new TorusKnotGeometry(id, this.getScene(), this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q, this.canBeRegenerated(), null, this.side);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public serialize(): any {
|
|
|
|
- var serializationObject = super.serialize();
|
|
|
|
-
|
|
|
|
- serializationObject.radius = this.radius;
|
|
|
|
- serializationObject.tube = this.tube;
|
|
|
|
- serializationObject.radialSegments = this.radialSegments;
|
|
|
|
- serializationObject.tubularSegments = this.tubularSegments;
|
|
|
|
- serializationObject.p = this.p;
|
|
|
|
- serializationObject.q = this.q;
|
|
|
|
-
|
|
|
|
- return serializationObject;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry> {
|
|
|
|
- if (scene.getGeometryByID(parsedTorusKnot.id)) {
|
|
|
|
- return null; // null since geometry could be something else than a ground...
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var torusKnot = new TorusKnotGeometry(parsedTorusKnot.id, scene, parsedTorusKnot.radius, parsedTorusKnot.tube, parsedTorusKnot.radialSegments, parsedTorusKnot.tubularSegments, parsedTorusKnot.p, parsedTorusKnot.q, parsedTorusKnot.canBeRegenerated, null);
|
|
|
|
- if (Tags) {
|
|
|
|
- Tags.AddTagsTo(torusKnot, parsedTorusKnot.tags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- scene.pushGeometry(torusKnot, true);
|
|
|
|
-
|
|
|
|
- return torusKnot;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
- //}
|
|
|
|
|
|
+}
|