Capítulo 803 de 859
Using Sprite/SpriteMaterial to make objects always face the camera, and using pre-rendered "facades" (2D textured planes) as a cheap stand-in for repeated complex 3D objects like trees.
Sprite / SpriteMaterial: a plane that always faces the camera, useful for labels, badges, or particle-like effects.RenderTarget: used to pre-render an object (e.g. a tree) to an offscreen texture that becomes the facade's texture.frameArea: a helper that positions a camera so an object's bounding box exactly fills the frame, used when baking a facade texture.function frameArea(sizeToFitOnScreen, boxSize, boxCenter, camera) {
const halfSizeToFitOnScreen = sizeToFitOnScreen * 0.5;
const halfFovY = THREE.MathUtils.degToRad(camera.fov * .5);
const distance = halfSizeToFitOnScreen / Math.tan(halfFovY);
camera.position.copy(boxCenter);
camera.position.z += distance;
camera.near = boxSize / 100;
camera.far = boxSize * 100;
camera.updateProjectionMatrix();
}
RenderTarget.Sprite + SpriteMaterial billboard a plane so it always faces the camera.RenderTarget is how you bake an object's appearance into a facade texture ahead of time.