sharon
sharon

Reputation: 123

Threejs: How to dynamically change width and height of plane?

Is there a way to easily change width and height of plane dynamically? The code below has no effect.

plane.geometry.parameters.width = width;
plane.geometry.parameters.height = height;

Upvotes: 8

Views: 11747

Answers (2)

RoyFat
RoyFat

Reputation: 44

This is what worked for me. You can try:

mesh.geometry.width = width;
mesh.updateMatrix();

Upvotes: 1

WestLangley
WestLangley

Reputation: 104763

Create the plane mesh

var geometry = new THREE.PlaneGeometry( 1, 1 );

var mesh = new THREE.Mesh( geometry, material );

You can then dynamically change the dimensions by resetting the scale, like so:

mesh.scale.set( width, height, 1 );

three.js r.74

Upvotes: 19

Related Questions