Jump to content

I might have broke the playground


Recommended Posts

Well I got the playground the way I wanted it.  I hit the save button, and the url does not change.  It is a crazy positional animation, that at the createScene() level looks like the gingerbread should just be moving in a straight line while spinning. In fact, that is NOT what happens, yes!


I hit .Zip button & I got a .Zip, but the html it is not animated.  I just put everything on the clipboard, and put it in a code section below.  That does not work, because the site says the post was too long.  So I put it in a .Zip I made myself. 


I really wanted to discuss this in a thread about the code, not about how it does not save.


Any reason why?






Link to comment
Share on other sites

I thought so, but no response the first time I or anyone uses a tool is tough to deal with.  An alert or console.log of the issue would be very helpful.  Might take double / front-end validation though.


I would also say that in a TOB world, chunks of inline code is simple.  Maybe up the limit, please.

Link to comment
Share on other sites

Before I attempt to re-use this thread to talk about movePOV() / calcMovePOV(), I tried to do additional saves with the code from the .ZIP above & and saw no change, no Alert, and the message in the log was "Empty string passed to getElementById()."


On to movePOV() / calcMovePOV(), see typescript below.  I made these methods while trying to develop closely integrated positional & rotational changes that occurred during shape key deformations, like walking / flying.  These functions are a later iteration of the moveForward() method in the above playground.zip, that is too large to save.  The principal difference is the arguments of the amounts to shift are specified as individual numbers (not a Vector3), and the forwardAmount arg is now multiplied by -1.  Also,  movePOV() calls calcMovePOV(), making 2 methods instead of 1.


This allows for reusable code to be made.  For example,  you could build a mesh in Blender with a couple of shape keys where the legs are in different positions.  You then export it, which builds a .js with an Automaton sub-class for the mesh.  You write code  (better yet sub-class again) which makes it take a step forward.  Any corresponding 'forward' positional change could be interpolated from its current position to calcMovePOV(0, 0, amt) called just before the start.  This single calc works as long no rotation is also being applied. 


If the mesh is making 'a turn', then iteratively call movePov(0, 0, amt / ratio complete).  Importantly, you would not want to just specify a non-zero amount to amountRight in a calcMovePOV().  This would not rotate the mesh.  See the playground.  All movePOV(0, 0, amt / % complete) thinks it is doing is moving in a straight line, but as each little bit of rotation occurs, it is not!


This works regardless of the rotational orientation at the start!  The values are also amounts to change, not absolute values.  The 2 == reusable. 


I am explaining what I intend to do,  because there are other possible uses for this.  I have no problem if it was decided that these could be implemented at AbstractMesh.  If so, let me know.



        /**         * Perform relative position change from the the point of view of behind the front of the mesh.         * This is performed taking into account the meshes current rotation, so you do not have to care.         * @param {number} amountRight         * @param {number} amountUp         * @param {number} amountForward         */        public movePOV(amountRight : number, amountUp : number, amountForward : number) : void {            this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));        }                /**         * Calculate relative position change from the the point of view of behind the front of the mesh.         * This is performed taking into account the meshes current rotation, so you do not have to care.         * @param {number} amountRight         * @param {number} amountUp         * @param {number} amountForward         */        public calcMovePOV(amountRight : number, amountUp : number, amountForward : number) : Vector3 {            var rotMatrix : Matrix = new Matrix();            var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);            rotQuaternion.toRotationMatrix(rotMatrix);                        var translationDelta : Vector3 = Vector3.Zero();            Vector3.TransformCoordinatesFromFloatsToRef(amountRight, amountUp, amountForward * -1, rotMatrix, translationDelta);            return translationDelta;        }
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...