-
-
Notifications
You must be signed in to change notification settings - Fork 36.5k
Expand file tree
/
Copy pathKTX2Loader.html
More file actions
144 lines (110 loc) · 4.09 KB
/
Copy pathKTX2Loader.html
File metadata and controls
144 lines (110 loc) · 4.09 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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] →
<h1>KTX2加载器([name])</h1>
<p class="desc">
KTX 2.0 GPU 纹理容器的加载程序。<br><br>
[link:http://github.khronos.org/KTX-Specification/ KTX 2.0] 是各种 GPU 纹理格式的容器格式。该加载器支持 Basis Universal GPU
纹理,可以快速转码为多种 GPU 纹理压缩格式。虽然 KTX 2.0 还允许其他特定于硬件的格式,但此加载程序尚未解析它们。
</p>
<p>
该加载程序解析 KTX 2.0 容器并将其转码为受支持的 GPU 压缩纹理格式。所需的 WASM 转码器和 JS 包装器可从
[link:https://github.com/mrdoob/three.js/tree/dev/examples/jsm/libs/basis examples/jsm/libs/basis] 目录中获取。
</p>
<h2>导入</h2>
<p>
[name] 是一个附加组件,必须显式导入。请参阅 [link:#manual/introduction/Installation Installation / Addons]。
</p>
<code>
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
</code>
<h2>代码示例</h2>
<code>
var ktx2Loader = new KTX2Loader();
ktx2Loader.setTranscoderPath( {
js: 'jsm/libs/basis/basis_transcoder.js',
wasm: 'jsm/libs/basis/basis_transcoder.wasm'
} )
ktx2Loader.detectSupport( renderer );
ktx2Loader.load( 'diffuse.ktx2', function ( texture ) {
var material = new THREE.MeshStandardMaterial( { map: texture } );
}, function () {
console.log( 'onProgress' );
}, function ( e ) {
console.error( e );
} );
</code>
<h2>例子</h2>
<p>
[example:webgl_loader_texture_ktx2]
</p>
<h2>浏览器兼容性</h2>
<p>
该加载器依赖于旧版浏览器不支持的 Web Assembly。
</p>
<br>
<hr>
<h2>构造函数</h2>
<h3>[name]( [param:LoadingManager manager] )</h3>
<p>
[page:LoadingManager manager] — 供加载器使用的 [page:LoadingManager] 。默认值为 [page:LoadingManager
THREE.DefaultLoadingManager]。
</p>
<p>
创建一个新的 [name]。
</p>
<h2>属性</h2>
<p>有关常用属性,请参阅 [page:Loader] 基类</p>
<h2>Methods</h2>
<p>有关常用方法,请参阅 [page:Loader] 基类</p>
<h3>[method:CompressedTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress],
[param:Function onError] )</h3>
<p>
[page:String url] — 包含 `.ktx2` 文件路径/URL 的字符串。<br />
[page:Function onLoad] — 加载成功完成后调用的函数。<br />
[page:Function onProgress] — (可选)加载过程中调用的函数。参数将是 XMLHttpRequest 实例,其中包含 .[page:Integer total] 和 .[page:Integer
loaded] 字节。如果服务器没有设置 Content-Length,.[page:Integer total] 将为 0。<br />
[page:Function onError] — (可选)加载期间发生错误时调用的函数。该函数接收错误作为参数。<br />
</p>
<p>
从 url 加载并在转码后 [page:CompressedTexture] 调用 `onLoad` 函数。
</p>
<h3>[method:this detectSupport]( [param:WebGLRenderer renderer] )</h3>
<p>
[page:WebGLRenderer renderer] — 渲染器实例。
</p>
<p>
检测可用压缩纹理格式的硬件支持,以确定转码器的输出格式。必须在加载纹理之前调用。
</p>
<h3>[method:this setTranscoderPath]( [param:String path] )</h3>
<p>
[page:String path] — 包含 WASM 转码器和 JS 包装器的文件夹路径。
</p>
<p>
WASM 转码器和 JS 包装器可从 [link:https://github.com/mrdoob/three.js/tree/dev/examples/jsm/libs/basis
examples/jsm/libs/basis] 目录中获取。
</p>
<h3>[method:this setWorkerLimit]( [param:Number limit] )</h3>
<p>
[page:Number limit] — 最大 worker 数量。默认值为 '4'。
</p>
<p>
设置此实例要分配的最大 Web Worker 数量。
</p>
<h3>[method:this dispose]()</h3>
<p>
处置加载器对象,取消分配创建的所有 Web Worker。
</p>
<h2>源代码</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/KTX2Loader.js examples/jsm/loaders/KTX2Loader.js]
</p>
</body>
</html>