Skip to content

Commit 342d0f4

Browse files
authored
Merge pull request #2968 from TanviKumar/test-io
Change loadModel() example
2 parents c6d66c1 + 5e00665 commit 342d0f4

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
v 0.000000E+00 0.000000E+00 40.0000
2+
v 22.5000 22.5000 0.000000E+00
3+
v 22.5000 -22.5000 0.000000E+00
4+
v -22.5000 -22.5000 0.000000E+00
5+
v -22.5000 22.5000 0.000000E+00
6+
v 0.000000E+00 0.000000E+00 -40.0000
7+
8+
f 1 2 3
9+
f 1 3 4
10+
f 1 4 5
11+
f 1 5 2
12+
f 6 5 4
13+
f 6 4 3
14+
f 6 3 2
15+
f 6 2 1
16+
f 6 1 5

src/webgl/loading.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,38 @@ require('./p5.Geometry');
3535
* @example
3636
* <div>
3737
* <code>
38+
* //draw a spinning octahedron
39+
* var octahedron;
40+
*
41+
* function preload() {
42+
* octahedron = loadModel('assets/octahedron.obj');
43+
* }
44+
*
45+
* function setup() {
46+
* createCanvas(100, 100, WEBGL);
47+
* }
48+
*
49+
* function draw() {
50+
* background(200);
51+
* rotateX(frameCount * 0.01);
52+
* rotateY(frameCount * 0.01);
53+
* model(octahedron);
54+
* }
55+
* </code>
56+
* </div>
57+
*
58+
* @alt
59+
* Vertically rotating 3-d octahedron.
60+
*
61+
* @example
62+
* <div>
63+
* <code>
3864
* //draw a spinning teapot
3965
* var teapot;
4066
*
4167
* function preload() {
42-
* teapot = loadModel('assets/teapot.obj');
68+
* // Load model with normalise parameter set to true
69+
* teapot = loadModel('assets/teapot.obj', true);
4370
* }
4471
*
4572
* function setup() {
@@ -48,8 +75,10 @@ require('./p5.Geometry');
4875
*
4976
* function draw() {
5077
* background(200);
78+
* scale(0.4); // Scaled to make model fit into canvas
5179
* rotateX(frameCount * 0.01);
5280
* rotateY(frameCount * 0.01);
81+
* normalMaterial(); // For effect
5382
* model(teapot);
5483
* }
5584
* </code>

0 commit comments

Comments
 (0)