Ver Fonte

JSM: Added module and TS file for Gyroscope.

Mugen87 há 6 anos atrás
pai
commit
37c215b8c5

+ 1 - 0
docs/manual/en/introduction/Import-via-modules.html

@@ -209,6 +209,7 @@
 				<li>misc
 					<ul>
 						<li>Car</li>
+						<li>Gyroscope</li>
 						<li>MD2Character</li>
 						<li>Ocean</li>
 					</ul>

+ 0 - 0
examples/js/Gyroscope.js → examples/js/misc/Gyroscope.js


+ 7 - 0
examples/jsm/misc/Gyroscope.d.ts

@@ -0,0 +1,7 @@
+import {
+  Object3D
+} from '../../../src/Three';
+
+export class Gyroscope extends Object3D {
+  constructor();
+}

+ 73 - 0
examples/jsm/misc/Gyroscope.js

@@ -0,0 +1,73 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+import {
+	Object3D,
+	Quaternion,
+	Vector3
+} from "../../../build/three.module.js";
+
+var Gyroscope = function () {
+
+	Object3D.call( this );
+
+};
+
+Gyroscope.prototype = Object.create( Object3D.prototype );
+Gyroscope.prototype.constructor = Gyroscope;
+
+Gyroscope.prototype.updateMatrixWorld = ( function () {
+
+	var translationObject = new Vector3();
+	var quaternionObject = new Quaternion();
+	var scaleObject = new Vector3();
+
+	var translationWorld = new Vector3();
+	var quaternionWorld = new Quaternion();
+	var scaleWorld = new Vector3();
+
+	return function updateMatrixWorld( force ) {
+
+		this.matrixAutoUpdate && this.updateMatrix();
+
+		// update matrixWorld
+
+		if ( this.matrixWorldNeedsUpdate || force ) {
+
+			if ( this.parent !== null ) {
+
+				this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
+
+				this.matrixWorld.decompose( translationWorld, quaternionWorld, scaleWorld );
+				this.matrix.decompose( translationObject, quaternionObject, scaleObject );
+
+				this.matrixWorld.compose( translationWorld, quaternionObject, scaleWorld );
+
+
+			} else {
+
+				this.matrixWorld.copy( this.matrix );
+
+			}
+
+
+			this.matrixWorldNeedsUpdate = false;
+
+			force = true;
+
+		}
+
+		// update children
+
+		for ( var i = 0, l = this.children.length; i < l; i ++ ) {
+
+			this.children[ i ].updateMatrixWorld( force );
+
+		}
+
+	};
+
+}() );
+
+export { Gyroscope };

+ 1 - 1
examples/webgl_loader_md2_control.html

@@ -30,7 +30,7 @@
 		<script src="js/loaders/MD2Loader.js"></script>
 		<script src="js/MorphBlendMesh.js"></script>
 		<script src="js/MD2CharacterComplex.js"></script>
-		<script src="js/Gyroscope.js"></script>
+		<script src="js/misc/Gyroscope.js"></script>
 
 		<script src="js/libs/stats.min.js"></script>
 		<script src="js/WebGL.js"></script>

+ 1 - 0
utils/modularize.js

@@ -108,6 +108,7 @@ var files = [
 
 	{ path: 'misc/CarControls.js', dependencies: [], ignoreList: [] },
 	{ path: 'misc/ConvexObjectBreaker.js', dependencies: [ { name: 'ConvexBufferGeometry', path: 'geometries/ConvexGeometry.js' } ], ignoreList: [ 'Matrix4' ] },
+	{ path: 'misc/Gyroscope.js', dependencies: [], ignoreList: [] },
 	{ path: 'misc/MD2Character.js', dependencies: [ { name: 'MD2Loader', path: 'loaders/MD2Loader.js' } ], ignoreList: [] },
 	{ path: 'misc/Ocean.js', dependencies: [ { name: 'OceanShaders', path: 'shaders/OceanShaders.js' } ], ignoreList: [] },