I was looking to follow this example and offset a simple square by a given distance:
There’s a question on SO:
And a forum topic:
With some changes of the ProfiledContourGeometry, there is a function which offsets points of a contour - OffsetContour :
[OffsetContour]
function OffsetContour(offset, contour) {
let result = [];
offset = new THREE.BufferAttribute(new Float32Array([offset, 0, 0]), 3);
for (let i = 0; i < contour.length; i++) {
let v1 = new THREE.Vector2().subVectors(contour[i - 1 < 0 ? contour.length - 1 : i - 1], contour[i])…
I have this codesandbox test environment:
https://codesandbox.io/p/sandbox/63h94y?file=%2Fsrc%2Findex.mjs%3A180%2C1
I am running into this error:
TypeError
shiftMatrix.applyToBufferAttribute is not a function
What is the expected input into this function? Is it the Three.Vector2 points?
I could not find any methods in the threeJS documentation that have applyToBufferAttribute().
Thanks for your help!
The applyToBufferAttribute
has been deprecated 4 years ago (in r113). You may need to either use an old Three.js release, or to find alternative ways to do the same matrix operation on a buffer. Have you tried to use BufferAttribute.applyMatrix3 or BufferAttribute.applyMatrix4 ?
3 Likes
Thank you, applyMatrix4 does the trick.
3 Likes