소스 검색

Merge pull request #17983 from TyLindberg/draco_preload

DRACOLoader: Add preload method
Michael Herzog 5 년 전
부모
커밋
ef17d6e800

+ 8 - 0
docs/examples/en/loaders/DRACOLoader.html

@@ -36,6 +36,9 @@
 		// Specify path to a folder containing WASM/JS decoding libraries.
 		loader.setDecoderPath( '/examples/js/libs/draco/' );
 
+		// Optional: Pre-fetch Draco WASM/JS module.
+		loader.preload();
+
 		// Load a Draco geometry
 		loader.load(
 			// resource URL
@@ -128,6 +131,11 @@
 		in the application.
 		</p>
 
+		<h3>[method:this preload]()</h3>
+		<p>
+		Requests the decoder libraries, if not already loaded.
+		</p>
+
 		<h3>[method:this dispose]()</h3>
 		<p>
 		Disposes of the decoder resources and deallocates memory. The decoder

+ 8 - 0
docs/examples/zh/loaders/DRACOLoader.html

@@ -36,6 +36,9 @@
 		// Specify path to a folder containing WASM/JS decoding libraries.
 		loader.setDecoderPath( '/examples/js/libs/draco/' );
 
+		// Optional: Pre-fetch Draco WASM/JS module.
+		loader.preload();
+
 		// Load a Draco geometry
 		loader.load(
 			// resource URL
@@ -128,6 +131,11 @@
 		in the application.
 		</p>
 
+		<h3>[method:this preload]()</h3>
+		<p>
+		Requests the decoder libraries, if not already loaded.
+		</p>
+
 		<h3>[method:this dispose]()</h3>
 		<p>
 		Disposes of the decoder resources and deallocates memory. The decoder

+ 8 - 0
examples/js/loaders/DRACOLoader.js

@@ -220,6 +220,14 @@ THREE.DRACOLoader.prototype = Object.assign( Object.create( THREE.Loader.prototy
 
 	},
 
+	preload: function () {
+
+		this._initDecoder();
+
+		return this;
+
+	},
+
 	_initDecoder: function () {
 
 		if ( this.decoderPending ) return this.decoderPending;

+ 1 - 0
examples/jsm/loaders/DRACOLoader.d.ts

@@ -12,6 +12,7 @@ export class DRACOLoader extends Loader {
 	setDecoderPath( path: string ): DRACOLoader;
 	setDecoderConfig( config: object ): DRACOLoader;
 	setWorkerLimit( workerLimit: number ): DRACOLoader;
+	preload(): DRACOLoader;
 	dispose(): DRACOLoader;
 
 }

+ 8 - 0
examples/jsm/loaders/DRACOLoader.js

@@ -227,6 +227,14 @@ DRACOLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	},
 
+	preload: function () {
+
+		this._initDecoder();
+
+		return this;
+
+	},
+
 	_initDecoder: function () {
 
 		if ( this.decoderPending ) return this.decoderPending;