WebGL

Threejs: Rotate sphere(globe) to another point(city) on the sphere itself

时光毁灭记忆、已成空白 提交于 2020-01-05 08:52:06
问题 I'm building a globe(sphere geometry) with set of predefined locations on geo-mapped and drawn as point(sphere geometry). I would like to focus(moving one location to another) those locations by rotating globe along y-axis. I tried the following code, seems not working for all locations. location.geometry.computeBoundingBox(); var position = new THREE.Vector3(); position.subVectors( location.geometry.boundingBox.max, location.geometry.boundingBox.min ); position.multiplyScalar( 0.20 );

Fastest method to load a large number of objects in Three.js?

拥有回忆 提交于 2020-01-05 08:12:43
问题 I'm currently exploring methods of optimising the time taken to load / generate a large number of objects in Three.js. The input for these objects are individual vertex points that make up a 2D footprint. The initial method I used is to create THREE.Shape objects from the individual vertex points and then use THREE.ExtrudeGeometry to pull the 2D shape into a 3D object. Doing this for all objects takes around 3500ms. A second method I've explored is to pre-export the generated 3D objects (from

How to work with framebuffers in webgl?

99封情书 提交于 2020-01-05 07:20:52
问题 I have been trying to understand framebuffer in WebGL/OpenGL-ES. I know that we can blend multiple textures using framebuffer. So, to understand that I wrote a sample by taking a 1*1 texture and tried to apply framebuffer logic on top of it. But , it didn't work. See snippet at bottom, if you click on "mix red and blue", the images doesn't get rendered, am I doing anything wrong? Code : ` var canvas, gl, attrPosition, texture, program, vertexBuffer, textureBuffer, vertices, texVertices,

My domain return error for texture load image url

好久不见. 提交于 2020-01-05 05:06:49
问题 image does not load by my domain Other domain no problem. it is working it just doesn't load my domain var textureLoader = new THREE.TextureLoader(); textureLoader.crossOrigin = ''; var map = textureLoader.load('https://MY-DOMAIN.com/upload/01.png'); Error : GET https://MY-DOMAIN.com/upload/01.png net::ERR_FAILED Note : I'm working on localhost. I taking pictures from remote server 回答1: From the response header your server sends I can see that it doesn't return a Access-Control-Allow-Origin

webgl glsl emulate texture3d

▼魔方 西西 提交于 2020-01-05 02:33:09
问题 I'm porting a piece of opengl to webgl and i'm trying to emulate texture3d. Somehow something is going wrong. No interpolation is needed because it is only used for calculations. I'm not sure about the geometry part of the original code, the per layer properties are now fetched trough a texture. Update : Ok i rewrote the texture 3d functions, I still encounter some problems : const vec3 volumeTextureSize = vec3( 256.0, 128.0, 32.0 ); const vec2 imageSize = vec2( 1024.0, 1024.0 ); vec2

Chroma key Fragment Shader fails to find the color

↘锁芯ラ 提交于 2020-01-04 11:42:55
问题 I'm trying to write a fragment-shader that functions as a chroma-key filter for a specific color (for example make all pixels with a specific green transparent). The shader I'm writing is for use in WebGL trough PIXI.js. JSFiddle: https://jsfiddle.net/IbeVanmeenen/hexec6eg/14/ So far, I wrote this code for the shader, based on the shader I've found here. varying vec2 vTextureCoord; uniform float thresholdSensitivity; uniform float smoothing; uniform vec3 colorToReplace; uniform sampler2D

Chroma key Fragment Shader fails to find the color

ぃ、小莉子 提交于 2020-01-04 11:42:26
问题 I'm trying to write a fragment-shader that functions as a chroma-key filter for a specific color (for example make all pixels with a specific green transparent). The shader I'm writing is for use in WebGL trough PIXI.js. JSFiddle: https://jsfiddle.net/IbeVanmeenen/hexec6eg/14/ So far, I wrote this code for the shader, based on the shader I've found here. varying vec2 vTextureCoord; uniform float thresholdSensitivity; uniform float smoothing; uniform vec3 colorToReplace; uniform sampler2D

What are the capabilities of canvas vs openGL?

[亡魂溺海] 提交于 2020-01-04 07:53:09
问题 I know that openGL works wonders if you send textures to it that are static and rarely change for example like tiles. But not when you have constantly changing sprites? Is it possible to create games like abduction purely from canvas and what would be its performance? 回答1: It is possible to create games like abduction using canvas, however eventually you are going to hit a stumbling block in terms of performance. OpenGL whether moving or static will handle images exponentially faster, by

Why does WebGL canvas turn white on the second frame when alpha is masked?

南楼画角 提交于 2020-01-04 04:31:08
问题 Please see this thread for details. To summarize, given the following circumstances: gl = canvas.getContext('experimental-webgl'); gl.clearColor(0, 0, 0, 1); gl.colorMask(1, 1, 1, 0); gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); gl.enable(gl.BLEND); ...and a standard render loop: function doRender() { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); // render stuff, and request another frame requestAnimationFrame(doRender); } ...then I would like to know what the expected output

WebGL on Cordova with Three.js

隐身守侯 提交于 2020-01-04 04:11:05
问题 I'm attempting to build a mobile app with Three.js on Cordova, This runs fine on the PC in the browser, but on the device it doesn't seem to be able to create the WebGL context on a Samsung Note 3 This is the error: THREE.WebGLRenderer 77 THREE.WebGLRenderer: Error creating WebGL context. three.min.js:633 THREE.WebGLRenderer three.min.js:633 Uncaught TypeError: Cannot call method 'getExtension' of null I'm using CrossWalk but it doesn't seem to make any difference 回答1: Yes I'm running 4.4.2