@luma.gl/test-utils 9.0.17 → 9.1.0-alpha.10

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.
Files changed (47) hide show
  1. package/dist/create-test-device.d.ts.map +1 -1
  2. package/dist/create-test-device.js +7 -4
  3. package/dist/engine/classic-animation-loop.d.ts.map +1 -1
  4. package/dist/engine/classic-animation-loop.js +2 -1
  5. package/dist/index.cjs +70 -66
  6. package/dist/index.cjs.map +4 -4
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -0
  10. package/dist/null-device/null-adapter.d.ts +13 -0
  11. package/dist/null-device/null-adapter.d.ts.map +1 -0
  12. package/dist/null-device/null-adapter.js +30 -0
  13. package/dist/null-device/null-canvas-context.d.ts +3 -1
  14. package/dist/null-device/null-canvas-context.d.ts.map +1 -1
  15. package/dist/null-device/null-canvas-context.js +2 -0
  16. package/dist/null-device/null-device.d.ts +0 -4
  17. package/dist/null-device/null-device.d.ts.map +1 -1
  18. package/dist/null-device/null-device.js +2 -17
  19. package/dist/null-device/resources/null-buffer.d.ts.map +1 -1
  20. package/dist/null-device/resources/null-buffer.js +3 -3
  21. package/dist/null-device/resources/null-framebuffer.d.ts +3 -0
  22. package/dist/null-device/resources/null-framebuffer.d.ts.map +1 -1
  23. package/dist/null-device/resources/null-framebuffer.js +2 -0
  24. package/dist/null-device/resources/null-render-pipeline.d.ts.map +1 -1
  25. package/dist/null-device/resources/null-render-pipeline.js +3 -3
  26. package/dist/null-device/resources/null-texture.d.ts +12 -18
  27. package/dist/null-device/resources/null-texture.d.ts.map +1 -1
  28. package/dist/null-device/resources/null-texture.js +31 -38
  29. package/dist/null-device/resources/null-vertex-array.d.ts +2 -1
  30. package/dist/null-device/resources/null-vertex-array.d.ts.map +1 -1
  31. package/dist/register-devices.js +3 -3
  32. package/dist/test-runner.d.ts +1 -1
  33. package/dist/test-runner.d.ts.map +1 -1
  34. package/dist/utils/resource-tracker.d.ts +2 -2
  35. package/package.json +9 -9
  36. package/src/create-test-device.ts +7 -5
  37. package/src/engine/classic-animation-loop.ts +2 -8
  38. package/src/index.ts +3 -0
  39. package/src/null-device/null-adapter.ts +38 -0
  40. package/src/null-device/null-canvas-context.ts +4 -1
  41. package/src/null-device/null-device.ts +2 -21
  42. package/src/null-device/resources/null-buffer.ts +3 -3
  43. package/src/null-device/resources/null-framebuffer.ts +4 -0
  44. package/src/null-device/resources/null-render-pipeline.ts +3 -3
  45. package/src/null-device/resources/null-texture.ts +56 -49
  46. package/src/null-device/resources/null-vertex-array.ts +2 -1
  47. package/src/register-devices.ts +3 -3
@@ -2,17 +2,32 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {TextureProps, Sampler, SamplerProps, TextureViewProps} from '@luma.gl/core';
6
- import {Texture, assert, loadImage} from '@luma.gl/core';
5
+ import type {
6
+ TextureProps,
7
+ Sampler,
8
+ SamplerProps,
9
+ TextureViewProps,
10
+ CopyExternalImageOptions
11
+ } from '@luma.gl/core';
12
+ import type {
13
+ Texture1DData,
14
+ Texture2DData,
15
+ Texture3DData,
16
+ TextureCubeData,
17
+ TextureArrayData,
18
+ TextureCubeArrayData
19
+ } from '@luma.gl/core';
20
+
21
+ import {Texture} from '@luma.gl/core';
7
22
  import {NullDevice} from '../null-device';
8
23
  import {NullSampler} from './null-sampler';
9
24
  import {NullTextureView} from './null-texture-view';
10
25
 
11
- export class NullTexture extends Texture<TextureProps> {
26
+ export class NullTexture extends Texture {
12
27
  readonly device: NullDevice;
13
28
 
14
- sampler!: NullSampler;
15
- view!: NullTextureView;
29
+ sampler: NullSampler;
30
+ view: NullTextureView;
16
31
 
17
32
  constructor(device: NullDevice, props: TextureProps) {
18
33
  super(device, props);
@@ -21,7 +36,7 @@ export class NullTexture extends Texture<TextureProps> {
21
36
 
22
37
  // Signature: new Texture2D(gl, {data: url})
23
38
  if (typeof this.props?.data === 'string') {
24
- Object.assign(this.props, {data: loadImage(this.props.data)});
39
+ throw new Error('Texture2D: Loading textures from URLs is not supported');
25
40
  }
26
41
 
27
42
  this.initialize(this.props);
@@ -40,22 +55,33 @@ export class NullTexture extends Texture<TextureProps> {
40
55
  return new NullTextureView(this.device, {...props, texture: this});
41
56
  }
42
57
 
43
- initialize(props: TextureProps = {}): this {
44
- const data = props.data;
45
-
46
- if (data instanceof Promise) {
47
- data.then(resolvedImageData =>
48
- this.initialize(
49
- Object.assign({}, props, {
50
- pixels: resolvedImageData,
51
- data: resolvedImageData
52
- })
53
- )
54
- );
55
- return this;
56
- }
58
+ setTexture1DData(data: Texture1DData): void {
59
+ throw new Error('not implemented');
60
+ }
57
61
 
58
- this.setImageData(props);
62
+ setTexture2DData(lodData: Texture2DData, depth?: number, target?: number): void {
63
+ throw new Error('not implemented');
64
+ }
65
+
66
+ setTexture3DData(lodData: Texture3DData, depth?: number, target?: number): void {
67
+ throw new Error('not implemented');
68
+ }
69
+
70
+ setTextureCubeData(data: TextureCubeData, depth?: number): void {
71
+ throw new Error('not implemented');
72
+ }
73
+
74
+ setTextureArrayData(data: TextureArrayData): void {
75
+ throw new Error('not implemented');
76
+ }
77
+
78
+ setTextureCubeArrayData(data: TextureCubeArrayData): void {
79
+ throw new Error('not implemented');
80
+ }
81
+
82
+ initialize(props: TextureProps = {}): this {
83
+ // const data = props.data;
84
+ // this.setImageData(props);
59
85
 
60
86
  this.setSampler(props.sampler);
61
87
 
@@ -79,29 +105,17 @@ export class NullTexture extends Texture<TextureProps> {
79
105
  return this;
80
106
  }
81
107
 
82
- resize(options: {height: number; width: number; mipmaps?: boolean}): this {
83
- const {height, width, mipmaps = false} = options;
84
- if (width !== this.width || height !== this.height) {
85
- return this.initialize({
86
- width,
87
- height,
88
- mipmaps
89
- });
90
- }
91
- return this;
92
- }
93
-
94
- setImageData(options: {data?: any; width?: number; height?: number}) {
108
+ copyExternalImage(options: CopyExternalImageOptions): {width: number; height: number} {
95
109
  this.trackDeallocatedMemory('Texture');
96
110
 
97
- const {data} = options;
111
+ const {image: data} = options;
98
112
 
99
- if (data && data.byteLength) {
100
- this.trackAllocatedMemory(data.byteLength, 'Texture');
101
- } else {
102
- const bytesPerPixel = 4;
103
- this.trackAllocatedMemory(this.width * this.height * bytesPerPixel, 'Texture');
104
- }
113
+ // if (data && data.byteLength) {
114
+ // this.trackAllocatedMemory(data.byteLength, 'Texture');
115
+ // } else {
116
+ const bytesPerPixel = 4;
117
+ this.trackAllocatedMemory(this.width * this.height * bytesPerPixel, 'Texture');
118
+ // }
105
119
 
106
120
  const width = options.width ?? (data as ImageBitmap).width;
107
121
  const height = options.height ?? (data as ImageBitmap).height;
@@ -109,13 +123,6 @@ export class NullTexture extends Texture<TextureProps> {
109
123
  this.width = width;
110
124
  this.height = height;
111
125
 
112
- return this;
113
- }
114
-
115
- setSubImageData(options: {data: any; width?: number; height?: number; x?: number; y?: number}) {
116
- const {data, x = 0, y = 0} = options;
117
- const width = options.width ?? (data as ImageBitmap).width;
118
- const height = options.height ?? (data as ImageBitmap).height;
119
- assert(width + x <= this.width && height + y <= this.height);
126
+ return {width, height};
120
127
  }
121
128
  }
@@ -2,7 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {Buffer, VertexArrayProps, TypedArray} from '@luma.gl/core';
5
+ import type {TypedArray} from '@math.gl/types';
6
+ import type {Buffer, VertexArrayProps} from '@luma.gl/core';
6
7
  import {VertexArray} from '@luma.gl/core';
7
8
 
8
9
  import type {NullDevice} from '../null-device';
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {luma} from '@luma.gl/core';
6
- import {WebGLDevice} from '@luma.gl/webgl';
7
- import {WebGPUDevice} from '@luma.gl/webgpu';
6
+ import {webgl2Adapter} from '@luma.gl/webgl';
7
+ import {webgpuAdapter} from '@luma.gl/webgpu';
8
8
 
9
- luma.registerDevices([WebGLDevice, WebGPUDevice]);
9
+ luma.registerAdapters([webgl2Adapter, webgpuAdapter]);