Difference between revisions of "Tips for Verge3D devs"

From Verge3D Wiki
Jump to navigationJump to search
(syntax highlight)
Line 1: Line 1:
[[Category:JavaScript]]
[[Category:JavaScript]]
== Debugging Verge3D render target ==
Use the following code to create a plane with the output of the given render target:
Use the following code to create a plane with the output of the given render target:


Line 11: Line 13:
planeMesh.position.x = 6;
planeMesh.position.x = 6;
v3d.apps[0].scene.add(planeMesh);
v3d.apps[0].scene.add(planeMesh);
</syntaxhighlight>
== Code Indentation Style ==
The K&R style, 4 spaces:
<syntaxhighlight lang="javascript">
function someFun() {
    const someConst = 10;
    const alwaysTrue = true;
    for (let i = 0; i < someConst; i++) {
        if (alwaysTrue) {
            console.log(`Hello ${i}!`);
        }
    }
}
</syntaxhighlight>
</syntaxhighlight>

Revision as of 08:14, 13 September 2021

Debugging Verge3D render target

Use the following code to create a plane with the output of the given render target:

// DONT FORGET TO REMOVE IT!
var texture = renderTarget.texture
var geometry = new v3d.PlaneBufferGeometry(3, 3);
var material = new v3d.MeshBasicMaterial();
material.map = texture;
var planeMesh = new v3d.Mesh(geometry, material);
planeMesh.position.x = 6;
v3d.apps[0].scene.add(planeMesh);

Code Indentation Style

The K&R style, 4 spaces:

function someFun() {
    const someConst = 10;
    const alwaysTrue = true;

    for (let i = 0; i < someConst; i++) {
        if (alwaysTrue) {
            console.log(`Hello ${i}!`);
        }
    }
}