basic texture mapping on a cube

18 views
Skip to first unread message

Muqing

unread,
Jan 10, 2012, 12:30:43 PM1/10/12
to SceneJS, mgo...@vt.edu
Hi All,

I am trying to do texturing map on a cube. I have read the sceneJS
wiki about texture mapping. http://scenejs.wikispaces.com/texture
However, right now I have a black cube with no texture mapping. The
following is my code.

{
"type": "geometry",
"coreId": "1g11z8oXL0HfHgCCmSivZT",
"primitive": "triangles",
"positions": [

1, 1, 1, -1, 1, 1,-1,-1, 1, 1,-1, 1,
1, 1, 1, 1,-1, 1, 1,-1,-1,1, 1,-1,
1, 1, 1, 1, 1,-1, -1, 1,-1, -1, 1, 1,
-1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1,
-1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1,
1,-1,-1, -1,-1,-1,-1, 1,-1, 1, 1,-1
],
"normals": [
0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1,
-1, 0, 0,-1, 0, 0, -1, 0, 0, -1, 0, 0,
0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1
],
"uv" : [
1, 1, 0, 1, 0, 0, 1, 0,
0, 1, 0, 0, 1, 0, 1, 1,
1, 0, 1, 1, 0, 1, 0, 0,
1, 1, 0, 1, 0, 0, 1, 0,
0, 0, 1, 0, 1, 1, 0, 1,
0, 0, 1, 0, 1, 1, 0, 1
],
"indices": [
0, 1, 2,
0, 2, 3,
4, 5, 6,
4, 6, 7,
8, 9, 10,
8, 10,11,
12,13,14,
12,14,15,
16,17,18,
16,18,19,
20,21,22,
20,22,23
],
"nodes": [
{
"type": "texture",
"layers": [
{
"uri": "http://d2el4marpcphqf.cloudfront.net/37725.jpg"
}
]
}
]
}


Would someone please help me? Thanks a lot!!

Muqing

Matt

unread,
Jan 10, 2012, 3:00:04 PM1/10/12
to SceneJS
You need to nest the geometry inside the texture, not the other way
around.

{
"type": "texture",
// ...

nodes: [
{
"type": "geometry"
// ...
}
]
}

On 10 Jan, 12:30, Muqing <moochin....@gmail.com> wrote:
> Hi All,
>
> I am trying to do texturing map on a cube. I have read the sceneJS
> wiki about texture mapping.http://scenejs.wikispaces.com/texture

Muqing

unread,
Jan 10, 2012, 4:58:30 PM1/10/12
to SceneJS
Thank you very much, Matt!

I changed the code to the following, as you suggested. but it still
does not give me any texture...Any other suggestion? thanks in
advance!

{
"type": "texture",
"layers": [
{
"uri": "http://d2el4marpcphqf.cloudfront.net/37725.jpg"
}
],
"nodes":[
]
}
Reply all
Reply to author
Forward
0 new messages