|
@@ -24,6 +24,7 @@
|
|
|
<script src="js/controls/VRControls.js"></script>
|
|
|
<script src="js/effects/VREffect.js"></script>
|
|
|
<script src="js/vr/ViveController.js"></script>
|
|
|
+ <script src="js/vr/PaintViveController.js"></script>
|
|
|
<script src="js/vr/WebVR.js"></script>
|
|
|
|
|
|
<script src="js/loaders/OBJLoader.js"></script>
|
|
@@ -54,8 +55,6 @@
|
|
|
var vector3 = new THREE.Vector3();
|
|
|
var vector4 = new THREE.Vector3();
|
|
|
|
|
|
- var color = new THREE.Color( 0, 0, 0 );
|
|
|
-
|
|
|
var point4 = new THREE.Vector3();
|
|
|
var point5 = new THREE.Vector3();
|
|
|
|
|
@@ -148,13 +147,13 @@
|
|
|
|
|
|
// controllers
|
|
|
|
|
|
- controller1 = new THREE.ViveController( 0 );
|
|
|
+ controller1 = new THREE.PaintViveController( 0 );
|
|
|
controller1.standingMatrix = controls.getStandingMatrix();
|
|
|
controller1.userData.points = [ new THREE.Vector3(), new THREE.Vector3() ];
|
|
|
controller1.userData.matrices = [ new THREE.Matrix4(), new THREE.Matrix4() ];
|
|
|
scene.add( controller1 );
|
|
|
|
|
|
- controller2 = new THREE.ViveController( 1 );
|
|
|
+ controller2 = new THREE.PaintViveController( 1 );
|
|
|
controller2.standingMatrix = controls.getStandingMatrix();
|
|
|
controller2.userData.points = [ new THREE.Vector3(), new THREE.Vector3() ];
|
|
|
controller2.userData.matrices = [ new THREE.Matrix4(), new THREE.Matrix4() ];
|
|
@@ -182,10 +181,9 @@
|
|
|
pivot.rotation.x = Math.PI / 5.5;
|
|
|
controller.add( pivot );
|
|
|
|
|
|
- var range = new THREE.Mesh( new THREE.IcosahedronGeometry( 0.03, 3 ), new THREE.MeshBasicMaterial( { opacity: 0.25, transparent: true } ) );
|
|
|
- pivot.add( range );
|
|
|
-
|
|
|
controller1.add( controller.clone() );
|
|
|
+
|
|
|
+ pivot.material = pivot.material.clone();
|
|
|
controller2.add( controller.clone() );
|
|
|
|
|
|
} );
|
|
@@ -265,7 +263,9 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- function stroke( point1, point2, matrix1, matrix2 ) {
|
|
|
+ function stroke( controller, point1, point2, matrix1, matrix2 ) {
|
|
|
+
|
|
|
+ var color = controller.getColor();
|
|
|
|
|
|
var shape = shapes[ 'tube' ];
|
|
|
|
|
@@ -373,7 +373,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- function handleController( controller, id ) {
|
|
|
+ function handleController( controller ) {
|
|
|
|
|
|
controller.update();
|
|
|
|
|
@@ -381,6 +381,8 @@
|
|
|
|
|
|
if ( pivot ) {
|
|
|
|
|
|
+ pivot.material.color.copy( controller.getColor() );
|
|
|
+
|
|
|
var matrix = pivot.matrixWorld;
|
|
|
|
|
|
var point1 = controller.userData.points[ 0 ];
|
|
@@ -392,15 +394,9 @@
|
|
|
point1.setFromMatrixPosition( matrix );
|
|
|
matrix1.lookAt( point2, point1, up );
|
|
|
|
|
|
- if ( controller.getButtonState( 'thumbpad' ) ) {
|
|
|
-
|
|
|
- color.setHex( Math.random() * 0xffffff );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
if ( controller.getButtonState( 'trigger' ) ) {
|
|
|
|
|
|
- stroke( point1, point2, matrix1, matrix2 );
|
|
|
+ stroke( controller, point1, point2, matrix1, matrix2 );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -415,8 +411,8 @@
|
|
|
|
|
|
controls.update();
|
|
|
|
|
|
- handleController( controller1, 0 );
|
|
|
- handleController( controller2, 1 );
|
|
|
+ handleController( controller1 );
|
|
|
+ handleController( controller2 );
|
|
|
|
|
|
effect.render( scene, camera );
|
|
|
|