Class: GpuSkulpt

SKULPT. GpuSkulpt

new GpuSkulpt(options)

Creates a GpuSkulpt instance for sculpting
Parameters:
Name Type Description
options object Options
Properties
Name Type Argument Description
renderer THREE.WebGLRenderer Three.js WebGL renderer
mesh THREE.Mesh Three.js mesh for sculpting
size number size of mesh
res number resolution of mesh
proxyRes number <optional>
resolution of proxy mesh
Source:

Methods

addCallback(type, callbackFn)

Adds callback function that are executed at specific times
Parameters:
Name Type Description
type string Type of callback: 'update' (only choice available now)
callbackFn function Callback function
Source:

clear()

Clears all sculpts
Source:

getCursorAddColor() → {THREE.Vector3}

Gets the color of the cursor in add mode
Source:
Returns:
A vector that represents the color of the cursor in add mode
Type
THREE.Vector3

getCursorHoverColor() → {THREE.Vector3}

Gets the color of the cursor in hover mode
Source:
Returns:
A vector that represents the color of the cursor in hover mode
Type
THREE.Vector3

getCursorRemoveColor() → {THREE.Vector3}

Gets the color of the cursor in remove mode
Source:
Returns:
A vector that represents the color of the cursor in remove mode
Type
THREE.Vector3

getPixelFloatData() → {Float32Array}

Gets float data for every pixel of the terrain texture
NOTE: This is an expensive operation.
Source:
Returns:
Float data of every pixel of the terrain texture
Type
Float32Array

getProxyPixelFloatData() → {Float32Array}

Gets float data for every pixel of the proxy terrain texture
NOTE: This is an expensive operation.
Source:
Returns:
Float data of every pixel of the proxy terrain texture
Type
Float32Array

getSculptDisplayTexture() → {THREE.WebGLRenderTarget}

Gets the sculpt texture that is used for displacement of mesh
Source:
Returns:
Sculpt texture that is used for displacement of mesh
Type
THREE.WebGLRenderTarget

hideCursor()

Hides the sculpt cursor
Source:

loadFromImageData(data, amount, midGreyIsLowest)

Loads terrain heights from image data
Parameters:
Name Type Description
data array Image data from canvas
amount number Height multiplier
midGreyIsLowest boolean Whether mid grey is considered the lowest part of the image
Source:

sculpt(type, position, amount)

Sculpt the terrain
Parameters:
Name Type Description
type enum Sculpt operation type: SKULPT.GpuSkulpt.ADD, SKULPT.GpuSkulpt.REMOVE
position THREE.Vector3 World-space position to sculpt at
amount number Amount to sculpt
Source:

setBrushAmount(amount)

Sets brush amount
Parameters:
Name Type Description
amount number Brush amount
Source:

setBrushSize(size)

Sets brush size
Parameters:
Name Type Description
size number Brush size
Source:

setCursorAddColor(r, g, b)

Sets the color of the cursor in add mode
Parameters:
Name Type Description
r number Red floating-point value between 0 and 1, inclusive
g number Green floating-point value between 0 and 1, inclusive
b number Blue floating-point value between 0 and 1, inclusive
Source:

setCursorHoverColor(r, g, b)

Sets the color of the cursor in hover mode
Parameters:
Name Type Description
r number Red floating-point value between 0 and 1, inclusive
g number Green floating-point value between 0 and 1, inclusive
b number Blue floating-point value between 0 and 1, inclusive
Source:

setCursorRemoveColor(r, g, b)

Sets the color of the cursor in remove mode
Parameters:
Name Type Description
r number Red floating-point value between 0 and 1, inclusive
g number Green floating-point value between 0 and 1, inclusive
b number Blue floating-point value between 0 and 1, inclusive
Source:

showCursor()

Shows the sculpt cursor
Source:

update(dt)

Updates the skulpt
NOTE: This needs to be called every frame, after renderer.clear() and before renderer.render(...)
Parameters:
Name Type Description
dt number Elapsed time since previous frame
Source:

updateCursor(position)

Updates the cursor position
Parameters:
Name Type Description
position THREE.Vector3 World-space position to update the cursor to
Source: