is possible a 3d viewport like sketchfab for C3?

Post » Mon Mar 20, 2017 6:17 pm

i would just love just to render an object and rotate it for educational content
Image

Image
B
37
S
14
G
7
Posts: 406
Reputation: 8,309

Post » Tue Mar 21, 2017 2:29 am

Here's demonstration of a way to run some webgl and display the result on a sprite (not minifier friendly):
https://www.dropbox.com/s/iq4xmleoeqkb1 ... .capx?dl=0

It may be useful as a base to do what's asked for in the op.
B
87
S
29
G
89
Posts: 5,103
Reputation: 60,192

Post » Tue Mar 21, 2017 3:00 am

R0J0hound wrote:Here's demonstration of a way to run some webgl and display the result on a sprite (not minifier friendly):
https://www.dropbox.com/s/iq4xmleoeqkb1 ... .capx?dl=0

It may be useful as a base to do what's asked for in the op.


thats really amazing, i managed to do some changes but just to rotate the object with some keys on the keyboard,

how do you tell what model to load? i dont see any event that explain to load that cube.
Image

Image
B
37
S
14
G
7
Posts: 406
Reputation: 8,309

Post » Tue Mar 21, 2017 3:09 am

The specific code that creates the cube is in the mycode.js file in the project files folder.
Code: Select all
var arrays = {
      position: [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],
      normal:   [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 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, 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, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1],
      texcoord: [1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 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],
    };

A parser for something like the obj file format would be more manageable.
B
87
S
29
G
89
Posts: 5,103
Reputation: 60,192

Post » Tue Mar 21, 2017 3:12 am

hmmm is there a way to import normal 3d objects? since doing it that way is really really hard.

but its pretty close to what i am looking for, its really amazing tbh
Image

Image
B
37
S
14
G
7
Posts: 406
Reputation: 8,309

Post » Tue Mar 21, 2017 3:19 am

Yeah, that's what I mean by an obj file parser. The idea would be to include an .obj file in the project and have it read all the vertices and faces from that. Anyways, that may be a while before I do something like that. I'm mostly done for the day.
B
87
S
29
G
89
Posts: 5,103
Reputation: 60,192

Post » Tue Mar 21, 2017 3:20 am

hmmm kk but yeah its really amazing to know that stuff like this works on C2,

btw is that threejs???
Image

Image
B
37
S
14
G
7
Posts: 406
Reputation: 8,309

Post » Tue Mar 21, 2017 4:02 am

It's another simple library to help make webgl less verbose. Threejs or babylon3d are kind of bulky since we won't use most of it. For minimum size just webgl could be used.
B
87
S
29
G
89
Posts: 5,103
Reputation: 60,192

Post » Tue Mar 21, 2017 7:07 am

Here's an updated capx with obj file loading.
https://www.dropbox.com/s/dbehcd1aestt0 ... .capx?dl=0

The obj files need to have triangulated faces, and uvs and normals in them as well. The texture files also should be flipped vertically.

Edit:
Another slight update: it can update the textures of tiledbg and particles as well as sprites now.
B
87
S
29
G
89
Posts: 5,103
Reputation: 60,192

Post » Tue Mar 21, 2017 8:17 am

R0J0hound wrote:Here's an updated capx with obj file loading.
https://www.dropbox.com/s/dbehcd1aestt0 ... .capx?dl=0

The obj files need to have triangulated faces, and uvs and normals in them as well. The texture files also should be flipped vertically.

Edit:
Another slight update: it can update the textures of tiledbg and particles as well as sprites now.



Mindblowing
B
96
S
33
G
29
Posts: 3,137
Reputation: 28,130

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: sizcoz and 1 guest