<commit_before># title: texture
# mode: webgl
# ---

# Simple texture mapping on a cube.

# Position the model.
var model = mat4.create();
mat4.scale(model, model, vec3(10.0, 10.0, 10.0));
mat4.rotateY(model, model, 1.0);

# Load buffers and parameters for the model.
var mesh = load_obj("cube.obj");
var position = mesh_positions(mesh);
var normal = mesh_normals(mesh);
var indices = mesh_indices(mesh);
var size = mesh_size(mesh);
var texcoord = mesh_texcoords(mesh);

# Load a texture from an image.
var tex = load_texture("default.png");

render js<
  vertex glsl<
    gl_Position = projection * view * model * vec4(position, 1.0);
    fragment glsl<
      gl_FragColor = texture2D(tex, vec2(0.0, 0.0));
    >
  >;
  draw_mesh(indices, size);
><commit_msg>Actually use texture coordinate in cube example<commit_after># title: texture
# mode: webgl
# ---

# Simple texture mapping on a cube.

# Position the model.
var model = mat4.create();
mat4.scale(model, model, vec3(10.0, 10.0, 10.0));
mat4.rotateY(model, model, 1.0);

# Load buffers and parameters for the model.
var mesh = load_obj("cube.obj");
var position = mesh_positions(mesh);
var normal = mesh_normals(mesh);
var indices = mesh_indices(mesh);
var size = mesh_size(mesh);
var texcoord = mesh_texcoords(mesh);

# Load a texture from an image.
var tex = load_texture("default.png");

render js<
  vertex glsl<
    gl_Position = projection * view * model * vec4(position, 1.0);
    fragment glsl<
      gl_FragColor = texture2D(tex, texcoord);
    >
  >;
  draw_mesh(indices, size);
>
{'fraction_non_alphanumeric': 0.13630490956072353, 'fraction_numerical': 0.027777777777777776, 'mean_word_length': 4.197986577181208, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7456003', 'n_tokens_mistral': 557, 'n_tokens_neox': 533, 'n_words': 159}