Detox Posted January 18, 2015 Share Posted January 18, 2015 Hello!First of all: I'm new to Babylon.js and looked through the Babylon.JS-Tutorials on Github. But now I'm stuck and don't know why: I looked at the 18 - Drag and Drop Example and instead of moving the Meshes I tried to simply rotate them, that worked fine. But when I change the BABYLON.ArcRotateCamera to BABYLON.FreeCamera it wouldn't rotate the objects in the front anymore, only the one in the back?! On my search for a Solution I found this Thread, where somebody posted this Example (A Modification of the Drag And Drop - Example), there I also replaced the BABYLON.ArcRotateCamera with a BABYLON.FreeCamera. Heres my Modification with the FreeCamera: Playground/#2CEF73 Now if I replace this 5th line of codevar camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(10, 10, 10), scene); with this:var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(10, 10, -10), scene); it works. But why??? How can I modify the code to make it work with the first line of code? Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 18, 2015 Share Posted January 18, 2015 Hi and welcome! So. A few things about your implementation :-) scene.pick gets requires 2 parameters (in your case). pointer X and pointerY. There is no pointerZ in the scene, as this refers to the mouse 2D coordinates on the screen. Same thing goes to createPickingRay . You have provided both with pointerZ (which doesn't exist). But this is not the cause to your problem :-) The main cause is the camera's target. camera.setTarget(greenBox.position); after creating the greenBox solves this issue. I didn't debug it completely, but this is what's missing and this will make it work with any of the positions. Updated demo - http://playground.babylonjs.com/#2CEF73#2 Detox 1 Quote Link to comment Share on other sites More sharing options...
Detox Posted January 19, 2015 Author Share Posted January 19, 2015 Thank you very much for your fast answer! Somehow it really fixed it! And I also figured out my mistake there.I took a closer look regarding the parameters for scene.pick & createPickingRay at http://doc.babylonjs.com/page.php?p=24646. Apparently I made a huge mistake there, lol! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.