Browse Source

use low-power

Gregg Tavares 7 years ago
parent
commit
387bf77c8b

+ 5 - 1
threejs/lessons/resources/threejs-lesson-utils.js

@@ -6,7 +6,11 @@ window.threejsLessonUtils = {
       return;
     }
     const canvas = document.querySelector('#c');
-    const renderer = new THREE.WebGLRenderer({canvas: canvas, alpha: true});
+    const renderer = new THREE.WebGLRenderer({
+      canvas: canvas,
+      alpha: true,
+      powerPreference: 'low-power',
+    });
     this.pixelRatio = Math.max(2, window.devicePixelRatio);
 
     this.renderer = renderer;

+ 5 - 1
threejs/resources/threejs-lessons-helper.js

@@ -894,7 +894,11 @@
         if (isWebGL) {
           setupLesson(this);
         }
-        const ctx = oldFn.apply(this, arguments);
+        const args = [].slice.apply(arguments);
+        args[1] = Object.assign({
+          powerPreference: 'low-power',
+        }, args[1]);
+        const ctx = oldFn.apply(this, args);
         if (!ctx && isWebGL) {
           showNeedWebGL(this);
         }