WebGL

Issue with Terrain Collision using Three.js

瘦欲@ 提交于 2019-12-06 15:01:49
I have created a terrain via a heightmap in Three.js and am using mrdoob's misc_controls_pointerlock for collision and movement. However, when I do objects.push(terrainobj); the performance goes down to about 3fps (from around 60) and there is no collision with the terrain. The collision is achieved via rays. How can I get around this? If it's just a heightmap you could avoid using ray and do the collision checking right in the bitmap (using canvas and imagedata). You just need to convert your XZ world position to the XY pixel in the heightmap. Then, if your Y position in the world is lower

Scroll / Zoom a pixi.js canvas

泪湿孤枕 提交于 2019-12-06 14:38:02
问题 Below is an easy way to put some text on a pixi.js (using WebGL) canvas. How can we scroll / zoom the displayed part of the canvas ? (i.e. mouse down + drag should move ...) Example of what I would like to achieve : http://s419743653.onlinehome.fr/things/test2.htm <!DOCTYPE HTML> <html> <head> <title>pixi.js example 1</title> <script src="pixi.js"></script> </head> <body> <script> var stage = new PIXI.Stage(0xFFFFFF); var renderer = PIXI.autoDetectRenderer(800, 600); document.body.appendChild

glGenerateMipmap - non-power-of-2

一笑奈何 提交于 2019-12-06 14:21:24
Environment Ubuntu 17.04, Chrome 60. Runs this example local without warnings/errors : https://github.com/mdn/webgl-examples/tree/gh-pages/tutorial/sample6 Then replace cubetexture.png with an non-power-of-2 image here : https://github.com/mdn/webgl-examples/blob/gh-pages/tutorial/sample6/webgl-demo.js#L220 Got as expected warnings/errors : [.Offscreen-For-WebGL-0x13d050ba2c00]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering. [.Offscreen-For-WebGL-0x13d050ba2c00]GL ERROR :GL_INVALID_OPERATION : glGenerateMipmap:

WebGL: How to bind values to a mat4 attribute?

大憨熊 提交于 2019-12-06 13:58:21
问题 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,

mat3 attribute in WebGL

拜拜、爱过 提交于 2019-12-06 13:40:58
I'm attempting to use the ANGLE_instanced_arrays extension in WebGL to render multiple instances of an object with different mat3 transformation matrices. This is the code related to the buffer for my matrices: //setup this.shaderProgram.transformAttribute = gl.getAttribLocation(this.shaderProgram, "transform"); ext.vertexAttribDivisorANGLE(this.shaderProgram.transformAttribute, 1); this.transformBuffer = gl.createBuffer(); //each render gl.enableVertexAttribArray(this.shaderProgram.transformAttribute); gl.bindBuffer(gl.ARRAY_BUFFER, this.transformBuffer); gl.bufferData(gl.ARRAY_BUFFER, new

Three.js, custom light geometry

允我心安 提交于 2019-12-06 12:54:30
Is it possible to create in Three.js a light source that has custom geometry, e.g. symbol. There is Arealight in Three.js that works as rectangular source of light and which has wigth and height parameters. Finally, the aim is to get a surface illuminated by a such source, which visually is that custom figure. Thank you WestLangley, this is a great example, I tried this way, but unfortunately, it didn't work for me. I tried this: var textTexture = new THREE.Texture( "textures/text.jpg" ); //var textTexture = THREE.ImageUtils.loadTexture("textures/text.jpg"); textTexture.format = THREE

Why do my three.js examples not load properly?

北慕城南 提交于 2019-12-06 12:29:19
问题 I just downloaded Mr. Doob's three.js project. In the examples folder, anything that doesn't use a model or texture will load up properly. The ones with models or textures show up blank. I don't understand why. I can webgl examples with models and textures to work on the three.js website. Can anybody help, I am stumped... 回答1: You need to run chrome using the --allow-file-access-from-files flag. https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally Also, here's some discussions on

Webgl update region using viewport+scissor

风流意气都作罢 提交于 2019-12-06 11:44:41
I've been trying to create a multiviewport webgl application. I got everything rendering quite nice using viewport+scissor for each view. But now I would like to improve rendering and just render the view which is updated, so skip overdrawing. I've made a little demo showing the idea: http://kile.stravaganza.org/lab/js/scissor/ As I understand scissor it's suposse that it will just render the current scissor box and keep the rest of the canvas untouched. But it seems that it just keeps clearing the whole canvas on each frame, no matter what I tried :( This is the rendering code (The last view

three.js - apply different material to extruded shape

南楼画角 提交于 2019-12-06 11:41:43
问题 I have Three.Shape which I can apply Extrusion To get a plane I drew a square first and then apply extrusion var squareShape = new THREE.Shape(); squareShape.moveTo( 0,0 ); squareShape.lineTo( 0, sqLength ); squareShape.lineTo( sqLength, sqLength ); squareShape.lineTo( sqLength, 0 ); squareShape.lineTo( 0, 0 ); var geometry = new THREE.ExtrudeGeometry( squareShape,extrudeSettings); now a 3D square is appearing on my browser. Next I want to apply a image texture of 256x256 on its top face. How

CSS3DObject is Always in Front of WebGL Mesh

我们两清 提交于 2019-12-06 11:23:53
I am mixing the CSS3D Renderer with WebGL Renderer to add HTML elements in 3D space to a WebGL scene. The CSS3DObject is in front of WebGL Meshes even though the WebGL Renderer has a higher z-index. Here is the jsfiddle http://jsfiddle.net/kd9Tc/ This is what the scene looks like. Note the back view. Whenever the CSS3DObject hits a mesh, I would like the correct depth to be displayed. I believe that this has something to do with the z-buffer or depth . I would prefer to have the text on a transparent background and not a solid color as shown in the example. How can this be done? 来源: https:/