mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Export gltf models in block instead of pixel units
This commit is contained in:
parent
4e1fe04e99
commit
52657c084f
@ -162,7 +162,8 @@ var codec = new Codec('gltf', {
|
||||
trs: true,
|
||||
truncateDrawRange: false,
|
||||
forcePowerOfTwoTextures: true,
|
||||
exportFaceColors: false
|
||||
scale_factor: 1/16,
|
||||
exportFaceColors: false,
|
||||
});
|
||||
},
|
||||
export() {
|
||||
|
@ -21,7 +21,12 @@ var codec = new Codec('obj', {
|
||||
if (!options) options = 0;
|
||||
|
||||
var old_scene_position = new THREE.Vector3().copy(scene.position);
|
||||
scene.position.set(0,0,0)
|
||||
scene.position.set(0,0,0);
|
||||
|
||||
/**
|
||||
Based on: three.js obj exporter, MIT license
|
||||
https://github.com/mrdoob/three.js/blob/dev/examples/js/exporters/OBJExporter.js
|
||||
*/
|
||||
|
||||
var output = '# Made in Blockbench '+appVersion+'\n';
|
||||
var materials = {};
|
||||
|
@ -1305,6 +1305,17 @@ GLTFExporter.prototype = {
|
||||
}
|
||||
})
|
||||
}
|
||||
if ( options.scale_factor && attributeName === 'POSITION' ) {
|
||||
|
||||
// Blockbench: Scaled export
|
||||
modifiedAttribute = new BufferAttribute( new Float32Array( array ), attribute.itemSize, attribute.normalized );
|
||||
|
||||
modifiedAttribute.array.forEach((v, i) => {
|
||||
|
||||
modifiedAttribute.array[i] *= options.scale_factor;
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
var accessor = processAccessor( modifiedAttribute || attribute, geometry );
|
||||
if ( accessor !== null ) {
|
||||
@ -1833,6 +1844,9 @@ GLTFExporter.prototype = {
|
||||
|
||||
if ( ! equalArray( position, [ 0, 0, 0 ] ) ) {
|
||||
|
||||
if (options.scale_factor) {
|
||||
position = position.map(v => v * options.scale_factor);
|
||||
}
|
||||
gltfNode.translation = position;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user