ylcnky
ylcnky

Reputation: 775

Three.js different orbit target points

I am a new learner for Three.js. I am loading a building model as obj+mtl files. I can zoom-in/out and rotate the model based on a specified orbit target point. However, the orbit target point is pre-defined. How can I define the target point of orbit as the current location of mouse pointer? and change the target point dynamically whenever I click somewhere else? so when I orbit the building model, I can see the components around the current position of mouse pointer. Thanks

// After necessary libraries and codes..
            var loader = new THREE.OBJMTLLoader();
            loader.load("./models/obj/file.obj", "./models/obj/file.mtl", function (obj) {
                obj.translateY(-3);
                obj.name = 'building';
                scene.add(obj);
                //console.log(obj);
            });

            var controls = new THREE.OrbitControls( camera, renderer.domElement );
            controls.addEventListener( 'change', render );
            controls.target.set( 0, 0, 0 ); //This is the pre-defined target point
            controls.update();

Upvotes: 0

Views: 253

Answers (1)

kaigorodov
kaigorodov

Reputation: 897

Have a look at this example: http://threejs.org/examples/#webgl_interactive_lines . You need to find an intersection of mouse projection on some mesh and then make an intersection position a new target for camera.

Upvotes: 1

Related Questions