Capítulo 618 de 859

Chapter 618: VolumeSlice

Core Idea

This class has been made to hold a slice of a volume data.

Key Concepts

  • axis : 'x' | 'y' | 'z': The normal axis.
  • canvas : HTMLCanvasElement: The final canvas used for the texture.
  • canvasBuffer : HTMLCanvasElement: The intermediary canvas used to paint the data.
  • ctx : CanvasRenderingContext2D: The rendering context of the canvas.
  • ctxBuffer : CanvasRenderingContext2D: The rendering context of the canvas buffer,
  • geometryNeedsUpdate : boolean: If set to true, updateGeometry() will be triggered at the next repaint.
  • iLength : number: Width of slice in the original coordinate system, corresponds to the width of the buffer canvas.
  • index : number: The index of the slice, if changed, will automatically call updateGeometry at the next repaint.
  • jLength : number: Height of slice in the original coordinate system, corresponds to the height of the buffer canvas.
  • mesh : Mesh: The mesh ready to get used in the scene.

Code Examples

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

Reference Tables

Constructor

Signature
`new VolumeSlice( volume : Volume, index : number, axis : 'x'

Properties

PropertyDescription
`.axis : 'x''y'
.canvas : HTMLCanvasElementThe final canvas used for the texture.
.canvasBuffer : HTMLCanvasElementThe intermediary canvas used to paint the data.
.ctx : CanvasRenderingContext2DThe rendering context of the canvas.
.ctxBuffer : CanvasRenderingContext2DThe rendering context of the canvas buffer,
.geometryNeedsUpdate : booleanIf set to true, updateGeometry() will be triggered at the next repaint.
.iLength : numberWidth of slice in the original coordinate system, corresponds to the width of the buffer canvas.
.index : numberThe index of the slice, if changed, will automatically call updateGeometry at the next repaint.
.jLength : numberHeight of slice in the original coordinate system, corresponds to the height of the buffer canvas.
.mesh : MeshThe mesh ready to get used in the scene.
.sliceAccess : functionFunction that allow the slice to access right data.
.volume : VolumeThe associated volume.

Methods

MethodDescription
.repaint()Refresh the texture and the geometry if geometryNeedsUpdate is set to true.
.updateGeometry()Refresh the geometry according to axis and index.

Key Takeaways

  1. Most relevant properties: axis, canvas, canvasBuffer, ctx.
  2. Key methods: repaint, updateGeometry.

Connects To