fix meshes to/from library
This commit is contained in:
parent
296f7a52a4
commit
39656bb33a
3 changed files with 22 additions and 26 deletions
|
|
@ -77,17 +77,13 @@
|
||||||
|
|
||||||
// uniformly scale any mesh to a max x/y/z dim of 'unit' (defaults to 1)
|
// uniformly scale any mesh to a max x/y/z dim of 'unit' (defaults to 1)
|
||||||
GP.unitScale = function(unit) {
|
GP.unitScale = function(unit) {
|
||||||
var bbox = this.getBoundingBox(),
|
var bbox = this.getBoundingBox().clone(),
|
||||||
scale = unit || 1;
|
scale = (unit || 1) / Math.max(
|
||||||
this.applyMatrix(
|
|
||||||
new THREE.Matrix3().identity().multiplyScalar(scale /
|
|
||||||
Math.max(
|
|
||||||
bbox.max.x - bbox.min.x,
|
bbox.max.x - bbox.min.x,
|
||||||
bbox.max.y - bbox.min.y,
|
bbox.max.y - bbox.min.y,
|
||||||
bbox.max.z - bbox.min.z
|
bbox.max.z - bbox.min.z
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
this.applyMatrix4(new THREE.Matrix4().makeScale(scale,scale,scale));
|
||||||
// force update of (obsolete) bounding box
|
// force update of (obsolete) bounding box
|
||||||
this.getBoundingBox(true);
|
this.getBoundingBox(true);
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
24
js/meta.js
24
js/meta.js
|
|
@ -214,9 +214,9 @@ THREE.Face3.prototype.mVisible = function(show) {
|
||||||
DATA = "/data/",
|
DATA = "/data/",
|
||||||
// ---------------
|
// ---------------
|
||||||
hashWatcher = null,
|
hashWatcher = null,
|
||||||
selectMode = SELECT.REGION,
|
selectMode = null,
|
||||||
editMode = EDIT.SELECT,
|
editMode = null,
|
||||||
markMode = MARK.EMIT,
|
markMode = null,
|
||||||
updateFacesScheduled = false,
|
updateFacesScheduled = false,
|
||||||
updateSynthetic = true,
|
updateSynthetic = true,
|
||||||
enablePost = true,
|
enablePost = true,
|
||||||
|
|
@ -445,10 +445,10 @@ THREE.Face3.prototype.mVisible = function(show) {
|
||||||
UC.newButton('center', function() { setAnchorSelection(0,0,0) })
|
UC.newButton('center', function() { setAnchorSelection(0,0,0) })
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
UC.newGroup('send').setAttribute("title","send selection to target");
|
UC.newGroup('export').setAttribute("title","send selection to target");
|
||||||
UC.newTableRow([
|
UC.newTableRow([
|
||||||
[
|
[
|
||||||
UC.newButton('mesh', selectionToLibrary ),
|
UC.newButton('library', selectionToLibrary ),
|
||||||
UC.newButton('kiri', selectionToKiri )
|
UC.newButton('kiri', selectionToKiri )
|
||||||
],[
|
],[
|
||||||
UC.newButton('download', downloadSelection )
|
UC.newButton('download', downloadSelection )
|
||||||
|
|
@ -476,7 +476,7 @@ THREE.Face3.prototype.mVisible = function(show) {
|
||||||
UI.libdrop.id = "dropbutton";
|
UI.libdrop.id = "dropbutton";
|
||||||
UC.newRow([UI.libdrop]);
|
UC.newRow([UI.libdrop]);
|
||||||
|
|
||||||
UC.newGroup('meshes');
|
UC.newGroup('library');
|
||||||
UI.library = UC.newRow();
|
UI.library = UC.newRow();
|
||||||
|
|
||||||
/** attach our key board controls */
|
/** attach our key board controls */
|
||||||
|
|
@ -521,9 +521,9 @@ THREE.Face3.prototype.mVisible = function(show) {
|
||||||
/** and a few more settings before we're done */
|
/** and a few more settings before we're done */
|
||||||
|
|
||||||
setGridSize(gridSize);
|
setGridSize(gridSize);
|
||||||
|
setSelectMode(SDB['meta-smode'] || SELECT.REGION,true);
|
||||||
|
setMarkMode(SDB['meta-mmode'] || MARK.EMIT,true);
|
||||||
setEditMode(EDIT.SELECT);
|
setEditMode(EDIT.SELECT);
|
||||||
setMarkMode(SDB['meta-mmode'] || MARK.EMIT);
|
|
||||||
setSelectMode(SDB['meta-smode'] || SELECT.REGION);
|
|
||||||
setSpaceUnits('1 cm');
|
setSpaceUnits('1 cm');
|
||||||
|
|
||||||
restoreWorkspace();
|
restoreWorkspace();
|
||||||
|
|
@ -764,16 +764,17 @@ THREE.Face3.prototype.mVisible = function(show) {
|
||||||
updateHighlights(selectModeButtons,newmode);
|
updateHighlights(selectModeButtons,newmode);
|
||||||
if (newmode == null) return;
|
if (newmode == null) return;
|
||||||
selectMode = parseInt(newmode);
|
selectMode = parseInt(newmode);
|
||||||
|
SDB['meta-smode'] = selectMode;
|
||||||
if (term) return;
|
if (term) return;
|
||||||
setEditMode(EDIT.SELECT,true);
|
setEditMode(EDIT.SELECT,true);
|
||||||
scheduleUpdateFaces();
|
scheduleUpdateFaces();
|
||||||
SDB['meta-smode'] = selectMode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMarkMode(newmode,term) {
|
function setMarkMode(newmode,term) {
|
||||||
updateHighlights(markTypeButtons,newmode);
|
updateHighlights(markTypeButtons,newmode);
|
||||||
if (newmode === null) return;
|
if (newmode === null) return;
|
||||||
markMode = parseInt(newmode);
|
markMode = parseInt(newmode);
|
||||||
|
SDB['meta-mmode'] = markMode;
|
||||||
selectedFace = null;
|
selectedFace = null;
|
||||||
if (term) return;
|
if (term) return;
|
||||||
setEditMode(EDIT.MARK,true);
|
setEditMode(EDIT.MARK,true);
|
||||||
|
|
@ -785,7 +786,6 @@ THREE.Face3.prototype.mVisible = function(show) {
|
||||||
case MARK.CLEAR: color = COLOR.CLEAR; break;
|
case MARK.CLEAR: color = COLOR.CLEAR; break;
|
||||||
}
|
}
|
||||||
hoverMaterial.color.setHex(color);
|
hoverMaterial.color.setHex(color);
|
||||||
SDB['meta-mmode'] = markMode;
|
|
||||||
SPACE.update();
|
SPACE.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1024,7 +1024,7 @@ THREE.Face3.prototype.mVisible = function(show) {
|
||||||
|
|
||||||
CP.rotateMesh = function(x,y,z,nostate) {
|
CP.rotateMesh = function(x,y,z,nostate) {
|
||||||
if (this.mesh) {
|
if (this.mesh) {
|
||||||
this.mesh.geometry.applyMatrix(new THREE.Matrix4().makeRotationFromEuler(
|
this.mesh.geometry.applyMatrix4(new THREE.Matrix4().makeRotationFromEuler(
|
||||||
new THREE.Euler((-x || 0) * PI2, (y || 0) * PI2, (-z || 0) * PI2))
|
new THREE.Euler((-x || 0) * PI2, (y || 0) * PI2, (-z || 0) * PI2))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -1521,7 +1521,7 @@ THREE.Face3.prototype.mVisible = function(show) {
|
||||||
if (LIBCACHE[filename]) callback(LIBCACHE[filename]);
|
if (LIBCACHE[filename]) callback(LIBCACHE[filename]);
|
||||||
MDB.getFile(filename, function(vertices) {
|
MDB.getFile(filename, function(vertices) {
|
||||||
if (!vertices) return callback();
|
if (!vertices) return callback();
|
||||||
let geo = THREE.Geometry.fromVertices(vertices).unitScale().center().fixNormals();
|
let geo = THREE.Geometry.fromVertices(vertices.slice()).unitScale().center().fixNormals();
|
||||||
geo.filename = filename;
|
geo.filename = filename;
|
||||||
callback(LIBCACHE[filename] = geo);
|
callback(LIBCACHE[filename] = geo);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
.ck_spaces button {
|
.ck_spaces button {
|
||||||
margin: 0px 0px 1px 2px !important;
|
margin: 0px 0px 1px 2px !important;
|
||||||
}
|
}
|
||||||
.ck_meshes {
|
.ck_library {
|
||||||
padding-top: 2px;
|
padding-top: 2px;
|
||||||
}
|
}
|
||||||
.ck_meshes div {
|
.ck_library div {
|
||||||
-webkit-flex-direction: row;
|
-webkit-flex-direction: row;
|
||||||
-webkit-justify-content: flex-start;
|
-webkit-justify-content: flex-start;
|
||||||
-webkit-align-items: center;
|
-webkit-align-items: center;
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 1px;
|
margin-bottom: 1px;
|
||||||
}
|
}
|
||||||
.ck_meshes button {
|
.ck_library button {
|
||||||
margin: 0px 0px 1px 2px !important;
|
margin: 0px 0px 1px 2px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue