Use arrow callbacks everywhere.

This commit is contained in:
kovacsv 2021-07-12 08:49:12 +02:00
parent d51c334219
commit 5851aedb1d
41 changed files with 361 additions and 421 deletions

View File

@ -25,6 +25,7 @@
"no-prototype-builtins": "error",
"no-eval": "error",
"no-useless-escape": "error",
"prefer-arrow-callback" : "error",
"quotes": ["error", "single"],
"block-scoped-var": "error",
"no-loop-func": "error",

View File

@ -26,7 +26,7 @@ OV.TaskRunner = class
stepCount = parseInt ((count - 1) / batchCount, 10) + 1;
}
this.Run (stepCount, {
runTask : function (index, ready) {
runTask : (index, ready) => {
const firstIndex = index * batchCount;
const lastIndex = Math.min ((index + 1) * batchCount, count) - 1;
callbacks.runTask (firstIndex, lastIndex, ready);
@ -37,9 +37,8 @@ OV.TaskRunner = class
RunOnce ()
{
let obj = this;
setTimeout (function () {
obj.callbacks.runTask (obj.current, obj.TaskReady.bind (obj));
setTimeout (() => {
this.callbacks.runTask (this.current, this.TaskReady.bind (this));
}, 0);
}
@ -58,7 +57,7 @@ OV.TaskRunner = class
OV.RunTaskAsync = function (task)
{
setTimeout (function () {
setTimeout (() => {
task ();
}, 0);
};

View File

@ -31,7 +31,7 @@ OV.Exporter = class
return;
}
exporter.Export (model, format, function (files) {
exporter.Export (model, format, (files) => {
if (files.length === 0) {
callbacks.onError ();
} else {

View File

@ -42,7 +42,7 @@ OV.ExporterBase = class
Export (model, format, onFinish)
{
let files = [];
this.ExportContent (model, format, files, function () {
this.ExportContent (model, format, files, () => {
onFinish (files);
});
}

View File

@ -46,7 +46,7 @@ OV.ExporterGltf = class extends OV.ExporterBase
});
let fileNameToIndex = [];
this.ExportMaterials (model, mainJson, function (texture) {
this.ExportMaterials (model, mainJson, (texture) => {
let fileName = OV.GetFileName (texture.name);
let textureIndex = fileNameToIndex[fileName];
if (textureIndex === undefined) {
@ -100,7 +100,7 @@ OV.ExporterGltf = class extends OV.ExporterBase
let textureOffset = mainBuffer.byteLength;
let fileNameToIndex = [];
this.ExportMaterials (model, mainJson, function (texture) {
this.ExportMaterials (model, mainJson, (texture) => {
let fileName = OV.GetFileName (texture.name);
let extension = OV.GetFileExtension (texture.name);
let textureIndex = fileNameToIndex[fileName];

View File

@ -20,7 +20,7 @@ OV.ExporterObj = class extends OV.ExporterBase
let fileName = OV.GetFileName (texture.name);
mtlWriter.WriteArrayLine ([keyword, fileName]);
let fileIndex = files.findIndex (function (file) {
let fileIndex = files.findIndex ((file) => {
return file.GetName () === fileName;
});
if (fileIndex === -1) {

View File

@ -27,7 +27,7 @@ OV.ExporterStl = class extends OV.ExporterBase
let stlWriter = new OV.TextWriter ();
stlWriter.WriteLine ('solid Model');
OV.EnumerateTrianglesWithNormals (model, function (v0, v1, v2, normal) {
OV.EnumerateTrianglesWithNormals (model, (v0, v1, v2, normal) => {
stlWriter.WriteArrayLine (['facet', 'normal', normal.x, normal.y, normal.z]);
stlWriter.Indent (1);
stlWriter.WriteLine ('outer loop');
@ -60,7 +60,7 @@ OV.ExporterStl = class extends OV.ExporterBase
}
stlWriter.WriteUnsignedInteger32 (triangleCount);
OV.EnumerateTrianglesWithNormals (model, function (v0, v1, v2, normal) {
OV.EnumerateTrianglesWithNormals (model, (v0, v1, v2, normal) => {
stlWriter.WriteFloat32 (normal.x);
stlWriter.WriteFloat32 (normal.y);
stlWriter.WriteFloat32 (normal.z);

View File

@ -38,16 +38,15 @@ OV.ImporterIfc = class extends OV.ImporterBase
ImportContent (fileContent, onFinish)
{
if (this.ifc === null) {
let obj = this;
OV.LoadExternalLibrary ('web-ifc-api.js', {
success : function () {
obj.ifc = new IfcAPI ();
obj.ifc.Init ().then (function () {
obj.ImportIfcContent (fileContent);
success : () => {
this.ifc = new IfcAPI ();
this.ifc.Init ().then (() => {
this.ImportIfcContent (fileContent);
onFinish ();
});
},
error : function () {
error : () => {
onFinish ();
}
});
@ -118,19 +117,18 @@ OV.ImporterIfc = class extends OV.ImporterBase
ImportProperties (modelID)
{
let obj = this;
// TODO: var IFCRELDEFINESBYPROPERTIES = 4186316022;
// TODO: var IFCBUILDING = 4031249490;
const lines = this.ifc.GetLineIDsWithType (modelID, 4186316022);
for (let i = 0; i < lines.size (); i++) {
const relID = lines.get (i);
const rel = this.ifc.GetLine (modelID, relID);
rel.RelatedObjects.forEach (function (objectRelID) {
let element = obj.expressIDToMesh[objectRelID.value];
rel.RelatedObjects.forEach ((objectRelID) => {
let element = this.expressIDToMesh[objectRelID.value];
if (element === undefined) {
let propSetOwner = obj.ifc.GetLine (modelID, objectRelID.value, true);
let propSetOwner = this.ifc.GetLine (modelID, objectRelID.value, true);
if (propSetOwner.type === 4031249490) {
element = obj.model;
element = this.model;
} else {
return;
}
@ -139,22 +137,22 @@ OV.ImporterIfc = class extends OV.ImporterBase
return;
}
let propSetDef = rel.RelatingPropertyDefinition;
let propSet = obj.ifc.GetLine (modelID, propSetDef.value, true);
let propSet = this.ifc.GetLine (modelID, propSetDef.value, true);
if (!propSet || !propSet.HasProperties) {
return;
}
let propertyGroup = new OV.PropertyGroup (propSet.Name.value);
propSet.HasProperties.forEach (function (property) {
propSet.HasProperties.forEach ((property) => {
if (!property || !property.Name || !property.NominalValue) {
return;
}
let elemProperty = null;
let propertyName = obj.GetIFCString (property.Name.value);
let propertyName = this.GetIFCString (property.Name.value);
switch (property.NominalValue.label) {
case 'IFCTEXT':
case 'IFCLABEL':
case 'IFCIDENTIFIER':
elemProperty = new OV.Property (OV.PropertyType.Text, propertyName, obj.GetIFCString (property.NominalValue.value));
elemProperty = new OV.Property (OV.PropertyType.Text, propertyName, this.GetIFCString (property.NominalValue.value));
break;
case 'IFCBOOLEAN':
elemProperty = new OV.Property (OV.PropertyType.Boolean, propertyName, property.NominalValue.value === 'T' ? true : false);

View File

@ -14,15 +14,14 @@ OV.Exporter3dm = class extends OV.ExporterBase
ExportContent (model, format, files, onFinish)
{
if (this.rhino === null) {
let obj = this;
OV.LoadExternalLibrary ('rhino3dm.min.js', {
success : function () {
rhino3dm ().then (function (rhino) {
obj.rhino = rhino;
obj.ExportRhinoContent (model, files, onFinish);
success : () => {
rhino3dm ().then ((rhino) => {
this.rhino = rhino;
this.ExportRhinoContent (model, files, onFinish);
});
},
error : function () {
error : () => {
onFinish ();
}
});

View File

@ -38,16 +38,15 @@ OV.Importer3dm = class extends OV.ImporterBase
ImportContent (fileContent, onFinish)
{
if (this.rhino === null) {
let obj = this;
OV.LoadExternalLibrary ('rhino3dm.min.js', {
success : function () {
rhino3dm ().then (function (rhino) {
obj.rhino = rhino;
obj.ImportRhinoContent (fileContent);
success : () => {
rhino3dm ().then ((rhino) => {
this.rhino = rhino;
this.ImportRhinoContent (fileContent);
onFinish ();
});
},
error : function () {
error : () => {
onFinish ();
}
});

View File

@ -35,7 +35,7 @@ OV.ConvertModelToThreeMeshes = function (model, params, result, callbacks)
return;
}
let loader = new THREE.TextureLoader ();
loader.load (texture.url, function (threeTexture) {
loader.load (texture.url, (threeTexture) => {
SetTextureParameters (texture, threeTexture);
threeTexture.image = OV.ResizeImageToPowerOfTwoSides (threeTexture.image);
threeMaterial.needsUpdate = true;
@ -66,26 +66,26 @@ OV.ConvertModelToThreeMeshes = function (model, params, result, callbacks)
}
let threeMaterial = new THREE.MeshPhongMaterial (materialParams);
LoadTexture (threeMaterial, material.diffuseMap, function (threeTexture) {
LoadTexture (threeMaterial, material.diffuseMap, (threeTexture) => {
if (!material.multiplyDiffuseMap) {
threeMaterial.color.setRGB (1.0, 1.0, 1.0);
}
threeMaterial.map = threeTexture;
callbacks.onTextureLoaded ();
});
LoadTexture (threeMaterial, material.specularMap, function (threeTexture) {
LoadTexture (threeMaterial, material.specularMap, (threeTexture) => {
threeMaterial.specularMap = threeTexture;
callbacks.onTextureLoaded ();
});
LoadTexture (threeMaterial, material.bumpMap, function (threeTexture) {
LoadTexture (threeMaterial, material.bumpMap, (threeTexture) => {
threeMaterial.bumpMap = threeTexture;
callbacks.onTextureLoaded ();
});
LoadTexture (threeMaterial, material.normalMap, function (threeTexture) {
LoadTexture (threeMaterial, material.normalMap, (threeTexture) => {
threeMaterial.normalMap = threeTexture;
callbacks.onTextureLoaded ();
});
LoadTexture (threeMaterial, material.emissiveMap, function (threeTexture) {
LoadTexture (threeMaterial, material.emissiveMap, (threeTexture) => {
threeMaterial.emissiveMap = threeTexture;
callbacks.onTextureLoaded ();
});
@ -109,7 +109,7 @@ OV.ConvertModelToThreeMeshes = function (model, params, result, callbacks)
for (let i = 0; i < triangleCount; i++) {
triangleIndices.push (i);
}
triangleIndices.sort (function (a, b) {
triangleIndices.sort ((a, b) => {
let aTriangle = mesh.GetTriangle (a);
let bTriangle = mesh.GetTriangle (b);
return aTriangle.mat - bTriangle.mat;

View File

@ -22,11 +22,10 @@ OV.ThreeModelLoader = class
return;
}
let obj = this;
this.inProgress = true;
this.callbacks.onLoadStart ();
this.importer.LoadFilesFromUrls (urls, function () {
obj.OnFilesLoaded (settings);
this.importer.LoadFilesFromUrls (urls, () => {
this.OnFilesLoaded (settings);
});
}
@ -36,11 +35,10 @@ OV.ThreeModelLoader = class
return;
}
let obj = this;
this.inProgress = true;
this.callbacks.onLoadStart ();
this.importer.LoadFilesFromFileObjects (files, function () {
obj.OnFilesLoaded (settings);
this.importer.LoadFilesFromFileObjects (files, () => {
this.OnFilesLoaded (settings);
});
}
@ -57,16 +55,15 @@ OV.ThreeModelLoader = class
OnFilesLoaded (settings)
{
let obj = this;
this.callbacks.onImportStart ();
OV.RunTaskAsync (function () {
obj.importer.Import (settings, {
onSuccess : function (importResult) {
obj.OnModelImported (importResult);
OV.RunTaskAsync (() => {
this.importer.Import (settings, {
onSuccess : (importResult) => {
this.OnModelImported (importResult);
},
onError : function (importError) {
obj.callbacks.onLoadError (importError);
obj.inProgress = false;
onError : (importError) => {
this.callbacks.onLoadError (importError);
this.inProgress = false;
}
});
});
@ -74,19 +71,18 @@ OV.ThreeModelLoader = class
OnModelImported (importResult)
{
let obj = this;
this.callbacks.onVisualizationStart ();
let params = new OV.ModelToThreeConversionParams ();
params.forceMediumpForMaterials = this.hasHighpDriverIssue;
let result = new OV.ModelToThreeConversionResult ();
OV.ConvertModelToThreeMeshes (importResult.model, params, result, {
onTextureLoaded : function () {
obj.callbacks.onTextureLoaded ();
onTextureLoaded : () => {
this.callbacks.onTextureLoaded ();
},
onModelLoaded : function (meshes) {
obj.defaultMaterial = result.defaultMaterial;
obj.callbacks.onModelFinished (importResult, meshes);
obj.inProgress = false;
onModelLoaded : (meshes) => {
this.defaultMaterial = result.defaultMaterial;
this.callbacks.onModelFinished (importResult, meshes);
this.inProgress = false;
}
});
}

View File

@ -53,11 +53,10 @@ OV.FileList = class
GetContent (onReady)
{
let obj = this;
let taskRunner = new OV.TaskRunner ();
taskRunner.Run (this.files.length, {
runTask : function (index, complete) {
obj.GetFileContent (obj.files[index], complete);
runTask : (index, complete) => {
this.GetFileContent (this.files[index], complete);
},
onReady : onReady
});
@ -132,13 +131,13 @@ OV.FileList = class
GetFileContent (file, complete)
{
let callbacks = {
success : function (content) {
success : (content) => {
file.content = content;
},
error : function () {
error : () => {
},
complete : function () {
complete : () => {
complete ();
}
};
@ -303,50 +302,49 @@ OV.Importer = class
this.missingFiles = [];
this.usedFiles.push (mainFile.file.name);
let obj = this;
let importer = mainFile.importer;
let buffers = new OV.ImportBuffers (function (fileName) {
let buffers = new OV.ImportBuffers ((fileName) => {
let fileBuffer = null;
let file = obj.fileList.FindFileByPath (fileName);
let file = this.fileList.FindFileByPath (fileName);
if (file === null || file.content === null) {
obj.missingFiles.push (fileName);
this.missingFiles.push (fileName);
fileBuffer = null;
} else {
fileBuffer = file.content;
obj.usedFiles.push (fileName);
this.usedFiles.push (fileName);
}
return fileBuffer;
});
importer.Import (mainFile.file.content, mainFile.file.extension, {
getDefaultMaterial : function () {
getDefaultMaterial : () => {
let material = new OV.Material ();
material.diffuse = settings.defaultColor;
return material;
},
getFileBuffer : function (filePath) {
getFileBuffer : (filePath) => {
return buffers.GetFileBuffer (filePath);
},
getTextureBuffer : function (filePath) {
getTextureBuffer : (filePath) => {
return buffers.GetTextureBuffer (filePath);
},
onSuccess : function () {
obj.model = importer.GetModel ();
obj.model.SetName (mainFile.file.name);
onSuccess : () => {
this.model = importer.GetModel ();
this.model.SetName (mainFile.file.name);
let result = new OV.ImportResult ();
result.mainFile = mainFile.file.name;
result.model = obj.model;
result.usedFiles = obj.usedFiles;
result.missingFiles = obj.missingFiles;
result.model = this.model;
result.usedFiles = this.usedFiles;
result.missingFiles = this.missingFiles;
result.upVector = importer.GetUpDirection ();
callbacks.onSuccess (result);
},
onError : function () {
onError : () => {
let message = importer.GetMessage ();
callbacks.onError (new OV.ImportError (OV.ImportErrorCode.ImportFailed, message));
},
onComplete : function () {
onComplete : () => {
importer.Clear ();
}
});
@ -382,7 +380,7 @@ OV.Importer = class
if (reset) {
this.fileList = newFileList;
}
this.fileList.GetContent (function () {
this.fileList.GetContent (() => {
onReady ();
});
}
@ -404,7 +402,7 @@ OV.Importer = class
}
for (let i = 0; i < this.model.MaterialCount (); i++) {
let material = this.model.GetMaterial (i);
material.EnumerateTextureMaps (function (texture) {
material.EnumerateTextureMaps ((texture) => {
if (texture.url !== null) {
OV.RevokeObjectUrl (texture.url);
}

View File

@ -94,76 +94,72 @@ OV.Importer3ds = class extends OV.ImporterBase
ProcessBinary (fileContent)
{
let obj = this;
let reader = new OV.BinaryReader (fileContent, true);
let endByte = reader.GetByteLength ();
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.MAIN3DS) {
obj.ReadMainChunk (reader, chunkLength);
this.ReadMainChunk (reader, chunkLength);
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
}
ReadMainChunk (reader, length)
{
let obj = this;
let endByte = this.GetChunkEnd (reader, length);
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.EDIT3DS) {
obj.ReadEditorChunk (reader, chunkLength);
this.ReadEditorChunk (reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.KF3DS) {
obj.ReadKeyFrameChunk (reader, chunkLength);
this.ReadKeyFrameChunk (reader, chunkLength);
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
}
ReadEditorChunk (reader, length)
{
let obj = this;
let endByte = this.GetChunkEnd (reader, length);
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.EDIT_MATERIAL) {
obj.ReadMaterialChunk (reader, chunkLength);
this.ReadMaterialChunk (reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.EDIT_OBJECT) {
obj.ReadObjectChunk (reader, chunkLength);
this.ReadObjectChunk (reader, chunkLength);
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
}
ReadMaterialChunk (reader, length)
{
let obj = this;
let material = new OV.Material ();
let endByte = this.GetChunkEnd (reader, length);
let shininess = null;
let shininessStrength = null;
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.MAT_NAME) {
material.name = obj.ReadName (reader);
material.name = this.ReadName (reader);
} else if (chunkId === OV.CHUNK3DS.MAT_AMBIENT) {
material.ambient = obj.ReadColorChunk (reader, chunkLength);
material.ambient = this.ReadColorChunk (reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.MAT_DIFFUSE) {
material.diffuse = obj.ReadColorChunk (reader, chunkLength);
material.diffuse = this.ReadColorChunk (reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.MAT_SPECULAR) {
material.specular = obj.ReadColorChunk (reader, chunkLength);
material.specular = this.ReadColorChunk (reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.MAT_SHININESS) {
shininess = obj.ReadPercentageChunk (reader, chunkLength);
shininess = this.ReadPercentageChunk (reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.MAT_SHININESS_STRENGTH) {
shininessStrength = obj.ReadPercentageChunk (reader, chunkLength);
shininessStrength = this.ReadPercentageChunk (reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.MAT_TRANSPARENCY) {
material.opacity = 1.0 - obj.ReadPercentageChunk (reader, chunkLength);
material.opacity = 1.0 - this.ReadPercentageChunk (reader, chunkLength);
OV.UpdateMaterialTransparency (material);
} else if (chunkId === OV.CHUNK3DS.MAT_TEXMAP) {
material.diffuseMap = obj.ReadTextureMapChunk (reader, chunkLength);
material.diffuseMap = this.ReadTextureMapChunk (reader, chunkLength);
OV.UpdateMaterialTransparency (material);
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
@ -176,13 +172,12 @@ OV.Importer3ds = class extends OV.ImporterBase
ReadTextureMapChunk (reader, length)
{
let obj = this;
let texture = new OV.TextureMap ();
let endByte = this.GetChunkEnd (reader, length);
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.MAT_TEXMAP_NAME) {
let textureName = obj.ReadName (reader);
let textureBuffer = obj.callbacks.getTextureBuffer (textureName);
let textureName = this.ReadName (reader);
let textureBuffer = this.callbacks.getTextureBuffer (textureName);
texture.name = textureName;
if (textureBuffer !== null) {
texture.url = textureBuffer.url;
@ -199,7 +194,7 @@ OV.Importer3ds = class extends OV.ImporterBase
} else if (chunkId === OV.CHUNK3DS.MAT_TEXMAP_ROTATION) {
texture.rotation = reader.ReadFloat32 () * OV.DegRad;
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
return texture;
@ -207,11 +202,10 @@ OV.Importer3ds = class extends OV.ImporterBase
ReadColorChunk (reader, length)
{
let obj = this;
let color = new OV.Color (0, 0, 0);
let endByte = this.GetChunkEnd (reader, length);
let hasLinColor = false;
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.MAT_COLOR) {
if (!hasLinColor) {
color.r = reader.ReadUnsignedCharacter8 ();
@ -235,7 +229,7 @@ OV.Importer3ds = class extends OV.ImporterBase
color.b = parseInt (reader.ReadFloat32 () * 255.0, 10);
hasLinColor = true;
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
return color;
@ -243,16 +237,15 @@ OV.Importer3ds = class extends OV.ImporterBase
ReadPercentageChunk (reader, length)
{
let obj = this;
let percentage = 0.0;
let endByte = this.GetChunkEnd (reader, length);
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.PERCENTAGE) {
percentage = reader.ReadUnsignedInteger16 () / 100.0;
} else if (chunkId === OV.CHUNK3DS.PERCENTAGE_F) {
percentage = reader.ReadFloat32 ();
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
return percentage;
@ -260,42 +253,39 @@ OV.Importer3ds = class extends OV.ImporterBase
ReadObjectChunk (reader, length)
{
let obj = this;
let endByte = this.GetChunkEnd (reader, length);
let objectName = this.ReadName (reader);
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.OBJ_TRIMESH) {
obj.ReadMeshChunk (reader, chunkLength, objectName);
this.ReadMeshChunk (reader, chunkLength, objectName);
} else if (chunkId === OV.CHUNK3DS.OBJ_LIGHT) {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.OBJ_CAMERA) {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
}
ReadMeshChunk (reader, length, objectName)
{
let obj = this;
let mesh = new OV.Mesh ();
mesh.SetName (objectName);
let endByte = this.GetChunkEnd (reader, length);
let transformation = null;
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.TRI_VERTEX) {
obj.ReadVerticesChunk (mesh, reader);
this.ReadVerticesChunk (mesh, reader);
} else if (chunkId === OV.CHUNK3DS.TRI_TEXVERTEX) {
obj.ReadTextureVerticesChunk (mesh, reader);
this.ReadTextureVerticesChunk (mesh, reader);
} else if (chunkId === OV.CHUNK3DS.TRI_FACE) {
obj.ReadFacesChunk (mesh, reader, chunkLength);
this.ReadFacesChunk (mesh, reader, chunkLength);
} else if (chunkId === OV.CHUNK3DS.TRI_TRANSFORMATION) {
transformation = obj.ReadTransformationChunk (reader);
transformation = this.ReadTransformationChunk (reader);
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
@ -348,14 +338,13 @@ OV.Importer3ds = class extends OV.ImporterBase
mesh.AddTriangle (new OV.Triangle (v0, v1, v2));
}
let obj = this;
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.TRI_MATERIAL) {
obj.ReadFaceMaterialsChunk (mesh, reader);
this.ReadFaceMaterialsChunk (mesh, reader);
} else if (chunkId === OV.CHUNK3DS.TRI_SMOOTH) {
obj.ReadFaceSmoothingGroupsChunk (mesh, faceCount, reader);
this.ReadFaceSmoothingGroupsChunk (mesh, faceCount, reader);
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
}
@ -408,12 +397,11 @@ OV.Importer3ds = class extends OV.ImporterBase
};
let endByte = this.GetChunkEnd (reader, length);
let obj = this;
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.OBJECT_NODE) {
obj.ReadObjectNodeChunk (nodeHierarchy, reader, chunkLength);
this.ReadObjectNodeChunk (nodeHierarchy, reader, chunkLength);
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});
@ -606,27 +594,26 @@ OV.Importer3ds = class extends OV.ImporterBase
matrix : null
};
let obj = this;
let endByte = this.GetChunkEnd (reader, length);
this.ReadChunks (reader, endByte, function (chunkId, chunkLength) {
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.OBJECT_HIERARCHY) {
objectNode.name = obj.ReadName (reader);
objectNode.name = this.ReadName (reader);
objectNode.flags = reader.ReadUnsignedInteger32 ();
objectNode.userId = reader.ReadUnsignedInteger16 ();
} else if (chunkId === OV.CHUNK3DS.OBJECT_INSTANCE_NAME) {
objectNode.instanceName = obj.ReadName (reader);
objectNode.instanceName = this.ReadName (reader);
} else if (chunkId === OV.CHUNK3DS.OBJECT_PIVOT) {
objectNode.pivot = obj.ReadVector (reader);
objectNode.pivot = this.ReadVector (reader);
} else if (chunkId === OV.CHUNK3DS.OBJECT_POSITION) {
objectNode.positions = ReadTrackVector (obj, reader, OV.CHUNK3DS.OBJECT_POSITION);
objectNode.positions = ReadTrackVector (this, reader, OV.CHUNK3DS.OBJECT_POSITION);
} else if (chunkId === OV.CHUNK3DS.OBJECT_ROTATION) {
objectNode.rotations = ReadTrackVector (obj, reader, OV.CHUNK3DS.OBJECT_ROTATION);
objectNode.rotations = ReadTrackVector (this, reader, OV.CHUNK3DS.OBJECT_ROTATION);
} else if (chunkId === OV.CHUNK3DS.OBJECT_SCALE) {
objectNode.scales = ReadTrackVector (obj, reader, OV.CHUNK3DS.OBJECT_SCALE);
objectNode.scales = ReadTrackVector (this, reader, OV.CHUNK3DS.OBJECT_SCALE);
} else if (chunkId === OV.CHUNK3DS.OBJECT_ID) {
objectNode.nodeId = reader.ReadUnsignedInteger16 ();
} else {
obj.SkipChunk (reader, chunkLength);
this.SkipChunk (reader, chunkLength);
}
});

View File

@ -15,10 +15,8 @@ OV.ImporterBase = class
this.error = false;
this.message = null;
this.ResetContent ();
let obj = this;
this.ImportContent (content, function () {
obj.CreateResult (callbacks);
this.ImportContent (content, () => {
this.CreateResult (callbacks);
});
}

View File

@ -613,9 +613,8 @@ OV.ImporterGltf = class extends OV.ImporterBase
}
}
let obj = this;
this.gltfExtensions.ProcessMaterial (gltfMaterial, material, function (textureRef) {
return obj.ImportTexture (gltf, textureRef);
this.gltfExtensions.ProcessMaterial (gltfMaterial, material, (textureRef) => {
return this.ImportTexture (gltf, textureRef);
});
this.model.AddMaterial (material);
}
@ -810,7 +809,7 @@ OV.ImporterGltf = class extends OV.ImporterBase
if (reader === null) {
return;
}
reader.EnumerateData (function (data) {
reader.EnumerateData ((data) => {
mesh.AddVertex (data);
});
} else {
@ -823,7 +822,7 @@ OV.ImporterGltf = class extends OV.ImporterBase
if (reader === null) {
return;
}
reader.EnumerateData (function (data) {
reader.EnumerateData ((data) => {
mesh.AddNormal (data);
});
}
@ -834,7 +833,7 @@ OV.ImporterGltf = class extends OV.ImporterBase
if (reader === null) {
return;
}
reader.EnumerateData (function (data) {
reader.EnumerateData ((data) => {
data.y = -data.y;
mesh.AddTextureUV (data);
});
@ -847,7 +846,7 @@ OV.ImporterGltf = class extends OV.ImporterBase
if (reader === null) {
return;
}
reader.EnumerateData (function (data) {
reader.EnumerateData ((data) => {
vertexIndices.push (data);
});
} else {

View File

@ -55,10 +55,9 @@ OV.ImporterObj = class extends OV.ImporterBase
ImportContent (fileContent, onFinish)
{
let obj = this;
OV.ReadLines (fileContent, function (line) {
if (!obj.IsError ()) {
obj.ProcessLine (line);
OV.ReadLines (fileContent, (line) => {
if (!this.IsError ()) {
this.ProcessLine (line);
}
});
onFinish ();
@ -183,7 +182,6 @@ OV.ImporterObj = class extends OV.ImporterBase
return texture;
}
let obj = this;
if (keyword === 'newmtl') {
if (parameters.length === 0) {
return true;
@ -214,9 +212,9 @@ OV.ImporterObj = class extends OV.ImporterBase
let fileName = OV.NameFromLine (line, keyword.length, '#');
let fileBuffer = this.callbacks.getFileBuffer (fileName);
if (fileBuffer !== null) {
OV.ReadLines (fileBuffer, function (line) {
if (!obj.IsError ()) {
obj.ProcessLine (line);
OV.ReadLines (fileBuffer, (line) => {
if (!this.IsError ()) {
this.ProcessLine (line);
}
});
}
@ -313,21 +311,21 @@ OV.ImporterObj = class extends OV.ImporterBase
function GetLocalVertexIndex (obj, mesh, globalIndex)
{
return GetLocalIndex (obj.globalVertices, obj.currentMeshData.globalToCurrentVertices, globalIndex, function (val) {
return GetLocalIndex (obj.globalVertices, obj.currentMeshData.globalToCurrentVertices, globalIndex, (val) => {
return mesh.AddVertex (new OV.Coord3D (val.x, val.y, val.z));
});
}
function GetLocalNormalIndex (obj, mesh, globalIndex)
{
return GetLocalIndex (obj.globalNormals, obj.currentMeshData.globalToCurrentNormals, globalIndex, function (val) {
return GetLocalIndex (obj.globalNormals, obj.currentMeshData.globalToCurrentNormals, globalIndex, (val) => {
return mesh.AddNormal (new OV.Coord3D (val.x, val.y, val.z));
});
}
function GetLocalUVIndex (obj, mesh, globalIndex)
{
return GetLocalIndex (obj.globalUvs, obj.currentMeshData.globalToCurrentUvs, globalIndex, function (val) {
return GetLocalIndex (obj.globalUvs, obj.currentMeshData.globalToCurrentUvs, globalIndex, (val) => {
return mesh.AddTextureUV (new OV.Coord2D (val.x, val.y));
});
}

View File

@ -42,10 +42,9 @@ OV.ImporterOff = class extends OV.ImporterBase
ImportContent (fileContent, onFinish)
{
let obj = this;
OV.ReadLines (fileContent, function (line) {
if (!obj.IsError ()) {
obj.ProcessLine (line);
OV.ReadLines (fileContent, (line) => {
if (!this.IsError ()) {
this.ProcessLine (line);
}
});
onFinish ();

View File

@ -164,7 +164,7 @@ OV.ImporterPly = class extends OV.ImporterBase
ReadHeader (headerContent)
{
let header = new OV.PlyHeader ();
OV.ReadLines (headerContent, function (line) {
OV.ReadLines (headerContent, (line) => {
let parameters = OV.ParametersFromLine (line, null);
if (parameters.length === 0 || parameters[0] === 'comment') {
return;
@ -190,13 +190,12 @@ OV.ImporterPly = class extends OV.ImporterBase
ReadAsciiContent (header, fileContent)
{
let obj = this;
let vertex = header.GetElement ('vertex');
let face = header.GetElement ('face');
let foundVertex = 0;
let foundFace = 0;
OV.ReadLines (fileContent, function (line) {
if (obj.IsError ()) {
OV.ReadLines (fileContent, (line) => {
if (this.IsError ()) {
return;
}
@ -207,7 +206,7 @@ OV.ImporterPly = class extends OV.ImporterBase
if (foundVertex < vertex.count) {
if (parameters.length >= 3) {
obj.mesh.AddVertex (new OV.Coord3D (
this.mesh.AddVertex (new OV.Coord3D (
parseFloat (parameters[0]),
parseFloat (parameters[1]),
parseFloat (parameters[2])
@ -228,7 +227,7 @@ OV.ImporterPly = class extends OV.ImporterBase
let v1 = parseInt (parameters[i + 2]);
let v2 = parseInt (parameters[i + 3]);
let triangle = new OV.Triangle (v0, v1, v2);
obj.mesh.AddTriangle (triangle);
this.mesh.AddTriangle (triangle);
}
foundFace += 1;
}

View File

@ -40,11 +40,10 @@ OV.ImporterStl = class extends OV.ImporterBase
if (this.IsBinaryStlFile (fileContent)) {
this.ProcessBinary (fileContent);
} else {
let obj = this;
let textContent = OV.ArrayBufferToUtf8String (fileContent);
OV.ReadLines (textContent, function (line) {
if (!obj.IsError ()) {
obj.ProcessLine (line);
OV.ReadLines (textContent, (line) => {
if (!this.IsError ()) {
this.ProcessLine (line);
}
});
}

View File

@ -142,7 +142,7 @@ OV.ConvertMeshToMeshBuffer = function (mesh)
for (let i = 0; i < triangleCount; i++) {
triangleIndices.push (i);
}
triangleIndices.sort (function (a, b) {
triangleIndices.sort ((a, b) => {
let aTriangle = mesh.GetTriangle (a);
let bTriangle = mesh.GetTriangle (b);
return aTriangle.mat - bTriangle.mat;

View File

@ -170,7 +170,7 @@ OV.EnumerateModelVerticesAndTriangles = function (model, callbacks)
OV.EnumerateTrianglesWithNormals = function (element, onTriangle)
{
element.EnumerateTriangles (function (v0, v1, v2) {
element.EnumerateTriangles ((v0, v1, v2) => {
let normal = OV.CalculateTriangleNormal (v0, v1, v2);
onTriangle (v0, v1, v2, normal);
});
@ -179,7 +179,7 @@ OV.EnumerateTrianglesWithNormals = function (element, onTriangle)
OV.GetBoundingBox = function (element)
{
let calculator = new OV.BoundingBoxCalculator3D ();
element.EnumerateVertices (function (vertex) {
element.EnumerateVertices ((vertex) => {
calculator.AddPoint (vertex);
});
return calculator.GetBox ();
@ -201,7 +201,7 @@ OV.GetTopology = function (element)
let octree = new OV.Octree (boundingBox);
let topology = new OV.Topology ();
element.EnumerateTriangles (function (v0, v1, v2) {
element.EnumerateTriangles ((v0, v1, v2) => {
let v0Index = GetVertexIndex (v0, octree, topology);
let v1Index = GetVertexIndex (v1, octree, topology);
let v2Index = GetVertexIndex (v2, octree, topology);

View File

@ -22,7 +22,7 @@ OV.CalculateVolume = function (element)
return null;
}
let volume = 0.0;
element.EnumerateTriangles (function (v0, v1, v2) {
element.EnumerateTriangles ((v0, v1, v2) => {
volume += OV.GetTetrahedronSignedVolume (v0, v1, v2);
});
return volume;
@ -31,7 +31,7 @@ OV.CalculateVolume = function (element)
OV.CalculateSurfaceArea = function (element)
{
let surface = 0.0;
element.EnumerateTriangles (function (v0, v1, v2) {
element.EnumerateTriangles ((v0, v1, v2) => {
surface += OV.GetTriangleArea (v0, v1, v2);
});
return surface;

View File

@ -31,7 +31,7 @@ OV.Init3DViewerElements = function (onReady)
element.removeChild (progressDiv);
canvas.style.display = 'inherit';
viewer.AddMeshes (threeMeshes);
let boundingSphere = viewer.GetBoundingSphere (function (meshUserData) {
let boundingSphere = viewer.GetBoundingSphere ((meshUserData) => {
return true;
});
viewer.AdjustClippingPlanes (boundingSphere);
@ -90,7 +90,7 @@ OV.Init3DViewerElements = function (onReady)
}
let viewerElements = [];
window.addEventListener ('load', function () {
window.addEventListener ('load', () => {
let elements = document.getElementsByClassName ('online_3d_viewer');
for (let i = 0; i < elements.length; i++) {
let element = elements[i];
@ -102,7 +102,7 @@ OV.Init3DViewerElements = function (onReady)
}
});
window.addEventListener ('resize', function () {
window.addEventListener ('resize', () => {
for (let i = 0; i < viewerElements.length; i++) {
let viewerElement = viewerElements[i];
let width = viewerElement.element.clientWidth;

View File

@ -301,7 +301,7 @@ OV.Navigation = class
obj.Update ();
if (index < count - 1) {
requestAnimationFrame (function () {
requestAnimationFrame (() => {
Step (obj, steps, count, index + 1);
});
}
@ -324,14 +324,13 @@ OV.Navigation = class
}
let tweenFunc = OV.ParabolicTweenFunction;
let obj = this;
let steps = {
eye : OV.TweenCoord3D (this.camera.eye, newCamera.eye, stepCount, tweenFunc),
center : OV.TweenCoord3D (this.camera.center, newCamera.center, stepCount, tweenFunc),
up : OV.TweenCoord3D (this.camera.up, newCamera.up, stepCount, tweenFunc)
};
requestAnimationFrame (function () {
Step (obj, steps, stepCount, 0);
requestAnimationFrame (() => {
Step (this, steps, stepCount, 0);
});
this.Update ();
}

View File

@ -320,7 +320,7 @@ OV.Viewer = class
SetMeshesVisibility (isVisible)
{
this.geometry.EnumerateModelMeshes (function (mesh) {
this.geometry.EnumerateModelMeshes ((mesh) => {
let visible = isVisible (mesh.userData);
if (mesh.visible !== visible) {
mesh.visible = visible;
@ -340,7 +340,7 @@ OV.Viewer = class
return highlightMaterials;
}
this.geometry.EnumerateModelMeshes (function (mesh) {
this.geometry.EnumerateModelMeshes ((mesh) => {
let highlighted = isHighlighted (mesh.userData);
if (highlighted) {
if (mesh.userData.threeMaterials === null) {
@ -376,7 +376,7 @@ OV.Viewer = class
{
let hasMesh = false;
let boundingBox = new THREE.Box3 ();
this.geometry.EnumerateModelMeshes (function (mesh) {
this.geometry.EnumerateModelMeshes ((mesh) => {
if (needToProcess (mesh.userData)) {
boundingBox.union (new THREE.Box3 ().setFromObject (mesh));
hasMesh = true;
@ -403,7 +403,7 @@ OV.Viewer = class
EnumerateMeshesUserData (enumerator)
{
this.geometry.EnumerateModelMeshes (function (mesh) {
this.geometry.EnumerateModelMeshes ((mesh) => {
enumerator (mesh.userData);
});
}
@ -416,10 +416,9 @@ OV.Viewer = class
let canvasElem = this.renderer.domElement;
let camera = OV.GetDefaultCamera (OV.Direction.Z);
let obj = this;
this.navigation = new OV.Navigation (canvasElem, camera);
this.navigation.SetUpdateHandler (function () {
obj.Render ();
this.navigation.SetUpdateHandler (() => {
this.Render ();
});
this.upVector = new OV.UpVector ();

View File

@ -21,14 +21,14 @@ OV.DetailsSidebarPanel = class extends OV.SidebarPanel
this.AddProperty (table, new OV.Property (OV.PropertyType.Number, 'Size X', size.x));
this.AddProperty (table, new OV.Property (OV.PropertyType.Number, 'Size Y', size.y));
this.AddProperty (table, new OV.Property (OV.PropertyType.Number, 'Size Z', size.z));
this.AddCalculatedProperty (table, 'Volume', function () {
this.AddCalculatedProperty (table, 'Volume', () => {
const volume = OV.CalculateVolume (element);
if (volume === null) {
return null;
}
return new OV.Property (OV.PropertyType.Number, null, volume);
});
this.AddCalculatedProperty (table, 'Surface Area', function () {
this.AddCalculatedProperty (table, 'Surface Area', () => {
const volume = OV.CalculateSurfaceArea (element);
if (volume === null) {
return null;
@ -102,17 +102,16 @@ OV.DetailsSidebarPanel = class extends OV.SidebarPanel
let valueColumn = $('<div>').addClass ('ov_property_table_cell ov_property_table_value').appendTo (row);
nameColum.html (name + ':').attr ('title', name);
let obj = this;
let calculateButton = $('<div>').addClass ('ov_property_table_button').html ('Calculate...').appendTo (valueColumn);
calculateButton.click (function () {
calculateButton.click (() => {
valueColumn.empty ();
valueColumn.html ('Please wait...');
OV.RunTaskAsync (function () {
OV.RunTaskAsync (() => {
let propertyValue = calculateValue ();
if (propertyValue === null) {
valueColumn.html ('-');
} else {
obj.DisplayPropertyValue (propertyValue, valueColumn);
this.DisplayPropertyValue (propertyValue, valueColumn);
}
});
});

View File

@ -35,10 +35,9 @@ OV.Embed = class
this.parameters.websiteLinkDiv.attr ('href', websiteUrl);
}
let obj = this;
$(window).on ('resize', function () {
obj.Resize ();
});
$(window).on ('resize', () => {
this.Resize ();
});
}
Resize ()
@ -51,7 +50,7 @@ OV.Embed = class
OnModelFinished (importResult, threeMeshes)
{
this.viewer.AddMeshes (threeMeshes);
let boundingSphere = this.viewer.GetBoundingSphere (function (meshUserData) {
let boundingSphere = this.viewer.GetBoundingSphere ((meshUserData) => {
return true;
});
this.viewer.AdjustClippingPlanes (boundingSphere);
@ -66,19 +65,18 @@ OV.Embed = class
InitModelLoader ()
{
let obj = this;
OV.InitModelLoader (this.modelLoader, {
onStart : function ()
onStart : () =>
{
},
onFinish : function (importResult, threeMeshes)
onFinish : (importResult, threeMeshes) =>
{
obj.OnModelFinished (importResult, threeMeshes);
this.OnModelFinished (importResult, threeMeshes);
},
onRender : function ()
onRender : () =>
{
obj.viewer.Render ();
this.viewer.Render ();
}
});
}

View File

@ -77,7 +77,6 @@ OV.ExportDialog = class
return;
}
let obj = this;
let mainDialog = new OV.ButtonDialog ();
let contentDiv = mainDialog.Init ('Export', [
{
@ -89,13 +88,13 @@ OV.ExportDialog = class
},
{
name : 'Export',
onClick () {
let selectedFormat = obj.formatParameters.selectedFormat;
onClick : () => {
let selectedFormat = this.formatParameters.selectedFormat;
if (selectedFormat === null) {
return;
}
mainDialog.Hide ();
obj.ExportFormat (model, viewer);
this.ExportFormat (model, viewer);
}
}
]);
@ -111,8 +110,8 @@ OV.ExportDialog = class
let exportFormat = this.exportFormats[i];
let exportFormatButton = $('<div>').addClass ('ov_dialog_select_option').html (exportFormat.name).width (buttonWidth).appendTo (exportFormatSelect);
this.formatParameters.exportFormatButtonDivs.push (exportFormatButton);
exportFormatButton.click (function () {
obj.OnExportFormatSelect (i);
exportFormatButton.click (() => {
this.OnExportFormatSelect (i);
});
}
this.OnExportFormatSelect (0);
@ -133,7 +132,6 @@ OV.ExportDialog = class
}
}
let obj = this;
let exportFormat = this.exportFormats[exportFormatIndex];
for (let i = 0; i < exportFormat.formats.length; i++) {
let format = exportFormat.formats[i];
@ -144,8 +142,8 @@ OV.ExportDialog = class
formatInput.prop ('checked', true);
this.formatParameters.selectedFormat = format;
}
formatInput.change (function () {
obj.formatParameters.selectedFormat = format;
formatInput.change (() => {
this.formatParameters.selectedFormat = format;
});
}
}
@ -158,17 +156,16 @@ OV.ExportDialog = class
}
if (selectedFormat.type === OV.ExportType.Model) {
let obj = this;
let progressDialog = new OV.ProgressDialog ();
progressDialog.Show ('Exporting Model');
OV.RunTaskAsync (function () {
OV.RunTaskAsync (() => {
let exporter = new OV.Exporter ();
exporter.AddExporter (new OV.Exporter3dm ());
exporter.Export (model, selectedFormat.format, selectedFormat.extension, {
onError : function () {
onError : () => {
progressDialog.Hide ();
},
onSuccess : function (files) {
onSuccess : (files) => {
if (files.length === 0) {
progressDialog.Hide ();
} else if (files.length === 1) {
@ -177,7 +174,7 @@ OV.ExportDialog = class
OV.DownloadArrayBufferAsFile (file.GetContent (), file.GetName ());
} else if (files.length > 1) {
progressDialog.Hide ();
obj.ShowExportedFiles (files);
this.ShowExportedFiles (files);
}
}
});

View File

@ -1,4 +1,4 @@
OV.FeatureSet =
{
SettingsPanel : true
SettingsPanel : false
};

View File

@ -42,9 +42,8 @@ OV.Modal = class
this.resizeHandler = this.Resize.bind (this);
windowObj.bind ('resize', this.resizeHandler);
if (this.closeable) {
let obj = this;
this.overlayDiv.click (function (ev) {
obj.Close ();
this.overlayDiv.click ((ev) => {
this.Close ();
});
}
@ -146,7 +145,7 @@ OV.ButtonDialog = class
if (button.subClass) {
buttonDiv.addClass (button.subClass);
}
buttonDiv.click (function () {
buttonDiv.click (() => {
button.onClick ();
});
}
@ -197,7 +196,7 @@ OV.PopupDialog = class
{
let contentDiv = this.modal.GetContentDiv ();
contentDiv.addClass ('ov_popup');
this.modal.SetCustomResizeHandler (function (modalDiv) {
this.modal.SetCustomResizeHandler ((modalDiv) => {
let offset = parentItem.offset ();
let left = offset.left + parentItem.outerWidth (false);
let bottom = offset.top + parentItem.outerHeight (false);
@ -252,10 +251,10 @@ OV.ListPopup = class extends OV.PopupDialog
listItemDiv.click (callbacks.onClick);
if (OV.IsHoverEnabled () && callbacks.onHoverStart && callbacks.onHoverStop) {
listItemDiv.hover (
function () {
() => {
callbacks.onHoverStart ();
},
function () {
() => {
callbacks.onHoverStop ();
}
);

View File

@ -13,10 +13,9 @@ OV.MaterialData = class
CreateMenuItem (name, callbacks)
{
let obj = this;
this.menuItem = new OV.TreeViewButtonItem (name);
this.menuItem.OnNameClick (function () {
callbacks.onSelected (obj.originalIndex);
this.menuItem.OnNameClick (() => {
callbacks.onSelected (this.originalIndex);
});
return this.menuItem;
}
@ -54,27 +53,26 @@ OV.MeshData = class
CreateMenuItem (name, callbacks)
{
let obj = this;
this.menuItem = new OV.TreeViewButtonItem (name);
let fitToWindowButton = new OV.TreeViewButton ('assets/images/tree/fit_tree.svg');
fitToWindowButton.OnClick (function () {
callbacks.onFitToWindow (obj.originalIndex);
fitToWindowButton.OnClick (() => {
callbacks.onFitToWindow (this.originalIndex);
});
this.menuItem.AddButton (fitToWindowButton);
this.showHideButton = new OV.TreeViewButton ('assets/images/tree/visible.svg');
this.showHideButton.OnClick (function (ev) {
this.showHideButton.OnClick ((ev) => {
if (ev.ctrlKey || ev.metaKey) {
callbacks.onIsolate (obj.originalIndex);
callbacks.onIsolate (this.originalIndex);
} else {
callbacks.onShowHide (obj.originalIndex);
callbacks.onShowHide (this.originalIndex);
}
});
this.menuItem.AddButton (this.showHideButton);
this.menuItem.OnNameClick (function () {
callbacks.onSelected (obj.originalIndex);
this.menuItem.OnNameClick (() => {
callbacks.onSelected (this.originalIndex);
});
return this.menuItem;

View File

@ -36,13 +36,12 @@ OV.NavigatorInfoPanel = class
});
}
let obj = this;
let meshesText = 'Meshes (' + meshItems.length + ')';
this.CreateButton (this.parentDiv, meshesText, function (button) {
this.CreateButton (this.parentDiv, meshesText, (button) => {
if (meshItems.length === 0) {
return;
}
obj.popup = OV.ShowListPopup (button, meshItems, {
this.popup = OV.ShowListPopup (button, meshItems, {
onHoverStart : function (index) {
const meshItem = usedByMeshes[index];
callbacks.onMeshHover (meshItem.index);
@ -74,11 +73,10 @@ OV.NavigatorInfoPanel = class
});
}
let obj = this;
let materialsText = 'Materials (' + materialItems.length + ')';
this.CreateButton (this.parentDiv, materialsText, function (button) {
obj.popup = OV.ShowListPopup (button, materialItems, {
onClick : function (index) {
this.CreateButton (this.parentDiv, materialsText, (button) => {
this.popup = OV.ShowListPopup (button, materialItems, {
onClick : (index) => {
let usedMaterial = usedMaterials[index];
callbacks.onMaterialSelect (usedMaterial.index);
}
@ -91,7 +89,7 @@ OV.NavigatorInfoPanel = class
let button = $('<div>').addClass ('ov_navigator_info_button').appendTo (parentDiv);
$('<div>').addClass ('ov_navigator_info_button_text').html (buttonText).appendTo (button);
$('<img>').addClass ('ov_navigator_info_button_icon').attr ('src', 'assets/images/tree/arrow_right.svg').appendTo (button);
button.click (function () {
button.click (() => {
onClick (button);
});
}
@ -137,8 +135,6 @@ OV.Navigator = class
FillTree (importResult)
{
let obj = this;
this.titleDiv.html (importResult.mainFile).attr ('title', importResult.mainFile);
let model = importResult.model;
@ -160,8 +156,8 @@ OV.Navigator = class
let file = missingFiles[i];
let item = new OV.TreeViewButtonItem (file);
let browseButton = new OV.TreeViewButton ('assets/images/tree/open.svg');
browseButton.OnClick (function () {
obj.callbacks.openFileBrowserDialog ();
browseButton.OnClick (() => {
this.callbacks.openFileBrowserDialog ();
});
item.AddButton (browseButton);
missingFilesItem.AddChild (item);
@ -175,8 +171,8 @@ OV.Navigator = class
let materialName = OV.GetMaterialName (material.name);
let materialData = new OV.MaterialData (i);
let materialItem = materialData.CreateMenuItem (materialName, {
onSelected : function (materialIndex) {
obj.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
onSelected : (materialIndex) => {
this.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
}
});
this.modelData.AddMaterialData (materialData);
@ -191,17 +187,17 @@ OV.Navigator = class
let meshData = new OV.MeshData (i);
let meshName = OV.GetMeshName (mesh.GetName ());
let meshItem = meshData.CreateMenuItem (meshName, {
onShowHide : function (meshIndex) {
obj.ToggleMeshVisibility (meshIndex);
onShowHide : (meshIndex) => {
this.ToggleMeshVisibility (meshIndex);
},
onIsolate : function (meshIndex) {
obj.IsolateMesh (meshIndex);
onIsolate : (meshIndex) => {
this.IsolateMesh (meshIndex);
},
onFitToWindow : function (meshIndex) {
obj.FitMeshToWindow (meshIndex);
onFitToWindow : (meshIndex) => {
this.FitMeshToWindow (meshIndex);
},
onSelected : function (meshIndex) {
obj.SetSelection (new OV.Selection (OV.SelectionType.Mesh, meshIndex));
onSelected : (meshIndex) => {
this.SetSelection (new OV.Selection (OV.SelectionType.Mesh, meshIndex));
}
});
this.modelData.AddMeshData (meshData);
@ -307,12 +303,11 @@ OV.Navigator = class
UpdateInfoPanel ()
{
let obj = this;
if (this.selection === null) {
let usedMaterials = this.callbacks.getMaterialsForModel ();
this.infoPanel.FillWithModelInfo (usedMaterials, {
onMaterialSelect : function (materialIndex) {
obj.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
onMaterialSelect : (materialIndex) => {
this.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
}
});
this.callbacks.onModelSelected ();
@ -320,19 +315,19 @@ OV.Navigator = class
if (this.selection.type === OV.SelectionType.Material) {
let usedByMeshes = this.callbacks.getMeshesForMaterial (this.selection.index);
this.infoPanel.FillWithMaterialInfo (usedByMeshes, {
onMeshHover : function (meshIndex) {
obj.SetTempSelectedMeshIndex (meshIndex);
onMeshHover : (meshIndex) => {
this.SetTempSelectedMeshIndex (meshIndex);
},
onMeshSelect : function (meshIndex) {
obj.SetSelection (new OV.Selection (OV.SelectionType.Mesh, meshIndex));
onMeshSelect : (meshIndex) => {
this.SetSelection (new OV.Selection (OV.SelectionType.Mesh, meshIndex));
}
});
this.callbacks.onMaterialSelected (this.selection.index);
} else if (this.selection.type === OV.SelectionType.Mesh) {
let usedMaterials = this.callbacks.getMaterialsForMesh (this.selection.index);
this.infoPanel.FillWithModelInfo (usedMaterials, {
onMaterialSelect : function (materialIndex) {
obj.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
onMaterialSelect : (materialIndex) => {
this.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
}
});
this.callbacks.onMeshSelected (this.selection.index);

View File

@ -38,7 +38,7 @@ OV.ShowOpenUrlDialog = function (onOk)
name : 'OK',
onClick () {
let urls = [];
OV.ReadLines (urlsTextArea.val (), function (line) {
OV.ReadLines (urlsTextArea.val (), (line) => {
urls.push (line);
});
dialog.Hide ();

View File

@ -24,7 +24,7 @@ OV.SettingsSidebarPanel = class extends OV.SidebarPanel
$('<div>').addClass ('ov_sidebar_column').html (description).appendTo (contentDiv);
let colorInput = $('<input>').attr ('type', 'color').addClass ('ov_sidebar_color').appendTo (colorColumn);
colorInput.val ('#' + OV.ColorToHexString (params.defaultValue));
colorInput.change (function () {
colorInput.change (() => {
let colorStr = colorInput.val ().substr (1);
params.onChange (OV.HexStringToColor (colorStr));
});

View File

@ -5,7 +5,7 @@ OV.ShowSharingDialog = function (importer, viewerSettings, importSettings, camer
let line = $('<div>').addClass ('ov_dialog_table_row').appendTo (parentDiv);
let check = $('<input>').attr ('type', 'checkbox').attr ('checked', 'true').addClass ('ov_dialog_checkradio').attr ('id', id).appendTo (line);
$('<label>').attr ('for', id).html (text).appendTo (line);
check.change (function () {
check.change (() => {
onChange (check.prop ('checked'));
});
}
@ -44,12 +44,12 @@ OV.ShowSharingDialog = function (importer, viewerSettings, importSettings, camer
let container = $('<div>').addClass ('ov_dialog_copyable_input').appendTo (parentDiv);
let input = $('<input>').prop ('readonly', true).appendTo (container);
let button = $('<div>').addClass ('button').html (copyText).appendTo (container);
button.click (function () {
button.click (() => {
OV.CopyToClipboard (getText ());
button.fadeOut (200, function () {
button.fadeOut (200, () => {
button.html (copiedText).fadeIn (200);
setTimeout (function () {
button.fadeOut (200, function () {
setTimeout (() => {
button.fadeOut (200, () => {
button.html (copyText).fadeIn (200);
});
}, 2000);
@ -66,13 +66,13 @@ OV.ShowSharingDialog = function (importer, viewerSettings, importSettings, camer
if (OV.FeatureSet.SettingsPanel) {
optionsSection = $('<div>').addClass ('ov_dialog_section').appendTo (section);
}
let sharingLinkInput = AddCopyableTextInput (section, function () {
let sharingLinkInput = AddCopyableTextInput (section, () => {
return GetSharingLink (sharingLinkParams);
});
// TODO: camera position in sharing link
// TODO: background color in sharing link
if (OV.FeatureSet.SettingsPanel) {
AddCheckboxLine (optionsSection, 'Use overridden default color', 'share_color', function (checked) {
AddCheckboxLine (optionsSection, 'Use overridden default color', 'share_color', (checked) => {
sharingLinkParams.color = checked ? importSettings.defaultColor : null;
sharingLinkInput.val (GetSharingLink (sharingLinkParams));
});
@ -86,20 +86,20 @@ OV.ShowSharingDialog = function (importer, viewerSettings, importSettings, camer
let section = $('<div>').addClass ('ov_dialog_section').css ('margin-top', '20px').appendTo (parentDiv);
$('<div>').html ('Embedding Code').addClass ('ov_dialog_inner_title').appendTo (section);
let optionsSection = $('<div>').addClass ('ov_dialog_section').appendTo (section);
let embeddingCodeInput = AddCopyableTextInput (section, function () {
let embeddingCodeInput = AddCopyableTextInput (section, () => {
return GetEmbeddingCode (embeddingCodeParams);
});
AddCheckboxLine (optionsSection, 'Use current camera position', 'embed_camera', function (checked) {
AddCheckboxLine (optionsSection, 'Use current camera position', 'embed_camera', (checked) => {
embeddingCodeParams.camera = checked ? camera : null;
embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams));
});
if (OV.FeatureSet.SettingsPanel) {
AddCheckboxLine (optionsSection, 'Use overridden background color', 'embed_background', function (checked) {
AddCheckboxLine (optionsSection, 'Use overridden background color', 'embed_background', (checked) => {
embeddingCodeParams.background = checked ? viewerSettings.backgroundColor : null;
embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams));
});
embeddingCodeParams.background = viewerSettings.backgroundColor;
AddCheckboxLine (optionsSection, 'Use overridden default color', 'embed_color', function (checked) {
AddCheckboxLine (optionsSection, 'Use overridden default color', 'embed_color', (checked) => {
embeddingCodeParams.color = checked ? importSettings.defaultColor : null;
embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams));
});

View File

@ -15,7 +15,7 @@ OV.SidebarPanel = class
this.contentDiv = $('<div>').addClass ('ov_sidebar_content').addClass ('ov_thin_scrollbar').appendTo (this.panelDiv);
$('<div>').addClass ('ov_sidebar_title_text').html (this.GetTitle ()).appendTo (this.titleDiv);
let titleImg = $('<img>').addClass ('ov_sidebar_title_img').attr ('src', 'assets/images/sidebar/close.svg').appendTo (this.titleDiv);
titleImg.click (function () {
titleImg.click (() => {
callbacks.onClose ();
});
}

View File

@ -63,7 +63,7 @@ OV.Toolbar = class
let buttons = [];
for (let buttonIndex = 0; buttonIndex < buttonData.length; buttonIndex++) {
let data = buttonData[buttonIndex];
let button = this.AddImageButton (data.image, data.title, function () {
let button = this.AddImageButton (data.image, data.title, () => {
for (let i = 0; i < buttons.length; i++) {
let currentButton = buttons[i];
if (i === buttonIndex) {

View File

@ -79,10 +79,9 @@ OV.TreeViewSingleItem = class extends OV.TreeViewItem
{
this.selected = selected;
if (this.selected) {
let obj = this;
this.mainElement.addClass ('selected');
this.parent.ShowChildren (true, function () {
OV.ScrollToView (obj.mainElement);
this.parent.ShowChildren (true, () => {
OV.ScrollToView (this.mainElement);
});
} else {
this.mainElement.removeClass ('selected');
@ -131,10 +130,9 @@ OV.TreeViewButtonItem = class extends OV.TreeViewSingleItem
}
this.CreateNameElement ();
if (this.onNameClick !== null) {
let obj = this;
this.nameElement.css ('cursor', 'pointer');
this.nameElement.click (function (ev) {
obj.onNameClick ();
this.nameElement.click ((ev) => {
this.onNameClick ();
});
}
}
@ -207,15 +205,14 @@ OV.TreeViewGroupItem = class extends OV.TreeViewItem
CreateChildrenDiv ()
{
if (this.childrenDiv === null) {
let obj = this;
this.childrenDiv = $('<div>').addClass ('ov_tree_view_children').insertAfter (this.mainElement);
this.mainElement.addClass ('clickable');
this.ShowChildren (this.showChildren, null);
this.mainElement.click (function (ev) {
obj.showChildren = !obj.showChildren;
obj.ShowChildren (obj.showChildren, null);
if (obj.openCloseHandler !== null) {
obj.openCloseHandler ();
this.mainElement.click ((ev) => {
this.showChildren = !this.showChildren;
this.ShowChildren (this.showChildren, null);
if (this.openCloseHandler !== null) {
this.openCloseHandler ();
}
});
}

View File

@ -77,11 +77,11 @@ OV.InstallTooltip = function (item, text)
let bodyObj = $(document.body);
let tooltip = null;
item.hover (
function () {
() => {
tooltip = $('<div>').html (text).addClass ('ov_tooltip').appendTo (bodyObj);
tooltip.offset (CalculateOffset (item, tooltip));
},
function () {
() => {
tooltip.remove ();
}
);
@ -126,10 +126,10 @@ OV.CreateIconButton = function (iconName, hoverIconName, title, link)
let imgElem = $('<img>').attr ('src', iconName).appendTo (buttonLink);
if (hoverIconName !== null && OV.IsHoverEnabled ()) {
buttonLink.hover (
function () {
() => {
imgElem.attr ('src', hoverIconName);
},
function () {
() => {
imgElem.attr ('src', iconName);
}
);

View File

@ -38,9 +38,8 @@ OV.Website = class
this.hashHandler.SetEventListener (this.OnHashChange.bind (this));
this.OnHashChange ();
let obj = this;
$(window).on ('resize', function () {
obj.Resize ();
$(window).on ('resize', () => {
this.Resize ();
});
}
@ -128,10 +127,9 @@ OV.Website = class
FitModelToWindow (onLoad)
{
let obj = this;
let animation = !onLoad;
let boundingSphere = this.viewer.GetBoundingSphere (function (meshUserData) {
return obj.navigator.IsMeshVisible (meshUserData.originalMeshIndex);
let boundingSphere = this.viewer.GetBoundingSphere ((meshUserData) => {
return this.navigator.IsMeshVisible (meshUserData.originalMeshIndex);
});
if (onLoad) {
this.viewer.AdjustClippingPlanes (boundingSphere);
@ -141,7 +139,7 @@ OV.Website = class
FitMeshToWindow (meshIndex)
{
let boundingSphere = this.viewer.GetBoundingSphere (function (meshUserData) {
let boundingSphere = this.viewer.GetBoundingSphere ((meshUserData) => {
return meshUserData.originalMeshIndex === meshIndex;
});
this.viewer.FitToWindow (boundingSphere, true);
@ -149,16 +147,15 @@ OV.Website = class
UpdateMeshesVisibility ()
{
let obj = this;
this.viewer.SetMeshesVisibility (function (meshUserData) {
return obj.navigator.IsMeshVisible (meshUserData.originalMeshIndex);
this.viewer.SetMeshesVisibility ((meshUserData) => {
return this.navigator.IsMeshVisible (meshUserData.originalMeshIndex);
});
}
UpdateMeshesSelection ()
{
let selectedMeshIndex = this.navigator.GetSelectedMeshIndex ();
this.viewer.SetMeshesHighlight (this.highlightMaterial, function (meshUserData) {
this.viewer.SetMeshesHighlight (this.highlightMaterial, (meshUserData) => {
if (meshUserData.originalMeshIndex === selectedMeshIndex) {
return true;
}
@ -270,97 +267,94 @@ OV.Website = class
}
}
let obj = this;
let importer = this.modelLoader.GetImporter ();
AddButton (this.toolbar, 'open', 'Open model from your device', false, function () {
obj.OpenFileBrowserDialog ();
AddButton (this.toolbar, 'open', 'Open model from your device', false, () => {
this.OpenFileBrowserDialog ();
});
AddButton (this.toolbar, 'open_url', 'Open model from a url', false, function () {
obj.dialog = OV.ShowOpenUrlDialog (function (urls) {
AddButton (this.toolbar, 'open_url', 'Open model from a url', false, () => {
this.dialog = OV.ShowOpenUrlDialog ((urls) => {
if (urls.length > 0) {
obj.hashHandler.SetModelFilesToHash (urls);
this.hashHandler.SetModelFilesToHash (urls);
}
});
});
AddSeparator (this.toolbar);
AddButton (this.toolbar, 'fit', 'Fit model to window', false, function () {
obj.FitModelToWindow (false);
AddButton (this.toolbar, 'fit', 'Fit model to window', false, () => {
this.FitModelToWindow (false);
});
AddButton (this.toolbar, 'up_y', 'Set Y axis as up vector', false, function () {
obj.viewer.SetUpVector (OV.Direction.Y, true);
AddButton (this.toolbar, 'up_y', 'Set Y axis as up vector', false, () => {
this.viewer.SetUpVector (OV.Direction.Y, true);
});
AddButton (this.toolbar, 'up_z', 'Set Z axis as up vector', false, function () {
obj.viewer.SetUpVector (OV.Direction.Z, true);
AddButton (this.toolbar, 'up_z', 'Set Z axis as up vector', false, () => {
this.viewer.SetUpVector (OV.Direction.Z, true);
});
AddButton (this.toolbar, 'flip', 'Flip up vector', false, function () {
obj.viewer.FlipUpVector ();
AddButton (this.toolbar, 'flip', 'Flip up vector', false, () => {
this.viewer.FlipUpVector ();
});
AddSeparator (this.toolbar);
AddRadioButton (this.toolbar, ['fix_up_on', 'fix_up_off'], ['Fixed up vector', 'Free orbit'], 0, false, function (buttonIndex) {
AddRadioButton (this.toolbar, ['fix_up_on', 'fix_up_off'], ['Fixed up vector', 'Free orbit'], 0, false, (buttonIndex) => {
if (buttonIndex === 0) {
obj.viewer.SetFixUpVector (true);
this.viewer.SetFixUpVector (true);
} else if (buttonIndex === 1) {
obj.viewer.SetFixUpVector (false);
this.viewer.SetFixUpVector (false);
}
});
AddSeparator (this.toolbar, true);
AddButton (this.toolbar, 'export', 'Export model', true, function () {
AddButton (this.toolbar, 'export', 'Export model', true, () => {
let exportDialog = new OV.ExportDialog ({
onDialog : function (dialog) {
obj.dialog = dialog;
onDialog : (dialog) => {
this.dialog = dialog;
}
});
exportDialog.Show (obj.model, obj.viewer);
exportDialog.Show (this.model, this.viewer);
});
AddButton (this.toolbar, 'share', 'Share model', true, function () {
obj.dialog = OV.ShowSharingDialog (importer, obj.viewerSettings, obj.importSettings, obj.viewer.GetCamera ());
AddButton (this.toolbar, 'share', 'Share model', true, () => {
this.dialog = OV.ShowSharingDialog (importer, this.viewerSettings, this.importSettings, this.viewer.GetCamera ());
});
this.parameters.fileInput.on ('change', function (ev) {
this.parameters.fileInput.on ('change', (ev) => {
if (ev.target.files.length > 0) {
obj.LoadModelFromFileList (ev.target.files);
this.LoadModelFromFileList (ev.target.files);
}
});
}
InitDragAndDrop ()
{
window.addEventListener ('dragstart', function (ev) {
window.addEventListener ('dragstart', (ev) => {
ev.preventDefault ();
}, false);
window.addEventListener ('dragover', function (ev) {
window.addEventListener ('dragover', (ev) => {
ev.stopPropagation ();
ev.preventDefault ();
ev.dataTransfer.dropEffect = 'copy';
}, false);
let obj = this;
window.addEventListener ('drop', function (ev) {
window.addEventListener ('drop', (ev) => {
ev.stopPropagation ();
ev.preventDefault ();
if (ev.dataTransfer.files.length > 0) {
obj.LoadModelFromFileList (ev.dataTransfer.files);
this.LoadModelFromFileList (ev.dataTransfer.files);
}
}, false);
}
InitModelLoader ()
{
let obj = this;
OV.InitModelLoader (this.modelLoader, {
onStart : function ()
onStart : () =>
{
obj.ClearModel ();
this.ClearModel ();
},
onFinish : function (importResult, threeMeshes)
onFinish : (importResult, threeMeshes) =>
{
obj.OnModelFinished (importResult, threeMeshes);
this.OnModelFinished (importResult, threeMeshes);
},
onRender : function ()
onRender : () =>
{
obj.viewer.Render ();
this.viewer.Render ();
}
});
}
@ -407,8 +401,6 @@ OV.Website = class
}
}
let obj = this;
this.detailsPanel = new OV.DetailsSidebarPanel (this.parameters.sidebarDiv);
let settingsPanel = new OV.SettingsSidebarPanel (this.parameters.sidebarDiv);
@ -436,14 +428,14 @@ OV.Website = class
for (let id = 0; id < sidebarPanels.length; id++) {
let sidebarPanel = sidebarPanels[id];
sidebarPanel.panelId = this.sidebar.AddPanel (sidebarPanel.panel);
sidebarPanel.button = AddSidebarButton (this.toolbar, sidebarPanel, function () {
ToggleSidebar (obj.sidebar, obj.cookieHandler, sidebarPanels, sidebarPanel.panelId);
obj.Resize ();
sidebarPanel.button = AddSidebarButton (this.toolbar, sidebarPanel, () => {
ToggleSidebar (this.sidebar, this.cookieHandler, sidebarPanels, sidebarPanel.panelId);
this.Resize ();
});
sidebarPanel.panel.Init ({
onClose : function () {
ShowSidebar (obj.sidebar, obj.cookieHandler, sidebarPanels, null);
obj.Resize ();
onClose : () => {
ShowSidebar (this.sidebar, this.cookieHandler, sidebarPanels, null);
this.Resize ();
}
});
}
@ -451,22 +443,22 @@ OV.Website = class
settingsPanel.InitSettings ({
backgroundColor : {
defaultValue : this.viewerSettings.backgroundColor,
onChange : function (newVal) {
obj.viewerSettings.backgroundColor = newVal;
obj.viewer.SetBackgroundColor (newVal);
obj.cookieHandler.SetColorVal ('ov_background_color', newVal);
onChange : (newVal) => {
this.viewerSettings.backgroundColor = newVal;
this.viewer.SetBackgroundColor (newVal);
this.cookieHandler.SetColorVal ('ov_background_color', newVal);
}
},
defaultColor : {
defaultValue : this.importSettings.defaultColor,
onChange : function (newVal) {
obj.importSettings.defaultColor = newVal;
obj.cookieHandler.SetColorVal ('ov_default_color', newVal);
if (obj.modelLoader.defaultMaterial !== null) {
OV.ReplaceDefaultMaterialColor (obj.model, newVal);
obj.modelLoader.defaultMaterial.color = new THREE.Color (newVal.r / 255.0, newVal.g / 255.0, newVal.b / 255.0);
onChange : (newVal) => {
this.importSettings.defaultColor = newVal;
this.cookieHandler.SetColorVal ('ov_default_color', newVal);
if (this.modelLoader.defaultMaterial !== null) {
OV.ReplaceDefaultMaterialColor (this.model, newVal);
this.modelLoader.defaultMaterial.color = new THREE.Color (newVal.r / 255.0, newVal.g / 255.0, newVal.b / 255.0);
}
obj.viewer.Render ();
this.viewer.Render ();
}
}
});
@ -480,7 +472,7 @@ OV.Website = class
function GetMeshUserData (viewer, meshIndex)
{
let userData = null;
viewer.EnumerateMeshesUserData (function (meshUserData) {
viewer.EnumerateMeshesUserData ((meshUserData) => {
if (meshUserData.originalMeshIndex === meshIndex) {
userData = meshUserData;
}
@ -491,7 +483,7 @@ OV.Website = class
function GetMeshesForMaterial (viewer, model, materialIndex)
{
let usedByMeshes = [];
viewer.EnumerateMeshesUserData (function (meshUserData) {
viewer.EnumerateMeshesUserData ((meshUserData) => {
if (meshUserData.originalMaterials.indexOf (materialIndex) !== -1) {
const mesh = model.GetMesh (meshUserData.originalMeshIndex);
usedByMeshes.push ({
@ -521,7 +513,7 @@ OV.Website = class
const materialIndex = userData.originalMaterials[i];
usedMaterials.push (GetMaterialReferenceInfo (model, materialIndex));
}
usedMaterials.sort (function (a, b) {
usedMaterials.sort ((a, b) => {
return a.index - b.index;
});
return usedMaterials;
@ -536,37 +528,36 @@ OV.Website = class
return usedMaterials;
}
let obj = this;
this.navigator.Init ({
openFileBrowserDialog : function () {
obj.OpenFileBrowserDialog ();
openFileBrowserDialog : () => {
this.OpenFileBrowserDialog ();
},
updateMeshesVisibility : function () {
obj.UpdateMeshesVisibility ();
updateMeshesVisibility : () => {
this.UpdateMeshesVisibility ();
},
updateMeshesSelection : function () {
obj.UpdateMeshesSelection ();
updateMeshesSelection : () => {
this.UpdateMeshesSelection ();
},
fitMeshToWindow : function (meshIndex) {
obj.FitMeshToWindow (meshIndex);
fitMeshToWindow : (meshIndex) => {
this.FitMeshToWindow (meshIndex);
},
getMeshesForMaterial : function (materialIndex) {
return GetMeshesForMaterial (obj.viewer, obj.model, materialIndex);
getMeshesForMaterial : (materialIndex) => {
return GetMeshesForMaterial (this.viewer, this.model, materialIndex);
},
getMaterialsForMesh : function (meshIndex) {
return GetMaterialsForMesh (obj.viewer, obj.model, meshIndex);
getMaterialsForMesh : (meshIndex) => {
return GetMaterialsForMesh (this.viewer, this.model, meshIndex);
},
getMaterialsForModel : function () {
return GetMaterialsForModel (obj.model);
getMaterialsForModel : () => {
return GetMaterialsForModel (this.model);
},
onModelSelected : function () {
obj.detailsPanel.AddElementProperties (obj.model);
onModelSelected : () => {
this.detailsPanel.AddElementProperties (this.model);
},
onMeshSelected : function (meshIndex) {
obj.detailsPanel.AddElementProperties (obj.model.GetMesh (meshIndex));
onMeshSelected : (meshIndex) => {
this.detailsPanel.AddElementProperties (this.model.GetMesh (meshIndex));
},
onMaterialSelected : function (materialIndex) {
obj.detailsPanel.AddMaterialProperties (obj.model.GetMaterial (materialIndex));
onMaterialSelected : (materialIndex) => {
this.detailsPanel.AddMaterialProperties (this.model.GetMaterial (materialIndex));
}
});
}
@ -578,9 +569,8 @@ OV.Website = class
return;
}
let obj = this;
OV.ShowCookieDialog (function () {
obj.cookieHandler.SetBoolVal ('ov_cookie_consent', true);
OV.ShowCookieDialog (() => {
this.cookieHandler.SetBoolVal ('ov_cookie_consent', true);
});
}
};