WebGL

Getting 'PERFORMANCE WARNING' messages in Chrome

南楼画角 提交于 2019-12-24 04:10:09
问题 I just recently starting getting these messages, and was wondering if anyone has seen them, or know what may be causing them. I'm using Three.js with Chrome version '21.0.1180.57' on MacOS. I don't get these messages with Safari or FireFox. PERFORMANCE WARNING: Attribute 0 is disabled. This has signficant performance penalty WebGL: too many errors, no more errors will be reported to the console for this context. 回答1: Same message on Firefox is : "Error: WebGL: Drawing without vertex attrib 0

Error when creating textures in WebGL with the RGB format

不打扰是莪最后的温柔 提交于 2019-12-24 04:05:53
问题 Trying to create a 1px x 4px texture from data with the RGBA format like so works: const texture = gl.createTexture() gl.activeTexture(gl.TEXTURE0) gl.bindTexture(gl.TEXTURE_2D, texture) gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([ 255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 255, 255, 0, 255 ])) gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) However

How to clear a rectangle area in WebGL?

こ雲淡風輕ζ 提交于 2019-12-24 03:05:07
问题 WebGL has a clear method that clears an entire surface. What's the best way to clear just a particular rectangle of the surface? For example I want to set a 100x100 box of pixels starting at (50, 50) to all zeroes (ARGB 0, 0, 0, 0). All I can think of right now is drawing a quad with a fragment shader that writes zeroes. Is there not an easier way? 回答1: You can use the SCISSOR test to constrain clearing (and rendering in general) to a rectangle. // turn on the scissor test. gl.enable(gl

WebGL blit texture to canvas

╄→尐↘猪︶ㄣ 提交于 2019-12-24 01:33:10
问题 What is the cleanest way of blitting a texture to the HTML canvas in WebGL. I could see setting up an orthographic projection and rendering a textured quad, but is there a cleaner way? 回答1: What to mean "blitting a texture to the HTML5 Canvas"? Do you mean just drawing a texture 1x1 pixel to the canvas? No need for a orthographic projection. The simplest thing is either make a unit quad and scale or make a quad in pixel coords and draw. Here's the pixel coord quad shader attribute vec2 a

WebGL / Three.js Different materials on one complex object (grid)

☆樱花仙子☆ 提交于 2019-12-24 01:25:30
问题 In order to increase performance i render grid to one THREE.Geometry() object in such loop: build : function(){ // simplified square = new THREE.Geometry(); face = 0; for( r = 0; r < this["rows"]; r++) for( c = 0; c < this["cols"]; c++) // creates square square.vertices.push(new THREE.Vector3( x, y, z)); square.vertices.push(new THREE.Vector3( x + w, y, z)); square.vertices.push(new THREE.Vector3( x + w, y - h, z)); square.vertices.push(new THREE.Vector3( x, y - h, z)); square.faces.push(new

Depth Map three.js

若如初见. 提交于 2019-12-23 23:17:43
问题 Is there any way to obtain a depth map in three.js? I am interested in producing something similar to what a Kinect would produce for a given scene. I have come across a hacky way of using no colors and fog to mimic this but it would not be ideal because it would use two different scenes and would be variant to lighting. Another way to do this I believe would be to access the depth buffer but it appears this cannot be accessed through three.js. 回答1: Yep. Try using MeshDepthMaterial . 来源:

three.js Raycaster intersectObjects

帅比萌擦擦* 提交于 2019-12-23 21:26:43
问题 I'm trying to modify this example from three.js to control the character(s) with mouse clicks. First, when I click on the canvas, I need the mouse coordinates and convert that into 3D space coordinates using THREE.Raycaster.intersectObjects. In the modified code, on left mouse up, I have the following: var vector = new THREE.Vector3((event.clientX / window.innerWidth) * 2 - 1, -(event.clientY / window.innerHeight) * 2 + 1, 0.5); var projector = new THREE.Projector(); projector.unprojectVector

WebGl packing a float into v4

心已入冬 提交于 2019-12-23 20:50:30
问题 I have this code sample from threejs example [http://threejs.org/examples/#webgl_animation_cloth] where a float value is converted to vec4. I have seen this logic on few other forums but no explanation. Could someone explain what this logic is doing and the use of 256 ?.I understand the bitwise masking and shifting . I have seen this link too Packing float into vec4 - how does this code work? It says the vec4 will be stored in a 32 bit RGBA8 buffer finally. Since we are passing the depth

What are VertexIndices in webgl?

回眸只為那壹抹淺笑 提交于 2019-12-23 19:15:39
问题 I'm learning WebGL from this site: http://learningwebgl.com/blog/?p=370 I don't understand, what are VertexIndices, and why the pyramid dont have them? 回答1: When defining the geometry for your 3D object, there's two basic elements that you are working with: Vertices and Triangles. A vertex is just a position in space defined by XYZ coords, (and usually some additional information, like texture coordinates) and a triangle is just three vertices. Defining vertices is pretty straightforward. You

基于 HTML5 WebGL 构建智能数字化城市 3D 全景

左心房为你撑大大i 提交于 2019-12-23 16:49:27
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 前言 自 2011 年我国城镇化率首次突破 50% 以来,《新型城镇化发展规划》将智慧城市列为我国城市发展的三大目标之一,并提出到 2020 年,建成一批特色鲜明的智慧城市。截至现今,全国 95% 的副省级以上城市、76% 的地级以上城市,总计约 500 多个城市提出或在建智慧城市。 基于这样的背景,本系统采用 Hightopo 的 HT for Web 产品来构造轻量化的 智慧城市 3D 可视化场景,通过三个角度的转换,更清晰让我们感知到 5G 时代下数字化智能城市的魅力 预览地址: HT 智慧城市 整体预览图 第一个视角下,城市以市中心为圆心缓缓浮现,市中心就如同整座城的大脑 第二个视角下,在楼房间穿过,细致的感受这城市的面貌 第三个视角下,鸟瞰整座城,体会智慧城市带来的不可思议的欣喜 是不是觉得有些神奇,我们接下来就是对项目的具体分析,手把手教你如何搭建一个自己心中的梦想城市 场景搭建 该系统中的大部分模型都是通过 3dMax 建模生成的,该建模工具可以导出 obj 与 mtl 文件,在 HT 中可以通过解析 obj 与 mtl 文件来生成 3D 场景中的所有复杂模型,(当然如果是某些简单的模型可以直接使用 HT 来绘制,这样会比 obj 模型更轻量化,所以大部分简单的模型都是采用 HT for Web