|
@@ -1778,6 +1778,27 @@
|
|
|
VertexData.ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
|
|
|
this.setVerticesData(VertexBuffer.NormalKind, normals, updatable);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Align the mesh with a normal.
|
|
|
+ * Returns the mesh.
|
|
|
+ */
|
|
|
+ public alignWithNormal(normal:BABYLON.Vector3, upDirection?:BABYLON.Vector3):AbstractMesh{
|
|
|
+ if(!upDirection){
|
|
|
+ upDirection = BABYLON.Axis.Y;
|
|
|
+ }
|
|
|
+
|
|
|
+ var axisX = Tmp.Vector3[0];
|
|
|
+ var axisZ = Tmp.Vector3[1];
|
|
|
+ Vector3.CrossToRef(upDirection, normal, axisZ);
|
|
|
+ Vector3.CrossToRef(normal, axisZ, axisX);
|
|
|
+
|
|
|
+ if(this.rotationQuaternion){
|
|
|
+ Quaternion.RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
|
|
|
+ }else{
|
|
|
+ Vector3.RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
|
|
|
protected checkOcclusionQuery() {
|
|
|
var engine = this.getEngine();
|