Comparing version 3.0.9 to 3.1.0
@@ -28,7 +28,9 @@ /** @module gl-util/context */ | ||
attrs: 'attributes attrs contextAttributes', | ||
pixelRatio: 'pixelRatio pxRatio px ratio pxratio pixelratio' | ||
pixelRatio: 'pixelRatio pxRatio px ratio pxratio pixelratio', | ||
width: 'w width', | ||
height: 'h height' | ||
}, true) | ||
} | ||
if (!o.pixelRatio) o.pixelRatio = window.pixelRatio || 1 | ||
if (!o.pixelRatio) o.pixelRatio = global.pixelRatio || 1 | ||
@@ -60,6 +62,11 @@ // make sure there is container and canvas | ||
else if (!o.canvas) { | ||
o.container = document.body || document.documentElement | ||
o.canvas = createCanvas() | ||
o.container.appendChild(o.canvas) | ||
resize(o) | ||
if (typeof document !== 'undefined') { | ||
o.container = document.body || document.documentElement | ||
o.canvas = createCanvas() | ||
o.container.appendChild(o.canvas) | ||
resize(o) | ||
} | ||
else { | ||
throw Error('Not DOM environment. Use headless-gl.') | ||
} | ||
} | ||
@@ -88,4 +95,4 @@ | ||
if (o.container == document.body) { | ||
if (!document.body.style.width) o.canvas.width = o.width || (o.pixelRatio * window.innerWidth) | ||
if (!document.body.style.height) o.canvas.height = o.height || (o.pixelRatio * window.innerHeight) | ||
if (!document.body.style.width) o.canvas.width = o.width || (o.pixelRatio * global.innerWidth) | ||
if (!document.body.style.height) o.canvas.height = o.height || (o.pixelRatio * global.innerHeight) | ||
} | ||
@@ -92,0 +99,0 @@ else { |
{ | ||
"name": "gl-util", | ||
"version": "3.0.9", | ||
"version": "3.1.0", | ||
"description": "Set of practical webgl utils", | ||
@@ -34,4 +34,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"gl": "^4.1.1", | ||
"tape": "^4.9.1" | ||
} | ||
} |
@@ -5,4 +5,8 @@ 'use strict' | ||
let context = require('../context') | ||
let isBrowser = require('is-browser') | ||
let createGl = require('gl') | ||
t('context over context', t => { | ||
if (!isBrowser) return t.end() | ||
let gl = context() | ||
@@ -16,2 +20,3 @@ | ||
t('context container as string', t => { | ||
if (!isBrowser) return t.end() | ||
let canvas = document.body.appendChild(document.createElement('canvas')) | ||
@@ -25,1 +30,9 @@ canvas.id = 'canvas' | ||
}) | ||
t('headless', t => { | ||
let gl = context(createGl(10, 10)) | ||
t.equal(gl, context(gl)) | ||
t.end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31105
763
2