11---
22id : images
3- title : Images
4- sidebar_label : Images
3+ title : Images & Textures
4+ sidebar_label : Images & Textures
55slug : /guides/images
66---
77
8- import useBaseUrl from ' @docusaurus/useBaseUrl'
8+ import useBaseUrl from " @docusaurus/useBaseUrl" ;
99
1010<div class = " image-container" >
1111 <svg xmlns = " http://www.w3.org/2000/svg" width = " 283" height = " 535" >
12- <image href = { useBaseUrl (" img/demo-backgroundimage.jpg" )} x = " 18" y = " 33" width = " 247" height = " 469" />
12+ <image
13+ href = { useBaseUrl (" img/demo-backgroundimage.jpg" )}
14+ x = " 18"
15+ y = " 33"
16+ width = " 247"
17+ height = " 469"
18+ />
1319 <image href = { useBaseUrl (" img/frame.png" )} width = " 283" height = " 535" />
1420 </svg >
1521</div >
@@ -25,20 +31,24 @@ You can only have one background image per scene. The background image is a 2D i
2531always fill the whole view.
2632
2733``` tsx
28- import { BackgroundImage , Camera , DefaultLight } from ' react-native-filament'
29- import BackgroundImageMaterial from ' ./assets/background_image.filamat'
34+ import { BackgroundImage , Camera , DefaultLight } from " react-native-filament" ;
35+ import BackgroundImageMaterial from " ./assets/background_image.filamat" ;
3036
31- const imageResource = require (' ./assets/background.jpg' )
37+ const imageResource = require (" ./assets/background.jpg" );
3238
3339function Renderer() {
3440 return (
3541 <FilamentView style = { styles .container } >
3642 <Camera />
3743 <DefaultLight />
3844
39- <BackgroundImage source = { imageResource } materialSource = { BackgroundImageMaterial } resizeMode = " cover" />
45+ <BackgroundImage
46+ source = { imageResource }
47+ materialSource = { BackgroundImageMaterial }
48+ resizeMode = " cover"
49+ />
4050 </FilamentView >
41- )
51+ );
4252}
4353```
4454
@@ -68,7 +78,13 @@ Compiled materials are `.filamat` files, where the definition files are human-re
6878
6979<div class = " image-container" >
7080 <svg xmlns = " http://www.w3.org/2000/svg" width = " 283" height = " 535" >
71- <image href = { useBaseUrl (" img/demo-change-textures.gif" )} x = " 18" y = " 33" width = " 247" height = " 469" />
81+ <image
82+ href = { useBaseUrl (" img/demo-change-textures.gif" )}
83+ x = " 18"
84+ y = " 33"
85+ width = " 247"
86+ height = " 469"
87+ />
7288 <image href = { useBaseUrl (" img/frame.png" )} width = " 283" height = " 535" />
7389 </svg >
7490</div >
@@ -85,17 +101,17 @@ For applying images as textures to 3D shapes need to have:
85101
86102For example, let's say we have [ this 3D model of a rocket] ( https://www.cgtrader.com/free-3d-models/space/spaceship/toy-rocket-4k ) . When we open it in blender we see:
87103
88- <img src = { useBaseUrl (' img/blender-explanation-materials.png' )} />
104+ <img src = { useBaseUrl (" img/blender-explanation-materials.png" )} />
89105
90106- In the top right corner you see the entities: ` Engine ` , ` Tip ` , ` Wings ` , etc.
91107- You can see that an entity is associated with a material.
92108- You can see the materials name is "Toy Ship", and you can see it uses a texture.
93109
94- | The base texture looks like this: | Variant of the base color texture : |
95- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
110+ | The base texture looks like this: | Variant of the base color texture : |
111+ | ------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
96112| <img src = { useBaseUrl (' img/example-Toy_Rocket_Toy Ship_BaseColor.jpg' )} /> | <img src = { useBaseUrl (' img/example-Toy_Rocket_Toy Ship_BaseColorBlue.jpg' )} /> |
97113
98- Now we can apply the new texture to the model:
114+ Now we can apply the new texture to the model:
99115
100116``` tsx
101117import RocketGlb from ' ~/assets/rocket.glb'
0 commit comments