未验证 提交 52719cfb 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #18601 from donmccurdy/feat-gltfloader-group

GLTFLoader: Return Group, not Scene.
......@@ -72,8 +72,8 @@
scene.add( gltf.scene );
gltf.animations; // Array<THREE.AnimationClip>
gltf.scene; // THREE.Scene
gltf.scenes; // Array<THREE.Scene>
gltf.scene; // THREE.Group
gltf.scenes; // Array<THREE.Group>
gltf.cameras; // Array<THREE.Camera>
gltf.asset; // Object
......@@ -199,7 +199,7 @@
[page:Function onError] — (optional) A function to be called if an error occurs during parsing. The function receives error as an argument.<br />
</p>
<p>
Parse a glTF-based ArrayBuffer or <em>JSON</em> String and fire [page:Function onLoad] callback when complete. The argument to [page:Function onLoad] will be an [page:object] that contains loaded parts: .[page:Scene scene], .[page:Array scenes], .[page:Array cameras], .[page:Array animations], and .[page:Object asset].
Parse a glTF-based ArrayBuffer or <em>JSON</em> String and fire [page:Function onLoad] callback when complete. The argument to [page:Function onLoad] will be an [page:object] that contains loaded parts: .[page:Group scene], .[page:Array scenes], .[page:Array cameras], .[page:Array animations], and .[page:Object asset].
</p>
<h2>Source</h2>
......
......@@ -71,8 +71,8 @@
scene.add( gltf.scene );
gltf.animations; // Array&lt;THREE.AnimationClip&gt;
gltf.scene; // THREE.Scene
gltf.scenes; // Array&lt;THREE.Scene&gt;
gltf.scene; // THREE.Group
gltf.scenes; // Array&lt;THREE.Group&gt;
gltf.cameras; // Array&lt;THREE.Camera&gt;
gltf.asset; // Object
......@@ -124,7 +124,7 @@
<h2>自定义扩展</h2>
<p>
来自未知扩展的元数据会被保存到Object3D、Scene和Material实例中上的“.userData.gltfExtensions”,
来自未知扩展的元数据会被保存到Object3D、Group和Material实例中上的“.userData.gltfExtensions”,
或被附加到 response “gltf”对象。示例:
</p>
......@@ -194,7 +194,7 @@
[page:Function onError] — (可选)若在解析过程发生错误,将被调用的函数。该函数接收error来作为参数。<br />
</p>
<p>
解析基于glTF的ArrayBuffer或<em>JSON</em>字符串,并在完成后触发[page:Function onLoad]回调。[page:Function onLoad]的参数将是一个包含有已加载部分的[page:object]:.[page:Scene scene]、 .[page:Array scenes]、 .[page:Array cameras]、 .[page:Array animations] 和 .[page:Object asset]。
解析基于glTF的ArrayBuffer或<em>JSON</em>字符串,并在完成后触发[page:Function onLoad]回调。[page:Function onLoad]的参数将是一个包含有已加载部分的[page:object]:.[page:Group scene]、 .[page:Array scenes]、 .[page:Array cameras]、 .[page:Array animations] 和 .[page:Object asset]。
</p>
<h2>源代码</h2>
......
......@@ -3042,7 +3042,7 @@ THREE.GLTFLoader = ( function () {
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
* @param {number} sceneIndex
* @return {Promise<THREE.Scene>}
* @return {Promise<THREE.Group>}
*/
GLTFParser.prototype.loadScene = function () {
......@@ -3151,7 +3151,9 @@ THREE.GLTFLoader = ( function () {
var sceneDef = this.json.scenes[ sceneIndex ];
var parser = this;
var scene = new THREE.Scene();
// Loader returns Group, not Scene.
// See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
var scene = new THREE.Group();
if ( sceneDef.name ) scene.name = sceneDef.name;
assignExtrasToUserData( scene, sceneDef );
......
......@@ -55,7 +55,6 @@ import {
RGBAFormat,
RGBFormat,
RepeatWrapping,
Scene,
Skeleton,
SkinnedMesh,
Sphere,
......@@ -3106,7 +3105,7 @@ var GLTFLoader = ( function () {
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
* @param {number} sceneIndex
* @return {Promise<Scene>}
* @return {Promise<Group>}
*/
GLTFParser.prototype.loadScene = function () {
......@@ -3215,7 +3214,9 @@ var GLTFLoader = ( function () {
var sceneDef = this.json.scenes[ sceneIndex ];
var parser = this;
var scene = new Scene();
// Loader returns Group, not Scene.
// See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
var scene = new Group();
if ( sceneDef.name ) scene.name = sceneDef.name;
assignExtrasToUserData( scene, sceneDef );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册