Automatically remove trailing whitespaces in Visual Studio Code.

This commit is contained in:
kovacsv 2021-10-25 16:30:25 +02:00
parent 44460d0597
commit 504c38848d
28 changed files with 175 additions and 172 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"files.trimTrailingWhitespace": true
}

View File

@ -9,7 +9,7 @@ OV.ExporterOff = class extends OV.ExporterBase
{
return format === OV.FileFormat.Text && extension === 'off';
}
ExportContent (model, format, files, onFinish)
{
let offFile = new OV.ExportedFile ('model.off');
@ -30,5 +30,5 @@ OV.ExporterOff = class extends OV.ExporterBase
offFile.SetTextContent (offWriter.GetText ());
onFinish ();
}
}
};

View File

@ -9,7 +9,7 @@ OV.ExporterPly = class extends OV.ExporterBase
{
return (format === OV.FileFormat.Text || format === OV.FileFormat.Binary) && extension === 'ply';
}
ExportContent (model, format, files, onFinish)
{
if (format === OV.FileFormat.Text) {
@ -28,7 +28,7 @@ OV.ExporterPly = class extends OV.ExporterBase
let plyWriter = new OV.TextWriter ();
let vertexCount = model.VertexCount ();
let triangleCount = model.TriangleCount ();
let triangleCount = model.TriangleCount ();
let headerText = this.GetHeaderText ('ascii', vertexCount, triangleCount);
plyWriter.Write (headerText);

View File

@ -9,7 +9,7 @@ OV.ExporterStl = class extends OV.ExporterBase
{
return (format === OV.FileFormat.Text || format === OV.FileFormat.Binary) && extension === 'stl';
}
ExportContent (model, format, files, onFinish)
{
if (format === OV.FileFormat.Text) {
@ -39,10 +39,10 @@ OV.ExporterStl = class extends OV.ExporterBase
stlWriter.WriteLine ('endloop');
stlWriter.Indent (-1);
stlWriter.WriteLine ('endfacet');
});
});
stlWriter.WriteLine ('endsolid Model');
stlFile.SetTextContent (stlWriter.GetText ());
stlFile.SetTextContent (stlWriter.GetText ());
}
ExportBinary (model, files)
@ -81,5 +81,5 @@ OV.ExporterStl = class extends OV.ExporterBase
});
stlFile.SetBufferContent (stlWriter.GetBuffer ());
}
}
};

View File

@ -11,7 +11,7 @@ OV.Coord3D = class
{
return Math.sqrt (this.x * this.x + this.y * this.y + this.z * this.z);
}
MultiplyScalar (scalar)
{
this.x *= scalar;
@ -19,7 +19,7 @@ OV.Coord3D = class
this.z *= scalar;
return this;
}
Normalize ()
{
let length = this.Length ();
@ -28,7 +28,7 @@ OV.Coord3D = class
}
return this;
}
Offset (direction, distance)
{
let normal = direction.Clone ().Normalize ();
@ -37,31 +37,31 @@ OV.Coord3D = class
this.z += normal.z * distance;
return this;
}
Rotate (axis, angle, origo)
{
let normal = axis.Clone ().Normalize ();
let u = normal.x;
let v = normal.y;
let w = normal.z;
let x = this.x - origo.x;
let y = this.y - origo.y;
let z = this.z - origo.z;
let si = Math.sin (angle);
let co = Math.cos (angle);
this.x = - u * (- u * x - v * y - w * z) * (1.0 - co) + x * co + (- w * y + v * z) * si;
this.y = - v * (- u * x - v * y - w * z) * (1.0 - co) + y * co + (w * x - u * z) * si;
this.z = - w * (- u * x - v * y - w * z) * (1.0 - co) + z * co + (- v * x + u * y) * si;
this.x += origo.x;
this.y += origo.y;
this.z += origo.z;
return this;
}
Clone ()
{
return new OV.Coord3D (this.x, this.y, this.z);

View File

@ -113,7 +113,7 @@ OV.Matrix = class
let qw = rotation.w;
let sx = scale.x;
let sy = scale.y;
let sz = scale.z;
let sz = scale.z;
let x2 = qx + qx;
let y2 = qy + qy;
@ -134,7 +134,7 @@ OV.Matrix = class
(xz + wy) * sz, (yz - wx) * sz, (1.0 - (xx + yy)) * sz, 0.0,
tx, ty, tz, 1.0
];
return this;
return this;
}
DecomposeTRS ()
@ -167,7 +167,7 @@ OV.Matrix = class
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
let rotation = null;
let tr = m00 + m11 + m22;
if (tr > 0.0) {
if (tr > 0.0) {
let s = Math.sqrt (tr + 1.0) * 2.0;
rotation = new OV.Quaternion (
(m21 - m12) / s,
@ -175,7 +175,7 @@ OV.Matrix = class
(m10 - m01) / s,
0.25 * s
);
} else if ((m00 > m11) && (m00 > m22)) {
} else if ((m00 > m11) && (m00 > m22)) {
let s = Math.sqrt (1.0 + m00 - m11 - m22) * 2.0;
rotation = new OV.Quaternion (
0.25 * s,
@ -183,7 +183,7 @@ OV.Matrix = class
(m02 + m20) / s,
(m21 - m12) / s
);
} else if (m11 > m22) {
} else if (m11 > m22) {
let s = Math.sqrt (1.0 + m11 - m00 - m22) * 2.0;
rotation = new OV.Quaternion (
(m01 + m10) / s,
@ -191,7 +191,7 @@ OV.Matrix = class
(m12 + m21) / s,
(m02 - m20) / s
);
} else {
} else {
let s = Math.sqrt (1.0 + m22 - m00 - m11) * 2.0;
rotation = new OV.Quaternion (
(m02 + m20) / s,
@ -226,7 +226,7 @@ OV.Matrix = class
let a31 = this.matrix[13];
let a32 = this.matrix[14];
let a33 = this.matrix[15];
let b00 = a00 * a11 - a01 * a10;
let b01 = a00 * a12 - a02 * a10;
let b02 = a00 * a13 - a03 * a10;
@ -239,7 +239,7 @@ OV.Matrix = class
let b09 = a21 * a32 - a22 * a31;
let b10 = a21 * a33 - a23 * a31;
let b11 = a22 * a33 - a23 * a32;
let determinant = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
return determinant;
}
@ -275,7 +275,7 @@ OV.Matrix = class
let b09 = a21 * a32 - a22 * a31;
let b10 = a21 * a33 - a23 * a31;
let b11 = a22 * a33 - a23 * a32;
let determinant = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (OV.IsEqual (determinant, 0.0)) {
return null;
@ -299,7 +299,7 @@ OV.Matrix = class
(a31 * b01 - a30 * b03 - a32 * b00) / determinant,
(a20 * b03 - a21 * b01 + a22 * b00) / determinant
];
return new OV.Matrix (result);
}
@ -309,7 +309,7 @@ OV.Matrix = class
let a01 = vector[1];
let a02 = vector[2];
let a03 = vector[3];
let b00 = this.matrix[0];
let b01 = this.matrix[1];
let b02 = this.matrix[2];
@ -326,7 +326,7 @@ OV.Matrix = class
let b31 = this.matrix[13];
let b32 = this.matrix[14];
let b33 = this.matrix[15];
let result = [
a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30,
a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31,
@ -354,7 +354,7 @@ OV.Matrix = class
let a31 = this.matrix[13];
let a32 = this.matrix[14];
let a33 = this.matrix[15];
let b00 = matrix.matrix[0];
let b01 = matrix.matrix[1];
let b02 = matrix.matrix[2];
@ -371,7 +371,7 @@ OV.Matrix = class
let b31 = matrix.matrix[13];
let b32 = matrix.matrix[14];
let b33 = matrix.matrix[15];
let result = [
a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30,
a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31,
@ -388,9 +388,9 @@ OV.Matrix = class
a30 * b00 + a31 * b10 + a32 * b20 + a33 * b30,
a30 * b01 + a31 * b11 + a32 * b21 + a33 * b31,
a30 * b02 + a31 * b12 + a32 * b22 + a33 * b32,
a30 * b03 + a31 * b13 + a32 * b23 + a33 * b33
a30 * b03 + a31 * b13 + a32 * b23 + a33 * b33
];
return new OV.Matrix (result);
}
};

View File

@ -101,7 +101,7 @@ OV.OctreeNode = class
let sizeX = (this.boundingBox.max.x - this.boundingBox.min.x) / 2.0;
let sizeY = (this.boundingBox.max.y - this.boundingBox.min.y) / 2.0;
let sizeZ = (this.boundingBox.max.z - this.boundingBox.min.z) / 2.0;
AddChildNode (this, min.x, min.y, min.z, sizeX, sizeY, sizeZ);
AddChildNode (this, center.x, min.y, min.z, sizeX, sizeY, sizeZ);
AddChildNode (this, min.x, center.y, min.z, sizeX, sizeY, sizeZ);

View File

@ -115,7 +115,7 @@ OV.FileList = class
{
this.files.push (file);
}
GetFileContent (file, complete)
{
if (file.content !== null) {

View File

@ -59,13 +59,13 @@ OV.Importer3ds = class extends OV.ImporterBase
GetUpDirection ()
{
return OV.Direction.Z;
}
}
ClearContent ()
{
this.materialNameToIndex = null;
this.meshNameToIndex = null;
this.meshTransformations = null;
this.defaultMaterialIndex = null;
}
@ -95,7 +95,7 @@ OV.Importer3ds = class extends OV.ImporterBase
} else {
this.SkipChunk (reader, chunkLength);
}
});
});
}
ReadMainChunk (reader, length)
@ -191,7 +191,7 @@ OV.Importer3ds = class extends OV.ImporterBase
}
});
return texture;
}
}
ReadColorChunk (reader, length)
{
@ -355,7 +355,7 @@ OV.Importer3ds = class extends OV.ImporterBase
}
}
}
ReadFaceSmoothingGroupsChunk (mesh, faceCount, reader)
{
for (let i = 0; i < faceCount; i++) {
@ -412,7 +412,7 @@ OV.Importer3ds = class extends OV.ImporterBase
}
return node.positions[0];
}
function GetNodeRotation (node)
{
function GetQuaternionFromAxisAndAngle (rotation)
@ -430,7 +430,7 @@ OV.Importer3ds = class extends OV.ImporterBase
if (node.rotations.length === 0) {
return [0.0, 0.0, 0.0, 1.0];
}
let rotation = node.rotations[0];
return GetQuaternionFromAxisAndAngle (rotation);
}
@ -442,11 +442,11 @@ OV.Importer3ds = class extends OV.ImporterBase
}
return node.scales[0];
}
if (node.matrix !== null) {
return node.matrix;
}
let matrix = new OV.Matrix ();
matrix.ComposeTRS (
OV.ArrayToCoord3D (GetNodePosition (node)),
@ -462,7 +462,7 @@ OV.Importer3ds = class extends OV.ImporterBase
matrix = matrix.MultiplyMatrix (parentMatrix);
}
}
node.matrix = matrix;
return matrix;
}
@ -499,7 +499,7 @@ OV.Importer3ds = class extends OV.ImporterBase
if (invMeshMatrix === null) {
return;
}
let pivotPoint = GetNodePivotPoint (node);
let pivotMatrix = new OV.Matrix ().CreateTranslation (-pivotPoint[0], -pivotPoint[1], -pivotPoint[2]);
@ -551,7 +551,7 @@ OV.Importer3ds = class extends OV.ImporterBase
{
let result = [];
reader.Skip (10);
let keyNum = reader.ReadInteger32 ();
for (let i = 0; i < keyNum; i++) {
reader.ReadInteger32 ();
@ -559,7 +559,7 @@ OV.Importer3ds = class extends OV.ImporterBase
if (flags !== 0) {
reader.ReadFloat32 ();
}
let current = null;
if (type === OV.CHUNK3DS.OBJECT_ROTATION) {
let tmp = reader.ReadFloat32 ();
@ -573,7 +573,7 @@ OV.Importer3ds = class extends OV.ImporterBase
return result;
}
let objectNode = {
name : '',
instanceName : '',
@ -586,7 +586,7 @@ OV.Importer3ds = class extends OV.ImporterBase
scales : [],
matrix : null
};
let endByte = this.GetChunkEnd (reader, length);
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
if (chunkId === OV.CHUNK3DS.OBJECT_HIERARCHY) {
@ -622,7 +622,7 @@ OV.Importer3ds = class extends OV.ImporterBase
}
nodeHierarchy.meshIndexToNodes[meshIndex].push (objectNode);
}
}
}
ReadName (reader)
{
@ -658,7 +658,7 @@ OV.Importer3ds = class extends OV.ImporterBase
onChunk (chunkId, chunkLength);
}
}
GetChunkEnd (reader, length)
{
return reader.GetPosition () + length - 6;
@ -667,5 +667,5 @@ OV.Importer3ds = class extends OV.ImporterBase
SkipChunk (reader, length)
{
reader.Skip (length - 6);
}
}
};

View File

@ -5,12 +5,12 @@ OV.ImporterIfc = class extends OV.ImporterBase
super ();
this.ifc = null;
}
CanImportExtension (extension)
{
return extension === 'ifc';
}
GetUpDirection ()
{
return OV.Direction.Y;
@ -198,13 +198,13 @@ OV.ImporterIfc = class extends OV.ImporterBase
parseInt (ifcColor.y * 255.0, 10),
parseInt (ifcColor.z * 255.0, 10)
);
const materialName = 'Color ' +
OV.IntegerToHexString (color.r) +
OV.IntegerToHexString (color.g) +
OV.IntegerToHexString (color.b) +
OV.IntegerToHexString (parseInt (ifcColor.w * 255.0, 10));
let materialIndex = this.materialNameToIndex[materialName];
if (materialIndex === undefined) {
let material = new OV.Material (OV.MaterialType.Phong);

View File

@ -71,7 +71,7 @@ OV.PlyHeader = class
if (vertex === null || vertex.length === 0 || vertex.format.length < 3) {
return OV.PlyHeaderCheckResult.NoVertices;
}
let face = this.GetElement ('face');
if (this.format === 'ascii') {
if (face === null || face.count === 0 || face.format.length < 0) {
@ -136,7 +136,7 @@ OV.PlyMaterialHandler = class
OV.IntegerToHexString (color[1]) +
OV.IntegerToHexString (color[2]) +
OV.IntegerToHexString (color[3]);
let materialIndex = this.colorToMaterial[materialName];
if (materialIndex === undefined) {
let material = new OV.Material (OV.MaterialType.Phong);
@ -158,17 +158,17 @@ OV.ImporterPly = class extends OV.ImporterBase
{
super ();
}
CanImportExtension (extension)
{
return extension === 'ply';
}
GetUpDirection ()
{
return OV.Direction.Y;
}
ClearContent ()
{
this.mesh = null;
@ -236,7 +236,7 @@ OV.ImporterPly = class extends OV.ImporterBase
if (parameters.length === 0 || parameters[0] === 'comment') {
return;
}
if (parameters[0] === 'ply') {
return;
} else if (parameters[0] === 'format' && parameters.length >= 2) {
@ -265,12 +265,12 @@ OV.ImporterPly = class extends OV.ImporterBase
if (this.WasError ()) {
return;
}
let parameters = OV.ParametersFromLine (line, null);
if (parameters.length === 0 || parameters[0] === 'comment') {
return;
}
if (foundVertex < vertex.count) {
if (parameters.length >= 3) {
this.mesh.AddVertex (new OV.Coord3D (
@ -282,7 +282,7 @@ OV.ImporterPly = class extends OV.ImporterBase
}
return;
}
if (foundFace < face.count) {
if (parameters.length >= 4) {
let vertexCount = parseInt (parameters[0], 10);
@ -328,7 +328,7 @@ OV.ImporterPly = class extends OV.ImporterBase
}
return null;
}
if (format.isSingle) {
return ReadType (reader, format.elemType);
} else {
@ -347,7 +347,7 @@ OV.ImporterPly = class extends OV.ImporterBase
ReadByFormat (reader, format[i]);
}
}
function SkipAndGetColor (reader, format, startIndex)
{
let r = null;
@ -441,7 +441,7 @@ OV.ImporterPly = class extends OV.ImporterBase
let triangle = new OV.Triangle (v0, v1, v2);
this.mesh.AddTriangle (triangle);
}
}
}
} else {
SkipFormat (reader, element.format, 0);
}

View File

@ -13,8 +13,8 @@ OV.ImporterStl = class extends OV.ImporterBase
GetUpDirection ()
{
return OV.Direction.Z;
}
}
ClearContent ()
{
this.mesh = null;
@ -37,7 +37,7 @@ OV.ImporterStl = class extends OV.ImporterBase
OV.ReadLines (textContent, (line) => {
if (!this.WasError ()) {
this.ProcessLine (line);
}
}
});
}
onFinish ();
@ -49,16 +49,16 @@ OV.ImporterStl = class extends OV.ImporterBase
if (byteLength < 84) {
return false;
}
let reader = new OV.BinaryReader (fileContent, true);
reader.Skip (80);
let triangleCount = reader.ReadUnsignedInteger32 ();
if (byteLength !== triangleCount * 50 + 84) {
return false;
}
return true;
return true;
}
ProcessLine (line)
@ -71,7 +71,7 @@ OV.ImporterStl = class extends OV.ImporterBase
if (parameters.length === 0) {
return;
}
let keyword = parameters[0];
if (keyword === 'solid') {
if (parameters.length > 1) {
@ -161,5 +161,5 @@ OV.ImporterStl = class extends OV.ImporterBase
}
this.mesh.AddTriangle (triangle);
}
}
}
};

View File

@ -22,7 +22,7 @@ OV.ThreeLoader = class
EnumerateMeshes (loadedObject, processor)
{
}
GetUpDirection ()
@ -234,8 +234,8 @@ OV.ImporterThree = class extends OV.ImporterBase
GetUpDirection ()
{
return this.loader.GetUpDirection ();
}
}
ClearContent ()
{
this.loader = null;
@ -265,7 +265,7 @@ OV.ImporterThree = class extends OV.ImporterBase
onFinish ();
return;
}
const libraries = this.loader.GetExternalLibraries ();
if (libraries === null) {
onFinish ();
@ -273,7 +273,7 @@ OV.ImporterThree = class extends OV.ImporterBase
}
LoadLibraries (libraries, () => {
this.LoadModel (fileContent, onFinish);
this.LoadModel (fileContent, onFinish);
}, () => {
onFinish ();
});
@ -351,7 +351,7 @@ OV.ImporterThree = class extends OV.ImporterBase
parseInt (threeColor.b * 255.0, 10)
);
}
function CreateTexture (threeMap, externalFileNames)
{
function GetDataUrl (img)
@ -361,7 +361,7 @@ OV.ImporterThree = class extends OV.ImporterBase
let imageSize = img.width * img.height * 4;
for (let i = 0; i < imageSize; i++) {
imageData.data[i] = img.data[i];
}
}
return THREE.ImageUtils.getDataURL (imageData);
} else {
return THREE.ImageUtils.getDataURL (threeMap.image);

View File

@ -12,7 +12,7 @@ OV.BinaryReader = class
{
return this.position;
}
SetPosition (position)
{
this.position = position;
@ -22,12 +22,12 @@ OV.BinaryReader = class
{
return this.arrayBuffer.byteLength;
}
Skip (bytes)
{
this.position = this.position + bytes;
}
End ()
{
return this.position >= this.arrayBuffer.byteLength;
@ -43,63 +43,63 @@ OV.BinaryReader = class
this.position += byteLength;
return arrayBuffer;
}
ReadBoolean8 ()
{
let result = this.dataView.getInt8 (this.position);
this.position = this.position + 1;
return result ? true : false;
}
ReadCharacter8 ()
{
let result = this.dataView.getInt8 (this.position);
this.position = this.position + 1;
return result;
}
ReadUnsignedCharacter8 ()
{
let result = this.dataView.getUint8 (this.position);
this.position = this.position + 1;
return result;
}
ReadInteger16 ()
{
let result = this.dataView.getInt16 (this.position, this.isLittleEndian);
this.position = this.position + 2;
return result;
}
ReadUnsignedInteger16 ()
{
let result = this.dataView.getUint16 (this.position, this.isLittleEndian);
this.position = this.position + 2;
return result;
}
ReadInteger32 ()
{
let result = this.dataView.getInt32 (this.position, this.isLittleEndian);
this.position = this.position + 4;
return result;
}
ReadUnsignedInteger32 ()
{
let result = this.dataView.getUint32 (this.position, this.isLittleEndian);
this.position = this.position + 4;
return result;
}
ReadFloat32 ()
{
let result = this.dataView.getFloat32 (this.position, this.isLittleEndian);
this.position = this.position + 4;
return result;
}
ReadDouble64 ()
{
let result = this.dataView.getFloat64 (this.position, this.isLittleEndian);

View File

@ -12,7 +12,7 @@ OV.BinaryWriter = class
{
return this.position;
}
SetPosition (position)
{
this.position = position;
@ -41,49 +41,49 @@ OV.BinaryWriter = class
this.dataView.setInt8 (this.position, val ? 1 : 0);
this.position = this.position + 1;
}
WriteCharacter8 (val)
{
this.dataView.setInt8 (this.position, val);
this.position = this.position + 1;
}
WriteUnsignedCharacter8 (val)
{
this.dataView.setUint8 (this.position, val);
this.position = this.position + 1;
}
WriteInteger16 (val)
{
this.dataView.setInt16 (this.position, val, this.isLittleEndian);
this.position = this.position + 2;
}
WriteUnsignedInteger16 (val)
{
this.dataView.setUint16 (this.position, val, this.isLittleEndian);
this.position = this.position + 2;
}
WriteInteger32 (val)
{
this.dataView.setInt32 (this.position, val, this.isLittleEndian);
this.position = this.position + 4;
}
WriteUnsignedInteger32 (val)
{
this.dataView.setUint32 (this.position, val, this.isLittleEndian);
this.position = this.position + 4;
}
WriteFloat32 (val)
{
this.dataView.setFloat32 (this.position, val, this.isLittleEndian);
this.position = this.position + 4;
}
WriteDouble64 (val)
{
this.dataView.setFloat64 (this.position, val, this.isLittleEndian);

View File

@ -115,7 +115,7 @@ OV.Generator = class
vertices[vertexIndex + 2]
);
}
}
}
};
OV.GeneratorHelper = class
@ -171,7 +171,7 @@ OV.GeneratorHelper = class
startIndices[nextIndex]
);
}
}
}
};
OV.GenerateCuboid = function (genParams, xSize, ySize, zSize)
@ -211,7 +211,7 @@ OV.GenerateCylinder = function (genParams, radius, height, segments, smooth)
}
let helper = new OV.GeneratorHelper (generator);
helper.GenerateExtrude (baseVertices, height, smooth ? 1 : null);
return generator.GetMesh ();
return generator.GetMesh ();
};
OV.GenerateSphere = function (genParams, radius, segments, smooth)
@ -256,10 +256,10 @@ OV.GenerateSphere = function (genParams, radius, segments, smooth)
let bottomVertex = generator.AddVertex (0.0, 0.0, -radius);
helper.GenerateTriangleFan (allLevelVertices[0].slice ().reverse (), topVertex);
helper.GenerateTriangleFan (allLevelVertices[allLevelVertices.length - 1], bottomVertex);
generator.ResetCurve ();
return generator.GetMesh ();
return generator.GetMesh ();
};
OV.GeneratePlatonicSolid = function (genParams, type, radius)

View File

@ -320,5 +320,5 @@ OV.EnumerateMaterialTextureMaps = function (material, enumerator)
}
if (material.metalnessMap !== null) {
enumerator (material.metalnessMap);
}
}
};

View File

@ -13,22 +13,22 @@ OV.Mesh = class extends OV.ModelObject3D
{
return this.vertices.length;
}
NormalCount ()
{
return this.normals.length;
}
TextureUVCount ()
{
return this.uvs.length;
}
TriangleCount ()
{
return this.triangles.length;
}
AddVertex (vertex)
{
this.vertices.push (vertex);
@ -39,12 +39,12 @@ OV.Mesh = class extends OV.ModelObject3D
{
this.vertices[index] = vertex;
}
GetVertex (index)
{
return this.vertices[index];
}
AddNormal (normal)
{
this.normals.push (normal);
@ -60,7 +60,7 @@ OV.Mesh = class extends OV.ModelObject3D
{
return this.normals[index];
}
AddTextureUV (uv)
{
this.uvs.push (uv);
@ -71,18 +71,18 @@ OV.Mesh = class extends OV.ModelObject3D
{
this.uvs[index] = uv;
}
GetTextureUV (index)
{
return this.uvs[index];
}
AddTriangle (triangle)
{
this.triangles.push (triangle);
return this.triangles.length - 1;
}
GetTriangle (index)
{
return this.triangles[index];
@ -110,5 +110,5 @@ OV.Mesh = class extends OV.ModelObject3D
let v2 = this.vertices[triangle.v2];
onTriangleVertices (v0, v1, v2);
}
}
}
};

View File

@ -58,7 +58,7 @@ OV.MeshBuffer = class
byteLength += primitive.GetByteLength (indexTypeSize, numberTypeSize);
}
return byteLength;
}
}
};
OV.ConvertMeshToMeshBuffer = function (mesh)
@ -95,7 +95,7 @@ OV.ConvertMeshToMeshBuffer = function (mesh)
uv : uv
};
}
function FindMatchingPrimitiveVertex (mesh, primitiveVertices, normalIndex, uvIndex)
{
for (let i = 0; i < primitiveVertices.length; i++) {
@ -112,7 +112,7 @@ OV.ConvertMeshToMeshBuffer = function (mesh)
if (equalNormal && equalUv) {
return primitiveVertex;
}
}
}
return null;
}

View File

@ -11,17 +11,17 @@ OV.MeshInstance = class extends OV.Object3D
{
return this.mesh.VertexCount ();
}
NormalCount ()
{
return this.mesh.NormalCount ();
}
TextureUVCount ()
{
return this.mesh.TextureUVCount ();
}
TriangleCount ()
{
return this.mesh.TriangleCount ();

View File

@ -85,7 +85,7 @@ OV.Model = class extends OV.ModelObject3D
node.meshIndices[i] += 1;
}
}
});
});
return index;
}

View File

@ -12,7 +12,7 @@ OV.FinalizeModel = function (model, getDefaultMaterial)
let current = array[i];
if (OV.CoordIsEqual3D (current, normal)) {
return true;
}
}
}
return false;
}
@ -41,11 +41,11 @@ OV.FinalizeModel = function (model, getDefaultMaterial)
let triangleNormals = [];
let vertexToTriangles = {};
for (let vertexIndex = 0; vertexIndex < mesh.VertexCount (); vertexIndex++) {
vertexToTriangles[vertexIndex] = [];
}
for (let triangleIndex = 0; triangleIndex < mesh.TriangleCount (); triangleIndex++) {
let triangle = mesh.GetTriangle (triangleIndex);
let v0 = mesh.GetVertex (triangle.v0);
@ -66,7 +66,7 @@ OV.FinalizeModel = function (model, getDefaultMaterial)
let n2 = AddAverageNormal (mesh, triangle, triangle.v2, triangleNormals, vertexToTriangles);
triangle.SetNormals (n0, n1, n2);
}
}
}
}
function FinalizeTriangle (mesh, triangle, status)
@ -90,7 +90,7 @@ OV.FinalizeModel = function (model, getDefaultMaterial)
triangle.curve = 0;
}
}
let status = {
getDefaultMaterialIndex : getDefaultMaterialIndex,
calculateCurveNormals : false
@ -146,7 +146,7 @@ OV.CheckModel = function (model)
return false;
}
return true;
}
}
function IsCorrectIndex (val, count)
{
@ -157,8 +157,8 @@ OV.CheckModel = function (model)
return false;
}
return true;
}
}
function CheckMesh (model, mesh)
{
function CheckTriangle (model, mesh, triangle)
@ -180,7 +180,7 @@ OV.CheckModel = function (model)
}
if (!IsCorrectIndex (triangle.n2, mesh.NormalCount ())) {
return false;
}
}
if (triangle.HasTextureUVs ()) {
if (!IsCorrectIndex (triangle.u0, mesh.TextureUVCount ())) {
return false;
@ -201,7 +201,7 @@ OV.CheckModel = function (model)
return true;
}
for (let i = 0; i < mesh.VertexCount (); i++) {
let vertex = mesh.GetVertex (i);
if (!IsCorrectNumber (vertex.x)) {
@ -236,7 +236,7 @@ OV.CheckModel = function (model)
if (!IsCorrectNumber (uv.y)) {
return false;
}
}
}
for (let i = 0; i < mesh.TriangleCount (); i++) {
let triangle = mesh.GetTriangle (i);

View File

@ -12,7 +12,7 @@ OV.TransformMesh = function (mesh, transformation)
if (transformation.IsIdentity ()) {
return;
}
for (let i = 0; i < mesh.VertexCount (); i++) {
let vertex = mesh.GetVertex (i);
let transformed = transformation.TransformCoord3D (vertex);
@ -80,7 +80,7 @@ OV.CloneMesh = function (mesh)
for (let i = 0; i < mesh.TriangleCount (); i++) {
let triangle = mesh.GetTriangle (i);
cloned.AddTriangle (triangle.Clone ());
}
}
return cloned;
};
@ -197,7 +197,7 @@ OV.GetTopology = function (object3D)
let boundingBox = OV.GetBoundingBox (object3D);
let octree = new OV.Octree (boundingBox);
let topology = new OV.Topology ();
object3D.EnumerateTriangleVertices ((v0, v1, v2) => {
let v0Index = GetVertexIndex (v0, octree, topology);
let v1Index = GetVertexIndex (v1, octree, topology);

View File

@ -9,17 +9,17 @@ OV.Object3D = class
{
return 0;
}
NormalCount ()
{
return 0;
}
TextureUVCount ()
{
return 0;
}
TriangleCount ()
{
return 0;
@ -54,7 +54,7 @@ OV.ModelObject3D = class extends OV.Object3D
{
return this.name;
}
SetName (name)
{
this.name = name;

View File

@ -68,7 +68,7 @@ OV.ThreeNodeTree = class
let matrix = node.GetTransformation ().GetMatrix ();
let threeMatrix = new THREE.Matrix4 ().fromArray (matrix.Get ());
threeNode.applyMatrix4 (threeMatrix);
const nodeIndex = this.nodes.length - 1;
for (let childNode of node.GetChildNodes ()) {
let threeChildNode = new THREE.Object3D ();
@ -145,7 +145,7 @@ OV.ConvertModelToThreeObject = function (model, params, output, callbacks)
threeMaterial.shininess = material.shininess * 100.0;
LoadTexture (stateHandler, threeMaterial, material.specularMap, (threeTexture) => {
threeMaterial.specularMap = threeTexture;
});
});
} else if (material.type === OV.MaterialType.Physical) {
threeMaterial = new THREE.MeshStandardMaterial (materialParams);
threeMaterial.metalness = material.metalness;
@ -276,7 +276,7 @@ OV.ConvertModelToThreeObject = function (model, params, output, callbacks)
originalMaterials : meshOriginalMaterials,
threeMaterials : null
};
return threeMesh;
}

View File

@ -26,7 +26,7 @@ OV.ThreeModelLoader = class
this.OnFilesLoaded (settings);
});
}
LoadFromFileList (files, settings)
{
if (this.inProgress) {
@ -39,7 +39,7 @@ OV.ThreeModelLoader = class
this.OnFilesLoaded (settings);
});
}
OnFilesLoaded (settings)
{
this.callbacks.onImportStart ();

View File

@ -3,7 +3,7 @@ OV.Init3DViewerElement = function (parentDiv, modelUrls, parameters)
if (!parameters) {
parameters = {};
}
let canvas = document.createElement ('canvas');
parentDiv.appendChild (canvas);
@ -42,7 +42,7 @@ OV.Init3DViewerElement = function (parentDiv, modelUrls, parameters)
} else {
viewer.SetUpVector (importResult.upVector, false);
}
viewer.FitSphereToWindow (boundingSphere, false);
viewer.FitSphereToWindow (boundingSphere, false);
},
onTextureLoaded : () => {
viewer.Render ();
@ -112,7 +112,7 @@ OV.Init3DViewerElements = function (onReady)
if (environmentMapParams) {
let environmentMapParts = environmentMapParams.split (',');
if (environmentMapParts.length === 6) {
environmentMap = environmentMapParts;
environmentMap = environmentMapParts;
}
}
@ -141,14 +141,14 @@ OV.Init3DViewerElements = function (onReady)
if (onReady !== undefined && onReady !== null) {
onReady (viewerElements);
}
});
});
window.addEventListener ('resize', () => {
for (let i = 0; i < viewerElements.length; i++) {
let viewerElement = viewerElements[i];
let width = viewerElement.element.clientWidth;
let height = viewerElement.element.clientHeight;
viewerElement.viewer.Resize (width, height);
viewerElement.viewer.Resize (width, height);
}
});
};

View File

@ -250,7 +250,7 @@ OV.Navigation = class
this.mouse = new OV.MouseInteraction ();
this.touch = new OV.TouchInteraction ();
this.clickDetector = new OV.ClickDetector ();
this.onUpdate = null;
this.onClick = null;
this.onContext = null;
@ -267,7 +267,7 @@ OV.Navigation = class
document.addEventListener ('mousemove', this.OnMouseMove.bind (this));
document.addEventListener ('mouseup', this.OnMouseUp.bind (this));
document.addEventListener ('mouseleave', this.OnMouseLeave.bind (this));
}
}
}
SetUpdateHandler (onUpdate)
@ -324,7 +324,7 @@ OV.Navigation = class
if (newCamera === null) {
return;
}
if (stepCount === 0) {
this.SetCamera (newCamera);
return;
@ -336,7 +336,7 @@ OV.Navigation = class
{
return;
}
let tweenFunc = OV.ParabolicTweenFunction;
let steps = {
eye : OV.TweenCoord3D (this.camera.eye, newCamera.eye, stepCount, tweenFunc),
@ -354,7 +354,7 @@ OV.Navigation = class
if (OV.IsZero (radius)) {
return;
}
let fitCamera = this.GetFitToSphereCamera (center, radius, fov);
this.camera = fitCamera;
@ -367,20 +367,20 @@ OV.Navigation = class
if (OV.IsZero (radius)) {
return null;
}
let fitCamera = this.camera.Clone ();
let offsetToOrigo = OV.SubCoord3D (fitCamera.center, center);
fitCamera.eye = OV.SubCoord3D (fitCamera.eye, offsetToOrigo);
fitCamera.center = center.Clone ();
let centerEyeDirection = OV.SubCoord3D (fitCamera.eye, fitCamera.center).Normalize ();
let fieldOfView = fov / 2.0;
if (this.canvas.width < this.canvas.height) {
fieldOfView = fieldOfView * this.canvas.width / this.canvas.height;
}
let distance = radius / Math.sin (fieldOfView * OV.DegRad);
fitCamera.eye = fitCamera.center.Clone ().Offset (centerEyeDirection, distance);
this.orbitCenter = fitCamera.center.Clone ();
return fitCamera;
@ -492,7 +492,7 @@ OV.Navigation = class
ev.preventDefault ();
let params = ev || window.event;
let delta = -params.deltaY / 40;
let ratio = 0.1;
if (delta < 0) {
@ -506,7 +506,7 @@ OV.Navigation = class
OnContextMenu (ev)
{
ev.preventDefault ();
this.clickDetector.Up (ev);
if (this.clickDetector.IsClick ()) {
this.Context (ev.clientX, ev.clientY);
@ -517,11 +517,11 @@ OV.Navigation = class
{
let radAngleX = angleX * OV.DegRad;
let radAngleY = angleY * OV.DegRad;
let viewDirection = OV.SubCoord3D (this.camera.center, this.camera.eye).Normalize ();
let horizontalDirection = OV.CrossVector3D (viewDirection, this.camera.up).Normalize ();
let differentCenter = !OV.CoordIsEqual3D (this.orbitCenter, this.camera.center);
if (this.fixUpVector) {
let originalAngle = OV.VectorAngle3D (viewDirection, this.camera.up);
let newAngle = originalAngle + radAngleY;
@ -552,10 +552,10 @@ OV.Navigation = class
let viewDirection = OV.SubCoord3D (this.camera.center, this.camera.eye).Normalize ();
let horizontalDirection = OV.CrossVector3D (viewDirection, this.camera.up).Normalize ();
let verticalDirection = OV.CrossVector3D (horizontalDirection, viewDirection).Normalize ();
this.camera.eye.Offset (horizontalDirection, -moveX);
this.camera.center.Offset (horizontalDirection, -moveX);
this.camera.eye.Offset (verticalDirection, moveY);
this.camera.center.Offset (verticalDirection, moveY);
}