|
@@ -11,15 +11,15 @@
|
|
<h1>[name]</h1>
|
|
<h1>[name]</h1>
|
|
|
|
|
|
<p class="desc">
|
|
<p class="desc">
|
|
- A loader for loading a JSON resource. Unlike the [page:JSONLoader], this one make use of the
|
|
|
|
- <em>.type</em> attributes of objects to map them to their original classes.<br /><br />
|
|
|
|
|
|
+ 一个用来加载JSON资源的加载器。 不像[page:JSONLoader],这个加载器使用
|
|
|
|
+ <em>.type</em>对象属性,来映射它自己到源类。<br /><br />
|
|
|
|
|
|
- Note that this loader can't load [page:Geometries]. Use [page:JSONLoader] instead for that.<br /><br />
|
|
|
|
|
|
+ 请注意这个加载器不能用来加载[page:Geometries],而是用[page:JSONLoader]进行加载。<br /><br />
|
|
|
|
|
|
- This uses the [page:FileLoader] internally for loading files.
|
|
|
|
|
|
+ 此加载器内部使用[page:FileLoader]进行加载文件。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
- <h2>Example</h2>
|
|
|
|
|
|
+ <h2>例子</h2>
|
|
|
|
|
|
<p>
|
|
<p>
|
|
|
|
|
|
@@ -32,29 +32,29 @@
|
|
var loader = new THREE.ObjectLoader();
|
|
var loader = new THREE.ObjectLoader();
|
|
|
|
|
|
loader.load(
|
|
loader.load(
|
|
- // resource URL
|
|
|
|
|
|
+ // 资源的URL
|
|
"models/json/example.json",
|
|
"models/json/example.json",
|
|
|
|
|
|
- // onLoad callback
|
|
|
|
|
|
+ // onLoad回调
|
|
// Here the loaded data is assumed to be an object
|
|
// Here the loaded data is assumed to be an object
|
|
function ( obj ) {
|
|
function ( obj ) {
|
|
// Add the loaded object to the scene
|
|
// Add the loaded object to the scene
|
|
scene.add( obj );
|
|
scene.add( obj );
|
|
},
|
|
},
|
|
|
|
|
|
- // onProgress callback
|
|
|
|
|
|
+ // onProgress回调
|
|
function ( xhr ) {
|
|
function ( xhr ) {
|
|
console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
|
|
console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
|
|
},
|
|
},
|
|
|
|
|
|
- // onError callback
|
|
|
|
|
|
+ // onError回调
|
|
function ( err ) {
|
|
function ( err ) {
|
|
console.error( 'An error happened' );
|
|
console.error( 'An error happened' );
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
- // Alternatively, to parse a previously loaded JSON structure
|
|
|
|
|
|
+ // 或者,解析先前加载的JSON结构
|
|
var object = loader.parse( a_json_object );
|
|
var object = loader.parse( a_json_object );
|
|
|
|
|
|
scene.add( object );
|
|
scene.add( object );
|
|
@@ -62,102 +62,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- <h2>Constructor</h2>
|
|
|
|
|
|
+ <h2>构造函数</h2>
|
|
|
|
|
|
<h3>[name]( [param:LoadingManager manager] )</h3>
|
|
<h3>[name]( [param:LoadingManager manager] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
|
|
|
|
|
|
+ [page:LoadingManager manager] — 加载器所使用的[page:LoadingManager loadingManager],默认值为[page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
|
|
|
|
|
|
- Creates a new [name].
|
|
|
|
|
|
+ 创建一个新的[name].
|
|
</p>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
- <h2>Properties</h2>
|
|
|
|
|
|
+ <h2>属性</h2>
|
|
|
|
|
|
<h3>[property:String crossOrigin]</h3>
|
|
<h3>[property:String crossOrigin]</h3>
|
|
<p>
|
|
<p>
|
|
- If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
|
|
|
|
- attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*.
|
|
|
|
|
|
+ 如果设置了,在开始加载前, 将为图片分配 [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
|
|
|
|
+ 属性,其值为 *crossOrigin*, 默认为"anonymous"。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h3>[property:LoadingManager manager]</h3>
|
|
<h3>[property:LoadingManager manager]</h3>
|
|
<p>
|
|
<p>
|
|
- The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
|
|
|
|
|
|
+ 加载器正在使用的[page:LoadingManager loadingManager],默认值为[page:DefaultLoadingManager]。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h3>[property:String texturePath]</h3>
|
|
<h3>[property:String texturePath]</h3>
|
|
<p>
|
|
<p>
|
|
- The base path or URL from which textures will be loaded. See [page:.setTexturePath].
|
|
|
|
- Default is the empty string.
|
|
|
|
|
|
+ 将要被加载的纹理的路径或者URL,详情请参考[page:.setTexturePath]。
|
|
|
|
+ 默认值为空字符串。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
- <h2>Methods</h2>
|
|
|
|
|
|
+ <h2>方法</h2>
|
|
|
|
|
|
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
|
|
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:String url] — the path or URL to the file. This can also be a
|
|
|
|
|
|
+ [page:String url] — 文件的URL或者路径,也可以为
|
|
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
|
|
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
|
|
- [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Object3D object].<br />
|
|
|
|
- [page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
|
|
|
|
- [page:Function onError] — Will be called when load errors.<br />
|
|
|
|
|
|
+ [page:Function onLoad] — 加载完成时将调用。回调参数为将要加载的[page:Object3D object].<br />
|
|
|
|
+ [page:Function onProgress] — 将在加载过程中进行调用。参数为XMLHttpRequest实例,实例包含[page:Integer total]和[page:Integer loaded]字节。<br />
|
|
|
|
+ [page:Function onError] — 在加载错误时被调用。<br />
|
|
</p>
|
|
</p>
|
|
<p>
|
|
<p>
|
|
- Begin loading from url and call onLoad with the parsed response content.
|
|
|
|
|
|
+ 从URL中进行加载,并将被解析的响应内容传递给onLoad。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<h3>[method:Object3D parse]( [param:Object json], [param:Function onLoad] )</h3>
|
|
<h3>[method:Object3D parse]( [param:Object json], [param:Function onLoad] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:Object json] — required. The JSON source to parse.<br /><br />
|
|
|
|
- [page:Function onLoad] — Will be called when parsed completes. The argument will be the parsed [page:Object3D object].<br /><br />
|
|
|
|
|
|
+ [page:Object json] — 必选参数,需要被解析的JSON源。<br /><br />
|
|
|
|
+ [page:Function onLoad] — 当解析完成时被调用,其中参数被解析为[page:Object3D object].<br /><br />
|
|
|
|
|
|
- Parse a <em>JSON</em> structure and return a threejs object.
|
|
|
|
- This is used internally by [page:.load], but can also be used directly to parse
|
|
|
|
- a previously loaded JSON structure.
|
|
|
|
|
|
+ 解析一个<em>JSON</em>结构,并返回一个threejs对象.
|
|
|
|
+ 内部使用[page:.load]进行加载, 但也可以直接用于解析先前加载的JSON结构。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h3>[method:Object3D parseGeometries]( [param:Object json] )</h3>
|
|
<h3>[method:Object3D parseGeometries]( [param:Object json] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:Object json] — required. The JSON source to parse.<br /><br />
|
|
|
|
|
|
+ [page:Object json] — 必选参数,需要被解析的JSON源。<br /><br />
|
|
|
|
|
|
- This is used [page:.parse] to parse any [page:Geometry geometries] or [page:BufferGeometry buffer geometries] in the JSON structure.
|
|
|
|
- Internally it uses [page:JSONLoader] for geometries and [page:BufferGeometryLoader] for buffer geometries.
|
|
|
|
|
|
+ 此函数以JSON结构,用[page:.parse]去解析[page:Geometry geometries]或[page:BufferGeometry buffer geometries]。
|
|
|
|
+ 在内部,它使用JSONLoader作为几何加载器,使用BufferGeometryLoader作为几何缓冲区加载器。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h3>[method:Object3D parseMaterials]( [param:Object json] )</h3>
|
|
<h3>[method:Object3D parseMaterials]( [param:Object json] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:Object json] — required. The JSON source to parse.<br /><br />
|
|
|
|
|
|
+ [page:Object json] — 必选参数,需要被解析的JSON源。<br /><br />
|
|
|
|
|
|
- This is used [page:.parse] to parse any materials in the JSON structure using [page:MaterialLoader].
|
|
|
|
|
|
+ 此函数通过[page:.parse]来使用[page:MaterialLoader],以解析JSON结构中任意材质。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h3>[method:Object3D parseAnimations]( [param:Object json] )</h3>
|
|
<h3>[method:Object3D parseAnimations]( [param:Object json] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:Object json] — required. The JSON source to parse.<br /><br />
|
|
|
|
|
|
+ [page:Object json] — 必选参数,需要被解析的JSON源。<br /><br />
|
|
|
|
|
|
- This is used [page:.parse] to parse any animations in the JSON structure, using [page:AnimationClip.parse].
|
|
|
|
- </p>
|
|
|
|
|
|
+ 此函数通过[page:.parse]来使用[page:AnimationClip.parse], 以解析JSON结构中任意动画。
|
|
|
|
+ </p>
|
|
|
|
|
|
<h3>[method:Object3D parseImages]( [param:Object json] )</h3>
|
|
<h3>[method:Object3D parseImages]( [param:Object json] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:Object json] — required. The JSON source to parse.<br /><br />
|
|
|
|
|
|
+ [page:Object json] — 必选参数,需要被解析的JSON源。<br /><br />
|
|
|
|
|
|
- This is used [page:.parse] to parse any images in the JSON structure, using [page:ImageLoader].
|
|
|
|
|
|
+ 此函数通过[page:.parse]来使用[page:ImageLoader], 以解析JSON结构中任意图片。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h3>[method:Object3D parseTextures]( [param:Object json] )</h3>
|
|
<h3>[method:Object3D parseTextures]( [param:Object json] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:Object json] — required. The JSON source to parse.<br /><br />
|
|
|
|
-
|
|
|
|
- This is used [page:.parse] to parse any textures in the JSON structure.
|
|
|
|
|
|
+ [page:Object json] — 必选参数,需要被解析的JSON源。<br /><br />
|
|
|
|
+ 此函数通过[page:.parse]来解析JSON结构中任意纹理。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h3>[method:Object3D parseObject]( [param:Object json] )</h3>
|
|
<h3>[method:Object3D parseObject]( [param:Object json] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:Object json] — required. The JSON source to parse.<br /><br />
|
|
|
|
|
|
+ [page:Object json] — 必选参数,需要被解析的JSON源。<br /><br />
|
|
|
|
|
|
- This is used [page:.parse] to parse any objects in the JSON structure.
|
|
|
|
- Objects can be of the following types:
|
|
|
|
|
|
+ 此函数通过[page:.parse]来解析JSON结构中任意对象。
|
|
|
|
+ 对象可以为如下类型:
|
|
|
|
|
|
<ul>
|
|
<ul>
|
|
<li>
|
|
<li>
|
|
@@ -214,17 +212,17 @@
|
|
|
|
|
|
<h3>[method:ObjectLoader setCrossOrigin]( [param:String value] )</h3>
|
|
<h3>[method:ObjectLoader setCrossOrigin]( [param:String value] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
|
|
|
|
|
|
+ [page:String value] — 在允许CROS时,跨域字段通过实现CORS来加载不同域下的URL。
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h3>[method:ObjectLoader setTexturePath]( [param:String value] )</h3>
|
|
<h3>[method:ObjectLoader setTexturePath]( [param:String value] )</h3>
|
|
<p>
|
|
<p>
|
|
- [page:String value] — The base path or URL from which textures will be loaded.<br /><br />
|
|
|
|
|
|
+ [page:String value] — 设置将要加载为纹理的路径或者URL<br /><br />
|
|
|
|
|
|
|
|
|
|
</p>
|
|
</p>
|
|
|
|
|
|
- <h2>Source</h2>
|
|
|
|
|
|
+ <h2>源</h2>
|
|
|
|
|
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
|
</body>
|
|
</body>
|