fixes unsynced position of outline
This commit is contained in:
@@ -34,15 +34,15 @@ const OutlineMesh = ({ meshesData }) => {
|
|||||||
});
|
});
|
||||||
}, [width, height, depth, dimensions]);
|
}, [width, height, depth, dimensions]);
|
||||||
|
|
||||||
const compansate = {
|
|
||||||
x: dimensions.x % 2 === 0 ? dimensions.x / 2 : (dimensions.x - 1) / 2,
|
|
||||||
z: dimensions.z % 2 === 0 ? dimensions.z / 2 : (dimensions.z - 1) / 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!ref.current) return;
|
if (!ref.current) return;
|
||||||
|
|
||||||
meshesData.forEach((meshData, i) => {
|
meshesData.forEach((meshData, i) => {
|
||||||
|
const compansate = {
|
||||||
|
x: dimensions.x % 2 === 0 ? dimensions.x / 2 : (dimensions.x - 1) / 2,
|
||||||
|
z: dimensions.z % 2 === 0 ? dimensions.z / 2 : (dimensions.z - 1) / 2,
|
||||||
|
};
|
||||||
|
|
||||||
const translation = meshData.translation;
|
const translation = meshData.translation;
|
||||||
|
|
||||||
const offset = {
|
const offset = {
|
||||||
@@ -58,9 +58,9 @@ const OutlineMesh = ({ meshesData }) => {
|
|||||||
|
|
||||||
dummy.rotation.set(0, meshData.rotation, 0);
|
dummy.rotation.set(0, meshData.rotation, 0);
|
||||||
dummy.position.set(
|
dummy.position.set(
|
||||||
meshData.position.x + offset.x,
|
meshData.position.x + (offset.x * width) / dimensions.x,
|
||||||
Math.abs(meshData.position.y),
|
Math.abs(meshData.position.y),
|
||||||
meshData.position.z + offset.z
|
meshData.position.z + (offset.z * width) / dimensions.z
|
||||||
);
|
);
|
||||||
dummy.updateMatrix();
|
dummy.updateMatrix();
|
||||||
ref.current.setMatrixAt(i, dummy.matrix);
|
ref.current.setMatrixAt(i, dummy.matrix);
|
||||||
@@ -74,6 +74,7 @@ const OutlineMesh = ({ meshesData }) => {
|
|||||||
ref={ref}
|
ref={ref}
|
||||||
position={[0, 0.5, 0]}
|
position={[0, 0.5, 0]}
|
||||||
args={[outlineGeometry, null, meshesData.length]}
|
args={[outlineGeometry, null, meshesData.length]}
|
||||||
|
raycast={() => {}}
|
||||||
>
|
>
|
||||||
<meshBasicMaterial color={"white"} side={BackSide} />
|
<meshBasicMaterial color={"white"} side={BackSide} />
|
||||||
</instancedMesh>
|
</instancedMesh>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export const SliderWithLabel = ({
|
|||||||
max={4}
|
max={4}
|
||||||
step={1}
|
step={1}
|
||||||
min={1}
|
min={1}
|
||||||
onValueChange={(newVal) => setValue(newVal)}
|
onValueChange={([newVal]) => setValue(newVal)}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<Slider.Track className="SliderTrack">
|
<Slider.Track className="SliderTrack">
|
||||||
|
|||||||
Reference in New Issue
Block a user