提交 f0ef2532 编写于 作者: M Mr.doob

Merging with @timknip2's mater.

上级 4484dc3a
此差异已折叠。
examples/models/monster.jpg

85.5 KB | W: | H:

examples/models/monster.jpg

85.3 KB | W: | H:

examples/models/monster.jpg
examples/models/monster.jpg
examples/models/monster.jpg
examples/models/monster.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -359,7 +359,7 @@ A regular skin controller would point at a geometry we wanted to skin. In this
taking the output of a morph controller (which is geometry) and skinning that.
*******************************************************************************************
-->
<skin source="#pCylinderShape1-morph">
<skin source="#pCylinderShape1">
<!--
*******************************************************************************************
The bind shape matrix describes how to transform the pCylinderShape1-morph geometry into the
......
......@@ -6,7 +6,7 @@
<style type="text/css">
body {
font-family: Monospace;
background-color: #ffffff;
background-color: #000000;
margin: 0px;
overflow: hidden;
}
......@@ -37,7 +37,9 @@
function colladaReady(collada) {
dae = collada.scene;
dae.scale.x = dae.scale.y = dae.scale.z = 0.002;
dae.scale.x = dae.scale.y = dae.scale.z = 0.003;
//dae.rotation.x = -Math.PI/2;
dae.updateMatrix();
init();
animate();
......
......@@ -6,6 +6,7 @@
* @author D1plo1d / http://github.com/D1plo1d
* @author alteredq / http://alteredqualia.com/
* @author mikael emtinger / http://gomo.se/
* @author timknip / http://www.floorplanner.com/
*/
THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
......@@ -667,6 +668,59 @@ THREE.Matrix4.prototype = {
},
compose: function ( translation, rotation, scale ) {
var mr = new THREE.Matrix4();
var ms = new THREE.Matrix4();
mr.setRotationFromQuaternion(rotation);
ms.setScale(scale.x, scale.y, scale.z);
this.multiply(mr, ms);
this.n14 = translation.x;
this.n24 = translation.y;
this.n34 = translation.z;
return this;
},
decompose: function ( translation, rotation, scale ) {
// grab the axis vecs
var x = new THREE.Vector3(this.n11, this.n21, this.n31);
var y = new THREE.Vector3(this.n12, this.n22, this.n32);
var z = new THREE.Vector3(this.n13, this.n23, this.n33);
translation = (translation instanceof THREE.Vector3) ? translation : new THREE.Vector3();
rotation = (rotation instanceof THREE.Quaternion) ? rotation : new THREE.Quaternion();
scale = (scale instanceof THREE.Vector3) ? scale : new THREE.Vector3();
scale.x = x.length();
scale.y = y.length();
scale.z = z.length();
translation.x = this.n14;
translation.y = this.n24;
translation.z = this.n34;
// scale the rotation part
var matrix = this.clone();
matrix.n11 /= scale.x;
matrix.n21 /= scale.x;
matrix.n31 /= scale.x;
matrix.n12 /= scale.y;
matrix.n22 /= scale.y;
matrix.n32 /= scale.y;
matrix.n13 /= scale.z;
matrix.n23 /= scale.z;
matrix.n33 /= scale.z;
rotation.setFromRotationMatrix(matrix);
return [translation, rotation, scale];
},
extractPosition: function ( m ) {
this.n14 = m.n14;
......@@ -674,7 +728,7 @@ THREE.Matrix4.prototype = {
this.n34 = m.n34;
},
extractRotation: function ( m, s ) {
var invScaleX = 1 / s.x, invScaleY = 1 / s.y, invScaleZ = 1 / s.z;
......
......@@ -85,6 +85,23 @@ THREE.Quaternion.prototype = {
},
setFromRotationMatrix: function ( m ) {
// Adapted from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
function copySign(a, b) {
return b < 0 ? -Math.abs(a) : Math.abs(a);
}
var absQ = Math.pow(m.determinant(), 1.0 / 3.0);
this.w = Math.sqrt( Math.max( 0, absQ + m.n11 + m.n22 + m.n33 ) ) / 2;
this.x = Math.sqrt( Math.max( 0, absQ + m.n11 - m.n22 - m.n33 ) ) / 2;
this.y = Math.sqrt( Math.max( 0, absQ - m.n11 + m.n22 - m.n33 ) ) / 2;
this.z = Math.sqrt( Math.max( 0, absQ - m.n11 - m.n22 + m.n33 ) ) / 2;
this.x = copySign( this.x, ( m.n32 - m.n23 ) );
this.y = copySign( this.y, ( m.n13 - m.n31 ) );
this.z = copySign( this.z, ( m.n21 - m.n12 ) );
this.normalize();
return this;
},
calculateW : function () {
this.w = - Math.sqrt( Math.abs( 1.0 - this.x * this.x - this.y * this.y - this.z * this.z ) );
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册