Free importer resources after import.
This commit is contained in:
parent
0372bf81c9
commit
edeb864576
22
source/external/rhino.importer.js
vendored
22
source/external/rhino.importer.js
vendored
@ -4,16 +4,8 @@ OV.Importer3dm = class extends OV.ImporterBase
|
||||
{
|
||||
super ();
|
||||
this.rhino = null;
|
||||
this.instanceObjects = null;
|
||||
this.instanceDefinitions = null;
|
||||
}
|
||||
|
||||
ResetState ()
|
||||
{
|
||||
this.instanceObjects = {};
|
||||
this.instanceDefinitions = {};
|
||||
}
|
||||
|
||||
|
||||
CanImportExtension (extension)
|
||||
{
|
||||
return extension === '3dm';
|
||||
@ -31,6 +23,18 @@ OV.Importer3dm = class extends OV.ImporterBase
|
||||
return OV.Direction.Z;
|
||||
}
|
||||
|
||||
ClearContent ()
|
||||
{
|
||||
this.instanceObjects = null;
|
||||
this.instanceDefinitions = null;
|
||||
}
|
||||
|
||||
ResetContent ()
|
||||
{
|
||||
this.instanceObjects = {};
|
||||
this.instanceDefinitions = {};
|
||||
}
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
if (this.rhino === null) {
|
||||
|
||||
@ -49,21 +49,6 @@ OV.Importer3ds = class extends OV.ImporterBase
|
||||
constructor ()
|
||||
{
|
||||
super ();
|
||||
|
||||
this.materialNameToIndex = null;
|
||||
this.meshNameToIndex = null;
|
||||
|
||||
this.meshTransformations = null;
|
||||
this.defaultMaterialIndex = null;
|
||||
}
|
||||
|
||||
ResetState ()
|
||||
{
|
||||
this.materialNameToIndex = {};
|
||||
this.meshNameToIndex = {};
|
||||
|
||||
this.meshTransformations = [];
|
||||
this.defaultMaterialIndex = null;
|
||||
}
|
||||
|
||||
CanImportExtension (extension)
|
||||
@ -81,6 +66,24 @@ OV.Importer3ds = class extends OV.ImporterBase
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Z;
|
||||
}
|
||||
|
||||
ClearContent ()
|
||||
{
|
||||
this.materialNameToIndex = null;
|
||||
this.meshNameToIndex = null;
|
||||
|
||||
this.meshTransformations = null;
|
||||
this.defaultMaterialIndex = null;
|
||||
}
|
||||
|
||||
ResetContent ()
|
||||
{
|
||||
this.materialNameToIndex = {};
|
||||
this.meshNameToIndex = {};
|
||||
|
||||
this.meshTransformations = [];
|
||||
this.defaultMaterialIndex = null;
|
||||
}
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
|
||||
@ -2,15 +2,13 @@ OV.ImporterBase = class
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
this.extension = null;
|
||||
this.callbacks = null;
|
||||
this.model = null;
|
||||
this.error = null;
|
||||
this.message = null;
|
||||
|
||||
}
|
||||
|
||||
Import (content, extension, callbacks)
|
||||
{
|
||||
this.Clear ();
|
||||
|
||||
this.extension = extension;
|
||||
this.callbacks = callbacks;
|
||||
this.model = new OV.Model ();
|
||||
@ -18,12 +16,22 @@ OV.ImporterBase = class
|
||||
this.message = null;
|
||||
|
||||
let obj = this;
|
||||
obj.ResetState ();
|
||||
obj.ImportContent (content, function () {
|
||||
this.ResetContent ();
|
||||
this.ImportContent (content, function () {
|
||||
obj.CreateResult (callbacks);
|
||||
});
|
||||
}
|
||||
|
||||
Clear ()
|
||||
{
|
||||
this.extension = null;
|
||||
this.callbacks = null;
|
||||
this.model = null;
|
||||
this.error = null;
|
||||
this.message = null;
|
||||
this.ClearContent ();
|
||||
}
|
||||
|
||||
CreateResult (callbacks)
|
||||
{
|
||||
if (this.error) {
|
||||
@ -41,11 +49,6 @@ OV.ImporterBase = class
|
||||
callbacks.onSuccess ();
|
||||
}
|
||||
|
||||
ResetState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CanImportExtension (extension)
|
||||
{
|
||||
return false;
|
||||
@ -61,6 +64,16 @@ OV.ImporterBase = class
|
||||
return OV.Direction.Z;
|
||||
}
|
||||
|
||||
ClearContent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ResetContent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
|
||||
|
||||
@ -348,17 +348,6 @@ OV.ImporterGltf = class extends OV.ImporterBase
|
||||
constructor ()
|
||||
{
|
||||
super ();
|
||||
|
||||
this.bufferContents = null;
|
||||
this.gltfExtensions = null;
|
||||
this.imageIndexToTextureParams = null;
|
||||
}
|
||||
|
||||
ResetState ()
|
||||
{
|
||||
this.bufferContents = [];
|
||||
this.gltfExtensions = new OV.GltfExtensions ();
|
||||
this.imageIndexToTextureParams = {};
|
||||
}
|
||||
|
||||
CanImportExtension (extension)
|
||||
@ -380,6 +369,20 @@ OV.ImporterGltf = class extends OV.ImporterBase
|
||||
return OV.Direction.Y;
|
||||
}
|
||||
|
||||
ClearContent ()
|
||||
{
|
||||
this.bufferContents = null;
|
||||
this.gltfExtensions = null;
|
||||
this.imageIndexToTextureParams = null;
|
||||
}
|
||||
|
||||
ResetContent ()
|
||||
{
|
||||
this.bufferContents = [];
|
||||
this.gltfExtensions = new OV.GltfExtensions ();
|
||||
this.imageIndexToTextureParams = {};
|
||||
}
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
if (this.extension === 'gltf') {
|
||||
|
||||
@ -3,33 +3,6 @@ OV.ImporterObj = class extends OV.ImporterBase
|
||||
constructor ()
|
||||
{
|
||||
super ();
|
||||
|
||||
this.globalVertices = null;
|
||||
this.globalNormals = null;
|
||||
this.globalUvs = null;
|
||||
|
||||
this.currentMesh = null;
|
||||
this.currentMeshData = null;
|
||||
this.currentMaterial = null;
|
||||
this.currentMaterialIndex = null;
|
||||
|
||||
this.meshNameToMeshData = null;
|
||||
this.materialNameToIndex = null;
|
||||
}
|
||||
|
||||
ResetState ()
|
||||
{
|
||||
this.globalVertices = [];
|
||||
this.globalNormals = [];
|
||||
this.globalUvs = [];
|
||||
|
||||
this.currentMesh = null;
|
||||
this.currentMeshData = null;
|
||||
this.currentMaterial = null;
|
||||
this.currentMaterialIndex = null;
|
||||
|
||||
this.meshNameToMeshData = {};
|
||||
this.materialNameToIndex = {};
|
||||
}
|
||||
|
||||
CanImportExtension (extension)
|
||||
@ -50,6 +23,36 @@ OV.ImporterObj = class extends OV.ImporterBase
|
||||
return OV.Direction.Y;
|
||||
}
|
||||
|
||||
ClearContent ()
|
||||
{
|
||||
this.globalVertices = null;
|
||||
this.globalNormals = null;
|
||||
this.globalUvs = null;
|
||||
|
||||
this.currentMesh = null;
|
||||
this.currentMeshData = null;
|
||||
this.currentMaterial = null;
|
||||
this.currentMaterialIndex = null;
|
||||
|
||||
this.meshNameToMeshData = null;
|
||||
this.materialNameToIndex = null;
|
||||
}
|
||||
|
||||
ResetContent ()
|
||||
{
|
||||
this.globalVertices = [];
|
||||
this.globalNormals = [];
|
||||
this.globalUvs = [];
|
||||
|
||||
this.currentMesh = null;
|
||||
this.currentMeshData = null;
|
||||
this.currentMaterial = null;
|
||||
this.currentMaterialIndex = null;
|
||||
|
||||
this.meshNameToMeshData = {};
|
||||
this.materialNameToIndex = {};
|
||||
}
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
let obj = this;
|
||||
|
||||
@ -3,23 +3,8 @@ OV.ImporterOff = class extends OV.ImporterBase
|
||||
constructor ()
|
||||
{
|
||||
super ();
|
||||
this.model = null;
|
||||
this.mesh = null;
|
||||
this.status = null;
|
||||
}
|
||||
|
||||
ResetState ()
|
||||
{
|
||||
this.mesh = new OV.Mesh ();
|
||||
this.model.AddMesh (this.mesh);
|
||||
this.status = {
|
||||
vertexCount : 0,
|
||||
faceCount : 0,
|
||||
foundVertex : 0,
|
||||
foundFace : 0
|
||||
};
|
||||
}
|
||||
|
||||
CanImportExtension (extension)
|
||||
{
|
||||
return extension === 'off';
|
||||
@ -36,6 +21,25 @@ OV.ImporterOff = class extends OV.ImporterBase
|
||||
{
|
||||
return OV.Direction.Y;
|
||||
}
|
||||
|
||||
ClearContent ()
|
||||
{
|
||||
this.model = null;
|
||||
this.mesh = null;
|
||||
this.status = null;
|
||||
}
|
||||
|
||||
ResetContent ()
|
||||
{
|
||||
this.mesh = new OV.Mesh ();
|
||||
this.model.AddMesh (this.mesh);
|
||||
this.status = {
|
||||
vertexCount : 0,
|
||||
faceCount : 0,
|
||||
foundVertex : 0,
|
||||
foundFace : 0
|
||||
};
|
||||
}
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
|
||||
@ -89,16 +89,8 @@ OV.ImporterPly = class extends OV.ImporterBase
|
||||
constructor ()
|
||||
{
|
||||
super ();
|
||||
this.model = null;
|
||||
this.mesh = null;
|
||||
}
|
||||
|
||||
ResetState ()
|
||||
{
|
||||
this.mesh = new OV.Mesh ();
|
||||
this.model.AddMesh (this.mesh);
|
||||
}
|
||||
|
||||
CanImportExtension (extension)
|
||||
{
|
||||
return extension === 'ply';
|
||||
@ -115,6 +107,18 @@ OV.ImporterPly = class extends OV.ImporterBase
|
||||
{
|
||||
return OV.Direction.Y;
|
||||
}
|
||||
|
||||
ClearContent ()
|
||||
{
|
||||
this.model = null;
|
||||
this.mesh = null;
|
||||
}
|
||||
|
||||
ResetContent ()
|
||||
{
|
||||
this.mesh = new OV.Mesh ();
|
||||
this.model.AddMesh (this.mesh);
|
||||
}
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
|
||||
@ -3,15 +3,6 @@ OV.ImporterStl = class extends OV.ImporterBase
|
||||
constructor ()
|
||||
{
|
||||
super ();
|
||||
this.mesh = null;
|
||||
this.triangle = null;
|
||||
}
|
||||
|
||||
ResetState ()
|
||||
{
|
||||
this.mesh = new OV.Mesh ();
|
||||
this.model.AddMesh (this.mesh);
|
||||
this.triangle = null;
|
||||
}
|
||||
|
||||
CanImportExtension (extension)
|
||||
@ -29,6 +20,19 @@ OV.ImporterStl = class extends OV.ImporterBase
|
||||
GetUpDirection ()
|
||||
{
|
||||
return OV.Direction.Z;
|
||||
}
|
||||
|
||||
ClearContent ()
|
||||
{
|
||||
this.mesh = null;
|
||||
this.triangle = null;
|
||||
}
|
||||
|
||||
ResetContent ()
|
||||
{
|
||||
this.mesh = new OV.Mesh ();
|
||||
this.model.AddMesh (this.mesh);
|
||||
this.triangle = null;
|
||||
}
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user