Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

webgl rotate an object around another object in one axis

I think you need to do a sequence of matrix operations and the order of matrix operation matters.

What you probably want in this case is to first translate Mercury to position of Sun, then do the rotation, then reverse the first translation. I have not yet implemented hierarchical objects myself so I dont want to confuse you. But here is the code for my implementation of orbit camera which the yaw function rotates the camera around a target point and you may find it useful:

 yaw: function(radian){
        this.q = quat.axisAngle(this.q,
this.GLOBALUP, radian);
        vec3.rotateByQuat(this.dir, this.dir,

        this.pos[0] =[0] - this.dir[0]
* this.dist;
        this.pos[1] =[1] - this.dir[1]
* this.dist;
        this.pos[2] =[2] - this.dir[2]
* this.dist;

Where this.dir is a normalized vector that always gives the direction from Camera to target and this.dist is the distance between camera and target. You can use matrix rotation instead of quaternion rotation.

Edit: just to add the direction can be calculated by taking the difference in position of the two objects then normalize it.

Categories : Javascript

Related to : webgl rotate an object around another object in one axis
webgl losing reference to an object in javascript
I assume you are calling setBufferName(Planets) before you call initBuffers(Planets). So setBufferName(Planets) will set VertexPositionBuffer[i] to a name, VertexPositionBuffer[i] = Planets[i].name+"VertexPositionBuffer"; but then initBuffers(Planets) will set VertexPositionBuffer[i] to a WebGLBuffer, VertexPositionBuffer[i] = gl.createBuffer(); So you will lose your name. I suggest you ca

Categories : Javascript
Error "Object.keys called on non-object" caused by empty json output
The error Object.keys called on non-object can only occured when you put non object into it. See below in return function(obj) { if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) { throw new TypeError('Object.keys called on non-object'); } Did you te

Categories : Javascript
AtrributeError: 'NoneType' object has no attribute 'data' & TypeError: 'str' object is not callable
You're trying to call string.lowercase(blabla) and that's where you get TypeError You should do print "In Boston, Lincolnshire it is currently: " + bostonweather['current_conditions']['text'].lower() + " and " + bostonweather['current_conditions']['temperature'].lower() + ("C. ")

Categories : Python
RenderSection set as required:false, but still throws "Object reference not set to an instance of an object"
This has nothing to do with your section. I'm not sure where you got the idea that the section being empty is generating this error, but that is categorically not what's happening. Object reference not set to an instance of an object is a runtime error generated when you attempt to reference a property off of a variable that evaluates to null. There's some piece of code somewhere that is referenci

Categories : Asp Net Mvc
Mapping Data Annotation of a Model object to Custom Class object .net mvc
As you have mentioned you can get attributes with the information from this question: How to retrieve Data Annotations from code? (programmatically) public static T GetAttributeFrom<T>(this object instance, string propertyName) where T : Attribute { var attrType = typeof(T); var property = instance.GetType().GetProperty(propertyName); return (T)property .GetCustomAttributes(attr

Categories : C#
Recently Add
Busy Indicator while page is loading
parent.document.getElementById and images path
Can not get bootstrap datetime picker to display properly
reading select box jquery issues
DC.JS Pie Chart + Select Deslect from external JavaScript function
Why would I ever need to cancelAnimationFrame()
Angular.ui alert doesn't close
HTML/JS How to position a rectangle relative to 'any' side of the parent canvas element
parse variable to xml
C# Dictionary equivalent in JavaScript
ExtJS Dashboard Panel Fit Panel Vertically
jQuery cross domain ajax call - Interpreted as script but transferred with MIME type text/xml
Reactjs map returns unexpected token }
Working with multiple pages in apache cordova and vs2013
Resize iframe to loaded content
Why 13596*0.1 is different than 13596/10?
AngularJS Validate all forms on application load
javascript open popup without menu/url/titlebar/scrollbar/anything
Can I use Razor syntax inside Javascript included in a ScriptBundle?
How to show a box for comment reply with id
parse name from user input when using jquery serialize
How to parse and load javascript object?
Marionette not navigating to the same url
Adding Google+ Sign in button to website
GRUNT - Install Grunt Packages?
how should I create the path of templateUrl property in Angular ui-router?
Update mysql database with jquery array using ajax
Run the same function on each item in a list / array
Get all ticks values (NVD3)
Button Click Event not Passing input String to MVC Controller Method
© Copyright 2017 Publishing Limited. All rights reserved.