Расширяя ответ Петра, вот код, необходимый для поддержки плоскостей среза для текстурированных сеток:
const imgTexture = THREE_FORGE.ImageUtils.loadTexture(textureUrl);
const vertexShader = `
#if NUM_CUTPLANES > 0
varying vec3 vWorldPosition;
#endif
varying vec2 vUv;
void main() {
#if NUM_CUTPLANES > 0
vec4 _worldPosition = modelMatrix * vec4( position, 1.0 );
vWorldPosition = _worldPosition.xyz;
#endif
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
}
`;
const fragmentShader = `
#include<cutplanes>
#if NUM_CUTPLANES > 0
varying highp vec3 vWorldPosition;
#endif
uniform sampler2D texture;
varying vec2 vUv;
void main() {
#if NUM_CUTPLANES > 0
checkCutPlanes(vWorldPosition);
#endif
gl_FragColor = texture2D(texture, vUv);
}
`;
const material = new THREE_FORGE.ShaderMaterial({
uniforms: {
cutplanes: {type: 'v4v', value: []},
hatchParams: {type: 'v2', value: new THREE_FORGE.Vector2(1.0, 10.0)},
hatchTintColor: {type: 'c', value: new THREE_FORGE.Color(0xFFFFFF)},
hatchTintIntensity: {type: 'f', value: 1.0},
texture: {type: 't', value: imgTexture},
},
vertexShader: vertexShader,
fragmentShader: fragmentShader,
});
const mesh = new THREE.Mesh(geometry, material);