Skip to content

Commit

Permalink
Added MorphTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson Silva committed Jan 29, 2013
1 parent 7d7c5d5 commit d451be0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/src/core/Geometry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class Geometry {
List faceUvs;
List<List> faceVertexUvs;

List morphTargets, morphColors, morphNormals;
List <MorphTarget> morphTargets;
List morphColors, morphNormals;
List skinWeights, skinIndices;

List<Vector3> __tmpVertices;
Expand Down
8 changes: 8 additions & 0 deletions lib/src/core/MorphTarget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
part of three;

class MorphTarget {
String name;
List<Vector3> vertices;
MorphTarget( { this.name, this.vertices } );
}

4 changes: 2 additions & 2 deletions lib/src/objects/Mesh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Mesh extends Object3D {
Geometry geometry;
Material material;

num _morphTargetBase;
num morphTargetBase;
List morphTargetForcedOrder;
List morphTargetInfluences;
Map _morphTargetDictionary;
Expand All @@ -35,7 +35,7 @@ class Mesh extends Object3D {

// setup morph targets
if( geometry.morphTargets.length != 0 ) {
_morphTargetBase = -1;
morphTargetBase = -1;
morphTargetForcedOrder = [];
morphTargetInfluences = [];
_morphTargetDictionary = {};
Expand Down
13 changes: 6 additions & 7 deletions lib/src/renderers/WebGLRenderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3440,7 +3440,7 @@ class WebGLRenderer implements Renderer {

// vertices

if ( !material.morphTargets && attributes["position"] >= 0 ) {
if ( (material.morphTargets == null) && attributes["position"] >= 0 ) {

if ( updateBuffers ) {

Expand All @@ -3451,7 +3451,7 @@ class WebGLRenderer implements Renderer {

} else {

if ( webglobject.morphTargetBase ) {
if ( webglobject.morphTargetBase != 0 ) {

setupMorphTargets( material, geometryGroup, webglobject );

Expand Down Expand Up @@ -3645,7 +3645,7 @@ class WebGLRenderer implements Renderer {

}

if ( object.morphTargetForcedOrder.length ) {
if ( object.morphTargetForcedOrder.length > 0) {

// set forced order

Expand Down Expand Up @@ -3710,7 +3710,7 @@ class WebGLRenderer implements Renderer {

while ( m < material.numSupportedMorphTargets ) {

if ( activeInfluenceIndices[ m ] != null && !activeInfluenceIndices[ m ].isEmpty) {
if ( m < activeInfluenceIndices.length && activeInfluenceIndices[ m ] != null && !activeInfluenceIndices[ m ].isEmpty) {

influenceIndex = activeInfluenceIndices[ m ][ 0 ];

Expand Down Expand Up @@ -4871,7 +4871,7 @@ class WebGLRenderer implements Renderer {

if ( material.morphTargets ) {

if ( ! object.__webglMorphTargetInfluences ) {
if ( object.__webglMorphTargetInfluences == null) {

object.__webglMorphTargetInfluences = new Float32Array( maxMorphTargets );

Expand Down Expand Up @@ -7161,7 +7161,7 @@ class WebGLMaterial { // implements Material {
var _uniforms;
var uniformsList;

num numSupportedMorphTargets, numSupportedMorphNormals;
num numSupportedMorphTargets = 0, numSupportedMorphNormals = 0;

// Used by ShadowMapPlugin
bool _shadowPass;
Expand Down Expand Up @@ -7223,7 +7223,6 @@ class WebGLMaterial { // implements Material {
get lights => isShaderMaterial ? (_material as ShaderMaterial).lights : false;

get morphTargets => _hasMorhTargets ? (_material as dynamic).morphTargets : false;

get morphNormals => _hasMorphNormals ? (_material as dynamic).morphNormals : false;

bool get metal => isMeshPhongMaterial ? (_material as MeshPhongMaterial).metal : false; //null;
Expand Down
1 change: 1 addition & 0 deletions lib/three.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ part 'src/core/Color.dart';
part 'src/core/Face3.dart';
part 'src/core/Face4.dart';
part 'src/core/Frustum.dart';
part 'src/core/MorphTarget.dart';
part 'src/core/Geometry.dart';
part 'src/core/Vertex.dart';
part 'src/core/Projector.dart';
Expand Down

0 comments on commit d451be0

Please sign in to comment.