提交 a807cdbd 编写于 作者: J Jeff Nusz

Allow user to change brush size

上级 18dc7e4c
...@@ -75,7 +75,7 @@ THREE.PaintViveController = function ( id ) { ...@@ -75,7 +75,7 @@ THREE.PaintViveController = function ( id ) {
} }
if ( mode === MODES.SIZE ) { if ( mode === MODES.SIZE ) {
size = y + 1; size = (0.5 - y) * 2;
} }
} }
......
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
// var pivot = new THREE.Group(); // var pivot = new THREE.Group();
// var pivot = new THREE.Mesh( new THREE.BoxGeometry( 0.01, 0.01, 0.01 ) ); // var pivot = new THREE.Mesh( new THREE.BoxGeometry( 0.01, 0.01, 0.01 ) );
var pivot = new THREE.Mesh( new THREE.IcosahedronGeometry( 0.002, 2 ) ); var pivot = new THREE.Mesh( new THREE.IcosahedronGeometry( 0.01, 2 ) );
pivot.name = 'pivot'; pivot.name = 'pivot';
pivot.position.y = -0.016; pivot.position.y = -0.016;
pivot.position.z = -0.043; pivot.position.z = -0.043;
...@@ -249,28 +249,31 @@ ...@@ -249,28 +249,31 @@
scene.add( line ); scene.add( line );
// Shapes // Shapes
shapes[ 'tube' ] = getTubeShapes(1.0);
}
function getTubeShapes(size) {
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var sides = 10; var sides = 10;
var array = []; var array = [];
var radius = 0.01 * size;
for ( var i = 0; i < sides; i ++ ) { for( var i = 0; i < sides; i ++ ){
var angle = ( i / sides ) * PI2; var angle = ( i / sides ) * PI2;
array.push( new THREE.Vector3( Math.sin( angle ) * 0.01, Math.cos( angle ) * 0.01, 0 ) ); array.push( new THREE.Vector3( Math.sin( angle ) * radius, Math.cos( angle ) * radius, 0 ) );
} }
shapes[ 'tube' ] = array; return array;
} }
function stroke( controller, point1, point2, matrix1, matrix2 ) { function stroke( controller, point1, point2, matrix1, matrix2 ) {
var color = controller.getColor(); var color = controller.getColor();
var shape = shapes[ 'tube' ]; var shapes = getTubeShapes( controller.getSize() );
var geometry = line.geometry; var geometry = line.geometry;
var attributes = geometry.attributes; var attributes = geometry.attributes;
...@@ -280,10 +283,10 @@ ...@@ -280,10 +283,10 @@
var normals = attributes.normal.array; var normals = attributes.normal.array;
var colors = attributes.color.array; var colors = attributes.color.array;
for ( var j = 0, jl = shape.length; j < jl; j ++ ) { for ( var j = 0, jl = shapes.length; j < jl; j ++ ) {
var vertex1 = shape[ j ]; var vertex1 = shapes[ j ];
var vertex2 = shape[ ( j + 1 ) % jl ]; var vertex2 = shapes[ ( j + 1 ) % jl ];
// positions // positions
...@@ -406,6 +409,7 @@ ...@@ -406,6 +409,7 @@
if ( pivot ) { if ( pivot ) {
pivot.material.color.copy( controller.getColor() ); pivot.material.color.copy( controller.getColor() );
pivot.scale.setScalar(controller.getSize());
var matrix = pivot.matrixWorld; var matrix = pivot.matrixWorld;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册