WebGL

How to set the Object3D position and rotation same as the added mesh ? [three.js]

血红的双手。 提交于 2019-12-25 04:12:24
问题 When I create an Object3D model and add the meshes to it, how do I set the position and rotation of the added mesh to same as the Object3D model, like when I rotate and position the Object3D there should be no difference in angle of rotation between the Object3D and the added mesh. How do I achieve such result? 回答1: If your Object3D model is called obj , then after obj.add(mesh) any changes to obj (position/rotation/scale) will change mesh in the same way. If instead you don't want mesh to be

An error when try to use mipmaping in three.js

人走茶凉 提交于 2019-12-25 03:26:38
问题 I'm trying to use mipmaps generation in three.js textures. When creating a texture I assign an image of size 512x512 to mipmaps[0]. Thus if my understanding is correct this image should be used by WebGL to generate smaller mipmaps textures. But then I see a black texture rendered and errors like this: in chrome WebGL: drawElements: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'. Or the texture is

How to do batching without UBOs?

試著忘記壹切 提交于 2019-12-25 03:22:34
问题 I'm trying to implement batching for a WebGL renderer which is struggling with lots of small objects due to too many draw calls. What I thought is I'd batch them all by the kind of shader they use, then draw a few at a time, uploading material parameters and the model matrix for each object once in uniforms. My problem is that the uniform size limits for non-UBO uniforms are extremely low, as in 256 floats low at a minimum. If my material uses, say, 8 floats, and if you factor in the model

How to do batching without UBOs?

安稳与你 提交于 2019-12-25 03:22:31
问题 I'm trying to implement batching for a WebGL renderer which is struggling with lots of small objects due to too many draw calls. What I thought is I'd batch them all by the kind of shader they use, then draw a few at a time, uploading material parameters and the model matrix for each object once in uniforms. My problem is that the uniform size limits for non-UBO uniforms are extremely low, as in 256 floats low at a minimum. If my material uses, say, 8 floats, and if you factor in the model

GLSL vertex shader gl_Position for gl.POINTS with large gl.PointSize

隐身守侯 提交于 2019-12-25 01:43:52
问题 I'm trying to render a lot of points with large gl_PointSize. Looks vertex shader will automatically discard gl.POINTS rendering if the position is out if[-1, 1]. In my case, if the point's position is a little bit out of [-1, 1], part of it still should be shown on the canvas. Any way to let the shader keep rendering point, when position out of [-1, 1]? Here's the code to draw a point with position a little bit off the canvas. But it is expect to show nearly half of it on canvas. var

Cannot run WebGL content on WebView

旧城冷巷雨未停 提交于 2019-12-25 01:38:47
问题 I am trying to open a webpage with WebGL content from wxPython WebView. The engine used by WebView, webkit , has WebGL support. How can I render the the WebGL content inside WebView? The complete code used by me: import wx import wx.html2 class MyBrowser(wx.Frame): def __init__(self, *args, **kwds): wx.Frame.__init__(self, *args, **kwds) sizer = wx.BoxSizer(wx.VERTICAL) self.browser = wx.html2.WebView.New(self) sizer.Add(self.browser, 1, wx.EXPAND, 10) self.SetSizer(sizer) self.Maximize() if

There are too many active WebGL contexts on this page, the oldest context will be lost. [dedup.min.js]

我怕爱的太早我们不能终老 提交于 2019-12-24 21:25:25
问题 I am getting this wiered error only on Safari browser. Don't know why. I am using AngularJS 1.3.x. So how do I detect which libraries may be using this. And why only in safari I get this error ? Is there a way via JS to enable or disable WebGL ? 回答1: Put this at the top of your HTML? <script> HTMLCanvasElement.prototype.getContext = (function(origFn) { var bannedTypes = { "webgl": true, "webgl2": true, "experimental-webgl":, true, }; return function() { var type = arguments[0]; return

Why don't my shaders work for trapezoids polygons?

时光毁灭记忆、已成空白 提交于 2019-12-24 20:30:27
问题 I need to draw parts of a texture on trapezoids polygons. (old school fake-3D race game, the road is made of these trapezoids and I want to apply a texture on them.) But the texture appears wrong, like if each of the two triangles forming a trapezoid are half of a parrallelogram instead, they have each a different horizontal skewing, not a global perspective transformation. Searching for a solution I see that this problem is common and the reason why is that the two triangles are not equal

WebGL not working for same spec system in chrome. How to fix?

梦想的初衷 提交于 2019-12-24 17:32:51
问题 Using info from chrome://gpu and chrome://version Both on Chrome version: 35.0.1916.153 (Official Build 274914) m Both using an Nvidia 670 GTX My driver: 9.18.13.3523 His driver: 9.18.13.4043 My webGL works perfectly, and my driver is slightly behind his. His webGL doesn't work even though in the settings it says all hardware accelerated, webGL enabled etc. When he goes on page with webGL things they don't work - he can't see them just like you wouldn't see them with old browsers. Why is this

Making a Mesh Plane in WebGL with Triangles

﹥>﹥吖頭↗ 提交于 2019-12-24 15:26:46
问题 I'm trying to create a triangulated plane in WebGL and I have the following code. However, when I render this in the browser, it just gives me a vertical line parallel to the y-axis. var quads = 200; for (var y = 0; y <= quads; ++y) { var v = y / quads * 40; for (var x = 0; x <= quads; ++x) { var u = x / quads * 40; recipient.vertices.push( vec3(u, v, 1)) recipient.normals.push( vec3(0, 0, 1)) } } var rowSize = (quads + 1); for (var y = 0; y < quads; ++y) { var rowOffset0 = (y + 0) * rowSize;