WebGL

pixi.js + three.js

对着背影说爱祢 提交于 2021-01-05 12:15:36
three.js 最好的webgl 3d渲染库之一, pixi.js  最好的webgl 2d渲染库之一,也许可以把之一去掉 两个库都很精简,如果把两个库结合起来,一定很爽很爽,你说是吧! 跳一跳three.js开发的。 欢乐球球three.js+pixi.js开发的. three.js, pixi.js都是javascript开发的,方便javascript爱好者。 three.js, pixi.js开发微信小游戏的话,适配很简单. 基本上可以这么说,three.js做2dui很麻烦,绝大多数是three.js开发 3d, pixi.js开发2d. 怎么做呢? 假设pixi.js的渲染器为renderer2D three.js的渲染器为renderer3D renderer2D.reset() renderer3D.state.reset(); // 处理3d场景 renderer3D.setRenderTarget(null); renderer3D.render(scene, camera, renderTarget); renderer2D.reset() // 处理2d变化 renderer2D.render(stage); // 核心的逻辑 renderer3D.state.reset(); renderer3D.setRenderTarget(null); //<-

Converting intBitsToFloat in GLSL and floatBitsToInt back in Javascript

痞子三分冷 提交于 2021-01-05 06:45:55
问题 I'm trying to encode an integer identifier in GLSL 3.3 shader to a Float output using intBitsToFloat (I'm using highp output float vector), then I use readPixels to get this value into pixelData = new Float32Array(4) . Then I decode it back to Int in JS using floatToIntBits(pixelData[0]) , where var int8 = new Int8Array(4) var int32 = new Int32Array(int8.buffer, 0, 1) var float32 = new Float32Array(int8.buffer, 0, 1) var floatToIntBits = function (f) { float32[0] = f return int32[0] } And now

Converting intBitsToFloat in GLSL and floatBitsToInt back in Javascript

别说谁变了你拦得住时间么 提交于 2021-01-05 06:44:34
问题 I'm trying to encode an integer identifier in GLSL 3.3 shader to a Float output using intBitsToFloat (I'm using highp output float vector), then I use readPixels to get this value into pixelData = new Float32Array(4) . Then I decode it back to Int in JS using floatToIntBits(pixelData[0]) , where var int8 = new Int8Array(4) var int32 = new Int32Array(int8.buffer, 0, 1) var float32 = new Float32Array(int8.buffer, 0, 1) var floatToIntBits = function (f) { float32[0] = f return int32[0] } And now

Webgl Cross Origin Images don't work

依然范特西╮ 提交于 2021-01-04 09:06:23
问题 I've got some problem with cross-origin image and I hope you can help. Here the beahviour. I've got 2 domains, in example: - domain1.com - domain2.com On domain1 I put many html5 games. This domain is only a repository of games. Domain2 is the real website (wordpress website) where users can play games hosted on domain1. To doing this I made a curl request for every game. In domain1 nginx configuration file I put these lines of code for enabling Cross Origin Resource Sharing: location ~* \.

Detect SwiftShader WebGL renderer in Chrome 18

不想你离开。 提交于 2020-12-29 12:41:00
问题 I have a 2D HTML5 game engine (www.scirra.com) and really want to detect if WebGL is going to render with Chrome 18's 'Swiftshader' software renderer. If so we would much prefer to fall back to the ordinary canvas 2D context, as happens in other browsers. The mass of people out there have low end machines with weak CPUs that turn the game in to a slideshow when software rendering, and I think in many cases the 2D canvas would have been hardware accelerated. However, the WebGL context creation

Detect SwiftShader WebGL renderer in Chrome 18

馋奶兔 提交于 2020-12-29 12:38:56
问题 I have a 2D HTML5 game engine (www.scirra.com) and really want to detect if WebGL is going to render with Chrome 18's 'Swiftshader' software renderer. If so we would much prefer to fall back to the ordinary canvas 2D context, as happens in other browsers. The mass of people out there have low end machines with weak CPUs that turn the game in to a slideshow when software rendering, and I think in many cases the 2D canvas would have been hardware accelerated. However, the WebGL context creation

Clean up Threejs WebGl contexts

冷暖自知 提交于 2020-12-28 13:11:06
问题 I have a problem while cleaning up my WebGl-Scenes. I'm using Three.js with a WebGlRenderer. In my application I have to change the views quite often and therefore need to render new scenes all the time. Uptil now I destroy and reinitialize the entire Threejs scene. After switching the scenes about 15 - 20 times I get following warning: WARNING: Too many active WebGL contexts. Oldest context will be lost. After switching a couple of times more the context is lost completly and the application

Clean up Threejs WebGl contexts

筅森魡賤 提交于 2020-12-28 13:10:52
问题 I have a problem while cleaning up my WebGl-Scenes. I'm using Three.js with a WebGlRenderer. In my application I have to change the views quite often and therefore need to render new scenes all the time. Uptil now I destroy and reinitialize the entire Threejs scene. After switching the scenes about 15 - 20 times I get following warning: WARNING: Too many active WebGL contexts. Oldest context will be lost. After switching a couple of times more the context is lost completly and the application

WebGL VS Canvas 2D hardware acceleration

前提是你 提交于 2020-12-27 17:17:43
问题 These days, I need to draw many images on a canvas. The canvas size is 800x600px, and I have many images of 256x256px(some is smaller) to draw on it, these small images will compose a complete image on the canvas. I have two ways to implement this. First, if I use canvas 2D context, that is context = canvas.getContext('2d') , then I can just use context.drawimage() method to put every image on the proper location of the canvas. Another way, I use WebGL to draw these images on the canvas. On

WebGL VS Canvas 2D hardware acceleration

我的未来我决定 提交于 2020-12-27 17:14:45
问题 These days, I need to draw many images on a canvas. The canvas size is 800x600px, and I have many images of 256x256px(some is smaller) to draw on it, these small images will compose a complete image on the canvas. I have two ways to implement this. First, if I use canvas 2D context, that is context = canvas.getContext('2d') , then I can just use context.drawimage() method to put every image on the proper location of the canvas. Another way, I use WebGL to draw these images on the canvas. On