Comments (10)
Hi @alexeyfaradise, thank you for submitting this issue.
setTexture()
appears to not work: Unfortunately this part of our API is still a little rough; it works but is very easy to get wrong. We're working on a sample to illustrate how to modify material parameters (including textures) at runtime and will improve our error reporting in the next release.- Thousands of models w/ multiple permutations how?: The plan here has two parts:
- The binaries used by the Android Studio plugin will be made available for use in build scripts on server platforms. This will allow you to do a server-side conversion of your assets to
.sfb
. We'll be releasing a blog post soon on how to do this. - The
.sfa
will get the ability to contain loose textures and materials not explicitly associated with geometry, and.sfa
's will be able to declare data dependencies on other.sfa
's. This will mean that you can author (and deliver).sfb
's that contain textures/materials (but no geometry) and.sfb
's that contain geometry (but no textures/materials), and if they're both available at instantiation time it will just work.
- The binaries used by the Android Studio plugin will be made available for use in build scripts on server platforms. This will allow you to do a server-side conversion of your assets to
from sceneform-android-sdk.
@Berenice2018
Excellent, thank you.
from sceneform-android-sdk.
@alexeyfaradise what solution did you used for this problem?
from sceneform-android-sdk.
Hey @alexeyfaradise, can you please post the contents of the .sfa file for the model you are testing with?
You can change the texture of the sample "andy" model at runtime using the following code in HelloSceneformActivity.java:
CompletableFuture<Texture> brickFuture = Texture.builder().setSource(this, R.drawable.bricks).build();
// When you build a Renderable, Sceneform loads its resources in the background while returning
// a CompletableFuture. Call thenAccept(), handle(), or check isDone() before calling get().
ModelRenderable.builder()
.setSource(this, R.raw.andy)
.build()
.thenAcceptBoth(brickFuture, (renderable, texture) -> {
andyRenderable = renderable;
andyRenderable.getMaterial().setTexture("baseColor", texture);
})
.exceptionally(
throwable -> {
Toast toast =
Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return null;
});
If your source assets are more complicated, the names of the material parameters could be different. However, those names should match what is in the .sfa file.
from sceneform-android-sdk.
Hello @dsternfeld7 ,
I would like to change textures on a simple box.obj at runtime. But, I cannot get it working. My cube is red as specified in the sfa file, but the texture is not applied at runtime. Could you give me a hint, please? This would be nice.
I tried the following code:
Sceneform SDK 1.3.0
CompletableFuture<Texture> futureTexture = Texture.builder()
.setSource(this, R.drawable.ic_launcher)
.build();
ModelRenderable.builder()
.setSource(this, R.raw.box)
.build()
.thenAcceptBoth(futureTexture, (renderable, texture) -> {
boxRenderable = renderable;
boxRenderable.getMaterial().setTexture("baseColor", texture);
})
.exceptionally(
throwable -> {
Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG).show();
return null;
});
The box.sfa file looks like:
{
materials: [
{
name: "unlit_material",
parameters: [
{
baseColor: "box",
},
{
baseColorTint: [
1,
0,
0,
1,
],
},
{
metallic: 1,
},
{
roughness: 1,
},
{
opacity: null,
},
],
source: "build/sceneform_sdk/default_materials/obj_material.sfm",
},
],
model: {
attributes: [
"Position",
"TexCoord",
"Orientation",
],
file: "sampledata/box.obj",
name: "box",
suggested_collision: {
center: {
x: 0,
y: 0,
z: 0,
},
size: {
x: 1,
y: 1,
z: 1,
},
type: "Box",
},
},
version: "0.51:1",
}
from sceneform-android-sdk.
@dsternfeld7
Should your code above also work with a ModelRenderable created with the ShapeFactory?
from sceneform-android-sdk.
@michaelvogt I tried a texture change on a primitive cube instantiated with ShapeFactory. It is working.
Check the last line of my code snippet here
#197
(Sorry for pasting the link. I am new to GitHub and have not yet found the button to reference a different thread here.)
from sceneform-android-sdk.
@Berenice2018 @AdrianAtGoogle can you please take a look at #448. It seems similar, but I can't understand how the ones discussed here can be applied to there. I'm just beginning to use Sceneform.
Thanks in advance.
from sceneform-android-sdk.
This feature works ?
from sceneform-android-sdk.
To me it looks like setTexture() btw. setMaterial() only work on the renderables created via ShapeFactory
from sceneform-android-sdk.
Related Issues (20)
- Null object
- How to find angle of model from localRotation?
- two modelRenderable overlapping will flicker HOT 1
- [SceneForm v1.16.0 breakage] Not AndroidX ready
- [SceneForm v1.16.0 breakage] no maven dep
- [SceneForm v1.16.0 breakage] ViewRenderables not working HOT 1
- available configuration for avoiding too much heat on device
- GLTF's UV scale functionality not implemented in 1.16.0?
- Object is moving along when i move the phone ?! HOT 5
- ArSceneView have some black dot
- Sceneform plugin:1.15.0 with Android Studio 3.6 not working at all HOT 5
- [SceneForm v1.16.0 breakage] chromakey video
- Cannot load GLB file at Runtime using canonical face
- Is there a way to generate .sfb files from .fbx in runtime HOT 2
- Work with Canonical Face Mesh in Blender
- SceneForm Uses 100% RAM HOT 3
- Update Filament to v1.6.0 (filament-android:1.6.0 & gltfio-android:1.6.0) HOT 1
- How To Show Normal Texture in UV1?
- How can I import model asset the obj file?
- ArFragment leaking after parent activity finished
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sceneform-android-sdk.