浏览代码

Merge pull request #16748 from Mugen87/dev31

JSM: Added module and TS file for MorphAnimMesh.
Michael Herzog 6 年之前
父节点
当前提交
924e590a4f

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

@@ -180,6 +180,7 @@
 						<li>LWOLoader</li>
 						<li>MD2Loader</li>
 						<li>MTLLoader</li>
+						<li>NRRDLoader</li>
 						<li>OBJLoader</li>
 						<li>PCDLoader</li>
 						<li>PDBLoader</li>
@@ -209,14 +210,17 @@
 				</li>
 				<li>misc
 					<ul>
-						<li>Car</li>
+						<li>CarControls</li>
 						<li>ConvexObjectBreaker</li>
 						<li>GPUComputationRenderer</li>
 						<li>Gyroscope</li>
 						<li>MD2Character</li>
 						<li>MD2CharacterComplex</li>
+						<li>MorphAnimMesh</li>
 						<li>MorphBlendMesh</li>
 						<li>Ocean</li>
+						<li>Volume</li>
+						<li>VolumeSlice</li>
 					</ul>
 				</li>
 				<li>modifiers

+ 4 - 3
examples/js/MorphAnimMesh.js → examples/js/misc/MorphAnimMesh.js

@@ -10,6 +10,7 @@ THREE.MorphAnimMesh = function ( geometry, material ) {
 
 	this.mixer = new THREE.AnimationMixer( this );
 	this.activeAction = null;
+
 };
 
 THREE.MorphAnimMesh.prototype = Object.create( THREE.Mesh.prototype );
@@ -23,17 +24,17 @@ THREE.MorphAnimMesh.prototype.setDirectionForward = function () {
 
 THREE.MorphAnimMesh.prototype.setDirectionBackward = function () {
 
-	this.mixer.timeScale = -1.0;
+	this.mixer.timeScale = - 1.0;
 
 };
 
 THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) {
 
-	if( this.activeAction ) {
+	if ( this.activeAction ) {
 
 		this.activeAction.stop();
 		this.activeAction = null;
-		
+
 	}
 
 	var clip = THREE.AnimationClip.findByName( this, label );

+ 20 - 0
examples/jsm/misc/MorphAnimMesh.d.ts

@@ -0,0 +1,20 @@
+import {
+  AnimationAction,
+  AnimationMixer,
+  BufferGeometry,
+  Geometry,
+  Material,
+  Mesh
+} from '../../../src/Three';
+
+export class MorphAnimMesh extends Mesh {
+  constructor(geometry: BufferGeometry | Geometry, material: Material);
+  mixer: AnimationMixer;
+  activeAction: AnimationAction | null;
+
+  setDirectionForward(): void;
+  setDirectionBackward(): void;
+  playAnimation(label: string, fps: number): void;
+  updateAnimation(delta: number): void;
+  copy(source: MorphAnimMesh): this;
+}

+ 78 - 0
examples/jsm/misc/MorphAnimMesh.js

@@ -0,0 +1,78 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+import {
+	AnimationClip,
+	AnimationMixer,
+	Mesh
+} from "../../../build/three.module.js";
+
+var MorphAnimMesh = function ( geometry, material ) {
+
+	Mesh.call( this, geometry, material );
+
+	this.type = 'MorphAnimMesh';
+
+	this.mixer = new AnimationMixer( this );
+	this.activeAction = null;
+
+};
+
+MorphAnimMesh.prototype = Object.create( Mesh.prototype );
+MorphAnimMesh.prototype.constructor = MorphAnimMesh;
+
+MorphAnimMesh.prototype.setDirectionForward = function () {
+
+	this.mixer.timeScale = 1.0;
+
+};
+
+MorphAnimMesh.prototype.setDirectionBackward = function () {
+
+	this.mixer.timeScale = - 1.0;
+
+};
+
+MorphAnimMesh.prototype.playAnimation = function ( label, fps ) {
+
+	if ( this.activeAction ) {
+
+		this.activeAction.stop();
+		this.activeAction = null;
+
+	}
+
+	var clip = AnimationClip.findByName( this, label );
+
+	if ( clip ) {
+
+		var action = this.mixer.clipAction( clip );
+		action.timeScale = ( clip.tracks.length * fps ) / clip.duration;
+		this.activeAction = action.play();
+
+	} else {
+
+		throw new Error( 'THREE.MorphAnimMesh: animations[' + label + '] undefined in .playAnimation()' );
+
+	}
+
+};
+
+MorphAnimMesh.prototype.updateAnimation = function ( delta ) {
+
+	this.mixer.update( delta );
+
+};
+
+MorphAnimMesh.prototype.copy = function ( source ) {
+
+	Mesh.prototype.copy.call( this, source );
+
+	this.mixer = new AnimationMixer( this );
+
+	return this;
+
+};
+
+export { MorphAnimMesh };

+ 1 - 0
utils/modularize.js

@@ -116,6 +116,7 @@ var files = [
 	{ path: 'misc/Gyroscope.js', dependencies: [], ignoreList: [] },
 	{ path: 'misc/MD2Character.js', dependencies: [ { name: 'MD2Loader', path: 'loaders/MD2Loader.js' } ], ignoreList: [] },
 	{ path: 'misc/MD2CharacterComplex.js', dependencies: [ { name: 'MD2Loader', path: 'loaders/MD2Loader.js' }, { name: 'MorphBlendMesh', path: 'misc/MorphBlendMesh.js' } ], ignoreList: [] },
+	{ path: 'misc/MorphAnimMesh.js', dependencies: [], ignoreList: [] },
 	{ path: 'misc/MorphBlendMesh.js', dependencies: [], ignoreList: [] },
 	{ path: 'misc/Ocean.js', dependencies: [ { name: 'OceanShaders', path: 'shaders/OceanShaders.js' } ], ignoreList: [] },
 	{ path: 'misc/Volume.js', dependencies: [ { name: 'VolumeSlice', path: 'misc/VolumeSlice.js' } ], ignoreList: [] },