@@ -26,19 +26,22 @@ namespace Polymesh {
2626 return htxt ;
2727 }
2828
29- export const rotatePoint3Dxyz = ( point : Vector3 , pivot : Vector3 , angle : Vector3 ) : Vector3 => {
29+ export const makeWave = ( angle : Vector3 ) : Wave3 => ( {
30+ cosX : Math . cos ( angle . x ) , sinX : Math . sin ( angle . x ) ,
31+ cosY : Math . cos ( angle . y ) , sinY : Math . sin ( angle . y ) ,
32+ cosZ : Math . cos ( angle . z ) , sinZ : Math . sin ( angle . z ) ,
33+ } )
34+
35+ export const rotatePoint3Dxyz = ( point : Vector3 , pivot : Vector3 , wave : Wave3 ) : Vector3 => {
3036 let tmp = 0
31- const cosX = Math . cos ( angle . x ) , sinX = Math . sin ( angle . x ) ;
32- const cosY = Math . cos ( angle . y ) , sinY = Math . sin ( angle . y ) ;
33- const cosZ = Math . cos ( angle . z ) , sinZ = Math . sin ( angle . z ) ;
3437 // move point with pivot to 1st place
3538 let dx = point . x - pivot . x ;
3639 let dy = point . y - pivot . y ;
3740 let dz = point . z - pivot . z ;
3841
39- tmp = dy * cosX - dz * sinX ; dz = dy * sinX + dz * cosX ; dy = tmp ; // --- rotate around x ---
40- tmp = dx * cosY + dz * sinY ; dz = - dx * sinY + dz * cosY ; dx = tmp ; // --- rotate around y ---
41- tmp = dx * cosZ - dy * sinZ ; dy = dx * sinZ + dy * cosZ ; dx = tmp ; // --- rotate around z ---
42+ tmp = dy * wave . cosX - dz * wave . sinX ; dz = dy * wave . sinX + dz * wave . cosX ; dy = tmp ; // --- rotate around x ---
43+ tmp = dx * wave . cosY + dz * wave . sinY ; dz = - dx * wave . sinY + dz * wave . cosY ; dx = tmp ; // --- rotate around y ---
44+ tmp = dx * wave . cosZ - dy * wave . sinZ ; dy = dx * wave . sinZ + dy * wave . cosZ ; dx = tmp ; // --- rotate around z ---
4245
4346 // move back to real position
4447 return {
@@ -48,19 +51,16 @@ namespace Polymesh {
4851 } ;
4952 } ;
5053
51- export const rotatePoint3Dyxz = ( point : Vector3 , pivot : Vector3 , angle : Vector3 ) => {
54+ export const rotatePoint3Dyxz = ( point : Vector3 , pivot : Vector3 , wave : Wave3 ) => {
5255 let tmp = 0
53- const cosX = Math . cos ( angle . x ) , sinX = Math . sin ( angle . x ) ;
54- const cosY = Math . cos ( angle . y ) , sinY = Math . sin ( angle . y ) ;
55- const cosZ = Math . cos ( angle . z ) , sinZ = Math . sin ( angle . z ) ;
5656
5757 // Transform vertices
5858 let dx = point . x - pivot . x ;
5959 let dy = point . y - pivot . y ;
6060 let dz = point . z - pivot . z ;
61- tmp = dx * cosY + dz * sinY , dz = - dx * sinY + dz * cosY , dx = tmp ; // --- rotate around y ---
62- tmp = dy * cosX - dz * sinX , dz = dy * sinX + dz * cosX , dy = tmp ; // --- rotate around x ---
63- tmp = dx * cosZ - dy * sinZ , dy = dx * sinZ + dy * cosZ , dx = tmp ; // --- rotate around z ---
61+ tmp = dx * wave . cosY + dz * wave . sinY , dz = - dx * wave . sinY + dz * wave . cosY , dx = tmp ; // --- rotate around y ---
62+ tmp = dy * wave . cosX - dz * wave . sinX , dz = dy * wave . sinX + dz * wave . cosX , dy = tmp ; // --- rotate around x ---
63+ tmp = dx * wave . cosZ - dy * wave . sinZ , dy = dx * wave . sinZ + dy * wave . cosZ , dx = tmp ; // --- rotate around z ---
6464
6565 return {
6666 x : dx + pivot . x ,
@@ -71,9 +71,6 @@ namespace Polymesh {
7171
7272 const normalLen3 = ( n : number ) => Math . sqrt ( ( n * n ) + ( n * n ) + ( n * n ) )
7373
74- export const rotatePointLen3D = ( len : number , pivot : Vector3 , angle : Vector3 , code : Buffer ) : Vector3 =>
75- rotatePoint3Dxyz ( { x : pivot . x + ( code [ 0 ] ? normalLen3 ( len ) : 0 ) , y : pivot . y + ( code [ 1 ] ? - normalLen3 ( len ) : 0 ) , z : pivot . z + ( code [ 2 ] ? normalLen3 ( len ) : 0 ) } , pivot , angle ) ;
76-
7774 const computeNormal = ( v0 : Vector3_ , v1 : Vector3_ , v2 : Vector3_ ) : Vector3 => {
7875 // make vector from triangle
7976 const u = {
@@ -257,7 +254,7 @@ namespace Polymesh {
257254
258255 export const meshDepthZ = ( msh : polymesh ) => {
259256 if ( msh . isDel ( ) ) return NaN ;
260- return rotatePoint3Dyxz ( msh . pos , Polymesh . camview . pos , Polymesh . camview . rot ) . z ;
257+ return rotatePoint3Dyxz ( msh . pos , Polymesh . camview . pos , Polymesh . camview . wave ) . z ;
261258 }
262259
263260 export const meshDistZ = ( msh : polymesh ) => ( Math . abs ( dist ) / ( Math . abs ( dist ) + meshDepthZ ( msh ) ) )
0 commit comments