|
@@ -11,7 +11,7 @@
|
|
|
private _engine: Engine;
|
|
|
private _meshes: Mesh[];
|
|
|
private _totalVertices = 0;
|
|
|
- private _indices: number[];
|
|
|
+ private _indices: number[] | Int32Array;
|
|
|
private _vertexBuffers;
|
|
|
private _isDisposed = false;
|
|
|
private _extend: { minimum: Vector3, maximum: Vector3 };
|
|
@@ -209,7 +209,7 @@
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public setIndices(indices: number[], totalVertices?: number): void {
|
|
|
+ public setIndices(indices: number[] | Int32Array, totalVertices?: number): void {
|
|
|
if (this._indexBuffer) {
|
|
|
this._engine._releaseBuffer(this._indexBuffer);
|
|
|
}
|
|
@@ -239,7 +239,7 @@
|
|
|
return this._indices.length;
|
|
|
}
|
|
|
|
|
|
- public getIndices(copyWhenShared?: boolean): number[] {
|
|
|
+ public getIndices(copyWhenShared?: boolean): number[] | Int32Array {
|
|
|
if (!this.isReady()) {
|
|
|
return null;
|
|
|
}
|
|
@@ -420,7 +420,7 @@
|
|
|
this._delayLoadingFunction = null;
|
|
|
this._delayInfo = [];
|
|
|
|
|
|
- this._boundingInfo = null;
|
|
|
+ this._boundingInfo = null;
|
|
|
|
|
|
this._scene.removeGeometry(this);
|
|
|
this._isDisposed = true;
|
|
@@ -433,7 +433,7 @@
|
|
|
|
|
|
var indices = this.getIndices();
|
|
|
for (var index = 0; index < indices.length; index++) {
|
|
|
- vertexData.indices.push(indices[index]);
|
|
|
+ (<number[]>vertexData.indices).push(indices[index]);
|
|
|
}
|
|
|
|
|
|
var updatable = false;
|
|
@@ -490,6 +490,263 @@
|
|
|
return v.toString(16);
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ public static ImportGeometry(parsedGeometry: any, mesh: Mesh): void {
|
|
|
+ var scene = mesh.getScene();
|
|
|
+
|
|
|
+ // Geometry
|
|
|
+ var geometryId = parsedGeometry.geometryId;
|
|
|
+ if (geometryId) {
|
|
|
+ var geometry = scene.getGeometryByID(geometryId);
|
|
|
+ if (geometry) {
|
|
|
+ geometry.applyToMesh(mesh);
|
|
|
+ }
|
|
|
+ } else if (parsedGeometry instanceof ArrayBuffer) {
|
|
|
+
|
|
|
+ var binaryInfo = mesh._binaryInfo;
|
|
|
+
|
|
|
+ if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
|
|
|
+ var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.PositionKind, positionsData, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
|
|
|
+ var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.NormalKind, normalsData, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
|
|
|
+ var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.UVKind, uvsData, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
|
|
|
+ var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV2Kind, uvs2Data, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
|
|
|
+ var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV3Kind, uvs3Data, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
|
|
|
+ var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV4Kind, uvs4Data, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
|
|
|
+ var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV5Kind, uvs5Data, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
|
|
|
+ var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV6Kind, uvs6Data, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
|
|
|
+ var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
|
|
|
+ var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.MatricesIndicesKind, matricesIndicesData, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
|
|
|
+ var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
|
|
|
+ mesh.setVerticesData(VertexBuffer.MatricesWeightsKind, matricesWeightsData, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
|
|
|
+ var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
|
|
|
+ mesh.setIndices(indicesData);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
|
|
|
+ var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
|
|
|
+
|
|
|
+ mesh.subMeshes = [];
|
|
|
+ for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
|
|
|
+ var materialIndex = subMeshesData[(i * 5) + 0];
|
|
|
+ var verticesStart = subMeshesData[(i * 5) + 1];
|
|
|
+ var verticesCount = subMeshesData[(i * 5) + 2];
|
|
|
+ var indexStart = subMeshesData[(i * 5) + 3];
|
|
|
+ var indexCount = subMeshesData[(i * 5) + 4];
|
|
|
+
|
|
|
+ var subMesh = new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.PositionKind, parsedGeometry.positions, false);
|
|
|
+ mesh.setVerticesData(VertexBuffer.NormalKind, parsedGeometry.normals, false);
|
|
|
+
|
|
|
+ if (parsedGeometry.uvs) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.UVKind, parsedGeometry.uvs, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.uvs2) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV2Kind, parsedGeometry.uvs2, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.uvs3) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV3Kind, parsedGeometry.uvs3, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.uvs4) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV4Kind, parsedGeometry.uvs4, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.uvs5) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV5Kind, parsedGeometry.uvs5, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.uvs6) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.UV6Kind, parsedGeometry.uvs6, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.colors) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.ColorKind, Color4.CheckColors4(parsedGeometry.colors, parsedGeometry.positions.length / 3), false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.matricesIndices) {
|
|
|
+ if (!parsedGeometry.matricesIndices._isExpanded) {
|
|
|
+ var floatIndices = [];
|
|
|
+
|
|
|
+ for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
|
|
|
+ var matricesIndex = parsedGeometry.matricesIndices[i];
|
|
|
+
|
|
|
+ floatIndices.push(matricesIndex & 0x000000FF);
|
|
|
+ floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
|
|
|
+ floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
|
|
|
+ floatIndices.push(matricesIndex >> 24);
|
|
|
+ }
|
|
|
+
|
|
|
+ mesh.setVerticesData(VertexBuffer.MatricesIndicesKind, floatIndices, false);
|
|
|
+ } else {
|
|
|
+ delete parsedGeometry.matricesIndices._isExpanded;
|
|
|
+ mesh.setVerticesData(VertexBuffer.MatricesIndicesKind, parsedGeometry.matricesIndices, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.matricesIndicesExtra) {
|
|
|
+ if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
|
|
|
+ var floatIndices = [];
|
|
|
+
|
|
|
+ for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
|
|
|
+ var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
|
|
|
+
|
|
|
+ floatIndices.push(matricesIndex & 0x000000FF);
|
|
|
+ floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
|
|
|
+ floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
|
|
|
+ floatIndices.push(matricesIndex >> 24);
|
|
|
+ }
|
|
|
+
|
|
|
+ mesh.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, floatIndices, false);
|
|
|
+ } else {
|
|
|
+ delete parsedGeometry.matricesIndices._isExpanded;
|
|
|
+ mesh.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.matricesWeights) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.MatricesWeightsKind, parsedGeometry.matricesWeights, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedGeometry.matricesWeightsExtra) {
|
|
|
+ mesh.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ mesh.setIndices(parsedGeometry.indices);
|
|
|
+ }
|
|
|
+
|
|
|
+ // SubMeshes
|
|
|
+ if (parsedGeometry.subMeshes) {
|
|
|
+ mesh.subMeshes = [];
|
|
|
+ for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
|
|
|
+ var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
|
|
|
+
|
|
|
+ var subMesh = new SubMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Flat shading
|
|
|
+ if (mesh._shouldGenerateFlatShading) {
|
|
|
+ mesh.convertToFlatShadedMesh();
|
|
|
+ delete mesh._shouldGenerateFlatShading;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Update
|
|
|
+ mesh.computeWorldMatrix(true);
|
|
|
+
|
|
|
+ // Octree
|
|
|
+ if (scene['_selectionOctree']) {
|
|
|
+ scene['_selectionOctree'].addMesh(mesh);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static ParseGeometry(parsedVertexData: any, scene: Scene, rootUrl: string): Geometry {
|
|
|
+ if (scene.getGeometryByID(parsedVertexData.id)) {
|
|
|
+ return null; // null since geometry could be something else than a box...
|
|
|
+ }
|
|
|
+
|
|
|
+ var geometry = new Geometry(parsedVertexData.id, scene);
|
|
|
+
|
|
|
+ Tags.AddTagsTo(geometry, parsedVertexData.tags);
|
|
|
+
|
|
|
+ if (parsedVertexData.delayLoadingFile) {
|
|
|
+ geometry.delayLoadState = Engine.DELAYLOADSTATE_NOTLOADED;
|
|
|
+ geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
|
|
|
+ geometry._boundingInfo = new BoundingInfo(Vector3.FromArray(parsedVertexData.boundingBoxMinimum), Vector3.FromArray(parsedVertexData.boundingBoxMaximum));
|
|
|
+
|
|
|
+ geometry._delayInfo = [];
|
|
|
+ if (parsedVertexData.hasUVs) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.UVKind);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedVertexData.hasUVs2) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.UV2Kind);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedVertexData.hasUVs3) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.UV3Kind);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedVertexData.hasUVs4) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.UV4Kind);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedVertexData.hasUVs5) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.UV5Kind);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedVertexData.hasUVs6) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.UV6Kind);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedVertexData.hasColors) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.ColorKind);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedVertexData.hasMatricesIndices) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.MatricesIndicesKind);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedVertexData.hasMatricesWeights) {
|
|
|
+ geometry._delayInfo.push(VertexBuffer.MatricesWeightsKind);
|
|
|
+ }
|
|
|
+
|
|
|
+ geometry._delayLoadingFunction = VertexData.ImportVertexData;
|
|
|
+ } else {
|
|
|
+ VertexData.ImportVertexData(parsedVertexData, geometry);
|
|
|
+ }
|
|
|
+
|
|
|
+ scene.pushGeometry(geometry, true);
|
|
|
+
|
|
|
+ return geometry;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/////// Primitives //////////////////////////////////////////////
|
|
@@ -533,7 +790,7 @@
|
|
|
super.setAllVerticesData(vertexData, false);
|
|
|
}
|
|
|
|
|
|
- public setVerticesData(kind: string, data: number[], updatable?: boolean): void {
|
|
|
+ public setVerticesData(kind: string, data: number[] | Int32Array | Float32Array, updatable?: boolean): void {
|
|
|
if (!this._beingRegenerated) {
|
|
|
return;
|
|
|
}
|
|
@@ -597,6 +854,19 @@
|
|
|
public copy(id: string): Geometry {
|
|
|
return new Box(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
|
|
|
}
|
|
|
+
|
|
|
+ public static ParseBox(parsedBox: any, scene: Scene): Geometry.Primitives.Box {
|
|
|
+ if (scene.getGeometryByID(parsedBox.id)) {
|
|
|
+ return null; // null since geometry could be something else than a box...
|
|
|
+ }
|
|
|
+
|
|
|
+ var box = new Geometry.Primitives.Box(parsedBox.id, scene, parsedBox.size, parsedBox.canBeRegenerated, null);
|
|
|
+ Tags.AddTagsTo(box, parsedBox.tags);
|
|
|
+
|
|
|
+ scene.pushGeometry(box, true);
|
|
|
+
|
|
|
+ return box;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export class Sphere extends _Primitive {
|
|
@@ -620,6 +890,19 @@
|
|
|
public copy(id: string): Geometry {
|
|
|
return new Sphere(id, this.getScene(), this.segments, this.diameter, this.canBeRegenerated(), null, this.side);
|
|
|
}
|
|
|
+
|
|
|
+ public static ParseSphere(parsedSphere: any, scene: Scene): Geometry.Primitives.Sphere {
|
|
|
+ if (scene.getGeometryByID(parsedSphere.id)) {
|
|
|
+ return null; // null since geometry could be something else than a sphere...
|
|
|
+ }
|
|
|
+
|
|
|
+ var sphere = new Geometry.Primitives.Sphere(parsedSphere.id, scene, parsedSphere.segments, parsedSphere.diameter, parsedSphere.canBeRegenerated, null);
|
|
|
+ Tags.AddTagsTo(sphere, parsedSphere.tags);
|
|
|
+
|
|
|
+ scene.pushGeometry(sphere, true);
|
|
|
+
|
|
|
+ return sphere;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export class Disc extends _Primitive {
|
|
@@ -673,6 +956,19 @@
|
|
|
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 static ParseCylinder(parsedCylinder: any, scene: Scene): Geometry.Primitives.Cylinder {
|
|
|
+ if (scene.getGeometryByID(parsedCylinder.id)) {
|
|
|
+ return null; // null since geometry could be something else than a cylinder...
|
|
|
+ }
|
|
|
+
|
|
|
+ var cylinder = new Geometry.Primitives.Cylinder(parsedCylinder.id, scene, parsedCylinder.height, parsedCylinder.diameterTop, parsedCylinder.diameterBottom, parsedCylinder.tessellation, parsedCylinder.subdivisions, parsedCylinder.canBeRegenerated, null);
|
|
|
+ Tags.AddTagsTo(cylinder, parsedCylinder.tags);
|
|
|
+
|
|
|
+ scene.pushGeometry(cylinder, true);
|
|
|
+
|
|
|
+ return cylinder;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export class Torus extends _Primitive {
|
|
@@ -698,6 +994,19 @@
|
|
|
public copy(id: string): Geometry {
|
|
|
return new Torus(id, this.getScene(), this.diameter, this.thickness, this.tessellation, this.canBeRegenerated(), null, this.side);
|
|
|
}
|
|
|
+
|
|
|
+ public static ParseTorus(parsedTorus: any, scene: Scene): Geometry.Primitives.Torus {
|
|
|
+ if (scene.getGeometryByID(parsedTorus.id)) {
|
|
|
+ return null; // null since geometry could be something else than a torus...
|
|
|
+ }
|
|
|
+
|
|
|
+ var torus = new Geometry.Primitives.Torus(parsedTorus.id, scene, parsedTorus.diameter, parsedTorus.thickness, parsedTorus.tessellation, parsedTorus.canBeRegenerated, null);
|
|
|
+ Tags.AddTagsTo(torus, parsedTorus.tags);
|
|
|
+
|
|
|
+ scene.pushGeometry(torus, true);
|
|
|
+
|
|
|
+ return torus;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export class Ground extends _Primitive {
|
|
@@ -721,6 +1030,19 @@
|
|
|
public copy(id: string): Geometry {
|
|
|
return new Ground(id, this.getScene(), this.width, this.height, this.subdivisions, this.canBeRegenerated(), null);
|
|
|
}
|
|
|
+
|
|
|
+ public static ParseGround(parsedGround: any, scene: Scene): Geometry.Primitives.Ground {
|
|
|
+ if (scene.getGeometryByID(parsedGround.id)) {
|
|
|
+ return null; // null since geometry could be something else than a ground...
|
|
|
+ }
|
|
|
+
|
|
|
+ var ground = new Geometry.Primitives.Ground(parsedGround.id, scene, parsedGround.width, parsedGround.height, parsedGround.subdivisions, parsedGround.canBeRegenerated, null);
|
|
|
+ Tags.AddTagsTo(ground, parsedGround.tags);
|
|
|
+
|
|
|
+ scene.pushGeometry(ground, true);
|
|
|
+
|
|
|
+ return ground;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export class TiledGround extends _Primitive {
|
|
@@ -771,6 +1093,19 @@
|
|
|
public copy(id: string): Geometry {
|
|
|
return new Plane(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
|
|
|
}
|
|
|
+
|
|
|
+ public static ParsePlane(parsedPlane: any, scene: Scene): Geometry.Primitives.Plane {
|
|
|
+ if (scene.getGeometryByID(parsedPlane.id)) {
|
|
|
+ return null; // null since geometry could be something else than a ground...
|
|
|
+ }
|
|
|
+
|
|
|
+ var plane = new Geometry.Primitives.Plane(parsedPlane.id, scene, parsedPlane.size, parsedPlane.canBeRegenerated, null);
|
|
|
+ Tags.AddTagsTo(plane, parsedPlane.tags);
|
|
|
+
|
|
|
+ scene.pushGeometry(plane, true);
|
|
|
+
|
|
|
+ return plane;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export class TorusKnot extends _Primitive {
|
|
@@ -802,6 +1137,19 @@
|
|
|
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);
|
|
|
}
|
|
|
+
|
|
|
+ public static ParseTorusKnot(parsedTorusKnot: any, scene: Scene): Geometry.Primitives.TorusKnot {
|
|
|
+ if (scene.getGeometryByID(parsedTorusKnot.id)) {
|
|
|
+ return null; // null since geometry could be something else than a ground...
|
|
|
+ }
|
|
|
+
|
|
|
+ var torusKnot = new Geometry.Primitives.TorusKnot(parsedTorusKnot.id, scene, parsedTorusKnot.radius, parsedTorusKnot.tube, parsedTorusKnot.radialSegments, parsedTorusKnot.tubularSegments, parsedTorusKnot.p, parsedTorusKnot.q, parsedTorusKnot.canBeRegenerated, null);
|
|
|
+ Tags.AddTagsTo(torusKnot, parsedTorusKnot.tags);
|
|
|
+
|
|
|
+ scene.pushGeometry(torusKnot, true);
|
|
|
+
|
|
|
+ return torusKnot;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|