SlideShare a Scribd company logo
L U I S H E N R I Q U E B I Z A R R O & H E N R I Q U E P O Y A T O S
T H R E E . J S
E - M A I L S I T E
hello@lhbzr.com lhbzr.com
T Ó P I C O S
• Sobre Nós
• Conceitos
• Web Graphics Library
• Introdução
• Exemplo
• Three.js
• Introdução
• Exemplo
• Showcase
• Hands-On
S O B R E N Ó S
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
C O N C E I T O S
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
W E B G L
W E B G L
• API de JavaScript utilizada para desenhar gráficos.
const canvas = document.createElement('canvas')
const gl = canvas.getContext('webgl')
• Suportada por todos os navegadores do mercado.
JS Experience 2017 - Animações simples com o three.js
// HTML.
<canvas id="canvas" width="500" height="500"></canvas>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
void main(void) {
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
</script>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
}
</script>
// Canvas.
const webGLStart = () => {
const canvas = document.getElementById('canvas')
initGL(canvas)
initShaders()
initBuffers()
gl.clearColor(0.0, 0.0, 0.0, 1.0)
gl.enable(gl.DEPTH_TEST)
drawScene()
}
webGLStart()
// Context.
let gl
const initGL = (canvas) => {
try {
gl = canvas.getContext('experimental-webgl')
gl.viewportWidth = canvas.width
gl.viewportHeight = canvas.height
} catch (e) {}
if (!gl) {
alert('Could not initialise WebGL, sorry :-(')
}
}
if (shaderScript.type == 'x-shader/x-fragment') {
shader = gl.createShader(gl.FRAGMENT_SHADER)
} else if (shaderScript.type == 'x-shader/x-vertex') {
shader = gl.createShader(gl.VERTEX_SHADER)
} else {
return null
}
gl.shaderSource(shader, str)
gl.compileShader(shader)
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
alert(gl.getShaderInfoLog(shader))
return null
}
return shader
// Shaders.
const getShader = (gl, id) => {
const shaderScript = document.getElementById(id)
if (!shaderScript) {
return null
}
let str = ''
let k = shaderScript.firstChild
while (k) {
if (k.nodeType == 3) {
str += k.textContent
}
k = k.nextSibling
}
let shader
}
let mvMatrix = mat4.create()
let pMatrix = mat4.create()
let shaderProgram
const initShaders = () => {
let fragmentShader = getShader(gl, 'shader-fs')
let vertexShader = getShader(gl, 'shader-vs')
shaderProgram = gl.createProgram()
gl.attachShader(shaderProgram, vertexShader)
gl.attachShader(shaderProgram, fragmentShader)
gl.linkProgram(shaderProgram)
if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
alert('Could not initialise shaders')
}
gl.useProgram(shaderProgram)
shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, 'aVertexPosition')
gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute)
shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, 'uPMatrix')
shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, 'uMVMatrix')
}
triangleVertexPositionBuffer = gl.createBuffer()
gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer)
let triangleVertices = [
0.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, -1.0, 0.0
]
gl.bufferData(
gl.ARRAY_BUFFER,
new Float32Array(triangleVertices),
gl.STATIC_DRAW
)
triangleVertexPositionBuffer.itemSize = 3
triangleVertexPositionBuffer.numItems = 3
// Buffers.
let triangleVertexPositionBuffer
let squareVertexPositionBuffer
const initBuffers = () => {
squareVertexPositionBuffer = gl.createBuffer()
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer)
let squareVertices = [
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
1.0, -1.0, 0.0,
-1.0, -1.0, 0.0
]
gl.bufferData(
gl.ARRAY_BUFFER,
new Float32Array(squareVertices),
gl.STATIC_DRAW
)
squareVertexPositionBuffer.itemSize = 3
squareVertexPositionBuffer.numItems = 4
}
// Draw.
let mvMatrix = mat4.create()
let pMatrix = mat4.create()
const drawScene = () => {
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight)
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
mat4.perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0, pMatrix)
mat4.identity(mvMatrix)
mat4.translate(mvMatrix, [-1.5, 0.0, -7.0])
gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer)
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, triangleVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0)
gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix)
gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix)
gl.drawArrays(gl.TRIANGLES, 0, triangleVertexPositionBuffer.numItems)
mat4.translate(mvMatrix, [3.0, 0.0, 0.0])
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer)
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0)
gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix)
gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix)
gl.drawArrays(gl.TRIANGLE_STRIP, 0, squareVertexPositionBuffer.numItems)
}
T H R E E . J S
• Biblioteca em JavaScript criada por Ricardo Cabello.
• Código Aberto, Documentação Detalhada, Comunidade Ativa e Exemplos.
• Cenas, Câmeras, Geometrias, Luzes, Materiais,
Texturas, Carregadores, Utilitários e muitas mais.
• Renderização em WebGL, Canvas, SVG, CSS 3D e DOM.
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
// Setup.
let WIDTH = window.innerWidth
let HEIGHT = window.innerHeight
const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(75, WIDTH / HEIGHT, 0.1, 1000)
camera.position.z = 5
const renderer = new THREE.WebGLRenderer()
renderer.setSize(WIDTH, HEIGHT)
document.body.appendChild(renderer.domElement)
// Mesh.
const geometry = new THREE.BoxGeometry(1, 1, 1)
const material = new THREE.MeshNormalMaterial()
const mesh = new THREE.Mesh(geometry, material)
scene.add(mesh)
// Render.
const render = () => {
requestAnimationFrame(render)
mesh.rotation.x += 0.01
mesh.rotation.y += 0.02
renderer.render(scene, camera)
}
render()
S H O W C A S E
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
H A N D S - O N

More Related Content

PPTX
лукьянченко л.а. пос 10а
PPTX
Introduction to three.js
PDF
Code Tops Comments
PDF
UIWebViewでつくるUI
PDF
Creating Applications with WebGL and Three.js
PDF
WebGL and three.js
PDF
Devcast node.js e mongo db o casamento perfeito
PDF
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
лукьянченко л.а. пос 10а
Introduction to three.js
Code Tops Comments
UIWebViewでつくるUI
Creating Applications with WebGL and Three.js
WebGL and three.js
Devcast node.js e mongo db o casamento perfeito
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014

What's hot (18)

PPTX
WebGL and three.js - Web 3D Graphics
PDF
A Novice's Guide to WebGL
KEY
Expressを使ってみた
PDF
HTML5 game dev with three.js - HexGL
KEY
Using Sass - Building on CSS
PPTX
Utility libraries to make your life easier
PPTX
Paperjs presentation
PDF
I Can't Believe It's Not Flash
PPTX
The jsdom
KEY
Node workShop Basic
PDF
用户行为系统Marmot - D2 2011 session
PDF
Integrating Angular js & three.js
PPTX
Developing Web Graphics with WebGL
PDF
刘平川:【用户行为分析】Marmot实践
TXT
PPTX
The State of JavaScript
ODP
Threejs使ってみた
WebGL and three.js - Web 3D Graphics
A Novice's Guide to WebGL
Expressを使ってみた
HTML5 game dev with three.js - HexGL
Using Sass - Building on CSS
Utility libraries to make your life easier
Paperjs presentation
I Can't Believe It's Not Flash
The jsdom
Node workShop Basic
用户行为系统Marmot - D2 2011 session
Integrating Angular js & three.js
Developing Web Graphics with WebGL
刘平川:【用户行为分析】Marmot实践
The State of JavaScript
Threejs使ってみた
Ad

Similar to JS Experience 2017 - Animações simples com o three.js (20)

PDF
WebGL - 3D in your Browser
PDF
Making Games in WebGL - Aro Wierzbowski & Tomasz Szepczyński
PDF
Intro to OpenGL ES 2.0
PDF
Learning WebGLで学ぶWebGL入門
PPTX
[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...
PDF
"Graphical fun With WebGL shaders", Martin Splitt
PDF
Modify code to change cube into pyramid.Javascriptuse strict.pdf
PDF
WebGL 2.0 Reference Guide
KEY
Leaving Flatland: getting started with WebGL
PDF
The fallowing program shows the simple transformation #define GLEW.pdf
PPTX
GFX Part 6 - Introduction to Vertex and Fragment Shaders in OpenGL ES
PDF
Webgl para JavaScripters
PPTX
Introduction to open gl in android droidcon - slides
PDF
Introduction to Webgl by Rachel Prudden
KEY
Getting Started with WebGL
PDF
OpenGL 4.4 - Scene Rendering Techniques
PDF
PhiloGL - WebGLCamp Google HQs - June 2011
PDF
1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf
DOCX
Manual
PDF
OpenGLES Android Graphics
WebGL - 3D in your Browser
Making Games in WebGL - Aro Wierzbowski & Tomasz Szepczyński
Intro to OpenGL ES 2.0
Learning WebGLで学ぶWebGL入門
[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...
"Graphical fun With WebGL shaders", Martin Splitt
Modify code to change cube into pyramid.Javascriptuse strict.pdf
WebGL 2.0 Reference Guide
Leaving Flatland: getting started with WebGL
The fallowing program shows the simple transformation #define GLEW.pdf
GFX Part 6 - Introduction to Vertex and Fragment Shaders in OpenGL ES
Webgl para JavaScripters
Introduction to open gl in android droidcon - slides
Introduction to Webgl by Rachel Prudden
Getting Started with WebGL
OpenGL 4.4 - Scene Rendering Techniques
PhiloGL - WebGLCamp Google HQs - June 2011
1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf
Manual
OpenGLES Android Graphics
Ad

More from iMasters (20)

PPTX
O que você precisa saber para modelar bancos de dados NoSQL - Dani Monteiro
PDF
Postgres: wanted, beloved or dreaded? - Fabio Telles
PPTX
Por que minha query esta lenta? - Suellen Moraes
PPTX
Relato das trincheiras: o dia a dia de uma consultoria de banco de dados - Ig...
PDF
ORMs heróis ou vilões dentro da arquitetura de dados? - Otávio gonçalves
PPTX
SQL e NoSQL trabalhando juntos: uma comparação para obter o melhor de ambos -...
PDF
Arquitetando seus dados na prática para a LGPD - Alessandra Martins
PDF
O papel do DBA no mundo de ciência de dados e machine learning - Mauro Pichil...
PDF
Desenvolvimento Mobile Híbrido, Nativo ou Web: Quando usá-los - Juliana Chahoud
PDF
Use MDD e faça as máquinas trabalharem para você - Andreza Leite
PDF
Entendendo os porquês do seu servidor - Talita Bernardes
PDF
Backend performático além do "coloca mais máquina lá" - Diana Arnos
PPTX
Dicas para uma maior performance em APIs REST - Renato Groffe
PPTX
7 dicas de desempenho que equivalem por 21 - Danielle Monteiro
PDF
Quem se importa com acessibilidade Web? - Mauricio Maujor
PDF
Service Mesh com Istio e Kubernetes - Wellington Figueira da Silva
PDF
Erros: Como eles vivem, se alimentam e se reproduzem? - Augusto Pascutti
PDF
Elasticidade e engenharia de banco de dados para alta performance - Rubens G...
PDF
Construindo aplicações mais confiantes - Carolina Karklis
PDF
Monitoramento de Aplicações - Felipe Regalgo
O que você precisa saber para modelar bancos de dados NoSQL - Dani Monteiro
Postgres: wanted, beloved or dreaded? - Fabio Telles
Por que minha query esta lenta? - Suellen Moraes
Relato das trincheiras: o dia a dia de uma consultoria de banco de dados - Ig...
ORMs heróis ou vilões dentro da arquitetura de dados? - Otávio gonçalves
SQL e NoSQL trabalhando juntos: uma comparação para obter o melhor de ambos -...
Arquitetando seus dados na prática para a LGPD - Alessandra Martins
O papel do DBA no mundo de ciência de dados e machine learning - Mauro Pichil...
Desenvolvimento Mobile Híbrido, Nativo ou Web: Quando usá-los - Juliana Chahoud
Use MDD e faça as máquinas trabalharem para você - Andreza Leite
Entendendo os porquês do seu servidor - Talita Bernardes
Backend performático além do "coloca mais máquina lá" - Diana Arnos
Dicas para uma maior performance em APIs REST - Renato Groffe
7 dicas de desempenho que equivalem por 21 - Danielle Monteiro
Quem se importa com acessibilidade Web? - Mauricio Maujor
Service Mesh com Istio e Kubernetes - Wellington Figueira da Silva
Erros: Como eles vivem, se alimentam e se reproduzem? - Augusto Pascutti
Elasticidade e engenharia de banco de dados para alta performance - Rubens G...
Construindo aplicações mais confiantes - Carolina Karklis
Monitoramento de Aplicações - Felipe Regalgo

Recently uploaded (20)

PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PDF
Sims 4 Historia para lo sims 4 para jugar
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PPT
tcp ip networks nd ip layering assotred slides
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
The Internet -By the Numbers, Sri Lanka Edition
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
innovation process that make everything different.pptx
PDF
Introduction to the IoT system, how the IoT system works
PPTX
Internet___Basics___Styled_ presentation
PPTX
presentation_pfe-universite-molay-seltan.pptx
Slides PDF The World Game (s) Eco Economic Epochs.pdf
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
Sims 4 Historia para lo sims 4 para jugar
Power Point - Lesson 3_2.pptx grad school presentation
tcp ip networks nd ip layering assotred slides
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
522797556-Unit-2-Temperature-measurement-1-1.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
SASE Traffic Flow - ZTNA Connector-1.pdf
The New Creative Director: How AI Tools for Social Media Content Creation Are...
The Internet -By the Numbers, Sri Lanka Edition
Design_with_Watersergyerge45hrbgre4top (1).ppt
Decoding a Decade: 10 Years of Applied CTI Discipline
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
Introuction about WHO-FIC in ICD-10.pptx
Tenda Login Guide: Access Your Router in 5 Easy Steps
innovation process that make everything different.pptx
Introduction to the IoT system, how the IoT system works
Internet___Basics___Styled_ presentation
presentation_pfe-universite-molay-seltan.pptx

JS Experience 2017 - Animações simples com o three.js

  • 1. L U I S H E N R I Q U E B I Z A R R O & H E N R I Q U E P O Y A T O S T H R E E . J S E - M A I L S I T E hello@lhbzr.com lhbzr.com
  • 2. T Ó P I C O S • Sobre Nós • Conceitos • Web Graphics Library • Introdução • Exemplo • Three.js • Introdução • Exemplo • Showcase • Hands-On
  • 3. S O B R E N Ó S
  • 6. C O N C E I T O S
  • 11. W E B G L
  • 12. W E B G L • API de JavaScript utilizada para desenhar gráficos. const canvas = document.createElement('canvas') const gl = canvas.getContext('webgl') • Suportada por todos os navegadores do mercado.
  • 14. // HTML. <canvas id="canvas" width="500" height="500"></canvas> <script id="shader-fs" type="x-shader/x-fragment"> precision mediump float; void main(void) { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); } </script> <script id="shader-vs" type="x-shader/x-vertex"> attribute vec3 aVertexPosition; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; void main(void) { gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); } </script>
  • 15. // Canvas. const webGLStart = () => { const canvas = document.getElementById('canvas') initGL(canvas) initShaders() initBuffers() gl.clearColor(0.0, 0.0, 0.0, 1.0) gl.enable(gl.DEPTH_TEST) drawScene() } webGLStart()
  • 16. // Context. let gl const initGL = (canvas) => { try { gl = canvas.getContext('experimental-webgl') gl.viewportWidth = canvas.width gl.viewportHeight = canvas.height } catch (e) {} if (!gl) { alert('Could not initialise WebGL, sorry :-(') } }
  • 17. if (shaderScript.type == 'x-shader/x-fragment') { shader = gl.createShader(gl.FRAGMENT_SHADER) } else if (shaderScript.type == 'x-shader/x-vertex') { shader = gl.createShader(gl.VERTEX_SHADER) } else { return null } gl.shaderSource(shader, str) gl.compileShader(shader) if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { alert(gl.getShaderInfoLog(shader)) return null } return shader // Shaders. const getShader = (gl, id) => { const shaderScript = document.getElementById(id) if (!shaderScript) { return null } let str = '' let k = shaderScript.firstChild while (k) { if (k.nodeType == 3) { str += k.textContent } k = k.nextSibling } let shader }
  • 18. let mvMatrix = mat4.create() let pMatrix = mat4.create() let shaderProgram const initShaders = () => { let fragmentShader = getShader(gl, 'shader-fs') let vertexShader = getShader(gl, 'shader-vs') shaderProgram = gl.createProgram() gl.attachShader(shaderProgram, vertexShader) gl.attachShader(shaderProgram, fragmentShader) gl.linkProgram(shaderProgram) if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { alert('Could not initialise shaders') } gl.useProgram(shaderProgram) shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, 'aVertexPosition') gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute) shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, 'uPMatrix') shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, 'uMVMatrix') }
  • 19. triangleVertexPositionBuffer = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer) let triangleVertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ] gl.bufferData( gl.ARRAY_BUFFER, new Float32Array(triangleVertices), gl.STATIC_DRAW ) triangleVertexPositionBuffer.itemSize = 3 triangleVertexPositionBuffer.numItems = 3 // Buffers. let triangleVertexPositionBuffer let squareVertexPositionBuffer const initBuffers = () => { squareVertexPositionBuffer = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer) let squareVertices = [ 1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -1.0, -1.0, 0.0 ] gl.bufferData( gl.ARRAY_BUFFER, new Float32Array(squareVertices), gl.STATIC_DRAW ) squareVertexPositionBuffer.itemSize = 3 squareVertexPositionBuffer.numItems = 4 }
  • 20. // Draw. let mvMatrix = mat4.create() let pMatrix = mat4.create() const drawScene = () => { gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight) gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) mat4.perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0, pMatrix) mat4.identity(mvMatrix) mat4.translate(mvMatrix, [-1.5, 0.0, -7.0]) gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer) gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, triangleVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0) gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix) gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix) gl.drawArrays(gl.TRIANGLES, 0, triangleVertexPositionBuffer.numItems) mat4.translate(mvMatrix, [3.0, 0.0, 0.0]) gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer) gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0) gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix) gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix) gl.drawArrays(gl.TRIANGLE_STRIP, 0, squareVertexPositionBuffer.numItems) }
  • 21. T H R E E . J S • Biblioteca em JavaScript criada por Ricardo Cabello. • Código Aberto, Documentação Detalhada, Comunidade Ativa e Exemplos. • Cenas, Câmeras, Geometrias, Luzes, Materiais, Texturas, Carregadores, Utilitários e muitas mais. • Renderização em WebGL, Canvas, SVG, CSS 3D e DOM.
  • 24. // Setup. let WIDTH = window.innerWidth let HEIGHT = window.innerHeight const scene = new THREE.Scene() const camera = new THREE.PerspectiveCamera(75, WIDTH / HEIGHT, 0.1, 1000) camera.position.z = 5 const renderer = new THREE.WebGLRenderer() renderer.setSize(WIDTH, HEIGHT) document.body.appendChild(renderer.domElement)
  • 25. // Mesh. const geometry = new THREE.BoxGeometry(1, 1, 1) const material = new THREE.MeshNormalMaterial() const mesh = new THREE.Mesh(geometry, material) scene.add(mesh)
  • 26. // Render. const render = () => { requestAnimationFrame(render) mesh.rotation.x += 0.01 mesh.rotation.y += 0.02 renderer.render(scene, camera) } render()
  • 27. S H O W C A S E
  • 33. H A N D S - O N