WebGL

WebGL Fillstyle

a 夏天 提交于 2020-02-25 04:07:11
问题 I currently have a canvas to which I am rendering a ThreeJS scene. Everything is working fine, however, I would like to display a transparent fill over it. With a normal canvas, I would simply do canvas = document.getElementById('canvas'); context = canvas.getContext('2d'); This, of course, doesn't work because I'm using WebGL and the context is different. But I try to apply fillStyle to renderer.context Nothing happens. I checked via console and the property does appear in the context as so

WebGL Fillstyle

孤街浪徒 提交于 2020-02-25 04:07:05
问题 I currently have a canvas to which I am rendering a ThreeJS scene. Everything is working fine, however, I would like to display a transparent fill over it. With a normal canvas, I would simply do canvas = document.getElementById('canvas'); context = canvas.getContext('2d'); This, of course, doesn't work because I'm using WebGL and the context is different. But I try to apply fillStyle to renderer.context Nothing happens. I checked via console and the property does appear in the context as so

Pack depth information in a RGBA texture using mediump precison

陌路散爱 提交于 2020-02-24 21:53:16
问题 Trying to understand the many issues related to the WebGL development for a generic mobile target, now I need to store depth information in a texture attachment for later retrieval and post-processing. JavaScript: var depthRB = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, depthRB); gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, w, h); gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthRB); gl.bindRenderbuffer(gl.RENDERBUFFER,

Pack depth information in a RGBA texture using mediump precison

做~自己de王妃 提交于 2020-02-24 21:51:33
问题 Trying to understand the many issues related to the WebGL development for a generic mobile target, now I need to store depth information in a texture attachment for later retrieval and post-processing. JavaScript: var depthRB = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, depthRB); gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, w, h); gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthRB); gl.bindRenderbuffer(gl.RENDERBUFFER,

Pack depth information in a RGBA texture using mediump precison

ぐ巨炮叔叔 提交于 2020-02-24 21:50:21
问题 Trying to understand the many issues related to the WebGL development for a generic mobile target, now I need to store depth information in a texture attachment for later retrieval and post-processing. JavaScript: var depthRB = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, depthRB); gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, w, h); gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthRB); gl.bindRenderbuffer(gl.RENDERBUFFER,

webGL学习随笔

风流意气都作罢 提交于 2020-02-21 23:55:10
这是对threejs初步的一个理解 EleVR elevr是基于webGL的原生API来实现的一个全景播放平台 首先 elevr 是根据绘制适口来进行双屏 VR 渲染的 if (eye === 0) { // left eye webGL. gl .viewport(0, 0, canvas . width / 2, canvas . height ); } else { // right eye webGL. gl .viewport( canvas . width / 2, 0, canvas . width / 2, canvas . height ); } 因为本身对 webGL 的 API 不熟悉,所以改写是存在很大难度的 通过层层样式的修改,通过用 localstorage 本地存储的方式写入一个变量值,每次点击去修改其存储的值,然后根据存入值的一个状态来决定走哪个绘制 vierport ,最后 reload 页面,基本实现单双屏切换的状态, 但是用户体验肯定不是很乐观,稍后会对 webGL 进入深层次的一个学习,暂时用此方法替代单双屏切换的一个状态 具体实现代码 var btn = document .getElementById("btn");// 获取点击按钮的 dom 元素 btn.onclick = function(){// 注册一个点击事件 if (

WebGL浏览器支持总结

放肆的年华 提交于 2020-02-16 11:21:46
若系统为Win10系统,建议使用Edge浏览器,没有任何问题。若系统为Win7系统,支持FireFox(火狐)、Chrome(谷歌)浏览器,但需做一下调整: 1.FireFox浏览器 打开浏览器,在地址栏中输入about:config(请注意冒号使用英文输入),会出现FireFox的配置信息,在Search中输入webgl,即会出现webGL相关的配置信息: ​ 1).将webgl.force-enabled设置为true(双击即可修改值) 2).将webgl.disabled设置为false 3).搜索security.fileuri.strict.origin_policy设置为false(允许从本地载入资源) 4).关闭所有所有窗口,重启FireFox即可。 2. Chrome浏览器 1).Chrome相对麻烦些,首先打开浏览器,在地址栏输入about:flags,同样搜索webGL,将过滤出来的两项值均改为Enabled。 2).在桌面右键Chrome浏览器图标进入到属性界面,查看其所在位置 3).在桌面新建一个txt文本,将其值复制到文本中,并在结尾空一格再输入--allow-file-access-from-files 请注意--allow前一定要输入空格 4).保存文本,并将后缀名 .txt修改为 .bat 5).将此作为浏览器的入口,双击进入即可

How to get object in WebGL 3d space from a mouse click coordinate

断了今生、忘了曾经 提交于 2020-02-09 01:10:56
问题 I'm building a boardgame in WebGL. The board can be rotated/zoomed. I need a way to translate a click on the canvas element (x,y) into the relevant point in 3D space (x, y, z). The ultimate result is that I want to know the (x, y, z) coordinate that contains the point that touches the object closest to the user. For instance, the user clicks a piece, and you imagine a ray traveling through 3D space that goes through both the piece and the game board, but I want the (x, y, z) coord of the

WebGL: fade drawing buffer

让人想犯罪 __ 提交于 2020-02-08 03:11:13
问题 I've set preserveDrawingBuffer to true . Doing this results in everything drawn on the buffer to be seen all at once, however, I was wondering if there is a way to somehow fade the buffer as time goes on so that the old elements drawn disappear over time, and the newest drawn elements appear with a relatively high opacity until they also fade away. Is there a better way to achieve such an effect? I've tried to render previous elements again by lowering their opacity until it reaches 0 but it

ray intersect not working in sphere

旧街凉风 提交于 2020-02-06 03:57:40
问题 created the sphere and the plane geometry when i ignore the sphere form scene.add() interesect work but here is the code.. http://jsfiddle.net/praveenv29/PZeY4/ for ( var i = 0; i<10; i ++ ) { var gloom = new THREE.ImageUtils.loadTexture('../map_pin.png' ); materialr = new THREE.MeshLambertMaterial( { color:Math.random() * 0xffffff ,side: THREE.DoubleSide} ) var geometry = new THREE.PlaneGeometry(10,15,2, 2); var object = new THREE.Mesh(geometry, materialr); object.position.x = Math.random()