@luma.gl/webgl 9.0.0-alpha.31 → 9.0.0-alpha.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgl",
3
- "version": "9.0.0-alpha.31",
3
+ "version": "9.0.0-alpha.32",
4
4
  "description": "WebGL2 adapter for the luma.gl API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -44,12 +44,12 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.0.0",
47
- "@luma.gl/constants": "9.0.0-alpha.31",
48
- "@luma.gl/core": "9.0.0-alpha.31",
47
+ "@luma.gl/constants": "9.0.0-alpha.32",
48
+ "@luma.gl/core": "9.0.0-alpha.32",
49
49
  "@probe.gl/env": "^4.0.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@luma.gl/test-utils": "9.0.0-alpha.31"
52
+ "@luma.gl/test-utils": "9.0.0-alpha.32"
53
53
  },
54
- "gitHead": "9f22c8a7f5a03abb1bea5530b77c083b8f553569"
54
+ "gitHead": "08b30dcae4aee321738cf05b509cef6b3b24c880"
55
55
  }
@@ -1,53 +1,53 @@
1
1
  /* eslint-disable */
2
2
 
3
3
  // Uniforms
4
- import {GL} from '@luma.gl/constants';
4
+ import type {UniformValue} from '@luma.gl/core';
5
+ import {GL, GLCompositeType, GLSamplerType} from '@luma.gl/constants';
5
6
 
6
7
  /** Set a raw uniform (without type conversion and caching) */
7
8
  /* eslint-disable max-len */
8
9
  export function setUniform(
9
10
  gl: WebGLRenderingContext,
10
11
  location: WebGLUniformLocation,
11
- type: GL,
12
- value: number | Float32Array | Int32Array | Uint32Array | boolean
12
+ type: GLCompositeType | GLSamplerType,
13
+ value: UniformValue
13
14
  ): void {
14
15
  const gl2 = gl as WebGL2RenderingContext;
15
16
 
16
- if (typeof value === 'number') {
17
- // prettier-ignore
18
- switch (type) {
19
- // WebGL1 samplers
20
- case GL.SAMPLER_2D:
21
- case GL.SAMPLER_CUBE:
22
- // WebGL2 samplers
23
- case GL.SAMPLER_3D:
24
- case GL.SAMPLER_2D_SHADOW:
25
- case GL.SAMPLER_2D_ARRAY:
26
- case GL.SAMPLER_2D_ARRAY_SHADOW:
27
- case GL.SAMPLER_CUBE_SHADOW:
28
- case GL.INT_SAMPLER_2D:
29
- case GL.INT_SAMPLER_3D:
30
- case GL.INT_SAMPLER_CUBE:
31
- case GL.INT_SAMPLER_2D_ARRAY:
32
- case GL.UNSIGNED_INT_SAMPLER_2D:
33
- case GL.UNSIGNED_INT_SAMPLER_3D:
34
- case GL.UNSIGNED_INT_SAMPLER_CUBE:
35
- case GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
36
- return gl.uniform1i(location, value);
37
- }
17
+ // Prepare the value for WebGL setters
18
+ let uniformValue = value;
19
+ if (uniformValue === true) {
20
+ uniformValue = 1;
38
21
  }
39
-
40
- if (value === true) {
41
- value = 1;
42
- }
43
-
44
- if (value === false) {
45
- value = 0;
22
+ if (uniformValue === false) {
23
+ uniformValue = 0;
46
24
  }
47
- const arrayValue = (typeof value === 'number') ? [value] : value;
25
+ const arrayValue = typeof uniformValue === 'number' ? [uniformValue] : uniformValue;
48
26
 
49
27
  // prettier-ignore
50
28
  switch (type) {
29
+ // WebGL1 samplers
30
+ case GL.SAMPLER_2D:
31
+ case GL.SAMPLER_CUBE:
32
+ // WebGL2 samplers
33
+ case GL.SAMPLER_3D:
34
+ case GL.SAMPLER_2D_SHADOW:
35
+ case GL.SAMPLER_2D_ARRAY:
36
+ case GL.SAMPLER_2D_ARRAY_SHADOW:
37
+ case GL.SAMPLER_CUBE_SHADOW:
38
+ case GL.INT_SAMPLER_2D:
39
+ case GL.INT_SAMPLER_3D:
40
+ case GL.INT_SAMPLER_CUBE:
41
+ case GL.INT_SAMPLER_2D_ARRAY:
42
+ case GL.UNSIGNED_INT_SAMPLER_2D:
43
+ case GL.UNSIGNED_INT_SAMPLER_3D:
44
+ case GL.UNSIGNED_INT_SAMPLER_CUBE:
45
+ case GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
46
+ if (typeof value !== 'number') {
47
+ throw new Error('samplers must be set to integers');
48
+ }
49
+ return gl.uniform1i(location, value);
50
+
51
51
  case GL.FLOAT: return gl.uniform1fv(location, arrayValue);
52
52
  case GL.FLOAT_VEC2: return gl.uniform2fv(location, arrayValue);
53
53
  case GL.FLOAT_VEC3: return gl.uniform3fv(location, arrayValue);
@@ -1,18 +1,16 @@
1
+ // luma.gl, MIT license
1
2
  import type {
3
+ TypedArray,
4
+ UniformValue,
2
5
  RenderPipelineProps,
3
- RenderPass,
4
- Buffer,
5
6
  Binding,
6
7
  ShaderLayout,
7
- PrimitiveTopology,
8
- TypedArray,
9
- BufferLayout
8
+ BufferLayout,
9
+ PrimitiveTopology
10
10
  } from '@luma.gl/core';
11
+ import type {RenderPass, Buffer} from '@luma.gl/core';
11
12
  import {RenderPipeline, cast, log} from '@luma.gl/core';
12
- import {
13
- mergeShaderLayout,
14
- getAttributeInfosFromLayouts
15
- } from '@luma.gl/core';
13
+ import {mergeShaderLayout, getAttributeInfosFromLayouts} from '@luma.gl/core';
16
14
  import {GL} from '@luma.gl/constants';
17
15
 
18
16
  import {getGLFromVertexType} from '../converters/vertex-formats';
@@ -112,7 +110,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
112
110
  this._indexBuffer = webglBuffer;
113
111
  }
114
112
 
115
-
116
113
  /** @todo needed for portable model */
117
114
  setAttributes(buffers: Record<string, Buffer>): void {
118
115
  const attributeInfos = getAttributeInfosFromLayouts(this.shaderLayout, this.bufferLayout);
@@ -159,8 +156,10 @@ export class WEBGLRenderPipeline extends RenderPipeline {
159
156
  });
160
157
  set = true;
161
158
  }
162
- if (!set) {
163
- log.warn(`setAttributes(): Ignoring (buffer "${buffer.id}" for unknown attribute "${name}" in pipeline "${this.id}"`)();
159
+ if (!set) {
160
+ log.warn(
161
+ `setAttributes(): Ignoring (buffer "${buffer.id}" for unknown attribute "${name}" in pipeline "${this.id}"`
162
+ )();
164
163
  }
165
164
  }
166
165
  }
@@ -227,7 +226,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
227
226
  }
228
227
  }
229
228
 
230
- setUniforms(uniforms: Record<string, any>) {
229
+ setUniforms(uniforms: Record<string, UniformValue>) {
231
230
  // TODO - check against layout
232
231
  Object.assign(this.uniforms, uniforms);
233
232
  }
@@ -81,7 +81,6 @@ export type BufferWithAccessorProps = BufferProps & {
81
81
 
82
82
  /** WebGL Buffer interface */
83
83
  export class BufferWithAccessor extends WEBGLBuffer {
84
- usage: number;
85
84
  accessor: Accessor;
86
85
 
87
86
  constructor(device: Device | WebGLRenderingContext, props?: BufferWithAccessorProps);