WebGL

Enable new GL rendering in Google Maps API v3?

房东的猫 提交于 2019-12-05 02:28:58
Just recently Google made available Maps GL on the GMaps platform. We have an HTML5 app that's heavily maps based, and we'd love to try out the new map rendering that's based on WebGL. Already we're noticing the potential performance benefits. Does anyone know how to switch API v3 to Maps GL rendering or other ways to implement it? WebGL maps hasn't been added to the API yet so you cannot enable it. I've opened up a feature request for this in the issues tracker: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4131&thanks=4131&ts=1336609133 来源: https://stackoverflow.com/questions

Getting started with marching cubes in three.js

安稳与你 提交于 2019-12-05 02:28:01
问题 I am new to Three.js and looking for a tutorial to get me started on how to use Marching Cubes in three.js. Some of the projects I have seen so far in three.js which use this are a bit complicated for me, so a simple tutorial would be nice. Thank you. 回答1: I looked at three.js and their marching cubes demo. It seems to have been built specifically for rendering meatballs :-) I started fresh and copied over the lookup tables and rewrote the main functions and linear interprolation methods and

THREE.js repeat wrapping texture in shader

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 02:20:42
问题 I want to repeat wrapping texture in THREE.js shader. The original texture image is: I want it to repeat 4x4 times which will looks like: But with the following code, it turns out to be: Vertex shader: varying vec2 vUv; uniform float textRepeat; void main() { // passing texture to fragment shader vUv = uv * textRepeat; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } Fragment shader: varying vec2 vUv; uniform sampler2D texture; void main() { // add origianl texture gl

How to optimize rendering of many sphereGeometry in three.js?

こ雲淡風輕ζ 提交于 2019-12-05 00:18:06
问题 I'd like to optimize the rendering of sphereGeometry in three.js, since it becomes bottleneck in my program. The javascript program is shown as follows: var sphereThree = []; for(var idSphere = 0; idSphere < numSphere; idSphere++){ var sphereGeometry = new THREE.SphereGeometry(1.0); var sphereMaterial = new THREE.MeshLambertMaterial({color: 'rgb(255, 0, 0)'}); sphereThree[idSphere] = new THREE.Mesh(sphereGeometry, sphereMaterial); sphereThree[idSphere].position.x = x[idSphere]; sphereThree

WebGL and HTML shader-type

一笑奈何 提交于 2019-12-04 23:06:11
I declare my GLSL ES shader program within a HTML file, using this code: <script id="shader-fs" type="x-shader/x-fragment">..shader-code..</script> as seen in the learning WebGL examples. Everything works fine, but I dont understand why I should use the type attribute of the script tag. I want to know where the "x-shader/x-fragment" value is specified. Who does that.. the W3C, the Khronos Group or the browser developers? Can anybody help me? Tahnk you. There is no official organization who specified that GLSL code should be put within a <script> tag of type "x-shader/x-fragment" . The only

How to map texture image onto a part of a sphere, or how to cut out (intersect) a rectangle of a sphere's surface?

狂风中的少年 提交于 2019-12-04 21:46:59
I am working with WebGL using three.js and I have an image that I want to project onto the (inner) surface of a sphere. The problem I am facing is how to limit the extent of that mapping to a horizontal and vertical field of view. Imagine projecting an image from the centre of a sphere onto a rectangular section of it. I suspect I can do this one of 2 ways, but am unsure about how to do either... 1) Map the texture onto the sphere based on the field of view angles. Mapping the image straight onto the sphere as below does a 360x180 degree wrap. Is there a UV mapping trick involved, or some

Render text on canvas using WebGL

倾然丶 夕夏残阳落幕 提交于 2019-12-04 21:29:08
问题 I want to render some text on a canvas using WebGL, which API of WebGL should be used? Note: "text" can be either plain text or HTML snippet with CSS style 回答1: Most demos that I've seen that do text of any sort (like a FPS counter) simply create an HTML element with the text they want and position it over the canvas. This would probably be a good approach for most text that you would want to show "in" a canvas (ie: menus). The only exception would be if you want the text to be an actual part

How to change one texture image of a 3d model(maya ) in three.js at runtime

£可爱£侵袭症+ 提交于 2019-12-04 21:06:46
This site is loading a maya model using three.js. This model has Below texture pictures Here is the JS var SCREEN_WIDTH = window.innerWidth; var SCREEN_HEIGHT = window.innerHeight; var container; var camera, scene; var canvasRenderer, webglRenderer; var mesh, zmesh, geometry, materials; var windowHalfX = window.innerWidth / 2; var windowHalfY = window.innerHeight / 2; var meshes = []; function init() { container = document.createElement('div'); document.body.appendChild(container); camera = new THREE.PerspectiveCamera(75, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 100000); camera.position.x = 400;

WebGL: How to bind values to a mat4 attribute?

一世执手 提交于 2019-12-04 20:26:56
In some WebGL application, let's assume that we have a GLSL vertex shader which starts like this: attribute vec4 foo1; attribute vec4 foo2; attribute vec4 foo3; attribute vec4 foo4; and some corresponding Javascript code for binding a data structure for those attributes: var buf = gl.createBuffer(), loc; gl.bindBuffer(gl.ARRAY_BUFFER, buf); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([…])); loc = gl.getAttribLocation(program, 'foo1'); gl.enableVertexArray(loc); gl.vertexAttribPointer(loc, 4, gl.FLOAT, false, 16, 0); loc = gl.getAttribLocation(program, 'foo2'); gl.enableVertexArray(loc); gl

Three.js WebGL Draw a circle custom fill and border color from shader

▼魔方 西西 提交于 2019-12-04 19:53:58
I'm using Three.js with the WebGLRenderer. I'm trying to figure out or see an example for how to draw circles using CircleGeometry and be able to control their fill and border color from a vertex or fragment shader. Is this even possible without using an image for the texture? Sorry if this is really simple, I'm still trying to wrap my head around Three.js and WebGL so any help is appreciated. Geometry presentation of the circle is imprefect because roundness depends on the number of vertices that make up that circle and it's quite difficult to change parameters. Texture presentation has