|
@@ -1201,398 +1201,398 @@
|
|
|
}
|
|
|
|
|
|
/////// Primitives //////////////////////////////////////////////
|
|
|
- export module Geometry.Primitives {
|
|
|
+ //export module Geometry.Primitives {
|
|
|
|
|
|
- /// Abstract class
|
|
|
- export class _Primitive extends Geometry {
|
|
|
+ /// Abstract class
|
|
|
+ export class _PrimitiveGeometry extends Geometry {
|
|
|
|
|
|
- private _beingRegenerated: boolean;
|
|
|
+ private _beingRegenerated: boolean;
|
|
|
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
- public canBeRegenerated(): boolean {
|
|
|
- return this._canBeRegenerated;
|
|
|
- }
|
|
|
-
|
|
|
- public regenerate(): void {
|
|
|
- if (!this._canBeRegenerated) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this._beingRegenerated = true;
|
|
|
- this.setAllVerticesData(this._regenerateVertexData(), false);
|
|
|
- this._beingRegenerated = false;
|
|
|
- }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
- public asNewGeometry(id: string): Geometry {
|
|
|
- return super.copy(id);
|
|
|
- }
|
|
|
+ public canBeRegenerated(): boolean {
|
|
|
+ return this._canBeRegenerated;
|
|
|
+ }
|
|
|
|
|
|
- // overrides
|
|
|
- public setAllVerticesData(vertexData: VertexData, updatable?: boolean): void {
|
|
|
- if (!this._beingRegenerated) {
|
|
|
- return;
|
|
|
- }
|
|
|
- super.setAllVerticesData(vertexData, false);
|
|
|
+ public regenerate(): void {
|
|
|
+ if (!this._canBeRegenerated) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ this._beingRegenerated = true;
|
|
|
+ this.setAllVerticesData(this._regenerateVertexData(), false);
|
|
|
+ this._beingRegenerated = false;
|
|
|
+ }
|
|
|
|
|
|
- public setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void {
|
|
|
- if (!this._beingRegenerated) {
|
|
|
- return;
|
|
|
- }
|
|
|
- super.setVerticesData(kind, data, false);
|
|
|
- }
|
|
|
+ public asNewGeometry(id: string): Geometry {
|
|
|
+ return super.copy(id);
|
|
|
+ }
|
|
|
|
|
|
- // to override
|
|
|
- // protected
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- throw new Error("Abstract method");
|
|
|
+ // overrides
|
|
|
+ public setAllVerticesData(vertexData: VertexData, updatable?: boolean): void {
|
|
|
+ if (!this._beingRegenerated) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ super.setAllVerticesData(vertexData, false);
|
|
|
+ }
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- throw new Error("Must be overriden in sub-classes.");
|
|
|
+ public setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void {
|
|
|
+ if (!this._beingRegenerated) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ super.setVerticesData(kind, data, false);
|
|
|
+ }
|
|
|
|
|
|
- public serialize(): any {
|
|
|
- var serializationObject = super.serialize();
|
|
|
-
|
|
|
- serializationObject.canBeRegenerated = this.canBeRegenerated();
|
|
|
-
|
|
|
- return serializationObject;
|
|
|
- }
|
|
|
+ // to override
|
|
|
+ // protected
|
|
|
+ public _regenerateVertexData(): VertexData {
|
|
|
+ throw new Error("Abstract method");
|
|
|
}
|
|
|
|
|
|
- export class Ribbon extends _Primitive {
|
|
|
- // Members
|
|
|
+ public copy(id: string): Geometry {
|
|
|
+ throw new Error("Must be overriden in sub-classes.");
|
|
|
+ }
|
|
|
|
|
|
- constructor(id: string, scene: Scene, public pathArray: Vector3[][], public closeArray: boolean, public closePath: boolean, public offset: number, canBeRegenerated?: boolean, mesh?: Mesh, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
- }
|
|
|
+ public serialize(): any {
|
|
|
+ var serializationObject = super.serialize();
|
|
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- return VertexData.CreateRibbon({ pathArray: this.pathArray, closeArray: this.closeArray, closePath: this.closePath, offset: this.offset, sideOrientation: this.side });
|
|
|
- }
|
|
|
+ serializationObject.canBeRegenerated = this.canBeRegenerated();
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new Ribbon(id, this.getScene(), this.pathArray, this.closeArray, this.closePath, this.offset, this.canBeRegenerated(), undefined, this.side);
|
|
|
- }
|
|
|
+ return serializationObject;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- export class Box extends _Primitive {
|
|
|
- // Members
|
|
|
- constructor(id: string, scene: Scene, public size: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
- }
|
|
|
+ export class RibbonGeometry extends _PrimitiveGeometry {
|
|
|
+ // Members
|
|
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- return VertexData.CreateBox({ size: this.size, sideOrientation: this.side });
|
|
|
- }
|
|
|
+ constructor(id: string, scene: Scene, public pathArray: Vector3[][], public closeArray: boolean, public closePath: boolean, public offset: number, canBeRegenerated?: boolean, mesh?: Mesh, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new Box(id, this.getScene(), this.size, this.canBeRegenerated(), undefined, this.side);
|
|
|
- }
|
|
|
+ public _regenerateVertexData(): VertexData {
|
|
|
+ return VertexData.CreateRibbon({ pathArray: this.pathArray, closeArray: this.closeArray, closePath: this.closePath, offset: this.offset, sideOrientation: this.side });
|
|
|
+ }
|
|
|
|
|
|
- public serialize(): any {
|
|
|
- var serializationObject = super.serialize();
|
|
|
+ public copy(id: string): Geometry {
|
|
|
+ return new RibbonGeometry(id, this.getScene(), this.pathArray, this.closeArray, this.closePath, this.offset, this.canBeRegenerated(), undefined, this.side);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- serializationObject.size = this.size;
|
|
|
+ export class BoxGeometry extends _PrimitiveGeometry {
|
|
|
+ // Members
|
|
|
+ constructor(id: string, scene: Scene, public size: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- return serializationObject;
|
|
|
- }
|
|
|
+ public _regenerateVertexData(): VertexData {
|
|
|
+ return VertexData.CreateBox({ size: this.size, sideOrientation: this.side });
|
|
|
+ }
|
|
|
|
|
|
- public static Parse(parsedBox: any, scene: Scene): Nullable<Box> {
|
|
|
- if (scene.getGeometryByID(parsedBox.id)) {
|
|
|
- return null; // null since geometry could be something else than a box...
|
|
|
- }
|
|
|
+ public copy(id: string): Geometry {
|
|
|
+ return new BoxGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), undefined, this.side);
|
|
|
+ }
|
|
|
|
|
|
- var box = new Geometry.Primitives.Box(parsedBox.id, scene, parsedBox.size, parsedBox.canBeRegenerated, null);
|
|
|
- if (Tags) {
|
|
|
- Tags.AddTagsTo(box, parsedBox.tags);
|
|
|
- }
|
|
|
+ public serialize(): any {
|
|
|
+ var serializationObject = super.serialize();
|
|
|
|
|
|
- scene.pushGeometry(box, true);
|
|
|
+ serializationObject.size = this.size;
|
|
|
|
|
|
- return box;
|
|
|
- }
|
|
|
+ return serializationObject;
|
|
|
}
|
|
|
|
|
|
- export class Sphere extends _Primitive {
|
|
|
-
|
|
|
- constructor(id: string, scene: Scene, public segments: number, public diameter: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
+ 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...
|
|
|
}
|
|
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- return VertexData.CreateSphere({ segments: this.segments, diameter: this.diameter, sideOrientation: this.side });
|
|
|
+ var box = new BoxGeometry(parsedBox.id, scene, parsedBox.size, parsedBox.canBeRegenerated, null);
|
|
|
+ if (Tags) {
|
|
|
+ Tags.AddTagsTo(box, parsedBox.tags);
|
|
|
}
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new Sphere(id, this.getScene(), this.segments, this.diameter, this.canBeRegenerated(), null, this.side);
|
|
|
- }
|
|
|
+ scene.pushGeometry(box, true);
|
|
|
|
|
|
- public serialize(): any {
|
|
|
- var serializationObject = super.serialize();
|
|
|
+ return box;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- serializationObject.segments = this.segments;
|
|
|
- serializationObject.diameter = this.diameter;
|
|
|
+ export class SphereGeometry extends _PrimitiveGeometry {
|
|
|
|
|
|
- return serializationObject;
|
|
|
- }
|
|
|
+ constructor(id: string, scene: Scene, public segments: number, public diameter: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- public static Parse(parsedSphere: any, scene: Scene): Nullable<Geometry.Primitives.Sphere> {
|
|
|
- if (scene.getGeometryByID(parsedSphere.id)) {
|
|
|
- return null; // null since geometry could be something else than a sphere...
|
|
|
- }
|
|
|
+ public _regenerateVertexData(): VertexData {
|
|
|
+ return VertexData.CreateSphere({ segments: this.segments, diameter: this.diameter, sideOrientation: this.side });
|
|
|
+ }
|
|
|
|
|
|
- var sphere = new Geometry.Primitives.Sphere(parsedSphere.id, scene, parsedSphere.segments, parsedSphere.diameter, parsedSphere.canBeRegenerated, null);
|
|
|
- if (Tags) {
|
|
|
- Tags.AddTagsTo(sphere, parsedSphere.tags);
|
|
|
- }
|
|
|
+ public copy(id: string): Geometry {
|
|
|
+ return new SphereGeometry(id, this.getScene(), this.segments, this.diameter, this.canBeRegenerated(), null, this.side);
|
|
|
+ }
|
|
|
|
|
|
- scene.pushGeometry(sphere, true);
|
|
|
+ public serialize(): any {
|
|
|
+ var serializationObject = super.serialize();
|
|
|
|
|
|
- return sphere;
|
|
|
- }
|
|
|
- }
|
|
|
+ serializationObject.segments = this.segments;
|
|
|
+ serializationObject.diameter = this.diameter;
|
|
|
|
|
|
- export class Disc extends _Primitive {
|
|
|
- // Members
|
|
|
+ return serializationObject;
|
|
|
+ }
|
|
|
|
|
|
- constructor(id: string, scene: Scene, public radius: number, public tessellation: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
+ 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...
|
|
|
}
|
|
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- return VertexData.CreateDisc({ radius: this.radius, tessellation: this.tessellation, sideOrientation: this.side });
|
|
|
+ var sphere = new SphereGeometry(parsedSphere.id, scene, parsedSphere.segments, parsedSphere.diameter, parsedSphere.canBeRegenerated, null);
|
|
|
+ if (Tags) {
|
|
|
+ Tags.AddTagsTo(sphere, parsedSphere.tags);
|
|
|
}
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new Disc(id, this.getScene(), this.radius, this.tessellation, this.canBeRegenerated(), null, this.side);
|
|
|
- }
|
|
|
+ scene.pushGeometry(sphere, true);
|
|
|
+
|
|
|
+ return sphere;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ export class DiscGeometry extends _PrimitiveGeometry {
|
|
|
+ // Members
|
|
|
|
|
|
- export class Cylinder extends _Primitive {
|
|
|
+ constructor(id: string, scene: Scene, public radius: number, public tessellation: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- constructor(id: string, scene: Scene, public height: number, public diameterTop: number, public diameterBottom: number, public tessellation: number, public subdivisions: number = 1, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
- }
|
|
|
+ public _regenerateVertexData(): VertexData {
|
|
|
+ return VertexData.CreateDisc({ radius: this.radius, tessellation: this.tessellation, sideOrientation: this.side });
|
|
|
+ }
|
|
|
|
|
|
- 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 DiscGeometry(id, this.getScene(), this.radius, this.tessellation, this.canBeRegenerated(), null, this.side);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new Cylinder(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();
|
|
|
+ export class CylinderGeometry extends _PrimitiveGeometry {
|
|
|
|
|
|
- serializationObject.height = this.height;
|
|
|
- serializationObject.diameterTop = this.diameterTop;
|
|
|
- serializationObject.diameterBottom = this.diameterBottom;
|
|
|
- serializationObject.tessellation = this.tessellation;
|
|
|
+ constructor(id: string, scene: Scene, public height: number, public diameterTop: number, public diameterBottom: number, public tessellation: number, public subdivisions: number = 1, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- return serializationObject;
|
|
|
- }
|
|
|
+ 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 static Parse(parsedCylinder: any, scene: Scene): Nullable<Geometry.Primitives.Cylinder> {
|
|
|
- if (scene.getGeometryByID(parsedCylinder.id)) {
|
|
|
- return null; // null since geometry could be something else than a cylinder...
|
|
|
- }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
- var cylinder = new Geometry.Primitives.Cylinder(parsedCylinder.id, scene, parsedCylinder.height, parsedCylinder.diameterTop, parsedCylinder.diameterBottom, parsedCylinder.tessellation, parsedCylinder.subdivisions, parsedCylinder.canBeRegenerated, null);
|
|
|
- if (Tags) {
|
|
|
- Tags.AddTagsTo(cylinder, parsedCylinder.tags);
|
|
|
- }
|
|
|
+ public serialize(): any {
|
|
|
+ var serializationObject = super.serialize();
|
|
|
|
|
|
- scene.pushGeometry(cylinder, true);
|
|
|
+ serializationObject.height = this.height;
|
|
|
+ serializationObject.diameterTop = this.diameterTop;
|
|
|
+ serializationObject.diameterBottom = this.diameterBottom;
|
|
|
+ serializationObject.tessellation = this.tessellation;
|
|
|
|
|
|
- return cylinder;
|
|
|
- }
|
|
|
+ return serializationObject;
|
|
|
}
|
|
|
|
|
|
- export class Torus extends _Primitive {
|
|
|
-
|
|
|
- constructor(id: string, scene: Scene, public diameter: number, public thickness: number, public tessellation: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
+ 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...
|
|
|
}
|
|
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- return VertexData.CreateTorus({ diameter: this.diameter, thickness: this.thickness, tessellation: this.tessellation, sideOrientation: this.side });
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new Torus(id, this.getScene(), this.diameter, this.thickness, this.tessellation, this.canBeRegenerated(), null, this.side);
|
|
|
- }
|
|
|
+ scene.pushGeometry(cylinder, true);
|
|
|
|
|
|
- public serialize(): any {
|
|
|
- var serializationObject = super.serialize();
|
|
|
+ return cylinder;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- serializationObject.diameter = this.diameter;
|
|
|
- serializationObject.thickness = this.thickness;
|
|
|
- serializationObject.tessellation = this.tessellation;
|
|
|
+ export class TorusGeometry extends _PrimitiveGeometry {
|
|
|
|
|
|
- return serializationObject;
|
|
|
- }
|
|
|
+ constructor(id: string, scene: Scene, public diameter: number, public thickness: number, public tessellation: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- public static Parse(parsedTorus: any, scene: Scene): Nullable<Geometry.Primitives.Torus> {
|
|
|
- if (scene.getGeometryByID(parsedTorus.id)) {
|
|
|
- return null; // null since geometry could be something else than a torus...
|
|
|
- }
|
|
|
+ public _regenerateVertexData(): VertexData {
|
|
|
+ return VertexData.CreateTorus({ diameter: this.diameter, thickness: this.thickness, tessellation: this.tessellation, sideOrientation: this.side });
|
|
|
+ }
|
|
|
|
|
|
- var torus = new Geometry.Primitives.Torus(parsedTorus.id, scene, parsedTorus.diameter, parsedTorus.thickness, parsedTorus.tessellation, parsedTorus.canBeRegenerated, null);
|
|
|
- if (Tags) {
|
|
|
- Tags.AddTagsTo(torus, parsedTorus.tags);
|
|
|
- }
|
|
|
+ public copy(id: string): Geometry {
|
|
|
+ return new TorusGeometry(id, this.getScene(), this.diameter, this.thickness, this.tessellation, this.canBeRegenerated(), null, this.side);
|
|
|
+ }
|
|
|
|
|
|
- scene.pushGeometry(torus, true);
|
|
|
+ public serialize(): any {
|
|
|
+ var serializationObject = super.serialize();
|
|
|
|
|
|
- return torus;
|
|
|
- }
|
|
|
- }
|
|
|
+ serializationObject.diameter = this.diameter;
|
|
|
+ serializationObject.thickness = this.thickness;
|
|
|
+ serializationObject.tessellation = this.tessellation;
|
|
|
|
|
|
- export class Ground extends _Primitive {
|
|
|
+ return serializationObject;
|
|
|
+ }
|
|
|
|
|
|
- constructor(id: string, scene: Scene, public width: number, public height: number, public subdivisions: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
+ 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...
|
|
|
}
|
|
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- return VertexData.CreateGround({ width: this.width, height: this.height, subdivisions: this.subdivisions });
|
|
|
+ var torus = new TorusGeometry(parsedTorus.id, scene, parsedTorus.diameter, parsedTorus.thickness, parsedTorus.tessellation, parsedTorus.canBeRegenerated, null);
|
|
|
+ if (Tags) {
|
|
|
+ Tags.AddTagsTo(torus, parsedTorus.tags);
|
|
|
}
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new Ground(id, this.getScene(), this.width, this.height, this.subdivisions, this.canBeRegenerated(), null);
|
|
|
- }
|
|
|
+ scene.pushGeometry(torus, true);
|
|
|
|
|
|
- public serialize(): any {
|
|
|
- var serializationObject = super.serialize();
|
|
|
+ return torus;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- serializationObject.width = this.width;
|
|
|
- serializationObject.height = this.height;
|
|
|
- serializationObject.subdivisions = this.subdivisions;
|
|
|
+ export class GroundGeometry extends _PrimitiveGeometry {
|
|
|
|
|
|
- return serializationObject;
|
|
|
- }
|
|
|
+ constructor(id: string, scene: Scene, public width: number, public height: number, public subdivisions: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- public static Parse(parsedGround: any, scene: Scene): Nullable<Geometry.Primitives.Ground> {
|
|
|
- if (scene.getGeometryByID(parsedGround.id)) {
|
|
|
- return null; // null since geometry could be something else than a ground...
|
|
|
- }
|
|
|
+ public _regenerateVertexData(): VertexData {
|
|
|
+ return VertexData.CreateGround({ width: this.width, height: this.height, subdivisions: this.subdivisions });
|
|
|
+ }
|
|
|
|
|
|
- var ground = new Geometry.Primitives.Ground(parsedGround.id, scene, parsedGround.width, parsedGround.height, parsedGround.subdivisions, parsedGround.canBeRegenerated, null);
|
|
|
- if (Tags) {
|
|
|
- Tags.AddTagsTo(ground, parsedGround.tags);
|
|
|
- }
|
|
|
+ public copy(id: string): Geometry {
|
|
|
+ return new GroundGeometry(id, this.getScene(), this.width, this.height, this.subdivisions, this.canBeRegenerated(), null);
|
|
|
+ }
|
|
|
|
|
|
- scene.pushGeometry(ground, true);
|
|
|
+ public serialize(): any {
|
|
|
+ var serializationObject = super.serialize();
|
|
|
|
|
|
- return ground;
|
|
|
- }
|
|
|
- }
|
|
|
+ serializationObject.width = this.width;
|
|
|
+ serializationObject.height = this.height;
|
|
|
+ serializationObject.subdivisions = this.subdivisions;
|
|
|
|
|
|
- export class TiledGround extends _Primitive {
|
|
|
+ return serializationObject;
|
|
|
+ }
|
|
|
|
|
|
- constructor(id: string, scene: Scene, public xmin: number, public zmin: number, public xmax: number, public zmax: number, public subdivisions: { w: number; h: number; }, public precision: { w: number; h: number; }, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
+ 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...
|
|
|
}
|
|
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- return VertexData.CreateTiledGround({ xmin: this.xmin, zmin: this.zmin, xmax: this.xmax, zmax: this.zmax, subdivisions: this.subdivisions, precision: this.precision });
|
|
|
+ var ground = new GroundGeometry(parsedGround.id, scene, parsedGround.width, parsedGround.height, parsedGround.subdivisions, parsedGround.canBeRegenerated, null);
|
|
|
+ if (Tags) {
|
|
|
+ Tags.AddTagsTo(ground, parsedGround.tags);
|
|
|
}
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new TiledGround(id, this.getScene(), this.xmin, this.zmin, this.xmax, this.zmax, this.subdivisions, this.precision, this.canBeRegenerated(), null);
|
|
|
- }
|
|
|
+ scene.pushGeometry(ground, true);
|
|
|
+
|
|
|
+ return ground;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- export class Plane extends _Primitive {
|
|
|
+ export class TiledGroundGeometry extends _PrimitiveGeometry {
|
|
|
|
|
|
- constructor(id: string, scene: Scene, public size: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
- }
|
|
|
+ constructor(id: string, scene: Scene, public xmin: number, public zmin: number, public xmax: number, public zmax: number, public subdivisions: { w: number; h: number; }, public precision: { w: number; h: number; }, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- public _regenerateVertexData(): VertexData {
|
|
|
- return VertexData.CreatePlane({ size: this.size, sideOrientation: this.side });
|
|
|
- }
|
|
|
+ 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 Plane(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
|
|
|
- }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- public serialize(): any {
|
|
|
- var serializationObject = super.serialize();
|
|
|
+ export class PlaneGeometry extends _PrimitiveGeometry {
|
|
|
|
|
|
- serializationObject.size = this.size;
|
|
|
+ constructor(id: string, scene: Scene, public size: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- return serializationObject;
|
|
|
- }
|
|
|
+ public _regenerateVertexData(): VertexData {
|
|
|
+ return VertexData.CreatePlane({ size: this.size, sideOrientation: this.side });
|
|
|
+ }
|
|
|
|
|
|
- public static Parse(parsedPlane: any, scene: Scene): Nullable<Geometry.Primitives.Plane> {
|
|
|
- if (scene.getGeometryByID(parsedPlane.id)) {
|
|
|
- return null; // null since geometry could be something else than a ground...
|
|
|
- }
|
|
|
+ public copy(id: string): Geometry {
|
|
|
+ return new PlaneGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
|
|
|
+ }
|
|
|
|
|
|
- var plane = new Geometry.Primitives.Plane(parsedPlane.id, scene, parsedPlane.size, parsedPlane.canBeRegenerated, null);
|
|
|
- if (Tags) {
|
|
|
- Tags.AddTagsTo(plane, parsedPlane.tags);
|
|
|
- }
|
|
|
+ public serialize(): any {
|
|
|
+ var serializationObject = super.serialize();
|
|
|
|
|
|
- scene.pushGeometry(plane, true);
|
|
|
+ serializationObject.size = this.size;
|
|
|
|
|
|
- return plane;
|
|
|
- }
|
|
|
+ return serializationObject;
|
|
|
}
|
|
|
|
|
|
- export class TorusKnot extends _Primitive {
|
|
|
-
|
|
|
- constructor(id: string, scene: Scene, public radius: number, public tube: number, public radialSegments: number, public tubularSegments: number, public p: number, public q: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
- super(id, scene, canBeRegenerated, mesh);
|
|
|
+ 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...
|
|
|
}
|
|
|
|
|
|
- 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 });
|
|
|
+ var plane = new PlaneGeometry(parsedPlane.id, scene, parsedPlane.size, parsedPlane.canBeRegenerated, null);
|
|
|
+ if (Tags) {
|
|
|
+ Tags.AddTagsTo(plane, parsedPlane.tags);
|
|
|
}
|
|
|
|
|
|
- public copy(id: string): Geometry {
|
|
|
- return new TorusKnot(id, this.getScene(), this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q, this.canBeRegenerated(), null, this.side);
|
|
|
- }
|
|
|
+ scene.pushGeometry(plane, true);
|
|
|
|
|
|
- public serialize(): any {
|
|
|
- var serializationObject = super.serialize();
|
|
|
+ return plane;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- serializationObject.radius = this.radius;
|
|
|
- serializationObject.tube = this.tube;
|
|
|
- serializationObject.radialSegments = this.radialSegments;
|
|
|
- serializationObject.tubularSegments = this.tubularSegments;
|
|
|
- serializationObject.p = this.p;
|
|
|
- serializationObject.q = this.q;
|
|
|
+ export class TorusKnotGeometry extends _PrimitiveGeometry {
|
|
|
|
|
|
- return serializationObject;
|
|
|
- };
|
|
|
+ constructor(id: string, scene: Scene, public radius: number, public tube: number, public radialSegments: number, public tubularSegments: number, public p: number, public q: number, canBeRegenerated?: boolean, mesh: Nullable<Mesh> = null, public side: number = Mesh.DEFAULTSIDE) {
|
|
|
+ super(id, scene, canBeRegenerated, mesh);
|
|
|
+ }
|
|
|
|
|
|
- public static Parse(parsedTorusKnot: any, scene: Scene): Nullable<Geometry.Primitives.TorusKnot> {
|
|
|
- if (scene.getGeometryByID(parsedTorusKnot.id)) {
|
|
|
- return null; // null since geometry could be something else than a ground...
|
|
|
- }
|
|
|
+ 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 });
|
|
|
+ }
|
|
|
|
|
|
- var torusKnot = new Geometry.Primitives.TorusKnot(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);
|
|
|
- }
|
|
|
+ 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;
|
|
|
+ };
|
|
|
|
|
|
- scene.pushGeometry(torusKnot, true);
|
|
|
+ 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...
|
|
|
+ }
|
|
|
|
|
|
- return torusKnot;
|
|
|
+ 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;
|
|
|
}
|
|
|
}
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
|