From edd2245915d9d440c6c344b37bf3cc4e2b1fcf2c Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sat, 5 Jun 2021 09:15:12 +0200 Subject: [PATCH] Comment to explain checker code. --- source/external/threemodelloader.js | 1 - source/external/threeutils.js | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/external/threemodelloader.js b/source/external/threemodelloader.js index 2bef725..76653f2 100644 --- a/source/external/threemodelloader.js +++ b/source/external/threemodelloader.js @@ -75,7 +75,6 @@ OV.ThreeModelLoader = class let obj = this; this.callbacks.onVisualizationStart (); let params = new OV.ModelToThreeConversionParams (); - // https://github.com/kovacsv/Online3DViewer/issues/69 params.forceMediumpForMaterials = this.hasHighpDriverIssue; OV.ConvertModelToThreeMeshes (importResult.model, params, { onTextureLoaded : function () { diff --git a/source/external/threeutils.js b/source/external/threeutils.js index 9dc9c6c..f2e1759 100644 --- a/source/external/threeutils.js +++ b/source/external/threeutils.js @@ -1,3 +1,7 @@ +// Some mobile devices say that they support mediump, but in reality they don't. At the end +// all materials rendered as black. This hack renders a single plane with red material and +// it checks if it's really red. If it's not, then probably there is a driver issue. +// https://github.com/kovacsv/Online3DViewer/issues/69 OV.HasHighpDriverIssue = function () { let canvas = document.createElement ('canvas'); @@ -43,7 +47,9 @@ OV.HasHighpDriverIssue = function () ); document.body.removeChild (canvas); - if (pixels[0] < 50 && pixels[1] < 50 && pixels[2] < 50) { + + let blackThreshold = 50; + if (pixels[0] < blackThreshold && pixels[1] < blackThreshold && pixels[2] < blackThreshold) { return true; } return false;