From 48972f79b3af5b61b410e17a7b444aa9ed7e9e57 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Wed, 12 Nov 2014 14:13:22 +0100 Subject: [PATCH] fixed interpolation material extension test --- .../PointCloudRGBInterpolationMaterial.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/materials/PointCloudRGBInterpolationMaterial.js b/src/materials/PointCloudRGBInterpolationMaterial.js index a602577b..e60a8e2d 100644 --- a/src/materials/PointCloudRGBInterpolationMaterial.js +++ b/src/materials/PointCloudRGBInterpolationMaterial.js @@ -13,17 +13,17 @@ Potree.PointCloudRGBInterpolationMaterial = function(parameters){ var pointSize = parameters.size || 1.0; var minSize = parameters.minSize || 2.0; + // check of extension is enabled and fallback if it's not. var vs; var fs; - var frag_depth_ext = renderer.context.getExtension('EXT_frag_depth'); - if(!frag_depth_ext){ - vs = Potree.PointCloudRGBMaterial.vs_points.join("\n"); - fs = Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n"); - }else{ + if(Potree.PointCloudRGBInterpolationMaterial.isSupported()){ vs = Potree.PointCloudRGBInterpolationMaterial.vs_points.join("\n"); fs = Potree.PointCloudRGBInterpolationMaterial.fs_points_rgb.join("\n"); + }else{ + vs = Potree.PointCloudRGBMaterial.vs_points.join("\n"); + fs = Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n"); } - + this.setValues({ uniforms: uniforms, attributes: attributes, @@ -38,6 +38,17 @@ Potree.PointCloudRGBInterpolationMaterial = function(parameters){ Potree.PointCloudRGBInterpolationMaterial.prototype = new THREE.ShaderMaterial(); +Potree.PointCloudRGBInterpolationMaterial.isSupported = function(){ + var canvas = document.createElement('canvas'); + var context = canvas.getContext('webgl'); + if(context){ + var frag_depth_ext = context.getExtension('EXT_frag_depth'); + return frag_depth_ext; + }else{ + return false; + } +} + Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype, "size", { get: function(){ return this.uniforms.size.value;