Open GoogleCodeExporter opened 9 years ago
This could be done as following:
var newTex = new JSC3D.Texture('blackandwhite');
newTex.onready = function() {
mesh.setTexture(this);
viewer.update();
};
newTex.createFromUrl('duckie/blackandwhite.png');
The createFromUrl() method is described here:
http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Texture.html#crea
teFromUrl.
Original comment by Humu2...@gmail.com
on 17 Dec 2013 at 3:32
Thanks for support!
Original comment by papa...@gmail.com
on 17 Dec 2013 at 9:05
Just another similiar question about changing textures:
What if I want to loop through all the meshes and apply different textures on
them?
The following is my trial code:
for (var mesh_index in currentScene.children)
{
var mesh = currentScene.children[mesh_index];
var myTexture = new JSC3D.Texture();
myTexture.onready = function()
{
// set texture to the model
console.log(mesh);
mesh.setTexture(this);
// notify viewer to deliver a new frame
viewer.update();
console.log("done");
}
myTexture.createFromUrl(myURL, false);
}
However, console.log(mesh) in the onready() call back shows that the "mesh"
variable is always pointing to the last mesh element undercurrentScene.children
so only the texture of last mesh element is being changed. What is the correct
approach to change all of them with possibility of they are using different
textures?
Original comment by passerby...@gmail.com
on 18 Dec 2013 at 3:47
I'm afraid you had a wrong practice of function closure. Try this instead:
var textures = [];
var textureOwners = {};
var meshes = viewer.getScene().getChildren();
for (var i=0; i<meshes.length; i++) {
var newTex = new JSC3D.Texture;
textures.push(newTex);
textureOwners[i] = meshes[i];
newTex.onready = function() {
textureOwners[textures.indexOf(this)].setTexture(this);
viewer.update();
};
newTex.createFromUrl(myURL, false);
}
The new one will work much better :-)
Original comment by Humu2...@gmail.com
on 18 Dec 2013 at 7:25
Can i add texture on specific x and y coordinates ?
Original comment by papa...@gmail.com
on 8 Jan 2014 at 2:00
When I add a texture to my 3D-model my used image gets very tiny and they are
all shaped like triangles. I've used "hasMipmap()" to see if there's a mipmap,
but it returns false. How can I set an image as texture that uses it's true
scale. Thanks.
Original comment by michaelt...@gmail.com
on 9 Jan 2014 at 10:43
I guess there must be something wrong with the texture coords of your model.
Try to check and adjust them using a modeling tool such as Blender or meshlab.
Original comment by Humu2...@gmail.com
on 11 Jan 2014 at 4:01
Original issue reported on code.google.com by
papa...@gmail.com
on 16 Dec 2013 at 9:11