I am using this function and it is not working properly. Coding is using three.js
function rotate(){
camera.rotation.x+=0.1;
}
. If I add this at the render function it works just once and not correct meaning that the rotate function event on mouse movement I have, rotates wrong or maybe at an other centre.
What I need is to rotate the camera on the x,y,z axes when the button is clicked.
Any ideas?
You defined controls. They decide the camera rotation instead of the line you added. You have to set controls.enabled=false when you want the camera to rotate.
Yo can’t rotate the camera if you later call controls.update(), OrbitControls will overwrite anything what you have applied.
So one simple solution is to not update the controls if you are transforming the camera by yourself.
As the previous answers said the OrbitControls overwrite anything
But it looks like three.js now doesn't need to call controls.update() as long as you instantiated it const controls = new OrbitControls(camera, renderer.domElement); it will work fine and won't interfere with the camera.
source
Related
I am using a framework called react-native-svg to draw SVG elements in a react native view.
My goal is that when I tap on the view (I use a PanResponder on the global view to get that), the element that is the closest to the tap changes.
I have everything that I need, except one thing: I need to be able to know the position of my svg elements, as well as their size, in order to find the one that was the closest to the tap event.
Now, I've tried most of the things available I'd say:
onLayout: those svg elements don't appear to be views and therefore don't call the onLayout callback.
this.refs.elem.measure: same as onLayout, they are not views therefore the measure function is undefined.
UIManager.measure(ReactNative.findNodeHandle(this.refs.elem), callback): returns 0 for all values, apart from the react-native-svg component Svg, but not for all the others: G, Path, Line, etc.
So I was wondering if there was any other solution or if I was doomed. :)
Do I have to change something in react-native-svg that would allow me to find these values or is there any solution ready for me?
Thanks!
I finally had to add some functionalities to react-native-svg so I could get the size of the different elements.
It's not very well done, but I may come back to it for a cleaner solution and submit a PR then.
Thanks.
I am developing a iOS-6 app. I have a UIViewController with a view that needs fixed orientation (portrait mode). But when the phone is rotated, one control on that view needs to be moved and rotated (so that it will always be in the upper left corner, and its text will be readable).
I am achieving this by shifting the control(a UIView) using the frame-property of my control (it is a custom view, more on that later), and then using CGAffineTRansformMakeRotate() afterwards, since I know that it's not advisable to use the frame after rotating a view. Everything is fine so far, but here's the thing: That custom view has three UIButtons of type UIButtonTypeCustom as its subviews. Because I rotated the View, but cannot rotate the buttons inside the view (they are not squares), I need to rotate the titleLabels of the Buttons for the text to be readable in the new deviceOrientation.
But it won't work very well. The text will be rotated, as I intended, but it will be clipped by the titleLabel, because the titleLabel has the wrong frame. I checked this by applying borders to the label. So I need to change the titleLabels frame, right? But how can I do that? I tried setting it using [titleLabel setFrame: frameThatFits];, but to no avail. (frameThatFits is a CGRect I created). Also, calling [button.titleLabel sizeToFit]; has no effect that I could see.
I am using [button setTitle:title forControlState: UIControlStateNormal];to set the title.
TL;DR: I'm trying to change the frame/bounds of a UIButtons titleLabel after rotating it using an affine transformation. Any help?
Thanks.
PS: I can supply code when needed, but I wouldn't know what to show you. Tell me what you need, I'll post it.
OK, first of all, thanks to everyone who tried to help. Im posting an alternative solution for my problem, and although it doesnt really address the problem of changing the titleLabels dimensions, it will result in the proper display of my ViewController.
It turns out using the frame is a bad idea. I initially used the frame to reposition the view and i figured that this couldnt be a problem because i only ever applied transformations afterwards, but i was wrong. Because OBVIOUSLY i tried to change the titleLabels frame. AFTER the rotation. And that didnt work.
So the way to go here is using the center-property and the bouds of the view consistently throughout the code. It will result in properly rotated Buttons, that do not need any fidgeting afterwards.
My takeaway here is that i will never ever again use the frame-property outside of a NSLog-statement. But why [button sizeToFit];wouldnt yield any results is still beyond me. If i ever figure it out, i might post it if i remember.
EDIT:
#ZevEisenberg nailed it with this comment:
“Warning: If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.” So you are right to use the center and bounds here, but if you do not have a transform, the frame is perfectly safe to use.
NEXT EDIT:
Heres how i ended up repositioning the Buttons:
-(CGPoint)centerForView:(UIView *)view{
//calculate a suitableposition for the view
//depending on the current orientation and the device type (iphone 4S/5, etc)
return point;
}
Then, as a reaction to the deviceOrientation change notification, i apply CGAffineTransformIdentity to all the views, reposition them using my centerForView shown above, and apply the correct rotation transformation to the View. I do this for all the subviews every time the divice rotates, like so:
-(void)setRightRotationTransformations{
[self resetAllTransformations];
self.someSubview.transform = CGAffineTransformRotate(self.someSubview.transform, -M_PI_2);
}
In my case works such hack:
set Line Break mode to Word Wrap
Add extra line to title (even for one line title)
I am hoping to be able to make something similar to the universal access zoom window shown below. I have already created an NSView and using a fill operation I made a rect with a clear "see through" composite to see through my window and show the desktop. Now I am wondering if it is possible to zoom in and out inside my view just like the picture below. I was thinking this might be an IkImageView or something I could apply but i wasent sure how it was done. Does anyone know how to do this or show me where I could find this in the docs? Some code would be great. Thanks!
Take a look at Apple's example CIAnnotation. In this example is magnifying image but I think You can achieve what You want. You can download sample code from here.
CIAnnotation app example:
References and guides which can help You with this:
Core Image Programming guide
Quartz 2D Programming Guide
NSGraphicsContext Class Reference
NSView supports zoom through - (void)scaleUnitSquareToSize:(NSSize)newUnitSize
This zooms the content of the view, so to use this you would have to set the Desktop behind the mouse as view content (NSImage maybe?) and then zoom the view. It will have to update when the mouse is dragged.
Check the ImageKit part of Quartz, in particular the class IKImageView. It has zoom features, but I have not worked with it myself yet.
I'm working on Map application that needs to work like original MapView on iOS.
I need to rotate mapview according to compass heading value. I tried MTLocation example also I also tried this answer But my results is not good.
Please see the screen shot.
When I rotate mapview according to heading value Map is rotating but as you can see on screen tiles is missing.
How can I solve this display problem ?
Regards
- Fatih
Hy,
I'm the author of MTLocation. Thanks for using it by the way!
For this to work you have to make sure, that your MKMapView is a subview of your ViewController's view (and not the view itself). Then you have to increase the frame of your mapView with a simple Pytaghoras - calculation: the width and height must be at least as big as the diagonal: sqrt(visibleWidth[320]^2 + visibleHeight[480-88]^2) = 506.
So that means
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(-100,-100,520,520)];
Hope that helped, please consider upvoting if it fixed your problem.
You can consider using a bigger frame for the MKMapView object. It should probably be a square with each side equal to the length of the device's diagonal. The problem with this approach is that there are regions of this object that the user won't see but we process information like views for annotations related to that region anyway. Other properties like visibleMapRect would be least helpful.
Another alternative would be to be zoom in by scaling the MKMapView object on rotation. But this might make the map blurry (untested). You could zoom out on the region displayed in the map but it could lead to frequent refreshes. You can look at a middle ground where you don't zoom out until the map is rotated over a certain angle. You can also look at using two views where one of the views is off screen and updated so that it can replace the view after a certain amount of rotation so that it feels seamless.
I am working towards making my own maps application in iPhone. I want my maps to rotate as the user turns. I tried setUserTrackingMode available in iOS 5, but due to some reason it doesn't work. So I decided to take help of MTLocation framework here.
Till now I have done the following.
created a new project and copied all .m and .h files in that.
Import MapKit.h and MTLocation.h.
In Viewcontroller.h, defined property for mapView (should I define a property for locateMeItem).
In ViewDidLoad, paste the code given at the end of the page here.
I get a few errors:
Can't see the locateMe button when created programatically.
Undefined property headingEnabled.
myCustomSelector has no effect.
self.toolbar- toolbar is not a instance of ViewController.
I have tried a code at gist[dot]github[dot]com/1373050 too, but I get similar errors.
Can anybody explain a detailed procedure of this.
This post had some easy to follow instructions to make a flash banner clickable, but it's not quite working for me.
http://www.austintreeexperts.com/maps/oakwilt.cfm is where my flash banner is. Under the google earth thing is a small flash ad. When I mouse over, the cursor turns to pointer like it knows it's a link, but clicking does nothing. I've been fooling with this for hours and I'm about to go crazy. My actionscript is this:
on(press){getURL("http://realgreenlawn.com","_blank");}
First thing to consider:
Are you using a button symbol? If so you will get a hand cursor whether or not the onPress() code is correct. You should use a movieclip symbol instead, with your over, up, and down states as frame label names "_up", "_over" and "_down". Those frame names will make a movieclip act like a button instance as long as you have an onRelease() or onPress() method assigned to it as outlined below. Also, to get a hand cursor you will need to set useHandCursor to true.
Second thing to consider:
Your onPress() code looks like its the kind of code placed right on a movieclip. If so, do not do that! Give it an instance name, like myButton and use the code below on the same frame the button resides:
myButton.useHandCursor = true;
myButton.onRelease = function()
{
getURL("http://realgreenlawn.com","_blank");
}
or alternatively and not best practice, but easier if your aren't that skilled with as2 is to put the above code on the first frame inside your button movieclip, but if you do that change it to:
this.useHandCursor = true;
this.onRelease = function()
{
getURL("http://realgreenlawn.com","_blank");
}