{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/1672","repository_url":"https://api.github.com/repos/mrdoob/three.js","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/1672/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/1672/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/1672/events","html_url":"https://github.com/mrdoob/three.js/issues/1672","id":4027253,"number":1672,"title":"how to use immediateRenderCallback() ?","user":{"login":"VelvetValve","id":1322704,"avatar_url":"https://avatars.githubusercontent.com/u/1322704?v=3","gravatar_id":"","url":"https://api.github.com/users/VelvetValve","html_url":"https://github.com/VelvetValve","followers_url":"https://api.github.com/users/VelvetValve/followers","following_url":"https://api.github.com/users/VelvetValve/following{/other_user}","gists_url":"https://api.github.com/users/VelvetValve/gists{/gist_id}","starred_url":"https://api.github.com/users/VelvetValve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VelvetValve/subscriptions","organizations_url":"https://api.github.com/users/VelvetValve/orgs","repos_url":"https://api.github.com/users/VelvetValve/repos","events_url":"https://api.github.com/users/VelvetValve/events{/privacy}","received_events_url":"https://api.github.com/users/VelvetValve/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mrdoob/three.js/labels/Question","name":"Question","color":"dad9ff"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2012-04-09T09:44:46Z","updated_at":"2016-06-11T23:20:44Z","closed_at":"2012-04-10T00:08:46Z","body":"hey my dear team!\r\n\r\nI would like to write an object-prototype inheriting from Object3D which uses renderBufferImmediate() resp. immediateRenderCallback() similarly to THREE.MarchingCubes. How do I have to build in the immediateRenderCallback and how do I pass position- and normal-coordinates into it correctly? My first attempt was the code below, which I expected to make the renderer draw a triangle (see the coordinates), but it doesn't show anything:\r\n\r\n```javascript\r\nFunction.prototype.inheritsFrom = function( parentClassOrObject ){ \r\n\tif ( parentClassOrObject.constructor == Function ) \r\n\t{ \r\n\t\t//Normal Inheritance \r\n\t\tthis.prototype = new parentClassOrObject;\r\n\t\tthis.prototype.constructor = this;\r\n\t\tthis.prototype.parent = parentClassOrObject.prototype;\r\n\t} \r\n\telse \r\n\t{ \r\n\t\t//Pure Virtual Inheritance \r\n\t\tthis.prototype = parentClassOrObject;\r\n\t\tthis.prototype.constructor = this;\r\n\t\tthis.prototype.parent = parentClassOrObject;\r\n\t} \r\n\treturn this;\r\n}\r\n```\r\n\r\n```javascript\r\nMyObject = function(options) {\r\n\t\r\n\tTHREE.Object3D.call(this);\r\n\r\n\tvar materialDefault = new THREE.MeshLambertMaterial( { color: 0xc9c8c0 } );\r\n\t\r\n\tthis.material = options.material != undefined ? options.material : materialDefault;\r\n\t\r\n\tthis.maxCount = 4096; // TODO: find the fastest size for this buffer\r\n\tthis.count = 1;\r\n\tthis.hasPos = false;\r\n\tthis.hasNormal = false;\r\n\r\n\tthis.positionArray = new Float32Array([\r\n\t\t0, 0, 0,\r\n\t\t100, 0, 0,\r\n\t\t0, 100, 0\r\n\t]);\r\n\tthis.normalArray   = new Float32Array([\r\n\t\t1, 0, 0,\r\n\t\t1, 0, 0,\r\n\t\t1, 0, 0\r\n\t]);\r\n}\r\n```\r\n\r\n```javascript\r\nMyObject.inheritsFrom(THREE.Object3D);\r\n```\r\n\r\n```javascript\r\nMyObject.prototype.immediateRenderCallback = function ( program, _gl, _frustum ) {\r\n\tif ( ! this.__webglVertexBuffer ) this.__webglVertexBuffer = _gl.createBuffer();\r\n\tif ( ! this.__webglNormalBuffer ) this.__webglNormalBuffer = _gl.createBuffer();\r\n\r\n\tif ( true ) {\r\n\r\n\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, this.__webglVertexBuffer );\r\n\t\t_gl.bufferData( _gl.ARRAY_BUFFER, this.positionArray, _gl.DYNAMIC_DRAW );\r\n\t\t_gl.enableVertexAttribArray( program.attributes.position );\r\n\t\t_gl.vertexAttribPointer( program.attributes.position, 3, _gl.FLOAT, false, 0, 0 );\r\n\r\n\t}\r\n\r\n\tif ( true ) {\r\n\r\n\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, this.__webglNormalBuffer );\r\n\t\t_gl.bufferData( _gl.ARRAY_BUFFER, this.normalArray, _gl.DYNAMIC_DRAW );\r\n\t\t_gl.enableVertexAttribArray( program.attributes.normal );\r\n\t\t_gl.vertexAttribPointer( program.attributes.normal, 3, _gl.FLOAT, false, 0, 0 );\r\n\r\n\t}\r\n\r\n\t_gl.drawArrays( _gl.TRIANGLES, 0, this.count );\r\n}\r\n```\r\n\r\nI would be grateful if you told me what I am doing entirely wrong here! Thanks in advance! :)\r\nP.S.: The inheritance works fine in other contexts. So it should not cause any problems here."},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/225399901","html_url":"https://github.com/mrdoob/three.js/issues/1672#issuecomment-225399901","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/1672","id":225399901,"user":{"login":"sohale","id":145215,"avatar_url":"https://avatars.githubusercontent.com/u/145215?v=3","gravatar_id":"","url":"https://api.github.com/users/sohale","html_url":"https://github.com/sohale","followers_url":"https://api.github.com/users/sohale/followers","following_url":"https://api.github.com/users/sohale/following{/other_user}","gists_url":"https://api.github.com/users/sohale/gists{/gist_id}","starred_url":"https://api.github.com/users/sohale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sohale/subscriptions","organizations_url":"https://api.github.com/users/sohale/orgs","repos_url":"https://api.github.com/users/sohale/repos","events_url":"https://api.github.com/users/sohale/events{/privacy}","received_events_url":"https://api.github.com/users/sohale/received_events","type":"User","site_admin":false},"created_at":"2016-06-11T23:20:44Z","updated_at":"2016-06-11T23:20:44Z","body":"@VelvetValve  Do you have the full code somewhere?"}}
{"actor":{"display_login":"sohale"}}