提交 9eaf84a5 编写于 作者: M Mr.doob

Added Vector*.toArray(). Implemented in SceneExporter2.

上级 e7d260cb
......@@ -31,10 +31,14 @@ THREE.SceneExporter2.prototype = {
if ( object instanceof THREE.PerspectiveCamera ) {
data.type = 'PerspectiveCamera';
data.position = object.position.toArray();
data.rotation = object.rotation.toArray();
} else if ( object instanceof THREE.OrthographicCamera ) {
data.type = 'OrthographicCamera';
data.position = object.position.toArray();
data.rotation = object.rotation.toArray();
} else if ( object instanceof THREE.AmbientLight ) {
......@@ -43,14 +47,17 @@ THREE.SceneExporter2.prototype = {
} else if ( object instanceof THREE.DirectionalLight ) {
data.type = 'DirectionalLight';
data.position = object.position.toArray();
} else if ( object instanceof THREE.PointLight ) {
data.type = 'PointLight';
data.position = object.position.toArray();
} else if ( object instanceof THREE.SpotLight ) {
data.type = 'SpotLight';
data.position = object.position.toArray();
} else if ( object instanceof THREE.HemisphereLight ) {
......@@ -59,10 +66,16 @@ THREE.SceneExporter2.prototype = {
} else if ( object instanceof THREE.Mesh ) {
data.type = 'Mesh';
data.position = object.position.toArray();
data.rotation = object.rotation.toArray();
data.scale = object.scale.toArray();
} else {
data.type = 'Object3D';
data.position = object.position.toArray();
data.rotation = object.rotation.toArray();
data.scale = object.scale.toArray();
}
......@@ -84,7 +97,7 @@ THREE.SceneExporter2.prototype = {
}
output.graph = parseObject( scene ).children;
output.scene = parseObject( scene ).children;
return JSON.stringify( output, null, '\t' );
......
......@@ -293,6 +293,12 @@ THREE.extend( THREE.Vector2.prototype, {
},
toArray: function () {
return [ this.x, this.y ];
},
clone: function () {
return new THREE.Vector2( this.x, this.y );
......
......@@ -751,6 +751,12 @@ THREE.extend( THREE.Vector3.prototype, {
},
toArray: function () {
return [ this.x, this.y, this.z ];
},
clone: function () {
return new THREE.Vector3( this.x, this.y, this.z );
......
......@@ -393,6 +393,12 @@ THREE.extend( THREE.Vector4.prototype, {
},
toArray: function () {
return [ this.x, this.y, this.z, this.w ];
},
clone: function () {
return new THREE.Vector4( this.x, this.y, this.z, this.w );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册