Skip to content

Commit

Permalink
Merge pull request #17332 from Mugen87/dev29
Browse files Browse the repository at this point in the history
ImageBitmapLoader: Inherit from Loader.
  • Loading branch information
Mugen87 authored Aug 24, 2019
2 parents 54aac70 + 4e50228 commit 7ce5c75
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 56 deletions.
22 changes: 4 additions & 18 deletions docs/api/en/loaders/ImageBitmapLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;

<h1>[name]</h1>

<p class="desc">
Expand Down Expand Up @@ -68,19 +70,13 @@ <h3>[name]( [param:LoadingManager manager] )</h3>
</p>

<h2>Properties</h2>

<h3>[property:LoadingManager manager]</h3>
<p>
The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
</p>
<p>See the base [page:Loader] class for common properties.</p>

<h3>[property:String options]</h3>
<p>An optional object that sets options for the internally used [link:https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap createImageBitmap] factory method. Default is *undefined*.</p>

<h3>[property:String path]</h3>
<p>The base path from which files will be loaded. See [page:.setPath]. Default is *undefined*.</p>

<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
Expand All @@ -94,21 +90,11 @@ <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Func
Begin loading from url and return the [page:ImageBitmap image] object that will contain the data.
</p>

<h3>[method:ImageBitmapLoader setCrossOrigin]()</h3>
<p>This method exists for compatibility reasons and implements no logic. It ensures that [name] has a similar interface like [page:ImageLoader].</p>

<h3>[method:ImageBitmapLoader setOptions]( [param:Object options] )</h3>
<p>
Sets the options object for [link:https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap createImageBitmap].
</p>

<h3>[method:ImageBitmapLoader setPath]( [param:String path] )</h3>
<p>
Sets the base path or URL from which to load files. This can be useful if
you are loading many images from the same directory.
</p>


<h2>Source</h2>

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
Expand Down
20 changes: 4 additions & 16 deletions docs/api/zh/loaders/ImageBitmapLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;

<h1>[name]</h1>

<p class="desc">
Expand Down Expand Up @@ -68,20 +70,15 @@ <h3>[name]( [param:LoadingManager manager] )</h3>
</p>

<h2>属性</h2>
<p>See the base [page:Loader] class for common properties.</p>

<h3>[property:LoadingManager manager]</h3>
<p>
加载器正在使用的[page:LoadingManager loadingManager] ,默认为[page:DefaultLoadingManager].
</p>

<h3>[property:String options]</h3>
<p>一个可选对象,用来设置内部使用的[link:https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap createImageBitmap]工厂方法,
默认为*undefined*.</p>

<h3>[property:String path]</h3>
<p>所要加载文件的基本路径。 请参考[page:.setPath],默认为*undefined*。</p>

<h2>方法</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
Expand All @@ -95,20 +92,11 @@ <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Func
从URL中进行加载,并返回将包含数据的[page:ImageBitmap image]对象。
</p>

<h3>[method:ImageBitmapLoader setCrossOrigin]()</h3>
<p>此方法出于兼容性原因而存在,并且不实现逻辑。它确保[name]具有[page:ImageLoader]的类似接口。</p>

<h3>[method:ImageBitmapLoader setOptions]( [param:Object options] )</h3>
<p>
设置[link:https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap createImageBitmap]的选项对象。
</p>

<h3>[method:ImageBitmapLoader setPath]( [param:String path] )</h3>
<p>
设置加载文件的基本路径或URL。当加载同一目录中下的许多图片时,此方法将很有用。
</p>


<h2></h2>

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
Expand Down
9 changes: 4 additions & 5 deletions src/loaders/ImageBitmapLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { Loader } from './Loader';
import { LoadingManager } from './LoadingManager.js';

export class ImageBitmapLoader {
export class ImageBitmapLoader extends Loader {

constructor( manager?: LoadingManager );

manager: LoadingManager;
options: undefined | object;

setOptions( options: any ): ImageBitmapLoader;
setOptions( options: object ): ImageBitmapLoader;
load(
url: string,
onLoad?: ( response: string | ArrayBuffer ) => void,
onProgress?: ( request: ProgressEvent ) => void,
onError?: ( event: ErrorEvent ) => void
): any;
setCrossOrigin(): ImageBitmapLoader;
setPath( path: string ): ImageBitmapLoader;

}
22 changes: 5 additions & 17 deletions src/loaders/ImageBitmapLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { Cache } from './Cache.js';
import { DefaultLoadingManager } from './LoadingManager.js';
import { Loader } from './Loader.js';


function ImageBitmapLoader( manager ) {
Expand All @@ -20,12 +20,13 @@ function ImageBitmapLoader( manager ) {

}

this.manager = manager !== undefined ? manager : DefaultLoadingManager;
Loader.call( this, manager );

this.options = undefined;

}

ImageBitmapLoader.prototype = {
ImageBitmapLoader.prototype = Object.assign( Object.create( Loader.prototype ), {

constructor: ImageBitmapLoader,

Expand Down Expand Up @@ -101,21 +102,8 @@ ImageBitmapLoader.prototype = {

scope.manager.itemStart( url );

},

setCrossOrigin: function ( /* value */ ) {

return this;

},

setPath: function ( value ) {

this.path = value;
return this;

}

};
} );

export { ImageBitmapLoader };

0 comments on commit 7ce5c75

Please sign in to comment.