cesium/packages/engine/Source/Scene/ResourceCacheKey.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

602 lines
19 KiB
JavaScript
Raw Permalink Normal View History

2021-03-06 08:31:22 +08:00
import Check from "../Core/Check.js";
import Frozen from "../Core/Frozen.js";
2021-03-06 08:31:22 +08:00
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
2021-03-06 08:31:22 +08:00
import getAbsoluteUri from "../Core/getAbsoluteUri.js";
2021-04-08 05:24:54 +08:00
import GltfLoaderUtil from "./GltfLoaderUtil.js";
2021-07-24 07:14:30 +08:00
import hasExtension from "./hasExtension.js";
2021-03-06 08:31:22 +08:00
/**
* Compute cache keys for resources in {@link ResourceCache}.
2021-03-06 08:31:22 +08:00
*
* @namespace ResourceCacheKey
2021-03-06 08:31:22 +08:00
*
* @private
*/
const ResourceCacheKey = {};
2021-03-06 08:31:22 +08:00
function getExternalResourceCacheKey(resource) {
2021-03-06 08:31:22 +08:00
return getAbsoluteUri(resource.url);
}
2021-04-08 05:24:54 +08:00
function getBufferViewCacheKey(bufferView) {
2024-04-26 11:30:17 +08:00
let { byteOffset, byteLength } = bufferView;
2021-07-24 07:14:30 +08:00
if (hasExtension(bufferView, "EXT_meshopt_compression")) {
2021-07-28 09:17:38 +08:00
const meshopt = bufferView.extensions.EXT_meshopt_compression;
2025-03-04 03:03:53 +08:00
byteOffset = meshopt.byteOffset ?? 0;
2021-07-24 07:14:30 +08:00
byteLength = meshopt.byteLength;
}
return `${byteOffset}-${byteOffset + byteLength}`;
2021-04-08 05:24:54 +08:00
}
function getAccessorCacheKey(accessor, bufferView) {
const byteOffset = bufferView.byteOffset + accessor.byteOffset;
2024-04-26 11:30:17 +08:00
const { componentType, type, count } = accessor;
return `${byteOffset}-${componentType}-${type}-${count}`;
2021-04-08 05:24:54 +08:00
}
function getEmbeddedBufferCacheKey(parentResource, bufferId) {
const parentCacheKey = getExternalResourceCacheKey(parentResource);
return `${parentCacheKey}-buffer-id-${bufferId}`;
2021-04-08 05:24:54 +08:00
}
function getBufferCacheKey(buffer, bufferId, gltfResource, baseResource) {
if (defined(buffer.uri)) {
const resource = baseResource.getDerivedResource({
url: buffer.uri,
});
2024-04-26 11:30:17 +08:00
return getExternalResourceCacheKey(resource);
2021-04-08 05:24:54 +08:00
}
return getEmbeddedBufferCacheKey(gltfResource, bufferId);
}
function getDracoCacheKey(gltf, draco, gltfResource, baseResource) {
const bufferViewId = draco.bufferView;
const bufferView = gltf.bufferViews[bufferViewId];
const bufferId = bufferView.buffer;
const buffer = gltf.buffers[bufferId];
const bufferCacheKey = getBufferCacheKey(
buffer,
bufferId,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
const bufferViewCacheKey = getBufferViewCacheKey(bufferView);
return `${bufferCacheKey}-range-${bufferViewCacheKey}`;
2021-04-08 05:24:54 +08:00
}
function getSpzCacheKey(gltf, primitive, gltfResource, baseResource) {
const bufferViewId = 0;
const bufferView = gltf.bufferViews[bufferViewId];
const bufferId = bufferView.buffer;
const buffer = gltf.buffers[bufferId];
const bufferCacheKey = getBufferCacheKey(
buffer,
bufferId,
gltfResource,
baseResource,
);
const bufferViewCacheKey = getBufferViewCacheKey(bufferView);
return `${bufferCacheKey}-range-${bufferViewCacheKey}`;
}
function getImageCacheKey(gltf, imageId, gltfResource, baseResource) {
const image = gltf.images[imageId];
const bufferViewId = image.bufferView;
const uri = image.uri;
2021-04-08 05:24:54 +08:00
if (defined(uri)) {
const resource = baseResource.getDerivedResource({
url: uri,
});
return getExternalResourceCacheKey(resource);
}
const bufferView = gltf.bufferViews[bufferViewId];
const bufferId = bufferView.buffer;
const buffer = gltf.buffers[bufferId];
const bufferCacheKey = getBufferCacheKey(
buffer,
bufferId,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
const bufferViewCacheKey = getBufferViewCacheKey(bufferView);
return `${bufferCacheKey}-range-${bufferViewCacheKey}`;
2021-04-08 05:24:54 +08:00
}
function getSamplerCacheKey(gltf, textureInfo) {
const sampler = GltfLoaderUtil.createSampler({
gltf: gltf,
textureInfo: textureInfo,
});
return `${sampler.wrapS}-${sampler.wrapT}-${sampler.minificationFilter}-${sampler.magnificationFilter}`;
2021-04-08 05:24:54 +08:00
}
2021-03-26 09:21:58 +08:00
/**
* Gets the schema cache key.
*
* @param {object} options Object with the following properties:
* @param {object} [options.schema] An object that explicitly defines a schema JSON. Mutually exclusive with options.resource.
2021-03-26 09:21:58 +08:00
* @param {Resource} [options.resource] The {@link Resource} pointing to the schema JSON. Mutually exclusive with options.schema.
*
* @returns {string} The schema cache key.
2021-03-26 09:21:58 +08:00
*
* @exception {DeveloperError} One of options.schema and options.resource must be defined.
* @private
2021-03-26 09:21:58 +08:00
*/
2021-03-24 01:37:11 +08:00
ResourceCacheKey.getSchemaCacheKey = function (options) {
2024-04-26 11:30:17 +08:00
const { schema, resource } = options;
2021-03-24 01:37:11 +08:00
//>>includeStart('debug', pragmas.debug);
if (defined(schema) === defined(resource)) {
2021-03-24 01:37:11 +08:00
throw new DeveloperError(
"One of options.schema and options.resource must be defined.",
2021-03-24 01:37:11 +08:00
);
}
//>>includeEnd('debug');
2021-03-26 09:21:58 +08:00
if (defined(schema)) {
return `embedded-schema:${JSON.stringify(schema)}`;
2021-03-24 01:37:11 +08:00
}
return `external-schema:${getExternalResourceCacheKey(resource)}`;
2021-03-24 01:37:11 +08:00
};
2021-03-06 08:31:22 +08:00
/**
* Gets the external buffer cache key.
2021-03-06 08:31:22 +08:00
*
* @param {object} options Object with the following properties:
* @param {Resource} options.resource The {@link Resource} pointing to the external buffer.
2021-03-06 08:31:22 +08:00
*
* @returns {string} The external buffer cache key.
* @private
2021-03-06 08:31:22 +08:00
*/
ResourceCacheKey.getExternalBufferCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const { resource } = options;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.resource", resource);
//>>includeEnd('debug');
2024-04-26 11:30:17 +08:00
return `external-buffer:${getExternalResourceCacheKey(resource)}`;
};
/**
* Gets the embedded buffer cache key.
*
* @param {object} options Object with the following properties:
* @param {Resource} options.parentResource The {@link Resource} containing the embedded buffer.
* @param {number} options.bufferId A unique identifier of the embedded buffer within the parent resource.
*
* @returns {string} The embedded buffer cache key.
* @private
*/
ResourceCacheKey.getEmbeddedBufferCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const { parentResource, bufferId } = options;
2021-03-06 08:31:22 +08:00
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.parentResource", parentResource);
2021-03-17 11:09:43 +08:00
Check.typeOf.number("options.bufferId", bufferId);
2021-03-06 08:31:22 +08:00
//>>includeEnd('debug');
return `embedded-buffer:${getEmbeddedBufferCacheKey(
parentResource,
bufferId,
)}`;
2021-04-08 05:24:54 +08:00
};
/**
* Gets the glTF cache key.
*
* @param {object} options Object with the following properties:
2021-04-13 09:36:37 +08:00
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
2021-04-08 05:24:54 +08:00
*
* @returns {string} The glTF cache key.
* @private
2021-04-08 05:24:54 +08:00
*/
ResourceCacheKey.getGltfCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const { gltfResource } = options;
2021-04-08 05:24:54 +08:00
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.gltfResource", gltfResource);
//>>includeEnd('debug');
return `gltf:${getExternalResourceCacheKey(gltfResource)}`;
2021-04-08 05:24:54 +08:00
};
/**
* Gets the buffer view cache key.
*
* @param {object} options Object with the following properties:
* @param {object} options.gltf The glTF JSON.
* @param {number} options.bufferViewId The bufferView ID.
2021-04-13 09:36:37 +08:00
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
2021-04-08 05:24:54 +08:00
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
*
* @returns {string} The buffer view cache key.
* @private
2021-04-08 05:24:54 +08:00
*/
ResourceCacheKey.getBufferViewCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const { gltf, bufferViewId, gltfResource, baseResource } = options;
2021-04-08 05:24:54 +08:00
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.gltf", gltf);
Check.typeOf.number("options.bufferViewId", bufferViewId);
Check.typeOf.object("options.gltfResource", gltfResource);
Check.typeOf.object("options.baseResource", baseResource);
//>>includeEnd('debug');
const bufferView = gltf.bufferViews[bufferViewId];
let bufferId = bufferView.buffer;
const buffer = gltf.buffers[bufferId];
2021-07-28 09:17:38 +08:00
if (hasExtension(bufferView, "EXT_meshopt_compression")) {
const meshopt = bufferView.extensions.EXT_meshopt_compression;
bufferId = meshopt.buffer;
2021-07-24 07:14:30 +08:00
}
2021-04-08 05:24:54 +08:00
const bufferCacheKey = getBufferCacheKey(
buffer,
bufferId,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
const bufferViewCacheKey = getBufferViewCacheKey(bufferView);
return `buffer-view:${bufferCacheKey}-range-${bufferViewCacheKey}`;
2021-04-08 05:24:54 +08:00
};
/**
* Gets the Draco cache key.
*
* @param {object} options Object with the following properties:
* @param {object} options.gltf The glTF JSON.
* @param {object} options.draco The Draco extension object.
2021-04-13 09:36:37 +08:00
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
2021-04-08 05:24:54 +08:00
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
*
* @returns {string} The Draco cache key.
* @private
2021-04-08 05:24:54 +08:00
*/
ResourceCacheKey.getDracoCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const { gltf, draco, gltfResource, baseResource } = options;
2021-04-08 05:24:54 +08:00
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.gltf", gltf);
Check.typeOf.object("options.draco", draco);
Check.typeOf.object("options.gltfResource", gltfResource);
Check.typeOf.object("options.baseResource", baseResource);
//>>includeEnd('debug');
return `draco:${getDracoCacheKey(gltf, draco, gltfResource, baseResource)}`;
2021-04-08 05:24:54 +08:00
};
ResourceCacheKey.getSpzCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
const { gltf, primitive, gltfResource, baseResource } = options;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.gltf", gltf);
Check.typeOf.object("options.primitive", primitive);
Check.typeOf.object("options.gltfResource", gltfResource);
Check.typeOf.object("options.baseResource", baseResource);
//>>includeEnd('debug');
return `spz:${getSpzCacheKey(gltf, primitive, gltfResource, baseResource)}`;
};
2021-04-08 05:24:54 +08:00
/**
* Gets the vertex buffer cache key.
*
* @param {object} options Object with the following properties:
* @param {object} options.gltf The glTF JSON.
2021-04-13 09:36:37 +08:00
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
2021-04-08 05:24:54 +08:00
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
* @param {FrameState} options.frameState The frame state.
* @param {number} [options.bufferViewId] The bufferView ID corresponding to the vertex buffer.
* @param {object} [options.draco] The Draco extension object.
* @param {string} [options.attributeSemantic] The attribute semantic, e.g. POSITION or NORMAL.
* @param {boolean} [options.dequantize=false] Determines whether or not the vertex buffer will be dequantized on the CPU.
* @param {boolean} [options.loadBuffer=false] Load vertex buffer as a GPU vertex buffer.
* @param {boolean} [options.loadTypedArray=false] Load vertex buffer as a typed array.
2021-04-08 05:24:54 +08:00
* @exception {DeveloperError} One of options.bufferViewId and options.draco must be defined.
2021-07-28 09:17:38 +08:00
* @exception {DeveloperError} When options.draco is defined options.attributeSemantic must also be defined.
2021-04-08 05:24:54 +08:00
*
* @returns {string} The vertex buffer cache key.
* @private
2021-04-08 05:24:54 +08:00
*/
ResourceCacheKey.getVertexBufferCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const {
gltf,
gltfResource,
baseResource,
frameState,
bufferViewId,
draco,
2025-04-16 17:03:32 +08:00
spz,
2024-04-26 11:30:17 +08:00
attributeSemantic,
dequantize = false,
loadBuffer = false,
loadTypedArray = false,
} = options;
2021-04-08 05:24:54 +08:00
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.gltf", gltf);
Check.typeOf.object("options.gltfResource", gltfResource);
Check.typeOf.object("options.baseResource", baseResource);
Check.typeOf.object("options.frameState", frameState);
2021-04-08 05:24:54 +08:00
const hasBufferViewId = defined(bufferViewId);
const hasDraco = hasDracoCompression(draco, attributeSemantic);
2021-07-28 09:17:38 +08:00
const hasAttributeSemantic = defined(attributeSemantic);
2025-04-17 22:01:20 +08:00
const hasSpz = defined(spz);
2025-04-16 17:03:32 +08:00
2025-06-07 05:32:11 +08:00
if (hasBufferViewId === (hasDraco !== hasSpz)) {
throw new DeveloperError(
"One of options.bufferViewId and options.draco must be defined.",
);
}
if (hasDraco && !hasAttributeSemantic) {
throw new DeveloperError(
"When options.draco is defined options.attributeSemantic must also be defined.",
);
2021-04-08 05:24:54 +08:00
}
2025-06-07 05:32:11 +08:00
if (hasDraco) {
Check.typeOf.object("options.draco", draco);
Check.typeOf.string("options.attributeSemantic", attributeSemantic);
}
if (!loadBuffer && !loadTypedArray) {
throw new DeveloperError(
"At least one of loadBuffer and loadTypedArray must be true.",
);
}
2021-04-08 05:24:54 +08:00
//>>includeEnd('debug');
let cacheKeySuffix = "";
if (dequantize) {
cacheKeySuffix += "-dequantize";
}
2022-05-25 03:04:20 +08:00
if (loadBuffer) {
cacheKeySuffix += "-buffer";
cacheKeySuffix += `-context-${frameState.context.id}`;
2022-05-25 03:04:20 +08:00
}
if (loadTypedArray) {
cacheKeySuffix += "-typed-array";
}
2021-04-08 05:24:54 +08:00
if (defined(draco)) {
const dracoCacheKey = getDracoCacheKey(
gltf,
draco,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
return `vertex-buffer:${dracoCacheKey}-draco-${attributeSemantic}${cacheKeySuffix}`;
2021-04-08 05:24:54 +08:00
}
2025-04-16 17:03:32 +08:00
if (spz) {
const spzCacheKey = getSpzCacheKey(gltf, spz, gltfResource, baseResource);
return `vertex-buffer:${spzCacheKey}-spz-${attributeSemantic}${cacheKeySuffix}`;
}
2021-04-08 05:24:54 +08:00
const bufferView = gltf.bufferViews[bufferViewId];
const bufferId = bufferView.buffer;
const buffer = gltf.buffers[bufferId];
const bufferCacheKey = getBufferCacheKey(
buffer,
bufferId,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
const bufferViewCacheKey = getBufferViewCacheKey(bufferView);
return `vertex-buffer:${bufferCacheKey}-range-${bufferViewCacheKey}${cacheKeySuffix}`;
2021-04-08 05:24:54 +08:00
};
function hasDracoCompression(draco, semantic) {
return (
defined(draco) &&
defined(draco.attributes) &&
defined(draco.attributes[semantic])
);
}
2021-04-08 05:24:54 +08:00
/**
* Gets the index buffer cache key.
*
* @param {object} options Object with the following properties:
* @param {object} options.gltf The glTF JSON.
* @param {number} options.accessorId The accessor ID corresponding to the index buffer.
2021-04-13 09:36:37 +08:00
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
2021-04-08 05:24:54 +08:00
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
* @param {FrameState} options.frameState The frame state.
* @param {object} [options.draco] The Draco extension object.
* @param {boolean} [options.loadBuffer=false] Load index buffer as a GPU index buffer.
* @param {boolean} [options.loadTypedArray=false] Load index buffer as a typed array.
2021-04-08 05:24:54 +08:00
*
* @returns {string} The index buffer cache key.
* @private
2021-04-08 05:24:54 +08:00
*/
ResourceCacheKey.getIndexBufferCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const {
gltf,
accessorId,
gltfResource,
baseResource,
frameState,
draco,
loadBuffer = false,
loadTypedArray = false,
} = options;
2021-04-08 05:24:54 +08:00
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.gltf", gltf);
Check.typeOf.number("options.accessorId", accessorId);
Check.typeOf.object("options.gltfResource", gltfResource);
Check.typeOf.object("options.baseResource", baseResource);
Check.typeOf.object("options.frameState", frameState);
2022-05-25 03:04:20 +08:00
if (!loadBuffer && !loadTypedArray) {
throw new DeveloperError(
"At least one of loadBuffer and loadTypedArray must be true.",
2022-05-25 03:04:20 +08:00
);
}
2021-04-08 05:24:54 +08:00
//>>includeEnd('debug');
let cacheKeySuffix = "";
2022-05-25 03:04:20 +08:00
if (loadBuffer) {
cacheKeySuffix += "-buffer";
cacheKeySuffix += `-context-${frameState.context.id}`;
2022-05-25 03:04:20 +08:00
}
if (loadTypedArray) {
cacheKeySuffix += "-typed-array";
}
2021-04-08 05:24:54 +08:00
if (defined(draco)) {
const dracoCacheKey = getDracoCacheKey(
gltf,
draco,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
return `index-buffer:${dracoCacheKey}-draco${cacheKeySuffix}`;
2021-04-08 05:24:54 +08:00
}
const accessor = gltf.accessors[accessorId];
const bufferViewId = accessor.bufferView;
const bufferView = gltf.bufferViews[bufferViewId];
const bufferId = bufferView.buffer;
const buffer = gltf.buffers[bufferId];
const bufferCacheKey = getBufferCacheKey(
buffer,
bufferId,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
const accessorCacheKey = getAccessorCacheKey(accessor, bufferView);
return `index-buffer:${bufferCacheKey}-accessor-${accessorCacheKey}${cacheKeySuffix}`;
2021-04-08 05:24:54 +08:00
};
/**
* Gets the image cache key.
*
* @param {object} options Object with the following properties:
* @param {object} options.gltf The glTF JSON.
* @param {number} options.imageId The image ID.
2021-04-13 09:36:37 +08:00
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
2021-04-08 05:24:54 +08:00
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
*
* @returns {string} The image cache key.
* @private
2021-04-08 05:24:54 +08:00
*/
ResourceCacheKey.getImageCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const { gltf, imageId, gltfResource, baseResource } = options;
2021-04-08 05:24:54 +08:00
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.gltf", gltf);
Check.typeOf.number("options.imageId", imageId);
Check.typeOf.object("options.gltfResource", gltfResource);
Check.typeOf.object("options.baseResource", baseResource);
//>>includeEnd('debug');
const imageCacheKey = getImageCacheKey(
gltf,
imageId,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
return `image:${imageCacheKey}`;
2021-04-08 05:24:54 +08:00
};
/**
* Gets the texture cache key.
*
* @param {object} options Object with the following properties:
* @param {object} options.gltf The glTF JSON.
* @param {object} options.textureInfo The texture info object.
2021-04-13 09:36:37 +08:00
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
2021-04-08 05:24:54 +08:00
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
* @param {SupportedImageFormats} options.supportedImageFormats The supported image formats.
* @param {FrameState} options.frameState The frame state.
2021-04-08 05:24:54 +08:00
*
* @returns {string} The texture cache key.
* @private
2021-04-08 05:24:54 +08:00
*/
ResourceCacheKey.getTextureCacheKey = function (options) {
options = options ?? Frozen.EMPTY_OBJECT;
2024-04-26 11:30:17 +08:00
const {
gltf,
textureInfo,
gltfResource,
baseResource,
supportedImageFormats,
frameState,
} = options;
2021-04-08 05:24:54 +08:00
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("options.gltf", gltf);
Check.typeOf.object("options.textureInfo", textureInfo);
Check.typeOf.object("options.gltfResource", gltfResource);
Check.typeOf.object("options.baseResource", baseResource);
Check.typeOf.object("options.supportedImageFormats", supportedImageFormats);
Check.typeOf.object("options.frameState", frameState);
2021-04-08 05:24:54 +08:00
//>>includeEnd('debug');
const textureId = textureInfo.index;
const imageId = GltfLoaderUtil.getImageIdFromTexture({
gltf: gltf,
textureId: textureId,
supportedImageFormats: supportedImageFormats,
});
const imageCacheKey = getImageCacheKey(
gltf,
imageId,
gltfResource,
baseResource,
2021-04-08 05:24:54 +08:00
);
// Include the sampler cache key in the texture cache key since textures and
// samplers are coupled in WebGL 1. When upgrading to WebGL 2 consider
// removing the sampleCacheKey here.
const samplerCacheKey = getSamplerCacheKey(gltf, textureInfo);
return `texture:${imageCacheKey}-sampler-${samplerCacheKey}-context-${frameState.context.id}`;
2021-03-06 08:31:22 +08:00
};
export default ResourceCacheKey;