diff --git a/sandbox/embed_edges.html b/sandbox/embed_edges.html index 822e9ff..8a16d89 100644 --- a/sandbox/embed_edges.html +++ b/sandbox/embed_edges.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_filehost.html b/sandbox/embed_filehost.html index a89d2c5..e2ddf1a 100644 --- a/sandbox/embed_filehost.html +++ b/sandbox/embed_filehost.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_selfhost_code.html b/sandbox/embed_selfhost_code.html index 3d013c5..8ea5a23 100644 --- a/sandbox/embed_selfhost_code.html +++ b/sandbox/embed_selfhost_code.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_selfhost_errors.html b/sandbox/embed_selfhost_errors.html index 424e6f1..ec2b1f3 100644 --- a/sandbox/embed_selfhost_errors.html +++ b/sandbox/embed_selfhost_errors.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_selfhost_externallibs.html b/sandbox/embed_selfhost_externallibs.html index 45d7ee8..e9a9b98 100644 --- a/sandbox/embed_selfhost_externallibs.html +++ b/sandbox/embed_selfhost_externallibs.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_selfhost_fullscreen.html b/sandbox/embed_selfhost_fullscreen.html index 974ac38..15976f6 100644 --- a/sandbox/embed_selfhost_fullscreen.html +++ b/sandbox/embed_selfhost_fullscreen.html @@ -27,6 +27,7 @@ + diff --git a/sandbox/embed_selfhost_manual.html b/sandbox/embed_selfhost_manual.html index 11d95e5..0c3b263 100644 --- a/sandbox/embed_selfhost_manual.html +++ b/sandbox/embed_selfhost_manual.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_selfhost_multiple.html b/sandbox/embed_selfhost_multiple.html index 4017fbb..a4488dc 100644 --- a/sandbox/embed_selfhost_multiple.html +++ b/sandbox/embed_selfhost_multiple.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_selfhost_multiple_2.html b/sandbox/embed_selfhost_multiple_2.html index 0161412..05c80be 100644 --- a/sandbox/embed_selfhost_multiple_2.html +++ b/sandbox/embed_selfhost_multiple_2.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_selfhost_single.html b/sandbox/embed_selfhost_single.html index 62bcb67..6387cbd 100644 --- a/sandbox/embed_selfhost_single.html +++ b/sandbox/embed_selfhost_single.html @@ -27,6 +27,7 @@ + diff --git a/sandbox/embed_selfhost_single_scroll.html b/sandbox/embed_selfhost_single_scroll.html index b54e8ff..aba3521 100644 --- a/sandbox/embed_selfhost_single_scroll.html +++ b/sandbox/embed_selfhost_single_scroll.html @@ -27,6 +27,7 @@ + diff --git a/source/model/color.js b/source/model/color.js new file mode 100644 index 0000000..5799c29 --- /dev/null +++ b/source/model/color.js @@ -0,0 +1,78 @@ +OV.Color = class +{ + constructor (r, g, b) + { + this.r = r; // 0 .. 255 + this.g = g; // 0 .. 255 + this.b = b; // 0 .. 255 + } + + Set (r, g, b) + { + this.r = r; + this.g = g; + this.b = b; + } + + Clone () + { + return new OV.Color (this.r, this.g, this.b); + } +}; + +OV.SRGBToLinear = function (component) +{ + if (component < 0.04045) { + return component * 0.0773993808; + } else { + return Math.pow (component * 0.9478672986 + 0.0521327014, 2.4); + } +}; + +OV.LinearToSRGB = function (component) +{ + if (component < 0.0031308) { + return component * 12.92; + } else { + return 1.055 * (Math.pow (component, 0.41666)) - 0.055; + } +}; + +OV.IntegerToHexString = function (intVal) +{ + let result = parseInt (intVal, 10).toString (16); + while (result.length < 2) { + result = '0' + result; + } + return result; +}; + +OV.ColorToHexString = function (color) +{ + let r = OV.IntegerToHexString (color.r); + let g = OV.IntegerToHexString (color.g); + let b = OV.IntegerToHexString (color.b); + return r + g + b; +}; + +OV.HexStringToColor = function (hexString) +{ + if (hexString.length !== 6) { + return null; + } + + let r = parseInt (hexString.substr (0, 2), 16); + let g = parseInt (hexString.substr (2, 2), 16); + let b = parseInt (hexString.substr (4, 2), 16); + return new OV.Color (r, g, b); +}; + +OV.ArrayToColor = function (arr) +{ + return new OV.Color (arr[0], arr[1], arr[2]); +}; + +OV.ColorIsEqual = function (a, b) +{ + return a.r === b.r && a.g === b.g && a.b === b.b; +}; diff --git a/source/model/material.js b/source/model/material.js index 305ffc2..a32d634 100644 --- a/source/model/material.js +++ b/source/model/material.js @@ -1,25 +1,3 @@ -OV.Color = class -{ - constructor (r, g, b) - { - this.r = r; // 0 .. 255 - this.g = g; // 0 .. 255 - this.b = b; // 0 .. 255 - } - - Set (r, g, b) - { - this.r = r; - this.g = g; - this.b = b; - } - - Clone () - { - return new OV.Color (this.r, this.g, this.b); - } -}; - OV.TextureMap = class { constructor () @@ -275,63 +253,6 @@ OV.PhysicalMaterial = class extends OV.FaceMaterial } }; -OV.SRGBToLinear = function (component) -{ - if (component < 0.04045) { - return component * 0.0773993808; - } else { - return Math.pow (component * 0.9478672986 + 0.0521327014, 2.4); - } -}; - -OV.LinearToSRGB = function (component) -{ - if (component < 0.0031308) { - return component * 12.92; - } else { - return 1.055 * (Math.pow (component, 0.41666)) - 0.055; - } -}; - -OV.IntegerToHexString = function (intVal) -{ - let result = parseInt (intVal, 10).toString (16); - while (result.length < 2) { - result = '0' + result; - } - return result; -}; - -OV.ColorToHexString = function (color) -{ - let r = OV.IntegerToHexString (color.r); - let g = OV.IntegerToHexString (color.g); - let b = OV.IntegerToHexString (color.b); - return r + g + b; -}; - -OV.HexStringToColor = function (hexString) -{ - if (hexString.length !== 6) { - return null; - } - - let r = parseInt (hexString.substr (0, 2), 16); - let g = parseInt (hexString.substr (2, 2), 16); - let b = parseInt (hexString.substr (4, 2), 16); - return new OV.Color (r, g, b); -}; - -OV.ArrayToColor = function (arr) -{ - return new OV.Color (arr[0], arr[1], arr[2]); -}; - -OV.ColorIsEqual = function (a, b) -{ - return a.r === b.r && a.g === b.g && a.b === b.b; -}; - OV.TextureIsEqual = function (a, b) { if (a.name !== b.name) { diff --git a/tools/config.json b/tools/config.json index 6efb90b..0c40066 100644 --- a/tools/config.json +++ b/tools/config.json @@ -18,6 +18,7 @@ "source/io/bufferutils.js", "source/io/fileutils.js", "source/io/externallibs.js", + "source/model/color.js", "source/model/material.js", "source/model/triangle.js", "source/model/property.js", diff --git a/website/embed.html b/website/embed.html index 0205247..47c16fd 100644 --- a/website/embed.html +++ b/website/embed.html @@ -34,6 +34,7 @@ + diff --git a/website/index.html b/website/index.html index e2eef97..25b049b 100644 --- a/website/index.html +++ b/website/index.html @@ -36,6 +36,7 @@ +