Rename Color to RGBColor.
This commit is contained in:
parent
cfdbdbbafa
commit
c168f944f6
@ -34,11 +34,11 @@
|
|||||||
|
|
||||||
// initialize the viewer with the parent element and some parameters
|
// initialize the viewer with the parent element and some parameters
|
||||||
let viewer = new OV.EmbeddedViewer (parentDiv, {
|
let viewer = new OV.EmbeddedViewer (parentDiv, {
|
||||||
backgroundColor : new OV.Color (255, 255, 255),
|
backgroundColor : new OV.RGBColor (255, 255, 255),
|
||||||
defaultColor : new OV.Color (200, 200, 200),
|
defaultColor : new OV.RGBColor (200, 200, 200),
|
||||||
edgeSettings : {
|
edgeSettings : {
|
||||||
showEdges : false,
|
showEdges : false,
|
||||||
edgeColor : new OV.Color (0, 0, 0),
|
edgeColor : new OV.RGBColor (0, 0, 0),
|
||||||
edgeThreshold : 1
|
edgeThreshold : 1
|
||||||
},
|
},
|
||||||
environmentSettings : {
|
environmentSettings : {
|
||||||
|
|||||||
@ -26,11 +26,11 @@
|
|||||||
|
|
||||||
// initialize the viewer with the parent element and some parameters
|
// initialize the viewer with the parent element and some parameters
|
||||||
let viewer = new OV.EmbeddedViewer (parentDiv, {
|
let viewer = new OV.EmbeddedViewer (parentDiv, {
|
||||||
backgroundColor : new OV.Color (255, 255, 255),
|
backgroundColor : new OV.RGBColor (255, 255, 255),
|
||||||
defaultColor : new OV.Color (200, 200, 200),
|
defaultColor : new OV.RGBColor (200, 200, 200),
|
||||||
edgeSettings : {
|
edgeSettings : {
|
||||||
showEdges : false,
|
showEdges : false,
|
||||||
edgeColor : new OV.Color (0, 0, 0),
|
edgeColor : new OV.RGBColor (0, 0, 0),
|
||||||
edgeThreshold : 1
|
edgeThreshold : 1
|
||||||
},
|
},
|
||||||
environmentSettings : {
|
environmentSettings : {
|
||||||
|
|||||||
@ -31,11 +31,11 @@
|
|||||||
new OV.Coord3D (0.0, 0.0, 0.0),
|
new OV.Coord3D (0.0, 0.0, 0.0),
|
||||||
new OV.Coord3D (0.0, 1.0, 0.0)
|
new OV.Coord3D (0.0, 1.0, 0.0)
|
||||||
),
|
),
|
||||||
backgroundColor : new OV.Color (255, 255, 255),
|
backgroundColor : new OV.RGBColor (255, 255, 255),
|
||||||
defaultColor : new OV.Color (200, 200, 200),
|
defaultColor : new OV.RGBColor (200, 200, 200),
|
||||||
edgeSettings : {
|
edgeSettings : {
|
||||||
showEdges : false,
|
showEdges : false,
|
||||||
edgeColor : new OV.Color (0, 0, 0),
|
edgeColor : new OV.RGBColor (0, 0, 0),
|
||||||
edgeThreshold : 1
|
edgeThreshold : 1
|
||||||
},
|
},
|
||||||
environmentSettings : {
|
environmentSettings : {
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
OV.Init3DViewerElements (function (viewers) {
|
OV.Init3DViewerElements (function (viewers) {
|
||||||
let firstViewer = viewers[0].viewer;
|
let firstViewer = viewers[0].viewer;
|
||||||
firstViewer.SetBackgroundColor (new OV.Color (34, 34, 34));
|
firstViewer.SetBackgroundColor (new OV.RGBColor (34, 34, 34));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { BinaryWriter } from '../io/binarywriter.js';
|
import { BinaryWriter } from '../io/binarywriter.js';
|
||||||
import { Utf8StringToArrayBuffer } from '../io/bufferutils.js';
|
import { Utf8StringToArrayBuffer } from '../io/bufferutils.js';
|
||||||
import { FileFormat, GetFileExtension, GetFileName } from '../io/fileutils.js';
|
import { FileFormat, GetFileExtension, GetFileName } from '../io/fileutils.js';
|
||||||
import { Color, SRGBToLinear } from '../model/color.js';
|
import { RGBColor, SRGBToLinear } from '../model/color.js';
|
||||||
import { MaterialType } from '../model/material.js';
|
import { MaterialType } from '../model/material.js';
|
||||||
import { ConvertMeshToMeshBuffer } from '../model/meshbuffer.js';
|
import { ConvertMeshToMeshBuffer } from '../model/meshbuffer.js';
|
||||||
import { ExportedFile, ExporterBase } from './exporterbase.js';
|
import { ExportedFile, ExporterBase } from './exporterbase.js';
|
||||||
@ -453,7 +453,7 @@ export class ExporterGltf extends ExporterBase
|
|||||||
let baseColorTexture = GetTextureParams (mainJson, material.diffuseMap, addTexture);
|
let baseColorTexture = GetTextureParams (mainJson, material.diffuseMap, addTexture);
|
||||||
if (baseColorTexture !== null) {
|
if (baseColorTexture !== null) {
|
||||||
if (!material.multiplyDiffuseMap) {
|
if (!material.multiplyDiffuseMap) {
|
||||||
jsonMaterial.pbrMetallicRoughness.baseColorFactor = ColorToRGBA (new Color (255, 255, 255), material.opacity);
|
jsonMaterial.pbrMetallicRoughness.baseColorFactor = ColorToRGBA (new RGBColor (255, 255, 255), material.opacity);
|
||||||
}
|
}
|
||||||
jsonMaterial.pbrMetallicRoughness.baseColorTexture = baseColorTexture;
|
jsonMaterial.pbrMetallicRoughness.baseColorTexture = baseColorTexture;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { RunTaskAsync } from '../core/taskrunner.js';
|
import { RunTaskAsync } from '../core/taskrunner.js';
|
||||||
import { FileSource, GetFileName } from '../io/fileutils.js';
|
import { FileSource, GetFileName } from '../io/fileutils.js';
|
||||||
import { Color } from '../model/color.js';
|
import { RGBColor } from '../model/color.js';
|
||||||
import { ImporterFile, ImporterFileList } from './importerfiles.js';
|
import { ImporterFile, ImporterFileList } from './importerfiles.js';
|
||||||
import { Importer3dm } from './importer3dm.js';
|
import { Importer3dm } from './importer3dm.js';
|
||||||
import { Importer3ds } from './importer3ds.js';
|
import { Importer3ds } from './importer3ds.js';
|
||||||
@ -21,7 +21,7 @@ export class ImportSettings
|
|||||||
{
|
{
|
||||||
constructor ()
|
constructor ()
|
||||||
{
|
{
|
||||||
this.defaultColor = new Color (200, 200, 200);
|
this.defaultColor = new RGBColor (200, 200, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { Matrix } from '../geometry/matrix.js';
|
|||||||
import { ArrayToQuaternion } from '../geometry/quaternion.js';
|
import { ArrayToQuaternion } from '../geometry/quaternion.js';
|
||||||
import { Transformation } from '../geometry/transformation.js';
|
import { Transformation } from '../geometry/transformation.js';
|
||||||
import { BinaryReader } from '../io/binaryreader.js';
|
import { BinaryReader } from '../io/binaryreader.js';
|
||||||
import { Color, ColorComponentFromFloat } from '../model/color.js';
|
import { RGBColor, ColorComponentFromFloat } from '../model/color.js';
|
||||||
import { PhongMaterial, TextureMap } from '../model/material.js';
|
import { PhongMaterial, TextureMap } from '../model/material.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { FlipMeshTrianglesOrientation, TransformMesh } from '../model/meshutils.js';
|
import { FlipMeshTrianglesOrientation, TransformMesh } from '../model/meshutils.js';
|
||||||
@ -246,7 +246,7 @@ export class Importer3ds extends ImporterBase
|
|||||||
|
|
||||||
ReadColorChunk (reader, length)
|
ReadColorChunk (reader, length)
|
||||||
{
|
{
|
||||||
let color = new Color (0, 0, 0);
|
let color = new RGBColor (0, 0, 0);
|
||||||
let endByte = this.GetChunkEnd (reader, length);
|
let endByte = this.GetChunkEnd (reader, length);
|
||||||
let hasLinColor = false;
|
let hasLinColor = false;
|
||||||
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
|
this.ReadChunks (reader, endByte, (chunkId, chunkLength) => {
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { Transformation } from '../geometry/transformation.js';
|
|||||||
import { BinaryReader } from '../io/binaryreader.js';
|
import { BinaryReader } from '../io/binaryreader.js';
|
||||||
import { ArrayBufferToUtf8String, Base64DataURIToArrayBuffer, GetFileExtensionFromMimeType } from '../io/bufferutils.js';
|
import { ArrayBufferToUtf8String, Base64DataURIToArrayBuffer, GetFileExtensionFromMimeType } from '../io/bufferutils.js';
|
||||||
import { LoadExternalLibrary } from '../io/externallibs.js';
|
import { LoadExternalLibrary } from '../io/externallibs.js';
|
||||||
import { Color, ColorComponentFromFloat, ColorFromFloatComponents, LinearToSRGB } from '../model/color.js';
|
import { RGBColor, ColorComponentFromFloat, RGBColorFromFloatComponents, LinearToSRGB } from '../model/color.js';
|
||||||
import { PhongMaterial, PhysicalMaterial, TextureMap } from '../model/material.js';
|
import { PhongMaterial, PhysicalMaterial, TextureMap } from '../model/material.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { Node, NodeType } from '../model/node.js';
|
import { Node, NodeType } from '../model/node.js';
|
||||||
@ -57,7 +57,7 @@ const GltfConstants =
|
|||||||
|
|
||||||
function GetGltfColor (color)
|
function GetGltfColor (color)
|
||||||
{
|
{
|
||||||
return ColorFromFloatComponents (
|
return RGBColorFromFloatComponents (
|
||||||
LinearToSRGB (color[0]),
|
LinearToSRGB (color[0]),
|
||||||
LinearToSRGB (color[1]),
|
LinearToSRGB (color[1]),
|
||||||
LinearToSRGB (color[2])
|
LinearToSRGB (color[2])
|
||||||
@ -77,7 +77,7 @@ function GetGltfVertexColor (color, componentType)
|
|||||||
return ColorComponentFromFloat (LinearToSRGB (normalized));
|
return ColorComponentFromFloat (LinearToSRGB (normalized));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Color (
|
return new RGBColor (
|
||||||
GetColorComponent (color[0], componentType),
|
GetColorComponent (color[0], componentType),
|
||||||
GetColorComponent (color[1], componentType),
|
GetColorComponent (color[1], componentType),
|
||||||
GetColorComponent (color[2], componentType)
|
GetColorComponent (color[2], componentType)
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { Direction } from '../geometry/geometry.js';
|
|||||||
import { Matrix } from '../geometry/matrix.js';
|
import { Matrix } from '../geometry/matrix.js';
|
||||||
import { Transformation } from '../geometry/transformation.js';
|
import { Transformation } from '../geometry/transformation.js';
|
||||||
import { LoadExternalLibrary } from '../io/externallibs.js';
|
import { LoadExternalLibrary } from '../io/externallibs.js';
|
||||||
import { ColorFromFloatComponents } from '../model/color.js';
|
import { RGBColorFromFloatComponents } from '../model/color.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
||||||
import { Triangle } from '../model/triangle.js';
|
import { Triangle } from '../model/triangle.js';
|
||||||
@ -207,7 +207,7 @@ export class ImporterIfc extends ImporterBase
|
|||||||
|
|
||||||
GetMaterialIndexByColor (ifcColor)
|
GetMaterialIndexByColor (ifcColor)
|
||||||
{
|
{
|
||||||
const color = ColorFromFloatComponents (ifcColor.x, ifcColor.y, ifcColor.z);
|
const color = RGBColorFromFloatComponents (ifcColor.x, ifcColor.y, ifcColor.z);
|
||||||
const alpha = parseInt (ifcColor.w * 255.0, 10);
|
const alpha = parseInt (ifcColor.w * 255.0, 10);
|
||||||
return this.colorToMaterial.GetMaterialIndex (color.r, color.g, color.b, alpha);
|
return this.colorToMaterial.GetMaterialIndex (color.r, color.g, color.b, alpha);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { Matrix } from '../geometry/matrix.js';
|
|||||||
import { ArrayToQuaternion, Quaternion } from '../geometry/quaternion.js';
|
import { ArrayToQuaternion, Quaternion } from '../geometry/quaternion.js';
|
||||||
import { Transformation } from '../geometry/transformation.js';
|
import { Transformation } from '../geometry/transformation.js';
|
||||||
import { ArrayBufferToUtf8String } from '../io/bufferutils.js';
|
import { ArrayBufferToUtf8String } from '../io/bufferutils.js';
|
||||||
import { ArrayToColor } from '../model/color.js';
|
import { ArrayToRGBColor } from '../model/color.js';
|
||||||
import { GenerateCone, GenerateCuboid, GenerateCylinder, GeneratePlatonicSolid, GenerateSphere, GeneratorParams } from '../model/generator.js';
|
import { GenerateCone, GenerateCuboid, GenerateCylinder, GeneratePlatonicSolid, GenerateSphere, GeneratorParams } from '../model/generator.js';
|
||||||
import { PhysicalMaterial } from '../model/material.js';
|
import { PhysicalMaterial } from '../model/material.js';
|
||||||
import { Node, NodeType } from '../model/node.js';
|
import { Node, NodeType } from '../model/node.js';
|
||||||
@ -76,7 +76,7 @@ export class ImporterO3dv extends ImporterBase
|
|||||||
material.name = materialContent.name;
|
material.name = materialContent.name;
|
||||||
}
|
}
|
||||||
if (materialContent.color !== undefined) {
|
if (materialContent.color !== undefined) {
|
||||||
material.color = ArrayToColor (materialContent.color);
|
material.color = ArrayToRGBColor (materialContent.color);
|
||||||
}
|
}
|
||||||
material.metalness = ValueOrDefault (materialContent.metalness, 0.0);
|
material.metalness = ValueOrDefault (materialContent.metalness, 0.0);
|
||||||
material.roughness = ValueOrDefault (materialContent.roughness, 1.0);
|
material.roughness = ValueOrDefault (materialContent.roughness, 1.0);
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Coord2D } from '../geometry/coord2d.js';
|
|||||||
import { Coord3D } from '../geometry/coord3d.js';
|
import { Coord3D } from '../geometry/coord3d.js';
|
||||||
import { Direction } from '../geometry/geometry.js';
|
import { Direction } from '../geometry/geometry.js';
|
||||||
import { ArrayBufferToUtf8String } from '../io/bufferutils.js';
|
import { ArrayBufferToUtf8String } from '../io/bufferutils.js';
|
||||||
import { Color, ColorFromFloatComponents } from '../model/color.js';
|
import { RGBColor, RGBColorFromFloatComponents } from '../model/color.js';
|
||||||
import { PhongMaterial, TextureMap } from '../model/material.js';
|
import { PhongMaterial, TextureMap } from '../model/material.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { Triangle } from '../model/triangle.js';
|
import { Triangle } from '../model/triangle.js';
|
||||||
@ -30,7 +30,7 @@ class ObjMeshConverter
|
|||||||
AddVertexColor (globalIndex, globalVertexColors)
|
AddVertexColor (globalIndex, globalVertexColors)
|
||||||
{
|
{
|
||||||
return this.GetLocalIndex (globalIndex, globalVertexColors, this.globalToMeshVertexColors, (val) => {
|
return this.GetLocalIndex (globalIndex, globalVertexColors, this.globalToMeshVertexColors, (val) => {
|
||||||
return this.mesh.AddVertexColor (new Color (val.r, val.g, val.b));
|
return this.mesh.AddVertexColor (new RGBColor (val.r, val.g, val.b));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class ObjMeshConverter
|
|||||||
|
|
||||||
function CreateColor (r, g, b)
|
function CreateColor (r, g, b)
|
||||||
{
|
{
|
||||||
return ColorFromFloatComponents (
|
return RGBColorFromFloatComponents (
|
||||||
parseFloat (r),
|
parseFloat (r),
|
||||||
parseFloat (g),
|
parseFloat (g),
|
||||||
parseFloat (b)
|
parseFloat (b)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Coord3D } from '../geometry/coord3d.js';
|
import { Coord3D } from '../geometry/coord3d.js';
|
||||||
import { Direction } from '../geometry/geometry.js';
|
import { Direction } from '../geometry/geometry.js';
|
||||||
import { ArrayBufferToUtf8String } from '../io/bufferutils.js';
|
import { ArrayBufferToUtf8String } from '../io/bufferutils.js';
|
||||||
import { Color, ColorComponentFromFloat } from '../model/color.js';
|
import { RGBColor, ColorComponentFromFloat } from '../model/color.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { Triangle } from '../model/triangle.js';
|
import { Triangle } from '../model/triangle.js';
|
||||||
import { ImporterBase } from './importerbase.js';
|
import { ImporterBase } from './importerbase.js';
|
||||||
@ -97,7 +97,7 @@ export class ImporterOff extends ImporterBase
|
|||||||
this.status.foundVertex += 1;
|
this.status.foundVertex += 1;
|
||||||
}
|
}
|
||||||
if (parameters.length >= 6) {
|
if (parameters.length >= 6) {
|
||||||
this.mesh.AddVertexColor (new Color (
|
this.mesh.AddVertexColor (new RGBColor (
|
||||||
CreateColorComponent (parameters[3]),
|
CreateColorComponent (parameters[3]),
|
||||||
CreateColorComponent (parameters[4]),
|
CreateColorComponent (parameters[4]),
|
||||||
CreateColorComponent (parameters[5])
|
CreateColorComponent (parameters[5])
|
||||||
@ -115,7 +115,7 @@ export class ImporterOff extends ImporterBase
|
|||||||
}
|
}
|
||||||
let materialIndex = null;
|
let materialIndex = null;
|
||||||
if (!hasVertexColors && parameters.length >= vertexCount + 4) {
|
if (!hasVertexColors && parameters.length >= vertexCount + 4) {
|
||||||
let color = new Color (
|
let color = new RGBColor (
|
||||||
CreateColorComponent (parameters[vertexCount + 1]),
|
CreateColorComponent (parameters[vertexCount + 1]),
|
||||||
CreateColorComponent (parameters[vertexCount + 2]),
|
CreateColorComponent (parameters[vertexCount + 2]),
|
||||||
CreateColorComponent (parameters[vertexCount + 3])
|
CreateColorComponent (parameters[vertexCount + 3])
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Coord3D } from '../geometry/coord3d.js';
|
|||||||
import { Direction } from '../geometry/geometry.js';
|
import { Direction } from '../geometry/geometry.js';
|
||||||
import { BinaryReader } from '../io/binaryreader.js';
|
import { BinaryReader } from '../io/binaryreader.js';
|
||||||
import { ArrayBufferToUtf8String } from '../io/bufferutils.js';
|
import { ArrayBufferToUtf8String } from '../io/bufferutils.js';
|
||||||
import { Color, IntegerToHexString } from '../model/color.js';
|
import { RGBColor, IntegerToHexString } from '../model/color.js';
|
||||||
import { PhongMaterial } from '../model/material.js';
|
import { PhongMaterial } from '../model/material.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { Triangle } from '../model/triangle.js';
|
import { Triangle } from '../model/triangle.js';
|
||||||
@ -124,7 +124,7 @@ class PlyMaterialHandler
|
|||||||
} else {
|
} else {
|
||||||
let material = new PhongMaterial ();
|
let material = new PhongMaterial ();
|
||||||
material.name = materialName;
|
material.name = materialName;
|
||||||
material.color = new Color (color[0], color[1], color[2]);
|
material.color = new RGBColor (color[0], color[1], color[2]);
|
||||||
material.opacity = color[3] / 255.0;
|
material.opacity = color[3] / 255.0;
|
||||||
UpdateMaterialTransparency (material);
|
UpdateMaterialTransparency (material);
|
||||||
let materialIndex = this.model.AddMaterial (material);
|
let materialIndex = this.model.AddMaterial (material);
|
||||||
@ -379,7 +379,7 @@ export class ImporterPly extends ImporterBase
|
|||||||
let z = ReadByFormat (reader, element.format[2]);
|
let z = ReadByFormat (reader, element.format[2]);
|
||||||
let color = SkipAndGetColor (reader, element.format, 3);
|
let color = SkipAndGetColor (reader, element.format, 3);
|
||||||
if (color !== null) {
|
if (color !== null) {
|
||||||
this.mesh.AddVertexColor (new Color (color[0], color[1], color[2]));
|
this.mesh.AddVertexColor (new RGBColor (color[0], color[1], color[2]));
|
||||||
}
|
}
|
||||||
this.mesh.AddVertex (new Coord3D (x, y, z));
|
this.mesh.AddVertex (new Coord3D (x, y, z));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Direction } from '../geometry/geometry.js';
|
import { Direction } from '../geometry/geometry.js';
|
||||||
import { GetExternalLibPath } from '../io/externallibs.js';
|
import { GetExternalLibPath } from '../io/externallibs.js';
|
||||||
import { Node } from '../model/node.js';
|
import { Node } from '../model/node.js';
|
||||||
import { ColorFromFloatComponents } from '../model/color.js';
|
import { RGBColorFromFloatComponents } from '../model/color.js';
|
||||||
import { ConvertThreeGeometryToMesh } from '../threejs/threeutils.js';
|
import { ConvertThreeGeometryToMesh } from '../threejs/threeutils.js';
|
||||||
import { ImporterBase } from './importerbase.js';
|
import { ImporterBase } from './importerbase.js';
|
||||||
import { ColorToMaterialConverter } from './importerutils.js';
|
import { ColorToMaterialConverter } from './importerutils.js';
|
||||||
@ -88,7 +88,7 @@ export class ImporterStp extends ImporterBase
|
|||||||
{
|
{
|
||||||
let materialIndex = null;
|
let materialIndex = null;
|
||||||
if (occtMesh.color) {
|
if (occtMesh.color) {
|
||||||
let color = ColorFromFloatComponents (occtMesh.color[0], occtMesh.color[1], occtMesh.color[2]);
|
let color = RGBColorFromFloatComponents (occtMesh.color[0], occtMesh.color[1], occtMesh.color[2]);
|
||||||
materialIndex = colorToMaterial.GetMaterialIndex (color.r, color.g, color.b, null);
|
materialIndex = colorToMaterial.GetMaterialIndex (color.r, color.g, color.b, null);
|
||||||
}
|
}
|
||||||
let mesh = ConvertThreeGeometryToMesh (occtMesh, materialIndex);
|
let mesh = ConvertThreeGeometryToMesh (occtMesh, materialIndex);
|
||||||
@ -97,7 +97,7 @@ export class ImporterStp extends ImporterBase
|
|||||||
}
|
}
|
||||||
if (occtMesh.face_colors) {
|
if (occtMesh.face_colors) {
|
||||||
for (let faceColorGroup of occtMesh.face_colors) {
|
for (let faceColorGroup of occtMesh.face_colors) {
|
||||||
let faceColor = ColorFromFloatComponents (faceColorGroup.color[0], faceColorGroup.color[1], faceColorGroup.color[2]);
|
let faceColor = RGBColorFromFloatComponents (faceColorGroup.color[0], faceColorGroup.color[1], faceColorGroup.color[2]);
|
||||||
let faceMaterialIndex = colorToMaterial.GetMaterialIndex (faceColor.r, faceColor.g, faceColor.b, null);
|
let faceMaterialIndex = colorToMaterial.GetMaterialIndex (faceColor.r, faceColor.g, faceColor.b, null);
|
||||||
for (let i = faceColorGroup.first; i <= faceColorGroup.last; i++) {
|
for (let i = faceColorGroup.first; i <= faceColorGroup.last; i++) {
|
||||||
let triangle = mesh.GetTriangle (i);
|
let triangle = mesh.GetTriangle (i);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { IsLower } from '../geometry/geometry.js';
|
import { IsLower } from '../geometry/geometry.js';
|
||||||
import { PhongMaterial } from '../model/material.js';
|
import { PhongMaterial } from '../model/material.js';
|
||||||
import { Color, IntegerToHexString } from '../model/color.js';
|
import { RGBColor, IntegerToHexString } from '../model/color.js';
|
||||||
|
|
||||||
export function NameFromLine (line, startIndex, commentChar)
|
export function NameFromLine (line, startIndex, commentChar)
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ export class ColorToMaterialConverter
|
|||||||
} else {
|
} else {
|
||||||
let material = new PhongMaterial ();
|
let material = new PhongMaterial ();
|
||||||
material.name = colorKey.toUpperCase ();
|
material.name = colorKey.toUpperCase ();
|
||||||
material.color = new Color (r, g, b);
|
material.color = new RGBColor (r, g, b);
|
||||||
if (hasAlpha && a < 255) {
|
if (hasAlpha && a < 255) {
|
||||||
material.opacity = a / 255.0;
|
material.opacity = a / 255.0;
|
||||||
UpdateMaterialTransparency (material);
|
UpdateMaterialTransparency (material);
|
||||||
|
|||||||
@ -43,7 +43,7 @@ import { ArrayBufferToUtf8String, ArrayBufferToAsciiString, AsciiStringToArrayBu
|
|||||||
import { SetExternalLibLocation, GetExternalLibPath, LoadExternalLibrary } from './io/externallibs.js';
|
import { SetExternalLibLocation, GetExternalLibPath, LoadExternalLibrary } from './io/externallibs.js';
|
||||||
import { GetFileName, GetFileExtension, RequestUrl, ReadFile, TransformFileHostUrls, IsUrl, FileSource, FileFormat } from './io/fileutils.js';
|
import { GetFileName, GetFileExtension, RequestUrl, ReadFile, TransformFileHostUrls, IsUrl, FileSource, FileFormat } from './io/fileutils.js';
|
||||||
import { TextWriter } from './io/textwriter.js';
|
import { TextWriter } from './io/textwriter.js';
|
||||||
import { Color, ColorComponentFromFloat, ColorFromFloatComponents, SRGBToLinear, LinearToSRGB, IntegerToHexString, ColorToHexString, HexStringToColor, ArrayToColor, ColorIsEqual } from './model/color.js';
|
import { RGBColor, ColorComponentFromFloat, RGBColorFromFloatComponents, SRGBToLinear, LinearToSRGB, IntegerToHexString, RGBColorToHexString, HexStringToRGBColor, ArrayToRGBColor, RGBColorIsEqual } from './model/color.js';
|
||||||
import { GeneratorParams, Generator, GeneratorHelper, GenerateCuboid, GenerateCone, GenerateCylinder, GenerateSphere, GeneratePlatonicSolid } from './model/generator.js';
|
import { GeneratorParams, Generator, GeneratorHelper, GenerateCuboid, GenerateCone, GenerateCylinder, GenerateSphere, GeneratePlatonicSolid } from './model/generator.js';
|
||||||
import { TextureMap, MaterialBase, FaceMaterial, PhongMaterial, PhysicalMaterial, TextureMapIsEqual, TextureIsEqual, MaterialType } from './model/material.js';
|
import { TextureMap, MaterialBase, FaceMaterial, PhongMaterial, PhysicalMaterial, TextureMapIsEqual, TextureIsEqual, MaterialType } from './model/material.js';
|
||||||
import { Mesh } from './model/mesh.js';
|
import { Mesh } from './model/mesh.js';
|
||||||
@ -199,16 +199,16 @@ export {
|
|||||||
FileSource,
|
FileSource,
|
||||||
FileFormat,
|
FileFormat,
|
||||||
TextWriter,
|
TextWriter,
|
||||||
Color,
|
RGBColor,
|
||||||
ColorComponentFromFloat,
|
ColorComponentFromFloat,
|
||||||
ColorFromFloatComponents,
|
RGBColorFromFloatComponents,
|
||||||
SRGBToLinear,
|
SRGBToLinear,
|
||||||
LinearToSRGB,
|
LinearToSRGB,
|
||||||
IntegerToHexString,
|
IntegerToHexString,
|
||||||
ColorToHexString,
|
RGBColorToHexString,
|
||||||
HexStringToColor,
|
HexStringToRGBColor,
|
||||||
ArrayToColor,
|
ArrayToRGBColor,
|
||||||
ColorIsEqual,
|
RGBColorIsEqual,
|
||||||
GeneratorParams,
|
GeneratorParams,
|
||||||
Generator,
|
Generator,
|
||||||
GeneratorHelper,
|
GeneratorHelper,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
export class Color
|
export class RGBColor
|
||||||
{
|
{
|
||||||
constructor (r, g, b)
|
constructor (r, g, b)
|
||||||
{
|
{
|
||||||
@ -16,7 +16,7 @@ export class Color
|
|||||||
|
|
||||||
Clone ()
|
Clone ()
|
||||||
{
|
{
|
||||||
return new Color (this.r, this.g, this.b);
|
return new RGBColor (this.r, this.g, this.b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,9 +25,9 @@ export function ColorComponentFromFloat (component)
|
|||||||
return parseInt (Math.round (component * 255.0), 10);
|
return parseInt (Math.round (component * 255.0), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ColorFromFloatComponents (r, g, b)
|
export function RGBColorFromFloatComponents (r, g, b)
|
||||||
{
|
{
|
||||||
return new Color (
|
return new RGBColor (
|
||||||
ColorComponentFromFloat (r),
|
ColorComponentFromFloat (r),
|
||||||
ColorComponentFromFloat (g),
|
ColorComponentFromFloat (g),
|
||||||
ColorComponentFromFloat (b)
|
ColorComponentFromFloat (b)
|
||||||
@ -61,7 +61,7 @@ export function IntegerToHexString (intVal)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ColorToHexString (color)
|
export function RGBColorToHexString (color)
|
||||||
{
|
{
|
||||||
let r = IntegerToHexString (color.r);
|
let r = IntegerToHexString (color.r);
|
||||||
let g = IntegerToHexString (color.g);
|
let g = IntegerToHexString (color.g);
|
||||||
@ -69,7 +69,7 @@ export function ColorToHexString (color)
|
|||||||
return r + g + b;
|
return r + g + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HexStringToColor (hexString)
|
export function HexStringToRGBColor (hexString)
|
||||||
{
|
{
|
||||||
if (hexString.length !== 6) {
|
if (hexString.length !== 6) {
|
||||||
return null;
|
return null;
|
||||||
@ -78,15 +78,15 @@ export function HexStringToColor (hexString)
|
|||||||
let r = parseInt (hexString.substring (0, 2), 16);
|
let r = parseInt (hexString.substring (0, 2), 16);
|
||||||
let g = parseInt (hexString.substring (2, 4), 16);
|
let g = parseInt (hexString.substring (2, 4), 16);
|
||||||
let b = parseInt (hexString.substring (4, 6), 16);
|
let b = parseInt (hexString.substring (4, 6), 16);
|
||||||
return new Color (r, g, b);
|
return new RGBColor (r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ArrayToColor (arr)
|
export function ArrayToRGBColor (arr)
|
||||||
{
|
{
|
||||||
return new Color (arr[0], arr[1], arr[2]);
|
return new RGBColor (arr[0], arr[1], arr[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ColorIsEqual (a, b)
|
export function RGBColorIsEqual (a, b)
|
||||||
{
|
{
|
||||||
return a.r === b.r && a.g === b.g && a.b === b.b;
|
return a.r === b.r && a.g === b.g && a.b === b.b;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Coord2D, CoordIsEqual2D } from '../geometry/coord2d.js';
|
import { Coord2D, CoordIsEqual2D } from '../geometry/coord2d.js';
|
||||||
import { IsEqual } from '../geometry/geometry.js';
|
import { IsEqual } from '../geometry/geometry.js';
|
||||||
import { Color, ColorIsEqual } from './color.js';
|
import { RGBColor, RGBColorIsEqual } from './color.js';
|
||||||
|
|
||||||
export class TextureMap
|
export class TextureMap
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ export class MaterialBase
|
|||||||
this.isDefault = false;
|
this.isDefault = false;
|
||||||
|
|
||||||
this.name = '';
|
this.name = '';
|
||||||
this.color = new Color (0, 0, 0);
|
this.color = new RGBColor (0, 0, 0);
|
||||||
|
|
||||||
this.vertexColors = false;
|
this.vertexColors = false;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ export class MaterialBase
|
|||||||
if (this.name !== rhs.name) {
|
if (this.name !== rhs.name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ColorIsEqual (this.color, rhs.color)) {
|
if (!RGBColorIsEqual (this.color, rhs.color)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.vertexColors !== rhs.vertexColors) {
|
if (this.vertexColors !== rhs.vertexColors) {
|
||||||
@ -110,7 +110,7 @@ export class FaceMaterial extends MaterialBase
|
|||||||
{
|
{
|
||||||
super (type);
|
super (type);
|
||||||
|
|
||||||
this.emissive = new Color (0, 0, 0);
|
this.emissive = new RGBColor (0, 0, 0);
|
||||||
|
|
||||||
this.opacity = 1.0; // 0.0 .. 1.0
|
this.opacity = 1.0; // 0.0 .. 1.0
|
||||||
this.transparent = false;
|
this.transparent = false;
|
||||||
@ -129,7 +129,7 @@ export class FaceMaterial extends MaterialBase
|
|||||||
if (!super.IsEqual (rhs)) {
|
if (!super.IsEqual (rhs)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ColorIsEqual (this.emissive, rhs.emissive)) {
|
if (!RGBColorIsEqual (this.emissive, rhs.emissive)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!IsEqual (this.opacity, rhs.opacity)) {
|
if (!IsEqual (this.opacity, rhs.opacity)) {
|
||||||
@ -166,8 +166,8 @@ export class PhongMaterial extends FaceMaterial
|
|||||||
{
|
{
|
||||||
super (MaterialType.Phong);
|
super (MaterialType.Phong);
|
||||||
|
|
||||||
this.ambient = new Color (0, 0, 0);
|
this.ambient = new RGBColor (0, 0, 0);
|
||||||
this.specular = new Color (0, 0, 0);
|
this.specular = new RGBColor (0, 0, 0);
|
||||||
this.shininess = 0.0; // 0.0 .. 1.0
|
this.shininess = 0.0; // 0.0 .. 1.0
|
||||||
this.specularMap = null;
|
this.specularMap = null;
|
||||||
}
|
}
|
||||||
@ -177,10 +177,10 @@ export class PhongMaterial extends FaceMaterial
|
|||||||
if (!super.IsEqual (rhs)) {
|
if (!super.IsEqual (rhs)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ColorIsEqual (this.ambient, rhs.ambient)) {
|
if (!RGBColorIsEqual (this.ambient, rhs.ambient)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ColorIsEqual (this.specular, rhs.specular)) {
|
if (!RGBColorIsEqual (this.specular, rhs.specular)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!IsEqual (this.shininess, rhs.shininess)) {
|
if (!IsEqual (this.shininess, rhs.shininess)) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Coord2D, CoordIsEqual2D } from '../geometry/coord2d.js';
|
import { Coord2D, CoordIsEqual2D } from '../geometry/coord2d.js';
|
||||||
import { CoordIsEqual3D } from '../geometry/coord3d.js';
|
import { CoordIsEqual3D } from '../geometry/coord3d.js';
|
||||||
import { Color, ColorIsEqual } from './color.js';
|
import { RGBColor, RGBColorIsEqual } from './color.js';
|
||||||
|
|
||||||
export class MeshPrimitiveBuffer
|
export class MeshPrimitiveBuffer
|
||||||
{
|
{
|
||||||
@ -75,7 +75,7 @@ export function ConvertMeshToMeshBuffer (mesh)
|
|||||||
if (colorIndex !== null) {
|
if (colorIndex !== null) {
|
||||||
return mesh.GetVertexColor (colorIndex);
|
return mesh.GetVertexColor (colorIndex);
|
||||||
} else if (forceColors) {
|
} else if (forceColors) {
|
||||||
return new Color (0, 0, 0);
|
return new RGBColor (0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ export function ConvertMeshToMeshBuffer (mesh)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let color = GetColorOrDefault (mesh, colorIndex, true);
|
let color = GetColorOrDefault (mesh, colorIndex, true);
|
||||||
return ColorIsEqual (existingColor, color);
|
return RGBColorIsEqual (existingColor, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsEqualNormal (mesh, normalIndex, existingNormal)
|
function IsEqualNormal (mesh, normalIndex, existingNormal)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { CopyObjectAttributes } from '../core/core.js';
|
import { CopyObjectAttributes } from '../core/core.js';
|
||||||
import { AddCoord3D, Coord3D, CoordIsEqual3D } from '../geometry/coord3d.js';
|
import { AddCoord3D, Coord3D, CoordIsEqual3D } from '../geometry/coord3d.js';
|
||||||
import { Color } from './color.js';
|
import { RGBColor } from './color.js';
|
||||||
import { PhongMaterial } from './material.js';
|
import { PhongMaterial } from './material.js';
|
||||||
import { CalculateTriangleNormal, GetMeshType, MeshType } from './meshutils.js';
|
import { CalculateTriangleNormal, GetMeshType, MeshType } from './meshutils.js';
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ class ModelFinalizer
|
|||||||
{
|
{
|
||||||
this.params = {
|
this.params = {
|
||||||
getDefaultMaterialColor : () => {
|
getDefaultMaterialColor : () => {
|
||||||
return new Color (0, 0, 0);
|
return new RGBColor (0, 0, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CopyObjectAttributes (params, this.params);
|
CopyObjectAttributes (params, this.params);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { EscapeHtmlChars } from '../core/core.js';
|
import { EscapeHtmlChars } from '../core/core.js';
|
||||||
import { ColorToHexString } from './color.js';
|
import { RGBColorToHexString } from './color.js';
|
||||||
|
|
||||||
export const PropertyType =
|
export const PropertyType =
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ export function PropertyToString (property)
|
|||||||
} else if (property.type === PropertyType.Percent) {
|
} else if (property.type === PropertyType.Percent) {
|
||||||
return parseInt (property.value * 100, 10).toString () + '%';
|
return parseInt (property.value * 100, 10).toString () + '%';
|
||||||
} else if (property.type === PropertyType.Color) {
|
} else if (property.type === PropertyType.Color) {
|
||||||
return '#' + ColorToHexString (property.value);
|
return '#' + RGBColorToHexString (property.value);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Coord3D } from '../geometry/coord3d.js';
|
import { Coord3D } from '../geometry/coord3d.js';
|
||||||
import { Color } from '../model/color.js';
|
import { RGBColor } from '../model/color.js';
|
||||||
import { Camera } from '../viewer/camera.js';
|
import { Camera } from '../viewer/camera.js';
|
||||||
|
|
||||||
export let ParameterConverter =
|
export let ParameterConverter =
|
||||||
@ -93,7 +93,7 @@ export let ParameterConverter =
|
|||||||
if (paramParts.length !== 3) {
|
if (paramParts.length !== 3) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let color = new Color (
|
let color = new RGBColor (
|
||||||
this.StringToInteger (paramParts[0]),
|
this.StringToInteger (paramParts[0]),
|
||||||
this.StringToInteger (paramParts[1]),
|
this.StringToInteger (paramParts[1]),
|
||||||
this.StringToInteger (paramParts[2])
|
this.StringToInteger (paramParts[2])
|
||||||
@ -153,7 +153,7 @@ export let ParameterConverter =
|
|||||||
}
|
}
|
||||||
let edgeSettings = {
|
let edgeSettings = {
|
||||||
showEdges : paramParts[0] === 'on' ? true : false,
|
showEdges : paramParts[0] === 'on' ? true : false,
|
||||||
edgeColor : new Color (
|
edgeColor : new RGBColor (
|
||||||
this.StringToInteger (paramParts[1]),
|
this.StringToInteger (paramParts[1]),
|
||||||
this.StringToInteger (paramParts[2]),
|
this.StringToInteger (paramParts[2]),
|
||||||
this.StringToInteger (paramParts[3])
|
this.StringToInteger (paramParts[3])
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Coord2D } from '../geometry/coord2d.js';
|
import { Coord2D } from '../geometry/coord2d.js';
|
||||||
import { Coord3D } from '../geometry/coord3d.js';
|
import { Coord3D } from '../geometry/coord3d.js';
|
||||||
import { ColorFromFloatComponents } from '../model/color.js';
|
import { RGBColorFromFloatComponents } from '../model/color.js';
|
||||||
import { MaterialType } from '../model/material.js';
|
import { MaterialType } from '../model/material.js';
|
||||||
import { Mesh } from '../model/mesh.js';
|
import { Mesh } from '../model/mesh.js';
|
||||||
import { Triangle } from '../model/triangle.js';
|
import { Triangle } from '../model/triangle.js';
|
||||||
@ -91,7 +91,7 @@ export function GetShadingType (model)
|
|||||||
|
|
||||||
export function ConvertThreeColorToColor (threeColor)
|
export function ConvertThreeColorToColor (threeColor)
|
||||||
{
|
{
|
||||||
return ColorFromFloatComponents (threeColor.r, threeColor.g, threeColor.b);
|
return RGBColorFromFloatComponents (threeColor.r, threeColor.g, threeColor.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ConvertColorToThreeColor (color)
|
export function ConvertColorToThreeColor (color)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Coord3D, CoordDistance3D, SubCoord3D } from '../geometry/coord3d.js';
|
import { Coord3D, CoordDistance3D, SubCoord3D } from '../geometry/coord3d.js';
|
||||||
import { Direction } from '../geometry/geometry.js';
|
import { Direction } from '../geometry/geometry.js';
|
||||||
import { ColorToHexString } from '../model/color.js';
|
import { RGBColorToHexString } from '../model/color.js';
|
||||||
import { ShadingType } from '../threejs/threeutils.js';
|
import { ShadingType } from '../threejs/threeutils.js';
|
||||||
import { Camera } from './camera.js';
|
import { Camera } from './camera.js';
|
||||||
import { GetDomElementInnerDimensions } from './domutils.js';
|
import { GetDomElementInnerDimensions } from './domutils.js';
|
||||||
@ -266,7 +266,7 @@ export class Viewer
|
|||||||
|
|
||||||
SetBackgroundColor (color)
|
SetBackgroundColor (color)
|
||||||
{
|
{
|
||||||
let hexColor = '#' + ColorToHexString (color);
|
let hexColor = '#' + RGBColorToHexString (color);
|
||||||
this.renderer.setClearColor (hexColor, 1.0);
|
this.renderer.setClearColor (hexColor, 1.0);
|
||||||
this.Render ();
|
this.Render ();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Color } from '../model/color.js';
|
import { RGBColor } from '../model/color.js';
|
||||||
import { ConvertColorToThreeColor } from '../threejs/threeutils.js';
|
import { ConvertColorToThreeColor } from '../threejs/threeutils.js';
|
||||||
|
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
@ -31,7 +31,7 @@ export class ViewerGeometry
|
|||||||
|
|
||||||
this.edgeSettings = {
|
this.edgeSettings = {
|
||||||
showEdges : false,
|
showEdges : false,
|
||||||
edgeColor : new Color (0, 0, 0),
|
edgeColor : new RGBColor (0, 0, 0),
|
||||||
edgeThreshold : 1
|
edgeThreshold : 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Color } from '../engine/model/color.js';
|
import { RGBColor } from '../engine/model/color.js';
|
||||||
import { CookieGetBoolVal, CookieGetColorVal, CookieGetIntVal, CookieGetStringVal, CookieSetBoolVal, CookieSetColorVal, CookieSetIntVal, CookieSetStringVal } from './cookiehandler.js';
|
import { CookieGetBoolVal, CookieGetColorVal, CookieGetIntVal, CookieGetStringVal, CookieSetBoolVal, CookieSetColorVal, CookieSetIntVal, CookieSetStringVal } from './cookiehandler.js';
|
||||||
|
|
||||||
export const Theme =
|
export const Theme =
|
||||||
@ -13,10 +13,10 @@ export class Settings
|
|||||||
{
|
{
|
||||||
this.environmentMapName = 'fishermans_bastion';
|
this.environmentMapName = 'fishermans_bastion';
|
||||||
this.backgroundIsEnvMap = false;
|
this.backgroundIsEnvMap = false;
|
||||||
this.backgroundColor = new Color (255, 255, 255);
|
this.backgroundColor = new RGBColor (255, 255, 255);
|
||||||
this.defaultColor = new Color (200, 200, 200);
|
this.defaultColor = new RGBColor (200, 200, 200);
|
||||||
this.showEdges = false;
|
this.showEdges = false;
|
||||||
this.edgeColor = new Color (0, 0, 0);
|
this.edgeColor = new RGBColor (0, 0, 0);
|
||||||
this.edgeThreshold = 1;
|
this.edgeThreshold = 1;
|
||||||
this.themeId = Theme.Light;
|
this.themeId = Theme.Light;
|
||||||
}
|
}
|
||||||
@ -25,10 +25,10 @@ export class Settings
|
|||||||
{
|
{
|
||||||
this.environmentMapName = CookieGetStringVal ('ov_environment_map', 'fishermans_bastion');
|
this.environmentMapName = CookieGetStringVal ('ov_environment_map', 'fishermans_bastion');
|
||||||
this.backgroundIsEnvMap = CookieGetBoolVal ('ov_background_is_envmap', false);
|
this.backgroundIsEnvMap = CookieGetBoolVal ('ov_background_is_envmap', false);
|
||||||
this.backgroundColor = CookieGetColorVal ('ov_background_color', new Color (255, 255, 255));
|
this.backgroundColor = CookieGetColorVal ('ov_background_color', new RGBColor (255, 255, 255));
|
||||||
this.defaultColor = CookieGetColorVal ('ov_default_color', new Color (200, 200, 200));
|
this.defaultColor = CookieGetColorVal ('ov_default_color', new RGBColor (200, 200, 200));
|
||||||
this.showEdges = CookieGetBoolVal ('ov_show_edges', false);
|
this.showEdges = CookieGetBoolVal ('ov_show_edges', false);
|
||||||
this.edgeColor = CookieGetColorVal ('ov_edge_color', new Color (0, 0, 0));
|
this.edgeColor = CookieGetColorVal ('ov_edge_color', new RGBColor (0, 0, 0));
|
||||||
this.edgeThreshold = CookieGetIntVal ('ov_edge_threshold', 1);
|
this.edgeThreshold = CookieGetIntVal ('ov_edge_threshold', 1);
|
||||||
this.themeId = CookieGetIntVal ('ov_theme_id', Theme.Light);
|
this.themeId = CookieGetIntVal ('ov_theme_id', Theme.Light);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { SidebarPanel } from './sidebarpanel.js';
|
|||||||
import { CreateInlineColorCircle } from './utils.js';
|
import { CreateInlineColorCircle } from './utils.js';
|
||||||
import { GetFileName, IsUrl } from '../engine/io/fileutils.js';
|
import { GetFileName, IsUrl } from '../engine/io/fileutils.js';
|
||||||
import { MaterialType } from '../engine/model/material.js';
|
import { MaterialType } from '../engine/model/material.js';
|
||||||
import { ColorToHexString } from '../engine/model/color.js';
|
import { RGBColorToHexString } from '../engine/model/color.js';
|
||||||
|
|
||||||
export class SidebarDetailsPanel extends SidebarPanel
|
export class SidebarDetailsPanel extends SidebarPanel
|
||||||
{
|
{
|
||||||
@ -167,7 +167,7 @@ export class SidebarDetailsPanel extends SidebarPanel
|
|||||||
valueHtml = PropertyToString (property);
|
valueHtml = PropertyToString (property);
|
||||||
}
|
}
|
||||||
} else if (property.type === PropertyType.Color) {
|
} else if (property.type === PropertyType.Color) {
|
||||||
let hexString = '#' + ColorToHexString (property.value);
|
let hexString = '#' + RGBColorToHexString (property.value);
|
||||||
let colorCircle = CreateInlineColorCircle (property.value);
|
let colorCircle = CreateInlineColorCircle (property.value);
|
||||||
targetDiv.appendChild (colorCircle);
|
targetDiv.appendChild (colorCircle);
|
||||||
AddDomElement (targetDiv, 'span', null, hexString);
|
AddDomElement (targetDiv, 'span', null, hexString);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Color, ColorToHexString } from '../engine/model/color.js';
|
import { RGBColor, RGBColorToHexString } from '../engine/model/color.js';
|
||||||
import { AddDiv, AddDomElement, ShowDomElement, SetDomElementOuterHeight } from '../engine/viewer/domutils.js';
|
import { AddDiv, AddDomElement, ShowDomElement, SetDomElementOuterHeight } from '../engine/viewer/domutils.js';
|
||||||
import { AddRangeSlider, AddToggle, AddCheckbox } from '../website/utils.js';
|
import { AddRangeSlider, AddToggle, AddCheckbox } from '../website/utils.js';
|
||||||
import { CalculatePopupPositionToElementTopLeft } from './dialogs.js';
|
import { CalculatePopupPositionToElementTopLeft } from './dialogs.js';
|
||||||
@ -15,7 +15,7 @@ function AddColorPicker (parentDiv, defaultColor, predefinedColors, onChange)
|
|||||||
position : 'left-start',
|
position : 'left-start',
|
||||||
swatches : predefinedColors,
|
swatches : predefinedColors,
|
||||||
comparison : false,
|
comparison : false,
|
||||||
default : '#' + ColorToHexString (defaultColor),
|
default : '#' + RGBColorToHexString (defaultColor),
|
||||||
components : {
|
components : {
|
||||||
preview : false,
|
preview : false,
|
||||||
opacity : false,
|
opacity : false,
|
||||||
@ -34,7 +34,7 @@ function AddColorPicker (parentDiv, defaultColor, predefinedColors, onChange)
|
|||||||
});
|
});
|
||||||
pickr.on ('change', (color, source, instance) => {
|
pickr.on ('change', (color, source, instance) => {
|
||||||
let rgbaColor = color.toRGBA ();
|
let rgbaColor = color.toRGBA ();
|
||||||
let ovColor = new Color (
|
let ovColor = new RGBColor (
|
||||||
parseInt (rgbaColor[0], 10),
|
parseInt (rgbaColor[0], 10),
|
||||||
parseInt (rgbaColor[1], 10),
|
parseInt (rgbaColor[1], 10),
|
||||||
parseInt (rgbaColor[2], 10)
|
parseInt (rgbaColor[2], 10)
|
||||||
@ -305,7 +305,7 @@ class SettingsModelDisplaySection extends SettingsSection
|
|||||||
Update (settings)
|
Update (settings)
|
||||||
{
|
{
|
||||||
if (this.backgroundColorPicker !== null) {
|
if (this.backgroundColorPicker !== null) {
|
||||||
this.backgroundColorPicker.setColor ('#' + ColorToHexString (settings.backgroundColor));
|
this.backgroundColorPicker.setColor ('#' + RGBColorToHexString (settings.backgroundColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.environmentMapPbrInput !== null || this.environmentMapPhongDiv !== null) {
|
if (this.environmentMapPbrInput !== null || this.environmentMapPhongDiv !== null) {
|
||||||
@ -316,7 +316,7 @@ class SettingsModelDisplaySection extends SettingsSection
|
|||||||
this.edgeDisplayToggle.SetStatus (settings.showEdges);
|
this.edgeDisplayToggle.SetStatus (settings.showEdges);
|
||||||
ShowDomElement (this.edgeSettingsDiv, settings.showEdges);
|
ShowDomElement (this.edgeSettingsDiv, settings.showEdges);
|
||||||
|
|
||||||
this.edgeColorPicker.setColor ('#' + ColorToHexString (settings.edgeColor));
|
this.edgeColorPicker.setColor ('#' + RGBColorToHexString (settings.edgeColor));
|
||||||
this.thresholdSlider.value = settings.edgeThreshold;
|
this.thresholdSlider.value = settings.edgeThreshold;
|
||||||
this.thresholdSliderValue.innerHTML = settings.edgeThreshold;
|
this.thresholdSliderValue.innerHTML = settings.edgeThreshold;
|
||||||
}
|
}
|
||||||
@ -362,7 +362,7 @@ class SettingsImportParametersSection extends SettingsSection
|
|||||||
Update (settings)
|
Update (settings)
|
||||||
{
|
{
|
||||||
if (this.defaultColorPicker !== null) {
|
if (this.defaultColorPicker !== null) {
|
||||||
this.defaultColorPicker.setColor ('#' + ColorToHexString (settings.defaultColor));
|
this.defaultColorPicker.setColor ('#' + RGBColorToHexString (settings.defaultColor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,11 +481,11 @@ export class SidebarSettingsPanel extends SidebarPanel
|
|||||||
this.appearanceSection.Init (this.settings, {
|
this.appearanceSection.Init (this.settings, {
|
||||||
onThemeChange : () => {
|
onThemeChange : () => {
|
||||||
if (this.settings.themeId === Theme.Light) {
|
if (this.settings.themeId === Theme.Light) {
|
||||||
this.settings.backgroundColor = new Color (255, 255, 255);
|
this.settings.backgroundColor = new RGBColor (255, 255, 255);
|
||||||
this.settings.defaultColor = new Color (200, 200, 200);
|
this.settings.defaultColor = new RGBColor (200, 200, 200);
|
||||||
} else if (this.settings.themeId === Theme.Dark) {
|
} else if (this.settings.themeId === Theme.Dark) {
|
||||||
this.settings.backgroundColor = new Color (42, 43, 46);
|
this.settings.backgroundColor = new RGBColor (42, 43, 46);
|
||||||
this.settings.defaultColor = new Color (200, 200, 200);
|
this.settings.defaultColor = new RGBColor (200, 200, 200);
|
||||||
}
|
}
|
||||||
this.modelDisplaySection.Update (this.settings);
|
this.modelDisplaySection.Update (this.settings);
|
||||||
this.importParametersSection.Update (this.settings);
|
this.importParametersSection.Update (this.settings);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Color, ColorToHexString } from '../engine/model/color.js';
|
import { RGBColor, RGBColorToHexString } from '../engine/model/color.js';
|
||||||
import { CreateObjectUrl } from '../engine/io/bufferutils.js';
|
import { CreateObjectUrl } from '../engine/io/bufferutils.js';
|
||||||
import { AddDiv, CreateDiv, AddDomElement, GetDomElementOuterWidth, SetDomElementOuterWidth } from '../engine/viewer/domutils.js';
|
import { AddDiv, CreateDiv, AddDomElement, GetDomElementOuterWidth, SetDomElementOuterWidth } from '../engine/viewer/domutils.js';
|
||||||
import { CreateVerticalSplitter } from './splitter.js';
|
import { CreateVerticalSplitter } from './splitter.js';
|
||||||
@ -143,13 +143,13 @@ export function SetSvgIconImageElement (iconElement, iconName)
|
|||||||
|
|
||||||
export function CreateInlineColorCircle (color)
|
export function CreateInlineColorCircle (color)
|
||||||
{
|
{
|
||||||
let hexString = '#' + ColorToHexString (color);
|
let hexString = '#' + RGBColorToHexString (color);
|
||||||
let darkerColor = new Color (
|
let darkerColor = new RGBColor (
|
||||||
Math.max (0, color.r - 50),
|
Math.max (0, color.r - 50),
|
||||||
Math.max (0, color.g - 50),
|
Math.max (0, color.g - 50),
|
||||||
Math.max (0, color.b - 50)
|
Math.max (0, color.b - 50)
|
||||||
);
|
);
|
||||||
let darkerColorHexString = '#' + ColorToHexString (darkerColor);
|
let darkerColorHexString = '#' + RGBColorToHexString (darkerColor);
|
||||||
let circleDiv = CreateDiv ('ov_color_circle');
|
let circleDiv = CreateDiv ('ov_color_circle');
|
||||||
circleDiv.style.background = hexString;
|
circleDiv.style.background = hexString;
|
||||||
circleDiv.style.border = '1px solid ' + darkerColorHexString;
|
circleDiv.style.border = '1px solid ' + darkerColorHexString;
|
||||||
|
|||||||
@ -10,9 +10,9 @@ function CreateTestModel ()
|
|||||||
|
|
||||||
let material1 = new OV.PhongMaterial ();
|
let material1 = new OV.PhongMaterial ();
|
||||||
material1.name = 'TestMaterial1';
|
material1.name = 'TestMaterial1';
|
||||||
material1.ambient = new OV.Color (0, 0, 0);
|
material1.ambient = new OV.RGBColor (0, 0, 0);
|
||||||
material1.color = new OV.Color (255, 0, 0);
|
material1.color = new OV.RGBColor (255, 0, 0);
|
||||||
material1.specular = new OV.Color (51, 51, 51);
|
material1.specular = new OV.RGBColor (51, 51, 51);
|
||||||
material1.diffuseMap = new OV.TextureMap ();
|
material1.diffuseMap = new OV.TextureMap ();
|
||||||
material1.diffuseMap.name = 'textures/texture1.png';
|
material1.diffuseMap.name = 'textures/texture1.png';
|
||||||
material1.diffuseMap.buffer = new ArrayBuffer (1);
|
material1.diffuseMap.buffer = new ArrayBuffer (1);
|
||||||
@ -26,9 +26,9 @@ function CreateTestModel ()
|
|||||||
|
|
||||||
let material2 = new OV.PhongMaterial ();
|
let material2 = new OV.PhongMaterial ();
|
||||||
material2.name = 'TestMaterial2';
|
material2.name = 'TestMaterial2';
|
||||||
material2.ambient = new OV.Color (0, 0, 0);
|
material2.ambient = new OV.RGBColor (0, 0, 0);
|
||||||
material2.color = new OV.Color (0, 255, 0);
|
material2.color = new OV.RGBColor (0, 255, 0);
|
||||||
material2.specular = new OV.Color (51, 51, 51);
|
material2.specular = new OV.RGBColor (51, 51, 51);
|
||||||
model.AddMaterial (material2);
|
model.AddMaterial (material2);
|
||||||
|
|
||||||
let mesh1 = new OV.Mesh ();
|
let mesh1 = new OV.Mesh ();
|
||||||
@ -217,7 +217,7 @@ describe ('Exporter', function () {
|
|||||||
let importer = new OV.ImporterStl ();
|
let importer = new OV.ImporterStl ();
|
||||||
importer.Import (stlFile.GetName (), 'stl', contentBuffer, {
|
importer.Import (stlFile.GetName (), 'stl', contentBuffer, {
|
||||||
getDefaultMaterialColor () {
|
getDefaultMaterialColor () {
|
||||||
return new OV.Color (0, 0, 0);
|
return new OV.RGBColor (0, 0, 0);
|
||||||
},
|
},
|
||||||
onSuccess () {
|
onSuccess () {
|
||||||
let importedModel = importer.GetModel ();
|
let importedModel = importer.GetModel ();
|
||||||
@ -311,7 +311,7 @@ describe ('Exporter', function () {
|
|||||||
let importer = new OV.ImporterPly ();
|
let importer = new OV.ImporterPly ();
|
||||||
importer.Import (plyFile.GetName (), 'ply', contentBuffer, {
|
importer.Import (plyFile.GetName (), 'ply', contentBuffer, {
|
||||||
getDefaultMaterialColor () {
|
getDefaultMaterialColor () {
|
||||||
return new OV.Color (0, 0, 0);
|
return new OV.RGBColor (0, 0, 0);
|
||||||
},
|
},
|
||||||
onSuccess () {
|
onSuccess () {
|
||||||
let importedModel = importer.GetModel ();
|
let importedModel = importer.GetModel ();
|
||||||
@ -341,7 +341,7 @@ describe ('Exporter', function () {
|
|||||||
let importer = new OV.ImporterGltf ();
|
let importer = new OV.ImporterGltf ();
|
||||||
importer.Import (gltfFile.GetName (), 'gltf', contentBuffer, {
|
importer.Import (gltfFile.GetName (), 'gltf', contentBuffer, {
|
||||||
getDefaultMaterialColor () {
|
getDefaultMaterialColor () {
|
||||||
return new OV.Color (0, 0, 0);
|
return new OV.RGBColor (0, 0, 0);
|
||||||
},
|
},
|
||||||
getFileBuffer (filePath) {
|
getFileBuffer (filePath) {
|
||||||
if (filePath == 'model.bin') {
|
if (filePath == 'model.bin') {
|
||||||
@ -376,7 +376,7 @@ describe ('Exporter', function () {
|
|||||||
let importer = new OV.ImporterGltf ();
|
let importer = new OV.ImporterGltf ();
|
||||||
importer.Import (glbFile.GetName (), 'glb', contentBuffer, {
|
importer.Import (glbFile.GetName (), 'glb', contentBuffer, {
|
||||||
getDefaultMaterialColor () {
|
getDefaultMaterialColor () {
|
||||||
return new OV.Color (0, 0, 0);
|
return new OV.RGBColor (0, 0, 0);
|
||||||
},
|
},
|
||||||
getFileBuffer (filePath) {
|
getFileBuffer (filePath) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -18,19 +18,19 @@ function CreateTestModel ()
|
|||||||
|
|
||||||
let phongMaterial = new OV.PhongMaterial ();
|
let phongMaterial = new OV.PhongMaterial ();
|
||||||
phongMaterial.name = 'Phong Material';
|
phongMaterial.name = 'Phong Material';
|
||||||
phongMaterial.emissive = new OV.Color (1, 1, 1);
|
phongMaterial.emissive = new OV.RGBColor (1, 1, 1);
|
||||||
phongMaterial.opacity = 0.1;
|
phongMaterial.opacity = 0.1;
|
||||||
phongMaterial.transparent = true;
|
phongMaterial.transparent = true;
|
||||||
phongMaterial.alphaTest = 0.2;
|
phongMaterial.alphaTest = 0.2;
|
||||||
phongMaterial.multiplyDiffuseMap = false;
|
phongMaterial.multiplyDiffuseMap = false;
|
||||||
phongMaterial.ambient = new OV.Color (2, 2, 2);
|
phongMaterial.ambient = new OV.RGBColor (2, 2, 2);
|
||||||
phongMaterial.specular = new OV.Color (3, 3, 3);
|
phongMaterial.specular = new OV.RGBColor (3, 3, 3);
|
||||||
phongMaterial.shininess = 0.3;
|
phongMaterial.shininess = 0.3;
|
||||||
model.AddMaterial (phongMaterial);
|
model.AddMaterial (phongMaterial);
|
||||||
|
|
||||||
let phongMaterialTexture = new OV.PhongMaterial ();
|
let phongMaterialTexture = new OV.PhongMaterial ();
|
||||||
phongMaterialTexture.name = 'Phong Material With Texture';
|
phongMaterialTexture.name = 'Phong Material With Texture';
|
||||||
phongMaterialTexture.emissive = new OV.Color (1, 1, 1);
|
phongMaterialTexture.emissive = new OV.RGBColor (1, 1, 1);
|
||||||
phongMaterialTexture.opacity = 0.1;
|
phongMaterialTexture.opacity = 0.1;
|
||||||
phongMaterialTexture.transparent = true;
|
phongMaterialTexture.transparent = true;
|
||||||
phongMaterialTexture.alphaTest = 0.2;
|
phongMaterialTexture.alphaTest = 0.2;
|
||||||
@ -39,15 +39,15 @@ function CreateTestModel ()
|
|||||||
phongMaterialTexture.bumpMap = CreateTexture ('bump.png', 'bump_url.png');
|
phongMaterialTexture.bumpMap = CreateTexture ('bump.png', 'bump_url.png');
|
||||||
phongMaterialTexture.normalMap = CreateTexture ('normal.png', 'normal_url.png');
|
phongMaterialTexture.normalMap = CreateTexture ('normal.png', 'normal_url.png');
|
||||||
phongMaterialTexture.emissiveMap = CreateTexture ('emissive.png', 'emissive_url.png');
|
phongMaterialTexture.emissiveMap = CreateTexture ('emissive.png', 'emissive_url.png');
|
||||||
phongMaterialTexture.ambient = new OV.Color (2, 2, 2);
|
phongMaterialTexture.ambient = new OV.RGBColor (2, 2, 2);
|
||||||
phongMaterialTexture.specular = new OV.Color (3, 3, 3);
|
phongMaterialTexture.specular = new OV.RGBColor (3, 3, 3);
|
||||||
phongMaterialTexture.shininess = 0.3;
|
phongMaterialTexture.shininess = 0.3;
|
||||||
phongMaterialTexture.specularMap = CreateTexture ('specular.png', 'specular_url.png');
|
phongMaterialTexture.specularMap = CreateTexture ('specular.png', 'specular_url.png');
|
||||||
model.AddMaterial (phongMaterialTexture);
|
model.AddMaterial (phongMaterialTexture);
|
||||||
|
|
||||||
let physicalMaterialTexture = new OV.PhysicalMaterial ();
|
let physicalMaterialTexture = new OV.PhysicalMaterial ();
|
||||||
physicalMaterialTexture.name = 'Phong Material With Texture';
|
physicalMaterialTexture.name = 'Phong Material With Texture';
|
||||||
physicalMaterialTexture.emissive = new OV.Color (1, 1, 1);
|
physicalMaterialTexture.emissive = new OV.RGBColor (1, 1, 1);
|
||||||
physicalMaterialTexture.opacity = 0.1;
|
physicalMaterialTexture.opacity = 0.1;
|
||||||
physicalMaterialTexture.transparent = true;
|
physicalMaterialTexture.transparent = true;
|
||||||
physicalMaterialTexture.alphaTest = 0.2;
|
physicalMaterialTexture.alphaTest = 0.2;
|
||||||
@ -240,7 +240,7 @@ describe ('Export-Import Vertex Colors Test', function () {
|
|||||||
mesh.AddVertex (new OV.Coord3D (0.0, 0.0, 0.0));
|
mesh.AddVertex (new OV.Coord3D (0.0, 0.0, 0.0));
|
||||||
mesh.AddVertex (new OV.Coord3D (1.0, 0.0, 0.0));
|
mesh.AddVertex (new OV.Coord3D (1.0, 0.0, 0.0));
|
||||||
mesh.AddVertex (new OV.Coord3D (1.0, 1.0, 0.0));
|
mesh.AddVertex (new OV.Coord3D (1.0, 1.0, 0.0));
|
||||||
mesh.AddVertexColor (new OV.Color (1.0, 0.0, 0.0));
|
mesh.AddVertexColor (new OV.RGBColor (1.0, 0.0, 0.0));
|
||||||
mesh.AddTriangle (new OV.Triangle (0, 1, 2).SetVertexColors (0, 0, 0));
|
mesh.AddTriangle (new OV.Triangle (0, 1, 2).SetVertexColors (0, 0, 0));
|
||||||
model.AddMeshToRootNode (mesh);
|
model.AddMeshToRootNode (mesh);
|
||||||
OV.FinalizeModel (model);
|
OV.FinalizeModel (model);
|
||||||
|
|||||||
@ -259,7 +259,7 @@ describe ('Importer Test', function () {
|
|||||||
];
|
];
|
||||||
let theImporter = new OV.Importer ();
|
let theImporter = new OV.Importer ();
|
||||||
let settings = new OV.ImportSettings ();
|
let settings = new OV.ImportSettings ();
|
||||||
settings.defaultColor = new OV.Color (200, 0, 0);
|
settings.defaultColor = new OV.RGBColor (200, 0, 0);
|
||||||
let inputFiles = OV.InputFilesFromFileObjects (files);
|
let inputFiles = OV.InputFilesFromFileObjects (files);
|
||||||
theImporter.ImportFiles (inputFiles, settings, {
|
theImporter.ImportFiles (inputFiles, settings, {
|
||||||
onFilesLoaded : function () {
|
onFilesLoaded : function () {
|
||||||
@ -270,7 +270,7 @@ describe ('Importer Test', function () {
|
|||||||
assert.deepStrictEqual (importResult.usedFiles, ['single_triangle.stl']);
|
assert.deepStrictEqual (importResult.usedFiles, ['single_triangle.stl']);
|
||||||
assert.deepStrictEqual (importResult.missingFiles, []);
|
assert.deepStrictEqual (importResult.missingFiles, []);
|
||||||
let material = importResult.model.GetMaterial (0);
|
let material = importResult.model.GetMaterial (0);
|
||||||
assert.deepStrictEqual (material.color, new OV.Color (200, 0, 0));
|
assert.deepStrictEqual (material.color, new OV.RGBColor (200, 0, 0));
|
||||||
done ();
|
done ();
|
||||||
},
|
},
|
||||||
onImportError : function (importError) {
|
onImportError : function (importError) {
|
||||||
|
|||||||
@ -219,7 +219,7 @@ describe ('Off Importer', function () {
|
|||||||
it ('rectangle_face_colors_int.off', function (done) {
|
it ('rectangle_face_colors_int.off', function (done) {
|
||||||
ImportOffFile ('rectangle_face_colors_int.off', function (model) {
|
ImportOffFile ('rectangle_face_colors_int.off', function (model) {
|
||||||
assert.ok (OV.CheckModel (model));
|
assert.ok (OV.CheckModel (model));
|
||||||
assert.ok (OV.ColorIsEqual (model.GetMaterial (0).color, new OV.Color (255, 0, 0)));
|
assert.ok (OV.RGBColorIsEqual (model.GetMaterial (0).color, new OV.RGBColor (255, 0, 0)));
|
||||||
assert.strictEqual (model.GetMaterial (0).vertexColors, false);
|
assert.strictEqual (model.GetMaterial (0).vertexColors, false);
|
||||||
assert.deepStrictEqual (ModelToObject (model), {
|
assert.deepStrictEqual (ModelToObject (model), {
|
||||||
name : '',
|
name : '',
|
||||||
@ -253,7 +253,7 @@ describe ('Off Importer', function () {
|
|||||||
it ('rectangle_face_colors_int.off', function (done) {
|
it ('rectangle_face_colors_int.off', function (done) {
|
||||||
ImportOffFile ('rectangle_face_colors_float.off', function (model) {
|
ImportOffFile ('rectangle_face_colors_float.off', function (model) {
|
||||||
assert.ok (OV.CheckModel (model));
|
assert.ok (OV.CheckModel (model));
|
||||||
assert.ok (OV.ColorIsEqual (model.GetMaterial (0).color, new OV.Color (255, 0, 0)));
|
assert.ok (OV.RGBColorIsEqual (model.GetMaterial (0).color, new OV.RGBColor (255, 0, 0)));
|
||||||
assert.strictEqual (model.GetMaterial (0).vertexColors, false);
|
assert.strictEqual (model.GetMaterial (0).vertexColors, false);
|
||||||
assert.deepStrictEqual (ModelToObject (model), {
|
assert.deepStrictEqual (ModelToObject (model), {
|
||||||
name : '',
|
name : '',
|
||||||
|
|||||||
@ -40,8 +40,8 @@ describe ('Mesh Buffer', function () {
|
|||||||
mesh.AddVertex (new OV.Coord3D (1.0, 1.0, 0.0));
|
mesh.AddVertex (new OV.Coord3D (1.0, 1.0, 0.0));
|
||||||
mesh.AddVertex (new OV.Coord3D (0.0, 1.0, 0.0));
|
mesh.AddVertex (new OV.Coord3D (0.0, 1.0, 0.0));
|
||||||
|
|
||||||
mesh.AddVertexColor (new OV.Color (0.1, 0.0, 0.0));
|
mesh.AddVertexColor (new OV.RGBColor (0.1, 0.0, 0.0));
|
||||||
mesh.AddVertexColor (new OV.Color (0.2, 0.0, 0.0));
|
mesh.AddVertexColor (new OV.RGBColor (0.2, 0.0, 0.0));
|
||||||
|
|
||||||
mesh.AddNormal (new OV.Coord3D (0.0, 0.0, 1.0));
|
mesh.AddNormal (new OV.Coord3D (0.0, 0.0, 1.0));
|
||||||
mesh.AddTriangle (new OV.Triangle (0, 1, 2).SetVertexColors (0, 0, 0).SetNormals (0, 0, 0).SetMaterial (0));
|
mesh.AddTriangle (new OV.Triangle (0, 1, 2).SetVertexColors (0, 0, 0).SetNormals (0, 0, 0).SetMaterial (0));
|
||||||
|
|||||||
@ -223,17 +223,17 @@ describe ('Model Finalization', function () {
|
|||||||
|
|
||||||
describe ('Color Conversion', function () {
|
describe ('Color Conversion', function () {
|
||||||
it ('Color equality check', function () {
|
it ('Color equality check', function () {
|
||||||
assert.ok (OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (10, 20, 30)));
|
assert.ok (OV.RGBColorIsEqual (new OV.RGBColor (10, 20, 30), new OV.RGBColor (10, 20, 30)));
|
||||||
assert.ok (!OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (11, 20, 30)));
|
assert.ok (!OV.RGBColorIsEqual (new OV.RGBColor (10, 20, 30), new OV.RGBColor (11, 20, 30)));
|
||||||
assert.ok (!OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (10, 21, 30)));
|
assert.ok (!OV.RGBColorIsEqual (new OV.RGBColor (10, 20, 30), new OV.RGBColor (10, 21, 30)));
|
||||||
assert.ok (!OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (10, 20, 31)));
|
assert.ok (!OV.RGBColorIsEqual (new OV.RGBColor (10, 20, 30), new OV.RGBColor (10, 20, 31)));
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('Color hex string conversion', function () {
|
it ('Color hex string conversion', function () {
|
||||||
let color = new OV.Color (10, 20, 30);
|
let color = new OV.RGBColor (10, 20, 30);
|
||||||
let hexString = '0a141e';
|
let hexString = '0a141e';
|
||||||
assert.strictEqual (OV.ColorToHexString (color), hexString);
|
assert.strictEqual (OV.RGBColorToHexString (color), hexString);
|
||||||
assert.deepStrictEqual (OV.HexStringToColor (hexString), color);
|
assert.deepStrictEqual (OV.HexStringToRGBColor (hexString), color);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -12,8 +12,8 @@ describe ('Parameter List', function () {
|
|||||||
new OV.Coord3D (0.0, 0.0, 0.0),
|
new OV.Coord3D (0.0, 0.0, 0.0),
|
||||||
new OV.Coord3D (0.0, 0.0, 1.0)
|
new OV.Coord3D (0.0, 0.0, 1.0)
|
||||||
);
|
);
|
||||||
let background = new OV.Color (4, 5, 6);
|
let background = new OV.RGBColor (4, 5, 6);
|
||||||
let color = new OV.Color (1, 2, 3);
|
let color = new OV.RGBColor (1, 2, 3);
|
||||||
let urlParams1 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).GetParameterList ();
|
let urlParams1 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).GetParameterList ();
|
||||||
let urlParams2 = OV.CreateUrlBuilder ().AddCamera (camera).GetParameterList ();
|
let urlParams2 = OV.CreateUrlBuilder ().AddCamera (camera).GetParameterList ();
|
||||||
let urlParams3 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).GetParameterList ();
|
let urlParams3 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).GetParameterList ();
|
||||||
@ -21,7 +21,7 @@ describe ('Parameter List', function () {
|
|||||||
let urlParams5 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).AddBackgroundColor (background).AddDefaultColor (color).GetParameterList ();
|
let urlParams5 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).AddBackgroundColor (background).AddDefaultColor (color).GetParameterList ();
|
||||||
let urlParams6 = OV.CreateUrlBuilder ().AddEdgeSettings ({
|
let urlParams6 = OV.CreateUrlBuilder ().AddEdgeSettings ({
|
||||||
showEdges : true,
|
showEdges : true,
|
||||||
edgeColor : new OV.Color (1, 2, 3),
|
edgeColor : new OV.RGBColor (1, 2, 3),
|
||||||
edgeThreshold : 15
|
edgeThreshold : 15
|
||||||
}).GetParameterList ();
|
}).GetParameterList ();
|
||||||
assert.strictEqual (urlParams1, 'model=a.txt,b.txt');
|
assert.strictEqual (urlParams1, 'model=a.txt,b.txt');
|
||||||
@ -39,8 +39,8 @@ describe ('Parameter List', function () {
|
|||||||
new OV.Coord3D (0.0, 0.0, 0.0),
|
new OV.Coord3D (0.0, 0.0, 0.0),
|
||||||
new OV.Coord3D (0.0, 0.0, 1.0)
|
new OV.Coord3D (0.0, 0.0, 1.0)
|
||||||
);
|
);
|
||||||
let background = new OV.Color (4, 5, 6);
|
let background = new OV.RGBColor (4, 5, 6);
|
||||||
let color = new OV.Color (1, 2, 3);
|
let color = new OV.RGBColor (1, 2, 3);
|
||||||
let urlParamsLegacy = 'a.txt,b.txt';
|
let urlParamsLegacy = 'a.txt,b.txt';
|
||||||
let urlParams1 = 'model=a.txt,b.txt';
|
let urlParams1 = 'model=a.txt,b.txt';
|
||||||
let urlParams2 = 'camera=1.0000,1.0000,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000';
|
let urlParams2 = 'camera=1.0000,1.0000,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000';
|
||||||
@ -75,7 +75,7 @@ describe ('Parameter List', function () {
|
|||||||
let parser6 = OV.CreateUrlParser (urlParams6);
|
let parser6 = OV.CreateUrlParser (urlParams6);
|
||||||
assert.deepStrictEqual (parser6.GetEdgeSettings (), {
|
assert.deepStrictEqual (parser6.GetEdgeSettings (), {
|
||||||
showEdges : true,
|
showEdges : true,
|
||||||
edgeColor : new OV.Color (1, 2, 3),
|
edgeColor : new OV.RGBColor (1, 2, 3),
|
||||||
edgeThreshold : 15
|
edgeThreshold : 15
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -73,7 +73,7 @@ describe ('Property Test', function () {
|
|||||||
group1.AddProperty (new OV.Property (OV.PropertyType.Text, 'name 01', 'value 01'));
|
group1.AddProperty (new OV.Property (OV.PropertyType.Text, 'name 01', 'value 01'));
|
||||||
group2.AddProperty (new OV.Property (OV.PropertyType.Integer, 'name 02', 2));
|
group2.AddProperty (new OV.Property (OV.PropertyType.Integer, 'name 02', 2));
|
||||||
group3.AddProperty (new OV.Property (OV.PropertyType.Number, 'name 03', 3.5));
|
group3.AddProperty (new OV.Property (OV.PropertyType.Number, 'name 03', 3.5));
|
||||||
group3.AddProperty (new OV.Property (OV.PropertyType.Color, 'name 04', new OV.Color (10, 20, 30)));
|
group3.AddProperty (new OV.Property (OV.PropertyType.Color, 'name 04', new OV.RGBColor (10, 20, 30)));
|
||||||
mesh.AddPropertyGroup (group1);
|
mesh.AddPropertyGroup (group1);
|
||||||
mesh.AddPropertyGroup (group2);
|
mesh.AddPropertyGroup (group2);
|
||||||
mesh.AddPropertyGroup (group3);
|
mesh.AddPropertyGroup (group3);
|
||||||
@ -90,8 +90,8 @@ describe ('Property Test', function () {
|
|||||||
assert.strictEqual (cloned.GetPropertyGroup (2).GetProperty (0).value, 3.5);
|
assert.strictEqual (cloned.GetPropertyGroup (2).GetProperty (0).value, 3.5);
|
||||||
assert.strictEqual (cloned.GetPropertyGroup (2).GetProperty (1).name, 'name 04');
|
assert.strictEqual (cloned.GetPropertyGroup (2).GetProperty (1).name, 'name 04');
|
||||||
assert.strictEqual (
|
assert.strictEqual (
|
||||||
OV.ColorToHexString (cloned.GetPropertyGroup (2).GetProperty (1).value),
|
OV.RGBColorToHexString (cloned.GetPropertyGroup (2).GetProperty (1).value),
|
||||||
OV.ColorToHexString (new OV.Color (10, 20, 30))
|
OV.RGBColorToHexString (new OV.RGBColor (10, 20, 30))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ describe ('Property Test', function () {
|
|||||||
assert.strictEqual (OV.PropertyToString (new OV.Property (OV.PropertyType.Boolean, 'name', true)), 'True');
|
assert.strictEqual (OV.PropertyToString (new OV.Property (OV.PropertyType.Boolean, 'name', true)), 'True');
|
||||||
assert.strictEqual (OV.PropertyToString (new OV.Property (OV.PropertyType.Boolean, 'name', false)), 'False');
|
assert.strictEqual (OV.PropertyToString (new OV.Property (OV.PropertyType.Boolean, 'name', false)), 'False');
|
||||||
assert.strictEqual (OV.PropertyToString (new OV.Property (OV.PropertyType.Percent, 'name', 0.2)), '20%');
|
assert.strictEqual (OV.PropertyToString (new OV.Property (OV.PropertyType.Percent, 'name', 0.2)), '20%');
|
||||||
assert.strictEqual (OV.PropertyToString (new OV.Property (OV.PropertyType.Color, 'color', new OV.Color (10, 20, 20))), '#0a1414');
|
assert.strictEqual (OV.PropertyToString (new OV.Property (OV.PropertyType.Color, 'color', new OV.RGBColor (10, 20, 20))), '#0a1414');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export function ImportFile (importer, folder, fileName, onReady)
|
|||||||
});
|
});
|
||||||
importer.Import (fileName, extension, content, {
|
importer.Import (fileName, extension, content, {
|
||||||
getDefaultMaterialColor () {
|
getDefaultMaterialColor () {
|
||||||
return new OV.Color (0, 0, 0);
|
return new OV.RGBColor (0, 0, 0);
|
||||||
},
|
},
|
||||||
getFileBuffer : function (filePath) {
|
getFileBuffer : function (filePath) {
|
||||||
return fileAccessor.GetFileBuffer (filePath);
|
return fileAccessor.GetFileBuffer (filePath);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user