提交 834b256a 编写于 作者: M Mr.doob

Merge remote-tracking branch 'origin/dev' into dev

......@@ -692,7 +692,9 @@ var Viewport = function ( signals ) {
}
var exporter = new object.exporter();
var output = exporter.parse( selected.geometry );
var output = JSON.stringify( exporter.parse( selected.geometry ), null, '\t' );
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
var blob = new Blob( [ output ], { type: 'text/plain' } );
var objectURL = URL.createObjectURL( blob );
......@@ -705,7 +707,9 @@ var Viewport = function ( signals ) {
signals.exportScene.add( function ( object ) {
var exporter = new object.exporter();
var output = exporter.parse( scene );
var output = JSON.stringify( exporter.parse( scene ), null, '\t' );
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
var blob = new Blob( [ output ], { type: 'text/plain' } );
var objectURL = URL.createObjectURL( blob );
......
......@@ -161,20 +161,16 @@ THREE.GeometryExporter.prototype = {
//
var output = JSON.stringify( {
return {
metadata: {
formatVersion: 3.1,
generatedBy: "GeometryExporter",
version: 4,
generator: "GeometryExporter",
},
vertices: vertices,
normals: normals,
uvs: uvs,
faces: faces
}, null, '\t' );
// output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
return output;
};
}
......
......@@ -747,7 +747,7 @@ THREE.SceneExporter.prototype = {
'}'
].join( '\n' );
return output;
return JSON.parse( output );
}
......
......@@ -14,12 +14,48 @@ THREE.SceneExporter2.prototype = {
metadata: {
version: 4.0,
type: 'scene',
generatedBy: 'SceneExporter'
generator: 'SceneExporter'
}
};
console.log( scene );
//
var geometries = {};
var geometryExporter = new THREE.GeometryExporter();
var parseGeometry = function ( geometry ) {
if ( geometries[ geometry.id ] === undefined ) {
if ( output.geometries === undefined ) {
output.geometries = [];
}
geometries[ geometry.id ] = output.geometries.length;
output.geometries.push( geometryExporter.parse( geometry ) );
}
return geometries[ geometry.id ];
};
/*
var materials = {};
var materialExporter = new THREE.MaterialExporter();
var parseMaterial = function ( material ) {
};
*/
var parseObject = function ( object ) {
var data = { name: object.name };
......@@ -84,6 +120,7 @@ THREE.SceneExporter2.prototype = {
data.position = object.position.toArray();
data.rotation = object.rotation.toArray();
data.scale = object.scale.toArray();
data.geometry = parseGeometry( object.geometry );
} else {
......@@ -114,7 +151,7 @@ THREE.SceneExporter2.prototype = {
output.scene = parseObject( scene ).children;
return JSON.stringify( output, null, '\t' );
return output;
}
......
......@@ -8,6 +8,7 @@
* @author mikael emtinger / http://gomo.se/
* @author timknip / http://www.floorplanner.com/
* @author bhouston / http://exocortex.com
* @author WestLangley / http://github.com/WestLangley
*/
......@@ -589,24 +590,24 @@ THREE.extend( THREE.Matrix4.prototype, {
},
compose: function() {
var mRotation = new THREE.Matrix4(),
mScale = new THREE.Matrix4();
return function ( translation, rotation, scale ) {
return function ( position, quaternion, scale ) {
var te = this.elements;
mRotation.identity();
mRotation.setRotationFromQuaternion( rotation );
mRotation.setRotationFromQuaternion( quaternion );
mScale.makeScale( scale.x, scale.y, scale.z );
this.multiplyMatrices( mRotation, mScale );
te[12] = translation.x;
te[13] = translation.y;
te[14] = translation.z;
te[12] = position.x;
te[13] = position.y;
te[14] = position.z;
return this;
......@@ -621,7 +622,7 @@ THREE.extend( THREE.Matrix4.prototype, {
z = new THREE.Vector3(),
matrix = new THREE.Matrix4();
return function ( translation, rotation, scale ) {
return function ( position, quaternion, scale ) {
var te = this.elements;
......@@ -630,17 +631,17 @@ THREE.extend( THREE.Matrix4.prototype, {
y.set( te[4], te[5], te[6] );
z.set( te[8], te[9], te[10] );
translation = ( translation instanceof THREE.Vector3 ) ? translation : new THREE.Vector3();
rotation = ( rotation instanceof THREE.Quaternion ) ? rotation : new THREE.Quaternion();
position = ( position instanceof THREE.Vector3 ) ? position : new THREE.Vector3();
quaternion = ( quaternion instanceof THREE.Quaternion ) ? quaternion : new THREE.Quaternion();
scale = ( scale instanceof THREE.Vector3 ) ? scale : new THREE.Vector3();
scale.x = x.length();
scale.y = y.length();
scale.z = z.length();
translation.x = te[12];
translation.y = te[13];
translation.z = te[14];
position.x = te[12];
position.y = te[13];
position.z = te[14];
// scale the rotation part
......@@ -658,9 +659,9 @@ THREE.extend( THREE.Matrix4.prototype, {
matrix.elements[9] /= scale.z;
matrix.elements[10] /= scale.z;
rotation.setFromRotationMatrix( matrix );
quaternion.setFromRotationMatrix( matrix );
return [ translation, rotation, scale ];
return [ position, quaternion, scale ];
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册