瀏覽代碼

Disable Cache by default

The global cache should be opt-in. #6834
dubejf 10 年之前
父節點
當前提交
6ec6702eac
共有 2 個文件被更改,包括 14 次插入3 次删除
  1. 8 3
      docs/api/loaders/Cache.html
  2. 6 0
      src/loaders/Cache.js

+ 8 - 3
docs/api/loaders/Cache.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html lang="en">
 <html lang="en">
 	<head>
 	<head>
-		<meta charset="utf-8" />
+		<meta charset="utf-8" />
 		<base href="../../" />
 		<base href="../../" />
 		<script src="list.js"></script>
 		<script src="list.js"></script>
 		<script src="page.js"></script>
 		<script src="page.js"></script>
@@ -23,6 +23,11 @@
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>
 
 
+		<h3>[property:Boolean enabled]</h3>
+		<div>
+		Whether caching is enabled. Default is *false*.
+		</div>
+
 		<h3>[property:Object files]</h3>
 		<h3>[property:Object files]</h3>
 		<div>
 		<div>
 		An [page:Object object] that hold cached values.
 		An [page:Object object] that hold cached values.
@@ -34,7 +39,7 @@
 		<h3>[method:null add]( [page:String key], value )</h3>
 		<h3>[method:null add]( [page:String key], value )</h3>
 		<div>
 		<div>
 		[page:String key] — required. A string key <br />
 		[page:String key] — required. A string key <br />
-		[page:Object] value — <br />
+		[page:Object] value — A value <br />
 		</div>
 		</div>
 		<div>
 		<div>
 		Adds a cache entry with that key to hold the value. If this key already holds a value, it is overwritten.
 		Adds a cache entry with that key to hold the value. If this key already holds a value, it is overwritten.
@@ -45,7 +50,7 @@
 		[page:String key] — required. A string key <br />
 		[page:String key] — required. A string key <br />
 		</div>
 		</div>
 		<div>
 		<div>
-		Get the value of key. If the key does not exist the null value is returned.
+		Get the value of key. If the key does not exist *undefined* is returned.
 		</div>
 		</div>
 
 
 		<h3>[method:null remove]( [page:String key] )</h3>
 		<h3>[method:null remove]( [page:String key] )</h3>

+ 6 - 0
src/loaders/Cache.js

@@ -4,10 +4,14 @@
 
 
 THREE.Cache = {
 THREE.Cache = {
 
 
+	enabled: false,
+
 	files: {},
 	files: {},
 
 
 	add: function ( key, file ) {
 	add: function ( key, file ) {
 
 
+		if ( this.enabled === false ) return;
+
 		// console.log( 'THREE.Cache', 'Adding key:', key );
 		// console.log( 'THREE.Cache', 'Adding key:', key );
 
 
 		this.files[ key ] = file;
 		this.files[ key ] = file;
@@ -16,6 +20,8 @@ THREE.Cache = {
 
 
 	get: function ( key ) {
 	get: function ( key ) {
 
 
+		if ( this.enabled === false ) return;
+
 		// console.log( 'THREE.Cache', 'Checking key:', key );
 		// console.log( 'THREE.Cache', 'Checking key:', key );
 
 
 		return this.files[ key ];
 		return this.files[ key ];