CodeSampleX

Sample

three 0.185.1: THREE.WebGLRenderer.capabilities.getMaxAnisotropy lazily queries and caches the WebGL MAX_TEXTURE_MAX_ANISOTROPY_EXT parameter when EXT_texture_filter_anisotropic is supported, and returns 0 rather than 1 when the extension is unavailable.

Verified sample for npm three 0.185.1: THREE.WebGLRenderer.capabilities.getMaxAnisotropy lazily queries and caches the WebGL MAX_TEXTURE_MAX_ANISOTROPY_EXT…

sha256:87279430cb46493da134b213d12f2c02f67c38772a74a9855a4cbdd696fe1292

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
3
Signing keys that built it
3
Declared environment node linux x64 node node npm

Verification-run environments

Environment Contract Stages Run
node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-17
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-18
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-09-07

Case

HOW
Goal
THREE.WebGLRenderer.capabilities.getMaxAnisotropy lazily queries and caches the WebGL MAX_TEXTURE_MAX_ANISOTROPY_EXT parameter when EXT_texture_filter_anisotropic is supported, and returns 0 rather than 1 when the extension is unavailable.
Packages
Symbols
  • THREE.WebGLRenderer.capabilities.getMaxAnisotropy
Environment
node
Created
2026-08-17T09:19:27Z

Contract

  1. renderer.capabilities.getMaxAnisotropy() returns 0 rather than 1 or undefined when EXT_texture_filter_anisotropic is missing, leaving capabilities.maxAnisotropy undefined.
  2. When EXT_texture_filter_anisotropic is available, getMaxAnisotropy() queries gl.getParameter(MAX_TEXTURE_MAX_ANISOTROPY_EXT) lazily on first invocation and caches the result for subsequent calls.

Files

  • NOTES.md
  • csx.json
  • package-lock.json
  • package.json
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

NOTES.md
# three: WebGLRenderer.capabilities.getMaxAnisotropy

## Search Result
Querying known solutions for `three` and `THREE.WebGLRenderer.capabilities.getMaxAnisotropy` returned no existing match for this symbol.

## Pinned Release
- Package: `three`
- Version: `0.185.1`

## Observed Behaviour
In `three@0.185.1`, `THREE.WebGLRenderer.capabilities` exposes capabilities of the underlying WebGL context. While many capability metrics (such as `maxTextures`, `maxTextureSize`, `maxSamples`, `maxAttributes`) are evaluated eagerly during renderer initialization and exposed as direct numeric properties on `renderer.capabilities`, anisotropic filtering is handled differently:

1. `renderer.capabilities.maxAnisotropy` is `undefined`. Anisotropy limits are accessible only via the method `renderer.capabilities.getMaxAnisotropy()`.
2. When the `EXT_texture_filter_anisotropic` WebGL extension is missing or unsupported by the graphics driver/context, `renderer.capabilities.getMaxAnisotropy()` returns `0` (rather than defaulting to `1`, returning `undefined`, or throwing).
3. When `EXT_texture_filter_anisotropic` is present, `renderer.capabilities.getMaxAnisotropy()` queries `gl.getParameter(extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT)` lazily on its first call and caches the integer result, avoiding repeated WebGL state queries on subsequent invocations.

## Failure Mode
A naive caller expecting `renderer.capabilities.maxAnisotropy` to exist as a property (analogous to `renderer.capabilities.maxTextureSize`) silently reads `undefined`. Furthermore, expecting `getMaxAnisotropy()` to default to `1` (the baseline texture anisotropy value) when anisotropy extensions are unsupported will fail assertions, as the library explicitly returns `0`.
csx.json
{"case":{"believed":"WebGLRenderer.capabilities exposes a maxAnisotropy numeric property or getMaxAnisotropy defaults to 1 when anisotropic filtering extensions are missing","caseId":"case:sha256:67bffe53aba92bf63eda382f9ad9070a7ede1693f92c31e5ddaf28daa3de299f","contract":["renderer.capabilities.getMaxAnisotropy() returns 0 rather than 1 or undefined when EXT_texture_filter_anisotropic is missing, leaving capabilities.maxAnisotropy undefined.","When EXT_texture_filter_anisotropic is available, getMaxAnisotropy() queries gl.getParameter(MAX_TEXTURE_MAX_ANISOTROPY_EXT) lazily on first invocation and caches the result for subsequent calls."],"goal":"THREE.WebGLRenderer.capabilities.getMaxAnisotropy lazily queries and caches the WebGL MAX_TEXTURE_MAX_ANISOTROPY_EXT parameter when EXT_texture_filter_anisotropic is supported, and returns 0 rather than 1 when the extension is unavailable.","kind":"HOW","packages":["pkg:npm/three@0.185.1"],"schemaVersion":1,"symbols":["THREE.WebGLRenderer.capabilities.getMaxAnisotropy"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/three@0.185.1"],"schemaVersion":1,"symbols":["THREE.WebGLRenderer.capabilities.getMaxAnisotropy"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "npm-three-wanted-0-185-1-three-webglrenderer-capabilities-getmaxanisotropy-3142f13d919ad96c53c0f043",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-three-wanted-0-185-1-three-webglrenderer-capabilities-getmaxanisotropy-3142f13d919ad96c53c0f043",
      "version": "1.0.0",
      "license": "ISC",
      "dependencies": {
        "three": "^0.185.1"
      }
    },
    "node_modules/three": {
      "version": "0.185.1",
      "resolved": "https://registry.npmjs.org/three/-/three-0.185.1.tgz",
      "integrity": "sha512-5aojFCXKwnjBRZvUnt3WFfEcvUJgkN5LlijRFN95hMy8WVkG4I0QNcJE+OuWvuJ0bOdStrbfXn0pkd6/QyiAlg==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "npm-three-wanted-0-185-1-three-webglrenderer-capabilities-getmaxanisotropy-3142f13d919ad96c53c0f043",
  "version": "1.0.0",
  "description": "",
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "three": "0.185.1"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import * as THREE from 'three';

function createMockCanvas() {
  return {
    addEventListener: () => {},
    removeEventListener: () => {},
    style: {},
    getContext: () => null,
  };
}

function createMockGL({ extensions = {}, parameters = {} } = {}) {
  const defaultParams = {
    7938: 'WebGL 2.0', // VERSION
    34930: 16, // MAX_TEXTURE_IMAGE_UNITS
    35660: 16, // MAX_VERTEX_TEXTURE_IMAGE_UNITS
    3379: 4096, // MAX_TEXTURE_SIZE
    34076: 4096, // MAX_CUBE_MAP_TEXTURE_SIZE
    34921: 16, // MAX_VERTEX_ATTRIBS
    36347: 1024, // MAX_VERTEX_UNIFORM_VECTORS
    36348: 30, // MAX_VARYING_VECTORS
    36349: 1024, // MAX_FRAGMENT_UNIFORM_VECTORS
    36183: 4, // MAX_SAMPLES
    32937: 4, // SAMPLES
    34929: 80, // MAX_COMBINED_TEXTURE_IMAGE_UNITS
    34852: 8, // MAX_DRAW_BUFFERS
    3088: [0, 0, 800, 600], // SCISSOR_BOX
    2978: [0, 0, 800, 600], // VIEWPORT
    ...parameters
  };

  const extMap = { ...extensions };

  return {
    VERSION: 7938,
    VERTEX_SHADER: 35633,
    FRAGMENT_SHADER: 35632,
    HIGH_FLOAT: 36338,
    MEDIUM_FLOAT: 36337,
    LOW_FLOAT: 36336,
    MAX_TEXTURE_IMAGE_UNITS: 34930,
    MAX_VERTEX_TEXTURE_IMAGE_UNITS: 35660,
    MAX_TEXTURE_SIZE: 3379,
    MAX_CUBE_MAP_TEXTURE_SIZE: 34076,
    MAX_VERTEX_ATTRIBS: 34921,
    MAX_VERTEX_UNIFORM_VECTORS: 36347,
    MAX_VARYING_VECTORS: 36348,
    MAX_FRAGMENT_UNIFORM_VECTORS: 36349,
    MAX_SAMPLES: 36183,
    SAMPLES: 32937,
    MAX_COMBINED_TEXTURE_IMAGE_UNITS: 34929,
    MAX_DRAW_BUFFERS: 34852,
    SCISSOR_BOX: 3088,
    VIEWPORT: 2978,
    TEXTURE_2D: 3553,
    TEXTURE_CUBE_MAP: 34067,
    TEXTURE_2D_ARRAY: 35866,
    TEXTURE_3D: 32879,
    TEXTURE_CUBE_MAP_POSITIVE_X: 34069,
    RGBA: 6408,
    UNSIGNED_BYTE: 5121,
    TEXTURE_MIN_FILTER: 10241,
    TEXTURE_MAG_FILTER: 10240,
    NEAREST: 9728,
    DEPTH_TEST: 2929,
    CULL_FACE: 2884,

    getContextAttributes: () => ({ alpha: true, depth: true, stencil: false, antialias: false }),
    getExtension: (name) => extMap[name] || null,
    getParameter: (pname) => defaultParams[pname] ?? 0,
    getShaderPrecisionFormat: () => ({ precision: 23, rangeMin: 127, rangeMax: 127 }),
    createFramebuffer: () => ({}),
    createVertexArray: () => ({}),
    bindVertexArray: () => {},
    createBuffer: () => ({}),
    bindBuffer: () => {},
    bufferData: () => {},
    createTexture: () => ({}),
    texImage2D: () => {},
    texImage3D: () => {},
    enable: () => {},
    disable: () => {},
    colorMask: () => {},
    depthMask: () => {},
    depthFunc: () => {},
    cullFace: () => {},
    frontFace: () => {},
    blendEquation: () => {},
    blendFunc: () => {},
    blendEquationSeparate: () => {},
    blendFuncSeparate: () => {},
    scissor: () => {},
    viewport: () => {},
    clearColor: () => {},
    clearDepth: () => {},
    clearStencil: () => {},
    pixelStorei: () => {},
    activeTexture: () => {},
    bindTexture: () => {},
    texParameteri: () => {},
    canvas: createMockCanvas()
  };
}

// Case 1: Extension is missing (e.g. unsupported platform)
{
  const gl = createMockGL();
  const renderer = new THREE.WebGLRenderer({ canvas: createMockCanvas(), context: gl });

  assert.equal(typeof renderer.capabilities.getMaxAnisotropy, 'function');
  assert.equal(renderer.capabilities.maxAnisotropy, undefined);

  // Without EXT_texture_filter_anisotropic, getMaxAnisotropy returns 0 (not 1, not undefined, not null)
  const maxAnisotropy = renderer.capabilities.getMaxAnisotropy();
  assert.strictEqual(maxAnisotropy, 0);
  assert.strictEqual(renderer.capabilities.getMaxAnisotropy(), 0);
}

// Case 2: Extension is supported -> lazy evaluation and internal caching
{
  const mockExt = {
    MAX_TEXTURE_MAX_ANISOTROPY_EXT: 34047,
    TEXTURE_MAX_ANISOTROPY_EXT: 34046
  };
  let paramQueryCount = 0;
  const gl = createMockGL({
    extensions: { 'EXT_texture_filter_anisotropic': mockExt },
    parameters: { 34047: 16 }
  });
  const originalGetParam = gl.getParameter;
  gl.getParameter = (pname) => {
    if (pname === 34047) {
      paramQueryCount++;
    }
    return originalGetParam(pname);
  };

  const renderer = new THREE.WebGLRenderer({ canvas: createMockCanvas(), context: gl });

  // Parameter should not be queried at renderer construction time (lazy)
  assert.strictEqual(paramQueryCount, 0);

  // First call queries gl.getParameter(MAX_TEXTURE_MAX_ANISOTROPY_EXT)
  const firstResult = renderer.capabilities.getMaxAnisotropy();
  assert.strictEqual(firstResult, 16);
  assert.strictEqual(paramQueryCount, 1);

  // Subsequent calls use cached value without additional gl.getParameter queries
  const secondResult = renderer.capabilities.getMaxAnisotropy();
  assert.strictEqual(secondResult, 16);
  assert.strictEqual(paramQueryCount, 1);
}

Origin Seeder

csx-seed