@luma.gl/webgl 9.0.0-alpha.6 → 9.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +13 -4
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/typed-array-utils.d.ts +1 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/{create-context.d.ts → create-browser-context.d.ts} +1 -1
- package/dist/context/context/create-browser-context.d.ts.map +1 -0
- package/dist/context/context/{create-context.js → create-browser-context.js} +1 -1
- package/dist/context/context/create-browser-context.js.map +1 -0
- package/dist/context/context/create-headless-context.d.ts +9 -0
- package/dist/context/context/create-headless-context.d.ts.map +1 -0
- package/dist/context/context/create-headless-context.js +43 -0
- package/dist/context/context/create-headless-context.js.map +1 -0
- package/dist/es5/adapter/webgl-device.js +14 -4
- package/dist/es5/adapter/webgl-device.js.map +1 -1
- package/dist/es5/classic/typed-array-utils.js.map +1 -1
- package/dist/es5/context/context/{create-context.js → create-browser-context.js} +1 -1
- package/dist/es5/context/context/create-browser-context.js.map +1 -0
- package/dist/es5/context/context/create-headless-context.js +60 -0
- package/dist/es5/context/context/create-headless-context.js.map +1 -0
- package/dist/es5/index.js +8 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/types/webgl.js.map +1 -1
- package/dist/esm/adapter/webgl-device.js +13 -4
- package/dist/esm/adapter/webgl-device.js.map +1 -1
- package/dist/esm/classic/typed-array-utils.js.map +1 -1
- package/dist/esm/context/context/{create-context.js → create-browser-context.js} +1 -1
- package/dist/esm/context/context/create-browser-context.js.map +1 -0
- package/dist/esm/context/context/create-headless-context.js +43 -0
- package/dist/esm/context/context/create-headless-context.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/webgl.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/webgl.d.ts +1 -1
- package/dist/types/webgl.d.ts.map +1 -1
- package/dist/types/webgl.js.map +1 -1
- package/package.json +4 -7
- package/src/adapter/webgl-device.ts +16 -4
- package/src/classic/typed-array-utils.ts +3 -1
- package/src/context/context/{create-context.ts → create-browser-context.ts} +0 -0
- package/src/context/context/create-headless-context.ts +48 -0
- package/src/index.ts +2 -0
- package/src/types/webgl.ts +1 -1
- package/dist/context/context/create-context.d.ts.map +0 -1
- package/dist/context/context/create-context.js.map +0 -1
- package/dist/es5/context/context/create-context.js.map +0 -1
- package/dist/esm/context/context/create-context.js.map +0 -1
package/dist/types/webgl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/webgl.ts"],"names":["GL"],"mappings":"AACA,OAAOA,EAAP,MAAe,oBAAf","sourcesContent":["import type {NumberArray} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\ntype Framebuffer = any;\n\nexport type GLDrawMode =\n | GL.POINTS\n | GL.LINES\n | GL.LINE_STRIP\n | GL.LINE_LOOP\n | GL.TRIANGLES\n | GL.TRIANGLE_STRIP\n | GL.TRIANGLE_FAN;\n\nexport type GLPrimitive = GL.POINTS | GL.LINES | GL.TRIANGLES;\n\nexport type GLType =\n | GL.FLOAT\n | GL.UNSIGNED_SHORT\n | GL.UNSIGNED_INT\n | GL.UNSIGNED_BYTE\n | GL.BYTE\n | GL.SHORT\n | GL.INT;\n\nexport type GLPackedType =\n | GL.UNSIGNED_SHORT_5_6_5\n | GL.UNSIGNED_SHORT_4_4_4_4\n | GL.UNSIGNED_SHORT_5_5_5_1;\n\nexport type GLUniformType = GLSamplerType | GLCompositeType;\n\nexport type GLSamplerType =\n | GL.SAMPLER_2D\n | GL.SAMPLER_CUBE\n | GL.SAMPLER_3D\n | GL.SAMPLER_2D_SHADOW\n | GL.SAMPLER_2D_ARRAY\n | GL.SAMPLER_2D_ARRAY_SHADOW\n | GL.SAMPLER_CUBE_SHADOW\n | GL.INT_SAMPLER_2D\n | GL.INT_SAMPLER_3D\n | GL.INT_SAMPLER_CUBE\n | GL.INT_SAMPLER_2D_ARRAY\n | GL.UNSIGNED_INT_SAMPLER_2D\n | GL.UNSIGNED_INT_SAMPLER_3D\n | GL.UNSIGNED_INT_SAMPLER_CUBE\n | GL.UNSIGNED_INT_SAMPLER_2D_ARRAY;\n\n// Composite types table\nexport type GLCompositeType =\n | GL.FLOAT\n | GL.FLOAT_VEC2\n | GL.FLOAT_VEC3\n | GL.FLOAT_VEC4\n | GL.INT\n | GL.INT_VEC2\n | GL.INT_VEC3\n | GL.INT_VEC4\n | GL.UNSIGNED_INT\n | GL.UNSIGNED_INT_VEC2\n | GL.UNSIGNED_INT_VEC3\n | GL.UNSIGNED_INT_VEC4\n | GL.BOOL\n | GL.BOOL_VEC2\n | GL.BOOL_VEC3\n | GL.BOOL_VEC4\n | GL.FLOAT_MAT2\n | GL.FLOAT_MAT2x3\n | GL.FLOAT_MAT2x4\n | GL.FLOAT_MAT3x2\n | GL.FLOAT_MAT3\n | GL.FLOAT_MAT3x4\n | GL.FLOAT_MAT4x2\n | GL.FLOAT_MAT4x3\n | GL.FLOAT_MAT4;\n\nexport type GLFunction =\n | GL.NEVER\n | GL.LESS\n | GL.EQUAL\n | GL.LEQUAL\n | GL.GREATER\n | GL.NOTEQUAL\n | GL.GEQUAL\n | GL.ALWAYS;\n\nexport type GLBlendEquation =\n | GL.FUNC_ADD\n | GL.FUNC_SUBTRACT\n | GL.FUNC_REVERSE_SUBTRACT\n | GL.MIN_EXT\n | GL.MAX_EXT;\n\nexport type GLBlendFunction =\n | GL.ZERO\n | GL.ONE\n | GL.SRC_COLOR\n | GL.ONE_MINUS_SRC_COLOR\n | GL.DST_COLOR\n | GL.ONE_MINUS_DST_COLOR\n | GL.SRC_ALPHA\n | GL.ONE_MINUS_SRC_ALPHA\n | GL.DST_ALPHA\n | GL.ONE_MINUS_DST_ALPHA\n | GL.CONSTANT_COLOR\n | GL.ONE_MINUS_CONSTANT_COLOR\n | GL.CONSTANT_ALPHA\n | GL.ONE_MINUS_CONSTANT_ALPHA\n | GL.SRC_ALPHA_SATURATE;\n\nexport type GLStencilOp =\n | GL.KEEP\n | GL.ZERO\n | GL.REPLACE\n | GL.INCR\n | GL.INCR_WRAP\n | GL.DECR\n | GL.DECR_WRAP\n | GL.INVERT;\n\n/** Parameters for textures and samplers */\nexport type GLSamplerParameters = {\n [GL.TEXTURE_WRAP_S]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_WRAP_T]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_WRAP_R]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_MAG_FILTER]?: GL.NEAREST | GL.LINEAR;\n [GL.TEXTURE_MIN_FILTER]?:\n | GL.NEAREST\n | GL.LINEAR\n | GL.NEAREST_MIPMAP_NEAREST\n | GL.NEAREST_MIPMAP_LINEAR\n | GL.LINEAR_MIPMAP_NEAREST\n | GL.LINEAR_MIPMAP_LINEAR;\n [GL.TEXTURE_MIN_LOD]?: number;\n [GL.TEXTURE_MAX_LOD]?: number;\n [GL.TEXTURE_COMPARE_FUNC]?: number; // COMPARE_FUNC);\n [GL.TEXTURE_COMPARE_MODE]?: GL.COMPARE_REF_TO_TEXTURE;\n [GL.TEXTURE_MAX_ANISOTROPY_EXT]?: number; //\n};\n\n/**\n * All global WebGL values set by a variety of setter gl.enable ...\n */\nexport type GLValueParameters = {\n [GL.BLEND]?: boolean;\n [GL.BLEND_COLOR]?: [number, number, number, number] | NumberArray;\n [GL.BLEND_EQUATION_RGB]?: GLBlendEquation;\n [GL.BLEND_EQUATION_ALPHA]?: GLBlendEquation;\n [GL.BLEND_SRC_RGB]?: GLBlendFunction;\n [GL.BLEND_DST_RGB]?: GLBlendFunction;\n [GL.BLEND_SRC_ALPHA]?: GLBlendFunction;\n [GL.BLEND_DST_ALPHA]?: GLBlendFunction;\n [GL.COLOR_CLEAR_VALUE]?: [number, number, number, number] | NumberArray;\n [GL.COLOR_WRITEMASK]?: [boolean, boolean, boolean, boolean] | boolean[];\n [GL.CULL_FACE]?: boolean;\n [GL.CULL_FACE_MODE]?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;\n [GL.DEPTH_TEST]?: boolean;\n [GL.DEPTH_CLEAR_VALUE]?: number;\n [GL.DEPTH_FUNC]?: GLFunction;\n [GL.DEPTH_RANGE]?: [number, number] | NumberArray;\n [GL.DEPTH_WRITEMASK]?: boolean;\n [GL.DITHER]?: boolean;\n [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n [GL.CURRENT_PROGRAM]?: WebGLProgram | null;\n [GL.FRAMEBUFFER_BINDING]?: WebGLFramebuffer | null;\n [GL.RENDERBUFFER_BINDING]?: WebGLRenderbuffer | null;\n [GL.TRANSFORM_FEEDBACK_BINDING]?: WebGLTransformFeedback | null;\n [GL.VERTEX_ARRAY_BINDING]?: WebGLVertexArrayObject | null;\n [GL.ARRAY_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.COPY_READ_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.COPY_WRITE_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.PIXEL_PACK_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.PIXEL_UNPACK_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.TEXTURE_BINDING_2D]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_2D_ARRAY]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_3D]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_CUBE_MAP]?: WebGLTexture | null;\n [GL.FRONT_FACE]?: GL.CW | GL.CCW;\n [GL.GENERATE_MIPMAP_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n [GL.LINE_WIDTH]?: number;\n [GL.POLYGON_OFFSET_FILL]?: boolean;\n [GL.POLYGON_OFFSET_FACTOR]?: number;\n [GL.POLYGON_OFFSET_UNITS]?: number;\n [GL.SAMPLE_ALPHA_TO_COVERAGE]?: boolean;\n [GL.SAMPLE_COVERAGE]?: boolean;\n [GL.RASTERIZER_DISCARD]?: boolean;\n [GL.SAMPLE_COVERAGE_VALUE]?: number;\n [GL.SAMPLE_COVERAGE_INVERT]?: boolean;\n [GL.SCISSOR_TEST]?: boolean;\n [GL.SCISSOR_BOX]?: [number, number, number, number] | NumberArray;\n [GL.STENCIL_TEST]?: boolean;\n [GL.STENCIL_CLEAR_VALUE]?: number;\n [GL.STENCIL_WRITEMASK]?: number;\n [GL.STENCIL_BACK_WRITEMASK]?: number;\n [GL.STENCIL_FUNC]?: GLFunction;\n [GL.STENCIL_REF]?: GLFunction;\n [GL.STENCIL_VALUE_MASK]?: GLFunction;\n [GL.STENCIL_BACK_FUNC]?: GLFunction;\n [GL.STENCIL_BACK_REF]?: GLFunction;\n [GL.STENCIL_BACK_VALUE_MASK]?: GLFunction;\n [GL.STENCIL_FAIL]?: GLStencilOp;\n [GL.STENCIL_PASS_DEPTH_FAIL]?: GLStencilOp;\n [GL.STENCIL_PASS_DEPTH_PASS]?: GLStencilOp;\n [GL.STENCIL_BACK_FAIL]?: GLStencilOp;\n [GL.STENCIL_BACK_PASS_DEPTH_FAIL]?: GLStencilOp;\n [GL.STENCIL_BACK_PASS_DEPTH_PASS]?: GLStencilOp;\n [GL.VIEWPORT]?: [number, number, number, number] | NumberArray;\n\n // WEBGL1 PIXEL PACK/UNPACK MODES\n [GL.PACK_ALIGNMENT]?: number;\n [GL.UNPACK_ALIGNMENT]?: number;\n [GL.UNPACK_FLIP_Y_WEBGL]?: boolean;\n [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?: boolean;\n [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]?: GL.NONE | GL.BROWSER_DEFAULT_WEBGL;\n\n // WEBGL2 PIXEL PACK/UNPACK MODES\n // RASTERIZER_DISCARD ...\n [GL.PACK_ROW_LENGTH]?: number;\n [GL.PACK_SKIP_PIXELS]?: number;\n [GL.PACK_SKIP_ROWS]?: number;\n [GL.READ_FRAMEBUFFER_BINDING]?: Framebuffer | null;\n [GL.UNPACK_ROW_LENGTH]?: number;\n [GL.UNPACK_IMAGE_HEIGHT]?: number;\n [GL.UNPACK_SKIP_PIXELS]?: number;\n [GL.UNPACK_SKIP_ROWS]?: number;\n [GL.UNPACK_SKIP_IMAGES]?: number;\n};\n\nexport type GLFunctionParameters = {\n // Function-style setters\n framebuffer?: Framebuffer | null;\n blend?: boolean;\n blendColor?: [number, number, number, number] | NumberArray;\n blendEquation?: GLBlendEquation | [GLBlendEquation, GLBlendEquation];\n blendFunc?:\n | [GLBlendFunction, GLBlendFunction]\n | [GLBlendFunction, GLBlendFunction, GLBlendFunction, GLBlendFunction];\n\n clearColor?: [number, number, number, number] | NumberArray;\n clearDepth?: number;\n clearStencil?: number;\n\n colorMask?: [boolean, boolean, boolean, boolean];\n\n cull?: boolean;\n cullFace?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;\n\n depthTest?: boolean;\n depthFunc?: GLFunction;\n depthMask?: boolean;\n depthRange?: [number, number] | NumberArray;\n\n dither?: boolean;\n\n derivativeHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n\n frontFace?: GL.CW | GL.CCW;\n\n mipmapHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n\n lineWidth?: number;\n\n polygonOffsetFill?: boolean;\n polygonOffset?: [number, number];\n\n sampleCoverage?: [number, boolean];\n\n scissorTest?: boolean;\n scissor?: [number, number, number, number] | NumberArray;\n\n stencilTest?: boolean;\n stencilMask?: number | [number, number];\n stencilFunc?:\n | [GLFunction, number, number]\n | [GLFunction, number, number, GLFunction, number, number];\n stencilOp?:\n | [GLStencilOp, GLStencilOp, GLStencilOp]\n | [GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp];\n viewport?: [number, number, number, number] | NumberArray;\n};\n\n/** WebGL style parameters object (with both GL constants and function style fields) */\nexport type GLParameters = GLValueParameters & GLFunctionParameters;\n"],"file":"webgl.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/types/webgl.ts"],"names":["GL"],"mappings":"AACA,OAAOA,EAAP,MAAe,oBAAf","sourcesContent":["import type {NumberArray} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\ntype Framebuffer = any;\n\nexport type GLDrawMode =\n | GL.POINTS\n | GL.LINES\n | GL.LINE_STRIP\n | GL.LINE_LOOP\n | GL.TRIANGLES\n | GL.TRIANGLE_STRIP\n | GL.TRIANGLE_FAN;\n\nexport type GLPrimitive = GL.POINTS | GL.LINES | GL.TRIANGLES;\n\nexport type GLType =\n | GL.FLOAT\n | GL.UNSIGNED_SHORT\n | GL.UNSIGNED_INT\n | GL.UNSIGNED_BYTE\n | GL.BYTE\n | GL.SHORT\n | GL.INT;\n\nexport type GLPackedType =\n | GL.UNSIGNED_SHORT_5_6_5\n | GL.UNSIGNED_SHORT_4_4_4_4\n | GL.UNSIGNED_SHORT_5_5_5_1;\n\nexport type GLUniformType = GLSamplerType | GLCompositeType;\n\nexport type GLSamplerType =\n | GL.SAMPLER_2D\n | GL.SAMPLER_CUBE\n | GL.SAMPLER_3D\n | GL.SAMPLER_2D_SHADOW\n | GL.SAMPLER_2D_ARRAY\n | GL.SAMPLER_2D_ARRAY_SHADOW\n | GL.SAMPLER_CUBE_SHADOW\n | GL.INT_SAMPLER_2D\n | GL.INT_SAMPLER_3D\n | GL.INT_SAMPLER_CUBE\n | GL.INT_SAMPLER_2D_ARRAY\n | GL.UNSIGNED_INT_SAMPLER_2D\n | GL.UNSIGNED_INT_SAMPLER_3D\n | GL.UNSIGNED_INT_SAMPLER_CUBE\n | GL.UNSIGNED_INT_SAMPLER_2D_ARRAY;\n\n// Composite types table\nexport type GLCompositeType =\n | GL.FLOAT\n | GL.FLOAT_VEC2\n | GL.FLOAT_VEC3\n | GL.FLOAT_VEC4\n | GL.INT\n | GL.INT_VEC2\n | GL.INT_VEC3\n | GL.INT_VEC4\n | GL.UNSIGNED_INT\n | GL.UNSIGNED_INT_VEC2\n | GL.UNSIGNED_INT_VEC3\n | GL.UNSIGNED_INT_VEC4\n | GL.BOOL\n | GL.BOOL_VEC2\n | GL.BOOL_VEC3\n | GL.BOOL_VEC4\n | GL.FLOAT_MAT2\n | GL.FLOAT_MAT2x3\n | GL.FLOAT_MAT2x4\n | GL.FLOAT_MAT3x2\n | GL.FLOAT_MAT3\n | GL.FLOAT_MAT3x4\n | GL.FLOAT_MAT4x2\n | GL.FLOAT_MAT4x3\n | GL.FLOAT_MAT4;\n\nexport type GLFunction =\n | GL.NEVER\n | GL.LESS\n | GL.EQUAL\n | GL.LEQUAL\n | GL.GREATER\n | GL.NOTEQUAL\n | GL.GEQUAL\n | GL.ALWAYS;\n\nexport type GLBlendEquation =\n | GL.FUNC_ADD\n | GL.FUNC_SUBTRACT\n | GL.FUNC_REVERSE_SUBTRACT\n | GL.MIN_EXT\n | GL.MAX_EXT;\n\nexport type GLBlendFunction =\n | GL.ZERO\n | GL.ONE\n | GL.SRC_COLOR\n | GL.ONE_MINUS_SRC_COLOR\n | GL.DST_COLOR\n | GL.ONE_MINUS_DST_COLOR\n | GL.SRC_ALPHA\n | GL.ONE_MINUS_SRC_ALPHA\n | GL.DST_ALPHA\n | GL.ONE_MINUS_DST_ALPHA\n | GL.CONSTANT_COLOR\n | GL.ONE_MINUS_CONSTANT_COLOR\n | GL.CONSTANT_ALPHA\n | GL.ONE_MINUS_CONSTANT_ALPHA\n | GL.SRC_ALPHA_SATURATE;\n\nexport type GLStencilOp =\n | GL.KEEP\n | GL.ZERO\n | GL.REPLACE\n | GL.INCR\n | GL.INCR_WRAP\n | GL.DECR\n | GL.DECR_WRAP\n | GL.INVERT;\n\n/** Parameters for textures and samplers */\nexport type GLSamplerParameters = {\n [GL.TEXTURE_WRAP_S]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_WRAP_T]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_WRAP_R]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_MAG_FILTER]?: GL.NEAREST | GL.LINEAR;\n [GL.TEXTURE_MIN_FILTER]?:\n | GL.NEAREST\n | GL.LINEAR\n | GL.NEAREST_MIPMAP_NEAREST\n | GL.NEAREST_MIPMAP_LINEAR\n | GL.LINEAR_MIPMAP_NEAREST\n | GL.LINEAR_MIPMAP_LINEAR;\n [GL.TEXTURE_MIN_LOD]?: number;\n [GL.TEXTURE_MAX_LOD]?: number;\n [GL.TEXTURE_COMPARE_FUNC]?: number; // COMPARE_FUNC);\n [GL.TEXTURE_COMPARE_MODE]?: GL.COMPARE_REF_TO_TEXTURE;\n [GL.TEXTURE_MAX_ANISOTROPY_EXT]?: number; //\n};\n\n/**\n * All global WebGL values set by a variety of setter gl.enable ...\n */\nexport type GLValueParameters = {\n [GL.BLEND]?: boolean;\n [GL.BLEND_COLOR]?: [number, number, number, number] | NumberArray;\n [GL.BLEND_EQUATION_RGB]?: GLBlendEquation;\n [GL.BLEND_EQUATION_ALPHA]?: GLBlendEquation;\n [GL.BLEND_SRC_RGB]?: GLBlendFunction;\n [GL.BLEND_DST_RGB]?: GLBlendFunction;\n [GL.BLEND_SRC_ALPHA]?: GLBlendFunction;\n [GL.BLEND_DST_ALPHA]?: GLBlendFunction;\n [GL.COLOR_CLEAR_VALUE]?: [number, number, number, number] | NumberArray;\n [GL.COLOR_WRITEMASK]?: [boolean, boolean, boolean, boolean] | boolean[];\n [GL.CULL_FACE]?: boolean;\n [GL.CULL_FACE_MODE]?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;\n [GL.DEPTH_TEST]?: boolean;\n [GL.DEPTH_CLEAR_VALUE]?: number;\n [GL.DEPTH_FUNC]?: GLFunction;\n [GL.DEPTH_RANGE]?: [number, number] | NumberArray;\n [GL.DEPTH_WRITEMASK]?: boolean;\n [GL.DITHER]?: boolean;\n [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n [GL.CURRENT_PROGRAM]?: WebGLProgram | null;\n [GL.FRAMEBUFFER_BINDING]?: WebGLFramebuffer | null;\n [GL.RENDERBUFFER_BINDING]?: WebGLRenderbuffer | null;\n [GL.TRANSFORM_FEEDBACK_BINDING]?: WebGLTransformFeedback | null;\n [GL.VERTEX_ARRAY_BINDING]?: WebGLVertexArrayObject | null;\n [GL.ARRAY_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.COPY_READ_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.COPY_WRITE_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.PIXEL_PACK_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.PIXEL_UNPACK_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.TEXTURE_BINDING_2D]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_2D_ARRAY]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_3D]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_CUBE_MAP]?: WebGLTexture | null;\n [GL.FRONT_FACE]?: GL.CW | GL.CCW;\n [GL.GENERATE_MIPMAP_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n [GL.LINE_WIDTH]?: number;\n [GL.POLYGON_OFFSET_FILL]?: boolean;\n [GL.POLYGON_OFFSET_FACTOR]?: number;\n [GL.POLYGON_OFFSET_UNITS]?: number;\n [GL.SAMPLE_ALPHA_TO_COVERAGE]?: boolean;\n [GL.SAMPLE_COVERAGE]?: boolean;\n [GL.RASTERIZER_DISCARD]?: boolean;\n [GL.SAMPLE_COVERAGE_VALUE]?: number;\n [GL.SAMPLE_COVERAGE_INVERT]?: boolean;\n [GL.SCISSOR_TEST]?: boolean;\n [GL.SCISSOR_BOX]?: [number, number, number, number] | NumberArray;\n [GL.STENCIL_TEST]?: boolean;\n [GL.STENCIL_CLEAR_VALUE]?: number;\n [GL.STENCIL_WRITEMASK]?: number;\n [GL.STENCIL_BACK_WRITEMASK]?: number;\n [GL.STENCIL_FUNC]?: GLFunction;\n [GL.STENCIL_REF]?: GLFunction;\n [GL.STENCIL_VALUE_MASK]?: GLFunction;\n [GL.STENCIL_BACK_FUNC]?: GLFunction;\n [GL.STENCIL_BACK_REF]?: GLFunction;\n [GL.STENCIL_BACK_VALUE_MASK]?: GLFunction;\n [GL.STENCIL_FAIL]?: GLStencilOp;\n [GL.STENCIL_PASS_DEPTH_FAIL]?: GLStencilOp;\n [GL.STENCIL_PASS_DEPTH_PASS]?: GLStencilOp;\n [GL.STENCIL_BACK_FAIL]?: GLStencilOp;\n [GL.STENCIL_BACK_PASS_DEPTH_FAIL]?: GLStencilOp;\n [GL.STENCIL_BACK_PASS_DEPTH_PASS]?: GLStencilOp;\n [GL.VIEWPORT]?: [number, number, number, number] | NumberArray;\n\n // WEBGL1 PIXEL PACK/UNPACK MODES\n [GL.PACK_ALIGNMENT]?: number;\n [GL.UNPACK_ALIGNMENT]?: number;\n [GL.UNPACK_FLIP_Y_WEBGL]?: boolean;\n [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?: boolean;\n [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]?: GL.NONE | GL.BROWSER_DEFAULT_WEBGL;\n\n // WEBGL2 PIXEL PACK/UNPACK MODES\n // RASTERIZER_DISCARD ...\n [GL.PACK_ROW_LENGTH]?: number;\n [GL.PACK_SKIP_PIXELS]?: number;\n [GL.PACK_SKIP_ROWS]?: number;\n [GL.READ_FRAMEBUFFER_BINDING]?: Framebuffer | null;\n [GL.UNPACK_ROW_LENGTH]?: number;\n [GL.UNPACK_IMAGE_HEIGHT]?: number;\n [GL.UNPACK_SKIP_PIXELS]?: number;\n [GL.UNPACK_SKIP_ROWS]?: number;\n [GL.UNPACK_SKIP_IMAGES]?: number;\n};\n\nexport type GLFunctionParameters = {\n // Function-style setters\n framebuffer?: Framebuffer | null;\n blend?: boolean;\n blendColor?: [number, number, number, number] | NumberArray;\n blendEquation?: GLBlendEquation | [GLBlendEquation, GLBlendEquation];\n blendFunc?:\n | [GLBlendFunction, GLBlendFunction]\n | [GLBlendFunction, GLBlendFunction, GLBlendFunction, GLBlendFunction];\n\n clearColor?: [number, number, number, number] | NumberArray;\n clearDepth?: number;\n clearStencil?: number;\n\n colorMask?: [boolean, boolean, boolean, boolean] | boolean[];\n\n cull?: boolean;\n cullFace?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;\n\n depthTest?: boolean;\n depthFunc?: GLFunction;\n depthMask?: boolean;\n depthRange?: [number, number] | NumberArray;\n\n dither?: boolean;\n\n derivativeHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n\n frontFace?: GL.CW | GL.CCW;\n\n mipmapHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n\n lineWidth?: number;\n\n polygonOffsetFill?: boolean;\n polygonOffset?: [number, number];\n\n sampleCoverage?: [number, boolean];\n\n scissorTest?: boolean;\n scissor?: [number, number, number, number] | NumberArray;\n\n stencilTest?: boolean;\n stencilMask?: number | [number, number];\n stencilFunc?:\n | [GLFunction, number, number]\n | [GLFunction, number, number, GLFunction, number, number];\n stencilOp?:\n | [GLStencilOp, GLStencilOp, GLStencilOp]\n | [GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp];\n viewport?: [number, number, number, number] | NumberArray;\n};\n\n/** WebGL style parameters object (with both GL constants and function style fields) */\nexport type GLParameters = GLValueParameters & GLFunctionParameters;\n"],"file":"webgl.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.7",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,12 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
|
-
"@luma.gl/api": "9.0.0-alpha.
|
|
39
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
38
|
+
"@luma.gl/api": "9.0.0-alpha.7",
|
|
39
|
+
"@luma.gl/constants": "9.0.0-alpha.7",
|
|
40
40
|
"@probe.gl/env": "^3.5.0"
|
|
41
41
|
},
|
|
42
|
-
"
|
|
43
|
-
"@luma.gl/test-utils": "9.0.0-alpha.6"
|
|
44
|
-
},
|
|
45
|
-
"gitHead": "d4a92477c1d76f6242ec0fe377e238669e0667c0"
|
|
42
|
+
"gitHead": "c1fbf71bb1311dcdc54338d82d299f8ed0d73346"
|
|
46
43
|
}
|
|
@@ -12,7 +12,8 @@ import {isBrowser} from '@probe.gl/env';
|
|
|
12
12
|
import {polyfillContext} from '../context/polyfill/polyfill-context';
|
|
13
13
|
import {trackContextState} from '../context/state-tracker/track-context-state';
|
|
14
14
|
import {ContextState} from '../context/context/context-state';
|
|
15
|
-
import {createBrowserContext} from '../context/context/create-context';
|
|
15
|
+
import {createBrowserContext} from '../context/context/create-browser-context';
|
|
16
|
+
import {createHeadlessContext, isHeadlessGLRegistered} from '../context/context/create-headless-context';
|
|
16
17
|
import {getDeviceInfo} from './device-helpers/get-device-info';
|
|
17
18
|
import {getDeviceFeatures} from './device-helpers/device-features';
|
|
18
19
|
import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';
|
|
@@ -65,7 +66,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
65
66
|
static type: string = 'webgl';
|
|
66
67
|
|
|
67
68
|
static isSupported(): boolean {
|
|
68
|
-
return typeof WebGLRenderingContext !== 'undefined';
|
|
69
|
+
return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
readonly info: DeviceInfo;
|
|
@@ -171,7 +172,11 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
171
172
|
// Create and instrument context
|
|
172
173
|
this.canvasContext = new WebGLCanvasContext(this, props);
|
|
173
174
|
|
|
174
|
-
|
|
175
|
+
let gl = props.gl;
|
|
176
|
+
gl = gl || (isBrowser() && createBrowserContext(this.canvasContext.canvas, props));
|
|
177
|
+
gl = gl || (!isBrowser() && createHeadlessContext(props));
|
|
178
|
+
|
|
179
|
+
this.handle = gl;
|
|
175
180
|
this.gl = this.handle;
|
|
176
181
|
this.gl2 = this.gl as WebGL2RenderingContext;
|
|
177
182
|
this.isWebGL2 = isWebGL2(this.gl);
|
|
@@ -187,8 +192,15 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
187
192
|
|
|
188
193
|
// Add subset of WebGL2 methods to WebGL1 context
|
|
189
194
|
polyfillContext(this.gl);
|
|
195
|
+
|
|
190
196
|
// Install context state tracking
|
|
191
|
-
|
|
197
|
+
// @ts-expect-error - hidden parameters
|
|
198
|
+
const {enable = true, copyState = false} = props;
|
|
199
|
+
trackContextState(this.gl, {
|
|
200
|
+
enable,
|
|
201
|
+
copyState,
|
|
202
|
+
log: (...args: any[]) => log.log(1, ...args)()
|
|
203
|
+
});
|
|
192
204
|
|
|
193
205
|
// DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1
|
|
194
206
|
if (isBrowser() && props.debug) {
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const ERR_HEADLESSGL_FAILED =
|
|
2
|
+
'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
3
|
+
|
|
4
|
+
const ERR_HEADLESSGL_LOAD = `\
|
|
5
|
+
luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
|
|
6
|
+
contexts can not be created. This may not be an error. For example, this is a \
|
|
7
|
+
typical configuration for isorender applications running on the server.`;
|
|
8
|
+
|
|
9
|
+
const CONTEXT_DEFAULTS = {
|
|
10
|
+
width: 1,
|
|
11
|
+
height: 1,
|
|
12
|
+
debug: true,
|
|
13
|
+
throwOnError: false
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Duck typing for the main headless gl export, a function to create contexts */
|
|
17
|
+
export type HeadlessGL = (width: number, height: number, options: Record<string, unknown>) => WebGLRenderingContext;
|
|
18
|
+
|
|
19
|
+
let headlessGL: HeadlessGL | null = null;
|
|
20
|
+
|
|
21
|
+
/** By importing `gl` and registering it with this function, contexts can be created under Node.js */
|
|
22
|
+
export function registerHeadlessGL(headlessgl: HeadlessGL) {
|
|
23
|
+
headlessGL = headlessgl;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @returns true if headless gl is registered */
|
|
27
|
+
export function isHeadlessGLRegistered(): boolean {
|
|
28
|
+
return headlessGL !== null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Create headless gl context (for running under Node.js) */
|
|
32
|
+
export function createHeadlessContext(options?: Record<string, any>): WebGLRenderingContext {
|
|
33
|
+
options = {...CONTEXT_DEFAULTS, ...options};
|
|
34
|
+
|
|
35
|
+
const {width, height, webgl1, webgl2} = options;
|
|
36
|
+
|
|
37
|
+
if (webgl2 && !webgl1) {
|
|
38
|
+
throw new Error('headless-gl does not support WebGL2');
|
|
39
|
+
}
|
|
40
|
+
if (!headlessGL) {
|
|
41
|
+
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
42
|
+
}
|
|
43
|
+
const gl = headlessGL(width, height, options);
|
|
44
|
+
if (!gl) {
|
|
45
|
+
throw new Error(ERR_HEADLESSGL_FAILED);
|
|
46
|
+
}
|
|
47
|
+
return gl;
|
|
48
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ import './init'
|
|
|
11
11
|
// Types
|
|
12
12
|
export type {WebGLLimits} from './adapter/device-helpers/device-limits';
|
|
13
13
|
|
|
14
|
+
export {registerHeadlessGL} from './context/context/create-headless-context';
|
|
15
|
+
|
|
14
16
|
// WebGL adapter classes
|
|
15
17
|
export {default as WebGLDevice} from './adapter/webgl-device';
|
|
16
18
|
export {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';
|
package/src/types/webgl.ts
CHANGED
|
@@ -241,7 +241,7 @@ export type GLFunctionParameters = {
|
|
|
241
241
|
clearDepth?: number;
|
|
242
242
|
clearStencil?: number;
|
|
243
243
|
|
|
244
|
-
colorMask?: [boolean, boolean, boolean, boolean];
|
|
244
|
+
colorMask?: [boolean, boolean, boolean, boolean] | boolean[];
|
|
245
245
|
|
|
246
246
|
cull?: boolean;
|
|
247
247
|
cullFace?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-context.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;EAgBE;AACF,aAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,SAAS,GAAI,kBAAkB,GAAG,WAAW,CAAC;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAC;AAUF;;;;GAIG;AACF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAAE,KAAK,EAAE,YAAY,GAAG,qBAAqB,CA6C7H"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/context/create-context.ts"],"names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error"],"mappings":"AAmCA,MAAMA,qBAAmC,GAAG;AAC1CC,EAAAA,MAAM,EAAE,IADkC;AAE1CC,EAAAA,MAAM,EAAE,IAFkC;AAG1CC,EAAAA,eAAe,EAAE,kBAHyB;AAI1CC,EAAAA,aAAa,EAAE,MAAMC,OAAO,CAACC,KAAR,CAAc,oBAAd,CAJqB;AAK1CC,EAAAA,iBAAiB,EAAE,MAAMF,OAAO,CAACG,IAAR,CAAa,wBAAb;AALiB,CAA5C;AAaC,OAAO,SAASC,oBAAT,CAA8BC,MAA9B,EAA2EC,KAA3E,EAAuH;AAC5HA,EAAAA,KAAK,GAAG,EAAC,GAAGX,qBAAJ;AAA2B,OAAGW;AAA9B,GAAR;AAGD,MAAIC,YAAY,GAAG,IAAnB;;AACA,QAAMC,aAAa,GAAIP,KAAD,IAAYM,YAAY,GAAGN,KAAK,CAACQ,aAAN,IAAuBF,YAAxE;;AACAF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,2BAAxB,EAAqDF,aAArD,EAAoE,KAApE;AAGA,MAAIG,EAAgC,GAAG,IAAvC;;AAEA,MAAIL,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,GAAG,EAAC,GAAGA,KAAJ;AAAWT,MAAAA,MAAM,EAAE;AAAnB,KAAR;AACD;;AACD,MAAIS,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,GAAG,EAAC,GAAGA,KAAJ;AAAWV,MAAAA,MAAM,EAAE;AAAnB,KAAR;AACD;;AAGD,MAAIU,KAAK,CAACV,MAAV,EAAkB;AAChBe,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,QAAlB,EAA4BP,KAA5B,CAAX;AACD;;AACD,MAAIA,KAAK,CAACT,MAAV,EAAkB;AAChBc,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,OAAlB,EAA2BP,KAA3B,CAAX;AACD;;AAGDD,EAAAA,MAAM,CAACS,mBAAP,CAA2B,2BAA3B,EAAwDN,aAAxD,EAAuE,KAAvE;;AAEA,MAAI,CAACG,EAAL,EAAS;AACP,UAAM,IAAII,KAAJ,4BACgBT,KAAK,CAACV,MAAN,IAAgB,CAACU,KAAK,CAACT,MAAvB,GAAgC,QAAhC,GAA2C,OAD3D,uBAEFU,YAAY,IAAI,eAFd,EAAN;AAKD;;AAED,MAAID,KAAK,CAACP,aAAV,EAAyB;AACvBM,IAAAA,MAAM,CAACK,gBAAP,CAAwB,kBAAxB,EAA4CJ,KAAK,CAACP,aAAlD,EAAiE,KAAjE;AACD;;AACD,MAAIO,KAAK,CAACJ,iBAAV,EAA6B;AAC3BG,IAAAA,MAAM,CAACK,gBAAP,CAAwB,sBAAxB,EAAgDJ,KAAK,CAACJ,iBAAtD,EAAyE,KAAzE;AACD;;AAED,SAAOS,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\n/**\n * ContextProps\n* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n* @param onContextLost\n* @param onContextRestored\n*\n* BROWSER CONTEXT PARAMETERS\n* @param debug Instrument context (at the expense of performance).\n* @param alpha Default render target has an alpha buffer.\n* @param depth Default render target has a depth buffer of at least 16 bits.\n* @param stencil Default render target has a stencil buffer of at least 8 bits.\n* @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n*/\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean, // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power',\n premultipliedAlpha?: boolean, // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n* @param canvas A canvas element or offscreen canvas\n */\n export function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (props.webgl2) {\n gl = gl || canvas.getContext('webgl2', props) as WebGL2RenderingContext | null;\n }\n if (props.webgl1) {\n gl = gl || canvas.getContext('webgl', props) as WebGLRenderingContext | null;\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n canvas.addEventListener('webglcontextlost', props.onContextLost, false);\n }\n if (props.onContextRestored) {\n canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"file":"create-context.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/context/create-context.ts"],"names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error"],"mappings":";;;;;;;;;;;;;;;AAmCA,IAAMA,qBAAmC,GAAG;AAC1CC,EAAAA,MAAM,EAAE,IADkC;AAE1CC,EAAAA,MAAM,EAAE,IAFkC;AAG1CC,EAAAA,eAAe,EAAE,kBAHyB;AAI1CC,EAAAA,aAAa,EAAE;AAAA,WAAMC,OAAO,CAACC,KAAR,CAAc,oBAAd,CAAN;AAAA,GAJ2B;AAK1CC,EAAAA,iBAAiB,EAAE;AAAA,WAAMF,OAAO,CAACG,IAAR,CAAa,wBAAb,CAAN;AAAA;AALuB,CAA5C;;AAaQ,SAASC,oBAAT,CAA8BC,MAA9B,EAA2EC,KAA3E,EAAuH;AAC5HA,EAAAA,KAAK,mCAAOX,qBAAP,GAAiCW,KAAjC,CAAL;AAGD,MAAIC,YAAY,GAAG,IAAnB;;AACA,MAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACP,KAAD;AAAA,WAAYM,YAAY,GAAGN,KAAK,CAACQ,aAAN,IAAuBF,YAAlD;AAAA,GAAtB;;AACAF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,2BAAxB,EAAqDF,aAArD,EAAoE,KAApE;AAGA,MAAIG,EAAgC,GAAG,IAAvC;;AAEA,MAAIL,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,mCAAOA,KAAP;AAAcT,MAAAA,MAAM,EAAE;AAAtB,MAAL;AACD;;AACD,MAAIS,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,mCAAOA,KAAP;AAAcV,MAAAA,MAAM,EAAE;AAAtB,MAAL;AACD;;AAGD,MAAIU,KAAK,CAACV,MAAV,EAAkB;AAChBe,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,QAAlB,EAA4BP,KAA5B,CAAX;AACD;;AACD,MAAIA,KAAK,CAACT,MAAV,EAAkB;AAChBc,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,OAAlB,EAA2BP,KAA3B,CAAX;AACD;;AAGDD,EAAAA,MAAM,CAACS,mBAAP,CAA2B,2BAA3B,EAAwDN,aAAxD,EAAuE,KAAvE;;AAEA,MAAI,CAACG,EAAL,EAAS;AACP,UAAM,IAAII,KAAJ,4BACgBT,KAAK,CAACV,MAAN,IAAgB,CAACU,KAAK,CAACT,MAAvB,GAAgC,QAAhC,GAA2C,OAD3D,uBAEFU,YAAY,IAAI,eAFd,EAAN;AAKD;;AAED,MAAID,KAAK,CAACP,aAAV,EAAyB;AACvBM,IAAAA,MAAM,CAACK,gBAAP,CAAwB,kBAAxB,EAA4CJ,KAAK,CAACP,aAAlD,EAAiE,KAAjE;AACD;;AACD,MAAIO,KAAK,CAACJ,iBAAV,EAA6B;AAC3BG,IAAAA,MAAM,CAACK,gBAAP,CAAwB,sBAAxB,EAAgDJ,KAAK,CAACJ,iBAAtD,EAAyE,KAAzE;AACD;;AAED,SAAOS,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\n/**\n * ContextProps\n* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n* @param onContextLost\n* @param onContextRestored\n*\n* BROWSER CONTEXT PARAMETERS\n* @param debug Instrument context (at the expense of performance).\n* @param alpha Default render target has an alpha buffer.\n* @param depth Default render target has a depth buffer of at least 16 bits.\n* @param stencil Default render target has a stencil buffer of at least 8 bits.\n* @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n*/\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean, // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power',\n premultipliedAlpha?: boolean, // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n* @param canvas A canvas element or offscreen canvas\n */\n export function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (props.webgl2) {\n gl = gl || canvas.getContext('webgl2', props) as WebGL2RenderingContext | null;\n }\n if (props.webgl1) {\n gl = gl || canvas.getContext('webgl', props) as WebGLRenderingContext | null;\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n canvas.addEventListener('webglcontextlost', props.onContextLost, false);\n }\n if (props.onContextRestored) {\n canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"file":"create-context.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/context/create-context.ts"],"names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error"],"mappings":"AAmCA,MAAMA,qBAAmC,GAAG;AAC1CC,EAAAA,MAAM,EAAE,IADkC;AAE1CC,EAAAA,MAAM,EAAE,IAFkC;AAG1CC,EAAAA,eAAe,EAAE,kBAHyB;AAI1CC,EAAAA,aAAa,EAAE,MAAMC,OAAO,CAACC,KAAR,CAAc,oBAAd,CAJqB;AAK1CC,EAAAA,iBAAiB,EAAE,MAAMF,OAAO,CAACG,IAAR,CAAa,wBAAb;AALiB,CAA5C;AAaC,OAAO,SAASC,oBAAT,CAA8BC,MAA9B,EAA2EC,KAA3E,EAAuH;AAC5HA,EAAAA,KAAK,GAAG,EAAC,GAAGX,qBAAJ;AAA2B,OAAGW;AAA9B,GAAR;AAGD,MAAIC,YAAY,GAAG,IAAnB;;AACA,QAAMC,aAAa,GAAIP,KAAD,IAAYM,YAAY,GAAGN,KAAK,CAACQ,aAAN,IAAuBF,YAAxE;;AACAF,EAAAA,MAAM,CAACK,gBAAP,CAAwB,2BAAxB,EAAqDF,aAArD,EAAoE,KAApE;AAGA,MAAIG,EAAgC,GAAG,IAAvC;;AAEA,MAAIL,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,GAAG,EAAC,GAAGA,KAAJ;AAAWT,MAAAA,MAAM,EAAE;AAAnB,KAAR;AACD;;AACD,MAAIS,KAAK,CAACM,IAAN,KAAe,QAAnB,EAA6B;AAC3BN,IAAAA,KAAK,GAAG,EAAC,GAAGA,KAAJ;AAAWV,MAAAA,MAAM,EAAE;AAAnB,KAAR;AACD;;AAGD,MAAIU,KAAK,CAACV,MAAV,EAAkB;AAChBe,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,QAAlB,EAA4BP,KAA5B,CAAX;AACD;;AACD,MAAIA,KAAK,CAACT,MAAV,EAAkB;AAChBc,IAAAA,EAAE,GAAGA,EAAE,IAAIN,MAAM,CAACQ,UAAP,CAAkB,OAAlB,EAA2BP,KAA3B,CAAX;AACD;;AAGDD,EAAAA,MAAM,CAACS,mBAAP,CAA2B,2BAA3B,EAAwDN,aAAxD,EAAuE,KAAvE;;AAEA,MAAI,CAACG,EAAL,EAAS;AACP,UAAM,IAAII,KAAJ,4BACgBT,KAAK,CAACV,MAAN,IAAgB,CAACU,KAAK,CAACT,MAAvB,GAAgC,QAAhC,GAA2C,OAD3D,uBAEFU,YAAY,IAAI,eAFd,EAAN;AAKD;;AAED,MAAID,KAAK,CAACP,aAAV,EAAyB;AACvBM,IAAAA,MAAM,CAACK,gBAAP,CAAwB,kBAAxB,EAA4CJ,KAAK,CAACP,aAAlD,EAAiE,KAAjE;AACD;;AACD,MAAIO,KAAK,CAACJ,iBAAV,EAA6B;AAC3BG,IAAAA,MAAM,CAACK,gBAAP,CAAwB,sBAAxB,EAAgDJ,KAAK,CAACJ,iBAAtD,EAAyE,KAAzE;AACD;;AAED,SAAOS,EAAP;AACD","sourcesContent":["// luma.gl, MIT license\n\n/**\n * ContextProps\n* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n* @param onContextLost\n* @param onContextRestored\n*\n* BROWSER CONTEXT PARAMETERS\n* @param debug Instrument context (at the expense of performance).\n* @param alpha Default render target has an alpha buffer.\n* @param depth Default render target has a depth buffer of at least 16 bits.\n* @param stencil Default render target has a stencil buffer of at least 8 bits.\n* @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n*/\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean, // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power',\n premultipliedAlpha?: boolean, // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n* @param canvas A canvas element or offscreen canvas\n */\n export function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (props.webgl2) {\n gl = gl || canvas.getContext('webgl2', props) as WebGL2RenderingContext | null;\n }\n if (props.webgl1) {\n gl = gl || canvas.getContext('webgl', props) as WebGLRenderingContext | null;\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n canvas.addEventListener('webglcontextlost', props.onContextLost, false);\n }\n if (props.onContextRestored) {\n canvas.addEventListener('webglcontextrestored', props.onContextRestored, false);\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"file":"create-context.js"}
|