Skip to content

Commit ef17d6e

Browse files
authored
Merge pull request #17983 from TyLindberg/draco_preload
DRACOLoader: Add preload method
2 parents 72a2490 + 828b01d commit ef17d6e

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

docs/examples/en/loaders/DRACOLoader.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ <h2>Example</h2>
3636
// Specify path to a folder containing WASM/JS decoding libraries.
3737
loader.setDecoderPath( '/examples/js/libs/draco/' );
3838

39+
// Optional: Pre-fetch Draco WASM/JS module.
40+
loader.preload();
41+
3942
// Load a Draco geometry
4043
loader.load(
4144
// resource URL
@@ -128,6 +131,11 @@ <h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
128131
in the application.
129132
</p>
130133

134+
<h3>[method:this preload]()</h3>
135+
<p>
136+
Requests the decoder libraries, if not already loaded.
137+
</p>
138+
131139
<h3>[method:this dispose]()</h3>
132140
<p>
133141
Disposes of the decoder resources and deallocates memory. The decoder

docs/examples/zh/loaders/DRACOLoader.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ <h2>Example</h2>
3636
// Specify path to a folder containing WASM/JS decoding libraries.
3737
loader.setDecoderPath( '/examples/js/libs/draco/' );
3838

39+
// Optional: Pre-fetch Draco WASM/JS module.
40+
loader.preload();
41+
3942
// Load a Draco geometry
4043
loader.load(
4144
// resource URL
@@ -128,6 +131,11 @@ <h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
128131
in the application.
129132
</p>
130133

134+
<h3>[method:this preload]()</h3>
135+
<p>
136+
Requests the decoder libraries, if not already loaded.
137+
</p>
138+
131139
<h3>[method:this dispose]()</h3>
132140
<p>
133141
Disposes of the decoder resources and deallocates memory. The decoder

examples/js/loaders/DRACOLoader.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ THREE.DRACOLoader.prototype = Object.assign( Object.create( THREE.Loader.prototy
220220

221221
},
222222

223+
preload: function () {
224+
225+
this._initDecoder();
226+
227+
return this;
228+
229+
},
230+
223231
_initDecoder: function () {
224232

225233
if ( this.decoderPending ) return this.decoderPending;

examples/jsm/loaders/DRACOLoader.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class DRACOLoader extends Loader {
1212
setDecoderPath( path: string ): DRACOLoader;
1313
setDecoderConfig( config: object ): DRACOLoader;
1414
setWorkerLimit( workerLimit: number ): DRACOLoader;
15+
preload(): DRACOLoader;
1516
dispose(): DRACOLoader;
1617

1718
}

examples/jsm/loaders/DRACOLoader.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ DRACOLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
227227

228228
},
229229

230+
preload: function () {
231+
232+
this._initDecoder();
233+
234+
return this;
235+
236+
},
237+
230238
_initDecoder: function () {
231239

232240
if ( this.decoderPending ) return this.decoderPending;

0 commit comments

Comments
 (0)