-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPillars.js
37 lines (26 loc) · 960 Bytes
/
Pillars.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React, { useEffect, useMemo, useRef } from "react";
import { useGLTF } from "@react-three/drei"
import { Mesh } from "three";
import { useFrame } from "@react-three/fiber";
export const Pillar = ({ n }) => {
const group = useRef()
const gltf = useGLTF('/Models/Pillar3/Pillar3.gltf');
const copiedScene = useMemo(() => gltf.scene.clone(), [gltf.scene])
const x = n % 2 == 0 ? -5 : 10
useEffect(() => {
// gltf.scene.scale.set(1,1,1);
// gltf.scene.position.set( 0, 0, n * 3.5);
gltf.scene.traverse((object) => {
if (object instanceof Mesh) {
object.castShadow = true;
object.receiveShadow = true;
object.material.envMapIntensity = 20;
}
})
}, [gltf])
return (
<group ref={group}>
<primitive object={copiedScene} position={[x, 0, n * -15]} scale={[0.5, 0.5, 0.5]} />
</group>
)
}