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

Editor: Added a selection axis.

上级 d75e7ae4
......@@ -32,11 +32,21 @@ var Viewport = function ( signals ) {
sceneHelpers.add( grid );
var selectionBox = new THREE.Mesh( new THREE.CubeGeometry( 1, 1, 1 ), new THREE.MeshBasicMaterial( { color: 0xffff00, wireframe: true } ) );
selectionBox.geometry.dynamic = true;
selectionBox.matrixAutoUpdate = false;
selectionBox.visible = false;
sceneHelpers.add( selectionBox );
var selectionAxis = new THREE.AxisHelper();
selectionAxis.matrixAutoUpdate = false;
sceneHelpers.add( selectionAxis );
for ( var i = 0; i < selectionAxis.children.length; i ++ ) {
selectionAxis.children[ i ].material.depthTest = false;
selectionAxis.children[ i ].material.transparent = true;
}
//
var scene = new THREE.Scene();
......@@ -56,11 +66,6 @@ var Viewport = function ( signals ) {
controls.dynamicDampingFactor = 0.3;
controls.addEventListener( 'change', render );
/*
var controls = new THREE.OrbitControls( camera, container.dom );
controls.addEventListener( 'change', render );
*/
var light = new THREE.DirectionalLight( 0xffffff );
light.position.set( 1, 0.5, 0 ).normalize();
scene.add( light );
......@@ -133,6 +138,7 @@ var Viewport = function ( signals ) {
signals.objectSelected.add( function ( object ) {
selectionBox.visible = false;
selectionAxis.getDescendants().map( function ( object ) { object.visible = false } );
if ( object !== null && object.geometry ) {
......@@ -181,8 +187,10 @@ var Viewport = function ( signals ) {
selectionBox.geometry.verticesNeedUpdate = true;
selectionBox.matrixWorld = object.matrixWorld;
selectionAxis.matrixWorld = object.matrixWorld;
selectionBox.visible = true;
selectionAxis.getDescendants().map( function ( object ) { object.visible = true } );
}
......@@ -231,8 +239,8 @@ var Viewport = function ( signals ) {
scene.updateMatrixWorld();
renderer.clear();
renderer.render( sceneHelpers, camera );
renderer.render( scene, camera );
renderer.render( sceneHelpers, camera );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册