Difference between revisions of "Tips for Verge3D devs"
From Verge3D Wiki
Jump to navigationJump to search(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:JavaScript]] | [[Category:JavaScript]] | ||
This page contains random tips and code snippets that Verge3D devs or [https://www.soft8soft.com/docs/manual/en/programmers_guide/Developer-Kit.html Verge3D DevKit] users may find useful for their work. | |||
== Getting v3d namespace from iframe == | |||
<syntaxhighlight lang="javascript"> | |||
document.getElementsByTagName("iframe")[0].contentWindow.v3d | |||
</syntaxhighlight> | |||
e.g. to print performance profile from the iframe: | |||
<syntaxhighlight lang="javascript"> | |||
document.getElementsByTagName("iframe")[0].contentWindow.v3d.apps[0].printPerformanceInfo() | |||
</syntaxhighlight> | |||
or to enable FPS counter: | |||
<syntaxhighlight lang="javascript"> | |||
document.getElementsByTagName("iframe")[0].contentWindow.v3d.apps[0].showFPS() | |||
</syntaxhighlight> | |||
== Debugging Verge3D render target == | == Debugging Verge3D render target == | ||
Line 31: | Line 51: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Key Triplets == | |||
There are several key triplets supported by Verge3D which are useful for debugging. To execute a triplet, wait until a Verge3D app finishes its loading, then press the same key thrice very quickly. | |||
* PPP — '''p'''rint '''p'''erformance '''p'''rofile. See [https://www.soft8soft.com/docs/manual/en/introduction/Performance-Bottlenecks.html#performance_profile here] for more info. | |||
* FFF — show/hide '''F'''PS counter in the upper left corner of the rendered canvas. | |||
* HHH — '''h'''alt/continue application rendering. | |||
== 3ds Max SDK requirements == | |||
See [https://help.autodesk.com/view/MAXDEV/2022/ENU/?guid=Max_Developer_Help_about_the_3ds_max_sdk_sdk_requirements_html here]. |
Revision as of 19:25, 12 October 2021
This page contains random tips and code snippets that Verge3D devs or Verge3D DevKit users may find useful for their work.
Getting v3d namespace from iframe
document.getElementsByTagName("iframe")[0].contentWindow.v3d
e.g. to print performance profile from the iframe:
document.getElementsByTagName("iframe")[0].contentWindow.v3d.apps[0].printPerformanceInfo()
or to enable FPS counter:
document.getElementsByTagName("iframe")[0].contentWindow.v3d.apps[0].showFPS()
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}!`);
}
}
}
Key Triplets
There are several key triplets supported by Verge3D which are useful for debugging. To execute a triplet, wait until a Verge3D app finishes its loading, then press the same key thrice very quickly.
- PPP — print performance profile. See here for more info.
- FFF — show/hide FPS counter in the upper left corner of the rendered canvas.
- HHH — halt/continue application rendering.
3ds Max SDK requirements
See here.