@flighthq/texture 0.3.0-next.1032.e2b99fc → 0.3.0-next.1220.6982c21

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.
@@ -3,4 +3,5 @@ export * from './renderTexture';
3
3
  export * from './sampler';
4
4
  export * from './texture';
5
5
  export * from './videoTexture';
6
+ export * from './voxelGrid';
6
7
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
package/dist/contract.js CHANGED
@@ -3,4 +3,5 @@ export * from './renderTexture';
3
3
  export * from './sampler';
4
4
  export * from './texture';
5
5
  export * from './videoTexture';
6
+ export * from './voxelGrid';
6
7
  //# sourceMappingURL=contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -1,9 +1,9 @@
1
- import type { CreateCubeTextureOptions, CubeTexture, ImageBacking } from '@flighthq/types/contract';
1
+ import type { CreateCubeTextureOptions, CubeTexture, TextureSource } from '@flighthq/types/contract';
2
2
  export declare function cloneCubeTexture(source: Readonly<CubeTexture>): CubeTexture;
3
3
  export declare function copyCubeTexture(out: CubeTexture, source: Readonly<CubeTexture>): void;
4
4
  export declare function createCubeTexture(opts?: Readonly<CreateCubeTextureOptions>): CubeTexture;
5
5
  export declare function equalsCubeTexture(a: Readonly<CubeTexture> | null | undefined, b: Readonly<CubeTexture> | null | undefined): boolean;
6
6
  export declare function getCubeTextureFaceSize(cube: Readonly<CubeTexture>): number;
7
7
  export declare function isCubeTextureComplete(cube: Readonly<CubeTexture>): boolean;
8
- export declare function setCubeTextureFace(cube: CubeTexture, faceIndex: number, image: ImageBacking | null): void;
8
+ export declare function setCubeTextureFace(cube: CubeTexture, faceIndex: number, source: TextureSource | null): void;
9
9
  //# sourceMappingURL=cubeTexture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cubeTexture.d.ts","sourceRoot":"","sources":["../src/cubeTexture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,YAAY,EAAqB,MAAM,0BAA0B,CAAC;AASvH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,WAAW,CAE3E;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAErF;AAED,wBAAgB,iBAAiB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,wBAAwB,CAAC,GAAG,WAAW,CASxF;AAED,wBAAgB,iBAAiB,CAC/B,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3C,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,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAK3G"}
@@ -1,7 +1,7 @@
1
1
  import { cloneSampler } from './sampler';
2
2
  import { cloneTexture, copyTexture, createTexture, equalsTexture } from './texture';
3
- function getCubeImages(texture) {
4
- return texture.storage.images;
3
+ function getCubeSources(texture) {
4
+ return texture.sources;
5
5
  }
6
6
  export function cloneCubeTexture(source) {
7
7
  return cloneTexture(source);
@@ -13,10 +13,8 @@ export function createCubeTexture(opts) {
13
13
  return createTexture({
14
14
  colorSpace: opts?.colorSpace ?? 'srgb',
15
15
  sampler: opts?.sampler ? cloneSampler(opts.sampler) : undefined,
16
- storage: {
17
- dimension: 'cube',
18
- images: opts?.images ?? [null, null, null, null, null, null],
19
- },
16
+ dimension: 'cube',
17
+ sources: opts?.sources ?? [null, null, null, null, null, null],
20
18
  });
21
19
  }
22
20
  export function equalsCubeTexture(a, b) {
@@ -25,22 +23,22 @@ export function equalsCubeTexture(a, b) {
25
23
  return equalsTexture(a, b);
26
24
  }
27
25
  export function getCubeTextureFaceSize(cube) {
28
- const images = getCubeImages(cube);
26
+ const sources = getCubeSources(cube);
29
27
  for (let i = 0; i < 6; i++) {
30
- const face = images[i];
28
+ const face = sources[i];
31
29
  if (face !== null)
32
30
  return face.width;
33
31
  }
34
32
  return -1;
35
33
  }
36
34
  export function isCubeTextureComplete(cube) {
37
- return getCubeImages(cube).every((face) => face !== null);
35
+ return getCubeSources(cube).every((face) => face !== null);
38
36
  }
39
- export function setCubeTextureFace(cube, faceIndex, image) {
40
- const images = getCubeImages(cube);
41
- if (images[faceIndex] === image)
37
+ export function setCubeTextureFace(cube, faceIndex, source) {
38
+ const sources = getCubeSources(cube);
39
+ if (sources[faceIndex] === source)
42
40
  return;
43
- images[faceIndex] = image;
41
+ sources[faceIndex] = source;
44
42
  cube.version = (cube.version + 1) >>> 0;
45
43
  }
46
44
  //# sourceMappingURL=cubeTexture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cube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,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,MAAM;QAAE,OAAO;IACzC,OAA+C,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IACrE,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { advanceVideoTexture, cloneCubeTexture, cloneSampler, cloneTexture, cloneVideoTexture, copyCubeTexture, copySampler, copyTexture, copyVideoTexture, createAnisotropicSampler, createClampLinearSampler, createCubeTexture, createPixelArtSampler, createRenderTexture, createSampler, createTexture, createTilingSampler, createVideoTexture, equalsCubeTexture, equalsSampler, equalsTexture, getCubeTextureFaceSize, getTextureBackingKind, getTextureHeight, getTextureInverseUvMatrix, getTextureUvMatrix, getTextureWidth, getVideoTextureHeight, getVideoTextureInverseUvMatrix, getVideoTextureUvMatrix, getVideoTextureWidth, hasTextureBacking, hasTextureUvTransform, isCubeTextureComplete, isTextureReady, isVideoTextureFrameReady, resetTextureUvTransform, resetVideoTextureFrame, setCubeTextureFace, setTextureFlip, setTextureImage, setTextureUvOffset, setTextureUvFromPixelRect, setTextureUvRotation, setTextureUvScale, setVideoTextureSource, transformTextureUv, } from './contract';
1
+ export { advanceVideoTexture, cloneCubeTexture, cloneSampler, cloneTexture, cloneVideoTexture, copyCubeTexture, copySampler, copyTexture, copyVideoTexture, createAnisotropicSampler, createClampLinearSampler, createCubeTexture, createPixelArtSampler, createRenderTexture, createSampler, createTexture, createTilingSampler, createVideoTexture, equalsCubeTexture, equalsSampler, equalsTexture, getCubeTextureFaceSize, getTextureSourceKind, getTextureSource, getTextureHeight, getTextureInverseUvMatrix, getTextureUvMatrix, getTextureWidth, getVideoTextureHeight, getVideoTextureInverseUvMatrix, getVideoTextureUvMatrix, getVideoTextureWidth, hasTextureSource, hasTextureUvTransform, isCubeTextureComplete, isTextureReady, isVideoTextureFrameReady, invalidateVoxelGrid, resetTextureUvTransform, resetVideoTextureFrame, setCubeTextureFace, setTextureFlip, setTextureSource, setTextureUvOffset, setTextureUvFromPixelRect, setTextureUvRotation, setTextureUvScale, setVideoTextureSource, transformTextureUv, } from './contract';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { advanceVideoTexture, cloneCubeTexture, cloneSampler, cloneTexture, cloneVideoTexture, copyCubeTexture, copySampler, copyTexture, copyVideoTexture, createAnisotropicSampler, createClampLinearSampler, createCubeTexture, createPixelArtSampler, createRenderTexture, createSampler, createTexture, createTilingSampler, createVideoTexture, equalsCubeTexture, equalsSampler, equalsTexture, getCubeTextureFaceSize, getTextureBackingKind, getTextureHeight, getTextureInverseUvMatrix, getTextureUvMatrix, getTextureWidth, getVideoTextureHeight, getVideoTextureInverseUvMatrix, getVideoTextureUvMatrix, getVideoTextureWidth, hasTextureBacking, hasTextureUvTransform, isCubeTextureComplete, isTextureReady, isVideoTextureFrameReady, resetTextureUvTransform, resetVideoTextureFrame, setCubeTextureFace, setTextureFlip, setTextureImage, setTextureUvOffset, setTextureUvFromPixelRect, setTextureUvRotation, setTextureUvScale, setVideoTextureSource, transformTextureUv, } from './contract';
1
+ export { advanceVideoTexture, cloneCubeTexture, cloneSampler, cloneTexture, cloneVideoTexture, copyCubeTexture, copySampler, copyTexture, copyVideoTexture, createAnisotropicSampler, createClampLinearSampler, createCubeTexture, createPixelArtSampler, createRenderTexture, createSampler, createTexture, createTilingSampler, createVideoTexture, equalsCubeTexture, equalsSampler, equalsTexture, getCubeTextureFaceSize, getTextureSourceKind, getTextureSource, getTextureHeight, getTextureInverseUvMatrix, getTextureUvMatrix, getTextureWidth, getVideoTextureHeight, getVideoTextureInverseUvMatrix, getVideoTextureUvMatrix, getVideoTextureWidth, hasTextureSource, hasTextureUvTransform, isCubeTextureComplete, isTextureReady, isVideoTextureFrameReady, invalidateVoxelGrid, resetTextureUvTransform, resetVideoTextureFrame, setCubeTextureFace, setTextureFlip, setTextureSource, setTextureUvOffset, setTextureUvFromPixelRect, setTextureUvRotation, setTextureUvScale, setVideoTextureSource, transformTextureUv, } from './contract';
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderTexture.d.ts","sourceRoot":"","sources":["../src/renderTexture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAS1F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,0BAA0B,CAAC,GAAG,aAAa,CAmChG"}
1
+ {"version":3,"file":"renderTexture.d.ts","sourceRoot":"","sources":["../src/renderTexture.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAgB,aAAa,EAAE,MAAM,0BAA0B,CAAC;AASxG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,0BAA0B,CAAC,GAAG,aAAa,CAiChG"}
@@ -1,7 +1,8 @@
1
- import { RenderTextureBackingKind } from '@flighthq/types/contract';
1
+ import { createEntity } from '@flighthq/entity/contract';
2
+ import { RenderTargetTextureSourceKind } from '@flighthq/types/contract';
2
3
  import { copySampler } from './sampler';
3
4
  import { createTexture } from './texture';
4
- // Creates a universal Texture with a GPU-origin render-target backing. Backend allocation stays lazy;
5
+ // Creates a universal Texture with a GPU-origin render-target source. Backend allocation stays lazy;
5
6
  // renderIntoGlRenderTexture realizes the target in one state and resolveGlTexture later returns its
6
7
  // color attachment without a CPU upload.
7
8
  export function createRenderTexture(options) {
@@ -10,23 +11,21 @@ export function createRenderTexture(options) {
10
11
  colorSpace: options.colorSpace ?? 'linear',
11
12
  flipX: options.flipX ?? false,
12
13
  flipY: options.flipY ?? false,
13
- storage: {
14
- dimension: '2d',
15
- image: null,
16
- target: {
17
- colorAttachments: options.colorAttachments,
18
- colorFormats: options.colorFormats,
19
- colorSpace,
20
- clearColors: options.clearColors,
21
- clearDepth: options.clearDepth,
22
- depth: options.depth,
23
- format: options.format,
24
- height: options.height,
25
- kind: RenderTextureBackingKind,
26
- sampleCount: options.sampleCount,
27
- width: options.width,
28
- },
29
- },
14
+ dimension: '2d',
15
+ source: createEntity({
16
+ colorAttachments: options.colorAttachments,
17
+ colorFormats: options.colorFormats,
18
+ colorSpace,
19
+ clearColors: options.clearColors,
20
+ clearDepth: options.clearDepth,
21
+ depth: options.depth,
22
+ format: options.format,
23
+ height: options.height,
24
+ kind: RenderTargetTextureSourceKind,
25
+ sampleCount: options.sampleCount,
26
+ version: 0,
27
+ width: options.width,
28
+ }),
30
29
  uvRotation: options.uvRotation,
31
30
  });
32
31
  if (options.sampler !== undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"renderTexture.js","sourceRoot":"","sources":["../src/renderTexture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa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,OAAO,CAAC,WAAW;YAChC,OAAO,EAAE,CAAC;YACV,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAiB;QAClB,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAkB,CAAC;IACpB,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;QAAE,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACjF,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACtC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/texture.d.ts CHANGED
@@ -1,22 +1,45 @@
1
- import type { CreateTextureOptions, ImageBacking, Matrix3Like, Texture, TextureBackingKind, TextureLike, TextureUvTransform, Vector2Like } from '@flighthq/types/contract';
1
+ import type { CreateTextureOptions, TextureSource, Matrix3Like, Texture, Texture2D, TextureSourceKind, TextureLike, TextureUvTransform, Vector2Like } from '@flighthq/types/contract';
2
2
  export declare function cloneTexture(source: Readonly<TextureLike>): Texture;
3
3
  export declare function copyTexture(out: TextureLike, source: Readonly<TextureLike>): void;
4
- export declare function createTexture(opts?: Readonly<CreateTextureOptions>): Texture;
4
+ type CreateTexture2DOptions = Extract<CreateTextureOptions, {
5
+ dimension?: '2d';
6
+ }>;
7
+ type CreateTexture2DArrayOptions = Extract<CreateTextureOptions, {
8
+ dimension: '2d-array';
9
+ }>;
10
+ type CreateTexture3DOptions = Extract<CreateTextureOptions, {
11
+ dimension: '3d';
12
+ }>;
13
+ type CreateTextureCubeOptions = Extract<CreateTextureOptions, {
14
+ dimension: 'cube';
15
+ }>;
16
+ export declare function createTexture(opts?: Readonly<CreateTexture2DOptions>): Texture2D;
17
+ export declare function createTexture(opts: Readonly<CreateTexture2DArrayOptions>): Extract<Texture, {
18
+ dimension: '2d-array';
19
+ }>;
20
+ export declare function createTexture(opts: Readonly<CreateTexture3DOptions>): Extract<Texture, {
21
+ dimension: '3d';
22
+ }>;
23
+ export declare function createTexture(opts: Readonly<CreateTextureCubeOptions>): Extract<Texture, {
24
+ dimension: 'cube';
25
+ }>;
5
26
  export declare function equalsTexture(a: Readonly<TextureLike> | null | undefined, b: Readonly<TextureLike> | null | undefined): boolean;
6
- export declare function getTextureBackingKind(texture: Readonly<TextureLike>): TextureBackingKind | null;
7
27
  export declare function getTextureHeight(texture: Readonly<TextureLike>): number;
8
28
  export declare function getTextureInverseUvMatrix(out: Matrix3Like, texture: Readonly<TextureLike>): void;
29
+ export declare function getTextureSource(texture: Readonly<TextureLike>): TextureSource | null;
30
+ export declare function getTextureSourceKind(texture: Readonly<TextureLike>): TextureSourceKind | null;
9
31
  export declare function getTextureUvMatrix(out: Matrix3Like, texture: Readonly<TextureUvTransform>): void;
10
32
  export declare function getTextureWidth(texture: Readonly<TextureLike>): number;
11
- export declare function hasTextureBacking(texture: Readonly<TextureLike>): boolean;
33
+ export declare function hasTextureSource(texture: Readonly<TextureLike>): boolean;
12
34
  export declare function hasTextureUvTransform(texture: Readonly<TextureUvTransform>): boolean;
13
35
  export declare function isTextureReady(texture: Readonly<TextureLike>): boolean;
14
36
  export declare function resetTextureUvTransform(texture: TextureLike): void;
15
37
  export declare function setTextureFlip(texture: TextureLike, flipX: boolean, flipY: boolean): void;
16
- export declare function setTextureImage(texture: TextureLike, image: ImageBacking | null): void;
38
+ export declare function setTextureSource(texture: TextureLike, source: TextureSource | null): void;
17
39
  export declare function setTextureUvFromPixelRect(texture: TextureLike, x: number, y: number, width: number, height: number): void;
18
40
  export declare function setTextureUvOffset(texture: TextureLike, x: number, y: number): void;
19
41
  export declare function setTextureUvRotation(texture: TextureLike, radians: number): void;
20
42
  export declare function setTextureUvScale(texture: TextureLike, x: number, y: number): void;
21
43
  export declare function transformTextureUv(out: Vector2Like, texture: Readonly<TextureLike>, u: number, v: number): void;
44
+ export {};
22
45
  //# sourceMappingURL=texture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"texture.d.ts","sourceRoot":"","sources":["../src/texture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACX,OAAO,EACP,kBAAkB,EAElB,WAAW,EAEX,kBAAkB,EAClB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAoClC,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,OAAO,CAYnE;AAKD,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAkBjF;AAKD,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAiB5E;AAID,wBAAgB,aAAa,CAC3B,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3C,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,GAC1C,OAAO,CAgBT;AAKD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,kBAAkB,GAAG,IAAI,CAI/F;AAGD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,CAIvE;AAQD,wBAAgB,yBAAyB,CAAC,GAAG,E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AAC,GAAG,OAAO,CAUpF;AAID,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,OAAO,CAEtE;AAID,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAQlE;AAKD,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAGzF;AAID,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAKzF;AAoBD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,WAAW,EACpB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAcN;AAID,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAGnF;AAGD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhF;AAGD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAGlF;AAMD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAa/G"}
package/dist/texture.js CHANGED
@@ -1,57 +1,56 @@
1
1
  import { createEntity } from '@flighthq/entity/contract';
2
2
  import { cloneVector2, copyVector2, createVector2, inverseMatrix3 } from '@flighthq/geometry/contract';
3
3
  import { cloneSampler, copySampler, createSampler, equalsSampler } from './sampler';
4
- function cloneTextureStorage(storage) {
5
- switch (storage.dimension) {
4
+ function getFirstTextureSource(texture) {
5
+ switch (texture.dimension) {
6
6
  case '2d':
7
- return { dimension: '2d', image: storage.image, target: storage.target };
8
- case '2d-array':
9
- return { dimension: '2d-array', images: storage.images.slice(), target: storage.target };
10
7
  case '3d':
11
- return { dimension: '3d', target: storage.target, volume: storage.volume };
12
- case 'cube':
13
- return {
14
- dimension: 'cube',
15
- images: storage.images.slice(),
16
- target: storage.target,
17
- };
18
- }
19
- }
20
- function getTextureStorageImage(storage) {
21
- switch (storage.dimension) {
22
- case '2d':
23
- return storage.image;
8
+ return texture.source;
24
9
  case '2d-array':
25
10
  case 'cube':
26
- return storage.images.find((image) => image !== null) ?? null;
27
- case '3d':
28
- return null;
11
+ return texture.sources.find((source) => source !== null) ?? null;
29
12
  }
30
13
  }
31
- // Allocates an independent Texture over the SAME image pixels: the ImageResource reference is shared
32
- // through a fresh storage record (clone the resource separately to duplicate its content identity),
33
- // while the Sampler and uv-transform vectors are deep-cloned for independent sampling.
14
+ // Allocates an independent sampling view over the same source identity. Sampler and uv-transform
15
+ // vectors are deep-cloned; array/cube source lists receive a fresh list.
34
16
  export function cloneTexture(source) {
35
- return createEntity({
17
+ const common = {
36
18
  colorSpace: source.colorSpace,
37
19
  flipX: source.flipX,
38
20
  flipY: source.flipY,
39
21
  sampler: cloneSampler(source.sampler),
40
- storage: cloneTextureStorage(source.storage),
41
22
  uvOffset: cloneVector2(source.uvOffset),
42
23
  uvRotation: source.uvRotation,
43
24
  uvScale: cloneVector2(source.uvScale),
44
25
  version: source.version >>> 0,
45
- });
26
+ };
27
+ switch (source.dimension) {
28
+ case '2d':
29
+ return createEntity({ ...common, dimension: '2d', source: source.source });
30
+ case '2d-array':
31
+ return createEntity({
32
+ ...common,
33
+ dimension: '2d-array',
34
+ sources: source.sources.slice(),
35
+ });
36
+ case '3d':
37
+ return createEntity({ ...common, dimension: '3d', source: source.source });
38
+ case 'cube':
39
+ return createEntity({
40
+ ...common,
41
+ dimension: 'cube',
42
+ sources: source.sources.slice(),
43
+ });
44
+ }
46
45
  }
47
- // Copies every Texture field from source into out in place. The image reference is shared; the
48
- // storage record, Sampler, and uv-transform vectors are copied into out's existing objects (their
49
- // identities are preserved). Safe when out aliases source.
46
+ // Copies every mutable field from source into a same-dimension out. Dimension is creation-time
47
+ // identity and never shape-shifts; source identities remain shared.
50
48
  export function copyTexture(out, source) {
49
+ if (out.dimension !== source.dimension)
50
+ throw new Error('copyTexture requires matching dimensions');
51
51
  const colorSpace = source.colorSpace;
52
52
  const flipX = source.flipX;
53
53
  const flipY = source.flipY;
54
- const storage = cloneTextureStorage(source.storage);
55
54
  const uvRotation = source.uvRotation;
56
55
  const version = source.version >>> 0;
57
56
  copySampler(out.sampler, source.sampler);
@@ -60,28 +59,77 @@ export function copyTexture(out, source) {
60
59
  out.colorSpace = colorSpace;
61
60
  out.flipX = flipX;
62
61
  out.flipY = flipY;
63
- const outStorage = out.storage;
64
- for (const key of Object.keys(outStorage))
65
- delete outStorage[key];
66
- Object.assign(outStorage, storage);
62
+ switch (out.dimension) {
63
+ case '2d':
64
+ if (source.dimension !== '2d')
65
+ throw new Error('copyTexture requires matching dimensions');
66
+ out.source = source.source;
67
+ break;
68
+ case '2d-array':
69
+ if (source.dimension !== '2d-array')
70
+ throw new Error('copyTexture requires matching dimensions');
71
+ out.sources = source.sources.slice();
72
+ break;
73
+ case '3d':
74
+ if (source.dimension !== '3d')
75
+ throw new Error('copyTexture requires matching dimensions');
76
+ out.source = source.source;
77
+ break;
78
+ case 'cube':
79
+ if (source.dimension !== 'cube')
80
+ throw new Error('copyTexture requires matching dimensions');
81
+ out.sources = source.sources.slice();
82
+ break;
83
+ }
67
84
  out.uvRotation = uvRotation;
68
85
  out.version = version;
69
86
  }
70
- // Builds a Texture: 2D storage with an unbound image slot (null), a default Sampler, 'srgb' color space (the
71
- // albedo default — data maps override to 'linear'), and an identity KHR_texture_transform
72
- // (zero offset, unit scale, no rotation). Pass TextureLike fields to override any of these.
87
+ // Builds a flat Texture union. Two-dimensional content is the default and retains a null source
88
+ // sentinel during the loader migration; non-2D variants are selected by their required dimension.
73
89
  export function createTexture(opts) {
74
- const texture = createEntity({
90
+ const common = {
75
91
  colorSpace: opts?.colorSpace ?? 'srgb',
76
92
  flipX: opts?.flipX ?? false,
77
93
  flipY: opts?.flipY ?? false,
78
94
  sampler: opts?.sampler ? cloneSampler(opts.sampler) : createSampler(),
79
- storage: opts?.storage ? cloneTextureStorage(opts.storage) : { dimension: '2d', image: null },
80
95
  uvOffset: opts?.uvOffset ? cloneVector2(opts.uvOffset) : createVector2(0, 0),
81
96
  uvRotation: opts?.uvRotation ?? 0,
82
97
  uvScale: opts?.uvScale ? cloneVector2(opts.uvScale) : createVector2(1, 1),
83
98
  version: (opts?.version ?? 0) >>> 0,
84
- });
99
+ };
100
+ let texture;
101
+ switch (opts?.dimension) {
102
+ case '2d-array':
103
+ texture = createEntity({
104
+ ...common,
105
+ dimension: '2d-array',
106
+ sources: opts.sources?.slice() ?? [],
107
+ });
108
+ break;
109
+ case '3d':
110
+ texture = createEntity({
111
+ ...common,
112
+ dimension: '3d',
113
+ source: opts.source ?? null,
114
+ });
115
+ break;
116
+ case 'cube':
117
+ texture = createEntity({
118
+ ...common,
119
+ dimension: 'cube',
120
+ sources: (opts.sources?.slice() ?? [null, null, null, null, null, null]),
121
+ });
122
+ break;
123
+ default: {
124
+ const options = opts;
125
+ texture = createEntity({
126
+ ...common,
127
+ dimension: '2d',
128
+ source: options?.source ?? null,
129
+ });
130
+ break;
131
+ }
132
+ }
85
133
  const resource = opts?.resource;
86
134
  if (resource != null) {
87
135
  (resource.textures ??= []).push(texture);
@@ -89,7 +137,7 @@ export function createTexture(opts) {
89
137
  return texture;
90
138
  }
91
139
  // True when both textures describe identical state: same color space, same sampler state, the same
92
- // image reference, and the same uv-transform values. Returns false for null/undefined operands.
140
+ // source reference, and the same uv-transform values. Returns false for null/undefined operands.
93
141
  export function equalsTexture(a, b) {
94
142
  if (!a || !b)
95
143
  return false;
@@ -98,7 +146,7 @@ export function equalsTexture(a, b) {
98
146
  return (a.colorSpace === b.colorSpace &&
99
147
  a.flipX === b.flipX &&
100
148
  a.flipY === b.flipY &&
101
- equalsTextureStorage(a.storage, b.storage) &&
149
+ equalsTextureContent(a, b) &&
102
150
  a.uvRotation === b.uvRotation &&
103
151
  a.uvOffset.x === b.uvOffset.x &&
104
152
  a.uvOffset.y === b.uvOffset.y &&
@@ -107,21 +155,9 @@ export function equalsTexture(a, b) {
107
155
  a.version === b.version &&
108
156
  equalsSampler(a.sampler, b.sampler));
109
157
  }
110
- // Returns the open resolver key declared by the texture's one active backing, or null when unbound.
111
- // CPU-origin images own their key; GPU-origin targets own theirs, so TextureStorage carries no duplicate
112
- // discriminant.
113
- export function getTextureBackingKind(texture) {
114
- const storage = texture.storage;
115
- if (storage.dimension === '3d')
116
- return storage.volume?.kind ?? storage.target?.kind ?? null;
117
- return getTextureStorageImage(storage)?.kind ?? storage.target?.kind ?? null;
118
- }
119
- // Returns the height declared by the CPU image or render target backing, or -1 when unbound.
158
+ // Returns the height declared by the active source, or -1 when unbound.
120
159
  export function getTextureHeight(texture) {
121
- const storage = texture.storage;
122
- if (storage.dimension === '3d')
123
- return storage.volume?.height ?? storage.target?.height ?? -1;
124
- return getTextureStorageImage(storage)?.height ?? storage.target?.height ?? -1;
160
+ return getFirstTextureSource(texture)?.height ?? -1;
125
161
  }
126
162
  // Composes the KHR_texture_transform fields and inverts the result, producing the matrix that maps
127
163
  // already-transformed uv coordinates back to the unit-square source uv. The forward transform is
@@ -133,6 +169,15 @@ export function getTextureInverseUvMatrix(out, texture) {
133
169
  getTextureUvMatrix(out, texture);
134
170
  inverseMatrix3(out, out);
135
171
  }
172
+ // Returns the first active source. Array and cube textures yield their first bound layer/face;
173
+ // unbound and entirely incomplete textures return null.
174
+ export function getTextureSource(texture) {
175
+ return getFirstTextureSource(texture);
176
+ }
177
+ // Returns the open resolver key declared by the texture's active source, or null when unbound.
178
+ export function getTextureSourceKind(texture) {
179
+ return getFirstTextureSource(texture)?.kind ?? null;
180
+ }
136
181
  // Composes the KHR_texture_transform fields (uvOffset, uvRotation, uvScale) into the 3×3 matrix
137
182
  // a shader consumes at sample time. Column-major layout matching @flighthq/geometry Matrix3, so it
138
183
  // uploads to a GL/WGSL mat3 uniform with no transpose. The resulting transform applies:
@@ -166,16 +211,13 @@ export function getTextureUvMatrix(out, texture) {
166
211
  m[7] = ty; // (1,2)
167
212
  m[8] = 1; // (2,2)
168
213
  }
169
- // Returns the width declared by the CPU image or render target backing, or -1 when unbound.
214
+ // Returns the width declared by the active source, or -1 when unbound.
170
215
  export function getTextureWidth(texture) {
171
- const storage = texture.storage;
172
- if (storage.dimension === '3d')
173
- return storage.volume?.width ?? storage.target?.width ?? -1;
174
- return getTextureStorageImage(storage)?.width ?? storage.target?.width ?? -1;
216
+ return getFirstTextureSource(texture)?.width ?? -1;
175
217
  }
176
- // True when the texture declares either a CPU-origin image or a GPU-origin target backing.
177
- export function hasTextureBacking(texture) {
178
- return getTextureBackingKind(texture) !== null;
218
+ // True when the texture declares at least one source.
219
+ export function hasTextureSource(texture) {
220
+ return getTextureSourceKind(texture) !== null;
179
221
  }
180
222
  // True when the texture carries a non-identity KHR_texture_transform — any non-unit scale, non-zero
181
223
  // offset, or non-zero rotation. GPU material renderers gate the HAS_UV_TRANSFORM shader variant on
@@ -190,13 +232,13 @@ export function hasTextureUvTransform(texture) {
190
232
  texture.uvOffset.y !== 0 ||
191
233
  texture.uvRotation !== 0);
192
234
  }
193
- // True once the texture references a pixel source. A texture whose storage has a null image is treated as an
194
- // absent slot by materials, so this is the gate a material samples behind.
235
+ // True once the texture references a pixel source. A null source is treated as an absent slot by
236
+ // materials, so this is the gate a material samples behind.
195
237
  export function isTextureReady(texture) {
196
- return hasTextureBacking(texture);
238
+ return hasTextureSource(texture);
197
239
  }
198
240
  // Resets the KHR_texture_transform to identity in place: zero offset, no rotation, unit scale, and
199
- // no flip. Leaves storage, color space, sampler, and version untouched.
241
+ // no flip. Leaves the source, color space, sampler, and version untouched.
200
242
  export function resetTextureUvTransform(texture) {
201
243
  texture.flipX = false;
202
244
  texture.flipY = false;
@@ -213,32 +255,31 @@ export function setTextureFlip(texture, flipX, flipY) {
213
255
  texture.flipX = flipX;
214
256
  texture.flipY = flipY;
215
257
  }
216
- // Binds (or clears, with null) the texture's image source in place and advances the u32 dirty-bit.
258
+ // Binds (or clears, with null) the texture's source in place and advances the u32 dirty-bit.
217
259
  // Does not touch sampling state or the uv-transform.
218
- export function setTextureImage(texture, image) {
219
- if (texture.storage.dimension !== '2d')
220
- throw new Error('setTextureImage requires 2d texture storage');
221
- if (texture.storage.image === image)
260
+ export function setTextureSource(texture, source) {
261
+ if (texture.dimension !== '2d')
262
+ throw new Error('setTextureSource requires a Texture2D');
263
+ if (texture.source === source)
222
264
  return;
223
- texture.storage.image = image;
265
+ texture.source = source;
224
266
  texture.version = (texture.version + 1) >>> 0;
225
267
  }
226
- function equalsTextureStorage(a, b) {
227
- if (a.dimension !== b.dimension || a.target !== b.target)
268
+ function equalsTextureContent(a, b) {
269
+ if (a.dimension !== b.dimension)
228
270
  return false;
229
271
  switch (a.dimension) {
230
272
  case '2d':
231
- return b.dimension === '2d' && a.image === b.image;
273
+ case '3d':
274
+ return b.dimension === a.dimension && a.source === b.source;
232
275
  case '2d-array':
233
276
  case 'cube':
234
277
  return (b.dimension === a.dimension &&
235
- a.images.length === b.images.length &&
236
- a.images.every((image, index) => image === b.images[index]));
237
- case '3d':
238
- return b.dimension === '3d' && a.volume === b.volume;
278
+ a.sources.length === b.sources.length &&
279
+ a.sources.every((source, index) => source === b.sources[index]));
239
280
  }
240
281
  }
241
- // Maps a pixel-space rectangle in the texture's backing to its normalized uv window. An unbound
282
+ // Maps a pixel-space rectangle in the texture's source to its normalized uv window. An unbound
242
283
  // texture has no pixel extent, so it receives an empty window rather than dividing by a sentinel.
243
284
  export function setTextureUvFromPixelRect(texture, x, y, width, height) {
244
285
  const textureWidth = getTextureWidth(texture);