-
-
Notifications
You must be signed in to change notification settings - Fork 36.4k
Expand file tree
/
Copy pathImageBitmapLoader.html
More file actions
163 lines (163 loc) · 7.43 KB
/
ImageBitmapLoader.html
File metadata and controls
163 lines (163 loc) · 7.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ImageBitmapLoader - Three.js Docs</title>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script src="../scripts/highlight.min.js"></script>
<link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
<link type="text/css" rel="stylesheet" href="../styles/page.css">
</head>
<body>
<p class="inheritance" translate="no"><a href="Loader.html">Loader</a> → </p>
<h1 translate="no">ImageBitmapLoader</h1>
<section>
<header>
<div class="class-description"><p>A loader for loading images as an <a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap" target="_blank" rel="noopener">ImageBitmap</a>.
An <code>ImageBitmap</code> provides an asynchronous and resource efficient pathway to prepare
textures for rendering.</p>
<p>Note that <a href="Texture.html#flipY">Texture#flipY</a> and <a href="Texture.html#premultiplyAlpha">Texture#premultiplyAlpha</a> are ignored with image bitmaps.
These options need to be configured via <a href="ImageBitmapLoader.html#setOptions">ImageBitmapLoader#setOptions</a> prior to loading,
unlike regular images which can be configured on the Texture to set these options on GPU upload instead.</p>
<p>To match the default behaviour of <a href="Texture.html">Texture</a>, the following options are needed:</p>
<p>Also note that unlike <a href="FileLoader.html">FileLoader</a>, this loader will only avoid multiple concurrent requests to the same URL if <a href="Cache.html">Cache</a> is enabled.</p>
<pre><code class="language-js">const loader = new THREE.ImageBitmapLoader();
loader.setOptions( { imageOrientation: 'flipY' } ); // set options if needed
const imageBitmap = await loader.loadAsync( 'image.png' );
const texture = new THREE.Texture( imageBitmap );
texture.needsUpdate = true;
</code></pre></div>
<h2>Code Example</h2>
<div translate="no"><pre><code class="language-js">{ imageOrientation: 'flipY', premultiplyAlpha: 'none' }
</code></pre></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h3 class="name name-method" id="ImageBitmapLoader" translate="no">new <a href="#ImageBitmapLoader">ImageBitmapLoader</a><span class="signature">( manager : <span class="param-type"><a href="LoadingManager.html">LoadingManager</a></span> )</span> </h3>
<div class="method">
<div class="description">
<p>Constructs a new image bitmap loader.</p>
</div>
<table class="params">
<tbody>
<tr>
<td class="name">
<strong>manager</strong>
</td>
<td class="description last">
<p>The loading manager.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 class="subsection-title">Properties</h2>
<div class="member">
<h3 class="name" id="isImageBitmapLoader" translate="no">.<a href="#isImageBitmapLoader">isImageBitmapLoader</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
<div class="description">
<p>This flag can be used for type testing.</p>
<p>Default is <code>true</code>.</p>
</div>
</div>
<div class="member">
<h3 class="name" id="options" translate="no">.<a href="#options">options</a><span class="type-signature"> : Object</span> </h3>
<div class="description">
<p>Represents the loader options.</p>
<p>Default is <code>{premultiplyAlpha:'none'}</code>.</p>
</div>
</div>
<h2 class="subsection-title">Methods</h2>
<h3 class="name name-method" id="abort" translate="no">.<a href="#abort">abort</a><span class="signature">()</span><span class="type-signature"> : <a href="ImageBitmapLoader.html">ImageBitmapLoader</a></span> </h3>
<div class="method">
<div class="description">
<p>Aborts ongoing fetch requests.</p>
</div>
<dl class="details">
<dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#abort">Loader#abort</a></dt>
</dl>
<dl class="details">
<dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
</dl>
</div>
<h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( url : <span class="param-type">string</span>, onLoad : <span class="param-type">function</span>, onProgress : <span class="param-type"><a href="global.html#onProgressCallback">onProgressCallback</a></span>, onError : <span class="param-type"><a href="global.html#onErrorCallback">onErrorCallback</a></span> )</span><span class="type-signature"> : ImageBitmap | undefined</span> </h3>
<div class="method">
<div class="description">
<p>Starts loading from the given URL and pass the loaded image bitmap to the <code>onLoad()</code> callback.</p>
</div>
<table class="params">
<tbody>
<tr>
<td class="name">
<strong>url</strong>
</td>
<td class="description last">
<p>The path/URL of the file to be loaded. This can also be a data URI.</p>
</td>
</tr>
<tr>
<td class="name">
<strong>onLoad</strong>
</td>
<td class="description last">
<p>Executed when the loading process has been finished.</p>
</td>
</tr>
<tr>
<td class="name">
<strong>onProgress</strong>
</td>
<td class="description last">
<p>Unsupported in this loader.</p>
</td>
</tr>
<tr>
<td class="name">
<strong>onError</strong>
</td>
<td class="description last">
<p>Executed when errors occur.</p>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
</dl>
<dl class="details">
<dt class="tag-returns"><strong>Returns:</strong> The image bitmap.</dt>
</dl>
</div>
<h3 class="name name-method" id="setOptions" translate="no">.<a href="#setOptions">setOptions</a><span class="signature">( options : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="ImageBitmapLoader.html">ImageBitmapLoader</a></span> </h3>
<div class="method">
<div class="description">
<p>Sets the given loader options. The structure of the object must match the <code>options</code> parameter of
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap" target="_blank" rel="noopener">createImageBitmap</a>.</p>
</div>
<table class="params">
<tbody>
<tr>
<td class="name">
<strong>options</strong>
</td>
<td class="description last">
<p>The loader options to set.</p>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-returns"><strong>Returns:</strong> A reference to this image bitmap loader.</dt>
</dl>
</div>
<h2 class="subsection-title">Source</h2>
<p>
<a href="https://github.com/mrdoob/three.js/blob/master/src/loaders/ImageBitmapLoader.js" translate="no" target="_blank" rel="noopener">src/loaders/ImageBitmapLoader.js</a>
</p>
</article>
</section>
<script src="../scripts/linenumber.js"></script>
<script src="../scripts/page.js"></script>
</body>
</html>