-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: example 3, textured & indexed plane.
- Loading branch information
Showing
21 changed files
with
132 additions
and
39 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Threeify - Getting Started - 3 Texture</title> | ||
<script type="module" src="/dist/examples/gettingstarted/3_texturedPlane/index.js"></script> | ||
</head> | ||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
precision highp float; | ||
|
||
uniform sampler2D map; | ||
|
||
varying vec2 v_texCoord; | ||
|
||
void main() { | ||
|
||
gl_FragColor = texture2D(map, v_texCoord); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { plane } from "../../../lib/geometry/primitives/Plane"; | ||
import { fetchImage } from "../../../lib/io/loaders/Image"; | ||
import { ShaderMaterial } from "../../../lib/materials/ShaderMaterial"; | ||
import { Program, RenderingContext, TexImage2D } from "../../../lib/renderers/webgl2"; | ||
import { BufferGeometry } from "../../../lib/renderers/webgl2/buffers/BufferGeometry"; | ||
import { Texture } from "../../../lib/textures"; | ||
import fragmentSourceCode from "./fragment.glsl"; | ||
import vertexSourceCode from "./vertex.glsl"; | ||
|
||
async function init(): Promise<null> { | ||
const geometry = plane(1, 1, 1, 1); | ||
const material = new ShaderMaterial(vertexSourceCode, fragmentSourceCode); | ||
const texture = new Texture(await fetchImage("/assets/textures/uv_grid_opengl.jpg")); | ||
|
||
const context = new RenderingContext(); | ||
const canvasFramebuffer = context.canvasFramebuffer; | ||
document.body.appendChild(canvasFramebuffer.canvas); | ||
|
||
const bufferGeometry = new BufferGeometry(context, geometry); | ||
const program = new Program(context, material); | ||
const texImage2D = new TexImage2D(context, texture); | ||
const uniforms = { map: texImage2D }; | ||
|
||
canvasFramebuffer.renderBufferGeometry(program, uniforms, bufferGeometry); | ||
|
||
return null; | ||
} | ||
init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
attribute vec3 position; | ||
attribute vec2 uv; | ||
|
||
varying vec2 v_texCoord; | ||
|
||
void main() { | ||
|
||
v_texCoord = uv; | ||
gl_Position = vec4( position.y, position.x, 0.5, 1.0 ); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters