Skip to content

Commit 63cb29a

Browse files
committed
try out: .glb files and override imported materails
1 parent bd47355 commit 63cb29a

File tree

14 files changed

+82
-677
lines changed

14 files changed

+82
-677
lines changed

public/public3d/India/India.glb

417 KB
Binary file not shown.
-179 KB
Binary file not shown.

public/public3d/India1/India_outline.gltf

Lines changed: 0 additions & 233 deletions
This file was deleted.

src/app/components/3d/3dComponents/LanguagesNearYou/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22
/* @jsxFrag React.Fragment */
33
import { jsx } from '@emotion/react';
44
import Scene3D from './scene3d';
5-
5+
import { RequestContext } from '#contexts/RequestContext';
6+
import config3d from '#app/components/3d/config3d.json';
7+
import { use } from 'react';
68
import styles from './index.styles';
79

810
const LanguagesNearYou = () => {
11+
12+
const { service } = use(RequestContext)
13+
const isEnabled = config3d.LanguagesNearYou.enabled.includes(service)
14+
15+
if (!isEnabled) {
16+
return null;
17+
}
18+
919
return (
1020
<div>
1121
<h2>Languages Near You</h2>

src/app/components/3d/3dComponents/LanguagesNearYou/scene3d.jsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
import { jsx } from '@emotion/react';
44
import { Suspense, useEffect } from 'react';
55
import { Canvas, useThree } from '@react-three/fiber';
6-
7-
import styles from './index.styles';
6+
import { OrbitControls, GizmoHelper, GizmoViewport } from '@react-three/drei';
87

98
// importing objects
10-
import India from '../../3dObjects/external/India1/india1';
11-
9+
import { India } from '#app/components/3d/3dObjects/external/India/India';
1210
import BillboardParticleSystem from '../../3dObjects/primitive/BillboardParticleSystem/BillboardParticleSystem';
1311

12+
import styles from './index.styles';
1413
/* eslint-disable react/no-unknown-property */
1514

1615
const SetCameraTarget = ({ position, target, fov }) => {
@@ -31,11 +30,17 @@ const Scene3D = () => (
3130
<Canvas>
3231
<Suspense fallback={null}>
3332
<SetCameraTarget position={[-3, 1, 0]} target={[0, 1, 0]} fov={80} />
33+
<GizmoHelper alignment="bottom-right" margin={[80, 80]}>
34+
<GizmoViewport />
35+
</GizmoHelper>
36+
<axesHelper args={[10]} />
37+
<gridHelper args={[20]} />
38+
<OrbitControls />
3439
{/* lights */}
35-
<ambientLight intensity={3} />
40+
<ambientLight intensity={4} />
3641
<directionalLight position={[2, 5, 1]} />
3742
{/* objects */}
38-
<India position={[0, 0, 1]} rotation={[0, Math.PI / 2, 0]} />
43+
<India position={[0, 0, 0]} rotation={[0, 0, 0]} />
3944
{/* particle systems */}
4045
<BillboardParticleSystem
4146
texturePath="/public3d/test-text.png"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/** @jsx jsx */
2+
/* @jsxFrag React.Fragment */
3+
/* eslint-disable react/no-unknown-property */
4+
import { jsx } from '@emotion/react';
5+
6+
import { useGLTF } from '@react-three/drei';
7+
8+
export function India(props) {
9+
const { nodes } = useGLTF('/public3d/India/India.glb');
10+
return (
11+
<group {...props} dispose={null}>
12+
<mesh
13+
name="Hindi_(flat)"
14+
castShadow
15+
receiveShadow
16+
geometry={nodes['Hindi_(flat)'].geometry}
17+
material={nodes['Hindi_(flat)'].material}
18+
>
19+
<meshStandardMaterial color="red" />
20+
</mesh>
21+
<mesh
22+
name="Urdu_(flat)"
23+
castShadow
24+
receiveShadow
25+
geometry={nodes['Urdu_(flat)'].geometry}
26+
material={nodes['Urdu_(flat)'].material}
27+
/>
28+
<mesh
29+
name="Telugu_(flat)"
30+
castShadow
31+
receiveShadow
32+
geometry={nodes['Telugu_(flat)'].geometry}
33+
material={nodes['Telugu_(flat)'].material}
34+
/>
35+
<mesh
36+
name="India_-_remaining_regions_(flat)"
37+
castShadow
38+
receiveShadow
39+
geometry={nodes['India_-_remaining_regions_(flat)'].geometry}
40+
material={nodes['India_-_remaining_regions_(flat)'].material}
41+
/>
42+
<mesh
43+
name="India_(outline)_(flat)"
44+
castShadow
45+
receiveShadow
46+
geometry={nodes['India_(outline)_(flat)'].geometry}
47+
material={nodes['India_(outline)_(flat)'].material}
48+
/>
49+
</group>
50+
);
51+
}
52+
53+
useGLTF.preload('/public3d/India/India.glb');
54+
55+
export default India;

0 commit comments

Comments
 (0)