PageSourceSearch

https://planetazip.ru/wp-content/plugins/3d-scene-viewer/assets/js/3js/src/loaders/Cache.js

js planetazip.ru collected 2026-10-07 09:35:21 UTC 1,648 bytes, 87 lines download raw bytes

1/**
2 * @class
3 * @classdesc A simple caching system, used internally by {@link FileLoader}.
4 * To enable caching across all loaders that use {@link FileLoader}, add `THREE.Cache.enabled = true.` once in your app.
5 * @hideconstructor
6 */
7const Cache = {
8
9	/**
10	 * Whether caching is enabled or not.
11	 *
12	 * @static
13	 * @type {boolean}
14	 * @default false
15	 */
16	enabled: false,
17
18	/**
19	 * A dictionary that holds cached files.
20	 *
21	 * @static
22	 * @type {Object<string,Object>}
23	 */
24	files: {},
25
26	/**
27	 * Adds a cache entry with a key to reference the file. If this key already
28	 * holds a file, it is overwritten.
29	 *
30	 * @static
31	 * @param {string} key - The key to reference the cached file.
32	 * @param {Object} file -  The file to be cached.
33	 */
34	add: function ( key, file ) {
35
36		if ( this.enabled === false ) return;
37
38		// console.log( 'THREE.Cache', 'Adding key:', key );
39
40		this.files[ key ] = file;
41
42	},
43
44	/**
45	 * Gets the cached value for the given key.
46	 *
47	 * @static
48	 * @param {string} key - The key to reference the cached file.
49	 * @return {Object|undefined} The cached file. If the key does not exist `undefined` is returned.
50	 */
51	get: function ( key ) {
52
53		if ( this.enabled === false ) return;
54
55		// console.log( 'THREE.Cache', 'Checking key:', key );
56
57		return this.files[ key ];
58
59	},
60
61	/**
62	 * Removes the cached file associated with the given key.
63	 *
64	 * @static
65	 * @param {string} key - The key to reference the cached file.
66	 */
67	remove: function ( key ) {
68
69		delete this.files[ key ];
70
71	},
72
73	/**
74	 * Remove all values from the cache.
75	 *
76	 * @static
77	 */
78	clear: function () {
79
80		this.files = {};
81
82	}
83
84};
85
86
87export { Cache };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.