Good day sir
Im just new here. I really need some help , Im trying to make a Simple 3d scene using babylonhx,
but when I try to run the sample code of BasicScene.hx as openfl project , html5 target , nothing happens. only a black screen. and also as js project , html5 target , it won’t compile.
and the code provided in the babylonhx website did’t compile due to incorrect parameter.
(maybe because my current babylonhx was updated) , so I changed it but still , black screen.
can you help me? please.
This is my Modified code of BasicScene.hx
package;
import com.babylonhx.cameras.FreeCamera;
import com.babylonhx.layer.Layer;
import com.babylonhx.lights.HemisphericLight;
import com.babylonhx.math.Vector3;
import com.babylonhx.mesh.Mesh;
import com.babylonhx.Scene;
/*
* Modified Code
*/
class Main
{
public function new(scene:Scene) {
// This creates and positions a free camera (non-mesh)
var camera = new FreeCamera("camera1", new Vector3(0, 5, -10), scene);
// This targets the camera to scene origin
camera.setTarget(Vector3.Zero());
// This attaches the camera to the canvas
camera.attachControl();
new Layer("background", "assets/img/graygrad.jpg", scene, true);
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new HemisphericLight("light1", new Vector3(0, 1, 0), scene);
// Default intensity is 1. Let's dim the light a small amount
light.intensity = 0.7;
var soption : SphereOptions =
{
segments: 2,
diameterX: 16,
diameterY: 16,
diameterZ: 16,
}
var goption : GroundOptions =
{
width: 6,
height: 6,
subdivision: 2
}
// Our built-in 'sphere' shape. Params: name, subdivs, size, scene
var sphere = Mesh.CreateSphere("sphere1", soption, scene);
// Move the sphere upward 1/2 its height
sphere.position.y = 1;
// Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene
var ground = Mesh.CreateGround("ground1", goption, scene);
scene.getEngine().runRenderLoop(function () {
scene.render();
});
}
}
and this is the Code provided in the website
package;
import com.babylonhx.cameras.FreeCamera;
import com.babylonhx.lights.HemisphericLight;
import com.babylonhx.layer.Layer;
import com.babylonhx.math.Vector3;
import com.babylonhx.mesh.Mesh;
import com.babylonhx.Scene;
class BasicScene {
public function new(scene:Scene) {
// This creates and positions a free camera (non-mesh)
var camera = new FreeCamera("camera1", new Vector3(0, 5, -10), scene);
// This targets the camera to scene origin
camera.setTarget(Vector3.Zero());
// This attaches the camera to the canvas
camera.attachControl();
new Layer("background", "assets/img/graygrad.jpg", scene, true);
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new HemisphericLight("light1", new Vector3(0, 1, 0), scene);
// Default intensity is 1. Let's dim the light a small amount
light.intensity = 0.7;
// Our built-in 'sphere' shape. Params: name, subdivs, size, scene
var sphere = Mesh.CreateSphere("sphere1", 16, 2, scene);
// Move the sphere upward 1/2 its height
sphere.position.y = 1;
// Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene
var ground = Mesh.CreateGround("ground1", 6, 6, 2, scene);
scene.getEngine().runRenderLoop(function () {
scene.render();
});
}
}
I just want to know things therefore I will able to create a some demo for my task in my Internship.
1. Proper creation of project for babylonhx or babylonhx+OpenFL , or any method that might help me to solve my problem.
2. Proper Entry Point , Basic Scene in babylonhx.
3. Is there any extra settings or some sort of configuration to change?
4. Is there any dependencies should I download and install? [I thought It will work without BabylonJS isn’t it?]
5. Any tips? Tricks? Hints? Please?
Thank you ladies , and gentlemen in advance.