Skip to content

Commit 0eedc63

Browse files
authored
Merge pull request #16110 from looeee/support_morph_targets_in_points
Points: Introduce . updateMorphTargets()
2 parents 8daf8e6 + 6f82a77 commit 0eedc63

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/objects/Points.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function Points( geometry, material ) {
1919
this.geometry = geometry !== undefined ? geometry : new BufferGeometry();
2020
this.material = material !== undefined ? material : new PointsMaterial( { color: Math.random() * 0xffffff } );
2121

22+
this.updateMorphTargets();
23+
2224
}
2325

2426
Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
@@ -136,6 +138,38 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
136138

137139
}() ),
138140

141+
updateMorphTargets: function () {
142+
143+
var geometry = this.geometry;
144+
var m, ml, name;
145+
146+
var morphAttributes = geometry.morphAttributes;
147+
var keys = Object.keys( morphAttributes );
148+
149+
if ( keys.length > 0 ) {
150+
151+
var morphAttribute = morphAttributes[ keys[ 0 ] ];
152+
153+
if ( morphAttribute !== undefined ) {
154+
155+
this.morphTargetInfluences = [];
156+
this.morphTargetDictionary = {};
157+
158+
for ( m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
159+
160+
name = morphAttribute[ m ].name || String( m );
161+
162+
this.morphTargetInfluences.push( 0 );
163+
this.morphTargetDictionary[ name ] = m;
164+
165+
}
166+
167+
}
168+
169+
}
170+
171+
},
172+
139173
clone: function () {
140174

141175
return new this.constructor( this.geometry, this.material ).copy( this );
@@ -144,5 +178,4 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
144178

145179
} );
146180

147-
148181
export { Points };

0 commit comments

Comments
 (0)