Capítulo 571 de 859

Chapter 571: MarchingCubes

Core Idea

A marching cubes implementation.

Port of: http://webglsamples.org/blob/blob.html

Key Concepts

  • enableColors : boolean: Whether colors should be animated or not.
  • enableUvs : boolean: Whether texture coordinates should be animated or not.
  • isMarchingCubes : boolean (readonly): This flag can be used for type testing.

Code Examples

import { MarchingCubes } from 'three/addons/objects/MarchingCubes.js';
  • What it demonstrates: Typical usage of MarchingCubes.

Reference Tables

Constructor

Signature
new MarchingCubes( resolution : number, material : Material, enableUvs : boolean, enableColors : boolean, maxPolyCount : number )

Properties

PropertyDescription
.enableColors : booleanWhether colors should be animated or not.
.enableUvs : booleanWhether texture coordinates should be animated or not.
.isMarchingCubes : boolean (readonly)This flag can be used for type testing.

Methods

MethodDescription
.addBall( ballx : number, bally : number, ballz : number, strength : number, subtract : number, colors : Color )Adds a reciprocal ball (nice and blobby) that, to be fast, fades to zero after a fixed distance, determined by strength and subtract.
.addPlaneX( strength : number, subtract : number )Adds a plane along the x-axis.
.addPlaneY( strength : number, subtract : number )Adds a plane along the y-axis.
.addPlaneZ( strength : number, subtract : number )Adds a plane along the z-axis.
.blur( intensity : number )Applies a blur with the given intensity.
.getCell( x : number, y : number, z : number ) : numberReturns the cell value for the given coordinates.
.reset()Resets the effect.
.setCell( x : number, y : number, z : number, value : number )Sets the cell value for the given coordinates.
.update()Updates the effect.

Key Takeaways

  1. Most relevant properties: enableColors, enableUvs, isMarchingCubes.
  2. Key methods: addBall, addPlaneX, addPlaneY, addPlaneZ.

Connects To